修改BC任务,增加订舱联系人写入和读取

optimize
jianghaiqing 10 months ago
parent 6b1e5b04a9
commit 8f90a13f2b

@ -105,5 +105,16 @@ namespace Myshipping.Application
/// 服务项目列表传serviceProjectCode
/// </summary>
public List<string> ProjectList { get; set; }
/// <summary>
/// 单证ID
/// </summary>
public Nullable<long> CustomerContactId { get; set; }
/// <summary>
/// 单证名称
/// </summary>
public string CustomerContactName { get; set; }
}
}

@ -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<SysUser> _sysUserRepository;
private readonly SqlSugarRepository<BookingFile> _bookingFileRepository;
private readonly SqlSugarRepository<DjyUserMailAccount> _djyUserMailAccount;
private readonly SqlSugarRepository<BookingOrderContact> _bookingOrderContactRepository;
private readonly IServiceWorkFlowBaseService _serviceWorkFlowBaseService;
private readonly IBookingOrderService _bookingOrderService;
@ -81,7 +83,8 @@ namespace Myshipping.Application
IServiceWorkFlowBaseService serviceWorkFlowBaseService,
IBookingOrderService bookingOrderService, ILogger<TaskManageBCService> logger,
IDjyCustomerService djyCustomerService,
IBookingSlotService bookingSlotService, ISysCacheService cache, IBookingValueAddedService bookingValueAddedService)
IBookingSlotService bookingSlotService, ISysCacheService cache, IBookingValueAddedService bookingValueAddedService,
SqlSugarRepository<BookingOrderContact> 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));
}
var bookingContact = _bookingOrderContactRepository.AsQueryable()
.First(a => a.BookingId == taskBCInfo.BOOKING_ORDER_ID);
if (djyCustomerContactMan == null)
if (bookingContact == null && string.IsNullOrWhiteSpace(bookingContact.Email))
{
throw Oops.Oh($"委托单位为配置对用备注是BCNotice的联系人请修改");
_logger.LogInformation($"当前订舱未指定的联系人toEmail={toEmail}");
}
if (string.IsNullOrWhiteSpace(djyCustomerContactMan.Email))
{
throw Oops.Oh($"委托单位为配置对用备注是BCNotice的联系人请修改");
}
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");
}

Loading…
Cancel
Save