|
|
|
@ -20,6 +20,7 @@ using Newtonsoft.Json;
|
|
|
|
|
using Npoi.Mapper;
|
|
|
|
|
using NPOI.HPSF;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using Org.BouncyCastle.Asn1.Tsp;
|
|
|
|
|
using RabbitMQ.Client;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using StackExchange.Profiling.Internal;
|
|
|
|
@ -59,6 +60,7 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly SqlSugarRepository<BookingFile> _bookingFileRepository;
|
|
|
|
|
private readonly SqlSugarRepository<DjyUserMailAccount> _djyUserMailAccount;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrderContact> _bookingOrderContactRepository;
|
|
|
|
|
private readonly SqlSugarRepository<BookingSlotCompare> _bookingSlotCompareRepository;
|
|
|
|
|
|
|
|
|
|
private readonly IServiceWorkFlowBaseService _serviceWorkFlowBaseService;
|
|
|
|
|
private readonly IBookingOrderService _bookingOrderService;
|
|
|
|
@ -85,7 +87,8 @@ namespace Myshipping.Application
|
|
|
|
|
IBookingOrderService bookingOrderService, ILogger<TaskManageBCService> logger,
|
|
|
|
|
IDjyCustomerService djyCustomerService,
|
|
|
|
|
IBookingSlotService bookingSlotService, ISysCacheService cache, IBookingValueAddedService bookingValueAddedService,
|
|
|
|
|
SqlSugarRepository<BookingOrderContact> bookingOrderContactRepository)
|
|
|
|
|
SqlSugarRepository<BookingOrderContact> bookingOrderContactRepository,
|
|
|
|
|
SqlSugarRepository<BookingSlotCompare> bookingSlotCompareRepository)
|
|
|
|
|
{
|
|
|
|
|
_taskBaseRepository = taskBaseRepository;
|
|
|
|
|
_taskBCInfoRepository = taskBCInfoRepository;
|
|
|
|
@ -103,6 +106,7 @@ namespace Myshipping.Application
|
|
|
|
|
_djyCustomerService = djyCustomerService;
|
|
|
|
|
_djyUserMailAccount = djyUserMailAccount;
|
|
|
|
|
_bookingOrderContactRepository = bookingOrderContactRepository;
|
|
|
|
|
_bookingSlotCompareRepository = bookingSlotCompareRepository;
|
|
|
|
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
@ -1031,6 +1035,8 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
id = await _bookingSlotService.InnerApiReceive(slotModel, dynameFile, dynameNoticeFile);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -1450,17 +1456,18 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
string emailTitle = $"Booking Confirmation : {taskBCInfo.MBL_NO}";
|
|
|
|
|
|
|
|
|
|
if (taskBCInfo.BUSI_TYPE == "BookingAmendment")
|
|
|
|
|
{
|
|
|
|
|
emailTitle = $"【变更】Booking Amendment : {taskBCInfo.MBL_NO}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string filePath = string.Empty;
|
|
|
|
|
|
|
|
|
|
SysUser opUserInfo = null;
|
|
|
|
|
|
|
|
|
|
if(!string.IsNullOrWhiteSpace(bookingOrderEntity.OPID) && Regex.IsMatch(bookingOrderEntity.OPID,"[0-9]+"))
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingOrderEntity.OPID) && Regex.IsMatch(bookingOrderEntity.OPID, "[0-9]+"))
|
|
|
|
|
opUserInfo = _sysUserRepository.AsQueryable().First(u => u.Id == long.Parse(bookingOrderEntity.OPID));
|
|
|
|
|
|
|
|
|
|
if (taskBCInfo.BUSI_TYPE == "BookingAmendment")
|
|
|
|
|
{
|
|
|
|
|
emailTitle = $"【变更】Booking Amendment : {taskBCInfo.MBL_NO}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//读取邮件模板并填充数据
|
|
|
|
|
string emailHtml = GenerateSendEmailHtml(taskBCInfo, opUserInfo,UserManager.TENANT_NAME).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
@ -1671,6 +1678,156 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 通过邮件模板生成HTML
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过邮件模板生成HTML
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskBCInfo">BC任务详情</param>
|
|
|
|
|
/// <param name="opUserInfo">订舱OP详情</param>
|
|
|
|
|
/// <param name="tenantName">当前租户全称</param>
|
|
|
|
|
/// <returns>返回生成的HTML</returns>
|
|
|
|
|
public async Task<string> GenerateSendEmailHtmlAmendment(TaskBCInfo taskBCInfo, SysUser opUserInfo, string tenantName)
|
|
|
|
|
{
|
|
|
|
|
string result = string.Empty;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
1、加载模板文件,读取HTML
|
|
|
|
|
2、读取main、conta的tr行,替换业务数据
|
|
|
|
|
3、返回HTML的文本信息。
|
|
|
|
|
*/
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string templatePath = App.Configuration["EmailTemplateFilePath"];
|
|
|
|
|
|
|
|
|
|
var opt = App.GetOptions<BookingAttachOptions>();
|
|
|
|
|
var dirAbs = opt.basePath;
|
|
|
|
|
if (string.IsNullOrEmpty(dirAbs))
|
|
|
|
|
{
|
|
|
|
|
dirAbs = App.WebHostEnvironment.WebRootPath;
|
|
|
|
|
}
|
|
|
|
|
templatePath = $"{dirAbs}{templatePath}\\BCModifyEmailTemplate.html";
|
|
|
|
|
|
|
|
|
|
string baseHtml = File.ReadAllText(templatePath);
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(baseHtml))
|
|
|
|
|
throw Oops.Oh($"读取邮件模板失败");
|
|
|
|
|
|
|
|
|
|
if (opUserInfo != null && !string.IsNullOrWhiteSpace(opUserInfo.Name))
|
|
|
|
|
{
|
|
|
|
|
baseHtml = baseHtml.Replace("#opname#", opUserInfo.Name);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
baseHtml = baseHtml.Replace("#opname#", "操作");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (opUserInfo != null && !string.IsNullOrWhiteSpace(opUserInfo.Email))
|
|
|
|
|
{
|
|
|
|
|
baseHtml = baseHtml.Replace("#opemail#", opUserInfo.Email);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
baseHtml = baseHtml.Replace("#opemail#", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (opUserInfo != null && !string.IsNullOrWhiteSpace(opUserInfo.Tel))
|
|
|
|
|
{
|
|
|
|
|
baseHtml = baseHtml.Replace("#optel#", opUserInfo.Tel);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
baseHtml = baseHtml.Replace("#optel#", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HtmlDocument html = new HtmlDocument();
|
|
|
|
|
html.LoadHtml(baseHtml);
|
|
|
|
|
|
|
|
|
|
HtmlNode baseTable = html.DocumentNode.SelectNodes("//table[@class='base-table']").FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (baseTable == null)
|
|
|
|
|
throw Oops.Oh($"读取邮件模板格式错误,定位base-table失败");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var baseTrList = baseTable.SelectNodes(".//tr");
|
|
|
|
|
|
|
|
|
|
foreach (var baseTr in baseTrList)
|
|
|
|
|
{
|
|
|
|
|
var tdList = baseTr.SelectNodes(".//td");
|
|
|
|
|
|
|
|
|
|
foreach (var baseTd in tdList)
|
|
|
|
|
{
|
|
|
|
|
if (baseTd.Attributes["class"].Value == "billno-val")
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = taskBCInfo.MBL_NO;
|
|
|
|
|
}
|
|
|
|
|
else if (baseTd.Attributes["class"].Value == "takebillno-val")
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = taskBCInfo.MBL_NO;
|
|
|
|
|
}
|
|
|
|
|
else if (baseTd.Attributes["class"].Value == "pol-val")
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = taskBCInfo.PLACERECEIPT;
|
|
|
|
|
}
|
|
|
|
|
else if (baseTd.Attributes["class"].Value == "pod-val")
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = taskBCInfo.PLACEDELIVERY;
|
|
|
|
|
}
|
|
|
|
|
else if (baseTd.Attributes["class"].Value == "ctn-val")
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = taskBCInfo.CTN_STAT;
|
|
|
|
|
}
|
|
|
|
|
else if (baseTd.Attributes["class"].Value == "etd-val")
|
|
|
|
|
{
|
|
|
|
|
if (taskBCInfo.ETD.HasValue)
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = taskBCInfo.ETD.Value.ToString("yyyy-MM-dd");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (baseTd.Attributes["class"].Value == "eta-val")
|
|
|
|
|
{
|
|
|
|
|
if (taskBCInfo.ETA.HasValue)
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = taskBCInfo.ETA.Value.ToString("yyyy-MM-dd");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var noreplyTr = html.DocumentNode.SelectNodes("//tr[@class='email-noreply']").FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (noreplyTr != null)
|
|
|
|
|
{
|
|
|
|
|
var currTd = noreplyTr.SelectNodes(".//td").FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (currTd != null)
|
|
|
|
|
{
|
|
|
|
|
var currPList = currTd.SelectNodes(".//p");
|
|
|
|
|
|
|
|
|
|
foreach (var baseP in currPList)
|
|
|
|
|
{
|
|
|
|
|
if (baseP.Attributes["class"].Value == "notice-comp-val")
|
|
|
|
|
{
|
|
|
|
|
baseP.InnerHtml = tenantName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = html.DocumentNode.OuterHtml;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"通过邮件模板生成HTML异常,原因={ex.Message}");
|
|
|
|
|
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 推送邮件
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 推送邮件
|
|
|
|
@ -1842,7 +1999,16 @@ namespace Myshipping.Application
|
|
|
|
|
//推送舱位
|
|
|
|
|
var bookingSlotId = GenerateBookingSlot(bcOrder, bcCtnList, fileList,"update").GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
//检索是否有差异
|
|
|
|
|
var compareResult = _bookingSlotCompareRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.Where(x => x.SLOT_ID == bookingSlotId && x.IsDeleted == false && x.TenantId ==
|
|
|
|
|
bcOrder.TenantId).OrderByDescending(a=>a.CreatedTime).First();
|
|
|
|
|
|
|
|
|
|
if(compareResult != null && compareResult.COMPARE_DIFF_NUM > 0)
|
|
|
|
|
{
|
|
|
|
|
//准备推送邮件
|
|
|
|
|
await GenerateSendEmail(bcOrder);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|