fix 批量更新任务状态

This commit is contained in:
2024-01-17 10:42:09 +08:00
parent fc5ee32f93
commit fddb0b12fc
5 changed files with 24 additions and 16 deletions

View File

@@ -188,10 +188,24 @@ public class AssignmentService : IAssignmentService
}
public async Task UpdateDeviceTaskStatusAsync(UpdateDeviceTaskStatusRequest request)
public async Task UpdateDeviceTaskStatusAsync(List<UpdateDeviceTaskStatusRequest> requests)
{
for (int i = 0; i < 5; i++)
foreach (var request in requests)
{
//for (int i = 0; i < 5; i++)
//{
// if (effect == 0)
// {
// continue;
// }
// return;
//}
//throw new UserFriendlyException("操作失败,请重试");
var deviceTask = await _dbContext.Queryable<DeviceTaskEntity>().Where(x => x.Id == request.TaskId).SingleAsync();
deviceTask.ThrowIfNull("设备任务不存在");
(deviceTask.Status != DeviceTaskStatusEnumType.Process)
@@ -206,16 +220,7 @@ public class AssignmentService : IAssignmentService
.SetColumns(x => x.ModifiedTime == DateTime.Now)
.Where(x => x.Id == request.TaskId && x.Version == deviceTask.Version)
.ExecuteCommandAsync();
if (effect == 0)
{
continue;
}
return;
}
throw new UserFriendlyException("操作失败,请重试");
}