diff --git a/ds-wms-service/DS.Module.Core/Constants/TaskFlowDataNameConst.cs b/ds-wms-service/DS.Module.Core/Constants/TaskFlowDataNameConst.cs index dc900d43..449e0444 100644 --- a/ds-wms-service/DS.Module.Core/Constants/TaskFlowDataNameConst.cs +++ b/ds-wms-service/DS.Module.Core/Constants/TaskFlowDataNameConst.cs @@ -72,5 +72,11 @@ namespace DS.Module.Core /// /// 类型:long public const string BusinessId = "BusinessId"; + + /// + /// 客户端参数 + /// + /// 类型:Param{T} + public const string ClientParam = "ClientParam"; } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Interface/TaskInteraction/IActionManagerService.cs b/ds-wms-service/DS.WMS.Core/Op/Interface/TaskInteraction/IActionManagerService.cs index e5350ab2..2d6b86c0 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Interface/TaskInteraction/IActionManagerService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Interface/TaskInteraction/IActionManagerService.cs @@ -66,8 +66,9 @@ namespace DS.WMS.Core.Op.Interface.TaskInteraction /// /// 任务信息 /// 是否包含订单数据 + /// 附加参数 /// - Task TriggerActionAsync(BusinessTask businessTask, bool includeOrder = false); + Task TriggerActionAsync(BusinessTask businessTask, bool includeOrder = false, IDictionary? additionalData = null); Task TriggerTestAsync(TaskBaseTypeEnum taskType, long? id); } diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs index 0421aa75..210ea565 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs @@ -185,15 +185,12 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction /// /// 任务信息 /// 是否包含订单数据 + /// 附加参数 /// - public async Task TriggerActionAsync(BusinessTask businessTask, bool includeOrder = false) + public async Task TriggerActionAsync(BusinessTask businessTask, bool includeOrder = false, IDictionary? additionalData = null) { ArgumentNullException.ThrowIfNull(businessTask, nameof(businessTask)); - ////目前只限制任务完成才触发 - //if (businessTask.TaskStatus != TaskStatusEnum.Complete) - // return; - TaskFlowDataContext dataContext = new( (TaskFlowDataNameConst.BusinessTask, businessTask) ); @@ -204,6 +201,11 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction dataContext[TaskFlowDataNameConst.Business] = biz; } + if (additionalData != null) + { + foreach (var item in additionalData) + dataContext[item.Key] = item.Value; + } TaskFlowRuner taskFlow = new(TenantDb, ServiceProvider); await taskFlow.RunWithBsno(businessTask.TaskType, businessTask.BusinessId, dataContext); diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionSelector/BookingSelector.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionSelector/BookingSelector.cs index a251c3e0..f4d11eb5 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionSelector/BookingSelector.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionSelector/BookingSelector.cs @@ -12,7 +12,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionSelector /// public class BookingSelector : IActionSelector { - const string Booking_Route = "BookingRoute"; + internal const string Booking_Route = "BookingRoute"; public async Task GetActionExecutor(ActionExecutionContext context) { 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 98ee11ab..23aed8eb 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,10 +1,12 @@ -using DS.Module.Core; +using System.Threading.Tasks; +using DS.Module.Core; using DS.Module.Core.Data; using DS.Module.Core.Helpers; using DS.WMS.Core.Flow.Dtos; using DS.WMS.Core.Flow.Entity; using DS.WMS.Core.Flow.Interface; using DS.WMS.Core.Flow.Method; +using DS.WMS.Core.Info.Interface; using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity.TaskInteraction; @@ -19,6 +21,7 @@ using Masuit.Tools; using Masuit.Tools.Systems; using Microsoft.Extensions.DependencyInjection; using SqlSugar; +using static DS.WMS.Core.Op.Method.TaskInteraction.ActionSelector.BookingSelector; namespace DS.WMS.Core.Op.Method.TaskInteraction { @@ -65,6 +68,11 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction /// protected ISeaExportService OpService { get; private set; } + /// + /// 客户端参数服务 + /// + protected IClientParamService ClientParamService { get; private set; } + /// /// 初始化 /// @@ -77,6 +85,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction FlowService = provider.GetRequiredService(); ActionService = provider.GetRequiredService(); OpService = provider.GetRequiredService(); + ClientParamService = provider.GetRequiredService(); TenantDb.QueryFilter.Clear(); } @@ -373,7 +382,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction }; if (!task.NextType.HasValue) task.NextType = await GetNextTypeAsync(task); - + await TenantDb.Insertable(task).ExecuteCommandAsync(); //审核任务需创建工作流 @@ -527,7 +536,20 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction if (useTransaction) await TenantDb.Ado.CommitTranAsync(); - ActionService.TriggerActionAsync(task); + if (task.TaskStatus == TaskStatusEnum.Complete)//目前限制任务完成才触发 + { + Dictionary? dic = null; + if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT) + { + dic = new Dictionary(); + var param = await ClientParamService.GetParamAsync(task.BusinessId, Booking_Route, + (x, y) => x.CustomerId == y.ForwarderId); + dic[TaskFlowDataNameConst.ClientParam] = param; + } + + ActionService.TriggerActionAsync(task, additionalData: dic); + } + return DataResult.Success(task.TaskStatus == TaskStatusEnum.Complete ? await GetNextTypeAsync(task) : null); } catch (Exception ex)