From 8f90a13f2be110788e8c99d5c15928b122fd0d6a Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Mon, 22 Jan 2024 15:26:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BC=E4=BB=BB=E5=8A=A1=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=A2=E8=88=B1=E8=81=94=E7=B3=BB=E4=BA=BA?= =?UTF-8?q?=E5=86=99=E5=85=A5=E5=92=8C=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/BC/BookingOrSlotGenerateDto.cs | 11 +++ .../TaskManagePlat/TaskManageBCService.cs | 83 +++++++++++++++---- 2 files changed, 76 insertions(+), 18 deletions(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/BookingOrSlotGenerateDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/BookingOrSlotGenerateDto.cs index f28040c7..73f4af9b 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/BookingOrSlotGenerateDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/BookingOrSlotGenerateDto.cs @@ -105,5 +105,16 @@ namespace Myshipping.Application /// 服务项目列表(传serviceProjectCode) /// public List ProjectList { get; set; } + + + /// + /// 单证ID + /// + public Nullable CustomerContactId { get; set; } + + /// + /// 单证名称 + /// + public string CustomerContactName { get; set; } } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index a62f02f0..267856d1 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs @@ -18,6 +18,7 @@ using Myshipping.Core.Entity; using Myshipping.Core.Service; using Newtonsoft.Json; using Npoi.Mapper; +using NPOI.HPSF; using NPOI.SS.Formula.Functions; using RabbitMQ.Client; using SqlSugar; @@ -56,6 +57,7 @@ namespace Myshipping.Application private readonly SqlSugarRepository _sysUserRepository; private readonly SqlSugarRepository _bookingFileRepository; private readonly SqlSugarRepository _djyUserMailAccount; + private readonly SqlSugarRepository _bookingOrderContactRepository; private readonly IServiceWorkFlowBaseService _serviceWorkFlowBaseService; private readonly IBookingOrderService _bookingOrderService; @@ -81,7 +83,8 @@ namespace Myshipping.Application IServiceWorkFlowBaseService serviceWorkFlowBaseService, IBookingOrderService bookingOrderService, ILogger logger, IDjyCustomerService djyCustomerService, - IBookingSlotService bookingSlotService, ISysCacheService cache, IBookingValueAddedService bookingValueAddedService) + IBookingSlotService bookingSlotService, ISysCacheService cache, IBookingValueAddedService bookingValueAddedService, + SqlSugarRepository bookingOrderContactRepository) { _taskBaseRepository = taskBaseRepository; _taskBCInfoRepository = taskBCInfoRepository; @@ -98,6 +101,7 @@ namespace Myshipping.Application _bookingFileRepository = bookingFileRepository; _djyCustomerService = djyCustomerService; _djyUserMailAccount = djyUserMailAccount; + _bookingOrderContactRepository = bookingOrderContactRepository; _logger = logger; } @@ -1107,6 +1111,59 @@ namespace Myshipping.Application if (id > 0) { + //这里如果指定了委托单位的邮件联系人,则推送订舱联系人 + if (generateModel.CustomerContactId.HasValue && generateModel.CustomerContactId.Value > 0) + { + var bookingContact = _bookingOrderContactRepository.AsQueryable() + .Where(a => a.BookingId == id && !a.IsDeleted).First(); + + var djyCustomerInfo = _djyCustomerService.Detail(new GetDjyCustomerInput { Id = generateModel.CustomerId.Value }) + .GetAwaiter().GetResult(); + + DjyCustomerContactOutput djyCustomerContactMan = null; + + if (djyCustomerInfo.Contacts != null && djyCustomerInfo.Contacts.Count > 0) + { + djyCustomerContactMan = djyCustomerInfo.Contacts.FirstOrDefault(a => + a.Remark.Equals("BCNotice", StringComparison.OrdinalIgnoreCase)); + } + + 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 + { + it.Name, + it.Email, + it.Remark, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + + }).ExecuteCommand(); + } + } + if (generateModel.ProjectList != null && generateModel.ProjectList.Count > 0) { ModifyServiceProjectDto projectDto = new ModifyServiceProjectDto @@ -1319,32 +1376,22 @@ namespace Myshipping.Application _logger.LogInformation($"获取委托单位详情完成,djyCustomerId={djyCustomerInfo.Id}"); - DjyCustomerContactOutput djyCustomerContactMan = null; + //DjyCustomerContactOutput djyCustomerContactMan = null; //TO 邮件接收人 string toEmail = string.Empty; //订舱OP的邮箱 string opEmail = string.Empty; - if (djyCustomerInfo.Contacts != null && djyCustomerInfo.Contacts.Count > 0) - { - djyCustomerContactMan = djyCustomerInfo.Contacts.FirstOrDefault(a => - a.Remark.Equals("BCNotice", StringComparison.OrdinalIgnoreCase)); - } - - if (djyCustomerContactMan == null) - { - throw Oops.Oh($"委托单位为配置对用备注是BCNotice的联系人,请修改"); - } + var bookingContact = _bookingOrderContactRepository.AsQueryable() + .First(a => a.BookingId == taskBCInfo.BOOKING_ORDER_ID); - if (string.IsNullOrWhiteSpace(djyCustomerContactMan.Email)) + if (bookingContact == null && string.IsNullOrWhiteSpace(bookingContact.Email)) { - throw Oops.Oh($"委托单位为配置对用备注是BCNotice的联系人,请修改"); + _logger.LogInformation($"当前订舱未指定的联系人,toEmail={toEmail}"); } - toEmail = djyCustomerContactMan.Email.Trim(); - - _logger.LogInformation($"委托单位为配置对用备注是BCNotice的联系人,toEmail={toEmail}"); + toEmail = bookingContact.Email.Trim(); //获取操作OP的邮箱 if (!string.IsNullOrWhiteSpace(bookingOrderEntity.OPID)) @@ -1364,7 +1411,7 @@ namespace Myshipping.Application var publicMailAccount = _djyUserMailAccount.FirstOrDefault(x => x.ShowName.Contains("BCNotice") && x.SmtpPort > 0 && x.SmtpServer != null && x.SmtpServer != ""); - if (string.IsNullOrWhiteSpace(djyCustomerContactMan.Email)) + if (publicMailAccount == null) { throw Oops.Oh($"提取公共邮箱配置失败,请在用户邮箱账号管理增加配置显示名为BCNotice"); }