|
|
|
@ -15,7 +15,9 @@ using Myshipping.Application.ConfigOption;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Myshipping.Application.Enum;
|
|
|
|
|
using Myshipping.Application.Helper;
|
|
|
|
|
using Myshipping.Application.Service;
|
|
|
|
|
using Myshipping.Application.Service.BookingOrder;
|
|
|
|
|
using Myshipping.Application.Service.BookingOrder.Dto;
|
|
|
|
|
using Myshipping.Application.Service.BookingSlot.Dto;
|
|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
@ -27,6 +29,7 @@ using NPOI.SS.Formula.Functions;
|
|
|
|
|
using NPOI.Util;
|
|
|
|
|
using NPOI.XWPF.UserModel;
|
|
|
|
|
using Org.BouncyCastle.Asn1.Tsp;
|
|
|
|
|
using Org.BouncyCastle.Utilities;
|
|
|
|
|
using RabbitMQ.Client;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using StackExchange.Profiling.Internal;
|
|
|
|
@ -890,7 +893,7 @@ namespace Myshipping.Application
|
|
|
|
|
if (currBCOrder != null && model.IsDirectSend)
|
|
|
|
|
{
|
|
|
|
|
//异步推送邮件
|
|
|
|
|
var mailRlt = await GenerateSendEmail(currBCOrder, bcTaskInfo, model.usePersonalEmailSend);
|
|
|
|
|
var mailRlt = await GenerateSendEmail(currBCOrder, bcTaskInfo,null, model.usePersonalEmailSend);
|
|
|
|
|
|
|
|
|
|
if (!mailRlt.succ)
|
|
|
|
|
{
|
|
|
|
@ -1036,7 +1039,7 @@ namespace Myshipping.Application
|
|
|
|
|
if (currBCOrder != null && model.IsDirectSend)
|
|
|
|
|
{
|
|
|
|
|
//异步推送邮件
|
|
|
|
|
var mailRlt = await GenerateSendEmail(currBCOrder, bcTaskInfo, model.usePersonalEmailSend);
|
|
|
|
|
var mailRlt = await GenerateSendEmail(currBCOrder, bcTaskInfo,null, model.usePersonalEmailSend);
|
|
|
|
|
|
|
|
|
|
if (!mailRlt.succ)
|
|
|
|
|
{
|
|
|
|
@ -1204,7 +1207,7 @@ namespace Myshipping.Application
|
|
|
|
|
if (currBCOrder != null && model.IsDirectSend)
|
|
|
|
|
{
|
|
|
|
|
//异步推送邮件
|
|
|
|
|
var mailRlt = await GenerateSendEmail(currBCOrder, bcTaskInfo, model.usePersonalEmailSend);
|
|
|
|
|
var mailRlt = await GenerateSendEmail(currBCOrder, bcTaskInfo, null, model.usePersonalEmailSend);
|
|
|
|
|
|
|
|
|
|
if (!mailRlt.succ)
|
|
|
|
|
{
|
|
|
|
@ -1426,6 +1429,19 @@ namespace Myshipping.Application
|
|
|
|
|
bkModel.VOYNOINNER = taskBCInfo.CARRIER_VOYNO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//处理自动对应场站
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(taskBCInfo.TAKE_CTN_YARD))
|
|
|
|
|
{
|
|
|
|
|
var yardInfo = _cache.GetAllCodeYard().GetAwaiter().GetResult().FirstOrDefault(a => a.Code.Equals(taskBCInfo.TAKE_CTN_YARD));
|
|
|
|
|
|
|
|
|
|
if (yardInfo != null)
|
|
|
|
|
{
|
|
|
|
|
bkModel.YARDID = yardInfo.Code;
|
|
|
|
|
bkModel.YARD = yardInfo.Name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//增加装货港、卸货港的对应
|
|
|
|
|
// 解析收货地,得到装货港名称及五字码
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(taskBCInfo.PLACERECEIPT))
|
|
|
|
@ -1831,7 +1847,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// <param name="bcTaskInfo">主任务详情</param>
|
|
|
|
|
/// <param name="usePersonalEmailSend">是否默认使用用户个人邮箱发送</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
private async Task<TaskManageOrderResultDto> GenerateSendEmail(TaskBCInfo taskBCInfo, TaskBaseInfo bcTaskInfo, bool usePersonalEmailSend = false)
|
|
|
|
|
private async Task<TaskManageOrderResultDto> GenerateSendEmail(TaskBCInfo taskBCInfo, TaskBaseInfo bcTaskInfo, Nullable<long> mandatoryBookingId = null, bool usePersonalEmailSend = false)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
@ -1846,9 +1862,21 @@ namespace Myshipping.Application
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//读取订舱数据
|
|
|
|
|
var bookingOrderEntity = _bookingOrderRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
BookingOrder bookingOrderEntity = null;
|
|
|
|
|
|
|
|
|
|
if(mandatoryBookingId.HasValue && mandatoryBookingId.Value> 0)
|
|
|
|
|
{
|
|
|
|
|
bookingOrderEntity = _bookingOrderRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.First(a => a.Id == mandatoryBookingId.Value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bookingOrderEntity = _bookingOrderRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.First(a => a.Id == taskBCInfo.BOOKING_ORDER_ID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ctnList = _bookingCtnRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.Where(a => a.BILLID == mandatoryBookingId.Value).ToList();
|
|
|
|
|
|
|
|
|
|
if (bookingOrderEntity == null)
|
|
|
|
|
{
|
|
|
|
@ -1892,7 +1920,7 @@ namespace Myshipping.Application
|
|
|
|
|
string opEmail = string.Empty;
|
|
|
|
|
|
|
|
|
|
var bookingContactList = _bookingOrderContactRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.Where(a => a.BookingId == taskBCInfo.BOOKING_ORDER_ID).ToList();
|
|
|
|
|
.Where(a => a.BookingId == bookingOrderEntity.Id).ToList();
|
|
|
|
|
|
|
|
|
|
if (bookingContactList == null || bookingContactList.Count == 0)
|
|
|
|
|
{
|
|
|
|
@ -1956,7 +1984,15 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
if (taskBCInfo.BUSI_TYPE == "BookingAmendment")
|
|
|
|
|
{
|
|
|
|
|
emailHtml = GenerateSendEmailHtmlAmendment(taskBCInfo, opUserInfo, UserManager.TENANT_NAME).GetAwaiter().GetResult();
|
|
|
|
|
if (mandatoryBookingId.HasValue)
|
|
|
|
|
{
|
|
|
|
|
emailHtml = GenerateSendEmailHtmlAmendment(taskBCInfo, opUserInfo, UserManager.TENANT_NAME, bookingOrderEntity, ctnList).GetAwaiter().GetResult();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
emailHtml = GenerateSendEmailHtmlAmendment(taskBCInfo, opUserInfo, UserManager.TENANT_NAME).GetAwaiter().GetResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -1975,18 +2011,19 @@ namespace Myshipping.Application
|
|
|
|
|
else if (bcTaskInfo.TASK_BASE_TYPE == TaskBaseTypeEnum.BC_MODIFY.ToString())
|
|
|
|
|
{
|
|
|
|
|
//CMA没有变更附件,所以转发邮件时默认用原文件转发
|
|
|
|
|
if(bcTaskInfo.CARRIER_ID.Equals("CMA",StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
if (bcTaskInfo.CARRIER_ID.Equals("CMA", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
fileInfo = _taskFileRepository.AsQueryable().Filter(null, true).Where(a => a.TASK_PKID == taskBCInfo.TASK_ID && a.FILE_CATEGORY.Contains("BC_MODIFY"))
|
|
|
|
|
.OrderByDescending(a => a.CreatedTime).First();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
fileInfo = _taskFileRepository.AsQueryable().Filter(null, true).Where(a => a.TASK_PKID == taskBCInfo.TASK_ID && a.FILE_CATEGORY.Contains("BC_MODIFY_NOTICE"))
|
|
|
|
|
.OrderByDescending(a => a.CreatedTime).First();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fileInfo == null)
|
|
|
|
|
{
|
|
|
|
@ -2004,6 +2041,22 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
filePath = Path.Combine(dirAbs, fileInfo.FILE_PATH);
|
|
|
|
|
|
|
|
|
|
if (mandatoryBookingId.HasValue)
|
|
|
|
|
{
|
|
|
|
|
//重新取BC文件
|
|
|
|
|
fileInfo = _taskFileRepository.AsQueryable().Filter(null, true).Where(a => a.TASK_PKID == taskBCInfo.TASK_ID && a.FILE_CATEGORY.Contains("BC_MODIFY"))
|
|
|
|
|
.OrderByDescending(a => a.CreatedTime).First();
|
|
|
|
|
|
|
|
|
|
filePath = Path.Combine(dirAbs, fileInfo.FILE_PATH);
|
|
|
|
|
|
|
|
|
|
var newFilePath = await ReGenerateBAFile(bookingOrderEntity, ctnList, filePath);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(newFilePath))
|
|
|
|
|
filePath = Path.Combine(dirAbs, newFilePath);
|
|
|
|
|
|
|
|
|
|
SaveEDIFile(bookingOrderEntity.Id, filePath, new System.IO.FileInfo(filePath).Name, taskBCInfo.TenantId.Value,
|
|
|
|
|
"splitfile", "Booking Confirmation Split").GetAwaiter();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EmailApiUserDefinedDto emailApiUserDefinedDto = new EmailApiUserDefinedDto
|
|
|
|
|
{
|
|
|
|
@ -2226,8 +2279,11 @@ namespace Myshipping.Application
|
|
|
|
|
/// <param name="taskBCInfo">BC任务详情</param>
|
|
|
|
|
/// <param name="opUserInfo">订舱OP详情</param>
|
|
|
|
|
/// <param name="tenantName">当前租户全称</param>
|
|
|
|
|
/// <param name="bookingOrder">相关订单详情</param>
|
|
|
|
|
/// <param name="ctnList">相关订单的集装箱列表</param>
|
|
|
|
|
/// <returns>返回生成的HTML</returns>
|
|
|
|
|
public async Task<string> GenerateSendEmailHtmlAmendment(TaskBCInfo taskBCInfo, SysUser opUserInfo, string tenantName)
|
|
|
|
|
public async Task<string> GenerateSendEmailHtmlAmendment(TaskBCInfo taskBCInfo, SysUser opUserInfo, string tenantName,
|
|
|
|
|
BookingOrder bookingOrder = null,List<BookingCtn> ctnList = null)
|
|
|
|
|
{
|
|
|
|
|
string result = string.Empty;
|
|
|
|
|
|
|
|
|
@ -2315,11 +2371,56 @@ namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
if (baseTd.Attributes["class"].Value == "billno-val")
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = taskBCInfo.MBL_NO;
|
|
|
|
|
if (bookingOrder != null)
|
|
|
|
|
{
|
|
|
|
|
//如果是外港这里需要填正式的提单号
|
|
|
|
|
if (!bookingOrder.CUSTNO.Equals(bookingOrder.HBLNO))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingOrder.PORTLOADID) && bookingOrder.PORTLOADID.Equals("CNTAO", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = bookingOrder.MBLNO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = bookingOrder.HBLNO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = bookingOrder.MBLNO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = taskBCInfo.MBL_NO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (baseTd.Attributes["class"].Value == "takebillno-val")
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = taskBCInfo.MBL_NO;
|
|
|
|
|
if (bookingOrder != null)
|
|
|
|
|
{
|
|
|
|
|
//如果是外港这里需要填正式的提单号
|
|
|
|
|
if (!bookingOrder.CUSTNO.Equals(bookingOrder.HBLNO))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(bookingOrder.PORTLOADID) && bookingOrder.PORTLOADID.Equals("CNTAO", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = bookingOrder.HBLNO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = bookingOrder.MBLNO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = bookingOrder.MBLNO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = taskBCInfo.MBL_NO;
|
|
|
|
|
}
|
|
|
|
|
//baseTd.InnerHtml = taskBCInfo.MBL_NO;
|
|
|
|
|
}
|
|
|
|
|
else if (baseTd.Attributes["class"].Value == "pol-val")
|
|
|
|
|
{
|
|
|
|
@ -2331,7 +2432,14 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
else if (baseTd.Attributes["class"].Value == "ctn-val")
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = taskBCInfo.CTN_STAT;
|
|
|
|
|
if (ctnList != null && ctnList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = string.Join(",", ctnList.GroupBy(a => a.CTNALL).Select(a => $"{a.Key}*{a.Sum(b => b.CTNNUM.HasValue ? b.CTNNUM.Value : 0)}").ToArray());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
baseTd.InnerHtml = taskBCInfo.CTN_STAT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
else if (baseTd.Attributes["class"].Value == "etd-val")
|
|
|
|
@ -2597,7 +2705,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// <param name="usePersonalEmailSend">是否默认使用用户个人邮箱发送</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[HttpGet("/TaskManageBC/SendEmail")]
|
|
|
|
|
public async Task<TaskManageOrderResultDto> SendEmail(string taskPKId, bool usePersonalEmailSend = false)
|
|
|
|
|
public async Task<TaskManageOrderResultDto> SendEmail(string taskPKId, Nullable<long> mandatoryBookingId = null, bool usePersonalEmailSend = false )
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(taskPKId))
|
|
|
|
|
throw Oops.Oh($"BC任务主键不能为空");
|
|
|
|
@ -2613,7 +2721,7 @@ namespace Myshipping.Application
|
|
|
|
|
if (bcOrder == null)
|
|
|
|
|
throw Oops.Oh($"任务主键{taskPKId}无法获取BC业务信息");
|
|
|
|
|
|
|
|
|
|
return await GenerateSendEmail(bcOrder, bcTaskInfo);
|
|
|
|
|
return await GenerateSendEmail(bcOrder, bcTaskInfo, mandatoryBookingId);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@ -2715,6 +2823,9 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//这个先取一下与订单的关系
|
|
|
|
|
var searchOrder = await _bookingOrderService.SearchOrderInfo(bcOrder.MBL_NO);
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 判断是否默认转发邮件 paramConfig={JSON.Serialize(paramConfig)}");
|
|
|
|
|
|
|
|
|
|
if (!bcOrder.BOOKING_SLOT_ID.HasValue || bcOrder.BOOKING_SLOT_ID.Value == 0)
|
|
|
|
@ -2790,66 +2901,101 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//去关联的订舱ID
|
|
|
|
|
if(bcOrder.BOOKING_ORDER_ID == null || bcOrder.BOOKING_ORDER_ID.Value == 0)
|
|
|
|
|
//如果是拆票需要更新所有的拆票订单,并根据修改BA文件的单号和箱型,自动转发给客户
|
|
|
|
|
if (searchOrder.splitOrMergeFlag == 1)
|
|
|
|
|
{
|
|
|
|
|
var server = _namedBookingSlotServiceProvider.GetService<ITransient>(nameof(BookingSlotService));
|
|
|
|
|
var slotModel = server.SearchBookingSlotWithOrderByNo(bcOrder.MBL_NO, bcOrder.TenantId.Value).GetAwaiter().GetResult();
|
|
|
|
|
var orderIdList = new List<long> { searchOrder.currOrder.Id };
|
|
|
|
|
|
|
|
|
|
if (slotModel.HasBookingOrder)
|
|
|
|
|
if (searchOrder.otherOrderList.Count > 0)
|
|
|
|
|
orderIdList.AddRange(searchOrder.otherOrderList.Select(b => b.Id).ToList());
|
|
|
|
|
|
|
|
|
|
foreach (var bkid in orderIdList)
|
|
|
|
|
{
|
|
|
|
|
bcOrder.BOOKING_ORDER_ID = slotModel.BookingOrderList.FirstOrDefault();
|
|
|
|
|
bcOrder.UpdatedTime = DateTime.Now;
|
|
|
|
|
bcOrder.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
bcOrder.UpdatedUserName = UserManager.Name;
|
|
|
|
|
var currBCOrder = bcOrder.Adapt<TaskBCInfo>();
|
|
|
|
|
|
|
|
|
|
currBCOrder.BOOKING_ORDER_ID = bkid;
|
|
|
|
|
|
|
|
|
|
await UpdateBookingOrder(currBCOrder, taskPKId, true);
|
|
|
|
|
|
|
|
|
|
await _taskBCInfoRepository.AsUpdateable(bcOrder).UpdateColumns(it => new
|
|
|
|
|
//如果值是ENABLE表示可以自动发送
|
|
|
|
|
if (paramConfig != null && paramConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
it.BOOKING_ORDER_ID,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 准备发送邮件");
|
|
|
|
|
|
|
|
|
|
if (bcOrder.BOOKING_ORDER_ID != null && bcOrder.BOOKING_ORDER_ID.HasValue && bcOrder.BOOKING_ORDER_ID.Value > 0)
|
|
|
|
|
{
|
|
|
|
|
await UpdateBookingOrder(bcOrder, taskPKId);
|
|
|
|
|
var emailRlt = await SendEmail(taskPKId, bkid);
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 发送邮件完成 结果={JSON.Serialize(emailRlt)}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 未配置自动发送邮件");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 更新订舱详情失败没有对应舱位ID");
|
|
|
|
|
}
|
|
|
|
|
//去关联的订舱ID
|
|
|
|
|
if (bcOrder.BOOKING_ORDER_ID == null || bcOrder.BOOKING_ORDER_ID.Value == 0)
|
|
|
|
|
{
|
|
|
|
|
var server = _namedBookingSlotServiceProvider.GetService<ITransient>(nameof(BookingSlotService));
|
|
|
|
|
var slotModel = server.SearchBookingSlotWithOrderByNo(bcOrder.MBL_NO, bcOrder.TenantId.Value).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
//如果值是ENABLE表示可以自动发送
|
|
|
|
|
if (paramConfig != null && paramConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 准备发送邮件");
|
|
|
|
|
if (slotModel.HasBookingOrder)
|
|
|
|
|
{
|
|
|
|
|
bcOrder.BOOKING_ORDER_ID = slotModel.BookingOrderList.FirstOrDefault();
|
|
|
|
|
bcOrder.UpdatedTime = DateTime.Now;
|
|
|
|
|
bcOrder.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
bcOrder.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
await _taskBCInfoRepository.AsUpdateable(bcOrder).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.BOOKING_ORDER_ID,
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bcOrder.BOOKING_ORDER_ID != null && bcOrder.BOOKING_ORDER_ID.HasValue && bcOrder.BOOKING_ORDER_ID.Value > 0)
|
|
|
|
|
{
|
|
|
|
|
await UpdateBookingOrder(bcOrder, taskPKId);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 更新订舱详情失败没有对应舱位ID");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var emailRlt = await SendEmail(taskPKId);
|
|
|
|
|
//如果值是ENABLE表示可以自动发送
|
|
|
|
|
if (paramConfig != null && paramConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 准备发送邮件");
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 发送邮件完成 结果={JSON.Serialize(emailRlt)}");
|
|
|
|
|
var emailRlt = await SendEmail(taskPKId);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 未配置自动发送邮件");
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 发送邮件完成 结果={JSON.Serialize(emailRlt)}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 未配置自动发送邮件");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dingdingConfig != null && dingdingConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 准备发送钉钉消息");
|
|
|
|
|
//if (dingdingConfig != null && dingdingConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
//{
|
|
|
|
|
// _logger.LogInformation($"taskPKId={taskPKId} 准备发送钉钉消息");
|
|
|
|
|
|
|
|
|
|
var emailRlt = await SendEmail(taskPKId);
|
|
|
|
|
// var emailRlt = await SendEmail(taskPKId);
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 发送钉钉消息完成 结果={JSON.Serialize(emailRlt)}");
|
|
|
|
|
// _logger.LogInformation($"taskPKId={taskPKId} 发送钉钉消息完成 结果={JSON.Serialize(emailRlt)}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 未配置自动发送邮件");
|
|
|
|
|
}
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// _logger.LogInformation($"taskPKId={taskPKId} 未配置自动发送邮件");
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
result.msg = "执行成功";
|
|
|
|
@ -2871,7 +3017,7 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private async Task UpdateBookingOrder(TaskBCInfo bcOrder,string taskPKId)
|
|
|
|
|
private async Task UpdateBookingOrder(TaskBCInfo bcOrder, string taskPKId, bool isAvoidUpdateCtn = false)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -3053,26 +3199,35 @@ namespace Myshipping.Application
|
|
|
|
|
bkModel.ChangedFields.Add(nameof(SaveBookingOrderInput.PLACERECEIPT));
|
|
|
|
|
bkModel.ChangedFields.Add(nameof(SaveBookingOrderInput.PLACERECEIPTID));
|
|
|
|
|
|
|
|
|
|
var taskBCCtnList = _taskBCCTNInfoRepository.AsQueryable().Filter(null, true).Where(a => a.P_ID == bcOrder.PK_ID && a.TenantId == UserManager.TENANT_ID).ToList();
|
|
|
|
|
if (!isAvoidUpdateCtn)
|
|
|
|
|
{
|
|
|
|
|
var taskBCCtnList = _taskBCCTNInfoRepository.AsQueryable().Filter(null, true).Where(a => a.P_ID == bcOrder.PK_ID && a.TenantId == UserManager.TENANT_ID).ToList();
|
|
|
|
|
|
|
|
|
|
var ctnCodeList = _cache.GetAllCodeCtn().GetAwaiter().GetResult().ToList();
|
|
|
|
|
var ctnCodeList = _cache.GetAllCodeCtn().GetAwaiter().GetResult().ToList();
|
|
|
|
|
|
|
|
|
|
if (taskBCCtnList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
taskBCCtnList.ForEach(t =>
|
|
|
|
|
if (taskBCCtnList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.Name) &&
|
|
|
|
|
a.Name.Equals(t.CTNALL, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
BookingCtnDto ctn = new BookingCtnDto
|
|
|
|
|
taskBCCtnList.ForEach(t =>
|
|
|
|
|
{
|
|
|
|
|
CTNCODE = ctnCode?.Code,
|
|
|
|
|
CTNALL = t.CTNALL,
|
|
|
|
|
CTNNUM = t.CTNNUM.HasValue ? t.CTNNUM.Value : 1
|
|
|
|
|
};
|
|
|
|
|
var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.Name) &&
|
|
|
|
|
a.Name.Equals(t.CTNALL, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
bkModel.ctnInputs.Add(ctn);
|
|
|
|
|
});
|
|
|
|
|
BookingCtnDto ctn = new BookingCtnDto
|
|
|
|
|
{
|
|
|
|
|
CTNCODE = ctnCode?.Code,
|
|
|
|
|
CTNALL = t.CTNALL,
|
|
|
|
|
CTNNUM = t.CTNNUM.HasValue ? t.CTNNUM.Value : 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bkModel.ctnInputs.Add(ctn);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var ctnList = _bookingCtnRepository.AsQueryable().Filter(null, true).Where(a => a.BILLID == bcOrder.BOOKING_ORDER_ID.Value).ToList();
|
|
|
|
|
|
|
|
|
|
bkModel.ctnInputs = ctnList.Select(b => b.Adapt<BookingCtnDto>()).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var bkRlt = await _bookingOrderService.Save(bkModel);
|
|
|
|
@ -4099,6 +4254,159 @@ namespace Myshipping.Application
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 重新获取生成BookingAmendment文件
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 重新获取生成BookingAmendment文件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bookingOrder"></param>
|
|
|
|
|
/// <param name="ctnList"></param>
|
|
|
|
|
/// <param name="origFilePath"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private async Task<string> ReGenerateBAFile(BookingOrder bookingOrder,List<BookingCtn> ctnList,string origFilePath)
|
|
|
|
|
{
|
|
|
|
|
DrawModifyBCConfig mConfig = new DrawModifyBCConfig {
|
|
|
|
|
drawTypeArg = new DrawModifyBCConfigTypeEnum[] { DrawModifyBCConfigTypeEnum.ChangeToSplitBillNo,DrawModifyBCConfigTypeEnum.SplitBC },
|
|
|
|
|
origBillNo = bookingOrder.CUSTNO,
|
|
|
|
|
newBillNo = bookingOrder.MBLNO,
|
|
|
|
|
newCtnNum = ctnList.Sum(a=> a.CTNNUM),
|
|
|
|
|
ctnAll = ctnList.FirstOrDefault().CTNALL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
NameValueCollection modifyPar = new NameValueCollection();
|
|
|
|
|
modifyPar.Add("jsonMessage", JSON.Serialize(mConfig));
|
|
|
|
|
|
|
|
|
|
DynameFileInfo dynameFile = null;
|
|
|
|
|
|
|
|
|
|
var fileName = Path.GetFileName(origFilePath);
|
|
|
|
|
|
|
|
|
|
var fileBytes = File.ReadAllBytes(origFilePath);
|
|
|
|
|
|
|
|
|
|
if (fileBytes.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
dynameFile = new DynameFileInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = fileName,
|
|
|
|
|
FileBytes = fileBytes
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string batchNo = IDGen.NextID().ToString();
|
|
|
|
|
|
|
|
|
|
byte[] modifyBytes = ModifyFile(modifyPar, dynameFile).GetAwaiter().GetResult();
|
|
|
|
|
|
|
|
|
|
var noExtensionFileName = Path.GetFileNameWithoutExtension(fileName);
|
|
|
|
|
return await FileAttachHelper.SaveFile(bookingOrder.Id.ToString(), modifyBytes, batchNo, noExtensionFileName,
|
|
|
|
|
GetFileType(origFilePath), "bcsplitnoticefiles");
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取文件类型
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取文件类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fileName">文件完成路径</param>
|
|
|
|
|
/// <returns>返回文件类型枚举</returns>
|
|
|
|
|
private PrintFileTypeEnum GetFileType(string fileName)
|
|
|
|
|
{
|
|
|
|
|
PrintFileTypeEnum fileType = PrintFileTypeEnum.PDF;
|
|
|
|
|
|
|
|
|
|
switch (Path.GetExtension(fileName).ToLower())
|
|
|
|
|
{
|
|
|
|
|
case ".pdf":
|
|
|
|
|
fileType = PrintFileTypeEnum.PDF;
|
|
|
|
|
break;
|
|
|
|
|
case ".xlsx":
|
|
|
|
|
fileType = PrintFileTypeEnum.XLSX;
|
|
|
|
|
break;
|
|
|
|
|
case ".docx":
|
|
|
|
|
fileType = PrintFileTypeEnum.DOCX;
|
|
|
|
|
break;
|
|
|
|
|
case ".xls":
|
|
|
|
|
fileType = PrintFileTypeEnum.XLS;
|
|
|
|
|
break;
|
|
|
|
|
case ".doc":
|
|
|
|
|
fileType = PrintFileTypeEnum.DOC;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fileType;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 请求变更BookingAmendment后的文件
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 请求变更BookingAmendment后的文件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="nameValueCollection">请求参数</param>
|
|
|
|
|
/// <param name="fileInfo">文件</param>
|
|
|
|
|
/// <param name="contentType">请求类型</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
[NonAction]
|
|
|
|
|
private async Task<byte[]> ModifyFile(NameValueCollection nameValueCollection, dynamic fileInfo,
|
|
|
|
|
string contentType = "application/json")
|
|
|
|
|
{
|
|
|
|
|
//Stream ms = null;
|
|
|
|
|
|
|
|
|
|
byte[] bytes;
|
|
|
|
|
var result = string.Empty;
|
|
|
|
|
|
|
|
|
|
using (var httpClient = new HttpClient())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (var reduceAttach = new MultipartFormDataContent())
|
|
|
|
|
{
|
|
|
|
|
string[] allKeys = nameValueCollection.AllKeys;
|
|
|
|
|
foreach (string key in allKeys)
|
|
|
|
|
{
|
|
|
|
|
var dataContent = new ByteArrayContent(Encoding.UTF8.GetBytes(nameValueCollection[key]));
|
|
|
|
|
|
|
|
|
|
dataContent.Headers.ContentDisposition = new ContentDispositionHeaderValue($"form-data")
|
|
|
|
|
{
|
|
|
|
|
Name = key
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
reduceAttach.Add(dataContent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 文件参数
|
|
|
|
|
if (fileInfo != null)
|
|
|
|
|
{
|
|
|
|
|
var Content = new ByteArrayContent(fileInfo.FileBytes);
|
|
|
|
|
|
|
|
|
|
//Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
|
|
|
|
|
//{
|
|
|
|
|
// Name = fileInfo.file.ToString(),
|
|
|
|
|
// FileName = fileInfo.fileName.ToString(),
|
|
|
|
|
|
|
|
|
|
//};
|
|
|
|
|
|
|
|
|
|
Content.Headers.Add("Content-Type", contentType);
|
|
|
|
|
|
|
|
|
|
reduceAttach.Add(Content, "file", HttpUtility.UrlEncode(fileInfo.FileName.ToString()));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//httpClient.DefaultRequestHeaders.Add("USER_KEY", App.Configuration["ApiUserKey"]);
|
|
|
|
|
//httpClient.DefaultRequestHeaders.Add("USER_SECRET", App.Configuration["ApiUserSecret"]);
|
|
|
|
|
//请求
|
|
|
|
|
var response = httpClient.PostAsync(App.Configuration["BookingAmendModifyWebApiUrl"], reduceAttach).Result;
|
|
|
|
|
bytes = response.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("请求自动变更BookingAmendment文件内容异常,原因:{error}", ex.Message);
|
|
|
|
|
|
|
|
|
|
throw Oops.Oh($"请求自动变更BookingAmendment文件内容异常,原因:{ex.Message}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return bytes;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|