From f0b9ba8dde01bed9ab5512d6fd236022d84ab73f Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 31 Jan 2023 09:33:27 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E6=88=91=E7=9A=84=E4=BB=BB=E5=8A=A1-?= =?UTF-8?q?=E6=96=B0=E5=A2=9EBC=E9=87=8D=E6=96=B0=E6=AF=94=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/TaskManagePlat/TaskStoreMsgInfo.cs | 34 ++++++++++ .../Interface/ITaskManageService.cs | 6 ++ .../TaskManagePlat/TaskManageService.cs | 65 +++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 Myshipping.Application/Entity/TaskManagePlat/TaskStoreMsgInfo.cs diff --git a/Myshipping.Application/Entity/TaskManagePlat/TaskStoreMsgInfo.cs b/Myshipping.Application/Entity/TaskManagePlat/TaskStoreMsgInfo.cs new file mode 100644 index 00000000..f2311a21 --- /dev/null +++ b/Myshipping.Application/Entity/TaskManagePlat/TaskStoreMsgInfo.cs @@ -0,0 +1,34 @@ +using Myshipping.Application.Entity; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// 任务报文表 + /// + [SugarTable("task_store_msg")] + [Description(" 任务报文表")] + public class TaskStoreMsgInfo : TaskManageDbEntity + { + /// + /// 任务主键(父主键) + /// + public string TASK_PKID { get; set; } + + /// + /// 报文JSON + /// + public string MSG_JSON { get; set; } + + /// + /// 报文类型 BC_MSG-订舱确认报文 + /// + public string MSG_TYPE { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs index 701ff4ea..0e9289db 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs @@ -219,5 +219,11 @@ namespace Myshipping.Application /// 返回结果 Task GetAbortChangeShipInfo(string taskPKId); + /// + /// 手工批量重新比对BC + /// + /// 任务主键数组 + /// 返回结果 + Task ManualReCompareBC(string[] PKIds); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 09360c33..648beaf2 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -76,6 +76,7 @@ namespace Myshipping.Application private readonly SqlSugarRepository _taskChargesHisInfoRepository; private readonly SqlSugarRepository _taskLARAPaperInfoRepository; private readonly SqlSugarRepository _taskPerBillBaseInfoRepository; + private readonly SqlSugarRepository _taskStoreMsgInfoRepository; private readonly SqlSugarRepository _bookingOrderRepository; private readonly SqlSugarRepository _bookingOrderContaRepository; @@ -113,6 +114,7 @@ namespace Myshipping.Application SqlSugarRepository bookingStatusRepository, SqlSugarRepository djyUserMailAccountRepository, SqlSugarRepository taskPerBillBaseInfoRepository, + SqlSugarRepository taskStoreMsgInfoRepository, IDjyWebsiteAccountConfigService webAccountConfig, ISysCacheService cache, ILogger logger) @@ -135,6 +137,7 @@ namespace Myshipping.Application _bookingStatusRepository = bookingStatusRepository; _djyUserMailAccountRepository = djyUserMailAccountRepository; _taskPerBillBaseInfoRepository = taskPerBillBaseInfoRepository; + _taskStoreMsgInfoRepository = taskStoreMsgInfoRepository; _webAccountConfig = webAccountConfig; _cache = cache; @@ -3404,6 +3407,68 @@ namespace Myshipping.Application return model; } #endregion + + #region 手工批量重新比对BC + /// + /// 手工批量重新比对BC + /// + /// 任务主键数组 + /// 返回结果 + [HttpPost("/TaskManage/ManualReCompareBC")] + public async Task ManualReCompareBC(string[] PKIds) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + string batchNo = IDGen.NextID().ToString(); + + _logger.LogInformation("批次={no} ids={ids} 手工批量重新比对BC开始", batchNo, string.Join(",", PKIds)); + + try + { + var taskList = _taskBaseInfoRepository.AsQueryable().Where(t => PKIds.Contains(t.PK_ID)).ToList(); + + _logger.LogInformation("批次={no} 获取任务完成,Num={Num}", batchNo, taskList.Count); + + + taskList.ForEach(async tsk => + { + + //await InnerDownloadOriginalTask(batchNo, tsk, userWebAccountConfig); + }); + + result.succ = true; + result.msg = "成功"; + } + catch (Exception ex) + { + throw Oops.Bah("手工批量重新比对BC异常,{0}", ex.Message); + } + + return result; + } + #endregion + + #region 手工单票重新比对BC + /// + /// 手工单票重新比对BC + /// + /// 任务详情 + /// 返回结果 + private async Task InnerSingleManualReCompareBC(TaskBaseInfo model) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + } + catch (Exception ex) + { + throw Oops.Bah("手工重新比对BC异常,{0}", ex.Message); + } + + return result; + } + #endregion } #region 样本业务提取帮助类 From 86a25c78190d27903e3cc122fdcc570c42cfdd05 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 31 Jan 2023 11:14:01 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E6=88=91=E7=9A=84=E4=BB=BB=E5=8A=A1-?= =?UTF-8?q?=E5=8F=91=E9=80=81SI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 4 +- .../BookingOrder/IBookingOrderService.cs | 2 + .../Interface/ITaskManageService.cs | 29 +++++ .../TaskManagePlat/TaskManageService.cs | 122 ++++++++++++++++++ 4 files changed, 156 insertions(+), 1 deletion(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index bb516ad2..5242299f 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -2850,6 +2850,7 @@ namespace Myshipping.Application } #endregion + [NonAction] public async Task InnerBookingOrClosingEDI(BookingOrClosingEDIOrderDto model) { string batchNo = IDGen.NextID().ToString(); @@ -3221,7 +3222,8 @@ namespace Myshipping.Application /// 订单主键 /// 订单号 /// 是否使用货代代码 - /// 货代代码 + /// 货代代码 + /// 货代称呼 /// 文件功能 (9原始,1 更新,5 退舱 ) /// 发送类型 B-订舱 E-截单 /// diff --git a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs index adc38634..2f089214 100644 --- a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs @@ -43,5 +43,7 @@ namespace Myshipping.Application Task SendBookingOrClosingEDI (BookingOrClosingEDIOrderDto model); Task BachUpdate(BatchUpdate dto); + + Task InnerBookingOrClosingEDI(BookingOrClosingEDIOrderDto model); } } \ No newline at end of file diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs index 0e9289db..d434ad2f 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs @@ -225,5 +225,34 @@ namespace Myshipping.Application /// 任务主键数组 /// 返回结果 Task ManualReCompareBC(string[] PKIds); + + /// + /// 下载截单EDI + /// + /// 任务主键 + /// 订单号 + /// 是否使用货代代码 + /// 货代代码 + /// 货代称呼 + /// 文件功能 (9原始,1 更新,5 退舱 ) + /// 发送类型 B-订舱 E-截单 + /// + Task DownloadClosingEDI(string taskPKId, string orderNo, bool useForwarderCode, + string forwarderCode, string forwarderName, string fileRole, string sendType); + + + /// + /// 发送截单EDI + /// + /// 任务主键 + /// 订单号 + /// 是否使用货代代码 + /// 货代代码 + /// 货代称呼 + /// 文件功能 (9原始,1 更新,5 退舱 ) + /// 发送类型 E-截单 + /// 返回结果 + Task SendClosingEDI(string taskPKId, string orderNo, bool useForwarderCode, + string forwarderCode, string forwarderName, string fileRole, string sendType); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 648beaf2..2a5671ce 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -89,6 +89,7 @@ namespace Myshipping.Application private readonly ISysCacheService _cache; private readonly ILogger _logger; + private readonly INamedServiceProvider _namedBookingOrderServiceProvider; const string CONST_WEB_ACCOUNT_TYPE = "CmaWeb"; const string CONST_BOOK_ORIGINAL_DOWN_URL_CODE = "bookOriginalDownUrl"; @@ -115,6 +116,7 @@ namespace Myshipping.Application SqlSugarRepository djyUserMailAccountRepository, SqlSugarRepository taskPerBillBaseInfoRepository, SqlSugarRepository taskStoreMsgInfoRepository, + INamedServiceProvider namedBookingOrderServiceProvider, IDjyWebsiteAccountConfigService webAccountConfig, ISysCacheService cache, ILogger logger) @@ -139,6 +141,8 @@ namespace Myshipping.Application _taskPerBillBaseInfoRepository = taskPerBillBaseInfoRepository; _taskStoreMsgInfoRepository = taskStoreMsgInfoRepository; + _namedBookingOrderServiceProvider = namedBookingOrderServiceProvider; + _webAccountConfig = webAccountConfig; _cache = cache; @@ -3469,6 +3473,124 @@ namespace Myshipping.Application return result; } #endregion + + #region 下载截单EDI + /// + /// 下载截单EDI + /// + /// 任务主键 + /// 订单号 + /// 是否使用货代代码 + /// 货代代码 + /// 货代称呼 + /// 文件功能 (9原始,1 更新,5 退舱 ) + /// 发送类型 E-截单 + /// 返回结果 + [HttpGet("/TaskManage/DownloadClosingEDI")] + public async Task DownloadClosingEDI([FromQuery] string taskPKId, [FromQuery] string orderNo, [FromQuery] bool useForwarderCode, + [FromQuery] string forwarderCode, [FromQuery] string forwarderName, [FromQuery] string fileRole, [FromQuery] string sendType) + { + if (sendType?.ToUpper() != "B") + throw Oops.Oh($"sendType只接收E-截单"); + + var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskPKId); + + if (taskInfo == null) + throw Oops.Oh($"任务信息获取失败"); + + if (string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO)) + throw Oops.Oh($"任务信息的订舱主键不存在"); + + if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.SI_FEEDBACK.ToString()) + throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.SI_FEEDBACK.GetDescription()}"); + + BookingOrder bookingOrder = null; + + if (!string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO)) + bookingOrder = _bookingOrderRepository.AsQueryable().First(t => t.Id == long.Parse(taskInfo.BOOK_ORDER_NO)); + + if (bookingOrder == null) + throw Oops.Oh($"订舱信息获取失败,MBLNO={taskInfo.MBL_NO}"); + + var model = new BookingOrClosingEDIOrderDto + { + Id = bookingOrder.Id, + orderNo = orderNo, + useForwarderCode = useForwarderCode, + forwarderCode = forwarderCode, + forwarderName = forwarderName, + fileRole = fileRole, + send = false, + sendType = sendType + }; + + var bookingOrderService = _namedBookingOrderServiceProvider.GetService(nameof(BookingOrderService)); + + var filePath = await bookingOrderService.InnerBookingOrClosingEDI(model); + + var fileInfo = new FileInfo(filePath); + + var result = new FileStreamResult(new FileStream(filePath, FileMode.Open), "application/octet-stream") { FileDownloadName = fileInfo.Name }; + return result; + } + #endregion + + + #region 发送截单EDI + /// + /// 发送截单EDI + /// + /// 任务主键 + /// 订单号 + /// 是否使用货代代码 + /// 货代代码 + /// 货代称呼 + /// 文件功能 (9原始,1 更新,5 退舱 ) + /// 发送类型 E-截单 + /// 返回结果 + [HttpPost("/TaskManage/SendClosingEDI")] + public async Task SendClosingEDI([FromQuery] string taskPKId, [FromQuery] string orderNo, [FromQuery] bool useForwarderCode, + [FromQuery] string forwarderCode, [FromQuery] string forwarderName, [FromQuery] string fileRole, [FromQuery] string sendType) + { + if (sendType?.ToUpper() != "B") + throw Oops.Oh($"sendType只接收E-截单"); + + var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskPKId); + + if (taskInfo == null) + throw Oops.Oh($"任务信息获取失败"); + + if (string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO)) + throw Oops.Oh($"任务信息的订舱主键不存在"); + + if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.SI_FEEDBACK.ToString()) + throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.SI_FEEDBACK.GetDescription()}"); + + BookingOrder bookingOrder = null; + + if (!string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO)) + bookingOrder = _bookingOrderRepository.AsQueryable().First(t => t.Id == long.Parse(taskInfo.BOOK_ORDER_NO)); + + if (bookingOrder == null) + throw Oops.Oh($"订舱信息获取失败,MBLNO={taskInfo.MBL_NO}"); + + var model = new BookingOrClosingEDIOrderDto + { + Id = bookingOrder.Id, + orderNo = orderNo, + useForwarderCode = useForwarderCode, + forwarderCode = forwarderCode, + forwarderName = forwarderName, + fileRole = fileRole, + send = true, + sendType = sendType + }; + + var bookingOrderService = _namedBookingOrderServiceProvider.GetService(nameof(BookingOrderService)); + + return await bookingOrderService.InnerBookingOrClosingEDI(model); + } + #endregion } #region 样本业务提取帮助类 From fe71a9cb6afa6f92b0b7c68f323a3f6c27936206 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 31 Jan 2023 11:18:52 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E6=88=91=E7=9A=84=E4=BB=BB=E5=8A=A1-?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TaskManagePlat/TaskManageService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 2a5671ce..de7a5631 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -3548,7 +3548,7 @@ namespace Myshipping.Application /// 文件功能 (9原始,1 更新,5 退舱 ) /// 发送类型 E-截单 /// 返回结果 - [HttpPost("/TaskManage/SendClosingEDI")] + [HttpGet("/TaskManage/SendClosingEDI")] public async Task SendClosingEDI([FromQuery] string taskPKId, [FromQuery] string orderNo, [FromQuery] bool useForwarderCode, [FromQuery] string forwarderCode, [FromQuery] string forwarderName, [FromQuery] string fileRole, [FromQuery] string sendType) { From 253f226e624ac01f5698ee11c59233288c92985c Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 31 Jan 2023 13:43:23 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E6=88=91=E7=9A=84=E4=BB=BB=E5=8A=A1-?= =?UTF-8?q?=E6=96=B0=E5=A2=9ELARA=E7=BA=B8=E8=AE=A1=E7=AE=97=E9=A1=B5?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/CalcLaraPageNumbersDto.cs | 29 +++++++++++++++++++ .../Dtos/LaraPaperRegistPostDto.cs | 5 ++++ .../Interface/ITaskManageService.cs | 8 +++++ .../TaskManagePlat/TaskManageService.cs | 24 +++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs new file mode 100644 index 00000000..b1124318 --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// + /// + public class CalcLaraPageNumbersDto + { + /// + /// 请求LARA纸列表 + /// + public List paperList { get; set; } + + /// + /// 当前任务主键 + /// + public string taskPkId { get; set; } + + /// + /// 移动方向 up-向上 down-向下 + /// + public string moveType { get; set; } = "down"; + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/LaraPaperRegistPostDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/LaraPaperRegistPostDto.cs index a9b4a101..113b7ab2 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/LaraPaperRegistPostDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/LaraPaperRegistPostDto.cs @@ -55,5 +55,10 @@ namespace Myshipping.Application /// /// public string ISSUETYPE { get; set; } + + /// + /// 排序值 + /// + public int SortNo { get; set; } } } diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs index d434ad2f..43c8f955 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs @@ -254,5 +254,13 @@ namespace Myshipping.Application /// 返回结果 Task SendClosingEDI(string taskPKId, string orderNo, bool useForwarderCode, string forwarderCode, string forwarderName, string fileRole, string sendType); + + + /// + /// 计算LARA纸计算页数 + /// + /// 请求LARA纸详情 + /// 返回结果 + Task> CalcLaraPageNumbers(CalcLaraPageNumbersDto model); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index de7a5631..79924419 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -3591,6 +3591,30 @@ namespace Myshipping.Application return await bookingOrderService.InnerBookingOrClosingEDI(model); } #endregion + + #region 计算LARA纸计算页数 + /// + /// 计算LARA纸计算页数 + /// + /// 请求LARA纸详情 + /// 返回结果 + [HttpPost("/TaskManage/CalcLaraPageNumbers")] + public async Task> CalcLaraPageNumbers(CalcLaraPageNumbersDto model) + { + List list = new List(); + + try + { + list = model.paperList; + } + catch (Exception ex) + { + throw Oops.Bah("计算LARA纸计算页数异常,{0}", ex.Message); + } + + return list; + } + #endregion } #region 样本业务提取帮助类 From a6480ff6b54a4cee9dd3fc18352b2516d4e56ee8 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 31 Jan 2023 14:21:30 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E6=88=91=E7=9A=84=E4=BB=BB=E5=8A=A1-?= =?UTF-8?q?=E4=BF=AE=E6=94=B9LARA=E7=BA=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs | 5 +++++ .../Service/TaskManagePlat/TaskManageService.cs | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs index b1124318..6630566b 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs @@ -25,5 +25,10 @@ namespace Myshipping.Application /// 移动方向 up-向上 down-向下 /// public string moveType { get; set; } = "down"; + + /// + /// 上次结束编号 + /// + public Int32 NumberTo { get; set; } } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 79924419..7564674a 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -3490,7 +3490,7 @@ namespace Myshipping.Application public async Task DownloadClosingEDI([FromQuery] string taskPKId, [FromQuery] string orderNo, [FromQuery] bool useForwarderCode, [FromQuery] string forwarderCode, [FromQuery] string forwarderName, [FromQuery] string fileRole, [FromQuery] string sendType) { - if (sendType?.ToUpper() != "B") + if (sendType?.ToUpper() != "E") throw Oops.Oh($"sendType只接收E-截单"); var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskPKId); @@ -3552,7 +3552,7 @@ namespace Myshipping.Application public async Task SendClosingEDI([FromQuery] string taskPKId, [FromQuery] string orderNo, [FromQuery] bool useForwarderCode, [FromQuery] string forwarderCode, [FromQuery] string forwarderName, [FromQuery] string fileRole, [FromQuery] string sendType) { - if (sendType?.ToUpper() != "B") + if (sendType?.ToUpper() != "E") throw Oops.Oh($"sendType只接收E-截单"); var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskPKId); From c4016e3cc99ebbe8faf4fb97fc1d693005f27a1c Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 31 Jan 2023 15:03:57 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E6=88=91=E7=9A=84=E4=BB=BB=E5=8A=A1-LARA?= =?UTF-8?q?=E7=BA=B8=E5=A2=9E=E5=8A=A0=E8=AE=A1=E7=AE=97=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs index 6630566b..805742e0 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs @@ -29,6 +29,16 @@ namespace Myshipping.Application /// /// 上次结束编号 /// - public Int32 NumberTo { get; set; } + public Int32 numberTo { get; set; } + + /// + /// 原始序号 + /// + public Nullable origIndex { get; set; } + + /// + /// 现序号 + /// + public Nullable currIndex { get; set; } } } From b7880fa0e75f7e18d6357dab2e88ca5a2209b62e Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 1 Feb 2023 16:03:47 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E6=88=91=E7=9A=84=E4=BB=BB=E5=8A=A1-?= =?UTF-8?q?=E4=BF=AE=E6=94=B9VGM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/CalcLaraPageNumbersDto.cs | 2 +- .../Dtos/LaraPaperRegistPostDto.cs | 12 +- .../TaskManagePlat/TaskManageService.cs | 137 ++++++++++++++++-- 3 files changed, 134 insertions(+), 17 deletions(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs index 805742e0..dee4d66d 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/CalcLaraPageNumbersDto.cs @@ -29,7 +29,7 @@ namespace Myshipping.Application /// /// 上次结束编号 /// - public Int32 numberTo { get; set; } + public string numberTo { get; set; } /// /// 原始序号 diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/LaraPaperRegistPostDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/LaraPaperRegistPostDto.cs index 113b7ab2..1c054645 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/LaraPaperRegistPostDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/LaraPaperRegistPostDto.cs @@ -59,6 +59,16 @@ namespace Myshipping.Application /// /// 排序值 /// - public int SortNo { get; set; } + public decimal SortNo { get; set; } + + /// + /// + /// + public int DraftNum { get; set; } + + /// + /// + /// + public int LastNumberTo { get; set; } } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 7564674a..6b5d95e4 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -97,6 +97,9 @@ namespace Myshipping.Application const string CONST_WEB_LARA_ACCOUNT_TYPE = "LaraWeb"; const string CONST_LARA_DOWN_URL_CODE = "LaraPaperPostUrl"; + //LARA纸计算常量 + const int LARA_PARER_DRAFT_VAR = 3; + public TaskManageService(SqlSugarRepository taskBaseInfoRepository, SqlSugarRepository taskSIFeedBackInfoRepository, SqlSugarRepository taskSIFeedBackContaInfoRepository, @@ -3034,31 +3037,31 @@ namespace Myshipping.Application if (currInfo != null) { - if(!l.SEALNO.Equals(currInfo.SEAL_NO)) + if(l.SEALNO != currInfo.SEAL_NO) { md.compareDiffList.Add(nameof(TaskVgmCompareDto.SealNo)); } - if (!l.CTNCODE.Equals(currInfo.CONTA_TYPE)) + if (l.CTNCODE != currInfo.CONTA_TYPE) { md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaType)); } - if (!l.CTNALL.Equals(currInfo.CONTA_TYPE_NAME)) + if (l.CTNALL != currInfo.CONTA_TYPE_NAME) { md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaTypeName)); } - if (!l.KGS.Equals(currInfo.KGS)) + if (l.KGS != currInfo.KGS) { md.compareDiffList.Add(nameof(TaskVgmCompareDto.KGS)); } - if (!l.TAREWEIGHT.Equals(currInfo.TAREWEIGHT)) + if (l.TAREWEIGHT != currInfo.TAREWEIGHT) { md.compareDiffList.Add(nameof(TaskVgmCompareDto.TareWeight)); } - if (!l.WEIGHKGS.Equals(currInfo.WEIGHKGS)) + if (l.WEIGHKGS != currInfo.WEIGHKGS) { md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighKGs)); } - if (!l.WEIGHTYPE.Equals(currInfo.WEIGHTYPE)) + if (l.WEIGHTYPE != currInfo.WEIGHTYPE) { md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighType)); } @@ -3088,31 +3091,31 @@ namespace Myshipping.Application if (currInfo != null) { - if (!l.SEAL_NO.Equals(currInfo.SEALNO)) + if (l.SEAL_NO != currInfo.SEALNO) { md.compareDiffList.Add(nameof(TaskVgmCompareDto.SealNo)); } - if (!l.CONTA_TYPE.Equals(currInfo.CTNCODE)) + if (l.CONTA_TYPE != currInfo.CTNCODE) { md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaType)); } - if (!l.CONTA_TYPE_NAME.Equals(currInfo.CTNALL)) + if (l.CONTA_TYPE_NAME != currInfo.CTNALL) { md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaTypeName)); } - if (!l.KGS.Equals(currInfo.KGS)) + if (l.KGS != currInfo.KGS) { md.compareDiffList.Add(nameof(TaskVgmCompareDto.KGS)); } - if (!l.TAREWEIGHT.Equals(currInfo.TAREWEIGHT)) + if (l.TAREWEIGHT != currInfo.TAREWEIGHT) { md.compareDiffList.Add(nameof(TaskVgmCompareDto.TareWeight)); } - if (!l.WEIGHKGS.Equals(currInfo.WEIGHKGS)) + if (l.WEIGHKGS != currInfo.WEIGHKGS) { md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighKGs)); } - if (!l.WEIGHTYPE.Equals(currInfo.WEIGHTYPE)) + if (l.WEIGHTYPE != currInfo.WEIGHTYPE) { md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighType)); } @@ -3603,9 +3606,22 @@ namespace Myshipping.Application { List list = new List(); + /* + LARA计算方法 + + 1、判断是否为首次加载,model.moveType为空时表示首次加载,触发InitCalcLaraPageNumbers方法。 + 2、如果 model.moveType有值时,判断是调整行位置,根据指定的行位置重新计算编号。 + */ try { - list = model.paperList; + if(string.IsNullOrWhiteSpace(model.moveType)) + { + list = InnerCalcLaraPageNumbers(model,true); + } + else + { + list = InnerCalcLaraPageNumbers(model); + } } catch (Exception ex) { @@ -3615,6 +3631,97 @@ namespace Myshipping.Application return list; } #endregion + + #region 计算LARA纸 + /// + /// 计算LARA纸 + /// + /// 请求LARA纸详情 + /// 是否初始化 true-初始化 + /// + private List InnerCalcLaraPageNumbers(CalcLaraPageNumbersDto model,bool isInit = false) + { + List list = new List(); + + //如果判断不是首次加载,需要将移动的行从列表移动到指定位置后,重新计算。 + if(!isInit) + { + model.paperList = model.paperList.Select(t => + { + if (t.SortNo == model.origIndex.Value) + { + //up + if(model.currIndex < model.origIndex) + { + t.SortNo = (decimal)model.currIndex.Value - 0.1m; + } + else + { + t.SortNo = (decimal)model.currIndex.Value + 0.1m; + } + } + + return t; + }).OrderBy(t => t.SortNo) + .Select((t, idx) => + { + t.SortNo = (decimal)idx + 1; + return t; + + }).ToList(); + } + + var mNumberTo = int.Parse(model.numberTo.TrimStart('0')); + + if (mNumberTo > 0) + { + int lastNumberTo = 0; + int lastNumberFrom = 0; + + model.paperList.OrderBy(t => t.SortNo).ToList().ForEach(t => + { + LaraPaperRegistPostDto info = new LaraPaperRegistPostDto(); + + info.SortNo = t.SortNo; + info.DraftNum = t.DraftNum; + info.TaskId = t.TaskId; + info.ORDNO = t.ORDNO; + info.MBLNO = t.MBLNO; + info.ISSUETYPE = t.ISSUETYPE; + + if (t.SortNo == 1) + { + lastNumberFrom = mNumberTo + 1; + info.NumberFrom = (lastNumberFrom).ToString().PadLeft(9, '0'); + + var currNumberTo = (t.DraftNum * LARA_PARER_DRAFT_VAR) + mNumberTo; + + info.NumberTo = currNumberTo.ToString().PadLeft(9, '0'); + info.PageSum = currNumberTo - lastNumberFrom + 1; + + lastNumberTo = currNumberTo; + } + else + { + lastNumberFrom = lastNumberTo + 1; + info.NumberFrom = (lastNumberFrom).ToString().PadLeft(9, '0'); + + var currNumberTo = (t.DraftNum * LARA_PARER_DRAFT_VAR) + lastNumberTo; + + info.NumberTo = currNumberTo.ToString().PadLeft(9, '0'); + info.PageSum = currNumberTo - lastNumberFrom + 1; + + lastNumberTo = currNumberTo; + } + + + list.Add(info); + }); + } + + return list; + } + #endregion } #region 样本业务提取帮助类 From 6ff1b48229c3c8772fcd0b066eda53dbac3aa5a1 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 1 Feb 2023 17:03:46 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E6=88=91=E7=9A=84=E4=BB=BB=E5=8A=A1-VGM?= =?UTF-8?q?=E6=AF=94=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/TaskManageOrderExtMessageInfo.cs | 29 +++++++++++++++++++ .../Dtos/TaskManageOrderMessageMainInfo.cs | 5 ++++ .../TaskManagePlat/TaskManageService.cs | 19 +++++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderExtMessageInfo.cs diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderExtMessageInfo.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderExtMessageInfo.cs new file mode 100644 index 00000000..6310f465 --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderExtMessageInfo.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// 任务扩展报文 + /// + public class TaskManageOrderExtMessageInfo + { + /// + /// 序列化报文 + /// + public string SerialMsg { get; set; } + + /// + /// 序列化报文类型 JSON-JSON序列化 + /// + public string SerialType { get; set; } + + /// + /// 业务类型 + /// + public string BusiType { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderMessageMainInfo.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderMessageMainInfo.cs index 1d93e803..f9772e5a 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderMessageMainInfo.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderMessageMainInfo.cs @@ -112,5 +112,10 @@ namespace Myshipping.Application /// 单票账单 /// public TaskManageOrderPerBillInfo PerBillInfo { get; set; } + + /// + /// 序列化报文详情 + /// + public TaskManageOrderExtMessageInfo SerialMsgInfo { get; set; } } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 6b5d95e4..3aec5e1b 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -377,6 +377,20 @@ namespace Myshipping.Application }); } + if (info.Main.SerialMsgInfo != null) + { + var storeInfo = new TaskStoreMsgInfo + { + PK_ID = IDGen.NextID().ToString(), + TASK_PKID = taskInfo.PK_ID, + MSG_JSON = info.Main.SerialMsgInfo.SerialMsg, + CreatedTime = taskInfo.CreatedTime, + UpdatedTime = taskInfo.CreatedTime, + }; + + await _taskStoreMsgInfoRepository.InsertAsync(storeInfo); + } + result.succ = true; result.msg = "新增任务成功"; } @@ -3035,6 +3049,8 @@ namespace Myshipping.Application TaskVgmCompareDto md = l.Adapt(); + md.compareDiffList = new List(); + if (currInfo != null) { if(l.SEALNO != currInfo.SEAL_NO) @@ -3089,6 +3105,8 @@ namespace Myshipping.Application TaskVgmCompareDto md = l.Adapt(); + md.compareDiffList = new List(); + if (currInfo != null) { if (l.SEAL_NO != currInfo.SEALNO) @@ -3538,7 +3556,6 @@ namespace Myshipping.Application } #endregion - #region 发送截单EDI /// /// 发送截单EDI From 9261b62d62f621a0bbd5e107fd07e731727792f9 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 2 Feb 2023 14:15:18 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E6=88=91=E7=9A=84=E4=BB=BB=E5=8A=A1-BC?= =?UTF-8?q?=E6=AF=94=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Enum/TaskStoreMsgTypeEnum.cs | 21 + .../Dtos/TaskBCStoreResultInfo.cs | 128 ++++++ .../TaskManagePlat/TaskManageService.cs | 370 +++++++++++++++++- 3 files changed, 515 insertions(+), 4 deletions(-) create mode 100644 Myshipping.Application/Enum/TaskStoreMsgTypeEnum.cs create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCStoreResultInfo.cs diff --git a/Myshipping.Application/Enum/TaskStoreMsgTypeEnum.cs b/Myshipping.Application/Enum/TaskStoreMsgTypeEnum.cs new file mode 100644 index 00000000..e76cc8a9 --- /dev/null +++ b/Myshipping.Application/Enum/TaskStoreMsgTypeEnum.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// 任务报文类型枚举 + /// + public enum TaskStoreMsgTypeEnum + { + /// + /// 订舱确认报文 + /// + [Description("订舱确认报文")] + BC_MSG, + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCStoreResultInfo.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCStoreResultInfo.cs new file mode 100644 index 00000000..777d39a3 --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCStoreResultInfo.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// 订舱确认结果 + /// + public class TaskBCStoreResultInfo + { + /// + /// 单号 + /// + [JsonPropertyName("bno")] + public string BNo { get; set; } + /// + /// 船名 + /// + [JsonPropertyName("CM")] + public string Vessel { get; set; } + + /// + /// 首程航次 + /// + [JsonPropertyName("HC1")] + public string Voyno { get; set; } + + /// + /// 二程航次 + /// + [JsonPropertyName("HC2")] + public string Voyno2 { get; set; } + + /// + /// 三程航次 + /// + [JsonPropertyName("HC3")] + public string Voyno3 { get; set; } + + /// + /// VGM时间 + /// + [JsonPropertyName("VGMTIME")] + public string VGMTime { get; set; } + + /// + /// ETD + /// + [JsonPropertyName("YJKHSJ")] + public string ETD { get; set; } + + /// + /// 装货截关时间 + /// + [JsonPropertyName("ZHQGSJ")] + public string ClosingDate { get; set; } + + /// + /// 湿度 + /// + [JsonPropertyName("humidity")] + public string Humidity { get; set; } + + /// + /// 最低温度 + /// + [JsonPropertyName("minimum_temperature")] + public string TempMin { get; set; } + + /// + /// 最高温度 + /// + [JsonPropertyName("maximum_temperature")] + public string TempMax { get; set; } + + /// + /// 中转温度 + /// + [JsonPropertyName("transport_temperature")] + public string TempTransport { get; set; } + + /// + /// 卸货港英文名称 + /// + [JsonPropertyName("XHG")] + public string PortDischargeEName { get; set; } + + /// + /// 集装箱 + /// + [JsonPropertyName("XXXL")] + public string CntrTotal { get; set; } + + /// + /// 报价号 + /// + [JsonPropertyName("BJH")] + public string BJH { get; set; } + + /// + /// 服务合同号 + /// + [JsonPropertyName("FWHT")] + public string FWHT { get; set; } + + /// + /// 通风立方米 + /// + [JsonPropertyName("ventilation_cubic_meter")] + public string VentilationCubicMeter { get; set; } + + /// + /// 客人参考号 + /// + [JsonPropertyName("guest_reference_number")] + public string GuestReferenceNumber { get; set; } + + /// + /// 最终交货地 + /// + [JsonPropertyName("ZZJHD")] + public string ZZJHD { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 3aec5e1b..836be510 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -21,6 +21,7 @@ using Myshipping.Core.Entity; using Myshipping.Core.Helper; using Myshipping.Core.Service; using MySqlX.XDevAPI.Common; +using NetTaste; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Npoi.Mapper; @@ -34,7 +35,9 @@ using NPOI.SS.Formula.Functions; using NPOI.SS.UserModel; using NPOI.Util; using NPOI.XSSF.Model; +using Org.BouncyCastle.Asn1.Tsp; using Org.BouncyCastle.Asn1.X500; +using Org.BouncyCastle.Asn1.X9; using SixLabors.ImageSharp.Processing.Processors.Transforms; using SqlSugar; using StackExchange.Profiling.Internal; @@ -97,6 +100,8 @@ namespace Myshipping.Application const string CONST_WEB_LARA_ACCOUNT_TYPE = "LaraWeb"; const string CONST_LARA_DOWN_URL_CODE = "LaraPaperPostUrl"; + const string CONST_MAPPING_MODULE = "YunJia"; + //LARA纸计算常量 const int LARA_PARER_DRAFT_VAR = 3; @@ -3454,15 +3459,26 @@ namespace Myshipping.Application _logger.LogInformation("批次={no} 获取任务完成,Num={Num}", batchNo, taskList.Count); - + var list = new List(); + taskList.ForEach(async tsk => { - //await InnerDownloadOriginalTask(batchNo, tsk, userWebAccountConfig); + var rlt = await InnerSingleManualReCompareBC(tsk); + + list.Add(rlt); }); result.succ = true; - result.msg = "成功"; + + if (list.Any(t => !t.succ)) + { + result.msg = "失败"; + } + else + { + result.msg = "成功"; + } } catch (Exception ex) { @@ -3483,18 +3499,364 @@ namespace Myshipping.Application { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + /* + 1、通过任务的报文表获取BC的报文。 + */ try { + var storeInfo = await _taskStoreMsgInfoRepository.AsQueryable() + .Where(t => t.TASK_PKID == model.PK_ID && t.MSG_TYPE == TaskStoreMsgTypeEnum.BC_MSG.ToString()).FirstAsync(); + + if(storeInfo == null) + throw Oops.Oh("MBL_NO={0},获取{1}报文失败", model.MBL_NO,TaskStoreMsgTypeEnum.BC_MSG.GetDescription()); + + var rtl = Newtonsoft.Json.JsonConvert.DeserializeObject(storeInfo.MSG_TYPE); + + var msg = rtl.mesage.ToString(); + + if (string.IsNullOrWhiteSpace(msg)) + throw Oops.Oh("MBL_NO={0},解析{1}报文详情异常", model.MBL_NO, TaskStoreMsgTypeEnum.BC_MSG.GetDescription()); + + + var bookOrderList = _bookingOrderRepository.EntityContext.Queryable() + .InnerJoin((bk, ctn) => bk.Id == ctn.BILLID) + .Where((bk, ctn) => bk.Id == long.Parse(model.BOOK_ORDER_NO) && bk.TenantId == UserManager.TENANT_ID) + .Select((bk, ctn) => new { bk = bk, ctn = ctn }).ToList(); + + //获取订舱详情与BC进行比对 + var orderInfo = bookOrderList.FirstOrDefault().bk; + + List ctnList = new List(); + + if (bookOrderList.Any(t => t.ctn != null)) + ctnList = bookOrderList.Select(t => t.ctn).ToList(); + + if (orderInfo == null) + throw Oops.Oh("MBL_NO={0},获取订舱详情失败", model.MBL_NO); + + TaskBCStoreResultInfo bcStoreInfo = JSON.Deserialize(msg); + + //BC比较 + var compareResult = InnerCompareBC(bcStoreInfo,orderInfo, ctnList); + + if(!compareResult.succ) + { + //更新任务的反馈结果 + model.RESULT_NOTE = compareResult.msg; + model.UpdatedTime = DateTime.Now; + model.UpdatedUserId = UserManager.UserId; + model.UpdatedUserName = UserManager.Name; + + await _taskBaseInfoRepository.AsUpdateable(model).UpdateColumns(it => new + { + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName, + it.RESULT_NOTE, + + }).ExecuteCommandAsync(); + } + else + { + //置任务状态为完成 + model.STATUS = TaskStatusEnum.Complete.ToString(); + model.STATUS_NAME = TaskStatusEnum.Complete.GetDescription(); + model.COMPLETE_DATE = DateTime.Now; + model.COMPLETE_DEAL = TaskCompleteDealEnum.MANUAL.ToString(); + model.COMPLETE_DEAL_NAME = TaskCompleteDealEnum.MANUAL.GetDescription(); + + model.UpdatedTime = DateTime.Now; + model.UpdatedUserId = UserManager.UserId; + model.UpdatedUserName = UserManager.Name; + + await _taskBaseInfoRepository.AsUpdateable(model).UpdateColumns(it => new + { + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName, + it.STATUS, + it.STATUS_NAME, + it.COMPLETE_DATE, + it.COMPLETE_DEAL, + it.COMPLETE_DEAL_NAME + }).ExecuteCommandAsync(); + + //更新订舱的ETD(记个日志) + if (!string.IsNullOrWhiteSpace(bcStoreInfo.ETD)) + { + DateTime etd = DateTime.MinValue; + + if(DateTime.TryParse(bcStoreInfo.ETD,out etd)) + { + orderInfo.ETD = etd; + orderInfo.UpdatedTime = DateTime.Now; + orderInfo.UpdatedUserId = UserManager.UserId; + orderInfo.UpdatedUserName = UserManager.Name; + + await _bookingOrderRepository.AsUpdateable(orderInfo).UpdateColumns(it => new + { + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName, + it.ETD + }).ExecuteCommandAsync(); + } + } + //【预留】异步推送后台任务(订舱自动放舱-BookingFangCang) + //【预留】异步推送后台任务(下货纸-Xiahuozhi) + } + + result.succ = true; + result.msg = "处理成功"; } catch (Exception ex) { - throw Oops.Bah("手工重新比对BC异常,{0}", ex.Message); + result.succ = true; + result.msg = $"手工重新比对BC异常,{ex.Message}"; + + //throw Oops.Bah("手工重新比对BC异常,{0}", ex.Message); } return result; } #endregion + #region 单票比对BC + /// + /// 单票比对BC + /// + /// BC回执详情 + /// 订舱详情 + /// 订舱集装箱列表 + /// 返回结果 + private TaskManageOrderResultDto InnerCompareBC(TaskBCStoreResultInfo bcStoreInfo,BookingOrder orderInfo,List ctnList) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto { succ = true}; + + try + { + List> rltTupleList = new List>(); + + /* + 迁移过来的注释 + 2021-9-28,需求再变,BC需要再次比对约号 + 2021-7-19 需求修改:BC不需要再对比约号 + */ + + //约号 + if (string.IsNullOrEmpty(orderInfo.CONTRACTNO) && + (!string.IsNullOrWhiteSpace(bcStoreInfo.BJH) || !string.IsNullOrWhiteSpace(bcStoreInfo.FWHT))) + { + rltTupleList.Add(new Tuple(false, "约号不一致")); + } + else + { + if (!orderInfo.CONTRACTNO.Contains(bcStoreInfo.BJH) && !orderInfo.CONTRACTNO.Contains(bcStoreInfo.FWHT)) + { + rltTupleList.Add(new Tuple(false, "约号不一致")); + } + } + + #region 集装箱 + //集装箱 + if (bcStoreInfo.CntrTotal != orderInfo.CNTRTOTAL) + { + //集装箱型 + var ediCtnList = _cache.GetAllMappingCtn().GetAwaiter().GetResult() + .Where(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase) + && !string.IsNullOrWhiteSpace(t.CarrierCode) && t.CarrierCode.Equals(orderInfo.CARRIERID, StringComparison.OrdinalIgnoreCase)).ToList(); + + var storeCtnList = bcStoreInfo.CntrTotal.Split(new char[] { ';' }).Select(t => + { + var currArg = t.Split(new char[] { 'x' }); + + return new { Code = currArg[1]?.Trim(), Num = int.Parse(currArg[0]?.Trim()) }; + }).GroupBy(t => t.Code) + .Select(t => + { + return new { Code = t.Key, Num = t.Sum(x => x.Num) }; + }).ToList(); + + var orderCtnListctnList = ctnList.Select(t => + { + var mapCtn = ediCtnList.FirstOrDefault(x => x.Code.Equals(t.CTNCODE)); + + if (mapCtn != null && !string.IsNullOrWhiteSpace(mapCtn.MapCode)) + return new { Code = mapCtn.MapCode, Num = t.CTNNUM.HasValue ? t.CTNNUM.Value : 1 }; + + return new { Code = t.CTNCODE, Num = t.CTNNUM.HasValue ? t.CTNNUM.Value : 1 }; + }).GroupBy(t => t.Code) + .Select(t => + { + return new { Code = t.Key, Num = t.Sum(x => x.Num) }; + }).ToList(); + + if (storeCtnList.Count != orderCtnListctnList.Count) + { + rltTupleList.Add(new Tuple(false, "箱型箱量不一致")); + } + else + { + var totalList = storeCtnList.GroupJoin(orderCtnListctnList, l => l.Code, r => r.Code, (l, r) => + { + var rModel = r.FirstOrDefault(); + + if (rModel == null) + { + return false; + } + else + { + if (l.Num != rModel.Num) + return false; + } + + return true; + }).ToList(); + + if (totalList.Any(t => !t)) + { + rltTupleList.Add(new Tuple(false, "箱型箱量不一致")); + } + } + + } + #endregion + + //船名 + if (bcStoreInfo.Vessel != orderInfo.VESSEL?.Trim()) + { + rltTupleList.Add(new Tuple(false, "船名不一致")); + } + + //航次 + if (bcStoreInfo.Voyno?.Replace("1MA", "") != orderInfo.VOYNO?.Trim() + && bcStoreInfo.Voyno2 != orderInfo.VOYNO?.Trim() && bcStoreInfo.Voyno3 != orderInfo.VOYNO?.Trim()) + { + rltTupleList.Add(new Tuple(false, "航次不一致")); + } + + /* + //2021-10-12,增加最小、最大、运输温度,湿度,通风 的比较 + //2021-11-23,备注中含有NOR,不比较温度湿度等信息 + + 2023-02-02 这里补充了一下EDIREMARK的判断,用正则匹配NOR信息。NOR(冻代干集装箱) + */ + if (orderInfo.CARGOID == "R" && (string.IsNullOrWhiteSpace(orderInfo.SOREMARK) || !Regex.IsMatch(orderInfo.SOREMARK, "\\bNOR\\b"))) + { + //最低温度 + var compareReult = CompareTemperatureNum(orderInfo.TEMPMIN, bcStoreInfo.TempMin, "temp"); + + if (!compareReult.Item1) + rltTupleList.Add(compareReult); + + //最高温度 + compareReult = CompareTemperatureNum(orderInfo.TEMPMAX, bcStoreInfo.TempMax, "temp", "最高温度"); + + if (!compareReult.Item1) + rltTupleList.Add(compareReult); + + //运输温度 + compareReult = CompareTemperatureNum(orderInfo.TEMPSET, bcStoreInfo.TempTransport, "temp", "运输温度"); + + if (!compareReult.Item1) + rltTupleList.Add(compareReult); + + //湿度 + compareReult = CompareTemperatureNum(orderInfo.HUMIDITY, bcStoreInfo.Humidity, "humidity", "湿度"); + + if (!compareReult.Item1) + rltTupleList.Add(compareReult); + + //通风 + compareReult = CompareTemperatureNum(orderInfo.REEFERF, bcStoreInfo.VentilationCubicMeter, "vent", "通风"); + + if (!compareReult.Item1) + rltTupleList.Add(compareReult); + } + + + /* + * 2021-12-3,捷丰要求加卸货港和目的地校验,规则: + * A:大简云里卸货港字段‘,’之前的字符和BC里卸货港‘,’之前的字段。 + * 1.一致,自动发送下货纸 + * 2.不一致,生成待处理下货纸任务。 + * B:bc如果有最终交货地 那么要和系统目的港对比;最终交货地空白 就不用对比这个地方 + */ + string orderPortDischarge = orderInfo.PORTDISCHARGE.Split(new char[] { ',' }).FirstOrDefault()?.Trim(); + string storePortDischarge = bcStoreInfo.PortDischargeEName.Split(new char[] { ',' }).FirstOrDefault()?.Trim(); + + if (orderPortDischarge != storePortDischarge) + rltTupleList.Add(new Tuple(false, "卸货港不一致")); + + string orderDest = orderInfo.DESTINATION.Split(new char[] { ',' }).FirstOrDefault()?.Trim(); + string storeDest = bcStoreInfo.ZZJHD.Split(new char[] { ',' }).FirstOrDefault()?.Trim(); + + if (orderDest != storeDest) + rltTupleList.Add(new Tuple(false, "目的地不一致")); + + if (rltTupleList.Any(t => !t.Item1)) + { + result.succ = false; + result.msg = string.Join(";", rltTupleList.Select(t => t.Item2).ToArray()); + } + } + catch(Exception ex) + { + throw Oops.Bah("{0}单票比对BC异常,{1}",nameof(InnerCompareBC), ex.Message); + } + + return result; + } + #endregion + + #region 对比温度 + /// + /// 对比温度 + /// + /// 订舱数值 + /// 回执数值 + /// 操作类型 temp-温度 humidity-湿度 vent-通风 + /// 显示名称 + /// 返回结果 + private Tuple CompareTemperatureNum(string orderTemperature,string storeTemperature,string operType = "temp",string showName = "最低温度") + { + decimal orderTemp = int.MaxValue; + decimal storeTemp = int.MaxValue; + + decimal.TryParse(orderTemperature, out orderTemp); + + if (!string.IsNullOrWhiteSpace(storeTemperature)) + { + if (operType == "temp") + { + decimal.TryParse(Regex.Match(storeTemperature, "(\\-?([0-9]?|[0-9]+)\\.?[0-9]+)(?=C)").Value, out storeTemp); + } + else if (operType == "humidity") + { + decimal.TryParse(Regex.Match(storeTemperature, "\\[0-9]+").Value, out storeTemp); + } + else if (operType == "vent") + { + decimal.TryParse(storeTemperature, out storeTemp); + } + } + + if (storeTemp != int.MaxValue && orderTemp != int.MaxValue) + { + if (storeTemp != orderTemp) + return new Tuple(false, $"{showName}不一致"); + } + else + { + if (storeTemp != int.MaxValue || orderTemp != int.MaxValue) + return new Tuple(false, $"{showName}不一致"); + } + + return new Tuple(true, ""); + } + #endregion + #region 下载截单EDI /// /// 下载截单EDI From 4573b9aaca8916aeaf8b3e3b9214705336b987f8 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 2 Feb 2023 16:08:52 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E6=88=91=E7=9A=84=E4=BB=BB=E5=8A=A1-BC?= =?UTF-8?q?=E6=AF=94=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskManagePlat/TaskManageService.cs | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 836be510..125ad612 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -389,6 +389,7 @@ namespace Myshipping.Application PK_ID = IDGen.NextID().ToString(), TASK_PKID = taskInfo.PK_ID, MSG_JSON = info.Main.SerialMsgInfo.SerialMsg, + MSG_TYPE = info.Main.SerialMsgInfo.SerialType, CreatedTime = taskInfo.CreatedTime, UpdatedTime = taskInfo.CreatedTime, }; @@ -3463,21 +3464,21 @@ namespace Myshipping.Application taskList.ForEach(async tsk => { - var rlt = await InnerSingleManualReCompareBC(tsk); list.Add(rlt); }); - result.succ = true; if (list.Any(t => !t.succ)) { result.msg = "失败"; + result.succ = false; } else { result.msg = "成功"; + result.succ = true; } } catch (Exception ex) @@ -3510,9 +3511,19 @@ namespace Myshipping.Application if(storeInfo == null) throw Oops.Oh("MBL_NO={0},获取{1}报文失败", model.MBL_NO,TaskStoreMsgTypeEnum.BC_MSG.GetDescription()); - var rtl = Newtonsoft.Json.JsonConvert.DeserializeObject(storeInfo.MSG_TYPE); + var rtl = Newtonsoft.Json.JsonConvert.DeserializeObject(storeInfo.MSG_JSON); + + string msg = string.Empty; + //2023-02-02 测试过程中发现JSON数据格式有了变化,这里增加兼容 + if(rtl.mesage != null) + { + msg = JSON.Serialize(rtl.mesage); + } + else + { + msg = storeInfo.MSG_JSON; + } - var msg = rtl.mesage.ToString(); if (string.IsNullOrWhiteSpace(msg)) throw Oops.Oh("MBL_NO={0},解析{1}报文详情异常", model.MBL_NO, TaskStoreMsgTypeEnum.BC_MSG.GetDescription()); @@ -3611,7 +3622,7 @@ namespace Myshipping.Application } catch (Exception ex) { - result.succ = true; + result.succ = false; result.msg = $"手工重新比对BC异常,{ex.Message}"; //throw Oops.Bah("手工重新比对BC异常,{0}", ex.Message); @@ -3644,14 +3655,17 @@ namespace Myshipping.Application */ //约号 - if (string.IsNullOrEmpty(orderInfo.CONTRACTNO) && - (!string.IsNullOrWhiteSpace(bcStoreInfo.BJH) || !string.IsNullOrWhiteSpace(bcStoreInfo.FWHT))) + if (!string.IsNullOrWhiteSpace(orderInfo.CONTRACTNO)) { - rltTupleList.Add(new Tuple(false, "约号不一致")); + if ((string.IsNullOrWhiteSpace(bcStoreInfo.BJH) || !Regex.IsMatch(orderInfo.CONTRACTNO, $"\\b{bcStoreInfo.BJH.Trim()}\\b")) + && (string.IsNullOrWhiteSpace(bcStoreInfo.FWHT) || !Regex.IsMatch(orderInfo.CONTRACTNO, $"\\b{bcStoreInfo.FWHT.Trim()}\\b"))) + { + rltTupleList.Add(new Tuple(false, "约号不一致")); + } } else { - if (!orderInfo.CONTRACTNO.Contains(bcStoreInfo.BJH) && !orderInfo.CONTRACTNO.Contains(bcStoreInfo.FWHT)) + if (!string.IsNullOrWhiteSpace(bcStoreInfo.BJH) || !string.IsNullOrWhiteSpace(bcStoreInfo.FWHT)) { rltTupleList.Add(new Tuple(false, "约号不一致")); }