From fddb0b12fcb460010eeb89160c1c206347ebc6dc Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 17 Jan 2024 10:42:09 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=89=B9=E9=87=8F=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dlhis.ScheduledTask.csproj | 1 + Src/Dlhis.ScheduledTask/Dockerfile | 1 + .../Controllers/AssignmentsController.cs | 7 ++--- .../Services/IAssignmentService.cs | 4 +-- .../Services/Implements/AssignmentService.cs | 27 +++++++++++-------- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj b/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj index 6d66acaf..918934a0 100644 --- a/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj +++ b/Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj @@ -22,6 +22,7 @@ + diff --git a/Src/Dlhis.ScheduledTask/Dockerfile b/Src/Dlhis.ScheduledTask/Dockerfile index 01d8ae26..8db1c218 100644 --- a/Src/Dlhis.ScheduledTask/Dockerfile +++ b/Src/Dlhis.ScheduledTask/Dockerfile @@ -8,6 +8,7 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src COPY ["Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj", "Src/Dlhis.ScheduledTask/"] COPY ["Src/Dlhis.Entity/Dlhis.Entity.csproj", "Src/Dlhis.Entity/"] +COPY ["Src/Dlhis.User.Api/Dlhis.User.Api.csproj", "Src/Dlhis.User.Api/"] RUN dotnet restore "Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj" COPY . . WORKDIR "/src/Src/Dlhis.ScheduledTask" diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/AssignmentsController.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/AssignmentsController.cs index 903e95bd..80dae44b 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/AssignmentsController.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Controllers/AssignmentsController.cs @@ -44,13 +44,14 @@ public class AssignmentsController : ControllerBase /// /// 更新任务状态 /// - /// + /// /// [HttpPost("taskstatus")] - public async Task UpdateDeviceTaskStatusAsync(UpdateDeviceTaskStatusRequest request) + public async Task UpdateDeviceTaskStatusAsync(List requests) { - await _assignmentService.UpdateDeviceTaskStatusAsync(request); + await _assignmentService.UpdateDeviceTaskStatusAsync(requests); } + /// /// 获取新人脸照片 /// diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/IAssignmentService.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/IAssignmentService.cs index 503af278..0e241174 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/IAssignmentService.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/IAssignmentService.cs @@ -16,9 +16,9 @@ public interface IAssignmentService : IScopeDependency /// /// 更新设备任务状态 /// - /// + /// /// - Task UpdateDeviceTaskStatusAsync(UpdateDeviceTaskStatusRequest request); + Task UpdateDeviceTaskStatusAsync(List requests); /// /// 获取新人脸照片 diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs index 92654640..bb595476 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Services/Implements/AssignmentService.cs @@ -188,10 +188,24 @@ public class AssignmentService : IAssignmentService } - public async Task UpdateDeviceTaskStatusAsync(UpdateDeviceTaskStatusRequest request) + public async Task UpdateDeviceTaskStatusAsync(List 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().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("操作失败,请重试"); }