From 03277b5c129fd1ae8bf580e089240df0215b3c01 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 16 Apr 2024 10:27:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A2=9E=E5=8A=A0=E5=B5=8C?= =?UTF-8?q?=E5=85=A5=E7=9A=84=E6=9C=8D=E5=8A=A1=E9=A1=B9=E7=9B=AE=E5=92=8C?= =?UTF-8?q?=E8=B4=A7=E7=89=A9=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingSlot/BookingSlotService.cs | 2 + .../BookingSlot/Dto/BookingGenerateDto.cs | 10 + .../Dtos/EmbedServiceProjectDto.cs | 73 ++++ .../EmbedProjectGoodsStatusService.cs | 397 ++++++++++++++++-- .../IEmbedProjectGoodsStatusService.cs | 10 +- .../Dtos/BC/BookingOrSlotGenerateDto.cs | 10 + .../TaskManagePlat/TaskManageBCService.cs | 3 + .../QueryServiceProjectWithStatusCommon.cs | 34 ++ .../IServiceWorkFlowManageService.cs | 18 +- .../ServiceWorkFlowManageService.cs | 376 +++++++++++++++-- Myshipping.Core/Myshipping.Core.xml | 5 + 11 files changed, 872 insertions(+), 66 deletions(-) create mode 100644 Myshipping.Application/Service/TrackingSystem/Dtos/QueryServiceProjectWithStatusCommon.cs diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs index 304b6e7d..76c6ad11 100644 --- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs @@ -1333,6 +1333,8 @@ namespace Myshipping.Application CLOSEVGMDATE = bookingSlotBase.VGM_SUBMISSION_CUT_DATE, CLOSINGDATE = bookingSlotBase.CY_CUT_DATE, CLOSEDOCDATE = bookingSlotBase.SI_CUT_DATE, + CUSTSERVICEID = generateModel.CustServiceId.HasValue? generateModel.CustServiceId.Value.ToString():null, + CUSTSERVICE = generateModel.CustServiceName, ctnInputs = new List() }; diff --git a/Myshipping.Application/Service/BookingSlot/Dto/BookingGenerateDto.cs b/Myshipping.Application/Service/BookingSlot/Dto/BookingGenerateDto.cs index 867e97c2..42580ad8 100644 --- a/Myshipping.Application/Service/BookingSlot/Dto/BookingGenerateDto.cs +++ b/Myshipping.Application/Service/BookingSlot/Dto/BookingGenerateDto.cs @@ -97,5 +97,15 @@ namespace Myshipping.Application /// 是否直接发送邮件给订舱联系人 /// public bool IsDirectSend { get; set; } = false; + + /// + /// 客服ID + /// + public Nullable CustServiceId { get; set; } + + /// + /// 客服名称 + /// + public string CustServiceName { get; set; } } } diff --git a/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/EmbedServiceProjectDto.cs b/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/EmbedServiceProjectDto.cs index 3a3f5284..abc7f8b3 100644 --- a/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/EmbedServiceProjectDto.cs +++ b/Myshipping.Application/Service/EmbedProjectGoodsStatus/Dtos/EmbedServiceProjectDto.cs @@ -20,5 +20,78 @@ namespace Myshipping.Application /// 服务项目代码 /// public string[] ProjectCodes { get; set; } + + /// + /// 状态操作类型 MANUAL-手工 AUTO-自动 + /// + public TrackingOperTypeEnum OpertType { get; set; } + } + + + /// + /// 修改服务项目状态 + /// + public class EmbedServiceProjectStatusDto + { + /// + /// 业务主键 + /// + public string businessId { get; set; } + + /// + /// 来源类型 + /// + public TrackingSourceTypeEnum SourceType { get; set; } = TrackingSourceTypeEnum.MANUAL; + + /// + /// 服务项目状态明细 + /// + public List StatusCodes { get; set; } + } + + public class EmbedServiceProjectStatusDetailDto + { + /// + /// 状态代码 + /// + public string StatusCode { get; set; } + + /// + /// 人工设定状态完成时间 + /// + public Nullable SetActDate { get; set; } + + /// + /// 人工设定状态值(可传箱使天数) + /// + public string SetActVal { get; set; } + + /// + /// 状态备注 + /// + public string ActRemark { get; set; } + } + + public class EmbedQueryServiceProjectWithStatus + { + /// + /// 业务主键(可为空,不为空时需要查询已触发的记录和未触发的记录,为空时只查询已启用的) + /// + public string businessId { get; set; } + + /// + /// 0-查服务项目 1-查服务项目下的状态 + /// + public TrackingQueryTypeEnum QueryType { get; set; } + + /// + /// 服务项目代码组 + /// + public string[] ProjectCodes { get; set; } + + /// + /// 租户ID + /// + public long TenantId { get; set; } } } diff --git a/Myshipping.Application/Service/EmbedProjectGoodsStatus/EmbedProjectGoodsStatusService.cs b/Myshipping.Application/Service/EmbedProjectGoodsStatus/EmbedProjectGoodsStatusService.cs index 606cdcf3..febca956 100644 --- a/Myshipping.Application/Service/EmbedProjectGoodsStatus/EmbedProjectGoodsStatusService.cs +++ b/Myshipping.Application/Service/EmbedProjectGoodsStatus/EmbedProjectGoodsStatusService.cs @@ -1,4 +1,5 @@ -using Furion.DependencyInjection; +using Furion.ClayObject.Extensions; +using Furion.DependencyInjection; using Furion.DistributedIDGenerator; using Furion.DynamicApiController; using Furion.FriendlyException; @@ -6,10 +7,12 @@ using Furion.JsonSerialization; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; +using Myshipping.Core; using StackExchange.Profiling.Internal; using System; using System.Collections.Generic; using System.Linq; +using System.Reflection.Emit; using System.Text; using System.Threading.Tasks; @@ -23,23 +26,26 @@ namespace Myshipping.Application public class EmbedProjectGoodsStatusService: IEmbedProjectGoodsStatusService, IDynamicApiController, ITransient { private readonly ILogger _logger; + private readonly IServiceWorkFlowManageService _serviceWorkFlowManageService; /// /// /// /// - public EmbedProjectGoodsStatusService(ILogger logger) + public EmbedProjectGoodsStatusService(ILogger logger, IServiceWorkFlowManageService serviceWorkFlowManageService) { _logger = logger; - } + _serviceWorkFlowManageService = serviceWorkFlowManageService; + } + #region 保存服务项目 /// /// 保存服务项目 /// /// 修改服务项目详情 /// 返回回执 - [HttpPost("/EmbedProjectGoodsStatus/SaveServiceProject")] + [AllowAnonymous, HttpPost("/EmbedProjectGoodsStatus/SaveServiceProject"), ApiUser(ApiCode = "EmbedServiceProjectStatus")] public async Task SaveServiceProject(EmbedServiceProjectDto model) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); @@ -75,11 +81,11 @@ namespace Myshipping.Application VesselVoyno = "", OrderNo = "", PushType = TrackingPushTypeEnum.Project, - OperTenantId = 0, - OperTenantName = "", - OpertType = TrackingOperTypeEnum.MANUAL, - OperUserId = "", - OperUserName = "", + OperTenantId = UserManager.TENANT_ID, + OperTenantName = UserManager.TENANT_NAME, + OpertType = model.OpertType, + OperUserId = UserManager.UserId.ToString(), + OperUserName = UserManager.Name, SourceType = TrackingSourceTypeEnum.MANUAL, ProjectList = model.ProjectCodes.Select(a => new TrackingMessageMainProjectInfo { @@ -92,24 +98,24 @@ namespace Myshipping.Application _logger.LogInformation("批次={no} 推送保存服务项目 msg={msg}", batchNo, JSON.Serialize(msgInfo)); - //var rlt = await _serviceWorkFlowManageService.PushStatus(msgInfo); + var rlt = await _serviceWorkFlowManageService.PushStatus(msgInfo); - //DateTime eDate = DateTime.Now; - //TimeSpan ts = eDate.Subtract(bDate); - //var timeDiff = ts.TotalMilliseconds; + DateTime eDate = DateTime.Now; + TimeSpan ts = eDate.Subtract(bDate); + var timeDiff = ts.TotalMilliseconds; - //_logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg} result={rlt}", batchNo, timeDiff, (rlt.succ ? "成功" : "失败") - // , JSON.Serialize(rlt)); + _logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg} result={rlt}", batchNo, timeDiff, (rlt.succ ? "成功" : "失败") + , JSON.Serialize(rlt)); - //if (!rlt.succ) - //{ - // result = rlt; - //} - //else - //{ - // result.succ = true; - // result.msg = "保存成功"; - //} + if (!rlt.succ) + { + result = rlt; + } + else + { + result.succ = true; + result.msg = "保存成功"; + } } catch (Exception ex) @@ -120,56 +126,377 @@ namespace Myshipping.Application return result; } + #endregion + #region 取消服务项目 /// /// 取消服务项目 /// /// 修改服务项目详情 /// 返回回执 - public async Task CancelServiceProject(ModifyServiceProjectDto model) + [AllowAnonymous, HttpPost("/EmbedProjectGoodsStatus/CancelServiceProject"), ApiUser(ApiCode = "EmbedServiceProjectStatus")] + public async Task CancelServiceProject(EmbedServiceProjectDto model) { - return null; + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + string batchNo = IDGen.NextID().ToString(); + + try + { + if (string.IsNullOrWhiteSpace(model.businessId)) + throw Oops.Oh($"业务主键不能为空"); + + _logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model)); + + TrackingMessageInfo msgInfo = new TrackingMessageInfo + { + Head = new TrackingMessageHeadInfo + { + GID = IDGen.NextID().ToString(), + MessageType = "PROJECT", + ReceiverId = "ServiceProjectStatus", + ReceiverName = "服务项目和状态", + SenderId = "BookingOrder", + SenderName = "海运订舱", + RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), + Version = "2.0", + RequestAction = "AddOrModify", + }, + Main = new TrackingMessageMainInfo + { + BusiId = model.businessId, + BusiSystemCode = "BOOKING_ORDER", + MBlNo = "", + VesselVoyno = "", + OrderNo = "", + PushType = TrackingPushTypeEnum.Project, + OperTenantId = UserManager.TENANT_ID, + OperTenantName = UserManager.TENANT_NAME, + OpertType = model.OpertType, + OperUserId = UserManager.UserId.ToString(), + OperUserName = UserManager.Name, + SourceType = TrackingSourceTypeEnum.MANUAL, + ProjectList = model.ProjectCodes.Select(a => new TrackingMessageMainProjectInfo + { + ServiceProjectCode = a, + }).ToList() + } + }; + DateTime bDate = DateTime.Now; + + _logger.LogInformation("批次={no} 推送取消服务项目 msg={msg}", batchNo, JSON.Serialize(msgInfo)); + + var rlt = await _serviceWorkFlowManageService.CancelStatus(msgInfo); + + DateTime eDate = DateTime.Now; + TimeSpan ts = eDate.Subtract(bDate); + var timeDiff = ts.TotalMilliseconds; + + _logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg} result={rlt}", batchNo, timeDiff, (rlt.succ ? "成功" : "失败") + , JSON.Serialize(rlt)); + + if (!rlt.succ) + { + result = rlt; + } + else + { + result.succ = true; + result.msg = "取消成功"; + } + + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"服务项目取消失败,原因:{ex.Message}"; + } + + return result; } + #endregion + #region 获取服务项目列表 /// /// 获取服务项目列表 /// /// 查询服务项目和状态详情 /// 返回回执 - public async Task GetServiceProjectList(QueryServiceProjectWithStatus model) + [AllowAnonymous, HttpPost("/EmbedProjectGoodsStatus/GetServiceProjectList"), ApiUser(ApiCode = "EmbedServiceProjectStatus")] + public async Task GetServiceProjectList(EmbedQueryServiceProjectWithStatus model) { - return null; - } + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + string batchNo = IDGen.NextID().ToString(); + + try + { + DateTime bDate = DateTime.Now; + + EmbedQueryServiceProjectWithStatus queryInfo = new EmbedQueryServiceProjectWithStatus + { + businessId = model.businessId, + QueryType = TrackingQueryTypeEnum.QUERY_SERVICE_PROJECT, + TenantId = UserManager.TENANT_ID + }; + + result = await _serviceWorkFlowManageService.GetEnableProjectListCommon(queryInfo); + + DateTime eDate = DateTime.Now; + TimeSpan ts = eDate.Subtract(bDate); + var timeDiff = ts.TotalMilliseconds; + + _logger.LogInformation("批次={no} id={id} 单票请求服务项目结果 耗时:{timeDiff}ms. ", batchNo, model.businessId, timeDiff); + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"获取服务项目列表失败,原因:{ex.Message}"; + } + return result; + } + #endregion + #region 获取服务项目下的状态列表 /// /// 获取服务项目下的状态列表 /// /// 查询服务项目和状态详情 /// 返回回执 - public async Task GetServiceStatusList(QueryServiceProjectWithStatus model) + [AllowAnonymous, HttpPost("/EmbedProjectGoodsStatus/GetServiceStatusList"), ApiUser(ApiCode = "EmbedServiceProjectStatus")] + public async Task GetServiceStatusList(EmbedQueryServiceProjectWithStatus model) { - return null; + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + string batchNo = IDGen.NextID().ToString(); + + try + { + //查询所有服务服务项目和状态时,需要先获取订舱详情 + if (model.QueryType == TrackingQueryTypeEnum.QUERY_SERVICE_ALL) + { + DateTime bDate = DateTime.Now; + + EmbedQueryServiceProjectWithStatus queryInfo = new EmbedQueryServiceProjectWithStatus + { + businessId = model.businessId, + QueryType = TrackingQueryTypeEnum.QUERY_SERVICE_PROJECT, + TenantId = UserManager.TENANT_ID + }; + + result = await _serviceWorkFlowManageService.GetEnableStatusListByBusinessCommon(queryInfo); + + DateTime eDate = DateTime.Now; + TimeSpan ts = eDate.Subtract(bDate); + var timeDiff = ts.TotalMilliseconds; + + _logger.LogInformation("批次={no} id={id} 单票请求服务状态结果 耗时:{timeDiff}ms. ", batchNo, model.businessId, timeDiff); + } + else + { + if (model.ProjectCodes == null || (model.ProjectCodes != null && model.ProjectCodes.Length == 0)) + throw Oops.Oh($"服务项目代码不能为空"); + + //model.TenantId = UserManager.TENANT_ID; + result = await _serviceWorkFlowManageService.GetEnableStatusListByProject(new QueryServiceProjectWithStatus { + ProjectCodes = model.ProjectCodes, + QueryType = model.QueryType, + TenantId = UserManager.TENANT_ID + }); + } + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"获取服务项目下的状态列表失败,原因:{ex.Message}"; + } + + return result; } + #endregion + #region 保存服务状态 /// /// 保存服务状态 /// /// 修改服务状态详情 /// 返回回执 - public async Task SaveServiceStatus(ModifyServiceProjectStatusDto model) + [AllowAnonymous, HttpPost("/EmbedProjectGoodsStatus/SaveServiceStatus"), ApiUser(ApiCode = "EmbedServiceProjectStatus")] + public async Task SaveServiceStatus(EmbedServiceProjectStatusDto model) { - return null; + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + string batchNo = IDGen.NextID().ToString(); + + try + { + if (string.IsNullOrWhiteSpace(model.businessId)) + throw Oops.Oh($"业务主键不能为空"); + + _logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model)); + + TrackingMessageInfo msgInfo = new TrackingMessageInfo + { + Head = new TrackingMessageHeadInfo + { + GID = IDGen.NextID().ToString(), + MessageType = "PROJECT", + ReceiverId = "ServiceProjectStatus", + ReceiverName = "服务项目和状态", + SenderId = "BookingOrder", + SenderName = "海运订舱", + RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), + Version = "2.0", + RequestAction = "AddOrModify", + }, + Main = new TrackingMessageMainInfo + { + BusiId = model.businessId, + BusiSystemCode = "BOOKING_ORDER", + MBlNo = "", + VesselVoyno = "", + OrderNo = "", + PushType = TrackingPushTypeEnum.Status, + OperTenantId = UserManager.TENANT_ID, + OperTenantName = UserManager.TENANT_NAME, + OpertType = TrackingOperTypeEnum.MANUAL, + OperUserId = UserManager.UserId.ToString(), + OperUserName = UserManager.Name, + SourceType = model.SourceType, + StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo + { + StatusCode = a.StatusCode, + StatusDate = a.SetActDate, + StatusVal = a.SetActVal, + Remark = a.ActRemark + }).ToList() + } + }; + DateTime bDate = DateTime.Now; + + _logger.LogInformation("批次={no} 推送保存服务项目 msg={msg}", batchNo, JSON.Serialize(msgInfo)); + + var rlt = await _serviceWorkFlowManageService.PushStatus(msgInfo); + + DateTime eDate = DateTime.Now; + TimeSpan ts = eDate.Subtract(bDate); + var timeDiff = ts.TotalMilliseconds; + + _logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg} result={rlt}", batchNo, timeDiff, (rlt.succ ? "成功" : "失败") + , JSON.Serialize(rlt)); + + if (!rlt.succ) + { + result = rlt; + } + else + { + result.succ = true; + result.msg = "推送成功"; + + //这里预留保存完货物状态主动推送东胜 + //var _bookingOrderService = _namedBookingOrderServiceProvider.GetService(nameof(BookingOrderService)); + // await _bookingOrderService.SetBookingGoodsStatus(bookingOrder.Id, true, "手动更新货物状态"); + } + + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"服务项目状态推送失败,原因:{ex.Message}"; + } + + return result; } + #endregion + #region 取消服务状态 /// /// 取消服务状态 /// /// 修改服务状态详情 /// 返回回执 - public async Task CancelServiceStatus(ModifyServiceProjectStatusDto model) + [AllowAnonymous, HttpPost("/EmbedProjectGoodsStatus/CancelServiceStatus"), ApiUser(ApiCode = "EmbedServiceProjectStatus")] + public async Task CancelServiceStatus(EmbedServiceProjectStatusDto model) { - return null; + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + string batchNo = IDGen.NextID().ToString(); + + try + { + _logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model)); + + TrackingMessageInfo msgInfo = new TrackingMessageInfo + { + Head = new TrackingMessageHeadInfo + { + GID = IDGen.NextID().ToString(), + MessageType = "PROJECT", + ReceiverId = "ServiceProjectStatus", + ReceiverName = "服务项目和状态", + SenderId = "BookingOrder", + SenderName = "海运订舱", + RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), + Version = "2.0", + RequestAction = "AddOrModify", + }, + Main = new TrackingMessageMainInfo + { + BusiId = model.businessId, + BusiSystemCode = "BOOKING_ORDER", + MBlNo = "", + VesselVoyno = "", + OrderNo = "", + PushType = TrackingPushTypeEnum.Status, + OperTenantId = UserManager.TENANT_ID, + OperTenantName = UserManager.TENANT_NAME, + OpertType = TrackingOperTypeEnum.MANUAL, + OperUserId = UserManager.UserId.ToString(), + OperUserName = UserManager.Name, + SourceType = model.SourceType, + StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo + { + StatusCode = a.StatusCode, + StatusDate = a.SetActDate, + StatusVal = a.SetActVal, + Remark = a.ActRemark + }).ToList() + } + }; + DateTime bDate = DateTime.Now; + + _logger.LogInformation("批次={no} 推送保存服务项目 msg={msg}", batchNo, JSON.Serialize(msgInfo)); + + var rlt = await _serviceWorkFlowManageService.CancelStatus(msgInfo); + + DateTime eDate = DateTime.Now; + TimeSpan ts = eDate.Subtract(bDate); + var timeDiff = ts.TotalMilliseconds; + + _logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg} result={rlt}", batchNo, timeDiff, (rlt.succ ? "成功" : "失败") + , JSON.Serialize(rlt)); + + if (!rlt.succ) + { + result = rlt; + } + else + { + result.succ = true; + result.msg = "推送成功"; + } + + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"服务项目状态推送失败,原因:{ex.Message}"; + } + + return result; } + #endregion } } diff --git a/Myshipping.Application/Service/EmbedProjectGoodsStatus/Interface/IEmbedProjectGoodsStatusService.cs b/Myshipping.Application/Service/EmbedProjectGoodsStatus/Interface/IEmbedProjectGoodsStatusService.cs index 9b2ca01e..6088d66d 100644 --- a/Myshipping.Application/Service/EmbedProjectGoodsStatus/Interface/IEmbedProjectGoodsStatusService.cs +++ b/Myshipping.Application/Service/EmbedProjectGoodsStatus/Interface/IEmbedProjectGoodsStatusService.cs @@ -20,14 +20,14 @@ namespace Myshipping.Application /// /// 修改服务项目详情 /// 返回回执 - Task CancelServiceProject(ModifyServiceProjectDto model); + Task CancelServiceProject(EmbedServiceProjectDto model); /// /// 获取服务项目列表 /// /// 查询服务项目和状态详情 /// 返回回执 - Task GetServiceProjectList(QueryServiceProjectWithStatus model); + Task GetServiceProjectList(EmbedQueryServiceProjectWithStatus model); /// @@ -35,20 +35,20 @@ namespace Myshipping.Application /// /// 查询服务项目和状态详情 /// 返回回执 - Task GetServiceStatusList(QueryServiceProjectWithStatus model); + Task GetServiceStatusList(EmbedQueryServiceProjectWithStatus model); /// /// 保存服务状态 /// /// 修改服务状态详情 /// 返回回执 - Task SaveServiceStatus(ModifyServiceProjectStatusDto model); + Task SaveServiceStatus(EmbedServiceProjectStatusDto model); /// /// 取消服务状态 /// /// 修改服务状态详情 /// 返回回执 - Task CancelServiceStatus(ModifyServiceProjectStatusDto model); + Task CancelServiceStatus(EmbedServiceProjectStatusDto model); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/BookingOrSlotGenerateDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/BookingOrSlotGenerateDto.cs index 35f3b091..90088592 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/BookingOrSlotGenerateDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/BookingOrSlotGenerateDto.cs @@ -120,6 +120,16 @@ namespace Myshipping.Application /// 是否默认使用用户个人邮箱发送 false-使用公共邮箱 true-使用个人邮箱 /// public bool usePersonalEmailSend { get; set; } = false; + + /// + /// 客服ID + /// + public Nullable CustServiceId { get; set; } + + /// + /// 客服名称 + /// + public string CustServiceName { get; set; } } public class CustomerContact diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index 75c0256b..5bbfa63c 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs @@ -1273,6 +1273,9 @@ namespace Myshipping.Application CLOSEVGMDATE = taskBCInfo.VGM_CUTOFF_TIME, CLOSINGDATE = taskBCInfo.CY_CUTOFF_TIME, CLOSEDOCDATE = taskBCInfo.CUT_SINGLE_TIME, + CUSTSERVICEID = generateModel.CustServiceId.HasValue? generateModel.CustServiceId.Value.ToString(): null, + CUSTSERVICE = generateModel.CustServiceName, + ctnInputs = new List() }; diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/QueryServiceProjectWithStatusCommon.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/QueryServiceProjectWithStatusCommon.cs new file mode 100644 index 00000000..dea87821 --- /dev/null +++ b/Myshipping.Application/Service/TrackingSystem/Dtos/QueryServiceProjectWithStatusCommon.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application.Service.TrackingSystem.Dtos +{ + /// + /// + /// + public class QueryServiceProjectWithStatusCommon + { + /// + /// 业务主键(可为空,不为空时需要查询已触发的记录和未触发的记录,为空时只查询已启用的) + /// + public string businessId { get; set; } + + /// + /// 0-查服务项目 1-查服务项目下的状态 + /// + public TrackingQueryTypeEnum QueryType { get; set; } + + /// + /// 服务项目代码组 + /// + public string[] ProjectCodes { get; set; } + + /// + /// 租户ID + /// + public long TenantId { get; set; } + } +} diff --git a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs index 3c64c144..17534a5b 100644 --- a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowManageService.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.AspNetCore.Mvc; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -106,5 +107,20 @@ namespace Myshipping.Application /// 租户ID /// Task ManualSyncHistoryServiceStatus(long tenantId); + + + /// + /// 检索已选中并且可用的服务项目列表(标准) + /// + /// 查询服务项目和状态详情 + /// 返回回执 + Task GetEnableProjectListCommon(EmbedQueryServiceProjectWithStatus model); + + /// + /// 单票检索服务项目下的状态列表(标准) + /// + /// 查询服务项目和状态详情 + /// 返回回执 + Task GetEnableStatusListByBusinessCommon(EmbedQueryServiceProjectWithStatus model); } } diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs index 18cd68fa..0dcd2623 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs @@ -1510,36 +1510,39 @@ namespace Myshipping.Application tskList.ForEach(async tsk => { if (tsk.OperType == "Update") { - var runInfo = _serviceWorkFlowRunInfoRepository.AsQueryable() + var runInfo = _serviceWorkFlowRunInfoRepository.AsQueryable().Filter(null,true) .First(a => a.PK_ID == tsk.Run.PK_ID); - runInfo.IS_YIELD = 0; - runInfo.ACT_DATE = null; - runInfo.UpdatedTime = nowDate; - runInfo.UpdatedUserId = long.Parse(info.Main.OperUserId); - runInfo.UpdatedUserName = info.Main.OperUserName; - - await _serviceWorkFlowRunInfoRepository.AsUpdateable(runInfo).UpdateColumns(it => new + if (runInfo != null) { - it.ACT_DATE, - it.IS_YIELD, - it.UpdatedTime, - it.UpdatedUserId, - it.UpdatedUserName - }).ExecuteCommandAsync(); + runInfo.IS_YIELD = 0; + runInfo.ACT_DATE = null; + runInfo.UpdatedTime = nowDate; + runInfo.UpdatedUserId = long.Parse(info.Main.OperUserId); + runInfo.UpdatedUserName = info.Main.OperUserName; - #region 写入运行日志 - var runLog = runInfo.Adapt(); - runLog.PK_ID = IDGen.NextID().ToString(); - runLog.RUN_ID = runInfo.PK_ID; - runLog.BATCH_NO = batchNo; - runLog.OPER_TYPE = TrackingRunOperTypeEnum.CANCEL_PROJECT.ToString(); - runLog.EXEC_RESULT = "SUCC"; - runLog.EXEC_NOTE = "Update"; - runLog.SOURCE_TYPE = info.Main.SourceType.ToString(); + await _serviceWorkFlowRunInfoRepository.AsUpdateable(runInfo).UpdateColumns(it => new + { + it.ACT_DATE, + it.IS_YIELD, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + }).ExecuteCommandAsync(); - await _serviceWorkFlowRunLogInfoRepository.InsertAsync(runLog); - #endregion + #region 写入运行日志 + var runLog = runInfo.Adapt(); + runLog.PK_ID = IDGen.NextID().ToString(); + runLog.RUN_ID = runInfo.PK_ID; + runLog.BATCH_NO = batchNo; + runLog.OPER_TYPE = TrackingRunOperTypeEnum.CANCEL_PROJECT.ToString(); + runLog.EXEC_RESULT = "SUCC"; + runLog.EXEC_NOTE = "Update"; + runLog.SOURCE_TYPE = info.Main.SourceType.ToString(); + + await _serviceWorkFlowRunLogInfoRepository.InsertAsync(runLog); + #endregion + } } }); @@ -2930,5 +2933,328 @@ namespace Myshipping.Application return result; } + + #region 检索已选中并且可用的服务项目列表(标准) + /// + /// 检索已选中并且可用的服务项目列表(标准) + /// + /// 查询服务项目和状态详情 + /// 返回回执 + public async Task GetEnableProjectListCommon(EmbedQueryServiceProjectWithStatus model) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + //先获取可用的服务项目 + var projectList = await _serviceWorkFlowBaseService.GetEnableProjectList(model.TenantId.ToString()); + + TrackingQueryMessageInfo messageInfo = new TrackingQueryMessageInfo + { + Head = new TrackingMessageHeadInfo + { + GID = IDGen.NextID().ToString(), + MessageType = "PROJECT", + ReceiverId = "ServiceProjectStatus", + ReceiverName = "服务项目和状态", + SenderId = "BookingOrder", + SenderName = "海运订舱", + RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), + Version = "2.0", + RequestAction = "AddOrModify", + }, + Main = new TrackingMessageQueryMainInfo + { + BusiId = model.businessId, + BusiSystemCode = "BOOKING_ORDER", + TenantId = model.TenantId.ToString(), + } + }; + //在获取运行表已有的记录 + var runList = InnerGetRunListBySingleBusiness(messageInfo); + + var resultList = projectList.GroupJoin(runList, l => l.PKId, r => r.ServiceProjectId, (l, r) => { + var currList = r.ToList(); + + var runInfo = currList.FirstOrDefault(); + + var dto = new ServiceProjectWithStatusDto + { + ProjectPKId = l.PKId, + ProjectCode = l.ServiceProjectCode, + ProjectName = l.ServiceProjectName, + SortNo = l.SortNo + }; + + if (runInfo != null) + { + dto.IsYield = runInfo.IsYield == 1 ? true : false; + dto.ActDate = runInfo.ActDate; + } + + return dto; + }).ToList(); + + result.succ = true; + result.ext = resultList; + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"检索已选中并且可用的服务项目列表失败,原因:{ex.Message}"; + } + + return result; + } + #endregion + + #region 单票检索服务项目下的状态列表 + /// + /// 单票检索服务项目下的状态列表 + /// + /// 查询服务项目和状态详情 + /// 返回回执 + [HttpPost("/ServiceWorkFlowManage/GetEnableStatusListByBusinessCommon")] + public async Task GetEnableStatusListByBusinessCommon([FromBody] EmbedQueryServiceProjectWithStatus model) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + var statuList = await _serviceWorkFlowBaseService.GetEnableProjectWithStatusList(model.TenantId.ToString()); + + TrackingQueryMessageInfo messageInfo = new TrackingQueryMessageInfo + { + Head = new TrackingMessageHeadInfo + { + GID = IDGen.NextID().ToString(), + MessageType = "PROJECT", + ReceiverId = "ServiceProjectStatus", + ReceiverName = "服务项目和状态", + SenderId = "BookingOrder", + SenderName = "海运订舱", + RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), + Version = "2.0", + RequestAction = "AddOrModify", + }, + Main = new TrackingMessageQueryMainInfo + { + BusiId = model.businessId, + BusiSystemCode = "BOOKING_ORDER", + TenantId = model.TenantId.ToString(), + } + }; + + DateTime bDate = DateTime.Now; + //在获取运行表已有的记录 + var runList = InnerGetRunListBySingleBusiness(messageInfo); + + DateTime eDate = DateTime.Now; + TimeSpan ts = eDate.Subtract(bDate); + var timeDiff = ts.TotalMilliseconds; + + _logger.LogInformation("测试读取服务状态-读取数据库记录 耗时:{timeDiff}ms. ", timeDiff); + + int lastWFSortNo = 0; + int calcNum = 1; + + //var allStatus = statuList.SelectMany(b => { + // var curArg = b.StatusList.SelectMany(x => x.SubStatusList).ToList(); + + // if (curArg == null) + // curArg = new List(); + + // curArg.AddRange(b.StatusList); + + // return curArg; + //}).ToList(); + + var resultList = statuList.Join(runList, l => l.WFPKId, + r => r.WFPKId, + (l, r) => { + + var runInfo = r; + + var rltList = new List(); + + if (runInfo.ActivitiesList == null || (runInfo.ActivitiesList != null && runInfo.ActivitiesList.Count == 0)) + { + l.StatusList.ForEach(b => { + rltList.Add(new ServiceProjectStatusDto + { + ActPKId = b.ActPKId, + ActSortNo = b.ActSortNo, + ShowName = b.ShowName, + IsYield = false, + StatusSKUCode = b.StatusSKUCode, + ActRemark = b.ActRemark, + WFSortNo = l.SortNo, + CalcSortNo = (decimal)b.ActSortNo, + SortNo = b.SortNo + }); + + if (b.SubStatusList != null && b.SubStatusList.Count > 0) + { + rltList.AddRange(b.SubStatusList.Select(c => new ServiceProjectStatusDto + { + ActPKId = c.ActPKId, + ActSortNo = c.ActSortNo, + ShowName = c.ShowName, + IsYield = false, + StatusSKUCode = c.StatusSKUCode, + ActRemark = c.ActRemark, + WFSortNo = l.SortNo, + CalcSortNo = (decimal)b.ActSortNo + (c.ActSortNo * 0.001m), + SortNo = c.SortNo + }).ToList()); + } + }); + } + else + { + l.StatusList.ForEach(b => { + + var eRunInfo = runInfo.ActivitiesList + .FirstOrDefault(p => p.ActId == b.ActPKId); + + if (eRunInfo != null) + { + rltList.Add(new ServiceProjectStatusDto + { + ActPKId = eRunInfo.ActId, + ActSortNo = eRunInfo.ExecSortNo, + ShowName = eRunInfo.ShowName, + IsYield = eRunInfo.IsYield == 1 ? true : false, + StatusSKUCode = eRunInfo.StatusSKUCode, + ActDate = eRunInfo.ActDate, + ActVal = eRunInfo.ActVal, + ActRemark = eRunInfo.ActRemark, + WFSortNo = l.SortNo, + CalcSortNo = (decimal)eRunInfo.ExecSortNo, + SortNo = b.SortNo + }); + } + else + { + rltList.Add(new ServiceProjectStatusDto + { + ActPKId = b.ActPKId, + ActSortNo = b.ActSortNo, + ShowName = b.ShowName, + IsYield = false, + StatusSKUCode = b.StatusSKUCode, + ActRemark = b.ActRemark, + WFSortNo = l.SortNo, + CalcSortNo = (decimal)b.ActSortNo, + SortNo = b.SortNo + }); + } + + if (b.SubStatusList != null && b.SubStatusList.Count > 0) + { + b.SubStatusList.ForEach(sb => { + + ServiceWorkFlowActivitiesRunSubDto eSubRunInfo = null; + + if (eRunInfo != null && eRunInfo.SubList != null) + { + eSubRunInfo = eRunInfo.SubList + .FirstOrDefault(p => p.ActId == sb.ActPKId); + } + + if (eSubRunInfo != null) + { + decimal calcSort = (decimal)b.ActSortNo + (eSubRunInfo.ExecSortNo * 0.001m); + + if (eRunInfo != null) + { + calcSort = (decimal)eRunInfo.ExecSortNo + (eSubRunInfo.ExecSortNo * 0.001m); + } + + rltList.Add(new ServiceProjectStatusDto + { + ActPKId = eSubRunInfo.ActId, + ActSortNo = eSubRunInfo.ExecSortNo, + ShowName = eSubRunInfo.ShowName, + IsYield = eSubRunInfo.IsYield == 1 ? true : false, + StatusSKUCode = eSubRunInfo.StatusSKUCode, + ActDate = eSubRunInfo.ActDate, + ActVal = eSubRunInfo.ActVal, + ActRemark = eSubRunInfo.ActRemark, + WFSortNo = l.SortNo, + CalcSortNo = calcSort, + + SortNo = sb.SortNo + }); + } + else + { + decimal calcSort = (decimal)b.ActSortNo + (sb.ActSortNo * 0.001m); + + if (eRunInfo != null) + { + calcSort = (decimal)eRunInfo.ExecSortNo + (sb.ActSortNo * 0.001m); + } + + rltList.Add(new ServiceProjectStatusDto + { + ActPKId = sb.ActPKId, + ActSortNo = sb.ActSortNo, + ShowName = sb.ShowName, + IsYield = false, + StatusSKUCode = sb.StatusSKUCode, + ActRemark = sb.ActRemark, + WFSortNo = l.SortNo, + CalcSortNo = calcSort, + SortNo = sb.SortNo + }); + } + }); + } + }); + } + + if (rltList != null && rltList.Count > 0) + { + var maxSort = rltList.Max(t => t.CalcSortNo); + rltList.FirstOrDefault(t => t.CalcSortNo == maxSort).IsEnd = true; + } + return rltList; + }).SelectMany(b => b).OrderBy(b => b.WFSortNo).Select(b => { + if (lastWFSortNo == 0) + { + b.GroupName = calcNum.ToString(); + lastWFSortNo = b.WFSortNo; + } + else if (b.WFSortNo == lastWFSortNo) + { + b.GroupName = calcNum.ToString(); + } + else + { + ++calcNum; + lastWFSortNo = b.WFSortNo; + b.GroupName = calcNum.ToString(); + } + + return b; + }).OrderBy(b => b.WFSortNo).ThenBy(b => b.CalcSortNo).ToList(); + + + result.succ = true; + result.ext = resultList; + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"检索服务项目下的状态列表失败,原因:{ex.Message}"; + } + + return result; + + + } + #endregion + } } diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index bcf94df1..2c856239 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -10247,6 +10247,11 @@ 船代名称 + + + 模块(公用时为空字符串) + + 备注