修改截止时间变更任务

master
jianghaiqing 6 months ago
parent dc2c5be096
commit 65755e4f29

@ -65,5 +65,20 @@ namespace Myshipping.Application
/// 原因
/// </summary>
public string REASON { get; set; }
/// <summary>
/// 任务批次明细合计
/// </summary>
public int TASK_BATCH_TOTAL { get; set; }
/// <summary>
/// 任务批次单票合计
/// </summary>
public int TASK_BATCH_PER_TOTAL { get; set; }
/// <summary>
/// 任务批次号
/// </summary>
public string TASK_BATCH_NO { get; set; }
}
}

@ -61,6 +61,15 @@ namespace Myshipping.Application.Service.TaskManagePlat.Dtos
/// </summary>
public string MBLNo { get; set; }
/// <summary>
/// 明细总票数
/// </summary>
public int TotalNum { get; set; }
/// <summary>
/// 单票总票数
/// </summary>
public int PerTotalNum { get; set; }
}
/// <summary>

@ -991,8 +991,10 @@ namespace Myshipping.Application
.Map(dest => dest.VESSEL, src => src.Vessel)
.Map(dest => dest.MBL_NO, src => src.MBLNo)
.Map(dest => dest.PORTLOAD_AREA, src => src.PortLoadArea)
.Map(dest => dest.REASON, src => src.Reason);
.Map(dest => dest.REASON, src => src.Reason)
.Map(dest => dest.TASK_BATCH_TOTAL, src => src.TotalNum)
.Map(dest => dest.TASK_BATCH_PER_TOTAL, src => src.PerTotalNum)
.Map(dest => dest.TASK_BATCH_NO, src => src.BatchNo);
config.ForType<CutDateChangeDetailDto, TaskCutDateChangeDetailInfo>()
.Map(dest => dest.MBL_NO, src => src.MBLNo)

@ -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
}
}

