Merge branch 'development'
This commit is contained in:
@@ -12,7 +12,6 @@ using Newtonsoft.Json.Linq;
|
||||
using Kurisu.AspNetCore.Utils;
|
||||
using Dlhis.ScheduledTask.TaskAssignment.Dto;
|
||||
using Kurisu.AspNetCore.CustomClass;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
|
||||
namespace Dlhis.ScheduledTask.TaskAssignment.Services.Implements;
|
||||
@@ -153,12 +152,13 @@ public class AssignmentService : IAssignmentService
|
||||
|
||||
case DeviceTaskEnumType.UploadRecord:
|
||||
{
|
||||
var timeInfo = deviceUploadInfos[d];
|
||||
dto.Info = new UploadRecordToDeviceResponse
|
||||
{
|
||||
DateTimePeriod = new DateTimePeriod
|
||||
{
|
||||
Start = deviceUploadInfos.TryGetValue(d, out var dt) ? (dt ?? DateTime.Now) : DateTime.Now,
|
||||
End = DateTime.Now.AddDays(1)
|
||||
Start = timeInfo.Item1,
|
||||
End = timeInfo.Item2
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -262,8 +262,6 @@ public class AssignmentService : IAssignmentService
|
||||
.WhereIF(request.Brand.IsPresent(), (deviceTask, device, deviceTemplate) => deviceTemplate.Brand == request.Brand)
|
||||
.Where((deviceTask, device, deviceTemplate, ga, gaLeave, department, deviceRegistry) =>
|
||||
device.HeartbeatInterval == 0 || SqlFunc.DateAdd(deviceRegistry.LastHeartbeatTime, device.HeartbeatInterval, DateType.Second) > DateTime.Now)
|
||||
#if !DEBUG
|
||||
#endif
|
||||
.OrderBy(deviceTask => new { deviceTask.CreateTime, Priority = SqlFunc.Desc(deviceTask.Priority) })
|
||||
.Select((deviceTask, device, deviceTemplate, ga, gaLeave, department) => new TaskDto
|
||||
{
|
||||
@@ -328,15 +326,21 @@ public class AssignmentService : IAssignmentService
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<Dictionary<string, DateTime?>> GetDeviceUploadRecordInfosAsync(List<TaskDto> data)
|
||||
private async Task<Dictionary<string, (DateTime, DateTime)>> GetDeviceUploadRecordInfosAsync(List<TaskDto> data)
|
||||
{
|
||||
if (data.All(x => x.Type != DeviceTaskEnumType.UploadRecord))
|
||||
{
|
||||
return new Dictionary<string, DateTime?>();
|
||||
return new Dictionary<string, (DateTime, DateTime)>();
|
||||
}
|
||||
|
||||
var deviceNos = data.Select(x => x.DeviceUniqueNo).Distinct().ToList();
|
||||
var result = new Dictionary<string, DateTime?>(deviceNos.Count);
|
||||
var result = new Dictionary<string, (DateTime, DateTime)>(deviceNos.Count);
|
||||
|
||||
var manualSettings = await _dbContext.Queryable<DeviceUploadLogManuallyEntity>().Where(x => deviceNos.Contains(x.DeviceNo))
|
||||
.Where(x => x.IsFinished == false)
|
||||
.OrderBy(x => x.CreateTime)
|
||||
.Select(x => new { x.Id, x.DeviceNo, x.Start, x.End })
|
||||
.ToListAsync();
|
||||
|
||||
var logInfos = await _dbContext.Queryable<DeviceUploadLogEntity>()
|
||||
.GroupBy(x => x.DeviceUniqueNo)
|
||||
@@ -347,12 +351,27 @@ public class AssignmentService : IAssignmentService
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var commonEnd = DateTime.Now.AddDays(1);
|
||||
foreach (var item in deviceNos)
|
||||
{
|
||||
var logInfo = logInfos.FirstOrDefault(x => x.DeviceUniqueNo == item);
|
||||
result.Add(item, logInfo?.RaiseDateTime);
|
||||
var setting = manualSettings.FirstOrDefault(x => x.DeviceNo == item);
|
||||
if (setting != null)
|
||||
{
|
||||
result.Add(item, (setting.Start, setting.End));
|
||||
}
|
||||
else
|
||||
{
|
||||
var logInfo = logInfos.FirstOrDefault(x => x.DeviceUniqueNo == item);
|
||||
result.Add(item, logInfo == null ? (DateTime.Now.AddMinutes(-10), commonEnd) : (logInfo.RaiseDateTime, commonEnd));
|
||||
}
|
||||
}
|
||||
|
||||
//更新为已处理
|
||||
await _dbContext.Updateable<DeviceUploadLogManuallyEntity>()
|
||||
.SetColumns(x => x.IsFinished == true)
|
||||
.Where(x => manualSettings.Select(p => p.Id).Contains(x.Id))
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user