fix 时段码数据处理first异常
This commit is contained in:
@@ -20,14 +20,17 @@ public class AssignmentService : IAssignmentService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly IDataProtectionProvider _dataProtectionProvider;
|
||||
private readonly ILogger<AssignmentService> _logger;
|
||||
private readonly FaceUrlOptions _faceUrlOptions;
|
||||
|
||||
public AssignmentService(IDbContext dbContext,
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
IOptions<FaceUrlOptions> options)
|
||||
IOptions<FaceUrlOptions> options,
|
||||
ILogger<AssignmentService> logger)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_dataProtectionProvider = dataProtectionProvider;
|
||||
_logger = logger;
|
||||
_faceUrlOptions = options.Value;
|
||||
}
|
||||
|
||||
@@ -36,7 +39,7 @@ public class AssignmentService : IAssignmentService
|
||||
var data = await GetDataAsync(request);
|
||||
if (data.IsEmpty()) return new List<DeviceTaskToDeviceByDeviceResponse>();
|
||||
|
||||
await HandlerOldDeviceGainfoAsync(data);
|
||||
//await HandlerOldDeviceGainfoAsync(data);
|
||||
await HandlerTimePeriodAsync(data);
|
||||
var deviceUploadInfos = await GetDeviceUploadRecordInfosAsync(data);
|
||||
|
||||
@@ -403,8 +406,11 @@ public class AssignmentService : IAssignmentService
|
||||
|
||||
|
||||
private async Task HandlerTimePeriodAsync(List<TaskDto> data)
|
||||
{
|
||||
try
|
||||
{
|
||||
var tasks = data.Where(x => x.EnableTimePeriod).Where(x => x.Type is DeviceTaskEnumType.TimePeriodAdd or DeviceTaskEnumType.TimePeriodDelete).ToList();
|
||||
if (tasks.IsEmpty()) return;
|
||||
var deviceUniqueNos = tasks.Select(x => x.DeviceUniqueNo).ToList();
|
||||
|
||||
var devices = await _dbContext.Queryable<DeviceEntity>().Where(x => deviceUniqueNos.Contains(x.UniqueNo)).ToListAsync();
|
||||
@@ -426,9 +432,14 @@ public class AssignmentService : IAssignmentService
|
||||
var basicTypes = await _dbContext.Queryable<BasicTypeEntity>().Where(x => x.Type == "timeperiod").ToListAsync();
|
||||
settings.ForEach(x => x.CardName = basicTypes.FirstOrDefault(p => p.Code == x.CardType.ToString())?.Display);
|
||||
|
||||
data.ForEach(item =>
|
||||
foreach (var item in data)
|
||||
{
|
||||
var device = devices.First(x => x.UniqueNo == item.DeviceUniqueNo);
|
||||
var device = devices.FirstOrDefault(x => x.UniqueNo == item.DeviceUniqueNo);
|
||||
if (device == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var templateCode = device.TemplateCode;
|
||||
var code = device.Code;
|
||||
|
||||
@@ -449,6 +460,11 @@ public class AssignmentService : IAssignmentService
|
||||
}
|
||||
|
||||
item.TimePeriods = tSettings;
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "处理时段码失败:{msg}", e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user