From 0a8e7b55b95765c8b3cc2dc3c545b05cb50bf943 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 30 May 2024 15:18:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=88=B1=E4=BD=8D=E7=94=9F?= =?UTF-8?q?=E6=88=90=E8=AE=A2=E8=88=B1=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=A7=9F=E6=88=B7=E5=8F=82=E6=95=B0=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E8=A6=81=E6=B1=82=E8=81=94=E7=B3=BB=E4=BA=BA=E5=BF=85=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/BookingSlot/BookingSlotService.cs | 58 ++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs index a27820d7..b5c10776 100644 --- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs @@ -71,7 +71,7 @@ namespace Myshipping.Application private readonly IDjyCustomerService _djyCustomerService; private readonly IBookingValueAddedService _bookingValueAddedService; private readonly IBookingLabelService _bookingLabelService; - + private readonly IDjyTenantParamService _djyTenantParamService; const string CONST_BC_FILE_CODE = "bc"; const string CONST_BC_FILE_NAME = "Booking Confirmation"; @@ -85,6 +85,9 @@ namespace Myshipping.Application const string CONST_BC_MODIFY_NOTICE_FILE_CODE = "bc_moidfynotice"; const string CONST_BC_MODIFY_NOTICE_FILE_NAME = "Booking Amendment Notice"; + //租户默认参数管理(BC任务或舱位生成订舱客户联系人必填) + const string CONST_CREATE_BOOKING_NEED_CONTACT = "BC_TASK_OR_SLOT_BOOKING_NEED_CONTACT"; + public BookingSlotService(SqlSugarRepository repBase, SqlSugarRepository repCtn, SqlSugarRepository repStock, @@ -108,6 +111,7 @@ namespace Myshipping.Application IBookingLabelService bookingLabelService, INamedServiceProvider namedTaskManageServiceProvider, SqlSugarRepository sysUserRepository, + IDjyTenantParamService djyTenantParamService, SqlSugarRepository repPrintTemplate) { _repBase = repBase; @@ -136,6 +140,8 @@ namespace Myshipping.Application _sysUserRepository = sysUserRepository; _namedTaskManageServiceProvider = namedTaskManageServiceProvider; + + _djyTenantParamService = djyTenantParamService; } #region 舱位 @@ -2683,6 +2689,56 @@ namespace Myshipping.Application var fileList = await _bookingfile.AsQueryable().Filter(null, true) .Where(u => u.BookingId == slotInfo.Id && u.Moudle == "BookingSlot").ToListAsync(); + DjyTenantParamValueOutput paramConfig = null; + + var paramList = _djyTenantParamService.GetParaCodeWithValue(new[] { CONST_CREATE_BOOKING_NEED_CONTACT }).GetAwaiter().GetResult(); + + if (paramList != null && paramList.Count > 0) + { + paramConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_CREATE_BOOKING_NEED_CONTACT, StringComparison.OrdinalIgnoreCase)); + } + + if (model.CustomerContactList != null && model.CustomerContactList.Count > 0) + { + //取委托客户下面所有的联系人列表 + var djyCustomerInfo = _djyCustomerService.Detail(new GetDjyCustomerInput { Id = model.CustomerId.Value }) + .GetAwaiter().GetResult(); + + if (djyCustomerInfo == null) + { + _logger.LogInformation($"委托单位{model.CustomerName} 获取失败,委托单位不存在或已作废 SlotId={model.SlotId.Value}"); + + throw Oops.Oh($"委托单位{model.CustomerName} 获取失败,委托单位不存在或已作废"); + } + + if (djyCustomerInfo.Contacts == null && djyCustomerInfo.Contacts.Count < 1) + { + _logger.LogInformation($"委托单位{model.CustomerName} 获取相关联系人失败,委托单位相关联系人为空 SlotId={model.SlotId.Value}"); + + throw Oops.Oh($"委托单位{model.CustomerName} 获取相关联系人失败,委托单位相关联系人为空"); + } + + model.CustomerContactList.ForEach(contact => + { + DjyCustomerContactOutput djyCustomerContactMan = djyCustomerInfo.Contacts + .FirstOrDefault(a => a.Id == contact.CustomerContactId); + + if (djyCustomerContactMan == null) + { + _logger.LogInformation($"委托单位{model.CustomerName} 联系人 {contact.CustomerContactName}获取失败,联系人不存在或已作废 SlotId={model.SlotId.Value}"); + + throw Oops.Oh($"委托单位{model.CustomerName} 联系人 {contact.CustomerContactName}获取失败,联系人不存在或已作废"); + } + }); + } + else + { + if (paramConfig != null && paramConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase)) + { + throw Oops.Oh($"生成订舱时往来单位联系必填,请修改"); + } + } + var bookingOrderId = await GenerateBookingOrder(slotInfo, fileList, model); result.succ = true;