diff --git a/Src/Dlhis.Entity/Device/Entities/DeviceUploadLogEntity.cs b/Src/Dlhis.Entity/Device/Entities/DeviceUploadLogEntity.cs
index 10471948..2bc71180 100644
--- a/Src/Dlhis.Entity/Device/Entities/DeviceUploadLogEntity.cs
+++ b/Src/Dlhis.Entity/Device/Entities/DeviceUploadLogEntity.cs
@@ -1,4 +1,5 @@
-using Dlhis.Entity.Device.Enums;
+using Dlhis.Entity.Basic.Enums;
+using Dlhis.Entity.Device.Enums;
using Kurisu.AspNetCore.DataAccess.Entity;
using Kurisu.AspNetCore.DataAccess.SqlSugar;
using SqlSugar;
@@ -9,9 +10,15 @@ namespace Dlhis.Entity.Device.Entities;
[SugarTable(TableName = "DeviceUploadLog", TableDescription = "设备上传记录")]
public class DeviceUploadLogEntity : SugarBaseEntity, ITenantId
{
- [SugarColumn(IsNullable = true)]
+ [SugarColumn(IsNullable = false)]
public string SerialNo { get; set; }
+ ///
+ /// 设备code
+ ///
+ [SugarColumn(IsNullable = false)]
+ public Guid DeviceCode { get; set; }
+
///
/// 设备号
///
@@ -24,6 +31,12 @@ public class DeviceUploadLogEntity : SugarBaseEntity, ITenantId
[SugarColumn(IsNullable = true)]
public string UserUniqueNo { get; set; }
+ ///
+ /// 人员类型
+ ///
+ [SugarColumn(IsNullable = true, ColumnDescription = "人员类型", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
+ public GainfoUserTypeEnumType? UserType { get; set; }
+
///
/// 产生时间
///
@@ -31,24 +44,30 @@ public class DeviceUploadLogEntity : SugarBaseEntity, ITenantId
public DateTime RaiseDateTime { get; set; }
///
- /// 日志类型
+ /// 记录类型
///
[SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
public DeviceUploadLogTypeEnumType Type { get; set; }
+ ///
+ /// 是否要上传
+ ///
+ [SugarColumn(IsNullable = false, ColumnDataType = "bit", DefaultValue = "0")]
+ public bool NeedUpload { get; set; }
+
///
/// 同步数据
///
- [SugarColumn(ColumnDataType = "bit")]
+ [SugarColumn(IsNullable = false, ColumnDataType = "bit", DefaultValue = "0")]
public bool Sync { get; set; }
///
/// 是否有效
///
- [SugarColumn(ColumnDataType = "bit")]
+ [SugarColumn(IsNullable = false, ColumnDataType = "bit")]
public bool Status { get; set; }
[SugarColumn(IndexGroupNameList = new[] { "idx_DeviceUploadLog_TenantId" })]
public string TenantId { get; set; }
-}
+}
\ No newline at end of file
diff --git a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs
index 7dcdfc67..37a543e2 100644
--- a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs
+++ b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs
@@ -33,6 +33,11 @@ public class DeviceUploadLogService : IDeviceUploadLogService
var devices = await _dbContext.Queryable().Where(x => deviceUniqueNos.Contains(x.UniqueNo)).ToListAsync();
var existsDeviceUniqueNos = devices.Select(x => x.UniqueNo).ToList();
+ var userCodes = requests.Where(x => x.UserUniqueNo.IsPresent()).Select(x => x.UserUniqueNo).Distinct().ToList();
+ var gainfo1 = await _dbContext.Queryable().Where(x => userCodes.Contains(x.Code)).Select(x => new { x.Code, x.Type }).ToListAsync();
+ var gainfo2 = await _dbContext.Queryable().AS("GainfoLeave").Where(x => userCodes.Contains(x.Code)).Select(x => new { x.Code, x.Type }).ToListAsync();
+ var gainfos = gainfo1.Concat(gainfo2).DistinctBy(x => x.Code).ToList();
+
var inserts = new List();
foreach (var request in requests.Where(x => existsDeviceUniqueNos.Contains(x.DeviceUniqueNo)))
{
@@ -60,20 +65,20 @@ public class DeviceUploadLogService : IDeviceUploadLogService
inserts.Add(new DeviceUploadLogEntity
{
+ DeviceCode = device.Code,
DeviceUniqueNo = request.DeviceUniqueNo,
UserUniqueNo = request.UserUniqueNo,
+ UserType = gainfos.FirstOrDefault(x => x.Code == request.UserUniqueNo)?.Type,
RaiseDateTime = request.RaiseDateTime,
- SerialNo = request.SerialNo,
+ SerialNo = request.SerialNo ?? string.Empty,
Type = device.Type == DeviceTypeEnumType.Attendance
? DeviceUploadLogTypeEnumType.Attendance
- : device.Type == DeviceTypeEnumType.Door && device.AsAttendance
- ? DeviceUploadLogTypeEnumType.Attendance
- : DeviceUploadLogTypeEnumType.Door,
-
+ : DeviceUploadLogTypeEnumType.Door,
+ NeedUpload = device.Type == DeviceTypeEnumType.Attendance || (device.Type == DeviceTypeEnumType.Door && device.AsAttendance),
TenantId = device.TenantId,
Status = request.Status ?? true,
CreatedBy = 1,
- ModifiedBy = 1,
+ ModifiedBy = 1
});
}