From 8409ab21941dcdfdbe649675e89b7a83777f7659 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 13 Mar 2024 10:43:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9VGM=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/BookingCtnVGM.cs | 10 + .../Entity/TaskManagePlat/TaskVGMInfo.cs | 5 + .../Enum/TaskBusiTypeEnum.cs | 11 +- .../BookingOrder/BookingValueAddedService.cs | 4 +- .../TaskManagePlat/Dtos/TaskManageMapper.cs | 31 +++ .../TaskManagePlat/Dtos/VGM/TaskVGMDto.cs | 6 + .../TaskManagePlat/Dtos/VGM/TaskVGMShowDto.cs | 31 +++ .../Interface/ITaskManageVGMService.cs | 42 ++++ .../TaskManagePlat/TaskManageService.cs | 158 +++++++++----- .../TaskManagePlat/TaskManageVGMService.cs | 199 ++++++++++++++++++ 10 files changed, 437 insertions(+), 60 deletions(-) create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/VGM/TaskVGMShowDto.cs create mode 100644 Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageVGMService.cs create mode 100644 Myshipping.Application/Service/TaskManagePlat/TaskManageVGMService.cs diff --git a/Myshipping.Application/Entity/BookingCtnVGM.cs b/Myshipping.Application/Entity/BookingCtnVGM.cs index 6bb08d7b..82b0c16b 100644 --- a/Myshipping.Application/Entity/BookingCtnVGM.cs +++ b/Myshipping.Application/Entity/BookingCtnVGM.cs @@ -51,5 +51,15 @@ namespace Myshipping.Application.Entity /// 接收时间 /// public Nullable REC_TIME { get; set; } + + /// + /// 是否未提交VGM + /// + public bool IS_MISSING { get; set; } + + /// + /// 最晚提交期限 + /// + public Nullable SUBMISSION_DEADLINE { get; set; } } } diff --git a/Myshipping.Application/Entity/TaskManagePlat/TaskVGMInfo.cs b/Myshipping.Application/Entity/TaskManagePlat/TaskVGMInfo.cs index 550e4d2d..86cd105c 100644 --- a/Myshipping.Application/Entity/TaskManagePlat/TaskVGMInfo.cs +++ b/Myshipping.Application/Entity/TaskManagePlat/TaskVGMInfo.cs @@ -72,5 +72,10 @@ namespace Myshipping.Application /// 订舱ID /// public Nullable BOOKING_ID { get; set; } + + /// + /// VGM通知类型 VGM_MISSING-VGM未提交,VGM_FEEDBACK-VGM回执 + /// + public string TASK_TYPE { get; set; } } } diff --git a/Myshipping.Application/Enum/TaskBusiTypeEnum.cs b/Myshipping.Application/Enum/TaskBusiTypeEnum.cs index cbaa138d..569c1336 100644 --- a/Myshipping.Application/Enum/TaskBusiTypeEnum.cs +++ b/Myshipping.Application/Enum/TaskBusiTypeEnum.cs @@ -139,9 +139,9 @@ namespace Myshipping.Application MSC_PENDING, /// - /// VGM反馈详情 + /// VGM回执 /// - [Description("VGM反馈详情")] + [Description("VGM回执")] VGM_FEEDBACK, /// /// 比对下货纸 @@ -174,6 +174,11 @@ namespace Myshipping.Application /// Transfer Nomination(预甩货通知) /// [Description("TransferNomination")] - TRANSFER_NOMINATION + TRANSFER_NOMINATION, + /// + /// VGM未提交 + /// + [Description("VGM未提交")] + VGM_MISSING, } } diff --git a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs index a7b810b3..1ae56596 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs @@ -2567,12 +2567,13 @@ namespace Myshipping.Application } #endregion - + #region 获取订舱对应的集装箱VGM回执详情 /// /// 获取订舱对应的集装箱VGM回执详情 /// /// 订舱ID /// 返回VGM明细 + [HttpGet("/BookingValueAdded/GetBookingVGMResult")] public async Task> GetBookingVGMResult(long id) { List list = new List(); @@ -2594,6 +2595,7 @@ namespace Myshipping.Application return list; } + #endregion } public class DateTimeJsonConverter : System.Text.Json.Serialization.JsonConverter> diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs index f0ec2e9c..c752e495 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs @@ -938,6 +938,37 @@ namespace Myshipping.Application .Map(dest => dest.CtnAll, src => src.CTNALL) .Map(dest => dest.CtnNum, src => src.CTNNUM) .Map(dest => dest.PKId, src => src.PK_ID); + + config.ForType() + .Map(dest => dest.PKId, src => src.PK_ID) + .Map(dest => dest.TaskId, src => src.TASK_ID) + .Map(dest => dest.MBlNo, src => src.MBL_NO) + .Map(dest => dest.Carrier, src => src.CARRIER) + .Map(dest => dest.Vessel, src => src.VESSEL) + .Map(dest => dest.Voyno, src => src.VOYNO) + .Map(dest => dest.PortLoad, src => src.PORTLOAD) + .Map(dest => dest.VGMSubmissionDeadLine, src => src.VGM_SUBMISSION_DEADLINE) + .Map(dest => dest.BookedByReference, src => src.BOOKED_BY_REFERENCE) + .Map(dest => dest.CtnStat, src => src.CTN_STAT) + .Map(dest => dest.NoticeDate, src => src.NOTICE_DATE) + .Map(dest => dest.BookingId, src => src.BOOKING_ID) + .Map(dest => dest.TaskType, src => src.TASK_TYPE); + + + config.ForType() + .Map(dest => dest.PKId, src => src.PK_ID) + .Map(dest => dest.TaskId, src => src.TASK_ID) + .Map(dest => dest.MBlNo, src => src.MBL_NO) + .Map(dest => dest.Carrier, src => src.CARRIER) + .Map(dest => dest.Vessel, src => src.VESSEL) + .Map(dest => dest.Voyno, src => src.VOYNO) + .Map(dest => dest.PortLoad, src => src.PORTLOAD) + .Map(dest => dest.VGMSubmissionDeadLine, src => src.VGM_SUBMISSION_DEADLINE) + .Map(dest => dest.BookedByReference, src => src.BOOKED_BY_REFERENCE) + .Map(dest => dest.CtnStat, src => src.CTN_STAT) + .Map(dest => dest.NoticeDate, src => src.NOTICE_DATE) + .Map(dest => dest.BookingId, src => src.BOOKING_ID) + .Map(dest => dest.TaskType, src => src.TASK_TYPE); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/VGM/TaskVGMDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/VGM/TaskVGMDto.cs index 08cfec71..054eba7d 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/VGM/TaskVGMDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/VGM/TaskVGMDto.cs @@ -73,5 +73,11 @@ namespace Myshipping.Application /// public Nullable BookingId { get; set; } + /// + /// VGM通知类型 + /// + public string TaskType { get; set; } + + } } diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/VGM/TaskVGMShowDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/VGM/TaskVGMShowDto.cs new file mode 100644 index 00000000..b1e2135c --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/VGM/TaskVGMShowDto.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class TaskVGMShowDto: TaskVGMDto + { + /// + /// 箱号 + /// + public string CntrNo { get; set; } + + /// + /// VGM重量 + /// + public Nullable VGMWeight { get; set; } + + /// + /// VGM重量单位 + /// + public string VGMWeightUnit { get; set; } + + /// + /// VGM称重方式 + /// + public string VGMWeightMethod { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageVGMService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageVGMService.cs new file mode 100644 index 00000000..70d26b30 --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageVGMService.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application.Service.TaskManagePlat.Interface +{ + /// + /// VGM任务 + /// + public interface ITaskManageVGMService + { + /// + /// 获取VGM成功回执详情 + /// + /// BC主键 + /// 返回回执 + Task> GetVGMSubmissionInfo(string pkId); + + /// + /// 通过任务主键获取VGM成功回执详情 + /// + /// VGM任务主键 + /// 返回回执 + Task> GetVGMSubmissionInfoByTaskId(string taskPkId); + + /// + /// 获取VGM未提交详情 + /// + /// BC主键 + /// 返回回执 + Task> GetVGMMissingInfo(string pkId); + + /// + /// 通过任务主键获取VGM未提交详情 + /// + /// VGM任务主键 + /// 返回回执 + Task> GetVGMMissingInfoByTaskId(string taskPkId); + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index d9b9ba3c..9fb72454 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -769,6 +769,7 @@ namespace Myshipping.Application vgmInfo.CreatedUserName = taskInfo.CreatedUserName; vgmInfo.TenantId = taskInfo.TenantId; vgmInfo.TenantName = taskInfo.TenantName; + vgmInfo.TASK_TYPE = info.Main.TaskType.ToString(); _taskVGMInfoRepository.InsertAsync(vgmInfo); @@ -813,78 +814,123 @@ namespace Myshipping.Application var bookingInfo = bookingList.FirstOrDefault(a => a.MBLNO.Equals(vgmInfo.MBL_NO, StringComparison.OrdinalIgnoreCase)); - //推送状态 - var pushModel = new ModifyServiceProjectStatusDto + if (bookingInfo != null) { - BookingId = bookingInfo.Id, - SourceType = TrackingSourceTypeEnum.AUTO, - StatusCodes = new List { - new ModifyServiceProjectStatusDetailDto { StatusCode = "VGMCG" } } - }; + var vgmEntity = _taskVGMInfoRepository.AsQueryable().Filter(null, true) + .First(x => x.PK_ID == vgmInfo.PK_ID && x.IsDeleted == false && x.TenantId == taskInfo.TenantId); - var saveStatusRlt = _bookingValueAddedService.SaveServiceStatus(pushModel).GetAwaiter().GetResult(); + vgmEntity.BOOKING_ID = bookingInfo.Id; - _logger.LogInformation("请求JSON={json} 异步推送服务状态完成,结果={rlt}", JSON.Serialize(pushModel), JSON.Serialize(saveStatusRlt)); + _taskVGMInfoRepository.AsUpdateable(vgmEntity).UpdateColumns(x => x.BOOKING_ID).ExecuteCommandAsync(); - var vgmEntity = _taskVGMInfoRepository.AsQueryable().Filter(null, true) - .First(x => x.PK_ID == vgmInfo.PK_ID && x.IsDeleted == false && x.TenantId == taskInfo.TenantId); + var ctnVGMList = _bookingCtnVGMRepository.AsQueryable().Filter(null, true) + .Where(x => x.BILLID == bookingInfo.Id && x.IsDeleted == false && x.TenantId == taskInfo.TenantId).ToList(); - vgmEntity.BOOKING_ID = bookingInfo.Id; + var bookCtnList = _bookingOrderContaRepository.AsQueryable().Filter(null, true) + .Where(x => x.BILLID == bookingInfo.Id && x.IsDeleted == false && x.TenantId == taskInfo.TenantId).ToList(); - _taskVGMInfoRepository.AsUpdateable(vgmEntity).UpdateColumns(x => x.BOOKING_ID).ExecuteCommandAsync(); + var ctnList = info.Main.VGMFeedBack + .FirstOrDefault(x => x.MBlNo.Equals(vgmInfo.MBL_NO, StringComparison.OrdinalIgnoreCase)).CtnList; - var ctnVGMList = _bookingCtnVGMRepository.AsQueryable().Filter(null, true) - .Where(x => x.BILLID == bookingInfo.Id && x.IsDeleted == false && x.TenantId == taskInfo.TenantId).ToList(); - - var bookCtnList = _bookingOrderContaRepository.AsQueryable().Filter(null, true) - .Where(x => x.BILLID == bookingInfo.Id && x.IsDeleted == false && x.TenantId == taskInfo.TenantId).ToList(); + if (info.Main.TaskType == TaskBaseTypeEnum.VGM_FEEDBACK) + { + //推送状态 + var pushModel = new ModifyServiceProjectStatusDto + { + BookingId = bookingInfo.Id, + SourceType = TrackingSourceTypeEnum.AUTO, + StatusCodes = new List { + new ModifyServiceProjectStatusDetailDto { StatusCode = "VGMCG" } } + }; - var ctnList = info.Main.VGMFeedBack - .FirstOrDefault(x => x.MBlNo.Equals(vgmInfo.MBL_NO, StringComparison.OrdinalIgnoreCase)).CtnList; + var saveStatusRlt = _bookingValueAddedService.SaveServiceStatus(pushModel).GetAwaiter().GetResult(); - foreach (var ctn in ctnList) - { - var bookCtnVGM = ctnVGMList.FirstOrDefault(t => t.CNTRNO.Equals(ctn.CntrNo, StringComparison.OrdinalIgnoreCase)); - var bookCtn = bookCtnList.FirstOrDefault(t => t.CNTRNO.Equals(ctn.CntrNo, StringComparison.OrdinalIgnoreCase)); + _logger.LogInformation("请求JSON={json} 异步推送服务状态完成,结果={rlt}", JSON.Serialize(pushModel), JSON.Serialize(saveStatusRlt)); - if (bookCtnVGM != null) - { - //更新 - bookCtnVGM.UpdatedTime = taskInfo.CreatedTime; - bookCtnVGM.UpdatedUserId = taskInfo.CreatedUserId; - bookCtnVGM.UpdatedUserName = taskInfo.CreatedUserName; - - _bookingCtnVGMRepository.AsUpdateable(bookCtnVGM).UpdateColumns(x => new + foreach (var ctn in ctnList) { - x.VGM_WEIGHT, - x.VGM_WEIGHT_UNIT, - x.VGM_METHOD, - x.IS_MATCH, - x.UpdatedTime, - x.UpdatedUserId, - x.UpdatedUserName - }).ExecuteCommand(); + var bookCtnVGM = ctnVGMList.FirstOrDefault(t => t.CNTRNO.Equals(ctn.CntrNo, StringComparison.OrdinalIgnoreCase)); + var bookCtn = bookCtnList.FirstOrDefault(t => t.CNTRNO.Equals(ctn.CntrNo, StringComparison.OrdinalIgnoreCase)); + + if (bookCtnVGM != null) + { + //更新 + bookCtnVGM.UpdatedTime = taskInfo.CreatedTime; + bookCtnVGM.UpdatedUserId = taskInfo.CreatedUserId; + bookCtnVGM.UpdatedUserName = taskInfo.CreatedUserName; + bookCtnVGM.IS_MISSING = false; + bookCtnVGM.SUBMISSION_DEADLINE = null; + + _bookingCtnVGMRepository.AsUpdateable(bookCtnVGM).UpdateColumns(x => new + { + x.VGM_WEIGHT, + x.VGM_WEIGHT_UNIT, + x.VGM_METHOD, + x.IS_MATCH, + x.UpdatedTime, + x.UpdatedUserId, + x.UpdatedUserName + }).ExecuteCommand(); + } + else + { + //写入 + var bookingCtnVGM = new BookingCtnVGM + { + CNTRNO = ctn.CntrNo, + BILLID = bookingInfo.Id, + VGM_WEIGHT = ctn.VGMWeight, + VGM_WEIGHT_UNIT = ctn.VGMWeightUnit, + VGM_METHOD = ctn.VGMWeightMethod, + IS_MATCH = bookCtn != null, + CreatedTime = taskInfo.CreatedTime, + UpdatedTime = taskInfo.CreatedTime, + CreatedUserId = taskInfo.CreatedUserId, + CreatedUserName = taskInfo.CreatedUserName, + TenantId = taskInfo.TenantId, + REC_TIME = vgmInfo.NOTICE_DATE + }; + + _bookingCtnVGMRepository.Insert(bookingCtnVGM); + } + } } else { - //写入 - var bookingCtnVGM = new BookingCtnVGM + if (ctnList.Count > 0) { - CNTRNO = ctn.CntrNo, - BILLID = bookingInfo.Id, - VGM_WEIGHT = ctn.VGMWeight, - VGM_WEIGHT_UNIT = ctn.VGMWeightUnit, - VGM_METHOD = ctn.VGMWeightMethod, - IS_MATCH = bookCtn != null, - CreatedTime = taskInfo.CreatedTime, - UpdatedTime = taskInfo.CreatedTime, - CreatedUserId = taskInfo.CreatedUserId, - CreatedUserName = taskInfo.CreatedUserName, - TenantId = taskInfo.TenantId, - }; - - _bookingCtnVGMRepository.Insert(bookingCtnVGM); + foreach (var ctn in ctnList) + { + var bookCtnVGM = ctnVGMList.FirstOrDefault(t => t.CNTRNO.Equals(ctn.CntrNo, StringComparison.OrdinalIgnoreCase)); + var bookCtn = bookCtnList.FirstOrDefault(t => t.CNTRNO.Equals(ctn.CntrNo, StringComparison.OrdinalIgnoreCase)); + + if (bookCtnVGM == null) + { + //写入 + var bookingCtnVGM = new BookingCtnVGM + { + CNTRNO = ctn.CntrNo, + BILLID = bookingInfo.Id, + VGM_WEIGHT = ctn.VGMWeight, + VGM_WEIGHT_UNIT = ctn.VGMWeightUnit, + VGM_METHOD = ctn.VGMWeightMethod, + IS_MATCH = bookCtn != null, + CreatedTime = taskInfo.CreatedTime, + UpdatedTime = taskInfo.CreatedTime, + CreatedUserId = taskInfo.CreatedUserId, + CreatedUserName = taskInfo.CreatedUserName, + TenantId = taskInfo.TenantId, + REC_TIME = vgmInfo.NOTICE_DATE, + IS_MISSING = true, + SUBMISSION_DEADLINE = vgmInfo.VGM_SUBMISSION_DEADLINE + }; + + _bookingCtnVGMRepository.Insert(bookingCtnVGM); + } + } + } } + } }); } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageVGMService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageVGMService.cs new file mode 100644 index 00000000..3caa4bf1 --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageVGMService.cs @@ -0,0 +1,199 @@ +using Furion.DynamicApiController; +using Furion.FriendlyException; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using Myshipping.Application.Entity; +using Myshipping.Application.Service.TaskManagePlat.Interface; +using Myshipping.Core; +using MySqlX.XDevAPI.Common; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + + /// + /// VGM任务 + /// + [ApiDescriptionSettings("Application", Name = "TaskManageVGM", Order = 10)] + public class TaskManageVGMService: ITaskManageVGMService, IDynamicApiController + { + private readonly SqlSugarRepository _taskVGMInfoRepository; + private readonly SqlSugarRepository _taskVGMCtnInfoRepository; + private readonly SqlSugarRepository _taskBaseRepository; + + public TaskManageVGMService(SqlSugarRepository taskVGMInfoRepository, + SqlSugarRepository taskVGMCtnInfoRepository, + SqlSugarRepository taskBaseRepository) + { + _taskVGMInfoRepository = taskVGMInfoRepository; + _taskVGMCtnInfoRepository = taskVGMCtnInfoRepository; + _taskBaseRepository = taskBaseRepository; + } + + #region 获取VGM成功回执详情 + /// + /// 获取VGM成功回执详情 + /// + /// BC主键 + /// 返回回执 + [HttpGet("/BookingMSKAPI/GetVGMSubmissionInfo")] + public async Task> GetVGMSubmissionInfo(string pkId) + { + List list = new List(); + + var vgmOrder = _taskVGMInfoRepository.AsQueryable().First(a => a.PK_ID == pkId); + + if (vgmOrder == null) + throw Oops.Oh($"VGM主键{pkId}无法获取业务信息"); + + var CtnList = _taskVGMCtnInfoRepository.AsQueryable() + .Where(a => a.P_ID == pkId).ToList(); + + if (CtnList.Count > 0) + { + list = CtnList.OrderBy(p => p.P_ID).ThenBy(p => p.CNTRNO).Select(p => + { + TaskVGMShowDto model = vgmOrder.Adapt(); + + model.CntrNo = p.CNTRNO; + model.VGMWeight = p.VGM_WEIGHT; + model.VGMWeightMethod = p.VGM_METHOD; + model.VGMWeightUnit = p.VGM_WEIGHT_UNIT; + + return model; + }).ToList(); + } + + return list; + } + #endregion + + #region 通过任务主键获取VGM成功回执详情 + /// + /// 通过任务主键获取VGM成功回执详情 + /// + /// VGM任务主键 + /// 返回回执 + [HttpGet("/BookingMSKAPI/GetVGMSubmissionInfoByTaskId")] + public async Task> GetVGMSubmissionInfoByTaskId(string taskPkId) + { + List list = new List(); + + var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPkId); + + if (taskBase == null) + throw Oops.Oh($"任务主键{taskPkId}无法获取业务信息"); + + var vgmOrder = _taskVGMInfoRepository.AsQueryable().First(a => a.TASK_ID == taskBase.PK_ID); + + if (vgmOrder == null) + throw Oops.Oh($"任务主键{taskPkId}无法获取VGM信息"); + + var CtnList = _taskVGMCtnInfoRepository.AsQueryable() + .Where(a => a.P_ID == vgmOrder.PK_ID).ToList(); + + if (CtnList.Count > 0) + { + list = CtnList.OrderBy(p => p.P_ID).ThenBy(p => p.CNTRNO).Select(p => + { + TaskVGMShowDto model = vgmOrder.Adapt(); + + model.CntrNo = p.CNTRNO; + model.VGMWeight = p.VGM_WEIGHT; + model.VGMWeightMethod = p.VGM_METHOD; + model.VGMWeightUnit = p.VGM_WEIGHT_UNIT; + + return model; + }).ToList(); + } + + return list; + } + #endregion + + #region 获取VGM未提交详情 + /// + /// 获取VGM未提交详情 + /// + /// BC主键 + /// 返回回执 + [HttpGet("/BookingMSKAPI/GetVGMMissingInfo")] + public async Task> GetVGMMissingInfo(string pkId) + { + List list = new List(); + + var vgmOrder = _taskVGMInfoRepository.AsQueryable().First(a => a.PK_ID == pkId); + + if (vgmOrder == null) + throw Oops.Oh($"VGM主键{pkId}无法获取业务信息"); + + var CtnList = _taskVGMCtnInfoRepository.AsQueryable() + .Where(a => a.P_ID == pkId).ToList(); + + if (CtnList.Count > 0) + { + list = CtnList.OrderBy(p => p.P_ID).ThenBy(p => p.CNTRNO).Select(p => + { + TaskVGMShowDto model = vgmOrder.Adapt(); + + model.CntrNo = p.CNTRNO; + model.VGMWeight = p.VGM_WEIGHT; + model.VGMWeightMethod = p.VGM_METHOD; + model.VGMWeightUnit = p.VGM_WEIGHT_UNIT; + + return model; + }).ToList(); + } + + return list; + } + #endregion + + #region 通过任务主键获取VGM未提交详情 + /// + /// 通过任务主键获取VGM未提交详情 + /// + /// VGM任务主键 + /// 返回回执 + [HttpGet("/BookingMSKAPI/GetVGMMissingInfoByTaskId")] + public async Task> GetVGMMissingInfoByTaskId(string taskPkId) + { + List list = new List(); + + var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPkId); + + if (taskBase == null) + throw Oops.Oh($"任务主键{taskPkId}无法获取业务信息"); + + var vgmOrder = _taskVGMInfoRepository.AsQueryable().First(a => a.TASK_ID == taskBase.PK_ID); + + if (vgmOrder == null) + throw Oops.Oh($"任务主键{taskPkId}无法获取VGM信息"); + + var CtnList = _taskVGMCtnInfoRepository.AsQueryable() + .Where(a => a.P_ID == vgmOrder.PK_ID).ToList(); + + if (CtnList.Count > 0) + { + list = CtnList.OrderBy(p => p.P_ID).ThenBy(p => p.CNTRNO).Select(p => + { + TaskVGMShowDto model = vgmOrder.Adapt(); + + model.CntrNo = p.CNTRNO; + model.VGMWeight = p.VGM_WEIGHT; + model.VGMWeightMethod = p.VGM_METHOD; + model.VGMWeightUnit = p.VGM_WEIGHT_UNIT; + + return model; + }).ToList(); + } + + return list; + } + #endregion + } +} From a7102aa065e07730509b4f16533dbe0934b075e1 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng Date: Wed, 13 Mar 2024 11:53:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E6=8E=A5?= =?UTF-8?q?=E6=94=B6=E8=AE=A2=E8=88=B1=E5=AE=A1=E6=A0=B8=E9=9C=80=E6=B1=82?= =?UTF-8?q?=E5=90=8E=E6=8E=A8=E9=80=81=E4=B8=9C=E8=83=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingCustomerOrderService.cs | 109 +++++++++--------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs b/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs index 643d78bc..7314a381 100644 --- a/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs +++ b/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs @@ -965,6 +965,61 @@ namespace Myshipping.Application return bkOrder.Id; } + + // 接收到订舱需求审核后推送东胜 + _ = Task.Run(() => + { + try + { + var body = new + { + Type = recModel.Accept ? "CustOrderStatusAccept" : "CustOrderStatusReject", + Data = new + { + model.BSNO, + BSSTATUS = recModel.Accept ? "已审核" : "已驳回", + BookingOrderId = recModel.Accept ? (long?)model.BookingId : null, + COMMENT = recModel.Accept ? null: recModel.Comment + } + }; + var json = body.ToJsonString(); + + var mqUrl = _cache.GetAllSysConfig().Result.FirstOrDefault(x => x.Code == "AuditBookingMqUrl")?.Value ?? throw new Exception("需配置接收订舱需求审核后推送东胜MQ连接串:[AuditBookingMqUrl]"); + + const string MqActionExchangeName = "amq.direct"; + const string MqActionQueueName = "auditbooking.output.ds"; + + ConnectionFactory factory = new ConnectionFactory(); + factory.Uri = new Uri(mqUrl); + + using (IConnection conn = factory.CreateConnection()) + using (IModel mqModel = conn.CreateModel()) + { + mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct, true); + + var queueName = $"{MqActionQueueName}.{model.TenantId}"; + mqModel.QueueDeclare(queueName, false, false, false, null); + + mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null); + + IBasicProperties props = mqModel.CreateBasicProperties(); + props.DeliveryMode = 2; + + byte[] messageBodyBytes = Encoding.UTF8.GetBytes(SharpZipLib.Compress(json)); + + mqModel.BasicPublish(MqActionExchangeName, queueName, props, messageBodyBytes); + + conn.Close(); + + _logger.LogInformation($"接收到订舱需求审核后推送东胜,已发送数据到消息队列【{mqUrl}】,数据内容:【{json}】"); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "接收到订舱需求审核后推送东胜时发生异常"); + } + }); + return 0; } #endregion @@ -1448,60 +1503,6 @@ namespace Myshipping.Application SaveAuditLog($"{(accept ? "审核通过" : "审核驳回")},审核意见:{comment}", id); - // 订舱需求审核后推送东胜 - _ = Task.Run(() => - { - try - { - var body = new - { - Type = accept ? "CustOrderStatusAccept" : "CustOrderStatusReject", - Data = new - { - model.BSNO, - BSSTATUS = accept ? "已审核" : "已驳回", - BookingOrderId = accept ? jobjRtn.GetLongValue("data") as long? : null - } - }; - var json = body.ToJsonString(); - - var mqUrl = _cache.GetAllSysConfig().Result.FirstOrDefault(x => x.Code == "AuditBookingMqUrl")?.Value ?? throw new Exception("需配置订舱需求审核后推送东胜MQ连接串:[AuditBookingMqUrl]"); - - const string MqActionExchangeName = "amq.direct"; - const string MqActionQueueName = "auditbooking.output.ds"; - - ConnectionFactory factory = new ConnectionFactory(); - factory.Uri = new Uri(mqUrl); - - using (IConnection conn = factory.CreateConnection()) - using (IModel mqModel = conn.CreateModel()) - { - mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct, true); - - var queueName = $"{MqActionQueueName}.{model.BookingCompanyId}"; - mqModel.QueueDeclare(queueName, false, false, false, null); - - mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null); - - IBasicProperties props = mqModel.CreateBasicProperties(); - props.DeliveryMode = 2; - - byte[] messageBodyBytes = Encoding.UTF8.GetBytes(SharpZipLib.Compress(json)); - - mqModel.BasicPublish(MqActionExchangeName, queueName, props, messageBodyBytes); - - conn.Close(); - - _logger.LogInformation($"订舱需求审核后推送东胜,已发送数据到消息队列【{mqUrl}】,数据内容:【{json}】"); - } - } - catch (Exception ex) - { - _logger.LogError(ex, "订舱需求审核后推送东胜时发生异常"); - } - }); - - //进入订舱台账 if (accept) {