diff --git a/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineService.cs b/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineService.cs index 8e910563..ad8bd3d1 100644 --- a/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineService.cs +++ b/ds-wms-service/DS.Module.DjyRulesEngine/RuleEngineService.cs @@ -81,7 +81,8 @@ namespace DS.Module.DjyRulesEngine Port = port, Path = sendUrl }; - var result = await api.PostAsync(uriBuilder.ToString(), req); + string url = uriBuilder.ToString(); + var result = await api.PostAsync(url, req); if (!result.Succeeded || result.Data == null) return RuleEngineResult.Failed("请求失败,请联系管理员"); diff --git a/ds-wms-service/DS.WMS.AdminApi/Controllers/CommonController.cs b/ds-wms-service/DS.WMS.AdminApi/Controllers/CommonController.cs index 80dcbf49..0e798baa 100644 --- a/ds-wms-service/DS.WMS.AdminApi/Controllers/CommonController.cs +++ b/ds-wms-service/DS.WMS.AdminApi/Controllers/CommonController.cs @@ -16,16 +16,30 @@ namespace DS.WMS.AdminApi.Controllers; public class CommonController : ApiController { private readonly ICommonService _invokeService; - + private readonly IServerCommonService _serverService; /// /// 构造函数 /// /// - public CommonController(ICommonService invokeService) + public CommonController(ICommonService invokeService, IServerCommonService serverService) { _invokeService = invokeService; + _serverService = serverService; } + + /// + /// 获取船公司下拉列表 + /// + /// 船公司代码或中文名称 + /// + [HttpGet] + [Route("GetCarrierSelectList")] + public async Task>> GetCarrierSelectList([FromQuery] string queryKey) + { + var res = await _serverService.GetCodeCarrierSelectList(queryKey); + return res; + } /// /// 用户登录-管理端 /// diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/BookingActionExecutor.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/BookingActionExecutor.cs index f09647ce..029b6bdb 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/BookingActionExecutor.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/BookingActionExecutor.cs @@ -29,39 +29,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking return Task.CompletedTask; } - protected async Task CreateTaskIfNotExistAsync(ActionExecutionContext context) - { - if (!context.TaskInfo.NextType.HasValue) - return DataResult.Success; - - var result = await TaskService.ExistsAsync(context.TaskInfo.BusinessId, context.TaskInfo.BusinessType, context.TaskInfo.NextType.Value); - //任务已存在,跳过创建步骤 - if (result.Data) - return DataResult.Success; - - return await TaskService.CreateTaskAsync(new TaskCreationRequest - { - BusinessId = context.TaskInfo.BusinessId, - BusinessType = context.TaskInfo.BusinessType, - TaskTypeName = context.TaskInfo.NextType.Value.ToString() - }); - } - - protected async Task SetTaskCompleteAsync(ActionExecutionContext context) - { - if (!context.TaskInfo.NextType.HasValue) - return; - - var result = await TaskService.SetTaskStatusAsync(new TaskUpdateRequest - { - BusinessId = context.TaskInfo.BusinessId, - BusinessType = context.TaskInfo.BusinessType, - TaskTypeName = context.TaskInfo.NextType.Value.ToString(), - TaskStatus = TaskStatusEnum.Complete, - AutoCreateNext = true - }); - if (!result.Succeeded) - await LogService.WriteLogAsync(context.TaskInfo, $"未能设置任务【{context.TaskInfo.NextType.Value.GetDescription()}】完成,返回结果:{result.Message}"); - } + } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/EDIActionExecutor.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/EDIActionExecutor.cs index 2a649040..b29e9f17 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/EDIActionExecutor.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/EDIActionExecutor.cs @@ -1,7 +1,7 @@ -using DS.WMS.Core.Op.Dtos; +using DS.Module.Core; +using DS.WMS.Core.Op.Dtos; using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Interface; -using Masuit.Tools.Systems; using Microsoft.Extensions.DependencyInjection; namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking @@ -11,7 +11,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking /// public class EDIActionExecutor : BookingActionExecutor { - public async override Task ExecuteAsync(ActionExecutionContext context) { await base.ExecuteAsync(context); @@ -41,7 +40,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking return; } - await SetTaskCompleteAsync(context); + var task = context.TaskInfo; + task.TaskType = TaskBaseTypeEnum.WAIT_BOOKING; + await SetTaskCompleteAsync(task, TaskService, LogService); } } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/MailActionExecutor.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/MailActionExecutor.cs index a18135d3..2ae9183e 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/MailActionExecutor.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/Booking/MailActionExecutor.cs @@ -1,4 +1,5 @@ -using DS.WMS.Core.Op.Dtos; +using DS.Module.Core; +using DS.WMS.Core.Op.Dtos; using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity.TaskInteraction; @@ -79,7 +80,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking return; } - await SetTaskCompleteAsync(context); + var task = context.TaskInfo; + task.TaskType = TaskBaseTypeEnum.WAIT_BOOKING; + await SetTaskCompleteAsync(task, TaskService, LogService); } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/DefaultActionExecutor.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/DefaultActionExecutor.cs index 565aa1b2..5d4ce511 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/DefaultActionExecutor.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/DefaultActionExecutor.cs @@ -1,6 +1,9 @@ using DS.Module.Core; 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 Masuit.Tools.Systems; namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor { @@ -25,5 +28,57 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor { return Task.CompletedTask; } + + /// + /// 如果指定类型的任务不存在则创建 + /// + /// 业务ID + /// 业务类型 + /// 任务类型 + /// 任务服务 + /// 任务日志服务 + /// + protected async Task CreateTaskIfNotExistAsync(long bsId, BusinessType type, TaskBaseTypeEnum taskType, + ITaskService taskService, ITaskLogService? logService = null) + { + ArgumentNullException.ThrowIfNull(taskService, nameof(taskService)); + + var result = await taskService.ExistsAsync(bsId, type, taskType); + //任务已存在,跳过创建步骤 + if (result.Data) + return DataResult.Success; + + return await taskService.CreateTaskAsync(new TaskCreationRequest + { + BusinessId = bsId, + BusinessType = type, + TaskTypeName = taskType.ToString() + }); + } + + /// + /// 设置任务状态为完成 + /// + /// 任务对象 + /// 任务服务 + /// 任务日志服务 + /// + protected virtual async Task SetTaskCompleteAsync(BusinessTask task, ITaskService taskService, ITaskLogService? logService = null) + { + ArgumentNullException.ThrowIfNull(task, nameof(task)); + ArgumentNullException.ThrowIfNull(taskService, nameof(taskService)); + + var result = await taskService.SetTaskStatusAsync(new TaskUpdateRequest + { + BusinessId = task.BusinessId, + BusinessType = task.BusinessType, + TaskTypeName = task.TaskType.ToString(), + TaskStatus = TaskStatusEnum.Complete, + AutoCreateNext = true + }); + if (!result.Succeeded && logService != null) + await logService.WriteLogAsync(task, $"未能设置任务【{task.NextType?.GetDescription()}】完成,返回结果:{result.Message}"); + } + } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/SpaceRelease/SpaceReleaseActionExecutor.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/SpaceRelease/SpaceReleaseActionExecutor.cs index 70bef106..9bad3f1e 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/SpaceRelease/SpaceReleaseActionExecutor.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionExecutor/SpaceRelease/SpaceReleaseActionExecutor.cs @@ -108,16 +108,27 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.SpaceRelease await LogService.WriteLogAsync(context.TaskInfo, result.Message); return; } + + await SetTaskCompleteAsync(context.TaskInfo, + context.ServiceProvider.GetRequiredService(), LogService); } //转发BC async Task RelayBCAsync(ActionExecutionContext context) { var taskBase = context.AdditionalData[TaskFlowDataNameConst.TaskBaseInfo] as TaskBaseInfo; - if (taskBase != null) - await BCService.SyncBookingSlotChange(taskBase.Id); + if (taskBase == null) + return; + + var result = await BCService.SyncBookingSlotChange(taskBase.Id); + if (!result.Succeeded) + return; + + await SetTaskCompleteAsync(context.TaskInfo, + context.ServiceProvider.GetRequiredService(), LogService); } + //下货纸 async Task SendShippingOrderAsync(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 99ca1684..c27464fb 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 @@ -115,14 +115,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction if (task != null && task.TaskStatus != TaskStatusEnum.Cancel) return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskExists)); - //审核任务需要校验订单规则 - if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT) - { - var result = await CheckOrderRulesAsync(request.BusinessId); - if (!result.Succeeded) - return result; - } - long tenatId = long.Parse(User.TenantId); string tenatName = Db.Queryable().Where(x => x.Id == tenatId).Select(x => x.Name).First(); var info = new TaskManageOrderMessageInfo @@ -216,6 +208,28 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction //审核任务需创建工作流 if (AuditTaskTypes.Contains(request.TaskType)) { + if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT) + { + var rulesReq = new RuleEngineReq(); + rulesReq.Head.MessageType = "BUSI_RULE"; + rulesReq.Head.SenderId = "NewOceanBooking"; + rulesReq.Head.RequestAction = "CheckRule"; + rulesReq.Main.ProjectCode = ["COMMON_OCEAN_BOOKING"]; + + var order = await TenantDb.Queryable().Where(x => x.Id == request.BusinessId).FirstAsync(); + rulesReq.Main.BusinessInfo = info.Adapt(); + + var ruleResult = await RuleEngineService.Value.ExecuteSeaExportAuditRulesAsync(rulesReq); + if (ruleResult?.Extra.DetailList?.Count > 0) + { + StringBuilder sb = new StringBuilder(); + foreach (var item in ruleResult?.Extra.DetailList) + sb.Append(item.ResultName); + + return DataResult.Failed(sb.ToString()); + } + } + result = await CreateAndStartWorkflow(task); if (!result.Succeeded) return result; @@ -346,8 +360,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction { BusinessId = request.BusinessId, BusinessType = request.BusinessType, - TaskTypeName = task.NextType.Value.ToString(), - RecvUserIdList = task.RecvUserIdArray + TaskTypeName = task.NextType.Value.ToString() }; result = await CreateTaskAsync(req, false); if (!result.Succeeded) @@ -363,7 +376,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction if (task.TaskStatus == TaskStatusEnum.Complete)//目前限制任务完成才触发 { Dictionary? dic = null; - if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT) + if (task.NextType == TaskBaseTypeEnum.WAIT_BOOKING) { dic = new Dictionary(); var param = await ClientParamService.GetParamAsync(task.BusinessId, BookingSelector.Booking_Route, @@ -461,14 +474,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction if (task.TaskStatus == TaskStatusEnum.Pending || task.TaskStatus == TaskStatusEnum.Create) { - //审核任务需要校验订单规则 - if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT) - { - var result = await CheckOrderRulesAsync(request.BusinessId); - if (!result.Succeeded) - return result; - } - await TenantDb.Ado.BeginTranAsync(); try { @@ -627,7 +632,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction BusinessType = callback.BusinessType.Value, TaskTypeName = taskType.ToString(), TaskStatus = callback.FlowStatus == FlowStatusEnum.Approve ? TaskStatusEnum.Complete : TaskStatusEnum.Pending, - AutoCreateNext = false //审批完成后需根据业务需要自定义任务类型,因此设置为不自动创建下一任务 + AutoCreateNext = true }; //根据审批结果更新任务状态 await SetTaskStatusAsync(req); @@ -668,34 +673,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction }); } - async Task CheckOrderRulesAsync(long businessId) - { - var rulesReq = new RuleEngineReq(); - rulesReq.Head.MessageType = "BUSI_RULE"; - rulesReq.Head.SenderId = "NewOceanBooking"; - rulesReq.Head.RequestAction = "CheckRule"; - rulesReq.Main.ProjectCode = ["COMMON_OCEAN_BOOKING"]; - - var order = await TenantDb.Queryable().Where(x => x.Id == businessId).FirstAsync(); - if (order == null) - return DataResult.FailedWithDesc(MultiLanguageConst.EmptyData); - - rulesReq.Main.BusinessInfo = order.Adapt(); - - var ruleResult = await RuleEngineService.Value.ExecuteSeaExportAuditRulesAsync(rulesReq); - if (ruleResult?.Extra.DetailList?.Count > 0) - { - StringBuilder sb = new StringBuilder(); - foreach (var item in ruleResult?.Extra.DetailList) - sb.Append(" " + item.ResultName); - - sb.Remove(0, 1); - return DataResult.Failed(sb.ToString()); - } - - return DataResult.Success; - } - /// /// 获取给定任务的下一任务类型 /// diff --git a/ds-wms-service/DS.WMS.Core/Sys/Interface/IServerCommonService.cs b/ds-wms-service/DS.WMS.Core/Sys/Interface/IServerCommonService.cs new file mode 100644 index 00000000..e434d1ba --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Sys/Interface/IServerCommonService.cs @@ -0,0 +1,23 @@ +using DS.Module.Core; +using DS.Module.Core.Extensions; +using DS.WMS.Core.Code.Dtos; +using DS.WMS.Core.Fee.Dtos; +using DS.WMS.Core.Info.Dtos; +using DS.WMS.Core.Op.Dtos; +using DS.WMS.Core.Sys.Dtos; +using DS.WMS.Core.Sys.Entity; +using SqlSugar; + +namespace DS.WMS.Core.Sys.Interface; +/// +/// +/// +public interface IServerCommonService +{ + /// + /// 获取船公司下拉列表-管理端 + /// + /// + public Task>> GetCodeCarrierSelectList(string queryKey = ""); + +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Sys/Method/ClientCommonService.cs b/ds-wms-service/DS.WMS.Core/Sys/Method/ClientCommonService.cs index 30428a72..0352f10a 100644 --- a/ds-wms-service/DS.WMS.Core/Sys/Method/ClientCommonService.cs +++ b/ds-wms-service/DS.WMS.Core/Sys/Method/ClientCommonService.cs @@ -1,6 +1,5 @@ using DS.Module.Core; using DS.Module.Core.Constants; -using DS.Module.Core.Data; using DS.Module.Core.Extensions; using DS.Module.Core.Log; using DS.Module.SqlSugar; @@ -11,21 +10,14 @@ using DS.WMS.Core.Fee.Dtos; using DS.WMS.Core.Fee.Entity; using DS.WMS.Core.Info.Dtos; using DS.WMS.Core.Info.Entity; -using DS.WMS.Core.Invoice.Dtos; using DS.WMS.Core.Op.Dtos; -using DS.WMS.Core.Op.EDI; using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Sys.Dtos; using DS.WMS.Core.Sys.Entity; using DS.WMS.Core.Sys.Interface; using Mapster; -using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.Extensions.DependencyInjection; -using NPOI.POIFS.Crypt.Dsig; using SqlSugar; -using System.Collections.Generic; -using System.Diagnostics.Contracts; -using static System.Runtime.InteropServices.JavaScript.JSType; namespace DS.WMS.Core.Sys.Method; diff --git a/ds-wms-service/DS.WMS.Core/Sys/Method/ServerCommonService.cs b/ds-wms-service/DS.WMS.Core/Sys/Method/ServerCommonService.cs new file mode 100644 index 00000000..fcbb3abb --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Sys/Method/ServerCommonService.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DS.Module.Core; +using DS.WMS.Core.Code.Dtos; +using DS.WMS.Core.Sys.Interface; +using Mapster; +using Microsoft.Extensions.DependencyInjection; +using SqlSugar; +using DS.Module.Core; +using DS.Module.Core.Constants; +using DS.Module.Core.Extensions; +using DS.Module.Core.Log; +using DS.Module.SqlSugar; +using DS.Module.UserModule; +using DS.WMS.Core.Code.Entity; + +namespace DS.WMS.Core.Sys.Method +{ + public class ServerCommonService : IServerCommonService + { + private readonly IServiceProvider _serviceProvider; + private readonly ISqlSugarClient db; + private readonly IUser user; + + /// + /// + /// + /// + public ServerCommonService(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + db = _serviceProvider.GetRequiredService(); + user = _serviceProvider.GetRequiredService(); + } + + /// + /// + /// + /// + /// + public async Task>> GetCodeCarrierSelectList(string queryKey = "") + { + var list = await db.Queryable() + .WhereIF(!string.IsNullOrEmpty(queryKey), a => a.Code.Contains(queryKey) || a.CnName.Contains(queryKey)) + .Select(a => new CodeCarrierRes() + { + PinYinCode = a.CnName + "(" + a.Code + ")", + }, + true) + .Take(20) + .ToListAsync(); + return await Task.FromResult(DataResult>.Success("获取数据成功!", list)); + } + } +}