diff --git a/Src/Dlhis.Basic/Common/ApiLog/Services/Implements/OperateLogService.cs b/Src/Dlhis.Basic/Common/ApiLog/Services/Implements/OperateLogService.cs
index b2a26087..3ddd9aaa 100644
--- a/Src/Dlhis.Basic/Common/ApiLog/Services/Implements/OperateLogService.cs
+++ b/Src/Dlhis.Basic/Common/ApiLog/Services/Implements/OperateLogService.cs
@@ -6,6 +6,7 @@ using Kurisu.AspNetCore.Authentication.Abstractions;
using Kurisu.AspNetCore.DataAccess.Dto;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
+using SqlSugar;
namespace Dlhis.Basic.Common.ApiLog.Services.Implements;
@@ -58,6 +59,7 @@ public class OperateLogService : IOperateLog
Operator = x.Operator,
CreateTime = x.CreateTime
})
+ .OrderBy(x => x.CreateTime, OrderByType.Desc)
.ToPageListAsync(request);
}
}
\ No newline at end of file
diff --git a/Src/Dlhis.Entity/Device/Entities/DeviceUploadLogEntity.cs b/Src/Dlhis.Entity/Device/Entities/DeviceUploadLogEntity.cs
index e8789cde..b6575422 100644
--- a/Src/Dlhis.Entity/Device/Entities/DeviceUploadLogEntity.cs
+++ b/Src/Dlhis.Entity/Device/Entities/DeviceUploadLogEntity.cs
@@ -76,6 +76,13 @@ public class DeviceUploadLogEntity : SugarBaseEntity, ITenantId
public string Image { get; set; }
+ ///
+ /// 网格信息
+ ///
+ [SugarColumn(IsNullable = true, ColumnDataType = "text")]
+ public string WorkGridInfo { 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 6336d998..d98f124b 100644
--- a/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs
+++ b/Src/Dlhis.ScheduledTask/DeviceUploadLog/Services/Implements/DeviceUploadLogService.cs
@@ -42,6 +42,28 @@ public class DeviceUploadLogService : IDeviceUploadLogService
var gainfo3 = await _dbContext.Queryable().Where(x => gainfoCardNos.Contains(x.Code)).Select(x => new { x.Code, x.Type }).ToListAsync();
var gainfos = gainfo1.Concat(gainfo2).Concat(gainfo3).DistinctBy(x => x.Code).ToList();
+ var userCodes2 = gainfos.Select(x => x.Code).Distinct().ToList();
+
+ var min = DateOnly.FromDateTime(requests.Min(x => x.RaiseDateTime)).AddDays(-1);
+ var max = DateOnly.FromDateTime(requests.Max(x => x.RaiseDateTime));
+
+ var workGridUsers = await _dbContext.Queryable()
+ .Where(x => userCodes2.Contains(x.UserCode))
+ .ToListAsync();
+
+ var workGridSchedules = await _dbContext.Queryable()
+ .Where(x => x.Date >= min && x.Date <= max)
+ .Where(x => userCodes2.Contains(x.UserCode)).ToListAsync();
+
+ var factories = devices.Select(x => x.TenantId).Distinct().ToList();
+ var workGridTimePeriods = await _dbContext.Queryable()
+ .Where(x => factories.Contains(x.TenantId))
+ .Select(x => new
+ {
+ x.Type, x.Start, x.End, x.Before, x.After, x.TenantId
+ })
+ .ToListAsync();
+
var inserts = new List();
foreach (var request in requests.Where(x => existsDeviceUniqueNos.Contains(x.DeviceUniqueNo)))
{
@@ -68,10 +90,70 @@ public class DeviceUploadLogService : IDeviceUploadLogService
var device = devices.First(x => x.UniqueNo == request.DeviceUniqueNo);
var userType = gainfos.FirstOrDefault(x => x.Code == request.UserUniqueNo)?.Type;
- var needUpload = userType is GainfoUserTypeEnumType.Normal or GainfoUserTypeEnumType.SecurityWhite && (device.Type == DeviceTypeEnumType.Attendance || (device.Type == DeviceTypeEnumType.Door && device.AsAttendance));
+ var needUpload = ((userType is GainfoUserTypeEnumType.Normal or GainfoUserTypeEnumType.SecurityWhite)
+ && (device.Type == DeviceTypeEnumType.Attendance || (device.Type == DeviceTypeEnumType.Door && device.AsAttendance)));
var dataType = device.Type == DeviceTypeEnumType.Attendance
? DeviceUploadLogTypeEnumType.Attendance
: DeviceUploadLogTypeEnumType.Door;
+
+ var workGridInfo = new WorkGridInfo();
+ var currentWorkGridTimePeriods = workGridTimePeriods.Where(x => x.TenantId == device.TenantId).ToList();
+ var workGridUser = workGridUsers.FirstOrDefault(x => x.UserCode == request.UserUniqueNo);
+ if (currentWorkGridTimePeriods.Any() && workGridUser != null)
+ {
+ workGridInfo.TimeSetting = currentWorkGridTimePeriods;
+ workGridInfo.WorkGrid = new
+ {
+ workGridUser.WorkGridCode
+ };
+ var currentDate = request.RaiseDateTime.Date;
+ var currentDateOnly = DateOnly.FromDateTime(currentDate);
+
+ var currentDayWorkGridTimePeriod = currentWorkGridTimePeriods.FirstOrDefault(x => x.Type == WorkGridTimePeriodEnumType.Day);
+ var currentDayWorkGridSchedule = workGridSchedules.FirstOrDefault(x => x.PeriodType == WorkGridTimePeriodEnumType.Day && x.Date == currentDateOnly);
+ if (currentDayWorkGridTimePeriod != null && currentDayWorkGridSchedule != null)
+ {
+ var start = currentDate.Add(currentDayWorkGridTimePeriod.Start.AddMinutes(currentDayWorkGridTimePeriod.Before).ToTimeSpan());
+ var end = currentDate.Add(currentDayWorkGridTimePeriod.End.AddMinutes(currentDayWorkGridTimePeriod.After).ToTimeSpan());
+
+ if (request.RaiseDateTime >= start && request.RaiseDateTime <= end)
+ {
+ workGridInfo.PeriodType = WorkGridTimePeriodEnumType.Day;
+ }
+ }
+
+ var currentNightWorkGridTimePeriod = currentWorkGridTimePeriods.FirstOrDefault(x => x.Type == WorkGridTimePeriodEnumType.Night);
+ var currentNightWorkGridSchedules = workGridSchedules
+ .Where(x => x.PeriodType == WorkGridTimePeriodEnumType.Night && (x.Date == currentDateOnly || x.Date == currentDateOnly.AddDays(-1))).ToList();
+ if (currentNightWorkGridTimePeriod != null && currentNightWorkGridSchedules.Any())
+ {
+ var startTime = currentNightWorkGridTimePeriod.Start.AddMinutes(currentNightWorkGridTimePeriod.Before);
+ var endTime = currentNightWorkGridTimePeriod.End.AddMinutes(currentNightWorkGridTimePeriod.After);
+
+ if (currentNightWorkGridSchedules.Any(x => x.Date == currentDateOnly))
+ {
+ var start = currentDateOnly.ToDateTime(startTime);
+ var end = currentDateOnly.ToDateTime(new TimeOnly(23, 59, 59, 999));
+
+ if (request.RaiseDateTime >= start && request.RaiseDateTime <= end)
+ {
+ workGridInfo.PeriodType = WorkGridTimePeriodEnumType.Night;
+ }
+ }
+
+ if (currentNightWorkGridSchedules.Any(x => x.Date == currentDateOnly.AddDays(-1)))
+ {
+ var start = currentDateOnly.AddDays(-1).ToDateTime(startTime);
+ var end = currentDateOnly.ToDateTime(endTime);
+
+ if (request.RaiseDateTime >= start && request.RaiseDateTime <= end)
+ {
+ workGridInfo.PeriodType = WorkGridTimePeriodEnumType.Night;
+ }
+ }
+ }
+ }
+
inserts.Add(new DeviceUploadLogEntity
{
DeviceCode = device.Code,
@@ -85,6 +167,7 @@ public class DeviceUploadLogService : IDeviceUploadLogService
TenantId = device.TenantId,
Status = request.Status ?? true,
Image = request.Image,
+ WorkGridInfo = workGridInfo.ToJson(),
CreatedBy = 1,
ModifiedBy = 1
});
@@ -316,4 +399,13 @@ public class DeviceUploadLogService : IDeviceUploadLogService
Data = r
};
}
+}
+
+public class WorkGridInfo
+{
+ public object WorkGrid { get; set; }
+ public WorkGridTimePeriodEnumType? PeriodType { get; set; }
+ public object TimeSetting { get; set; }
+
+ public bool NeedUpload => WorkGrid != null && PeriodType.HasValue;
}
\ No newline at end of file