fix 老档案数据处理

This commit is contained in:
2025-02-10 11:32:24 +08:00
parent 565692b045
commit ee0eec2745

View File

@@ -39,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);
@@ -194,42 +194,45 @@ public class AssignmentService : IAssignmentService
task.ModifiedTime = now;
});
// if (await _dbContext.Queryable<OldDeviceGainfoEntity>().Where(x => x.Status != OldDeviceGainfoEnumType.Deleted).AnyAsync())
// {
// var dCodes = await _dbContext.Queryable<DeviceTaskEntity>()
// .LeftJoin<GainfoEntity>((x, ga) => x.UserNo == ga.No)
// .Where(x => taskIds.Contains(x.Id))
// .Where(x => x.Status == DeviceTaskStatusEnumType.Process)
// .Select((x, ga) => new
// {
// x.DeviceUniqueNo,
// ga.Code,
// ga.No
// })
// .ToListAsync();
//
// var oldDeviceGainfoWhere = LinqExpressionExtensions.False<OldDeviceGainfoEntity>();
// dCodes.ForEach(item => { oldDeviceGainfoWhere = oldDeviceGainfoWhere.Or(x => x.Code == item.Code && x.DeviceUniqueNo == item.DeviceUniqueNo); });
// var oldData = await _dbContext.Queryable<OldDeviceGainfoEntity>().Where(x => x.Status == OldDeviceGainfoEnumType.Wait)
// .Where(oldDeviceGainfoWhere)
// .ToListAsync();
//
// oldData.ForEach(d =>
// {
// var current = dCodes.First(x => x.Code == d.Code);
// var task = deviceTasks.FirstOrDefault(x => x.UserNo == current.No && x.DeviceUniqueNo == current.DeviceUniqueNo);
// if (task != null)
// {
// d.Status = task.Status == DeviceTaskStatusEnumType.Success
// ? OldDeviceGainfoEnumType.Deleted
// : OldDeviceGainfoEnumType.Error;
//
// d.Remark = task.ResultMessage;
// }
// });
//
// await _dbContext.UpdateAsync(oldData);
// }
if (await _dbContext.Queryable<OldDeviceGainfoEntity>().Where(x => x.Status != OldDeviceGainfoEnumType.Deleted).AnyAsync())
{
var dCodes = await _dbContext.Queryable<DeviceTaskEntity>()
.LeftJoin<GainfoEntity>((x, ga) => x.UserNo == ga.No)
.Where(x => taskIds.Contains(x.Id))
.Where(x => x.Status == DeviceTaskStatusEnumType.Process)
.Select((x, ga) => new
{
x.DeviceUniqueNo,
ga.Code,
ga.No
})
.ToListAsync();
var oldDeviceGainfoWhere = LinqExpressionExtensions.False<OldDeviceGainfoEntity>();
dCodes.ForEach(item => { oldDeviceGainfoWhere = oldDeviceGainfoWhere.Or(x => x.Code == item.Code && x.DeviceUniqueNo == item.DeviceUniqueNo); });
var oldData = await _dbContext.Queryable<OldDeviceGainfoEntity>().Where(x => x.Status == OldDeviceGainfoEnumType.Wait)
.Where(oldDeviceGainfoWhere)
.ToListAsync();
oldData.ForEach(d =>
{
var current = dCodes.FirstOrDefault(x => x.Code == d.Code);
if (current != null)
{
var task = deviceTasks.FirstOrDefault(x => x.UserNo == current.No && x.DeviceUniqueNo == current.DeviceUniqueNo);
if (task != null)
{
d.Status = task.Status == DeviceTaskStatusEnumType.Success
? OldDeviceGainfoEnumType.Deleted
: OldDeviceGainfoEnumType.Error;
d.Remark = task.ResultMessage;
}
}
});
await _dbContext.UpdateAsync(oldData);
}
await _dbContext.UpdateAsync(deviceTasks);
@@ -391,7 +394,8 @@ public class AssignmentService : IAssignmentService
{
var oldDeviceGainfoWhere = LinqExpressionExtensions.False<OldDeviceGainfoEntity>();
data.ForEach(item => { oldDeviceGainfoWhere = oldDeviceGainfoWhere.Or(x => x.Code == item.UserCode && x.DeviceUniqueNo == item.DeviceUniqueNo); });
var oldData = await _dbContext.Queryable<OldDeviceGainfoEntity>().Where(x => x.Status == OldDeviceGainfoEnumType.Wait || x.Status == OldDeviceGainfoEnumType.Error)
var oldData = await _dbContext.Queryable<OldDeviceGainfoEntity>()
.Where(x => x.Status == OldDeviceGainfoEnumType.Wait || x.Status == OldDeviceGainfoEnumType.Error)
.Where(oldDeviceGainfoWhere)
.ToListAsync();