feat 老档案号任务处理

This commit is contained in:
2024-07-02 18:28:14 +08:00
parent 2c8f7a016f
commit 4c12571c29
2 changed files with 52 additions and 0 deletions

View File

@@ -219,6 +219,43 @@ public class AssignmentService : IAssignmentService
task.ModifiedTime = now;
});
if (await _dbContext.Queryable<OldDeviceGainfoEntity>().Where(x => x.Status == OldDeviceGainfoEnumType.Wait).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 task = deviceTasks.FirstOrDefault(x => x.UserNo == d.No && x.DeviceUniqueNo == d.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);
}
@@ -299,6 +336,19 @@ public class AssignmentService : IAssignmentService
throw new VersionExceptions("version exceptions");
}
var oldDeviceGainfoWhere = LinqExpressionExtensions.False<OldDeviceGainfoEntity>();
page.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)
.Where(oldDeviceGainfoWhere)
.ToListAsync();
page.Data.ForEach(item =>
{
var o = oldData.FirstOrDefault(x => x.Code == item.UserCode && x.DeviceUniqueNo == item.DeviceUniqueNo);
if (o != null)
item.OldUserNo = o.No;
});
return page.Data;
}, 5);