From cc96089e9215d3e3d5159459378999b0552c7242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Tue, 13 Aug 2024 16:19:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=8F=E8=94=BD=E6=96=B0=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Op/Method/TaskInteraction/TaskService.cs | 57 ++++++++++++------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs index f09a0251..fcfe61b1 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs @@ -1,5 +1,4 @@ using DS.Module.Core; -using DS.Module.Core.Condition; using DS.Module.Core.Data; using DS.Module.Core.Helpers; using DS.WMS.Core.Flow.Dtos; @@ -18,7 +17,6 @@ using DS.WMS.Core.TaskPlat.Interface; using Masuit.Tools; using Masuit.Tools.Systems; using Microsoft.Extensions.DependencyInjection; -using Newtonsoft.Json; using SqlSugar; namespace DS.WMS.Core.Op.Method.TaskInteraction @@ -74,6 +72,23 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction ActionService = new Lazy(provider.GetRequiredService()); } + /// + /// 获取给定任务的下一默认任务类型 + /// + /// 任务信息 + /// + internal static async Task GetDefaultNextTypeAsync(BusinessTask current) + { + if (current.TaskType == TaskBaseTypeEnum.NOT_SPECIFIED || current.TaskType == TaskBaseTypeEnum.WAIT_CHECKOUT_BILL) //流程的最后一步 + return null; + + int currentTypeVal = (int)current.TaskType; + if (currentTypeVal >= 300) //300开始的枚举值为可选服务项目,不存在前后关联性 + return null; + + return (TaskBaseTypeEnum)(currentTypeVal + 1); + } + /// /// 获取给定任务的下一任务类型 /// @@ -258,8 +273,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction if (task != null && task.TaskStatus != TaskStatusEnum.Cancel) return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskExists)); - if (await ShouldSkipAsync(request)) - return DataResult.Success; + //if (await ShouldSkipAsync(request)) + // return DataResult.Success; long tenatId = long.Parse(User.TenantId); string tenatName = Db.Queryable().Where(x => x.Id == tenatId).Select(x => x.Name).First(); @@ -347,7 +362,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction CreateBy = long.Parse(User.UserId), CreateTime = DateTime.Now }; - task.NextType = await GetNextTypeAsync(task); + task.NextType = await GetDefaultNextTypeAsync(task); await TenantDb.Insertable(task).ExecuteCommandAsync(); //审核任务需创建工作流 @@ -380,21 +395,21 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction } } - internal async Task ShouldSkipAsync(TaskRequest request) - { - var configList = await TenantDb.Queryable().Where(x => x.TaskType == request.TaskType && x.IsSkip) - .Select(x => new { x.Id, x.SourceName, x.MatchCondition }).ToListAsync(); - if (configList.Count > 0) - { - var conditionList = configList.Select(x => new { x.Id, x.SourceName, MatchCondition = JsonConvert.DeserializeObject(x.MatchCondition) }).ToList(); - foreach (var item in conditionList) - item.MatchCondition.SourceName = item.SourceName; + //internal async Task ShouldSkipAsync(TaskRequest request) + //{ + // var configList = await TenantDb.Queryable().Where(x => x.TaskType == request.TaskType && x.IsSkip) + // .Select(x => new { x.Id, x.SourceName, x.MatchCondition }).ToListAsync(); + // if (configList.Count > 0) + // { + // var conditionList = configList.Select(x => new { x.Id, x.SourceName, MatchCondition = JsonConvert.DeserializeObject(x.MatchCondition) }).ToList(); + // foreach (var item in conditionList) + // item.MatchCondition.SourceName = item.SourceName; - return await ActionService.Value.IsMatchAsync(request, conditionList.Select(x => x.MatchCondition)); - } + // return await ActionService.Value.IsMatchAsync(request, conditionList.Select(x => x.MatchCondition)); + // } - return false; - } + // return false; + //} /// /// 创建并启动审批工作流 @@ -516,8 +531,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction if (useTransaction) await TenantDb.Ado.CommitTranAsync(); - ActionService.Value.TriggerAction(task); - return DataResult.Success(task.TaskStatus == TaskStatusEnum.Complete ? await GetNextTypeAsync(task) : null); + //ActionService.Value.TriggerAction(task); + return DataResult.Success(task.TaskStatus == TaskStatusEnum.Complete ? await GetDefaultNextTypeAsync(task) : null); } catch (Exception ex) { @@ -676,7 +691,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction /// protected internal async Task>> GetRecvUsersAsync(long id, BusinessType businessType, List taskTypes) { - var biz = ActionService.Value.GetBusinessDataAsync(id, businessType); + var biz = await ActionService.Value.GetBusinessDataAsync(id, businessType); var result = await TaskAllocationService.Value.GetAllotUserBySeaExportId(taskTypes, id, new TaskFlowDataContext( (TaskFlowDataNameConst.Business, biz) ));