diff --git a/Myshipping.Application/Entity/BookingSlot/BookingSlotCompare.cs b/Myshipping.Application/Entity/BookingSlot/BookingSlotCompare.cs index 2a79d425..e641d731 100644 --- a/Myshipping.Application/Entity/BookingSlot/BookingSlotCompare.cs +++ b/Myshipping.Application/Entity/BookingSlot/BookingSlotCompare.cs @@ -49,5 +49,12 @@ namespace Myshipping.Application [SugarColumn(ColumnName = "COMPARE_DIFF_NUM")] [Description("比对差异项数")] public Nullable COMPARE_DIFF_NUM { get; set; } + + /// + /// 比对批次号 + /// + [SugarColumn(ColumnName = "COMPARE_BATCHNO")] + [Description("比对批次号")] + public string COMPARE_BATCHNO { get; set; } } } diff --git a/Myshipping.Application/Entity/TaskManagePlat/TaskBCInfo.cs b/Myshipping.Application/Entity/TaskManagePlat/TaskBCInfo.cs index 99502c51..4cbca1b0 100644 --- a/Myshipping.Application/Entity/TaskManagePlat/TaskBCInfo.cs +++ b/Myshipping.Application/Entity/TaskManagePlat/TaskBCInfo.cs @@ -346,5 +346,10 @@ namespace Myshipping.Application /// 订舱确认时间 /// public Nullable BOOKING_COMFIRM_DATE { get; set; } + + /// + /// 批次号 + /// + public string BATCH_NO { get; set; } } } diff --git a/Myshipping.Application/Enum/TaskBaseTypeEnum.cs b/Myshipping.Application/Enum/TaskBaseTypeEnum.cs index 43df6fa0..ad15fc25 100644 --- a/Myshipping.Application/Enum/TaskBaseTypeEnum.cs +++ b/Myshipping.Application/Enum/TaskBaseTypeEnum.cs @@ -130,6 +130,11 @@ namespace Myshipping.Application /// Booking Amendment /// [Description("BC变更")] - BC_MODIFY + BC_MODIFY, + /// + /// 截止时间变更通知 + /// + [Description("截止时间变更")] + CUT_MODIFY } } diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs index 391c2e49..7ebdc855 100644 --- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs @@ -51,6 +51,7 @@ namespace Myshipping.Application private readonly SqlSugarRepository _repAllocation; private readonly SqlSugarRepository _repAllocationCtn; private readonly SqlSugarRepository _bookingFileRepository; + private readonly SqlSugarRepository _bookingSlotCompareRepository; private readonly SqlSugarRepository _repBookingLog; private readonly SqlSugarRepository _repBookingLogDetail; @@ -84,7 +85,8 @@ namespace Myshipping.Application IEventPublisher publisher, SqlSugarRepository repAllocation, SqlSugarRepository repAllocationCtn, - SqlSugarRepository bookingFileRepository) + SqlSugarRepository bookingFileRepository, + SqlSugarRepository bookingSlotCompareRepository) { _repBase = repBase; _repCtn = repCtn; @@ -101,6 +103,7 @@ namespace Myshipping.Application _publisher = publisher; _bookingfile = bookingfile; _bookingFileRepository = bookingFileRepository; + _bookingSlotCompareRepository = bookingSlotCompareRepository; } #region 舱位 @@ -455,7 +458,7 @@ namespace Myshipping.Application } //一般更新数据指的是Booking Amendment,需要与舱位进行数据比对 - await PushCompareBCInfo(bcSrcDto, bcTargetDto,id); + await PushCompareBCInfo(bcSrcDto, bcTargetDto,id, dto.BatchNo); } else if (dto.OpType == "del") { @@ -966,8 +969,16 @@ namespace Myshipping.Application } #endregion - - private async Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto,long slotId) + #region 推送BC变更比对 + /// + /// 推送BC变更比对 + /// + /// 原舱位详情 + /// 变更后舱位详情 + /// 舱位主键 + /// 请求批次号用来区分对应的哪个批次任务 + /// + private async Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto,long slotId,string reqBatchNo) { string batchNo = IDGen.NextID().ToString(); @@ -984,10 +995,27 @@ namespace Myshipping.Application if (compareResult == null) throw Oops.Oh($"舱位主键{slotId}请求BC比对失败,返回为空"); + DateTime nowDate = DateTime.Now; + BookingSlotCompare entity = new BookingSlotCompare + { + SLOT_ID = slotId, + COMPARE_BATCHNO = reqBatchNo, + COMPARE_DIFF_NUM = compareResult.extra.IsExistsDiff? compareResult.extra.ShowDetailList.Count : 0, + CreatedTime = nowDate, + UpdatedTime = nowDate, + CreatedUserId = UserManager.UserId, + CreatedUserName = UserManager.Name, + UpdatedUserId = UserManager.UserId, + UpdatedUserName = UserManager.Name, + COMPARE_TYPE = "BC_MODIFY", + COMPARE_RLT = JSON.Serialize(compareResult.extra.ShowDetailList), + }; + await _bookingSlotCompareRepository.InsertAsync(entity); } + #endregion #region 请求BC比对 /// @@ -1052,6 +1080,32 @@ namespace Myshipping.Application return model; } #endregion + + #region 获取舱位变更比对结果 + /// + /// 获取舱位变更比对结果 + /// + /// 舱位主键 + /// 批次号 + /// 返回舱位变更比对结果 + public async Task> GetSlotCompareResult(long id,string batchNo) + { + var compareInfo = await _bookingSlotCompareRepository.AsQueryable() + .FirstAsync(t => t.SLOT_ID == id && t.COMPARE_BATCHNO == batchNo); + + if (compareInfo == null) + { + throw Oops.Oh($"舱位变更比对结果不存在"); + } + + if (string.IsNullOrWhiteSpace(compareInfo.COMPARE_RLT)) + { + throw Oops.Oh($"获取舱位变更比对结果错误,比对内容不存在"); + } + + return JSON.Deserialize>(compareInfo.COMPARE_RLT); + } + #endregion } public class DynameFileInfo diff --git a/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotBaseDto.cs b/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotBaseDto.cs index c4a0b4af..e297a9f8 100644 --- a/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotBaseDto.cs +++ b/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotBaseDto.cs @@ -452,6 +452,11 @@ namespace Myshipping.Application.Service.BookingSlot.Dto /// 数据对象 /// public BookingSlotBaseApiSaveDto DataObj { get; set; } + + /// + /// 批次号 + /// + public string BatchNo { get; set; } } /// diff --git a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs index 7d24dba0..8f31b954 100644 --- a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs @@ -74,5 +74,13 @@ namespace Myshipping.Application /// /// Task InnerApiReceive(BookingSlotBaseApiDto dto, DynameFileInfo file = null, DynameFileInfo modifyFile = null); + + /// + /// 获取舱位变更比对结果 + /// + /// 舱位主键 + /// 批次号 + /// 返回舱位变更比对结果 + Task> GetSlotCompareResult(long id, string batchNo); } } \ No newline at end of file diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/BookingOrSlotGenerateDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/BookingOrSlotGenerateDto.cs index 6e404ab3..8f0a4414 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/BookingOrSlotGenerateDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/BookingOrSlotGenerateDto.cs @@ -106,15 +106,28 @@ namespace Myshipping.Application /// public List ProjectList { get; set; } + /// + /// 联系人列表 + /// + public List CustomerContactList { get; set; } + + /// + /// 是否直接发送邮件给订舱联系人 + /// + public bool IsDirectSend { get; set; } = false; + } + public class CustomerContact + { /// /// 委托单位联系人ID /// - public Nullable CustomerContactId { get; set; } + public long CustomerContactId { get; set; } /// /// 委托单位联系人名称 /// public string CustomerContactName { get; set; } } + } diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/TaskBCShowBaseDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/TaskBCShowBaseDto.cs index 0335e680..4cf42261 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/TaskBCShowBaseDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/TaskBCShowBaseDto.cs @@ -371,6 +371,11 @@ namespace Myshipping.Application /// 任务状态 /// public string taskStatus { get; set; } + + /// + /// 批次号 + /// + public string BatchNo { get; set; } } public class TaskBCShowBaseKeywordDto diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs index d9b002a9..ddb61571 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs @@ -367,5 +367,9 @@ namespace Myshipping.Application /// public Nullable BookingConfirmDate { get; set; } + /// + /// 批次号 + /// + public string BatchNo { get; set; } } } diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs index 15a9dc40..00ea4917 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs @@ -683,8 +683,8 @@ namespace Myshipping.Application .Map(dest => dest.SecondETD, src => src.SECOND_ETD) .Map(dest => dest.SecondETA, src => src.SECOND_ETA) .Map(dest => dest.BookingSlotId, src => src.BOOKING_SLOT_ID) - .Map(dest => dest.BookingConfirmDate, src => src.BOOKING_COMFIRM_DATE); - + .Map(dest => dest.BookingConfirmDate, src => src.BOOKING_COMFIRM_DATE) + .Map(dest => dest.BatchNo, src => src.BATCH_NO); config.ForType() .Map(dest => dest.PKId, src => src.PK_ID) @@ -754,7 +754,8 @@ namespace Myshipping.Application .Map(dest => dest.SecondETD, src => src.SECOND_ETD) .Map(dest => dest.SecondETA, src => src.SECOND_ETA) .Map(dest => dest.BookingSlotId, src => src.BOOKING_SLOT_ID) - .Map(dest => dest.BookingConfirmDate, src => src.BOOKING_COMFIRM_DATE); + .Map(dest => dest.BookingConfirmDate, src => src.BOOKING_COMFIRM_DATE) + .Map(dest => dest.BatchNo, src => src.BATCH_NO); config.ForType() .Map(dest => dest.BUSI_TYPE, src => src.BusiType) @@ -816,7 +817,8 @@ namespace Myshipping.Application .Map(dest => dest.SECOND_VOYNO, src => src.SecondVoyno) .Map(dest => dest.SECOND_ETD, src => src.SecondETD) .Map(dest => dest.SECOND_ETA, src => src.SecondETA) - .Map(dest => dest.BOOKING_COMFIRM_DATE, src => src.BookingConfirmDate); + .Map(dest => dest.BOOKING_COMFIRM_DATE, src => src.BookingConfirmDate) + .Map(dest => dest.BATCH_NO, src => src.BatchNo); config.ForType() .Map(dest => dest.CtnCode, src => src.CTNCODE) diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderBCInfo.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderBCInfo.cs index 7c97e8a1..2aa4d7e4 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderBCInfo.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderBCInfo.cs @@ -341,5 +341,10 @@ namespace Myshipping.Application /// 舱位主键 /// public Nullable BookingSlotId { get; set; } + + /// + /// 批次号 + /// + public string BatchNo { get; set; } } } diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs index e8e963c0..01de4889 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs @@ -82,5 +82,12 @@ namespace Myshipping.Application /// BC任务主键 /// 返回回执 Task SendEmail(string taskPKId); + + /// + /// 获取当前比对结果 + /// + /// BC任务主键 + /// 返回回执 + Task> GetCompareResult(string taskPKId); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index 267856d1..11cdf8d7 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs @@ -708,9 +708,19 @@ namespace Myshipping.Application if (bookingOrderId > 0) { - - //更新库存 - //_bookingSlotService. + List slots = new List(); + + var slotInfo = _bookingSlotService.Detail(bookingSlotId).GetAwaiter().GetResult(); + + BookingSlotBaseWithCtnDto baseInfo = slotInfo.Adapt(); + baseInfo.Id = bookingSlotId; + baseInfo.CtnList = slotInfo.CtnList.Adapt>(); + + slots.Add(baseInfo); + + //对应订舱和舱位关系 + var allocRlt = _bookingSlotService.ImportSlots(slots, bookingOrderId, false); + var bcEntity = _taskBCInfoRepository.AsQueryable().First(a => a.PK_ID == bcOrder.PK_ID); if (bcEntity != null) @@ -737,8 +747,11 @@ namespace Myshipping.Application var currBCOrder = _taskBCInfoRepository.AsQueryable().First(a => a.PK_ID == bcEntity.PK_ID); - if (currBCOrder != null) + if (currBCOrder != null && model.IsDirectSend) + { + //异步推送邮件 await GenerateSendEmail(currBCOrder); + } var taskEntity = _taskBaseRepository.AsQueryable().First(u => u.PK_ID == bcEntity.TASK_ID); @@ -779,8 +792,11 @@ namespace Myshipping.Application if (bookingOrderId > 0) { - //异步推送邮件 - await GenerateSendEmail(bcOrder); + if (model.IsDirectSend) + { + //异步推送邮件 + await GenerateSendEmail(bcOrder); + } var bcEntity = _taskBCInfoRepository.AsQueryable().First(a => a.PK_ID == bcTaskInfo.PK_ID); @@ -1112,56 +1128,67 @@ namespace Myshipping.Application if (id > 0) { //这里如果指定了委托单位的邮件联系人,则推送订舱联系人 - if (generateModel.CustomerContactId.HasValue && generateModel.CustomerContactId.Value > 0) + if (generateModel.CustomerContactList != null && generateModel.CustomerContactList.Count > 0) { - var bookingContact = _bookingOrderContactRepository.AsQueryable() - .Where(a => a.BookingId == id && !a.IsDeleted).First(); + var bookingContactList = _bookingOrderContactRepository.AsQueryable() + .Where(a => a.BookingId == id && !a.IsDeleted).ToList(); var djyCustomerInfo = _djyCustomerService.Detail(new GetDjyCustomerInput { Id = generateModel.CustomerId.Value }) .GetAwaiter().GetResult(); - DjyCustomerContactOutput djyCustomerContactMan = null; - - if (djyCustomerInfo.Contacts != null && djyCustomerInfo.Contacts.Count > 0) + generateModel.CustomerContactList.ForEach(contact => { - djyCustomerContactMan = djyCustomerInfo.Contacts.FirstOrDefault(a => - a.Remark.Equals("BCNotice", StringComparison.OrdinalIgnoreCase)); - } + DjyCustomerContactOutput djyCustomerContactMan = null; - if (bookingContact == null) - { - bookingContact = new BookingOrderContact { - Name = generateModel.CustomerContactName, - BookingId = id, - Email = djyCustomerContactMan.Email, - Remark = djyCustomerContactMan.Remark, - CreatedTime = DateTime.Now, - CreatedUserId = UserManager.UserId, - CreatedUserName = UserManager.Name - }; - - await _bookingOrderContactRepository.InsertAsync(bookingContact); - } - else - { - bookingContact.Name = generateModel.CustomerContactName; - bookingContact.Email = djyCustomerContactMan.Email; - bookingContact.Remark = djyCustomerContactMan.Remark; - bookingContact.UpdatedTime = DateTime.Now; - bookingContact.UpdatedUserId = UserManager.UserId; - bookingContact.UpdatedUserName = UserManager.Name; - - _bookingOrderContactRepository.AsUpdateable(bookingContact).UpdateColumns(it => new + if (djyCustomerInfo.Contacts != null && djyCustomerInfo.Contacts.Count > 0) { - it.Name, - it.Email, - it.Remark, - it.UpdatedTime, - it.UpdatedUserId, - it.UpdatedUserName + djyCustomerContactMan = djyCustomerInfo.Contacts.FirstOrDefault(a => + a.Id == contact.CustomerContactId); + } - }).ExecuteCommand(); - } + if (djyCustomerContactMan != null) + { + var bookingContact = bookingContactList + .FirstOrDefault(x => x.Email.Equals(djyCustomerContactMan.Email, StringComparison.OrdinalIgnoreCase)); + + if (bookingContact == null) + { + bookingContact = new BookingOrderContact + { + Name = djyCustomerContactMan.Name, + BookingId = id, + Email = djyCustomerContactMan.Email, + Remark = djyCustomerContactMan.Remark, + CreatedTime = DateTime.Now, + CreatedUserId = UserManager.UserId, + CreatedUserName = UserManager.Name + }; + + _bookingOrderContactRepository.Insert(bookingContact); + } + else + { + bookingContact.Name = djyCustomerContactMan.Name; + bookingContact.Email = djyCustomerContactMan.Email; + bookingContact.Remark = djyCustomerContactMan.Remark; + bookingContact.UpdatedTime = DateTime.Now; + bookingContact.UpdatedUserId = UserManager.UserId; + bookingContact.UpdatedUserName = UserManager.Name; + + _bookingOrderContactRepository.AsUpdateable(bookingContact).UpdateColumns(it => new + { + it.Name, + it.Email, + it.Remark, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + + }).ExecuteCommand(); + } + } + }); + } if (generateModel.ProjectList != null && generateModel.ProjectList.Count > 0) @@ -1383,15 +1410,15 @@ namespace Myshipping.Application //订舱OP的邮箱 string opEmail = string.Empty; - var bookingContact = _bookingOrderContactRepository.AsQueryable() - .First(a => a.BookingId == taskBCInfo.BOOKING_ORDER_ID); + var bookingContactList = _bookingOrderContactRepository.AsQueryable() + .Where(a => a.BookingId == taskBCInfo.BOOKING_ORDER_ID).ToList(); - if (bookingContact == null && string.IsNullOrWhiteSpace(bookingContact.Email)) + if (bookingContactList == null || bookingContactList.Count == 0) { _logger.LogInformation($"当前订舱未指定的联系人,toEmail={toEmail}"); } - toEmail = bookingContact.Email.Trim(); + toEmail = string.Join(";", bookingContactList.Select(x => x.Email.Trim()).Distinct().ToArray()); //获取操作OP的邮箱 if (!string.IsNullOrWhiteSpace(bookingOrderEntity.OPID)) @@ -1419,6 +1446,12 @@ namespace Myshipping.Application _logger.LogInformation($"提取当前公共邮箱的配置完成,id={publicMailAccount.Id}"); string emailTitle = $"Booking Confirmation : {taskBCInfo.MBL_NO}"; + + if (taskBCInfo.BUSI_TYPE == "BookingAmendment") + { + emailTitle = $"【变更】Booking Amendment : {taskBCInfo.MBL_NO}"; + } + string filePath = string.Empty; //读取邮件模板并填充数据 @@ -1716,6 +1749,31 @@ namespace Myshipping.Application return await GenerateSendEmail(bcOrder); } #endregion + + /// + /// 获取当前比对结果 + /// + /// BC任务主键 + /// 返回回执 + [HttpGet("/TaskManageBC/GetCompareResult")] + public async Task> GetCompareResult(string taskPKId) + { + if (string.IsNullOrWhiteSpace(taskPKId)) + throw Oops.Oh($"BC任务主键不能为空"); + + var bcTaskInfo = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == taskPKId); + if (bcTaskInfo == null) + { + throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息"); + } + + var bcOrder = _taskBCInfoRepository.AsQueryable().First(a => a.TASK_ID == bcTaskInfo.PK_ID); + + if (bcOrder == null) + throw Oops.Oh($"任务主键{taskPKId}无法获取BC业务信息"); + + return await _bookingSlotService.GetSlotCompareResult(bcOrder.BOOKING_SLOT_ID.Value, bcOrder.BATCH_NO); + } } /// diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 63f2d61d..85606a95 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -397,7 +397,7 @@ namespace Myshipping.Application fileCategory = TaskFileCategoryEnum.BC_NOTICE.ToString(); } - else if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.BC_MODIFY.ToString() == taskInfo.TASK_BASE_TYPE) { attachFileType = "bcmodifynoticefiles"; @@ -688,7 +688,8 @@ namespace Myshipping.Application #endregion #region BC 任务 - if (info.Main.TaskType == TaskBaseTypeEnum.BC || info.Main.TaskType == TaskBaseTypeEnum.BC_MODIFY) + if (info.Main.TaskType == TaskBaseTypeEnum.BC || info.Main.TaskType == TaskBaseTypeEnum.BC_MODIFY + || info.Main.TaskType == TaskBaseTypeEnum.CANCELLATION) { //异步写入 var bcInfo = info.Main.BCInfo.Adapt();