|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using Furion;
|
|
|
|
|
using Furion.DependencyInjection;
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Furion.JsonSerialization;
|
|
|
|
@ -7,10 +8,12 @@ using HtmlAgilityPack;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Myshipping.Application;
|
|
|
|
|
using Myshipping.Application.ConfigOption;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Myshipping.Application.Enum;
|
|
|
|
|
using Myshipping.Application.Helper;
|
|
|
|
|
using Myshipping.Application.Service.BookingSlot.Dto;
|
|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
using Myshipping.Core.Helper;
|
|
|
|
@ -18,6 +21,7 @@ using Myshipping.Core.Service;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Npoi.Mapper;
|
|
|
|
|
using NPOI.OpenXmlFormats.Wordprocessing;
|
|
|
|
|
using Org.BouncyCastle.Asn1.Tsp;
|
|
|
|
|
using Org.BouncyCastle.Crypto;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
@ -34,7 +38,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// 截止时间变更
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiDescriptionSettings("Application", Name = "TaskManageCutDateChange", Order = 10)]
|
|
|
|
|
public class TaskManageCutDateChangeService: ITaskManageCutDateChangeService, IDynamicApiController
|
|
|
|
|
public class TaskManageCutDateChangeService : ITaskManageCutDateChangeService, IDynamicApiController
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<TaskCutDateChangeInfo> _taskCutDateChangeInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<TaskCutDateChangeDetailInfo> _taskCutDateChangeDetailInfoRepository;
|
|
|
|
@ -46,6 +50,8 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly SqlSugarRepository<DjyUserMailAccount> _djyUserMailAccount;
|
|
|
|
|
private readonly SqlSugarRepository<BookingPrintTemplate> _repPrintTemplate;
|
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
|
private readonly INamedServiceProvider<IBookingOrderService> _namedBookingOrderServiceProvider;
|
|
|
|
|
private readonly SqlSugarRepository<BookingSlotBase> _bookingSlotBaseRepository;
|
|
|
|
|
|
|
|
|
|
public TaskManageCutDateChangeService(SqlSugarRepository<TaskCutDateChangeInfo> taskCutDateChangeInfoRepository,
|
|
|
|
|
SqlSugarRepository<TaskCutDateChangeDetailInfo> taskCutDateChangeDetailInfoRepository,
|
|
|
|
@ -56,6 +62,8 @@ namespace Myshipping.Application
|
|
|
|
|
SqlSugarRepository<BookingPrintTemplate> repPrintTemplate,
|
|
|
|
|
ILogger<TaskManageCutDateChangeService> logger,
|
|
|
|
|
ISysCacheService cache,
|
|
|
|
|
INamedServiceProvider<IBookingOrderService> namedBookingOrderServiceProvider,
|
|
|
|
|
SqlSugarRepository<BookingSlotBase> bookingSlotBaseRepository,
|
|
|
|
|
SqlSugarRepository<BookingOrder> bookingOrderRepository)
|
|
|
|
|
{
|
|
|
|
|
_taskCutDateChangeInfoRepository = taskCutDateChangeInfoRepository;
|
|
|
|
@ -66,6 +74,8 @@ namespace Myshipping.Application
|
|
|
|
|
_sysUserRepository = sysUserRepository;
|
|
|
|
|
_djyUserMailAccount = djyUserMailAccount;
|
|
|
|
|
_repPrintTemplate = repPrintTemplate;
|
|
|
|
|
_namedBookingOrderServiceProvider = namedBookingOrderServiceProvider;
|
|
|
|
|
_bookingSlotBaseRepository = bookingSlotBaseRepository;
|
|
|
|
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_cache = cache;
|
|
|
|
@ -278,12 +288,12 @@ namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
msgList.ForEach(t =>
|
|
|
|
|
{
|
|
|
|
|
DingTalkGroupHelper.SendDingTalkGroupMessage("KangqianNotify", "截止时间变更消息", $"@{t.Key} 收到如下提单号{(string.Join(",",t.Value.ToArray()))}的截止时间变更消息");
|
|
|
|
|
DingTalkGroupHelper.SendDingTalkGroupMessage("KangqianNotify", "截止时间变更消息", $"@{t.Key} 收到如下提单号{(string.Join(",", t.Value.ToArray()))}的截止时间变更消息");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(detailList.Any(t=>!t.BOOKING_ID.HasValue))
|
|
|
|
|
throw Oops.Oh($"提单号{(string.Join(",", detailList.Where(t => !t.BOOKING_ID.HasValue).Select(t=>t.MBL_NO).ToArray()))}未提取有效的订舱订单");
|
|
|
|
|
if (detailList.Any(t => !t.BOOKING_ID.HasValue))
|
|
|
|
|
throw Oops.Oh($"提单号{(string.Join(",", detailList.Where(t => !t.BOOKING_ID.HasValue).Select(t => t.MBL_NO).ToArray()))}未提取有效的订舱订单");
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
result.msg = "成功";
|
|
|
|
@ -306,12 +316,19 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var queryRlt = QueryBookingOrder(taskPKId);
|
|
|
|
|
var queryRlt = await QueryBookingOrder(taskPKId);
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 检索对应的订舱记录完成,结果:{JSON.Serialize(queryRlt)}");
|
|
|
|
|
|
|
|
|
|
if (queryRlt.succ)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskPKId={taskPKId} 检索对应的订舱记录成功,触发订舱的截止时间更新");
|
|
|
|
|
|
|
|
|
|
//更新订舱的截单时间
|
|
|
|
|
await UpdateBookingOrderCutDate(taskPKId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//_logger.LogInformation($"taskPKId={taskPKId} 当前租户未开启货物运输计划已变更是否同批次同客户合并邮件通知,按照单票推送邮件处理");
|
|
|
|
|
await UpdateBookingSlotCutDate(taskPKId);
|
|
|
|
|
|
|
|
|
|
//如果没有配置批量,则按单票发送邮件
|
|
|
|
|
var rlt = SendEmailToCustomer(taskPKId);
|
|
|
|
@ -352,7 +369,8 @@ namespace Myshipping.Application
|
|
|
|
|
var entityInfo = _taskCutDateChangeInfoRepository.AsQueryable().Filter(null, true).First(a => a.TASK_ID == taskBase.PK_ID);
|
|
|
|
|
|
|
|
|
|
if (entityInfo == null)
|
|
|
|
|
throw Oops.Oh($"起运港未提箱主键{taskPKId}无法获取业务信息");
|
|
|
|
|
throw Oops.Oh($"截止时间变更主键{taskPKId}无法获取业务信息");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//通过船名航次取是主单的订舱记录列表
|
|
|
|
|
var bookingInfo = _bookingOrderRepository.AsQueryable().Filter(null, true).First(a => a.MBLNO == entityInfo.MBL_NO
|
|
|
|
@ -366,7 +384,8 @@ namespace Myshipping.Application
|
|
|
|
|
entityInfo.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
entityInfo.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
await _taskCutDateChangeInfoRepository.AsUpdateable(entityInfo).UpdateColumns(x => new {
|
|
|
|
|
await _taskCutDateChangeInfoRepository.AsUpdateable(entityInfo).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.BOOKING_ID,
|
|
|
|
|
x.UpdatedTime,
|
|
|
|
|
x.UpdatedUserId,
|
|
|
|
@ -375,7 +394,7 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
var list = _taskCutDateChangeDetailInfoRepository.AsQueryable().Filter(null, true).Where(a => a.P_ID == entityInfo.PK_ID).ToList();
|
|
|
|
|
|
|
|
|
|
if(list != null && list.Count > 0)
|
|
|
|
|
if (list != null && list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
list.ForEach(async p =>
|
|
|
|
|
{
|
|
|
|
@ -386,7 +405,8 @@ namespace Myshipping.Application
|
|
|
|
|
p.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
p.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
await _taskCutDateChangeDetailInfoRepository.AsUpdateable(p).UpdateColumns(x => new {
|
|
|
|
|
await _taskCutDateChangeDetailInfoRepository.AsUpdateable(p).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.BOOKING_ID,
|
|
|
|
|
x.UpdatedTime,
|
|
|
|
|
x.UpdatedUserId,
|
|
|
|
@ -657,7 +677,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// <param name="tenantName"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[NonAction]
|
|
|
|
|
private async Task<string> GenerateSendEmailHtml(TaskCutDateChangeInfo model,List<TaskCutDateChangeDetailInfo> rowList, List<BookingOrder> bookingOrderList,
|
|
|
|
|
private async Task<string> GenerateSendEmailHtml(TaskCutDateChangeInfo model, List<TaskCutDateChangeDetailInfo> rowList, List<BookingOrder> bookingOrderList,
|
|
|
|
|
string filePath, SysUser opUserInfo, string tenantName)
|
|
|
|
|
{
|
|
|
|
|
string result = string.Empty;
|
|
|
|
@ -808,7 +828,7 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < rowList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
tableBuilder.Append($"<tr><td>{rowList[i].MBL_NO}</td><td>{rowList[i].CONTA_NO}</td><td>{rowList[i].LOAD_PORT}</td><td>{(rowList[i].ETB.HasValue? rowList[i].ETB.Value.ToString("yyyy-MM-dd HH:mm"):"")}</td><td>{(rowList[i].ETD.HasValue ? rowList[i].ETD.Value.ToString("yyyy-MM-dd HH:mm") : "")}</td></tr>");
|
|
|
|
|
tableBuilder.Append($"<tr><td>{rowList[i].MBL_NO}</td><td>{rowList[i].CONTA_NO}</td><td>{rowList[i].LOAD_PORT}</td><td>{(rowList[i].ETB.HasValue ? rowList[i].ETB.Value.ToString("yyyy-MM-dd HH:mm") : "")}</td><td>{(rowList[i].ETD.HasValue ? rowList[i].ETD.Value.ToString("yyyy-MM-dd HH:mm") : "")}</td></tr>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//生成From Vessel的table列表
|
|
|
|
@ -894,5 +914,140 @@ namespace Myshipping.Application
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 更新订舱截止时间
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新订舱截止时间
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskPKId">截止时间变更任务主键</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private async Task UpdateBookingOrderCutDate(string taskPKId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var taskBase = _taskBaseRepository.AsQueryable().Filter(null, true).First(a => a.PK_ID == taskPKId);
|
|
|
|
|
|
|
|
|
|
if (taskBase == null)
|
|
|
|
|
throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息");
|
|
|
|
|
|
|
|
|
|
var entityInfo = _taskCutDateChangeInfoRepository.AsQueryable().Filter(null, true).First(a => a.TASK_ID == taskBase.PK_ID);
|
|
|
|
|
|
|
|
|
|
if (entityInfo == null)
|
|
|
|
|
throw Oops.Oh($"截止时间变更主键{taskPKId}无法获取业务信息");
|
|
|
|
|
|
|
|
|
|
if (!entityInfo.BOOKING_ID.HasValue)
|
|
|
|
|
throw Oops.Oh($"截止时间变更主键{taskPKId} mblno={entityInfo.MBL_NO} 没有匹配的订舱记录,更新截止时间失败");
|
|
|
|
|
|
|
|
|
|
var bookingId = entityInfo.BOOKING_ID.Value;
|
|
|
|
|
|
|
|
|
|
//通过船名航次取是主单的订舱记录列表
|
|
|
|
|
var bookingInfo = _bookingOrderRepository.AsQueryable().Filter(null, true).First(a => a.Id == bookingId);
|
|
|
|
|
|
|
|
|
|
var detailInfo = _taskCutDateChangeDetailInfoRepository.AsQueryable().Filter(null, true).First(a => a.P_ID == entityInfo.PK_ID);
|
|
|
|
|
|
|
|
|
|
var oldOrder = bookingInfo.Adapt<BookingOrder>();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"更新订舱相关的截单时间 JSON={JSON.Serialize(detailInfo)}");
|
|
|
|
|
|
|
|
|
|
if (detailInfo.VGM_CUT.HasValue)
|
|
|
|
|
bookingInfo.CLOSEVGMDATE = detailInfo.VGM_CUT.Value;
|
|
|
|
|
|
|
|
|
|
if (detailInfo.CY_CUTOFF.HasValue)
|
|
|
|
|
bookingInfo.CLOSINGDATE = detailInfo.CY_CUTOFF.Value;
|
|
|
|
|
|
|
|
|
|
if (detailInfo.SI_CUTOFF.HasValue)
|
|
|
|
|
bookingInfo.CLOSEDOCDATE = detailInfo.SI_CUTOFF.Value;
|
|
|
|
|
|
|
|
|
|
_bookingOrderRepository.AsUpdateable(bookingInfo).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.CLOSEVGMDATE,
|
|
|
|
|
it.CLOSINGDATE,
|
|
|
|
|
it.CLOSEDOCDATE
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
// 保存日志
|
|
|
|
|
var bookingOrderService = _namedBookingOrderServiceProvider.GetService<ITransient>(nameof(BookingOrderService));
|
|
|
|
|
bookingOrderService.SaveLog(bookingInfo, oldOrder, "截止时间变更");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"截止时间变更主键{taskPKId} mblno={entityInfo.MBL_NO} 更新订舱完毕");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskid={taskPKId} 截止时间变更更新订舱失败");
|
|
|
|
|
|
|
|
|
|
new EmailNoticeHelper().SendEmailNotice($"taskid={taskPKId} 截止时间变更更新订舱失败", $"taskid={taskPKId} 截止时间变更更新订舱失败,原因:{ex.Message}", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 更新舱位截止时间
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新舱位截止时间
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskPKId">截止时间变更任务主键</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private async Task UpdateBookingSlotCutDate(string taskPKId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var taskBase = _taskBaseRepository.AsQueryable().Filter(null, true).First(a => a.PK_ID == taskPKId);
|
|
|
|
|
|
|
|
|
|
if (taskBase == null)
|
|
|
|
|
throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息");
|
|
|
|
|
|
|
|
|
|
var entityInfo = _taskCutDateChangeInfoRepository.AsQueryable().Filter(null, true).First(a => a.TASK_ID == taskBase.PK_ID);
|
|
|
|
|
|
|
|
|
|
if (entityInfo == null)
|
|
|
|
|
throw Oops.Oh($"截止时间变更主键{taskPKId}无法获取业务信息");
|
|
|
|
|
|
|
|
|
|
var detailInfo = _taskCutDateChangeDetailInfoRepository.AsQueryable().Filter(null, true).First(a => a.P_ID == entityInfo.PK_ID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断是否有舱位,需要更新舱位
|
|
|
|
|
var slotOrder = _bookingSlotBaseRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.First(x => entityInfo.MBL_NO.Equals(x.SLOT_BOOKING_NO)
|
|
|
|
|
&& x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID);
|
|
|
|
|
|
|
|
|
|
var oldOrder = slotOrder.Adapt<BookingSlotBaseApiSaveDto>();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"更新订舱相关的截单时间 JSON={JSON.Serialize(entityInfo)}");
|
|
|
|
|
|
|
|
|
|
if (detailInfo.VGM_CUT.HasValue)
|
|
|
|
|
slotOrder.VGM_SUBMISSION_CUT_DATE = detailInfo.VGM_CUT.Value;
|
|
|
|
|
|
|
|
|
|
if (detailInfo.CY_CUTOFF.HasValue)
|
|
|
|
|
slotOrder.CY_CUT_DATE = detailInfo.CY_CUTOFF.Value;
|
|
|
|
|
|
|
|
|
|
if (detailInfo.SI_CUTOFF.HasValue)
|
|
|
|
|
slotOrder.SI_CUT_DATE = detailInfo.SI_CUTOFF.Value;
|
|
|
|
|
|
|
|
|
|
if (detailInfo.MDGF_CUT.HasValue)
|
|
|
|
|
slotOrder.MDGF_CUT_DATE = detailInfo.MDGF_CUT.Value;
|
|
|
|
|
|
|
|
|
|
if (detailInfo.MANIFEST_CUT.HasValue)
|
|
|
|
|
slotOrder.MANIFEST_CUT_DATE = detailInfo.MANIFEST_CUT.Value;
|
|
|
|
|
|
|
|
|
|
_bookingSlotBaseRepository.AsUpdateable(slotOrder).UpdateColumns(it => new
|
|
|
|
|
{
|
|
|
|
|
it.VGM_SUBMISSION_CUT_DATE,
|
|
|
|
|
it.CY_CUT_DATE,
|
|
|
|
|
it.SI_CUT_DATE,
|
|
|
|
|
it.MDGF_CUT_DATE,
|
|
|
|
|
it.MANIFEST_CUT_DATE
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"截止时间变更主键{taskPKId} mblno={entityInfo.MBL_NO} 更新舱位完毕");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"taskid={taskPKId} 截止时间变更更新舱位失败");
|
|
|
|
|
|
|
|
|
|
new EmailNoticeHelper().SendEmailNotice($"taskid={taskPKId} 截止时间变更更新舱位失败", $"taskid={taskPKId} 截止时间变更更新舱位失败,原因:{ex.Message}", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|