From f0d196021b775a49210145055f069e7a110d5514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Fri, 1 Nov 2024 14:19:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AD=90=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Constants/MultiLanguageConst.cs | 2 + .../TaskInteraction/Method/FeeTaskService.cs | 2 +- .../TaskInteraction/Method/TaskService.cs | 46 ++++++++++++++----- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs index 942ce322..63ded1eb 100644 --- a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs +++ b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs @@ -1570,6 +1570,8 @@ public static class MultiLanguageConst public const string TypeOrName = "TypeOrName"; [Description("此任务尚有未完成的优先级别更高的子任务或前置条件")] public const string HigherUnfinishedItems = "Higher_Unfinished_Items"; + [Description("无法获取主任务信息")] + public const string MainTaskNotFound = "Main_Task_NotFound"; #endregion #region 任务台相关 diff --git a/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/FeeTaskService.cs b/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/FeeTaskService.cs index 93f19d14..91d20ba5 100644 --- a/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/FeeTaskService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/FeeTaskService.cs @@ -42,7 +42,7 @@ namespace DS.WMS.Core.TaskInteraction.Method if (request.Steps?.Count > 0) { - if (request.Steps.Where(x => x.Type != StepType.NotSpecified).GroupBy(x => x.Type).Select(x => x.Key).Count() == 1) + if (request.Steps.Where(x => x.Type != StepType.NotSpecified).GroupBy(x => x.Type).Select(x => x.Key).Count() > 1) return DataResult.FailedWithDesc(nameof(MultiLanguageConst.DuplicateStepType)); if (request.Steps.Any(x => x.Type == StepType.NotSpecified && string.IsNullOrEmpty(x.Name))) diff --git a/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/TaskService.cs b/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/TaskService.cs index 3622e262..6cdf89d6 100644 --- a/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/TaskService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskInteraction/Method/TaskService.cs @@ -474,7 +474,31 @@ namespace DS.WMS.Core.TaskInteraction.Method x.UpdateTime }).ExecuteCommandAsync(); - DataResult result = await ManagerService.SetTaskStatusWithBsno(request.BusinessId, request.TaskType, request.TaskStatus, DateTime.Now, false, request.TaskDesc); + DataResult result; + if (request.ParentId.HasValue || request.ParentBusinessId.HasValue) //设置子任务状态 + { + var parentTask = await TenantDb.Queryable().Where(x => x.BusinessType == request.BusinessType) + .WhereIF(request.ParentId.HasValue, x => x.Id == request.ParentId) + .WhereIF(request.ParentBusinessId.HasValue, x => x.BusinessId == request.ParentBusinessId && x.TaskType == request.ParentTaskType) + .Select(x => new + { + x.BusinessId, + x.TaskType + }).FirstAsync(); + if (parentTask == null) + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.MainTaskNotFound)); + + result = await ManagerService.SetTaskStatusWithBsno( + parentTask.BusinessId, parentTask.TaskType, + request.TaskStatus, DateTime.Now, false, request.TaskDesc, + childBsno: request.BusinessId, + childTaskBaseTypeEnum: request.TaskType); + } + else + { + result = await ManagerService.SetTaskStatusWithBsno(request.BusinessId, request.TaskType, request.TaskStatus, DateTime.Now, false, request.TaskDesc); + } + if (!result.Succeeded) return DataResult.Failed(result.Message, result.MultiCode); @@ -538,17 +562,16 @@ namespace DS.WMS.Core.TaskInteraction.Method if (request.Steps == null || request.Steps.Count == 0) return DataResult.FailedWithDesc(nameof(MultiLanguageConst.SubTaskCannotNull)); + BusinessTask task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).FirstAsync(); + if (task == null) + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskNotExists)); + if (task.TaskStatus == TaskStatusEnum.Complete) + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted)); + if (useTransaction) await TenantDb.Ado.BeginTranAsync(); - try { - BusinessTask task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).FirstAsync(); - if (task == null) - return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskNotExists)); - if (task.TaskStatus == TaskStatusEnum.Complete) - return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted)); - var allSteps = await TenantDb.Queryable().Where(x => x.TaskId == task.Id && !x.IsCompleted).OrderBy(x => x.Priority) .Select(x => new TaskStep { @@ -598,10 +621,11 @@ namespace DS.WMS.Core.TaskInteraction.Method if (request.AutoSync && allSteps.Count > 0 && allSteps.Count == allSteps.Count(x => x.IsCompleted)) { - var result = await SetTaskStatusAsync(new TaskUpdateRequest + DataResult result = await SetTaskStatusAsync(new TaskUpdateRequest { - BusinessId = task.BusinessId, - BusinessType = task.BusinessType, + ParentId = request.ParentId, + BusinessId = request.BusinessId, + BusinessType = request.BusinessType, TaskTypeName = request.TaskTypeName, TaskStatus = TaskStatusEnum.Complete }, false);