From 37bc0e01a9a6166e701b645223b2b0d6f00225bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Fri, 23 Aug 2024 15:26:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A7=A6=E5=8F=91=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=AE=A2=E8=88=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskInteraction/IActionManagerService.cs | 9 ++++- .../TaskInteraction/ActionManagerService.cs | 33 ++++++++++++++++++- .../ActionSelector/BookingSelector.cs | 10 ++++-- .../Op/Method/TaskInteraction/TaskService.cs | 5 +-- .../Controllers/SeaExportTaskController.cs | 14 ++++++++ 5 files changed, 65 insertions(+), 6 deletions(-) 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 8bb70911..98057bab 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 @@ -70,10 +70,17 @@ namespace DS.WMS.Core.Op.Interface.TaskInteraction /// Task TriggerActionAsync(BusinessTask businessTask, bool includeOrder = false, IDictionary? additionalData = null); - /// /// 执行放舱任务(任务台使用) /// Task SpaceReleaseTask(TaskFlowDataContext dataContext); + + /// + /// 自动订舱 + /// + /// 业务ID + /// 业务类型 + /// + Task AutomaticBooking(long businessId, BusinessType businessType); } } 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 6480bc9f..5c732d85 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 @@ -7,6 +7,7 @@ using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity.TaskInteraction; using DS.WMS.Core.Op.Interface.TaskInteraction; +using DS.WMS.Core.Op.Method.TaskInteraction.ActionSelector; using DS.WMS.Core.TaskPlat; using Fasterflect; using Masuit.Tools; @@ -234,6 +235,37 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction await taskFlow.RunWithBsno(businessTask.TaskType, businessTask.BusinessId, dataContext); } + /// + /// 自动订舱 + /// + /// 业务ID + /// 业务类型 + /// + public async Task AutomaticBooking(long businessId, BusinessType businessType) + { + try + { + var businessTask = await TenantDb.Queryable().Where( + x => x.BusinessId == businessId && x.BusinessType == businessType && x.TaskType == TaskBaseTypeEnum.WAIT_BOOKING).FirstAsync(); + if (businessTask == null) + return DataResult.FailedWithDesc(MultiLanguageConst.TaskStatusNotSupported); + + TaskFlowDataContext dataContext = new + ( + (TaskFlowDataNameConst.BusinessTask, businessTask), + ("TypeName", typeof(BookingSelector).AssemblyQualifiedName) + ); + + await ExecuteAsync(dataContext); + return DataResult.Success; + } + catch (Exception ex) + { + await ex.LogAsync(Db); + return DataResult.FailedWithDesc(MultiLanguageConst.Operation_Failed); + } + } + /// /// 执行动作 /// @@ -250,7 +282,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction ServiceProvider = ServiceProvider }; - foreach (var key in dataContext.Keys) context.AdditionalData[key] = dataContext[key]; 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 a1aeda86..d662986f 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 @@ -1,4 +1,5 @@ -using DS.WMS.Core.Info.Interface; +using DS.Module.Core; +using DS.WMS.Core.Info.Interface; using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Interface.TaskInteraction; @@ -18,10 +19,15 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionSelector public async Task GetActionExecutor(ActionExecutionContext context) { + //var taskService = context.ServiceProvider.GetRequiredService(); + //var list = await taskService.GetTasks(context.TaskInfo.BusinessId, context.TaskInfo.BusinessType, TaskBaseTypeEnum.WAIT_BOOKING); + //if (list.Data?.Count > 0 && list.Data?[0].TaskStatus == TaskStatusEnum.Complete) + // return new DefaultActionExecutor(); + switch (context.TaskInfo.BusinessType) { case BusinessType.OceanShippingExport: - var seTaskService = context.ServiceProvider.GetService(); + var seTaskService = context.ServiceProvider.GetRequiredService(); var order = await seTaskService.AsQueryable(x => x.Id == context.TaskInfo.BusinessId).Select(x => new { x.BookingNo, 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 4f3f8291..b0e2abc0 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 @@ -99,7 +99,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction TenantDb.QueryFilter.Clear(); } - /// /// 创建关联任务 /// @@ -661,8 +660,10 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction public virtual async Task UpdateBusinessAsync(FlowCallback callback) { ArgumentNullException.ThrowIfNull(callback, nameof(callback)); + if (callback.Type == null || callback.BusinessType == null) + return; - var taskType = TypeMappings.Where(x => x.Value == callback.Type.GetValueOrDefault()).Select(x => x.Key).FirstOrDefault(); + var taskType = TypeMappings.Where(x => x.Value == callback.Type.Value).Select(x => x.Key).FirstOrDefault(); var req = new TaskUpdateRequest { BusinessId = callback.BusinessId, diff --git a/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportTaskController.cs b/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportTaskController.cs index d26069b9..a4996bc5 100644 --- a/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportTaskController.cs +++ b/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportTaskController.cs @@ -1,5 +1,6 @@ using System.Net; using DS.Module.Core; +using DS.WMS.Core; using DS.WMS.Core.Flow.Dtos; using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Entity; @@ -58,6 +59,19 @@ namespace DS.WMS.OpApi.Controllers return await logService.ReadLogAsync(businessId, businessType); } + /// + /// 触发自动订舱 + /// + /// + /// 业务ID + /// 业务类型(可空,默认=海运出口) + /// + public async Task AutomaticBooking([FromServices] IActionManagerService actionService, + [FromQuery] long businessId, [FromQuery] BusinessType businessType = BusinessType.OceanShippingExport) + { + return await actionService.AutomaticBooking(businessId, businessType); + } + /// /// 创建关联任务 /// From 7f3a68b01158579724382803de177aa19b964490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Fri, 23 Aug 2024 16:34:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=98=AF=E5=90=A6=E7=8E=B0=E8=88=B1=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskInteraction/TaskCreationRequest.cs | 5 +++ .../Op/Method/TaskInteraction/TaskService.cs | 32 +++++++++++++++---- .../Controllers/SeaExportTaskController.cs | 4 +-- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/TaskCreationRequest.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/TaskCreationRequest.cs index 1e755eda..b133c8c6 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/TaskCreationRequest.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/TaskInteraction/TaskCreationRequest.cs @@ -31,5 +31,10 @@ namespace DS.WMS.Core.Op.Dtos.TaskInteraction /// 下一任务类型 /// public TaskBaseTypeEnum? NextType { get; set; } + + /// + /// 是否现舱(默认null值) + /// + public bool? HasCabin { get; set; } } } 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 b0e2abc0..3d934e26 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 @@ -110,6 +110,14 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction if (!await EnsureModuleAuthorized()) return DataResult.SuccessedWithDesc(nameof(MultiLanguageConst.ModuleUnauthorized)); + if (request.HasCabin.GetValueOrDefault()) + { + //如果为现舱,获取下一任务类型进行创建 + var nextType = await GetNextTypeAsync(request.BusinessId, request.BusinessType, request.TaskType); + if (nextType.HasValue) + request.TaskTypeName = nextType.Value.ToString(); + } + var task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).FirstAsync(); if (task != null && task.TaskStatus != TaskStatusEnum.Cancel) return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskExists)); @@ -742,14 +750,24 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction /// protected async Task GetNextTypeAsync(BusinessTask current) { - var order = await ActionService.GetBusinessDataAsync(current.BusinessId, current.BusinessType); - TaskFlowRuner flowRuner = new(TenantDb, ServiceProvider); - var taskType = await flowRuner.GetWorkFlowNextConfigByTaskType(TaskBaseTypeEnum.WORK_FLOW_MAIN, - new TaskFlowDataContext( - (TaskFlowDataNameConst.Business, order) - ), current.TaskType); + return await GetNextTypeAsync(current.BusinessId, current.BusinessType, current.TaskType); + } - return taskType; + /// + /// 获取给定任务的下一任务类型 + /// + /// 业务ID + /// 业务类型 + /// 当前任务类型 + /// + protected async Task GetNextTypeAsync(long bsId, BusinessType businessType, TaskBaseTypeEnum currentType) + { + var order = await ActionService.GetBusinessDataAsync(bsId, businessType); + TaskFlowRuner flowRuner = new(TenantDb, ServiceProvider); + return await flowRuner.GetWorkFlowNextConfigByTaskType(TaskBaseTypeEnum.WORK_FLOW_MAIN, + new TaskFlowDataContext( + (TaskFlowDataNameConst.Business, order) + ), currentType); } /// diff --git a/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportTaskController.cs b/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportTaskController.cs index a4996bc5..073be7ea 100644 --- a/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportTaskController.cs +++ b/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportTaskController.cs @@ -1,6 +1,5 @@ using System.Net; using DS.Module.Core; -using DS.WMS.Core; using DS.WMS.Core.Flow.Dtos; using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Entity; @@ -66,7 +65,8 @@ namespace DS.WMS.OpApi.Controllers /// 业务ID /// 业务类型(可空,默认=海运出口) /// - public async Task AutomaticBooking([FromServices] IActionManagerService actionService, + [HttpPost, Route("AutomaticBooking")] + public async Task AutomaticBookingAsync([FromServices] IActionManagerService actionService, [FromQuery] long businessId, [FromQuery] BusinessType businessType = BusinessType.OceanShippingExport) { return await actionService.AutomaticBooking(businessId, businessType);