diff --git a/Myshipping.Application/Entity/BookingSlot/BookingSlotCompare.cs b/Myshipping.Application/Entity/BookingSlot/BookingSlotCompare.cs index e641d731..801e54c7 100644 --- a/Myshipping.Application/Entity/BookingSlot/BookingSlotCompare.cs +++ b/Myshipping.Application/Entity/BookingSlot/BookingSlotCompare.cs @@ -56,5 +56,12 @@ namespace Myshipping.Application [SugarColumn(ColumnName = "COMPARE_BATCHNO")] [Description("比对批次号")] public string COMPARE_BATCHNO { get; set; } + + /// + /// 任务BC主键 + /// + [SugarColumn(ColumnName = "BC_TASK_ID")] + [Description("任务BC主键")] + public string BC_TASK_ID { get; set; } } } diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs index 3039d3c9..b93b4c35 100644 --- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs @@ -1168,7 +1168,12 @@ namespace Myshipping.Application throw Oops.Oh($"获取舱位变更比对结果错误,比对内容不存在"); } - return JSON.Deserialize>(compareInfo.COMPARE_RLT); + if(!string.IsNullOrWhiteSpace(compareInfo.COMPARE_RLT)) + { + return JSON.Deserialize>(compareInfo.COMPARE_RLT); + } + + return new List(); } #endregion @@ -1570,10 +1575,10 @@ namespace Myshipping.Application /// /// 批量发送邮件提醒(发送客户) /// - /// 舱位主键组 + /// 舱位批量发送邮件请求 /// [HttpPost("/BookingSlot/SendEmail")] - public async Task SendEmail([FromBody]long[] ids) + public async Task SendEmail(BookingSlotSendEmailDto model) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); diff --git a/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotMapper.cs b/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotMapper.cs index 4e1c45d3..81998ebd 100644 --- a/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotMapper.cs +++ b/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotMapper.cs @@ -21,20 +21,21 @@ namespace Myshipping.Application .Map(dest => dest.BookingSlotTypeName, src => src.BOOKING_SLOT_TYPE_NAME) .Map(dest => dest.Vessel, src => src.VESSEL) .Map(dest => dest.VoyNo, src => src.VOYNO) - .Map(dest => dest.VGMSubmissionCutDate, src => src.VGM_SUBMISSION_CUT_DATE) + .Map(dest => dest.VGMSubmissionCutDate, src => src.VGM_SUBMISSION_CUT_DATE.HasValue ? src.VGM_SUBMISSION_CUT_DATE.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") .Map(dest => dest.WeekAt, src => src.WEEK_AT) .Map(dest => dest.CarriageType, src => src.CARRIAGE_TYPE) .Map(dest => dest.CarriageTypeName, src => src.CARRIAGE_TYPE_NAME) .Map(dest => dest.ContractNo, src => src.CONTRACT_NO) .Map(dest => dest.CtnStat, src => src.CTN_STAT) - .Map(dest => dest.CYCutoffTime, src => src.CY_CUT_DATE) + .Map(dest => dest.CYCutoffTime, src => src.CY_CUT_DATE.HasValue? src.CY_CUT_DATE.Value.ToString("yyyy-MM-dd HH:mm:ss"):"") .Map(dest => dest.DetensionFreeDays, src => src.DETENSION_FREE_DAYS) - .Map(dest => dest.ETD, src => src.ETD) - .Map(dest => dest.ETA, src => src.ETA) + .Map(dest => dest.ETD, src => src.ETD.HasValue ? src.ETD.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") + .Map(dest => dest.ETA, src => src.ETA.HasValue ? src.ETA.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") .Map(dest => dest.LaneCode, src => src.LANECODE) .Map(dest => dest.LaneName, src => src.LANENAME) - .Map(dest => dest.ManifestCutDate, src => src.MANIFEST_CUT_DATE) - .Map(dest => dest.MDGFCutDate, src => src.MDGF_CUT_DATE) + .Map(dest => dest.ManifestCutDate, src => src.MANIFEST_CUT_DATE.HasValue ? src.CY_CUT_DATE.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") + .Map(dest => dest.MDGFCutDate, src => src.MDGF_CUT_DATE.HasValue ? src.MDGF_CUT_DATE.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") + .Map(dest => dest.SICutDate, src => src.SI_CUT_DATE.HasValue ? src.SI_CUT_DATE.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") .Map(dest => dest.PlaceDelivery, src => src.PLACEDELIVERY) .Map(dest => dest.PlaceReceipt, src => src.PLACERECEIPT) .Map(dest => dest.PortDischarge, src => src.PORTDISCHARGE) @@ -50,20 +51,21 @@ namespace Myshipping.Application .Map(dest => dest.BookingSlotTypeName, src => src.BOOKING_SLOT_TYPE_NAME) .Map(dest => dest.Vessel, src => src.VESSEL) .Map(dest => dest.VoyNo, src => src.VOYNO) - .Map(dest => dest.VGMSubmissionCutDate, src => src.VGM_SUBMISSION_CUT_DATE) + .Map(dest => dest.VGMSubmissionCutDate, src => src.VGM_SUBMISSION_CUT_DATE.HasValue ? src.VGM_SUBMISSION_CUT_DATE.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") .Map(dest => dest.WeekAt, src => src.WEEK_AT) .Map(dest => dest.CarriageType, src => src.CARRIAGE_TYPE) .Map(dest => dest.CarriageTypeName, src => src.CARRIAGE_TYPE_NAME) .Map(dest => dest.ContractNo, src => src.CONTRACT_NO) .Map(dest => dest.CtnStat, src => src.CTN_STAT) - .Map(dest => dest.CYCutoffTime, src => src.CY_CUT_DATE) + .Map(dest => dest.CYCutoffTime, src => src.CY_CUT_DATE.HasValue ? src.CY_CUT_DATE.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") .Map(dest => dest.DetensionFreeDays, src => src.DETENSION_FREE_DAYS) - .Map(dest => dest.ETD, src => src.ETD) - .Map(dest => dest.ETA, src => src.ETA) + .Map(dest => dest.ETD, src => src.ETD.HasValue ? src.ETD.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") + .Map(dest => dest.ETA, src => src.ETA.HasValue ? src.ETA.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") .Map(dest => dest.LaneCode, src => src.LANECODE) .Map(dest => dest.LaneName, src => src.LANENAME) - .Map(dest => dest.ManifestCutDate, src => src.MANIFEST_CUT_DATE) - .Map(dest => dest.MDGFCutDate, src => src.MDGF_CUT_DATE) + .Map(dest => dest.ManifestCutDate, src => src.MANIFEST_CUT_DATE.HasValue ? src.MANIFEST_CUT_DATE.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") + .Map(dest => dest.MDGFCutDate, src => src.MDGF_CUT_DATE.HasValue ? src.MDGF_CUT_DATE.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") + .Map(dest => dest.SICutDate, src => src.SI_CUT_DATE.HasValue ? src.SI_CUT_DATE.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") .Map(dest => dest.PlaceDelivery, src => src.PLACEDELIVERY) .Map(dest => dest.PlaceReceipt, src => src.PLACERECEIPT) .Map(dest => dest.PortDischarge, src => src.PORTDISCHARGE) diff --git a/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotSendEmailDto.cs b/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotSendEmailDto.cs new file mode 100644 index 00000000..6e99803f --- /dev/null +++ b/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotSendEmailDto.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class BookingSlotSendEmailDto + { + /// + /// 舱位主键组 + /// + public List ids { get; set; } + + /// + /// 是否默认使用用户个人邮箱发送 + /// + public bool usePersonalEmailSend { get; set; } = false; + } +} diff --git a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs index ac2b9bb8..3f51f0ab 100644 --- a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs @@ -118,15 +118,15 @@ namespace Myshipping.Application /// 校验是否可以生成订舱订单 /// /// 舱位主键 - /// + /// 返回回执 Task ValidateCreateBookingOrder(long id); /// /// 批量发送邮件提醒(发送客户) /// - /// 舱位主键组 - /// - Task SendEmail(long[] ids); + /// 舱位批量发送邮件请求 + /// 返回回执 + Task SendEmail(BookingSlotSendEmailDto model); } } \ 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 8f0a4414..35f3b091 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/BookingOrSlotGenerateDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/BC/BookingOrSlotGenerateDto.cs @@ -115,6 +115,11 @@ namespace Myshipping.Application /// 是否直接发送邮件给订舱联系人 /// public bool IsDirectSend { get; set; } = false; + + /// + /// 是否默认使用用户个人邮箱发送 false-使用公共邮箱 true-使用个人邮箱 + /// + public bool usePersonalEmailSend { get; set; } = false; } public class CustomerContact diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs index ddb61571..491fec99 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs @@ -89,32 +89,32 @@ namespace Myshipping.Application /// /// 截关时间 /// - public Nullable ClosingDate { get; set; } + public string ClosingDate { get; set; } /// /// 截VGM时间 /// - public Nullable VGMCutoffTime { get; set; } + public string VGMCutoffTime { get; set; } /// /// ETA(预计到港时间) /// - public Nullable ETA { get; set; } + public string ETA { get; set; } /// /// ETD(预计离港时间) /// - public Nullable ETD { get; set; } + public string ETD { get; set; } /// /// 目的港ETA /// - public Nullable PODETA { get; set; } + public string PODETA { get; set; } /// /// 截单时间 /// - public Nullable CutSingleTime { get; set; } + public string CutSingleTime { get; set; } /// /// 卸货港 @@ -209,7 +209,7 @@ namespace Myshipping.Application /// /// 截港时间 /// - public Nullable CYCutoffTime { get; set; } + public string CYCutoffTime { get; set; } /// /// 状态 TEMP-暂存 SUCC-已对应 ERROR-异常 @@ -224,7 +224,7 @@ namespace Myshipping.Application /// /// 最后对应时间,最后关联到订舱日期 /// - public Nullable LastToBookingDate { get; set; } + public string LastToBookingDate { get; set; } /// /// 来源邮箱 @@ -314,22 +314,22 @@ namespace Myshipping.Application /// /// 样单截止日期 /// - public Nullable SICutDate { get; set; } + public string SICutDate { get; set; } /// /// VGM截止日期 /// - public Nullable VGMSubmissionCutDate { get; set; } + public string VGMSubmissionCutDate { get; set; } /// /// 舱单截止时间 /// - public Nullable ManifestCutDate { get; set; } + public string ManifestCutDate { get; set; } /// /// MDGF提交截止时间 /// - public Nullable MDGFCutDate { get; set; } + public string MDGFCutDate { get; set; } /// /// 中转港1 @@ -355,12 +355,12 @@ namespace Myshipping.Application /// /// 二程ETD /// - public Nullable SecondETD { get; set; } + public string SecondETD { get; set; } /// /// 二程ETA /// - public Nullable SecondETA { get; set; } + public string SecondETA { get; set; } /// /// 订舱确认时间 diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs index 6cb87946..062af2bc 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs @@ -80,8 +80,9 @@ namespace Myshipping.Application /// 发送邮件 /// /// BC任务主键 + /// 是否默认使用用户个人邮箱发送 /// 返回回执 - Task SendEmail(string taskPKId); + Task SendEmail(string taskPKId, bool usePersonalEmailSend = false); /// /// 获取当前比对结果 diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageDRAFTService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageDRAFTService.cs index d296340d..9514cf3a 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageDRAFTService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageDRAFTService.cs @@ -35,8 +35,9 @@ namespace Myshipping.Application /// 发送邮件 /// /// DRAFT任务主键 + /// 是否使用个人邮箱发送 /// 返回回执 - Task SendEmail(string taskPKId); + Task SendEmail(string taskPKId,bool usePersonalEmailSend = false); /// /// 重新处理DRAFT任务 diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index 3379f1d1..a73681f3 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs @@ -13,6 +13,7 @@ using Microsoft.Extensions.Logging; using Myshipping.Application.ConfigOption; using Myshipping.Application.Entity; using Myshipping.Application.Enum; +using Myshipping.Application.Service.BookingOrder; using Myshipping.Application.Service.BookingSlot.Dto; using Myshipping.Core; using Myshipping.Core.Entity; @@ -21,6 +22,7 @@ using Newtonsoft.Json; using Npoi.Mapper; using NPOI.HPSF; using NPOI.SS.Formula.Functions; +using NPOI.Util; using NPOI.XWPF.UserModel; using Org.BouncyCastle.Asn1.Tsp; using RabbitMQ.Client; @@ -47,7 +49,7 @@ namespace Myshipping.Application /// BC任务 /// [ApiDescriptionSettings("Application", Name = "TaskManageBC", Order = 10)] - public class TaskManageBCService: ITaskManageBCService, IDynamicApiController + public class TaskManageBCService: ITaskManageBCService, IDynamicApiController, ITransient { private readonly ISysCacheService _cache; private readonly ILogger _logger; @@ -75,6 +77,7 @@ namespace Myshipping.Application private readonly IBookingSlotService _bookingSlotService; private readonly IBookingValueAddedService _bookingValueAddedService; private readonly IDjyCustomerService _djyCustomerService; + private readonly INamedServiceProvider _namedBookingMSKAPIServiceProvider; private readonly INamedServiceProvider _namedBookingSlotServiceProvider; @@ -98,6 +101,7 @@ namespace Myshipping.Application IDjyCustomerService djyCustomerService, IBookingSlotService bookingSlotService, ISysCacheService cache, IBookingValueAddedService bookingValueAddedService, INamedServiceProvider namedBookingSlotServiceProvider, + INamedServiceProvider namedBookingMSKAPIServiceProvider, SqlSugarRepository bookingSlotBaseRepository, SqlSugarRepository bookingSlotBaseCtnRepository, SqlSugarRepository bookingSlotAllocationRepository, @@ -127,6 +131,8 @@ namespace Myshipping.Application _bookingSlotBaseCtnRepository = bookingSlotBaseCtnRepository; _bookingSlotAllocationRepository = bookingSlotAllocationRepository; _bookingSlotAllocationCtnRepository = bookingSlotAllocationCtnRepository; + _namedBookingMSKAPIServiceProvider = namedBookingMSKAPIServiceProvider; + _namedBookingSlotServiceProvider = namedBookingSlotServiceProvider; _logger = logger; } @@ -308,7 +314,7 @@ namespace Myshipping.Application Dictionary> toDoListDict = new Dictionary>(); //获取所有待处理的BC任务 var taskList = await _taskBCInfoRepository.AsQueryable().InnerJoin((a,b)=>a.TASK_ID == b.PK_ID) - .Where((a, b)=> !a.BOOKING_ORDER_ID.HasValue && b.STATUS == TaskStatusEnum.Create.ToString()) + .Where((a, b)=> !a.BOOKING_ORDER_ID.HasValue && b.STATUS == TaskStatusEnum.Create.ToString() && b.TASK_BASE_TYPE == TaskBaseTypeEnum.BC.ToString()) .Select((a,b)=>new { BC = a,TSK = b }).ToListAsync(); if (taskList.Count > 0) @@ -834,7 +840,7 @@ namespace Myshipping.Application if (currBCOrder != null && model.IsDirectSend) { //异步推送邮件 - var mailRlt = await GenerateSendEmail(currBCOrder); + var mailRlt = await GenerateSendEmail(currBCOrder, bcTaskInfo, model.usePersonalEmailSend); if (!mailRlt.succ) { @@ -961,7 +967,7 @@ namespace Myshipping.Application if (currBCOrder != null && model.IsDirectSend) { //异步推送邮件 - var mailRlt = await GenerateSendEmail(currBCOrder); + var mailRlt = await GenerateSendEmail(currBCOrder, bcTaskInfo, model.usePersonalEmailSend); if (!mailRlt.succ) { @@ -1518,8 +1524,10 @@ namespace Myshipping.Application /// 生成并推送邮件 /// /// BC任务详情 + /// 主任务详情 + /// 是否默认使用用户个人邮箱发送 /// 返回回执 - private async Task GenerateSendEmail(TaskBCInfo taskBCInfo) + private async Task GenerateSendEmail(TaskBCInfo taskBCInfo, TaskBaseInfo bcTaskInfo, bool usePersonalEmailSend = false) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); @@ -1592,12 +1600,23 @@ namespace Myshipping.Application } //提取当前公共邮箱的配置 - var publicMailAccount = _djyUserMailAccount.FirstOrDefault(x => x.CreatedUserId == UserManager.UserId + DjyUserMailAccount publicMailAccount = null; + + if(usePersonalEmailSend) + { + publicMailAccount = _djyUserMailAccount.FirstOrDefault(x => x.CreatedUserId == UserManager.UserId && x.SmtpPort > 0 && x.SmtpServer != null && x.SmtpServer != ""); + } + else + { + //这个是公共邮箱配置 + publicMailAccount = _djyUserMailAccount.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID && x.ShowName == "PublicSend" + && x.SmtpPort > 0 && x.SmtpServer != null && x.SmtpServer != ""); + } if (publicMailAccount == null) { - throw Oops.Oh($"提取公共邮箱配置失败,请在用户邮箱账号管理增加配置显示名为BCNotice"); + throw Oops.Oh($"提取公共邮箱配置失败,请在用户邮箱账号管理增加配置显示名为PublicSend或者配置个人邮箱"); } _logger.LogInformation($"提取当前公共邮箱的配置完成,id={publicMailAccount.Id}"); @@ -1615,21 +1634,40 @@ namespace Myshipping.Application { emailTitle = $"【变更】Booking Amendment : {taskBCInfo.MBL_NO}"; } - + //读取邮件模板并填充数据 - string emailHtml = GenerateSendEmailHtml(taskBCInfo, opUserInfo,UserManager.TENANT_NAME).GetAwaiter().GetResult(); + string emailHtml = string.Empty; + + if (taskBCInfo.BUSI_TYPE == "BookingAmendment") + { + emailHtml = GenerateSendEmailHtmlAmendment(taskBCInfo, opUserInfo, UserManager.TENANT_NAME).GetAwaiter().GetResult(); + } + else + { + emailHtml = GenerateSendEmailHtml(taskBCInfo, opUserInfo, UserManager.TENANT_NAME).GetAwaiter().GetResult(); + } _logger.LogInformation($"生成邮件BODY,结果:{emailHtml}"); - var fileInfo = _bookingFileRepository.AsQueryable().Where(a => a.BookingId == bookingOrderEntity.Id && a.TypeCode.Contains("bc_notice")) + TaskFileInfo fileInfo = null; + + if (bcTaskInfo.TASK_BASE_TYPE == TaskBaseTypeEnum.BC.ToString()) + { + fileInfo = _taskFileRepository.AsQueryable().Where(a => a.TASK_PKID == taskBCInfo.TASK_ID && a.FILE_CATEGORY.Contains("BC_NOTICE")) .OrderByDescending(a => a.CreatedTime).First(); + } + else if (bcTaskInfo.TASK_BASE_TYPE == TaskBaseTypeEnum.BC_MODIFY.ToString()) + { + fileInfo = _taskFileRepository.AsQueryable().Where(a => a.TASK_PKID == taskBCInfo.TASK_ID && a.FILE_CATEGORY.Contains("BC_MODIFY_NOTICE")) + .OrderByDescending(a => a.CreatedTime).First(); + } if (fileInfo == null) { throw Oops.Oh($"提取订舱的Booking Confirmation Notice文件失败,不能发送邮件"); } - _logger.LogInformation($"获取订舱附件地址,结果:{fileInfo.FilePath}"); + _logger.LogInformation($"获取订舱附件地址,结果:{fileInfo.FILE_PATH}"); var opt = App.GetOptions(); var dirAbs = opt.basePath; @@ -1638,7 +1676,7 @@ namespace Myshipping.Application dirAbs = App.WebHostEnvironment.WebRootPath; } - filePath = Path.Combine(dirAbs, fileInfo.FilePath); + filePath = Path.Combine(dirAbs, fileInfo.FILE_PATH); EmailApiUserDefinedDto emailApiUserDefinedDto = new EmailApiUserDefinedDto { @@ -1662,8 +1700,16 @@ namespace Myshipping.Application _logger.LogInformation($"推送邮件完成,结果:{JSON.Serialize(emailRlt)}"); - result.succ = true; - result.msg = "成功"; + if(emailRlt.succ) + { + result.succ = true; + result.msg = "成功"; + } + else + { + result.succ = false; + result.msg = emailRlt.msg; + } } catch (Exception ex) { @@ -1864,6 +1910,11 @@ namespace Myshipping.Application if (string.IsNullOrWhiteSpace(baseHtml)) throw Oops.Oh($"读取邮件模板失败"); + List compareList = GetCompareResult(taskBCInfo.TASK_ID).GetAwaiter().GetResult(); + + if (compareList == null || compareList.Count == 0) + throw Oops.Oh($"读取变更数据失败,没有差异数据"); + if (opUserInfo != null && !string.IsNullOrWhiteSpace(opUserInfo.Name)) { baseHtml = baseHtml.Replace("#opname#", opUserInfo.Name); @@ -1932,6 +1983,7 @@ namespace Myshipping.Application { baseTd.InnerHtml = taskBCInfo.CTN_STAT; } + /* else if (baseTd.Attributes["class"].Value == "etd-val") { if (taskBCInfo.ETD.HasValue) @@ -1945,10 +1997,120 @@ namespace Myshipping.Application { baseTd.InnerHtml = taskBCInfo.ETA.Value.ToString("yyyy-MM-dd"); } - } + }*/ } } + bool isOnlyChangeOne = false; + + List nameList = new List(); + //船名 + if (compareList.Any(x => x.FieldCode.Equals("vessel", StringComparison.OrdinalIgnoreCase))) + { + var name = compareList.FirstOrDefault(x => x.FieldCode.Equals("vessel", StringComparison.OrdinalIgnoreCase)).TargetVal; + + baseTable.AppendChild(HtmlNode.CreateNode("船名 变更为:" + name + "")); + + nameList.Add("船名"); + } + //航次号 + if (compareList.Any(x => x.FieldCode.Equals("voyNo", StringComparison.OrdinalIgnoreCase))) + { + var name = compareList.FirstOrDefault(x => x.FieldCode.Equals("voyNo", StringComparison.OrdinalIgnoreCase)).TargetVal; + + baseTable.AppendChild(HtmlNode.CreateNode("航次号 变更为:" + name + "")); + + nameList.Add("航次号"); + } + //ETD + if (compareList.Any(x => x.FieldCode.Equals("ETD", StringComparison.OrdinalIgnoreCase))) + { + var name = compareList.FirstOrDefault(x => x.FieldCode.Equals("ETD", StringComparison.OrdinalIgnoreCase)).TargetVal; + + baseTable.AppendChild(HtmlNode.CreateNode("ETD 变更为:" + name + "")); + + nameList.Add("ETD"); + } + //ETA + if (compareList.Any(x => x.FieldCode.Equals("ETA", StringComparison.OrdinalIgnoreCase))) + { + var name = compareList.FirstOrDefault(x => x.FieldCode.Equals("ETA", StringComparison.OrdinalIgnoreCase)).TargetVal; + + baseTable.AppendChild(HtmlNode.CreateNode("ETA 变更为:" + name + "")); + + nameList.Add("ETA"); + } + + //SICutDate 样单截止日期 + if (compareList.Any(x => x.FieldCode.Equals("SICutDate", StringComparison.OrdinalIgnoreCase))) + { + var name = compareList.FirstOrDefault(x => x.FieldCode.Equals("SICutDate", StringComparison.OrdinalIgnoreCase)).TargetVal; + + baseTable.AppendChild(HtmlNode.CreateNode("样单截止日期 变更为:" + name + "")); + + nameList.Add("样单截止日期"); + } + + //CYCutoffTime 截港时间 + if (compareList.Any(x => x.FieldCode.Equals("CYCutoffTime", StringComparison.OrdinalIgnoreCase))) + { + var name = compareList.FirstOrDefault(x => x.FieldCode.Equals("CYCutoffTime", StringComparison.OrdinalIgnoreCase)).TargetVal; + + baseTable.AppendChild(HtmlNode.CreateNode("截港时间 变更为:" + name + "")); + + nameList.Add("截港时间"); + } + + //ManifestCutDate 舱单截止时间 + if (compareList.Any(x => x.FieldCode.Equals("ManifestCutDate", StringComparison.OrdinalIgnoreCase))) + { + var name = compareList.FirstOrDefault(x => x.FieldCode.Equals("ManifestCutDate", StringComparison.OrdinalIgnoreCase)).TargetVal; + + baseTable.AppendChild(HtmlNode.CreateNode("舱单截止时间 变更为:" + name + "")); + + nameList.Add("舱单截止时间"); + } + + //VGMCutoffTime MDGF提交截止时间 + if (compareList.Any(x => x.FieldCode.Equals("VGMCutoffTime", StringComparison.OrdinalIgnoreCase))) + { + var name = compareList.FirstOrDefault(x => x.FieldCode.Equals("VGMCutoffTime", StringComparison.OrdinalIgnoreCase)).TargetVal; + + baseTable.AppendChild(HtmlNode.CreateNode("截VGM时间 变更为:" + name + "")); + + nameList.Add("截VGM时间"); + } + + //MDGFCutDate MDGF提交截止时间 + if (compareList.Any(x => x.FieldCode.Equals("MDGFCutDate", StringComparison.OrdinalIgnoreCase))) + { + var name = compareList.FirstOrDefault(x => x.FieldCode.Equals("MDGFCutDate", StringComparison.OrdinalIgnoreCase)).TargetVal; + + baseTable.AppendChild(HtmlNode.CreateNode("MDGF提交截止时间 变更为:" + name + "")); + + nameList.Add("MDGF提交截止时间"); + } + + //PlaceReceipt 收货地 + if (compareList.Any(x => x.FieldCode.Equals("PlaceReceipt", StringComparison.OrdinalIgnoreCase))) + { + var name = compareList.FirstOrDefault(x => x.FieldCode.Equals("PlaceReceipt", StringComparison.OrdinalIgnoreCase)).TargetVal; + + baseTable.AppendChild(HtmlNode.CreateNode("收货地 变更为:" + name + "")); + + nameList.Add("收货地"); + } + + //PlaceDelivery 交货地 + if (compareList.Any(x => x.FieldCode.Equals("PlaceDelivery", StringComparison.OrdinalIgnoreCase))) + { + var name = compareList.FirstOrDefault(x => x.FieldCode.Equals("PlaceDelivery", StringComparison.OrdinalIgnoreCase)).TargetVal; + + baseTable.AppendChild(HtmlNode.CreateNode("交货地 变更为:" + name + "")); + + nameList.Add("交货地"); + } + var noreplyTr = html.DocumentNode.SelectNodes("//tr[@class='email-noreply']").FirstOrDefault(); if (noreplyTr != null) @@ -1965,6 +2127,13 @@ namespace Myshipping.Application { baseP.InnerHtml = tenantName; } + else if(baseP.Attributes["class"].Value == "dynamic-val") + { + if (nameList.Count > 0) + { + baseP.InnerHtml = $"请注意{(string.Join("、", nameList.ToArray()))} 变更,请您按相关的更新安排操作,谢谢!"; + } + } } } @@ -2028,7 +2197,7 @@ namespace Myshipping.Application emailList.Add(emailApiUserDefinedDto); - string strJoin = System.IO.File.ReadAllText(filePath); + //string strJoin = System.IO.File.ReadAllText(filePath); DateTime bDate = DateTime.Now; @@ -2047,7 +2216,7 @@ namespace Myshipping.Application TimeSpan ts = eDate.Subtract(bDate); var timeDiff = ts.TotalMilliseconds; - _logger.LogInformation($"邮件上传完成 上传文件大小:{heByte.Length} 用时:{timeDiff}ms.,{strJoin}"); + _logger.LogInformation($"邮件上传完成 上传文件大小:{heByte.Length} 用时:{timeDiff}ms.,"); _logger.LogInformation($"发送邮件返回:{JSON.Serialize(res)}"); @@ -2075,9 +2244,10 @@ namespace Myshipping.Application /// 发送邮件 /// /// BC任务主键 + /// 是否默认使用用户个人邮箱发送 /// 返回回执 [HttpGet("/TaskManageBC/SendEmail")] - public async Task SendEmail(string taskPKId) + public async Task SendEmail(string taskPKId, bool usePersonalEmailSend = false) { if (string.IsNullOrWhiteSpace(taskPKId)) throw Oops.Oh($"BC任务主键不能为空"); @@ -2093,7 +2263,7 @@ namespace Myshipping.Application if (bcOrder == null) throw Oops.Oh($"任务主键{taskPKId}无法获取BC业务信息"); - return await GenerateSendEmail(bcOrder); + return await GenerateSendEmail(bcOrder, bcTaskInfo); } #endregion @@ -2234,32 +2404,81 @@ namespace Myshipping.Application if (taskBCInfo == null) throw Oops.Oh($"BC任务主键{taskPkId}无法获取业务信息"); - if (taskBCInfo.BOOKING_SLOT_ID.HasValue) - throw Oops.Oh($"当前BC任务已有匹配的舱位"); - string mblNo = taskBCInfo.MBL_NO.ToUpper().Trim(); var server = _namedBookingSlotServiceProvider.GetService(nameof(BookingSlotService)); - var slotInfo = await server.SearchBookingSlotWithOrderByNo(mblNo); - if (slotInfo == null) - throw Oops.Oh($"提单号{mblNo}未提取有效的舱位信息"); + //首先检索关联舱位 + if (!taskBCInfo.BOOKING_SLOT_ID.HasValue) + { + //var server = _namedBookingSlotServiceProvider.GetService(nameof(BookingSlotService)); + var slotInfo = await server.SearchBookingSlotWithOrderByNo(mblNo); + + if (slotInfo == null) + throw Oops.Oh($"提单号{mblNo}未提取有效的舱位信息"); + + taskBCInfo.BOOKING_SLOT_ID = slotInfo.BookingSlotId; + taskBCInfo.UpdatedUserId = UserManager.UserId; + taskBCInfo.UpdatedUserName = UserManager.Name; + + if (slotInfo.HasBookingOrder && !taskBCInfo.BOOKING_ORDER_ID.HasValue) + { + taskBCInfo.BOOKING_ORDER_ID = slotInfo.BookingOrderList.FirstOrDefault(); - taskBCInfo.BOOKING_SLOT_ID = slotInfo.BookingSlotId; - taskBCInfo.UpdatedUserId = UserManager.UserId; - taskBCInfo.UpdatedUserName = UserManager.Name; + //更新任务BC + await _taskBCInfoRepository.AsUpdateable(taskBCInfo).UpdateColumns(it => new + { + it.BOOKING_SLOT_ID, + it.BOOKING_ORDER_ID, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName - //更新任务BC - await _taskBCInfoRepository.AsUpdateable(taskBCInfo).UpdateColumns(it => new + }).ExecuteCommandAsync(); + } + else + { + //更新任务BC + await _taskBCInfoRepository.AsUpdateable(taskBCInfo).UpdateColumns(it => new + { + it.BOOKING_SLOT_ID, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + + }).ExecuteCommandAsync(); + } + + _logger.LogInformation($"提单号{mblNo} 提取到舱位ID,更新完成"); + } + + //对应订舱订单 + if (!taskBCInfo.BOOKING_ORDER_ID.HasValue) { - it.BOOKING_SLOT_ID, - it.UpdatedTime, - it.UpdatedUserId, - it.UpdatedUserName + var slotInfo = await server.SearchBookingSlotWithOrderByNo(mblNo); - }).ExecuteCommandAsync(); + if (slotInfo == null) + throw Oops.Oh($"提单号{mblNo}未提取有效的舱位信息"); - _logger.LogInformation($"提单号{mblNo} 提取到舱位ID,更新完成"); + if (slotInfo.HasBookingOrder && !taskBCInfo.BOOKING_ORDER_ID.HasValue) + { + taskBCInfo.BOOKING_ORDER_ID = slotInfo.BookingOrderList.FirstOrDefault(); + taskBCInfo.UpdatedUserId = UserManager.UserId; + taskBCInfo.UpdatedUserName = UserManager.Name; + + //更新任务BC + await _taskBCInfoRepository.AsUpdateable(taskBCInfo).UpdateColumns(it => new + { + it.BOOKING_ORDER_ID, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + + }).ExecuteCommandAsync(); + + _logger.LogInformation($"提单号{mblNo} 提取到订舱订单ID,更新完成"); + } + } //取消舱位 if (taskBCInfo.BUSI_TYPE == TaskBusiTypeEnum.CANCELLATION.ToString()) @@ -2280,6 +2499,13 @@ namespace Myshipping.Application var pushRlt = await server.ApiReceive(JSON.Serialize(slotModel)); _logger.LogInformation($"提单号{mblNo} 推送舱位取消,结果={JSON.Serialize(pushRlt)}"); + + var service = _namedBookingMSKAPIServiceProvider + .GetService(nameof(BookingMSKAPIService)); + + var synRlt = await service.SyncBCInfo(taskBCInfo.MBL_NO, taskBCInfo.TenantId.Value, "Cancellation"); + + _logger.LogInformation($"入库完BC,自动推送状态到API订舱列表 mblno={taskBCInfo.MBL_NO} synRlt={JSON.Serialize(synRlt)}"); } else if (taskBCInfo.BUSI_TYPE == TaskBusiTypeEnum.BC_MODIFY.ToString()) { @@ -2317,7 +2543,7 @@ namespace Myshipping.Application TRANSFER_PORT_2 = taskBCInfo.TRANSFER_PORT_2, CtnList = new List() }, - OpType = "add" + OpType = "update" }; var ctnList = _taskBCCTNInfoRepository.AsQueryable().Where(a => a.P_ID == taskBCInfo.PK_ID).ToList(); diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageDRAFTService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageDRAFTService.cs index ceb4d39f..3032264b 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageDRAFTService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageDRAFTService.cs @@ -207,9 +207,10 @@ namespace Myshipping.Application /// 发送邮件 /// /// DRAFT任务主键 + /// 是否使用个人邮箱发送 /// 返回回执 [HttpGet("/TaskManageDRAFT/SendEmail")] - public async Task SendEmail(string taskPKId) + public async Task SendEmail(string taskPKId, bool usePersonalEmailSend = false) { if (string.IsNullOrWhiteSpace(taskPKId)) throw Oops.Oh($"DRAFT任务主键不能为空"); @@ -225,7 +226,7 @@ namespace Myshipping.Application if (draft == null) throw Oops.Oh($"任务主键{taskPKId}无法获取DRAFT业务信息"); - return await GenerateSendEmail(draft); + return await GenerateSendEmail(draft, usePersonalEmailSend); } #endregion @@ -235,7 +236,7 @@ namespace Myshipping.Application /// /// DRAFT任务详情 /// 返回回执 - private async Task GenerateSendEmail(TaskDraftInfo taskDraftInfo) + private async Task GenerateSendEmail(TaskDraftInfo taskDraftInfo, bool usePersonalEmailSend = false) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); diff --git a/Myshipping.Web.Core/applicationconfig.json b/Myshipping.Web.Core/applicationconfig.json index bb5886ab..2355f0cb 100644 --- a/Myshipping.Web.Core/applicationconfig.json +++ b/Myshipping.Web.Core/applicationconfig.json @@ -133,7 +133,7 @@ "GetDraftCompareUrl": "http://localhost:5110/api/TaskDraftCompare/DraftCompareResult", "DraftReadUrl": "http://localhost:5110/api/TaskDraftCompare/ExcuteDraftFileRead", "EmailTemplateFilePath": "\\EmailTemplate", - "BCCompareUrl": "http://60.209.125.238:35210/api/TaskBookingAmendmentParser/ExcuteBookingAmendmentCompare", + "BCCompareUrl": "http://localhost:5110/api/TaskBookingAmendmentParser/ExcuteBookingAmendmentCompare", "MSKAPIDjyUserKey": "wu", "MSKAPIDjyUserSecret": "123456", "MSKAPIOPEnvironment": "TEST" diff --git a/Myshipping.Web.Entry/wwwroot/EmailTemplate/BCModifyEmailTemplate.html b/Myshipping.Web.Entry/wwwroot/EmailTemplate/BCModifyEmailTemplate.html index c823d1a0..006a949f 100644 --- a/Myshipping.Web.Entry/wwwroot/EmailTemplate/BCModifyEmailTemplate.html +++ b/Myshipping.Web.Entry/wwwroot/EmailTemplate/BCModifyEmailTemplate.html @@ -24,31 +24,31 @@ - + - + - + - + - + -
提单号:提单号: TEST123456
提箱提单号:提箱提单号: TEST123456
POL:POL: Qingdao,Shandong,China
POD:POD: Fremantle,Western Australia,Australia
箱型箱量:箱型箱量: 40OH*1
+

请您按照更新的ETD在免箱期内用箱,以免产生超期箱使费,谢谢!

请不要回复此邮箱(自动发送邮箱无人处理邮件),如有疑问,请联系#opname#(邮箱#opemail#,电话#optel#),谢谢!

货物到港后,贵司保证目的港收货人及时提取货物。因货物提取不及时/弃货产生的滞箱费、堆存费、港口费、货物处理费等概由贵司或者目的港收货人承担。如果我司对外承担了上述费用,则贵司应当无条件支付给我司,如果因此给我司造成了经济损失,则贵司还应当赔偿我司所有经济损失,包括但不限于律师费、诉讼费等等。一旦此票提箱出运就视为同意此条款,谢谢配合!