@ -147,6 +147,7 @@ namespace Myshipping.Application
private readonly INamedServiceProvider<ITaskCautionNoticeService> _namedTaskCautionNoticeServiceProvider;
private readonly INamedServiceProvider<ITaskTransPlanHasChangeService> _namedTaskTransPlanHasChangeServiceProvider;
private readonly INamedServiceProvider<ITaskPOLContainerNotPickUpService> _namedTaskPOLContainerNotPickUpServiceProvider;
private readonly INamedServiceProvider<ITaskManageCutDateChangeService> _namedTaskManageCutDateChangeServiceProvider;
private readonly IBookingValueAddedService _bookingValueAddedService;
@ -216,6 +217,7 @@ namespace Myshipping.Application
INamedServiceProvider<ITaskCautionNoticeService> namedTaskCautionNoticeServiceProvider,
INamedServiceProvider<ITaskTransPlanHasChangeService> namedTaskTransPlanHasChangeServiceProvider,
INamedServiceProvider<ITaskPOLContainerNotPickUpService> namedTaskPOLContainerNotPickUpServiceProvider,
INamedServiceProvider<ITaskManageCutDateChangeService> namedTaskManageCutDateChangeServiceProvider,
ILogger<BookingOrderService> logger)
{
_taskBaseInfoRepository = taskBaseInfoRepository;
@ -283,6 +285,7 @@ namespace Myshipping.Application
_namedTaskTransPlanHasChangeServiceProvider = namedTaskTransPlanHasChangeServiceProvider;
_taskPOLContainerNotPickUpInfoRepository = taskPOLContainerNotPickUpInfoRepository;
_namedTaskPOLContainerNotPickUpServiceProvider = namedTaskPOLContainerNotPickUpServiceProvider;
_namedTaskManageCutDateChangeServiceProvider = namedTaskManageCutDateChangeServiceProvider;
}
#region 创建任务
@ -1086,101 +1089,11 @@ namespace Myshipping.Application
});
}
//判断是否有订舱,有订舱需要更新
var mblNoList = info.Main.CutDateChange.Details
.Select(x => x.MBLNo.Trim().ToUpper()).Distinct().ToList();
var bookingList = _bookingOrderRepository.AsQueryable().Filter(null, true)
.Where(x => mblNoList.Contains(x.MBLNO) && (x.ParentId == 0 || x.ParentId == null)
&& x.IsDeleted == false && x.TenantId == taskInfo.TenantId).ToList();
if (bookingList.Count > 0)
{
bookingList.ForEach(x => {
var chageInfo = info.Main.CutDateChange.Details.FirstOrDefault(a =>
a.MBLNo.Equals(x.MBLNO, StringComparison.OrdinalIgnoreCase));
var bookingOrder = _bookingOrderRepository.AsQueryable()
.First(a => a.Id == x.Id);
var oldOrder = bookingOrder.Adapt<BookingOrder>();
_logger.LogInformation($"更新订舱相关的截单时间 JSON={JSON.Serialize(chageInfo)}");
if(chageInfo.VGMCutoffTime.HasValue)
x.CLOSEVGMDATE = chageInfo.VGMCutoffTime.Value;
if (chageInfo.CYCutoffTime.HasValue)
x.CLOSINGDATE = chageInfo.CYCutoffTime.Value;
if (chageInfo.SICutDate.HasValue)
x.CLOSEDOCDATE = chageInfo.SICutDate.Value;
_bookingOrderRepository.AsUpdateable(x).UpdateColumns(it => new
{
it.CLOSEVGMDATE,
it.CLOSINGDATE,
it.CLOSEDOCDATE
}).ExecuteCommand();
// 保存日志
var bookingOrderService = _namedBookingOrderServiceProvider.GetService<ITransient>(nameof(BookingOrderService));
bookingOrderService.SaveLog(bookingOrder, oldOrder, "截止时间变更");
});
}
//判断是否有舱位,需要更新舱位
var bookingSlotList = _bookingSlotBaseRepository.AsQueryable().Filter(null, true)
.Where(x => mblNoList.Contains(x.SLOT_BOOKING_NO)
&& x.IsDeleted == false && x.TenantId == taskInfo.TenantId).ToList();
if (bookingSlotList.Count > 0)
{
bookingSlotList.ForEach(x => {
var chageInfo = info.Main.CutDateChange.Details.FirstOrDefault(a =>
a.MBLNo.Equals(x.SLOT_BOOKING_NO, StringComparison.OrdinalIgnoreCase));
var slotOrder = _bookingSlotBaseRepository.AsQueryable()
.First(a => a.Id == x.Id);
var oldOrder = slotOrder.Adapt<BookingSlotBaseApiSaveDto>();
_logger.LogInformation($"更新订舱相关的截单时间 JSON={JSON.Serialize(chageInfo)}");
if (chageInfo.VGMCutoffTime.HasValue)
x.VGM_SUBMISSION_CUT_DATE = chageInfo.VGMCutoffTime.Value;
if (chageInfo.CYCutoffTime.HasValue)
x.CY_CUT_DATE = chageInfo.CYCutoffTime.Value;
if (chageInfo.SICutDate.HasValue)
x.SI_CUT_DATE = chageInfo.SICutDate.Value;
if (chageInfo.MDGFCutDate.HasValue)
x.MDGF_CUT_DATE = chageInfo.MDGFCutDate.Value;
if (chageInfo.ManifestCutDate.HasValue)
x.MANIFEST_CUT_DATE = chageInfo.ManifestCutDate.Value;
_bookingSlotBaseRepository.AsUpdateable(x).UpdateColumns(it => new
{
it.VGM_SUBMISSION_CUT_DATE,
it.CY_CUT_DATE,
it.SI_CUT_DATE,
x.MDGF_CUT_DATE,
x.MANIFEST_CUT_DATE
}).ExecuteCommand();
// 保存日志
// var bookingOrderService = _namedBookingOrderServiceProvider.GetService<ITransient>(nameof(BookingOrderService));
//bookingOrderService.SaveLog(bookingOrder, oldOrder, "截止时间变更");
//触发推送消息
var name = _namedTaskManageCutDateChangeServiceProvider
.GetService<ITransient>(nameof(TaskManageCutDateChangeService));
});
}
await name.AutoTransferNotice(taskInfo.PK_ID);
}
#endregion

Loading…
Cancel
Save