diff --git a/Myshipping.Application/Enum/CautionNoticeTaskEnum.cs b/Myshipping.Application/Enum/CautionNoticeTaskEnum.cs
new file mode 100644
index 00000000..9c93a18b
--- /dev/null
+++ b/Myshipping.Application/Enum/CautionNoticeTaskEnum.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Myshipping.Application
+{
+ ///
+ /// 重要提醒任务类型枚举
+ ///
+ public enum CautionNoticeTaskEnum
+ {
+ ///
+ /// 计费周差异
+ ///
+ [Description("计费周差异")]
+ WeekAt,
+ ///
+ /// 计费日期差异
+ ///
+ [Description("计费日期差异")]
+ PriceCalcDate
+ }
+
+ public enum CautionNoticeTypeEnum
+ {
+ ///
+ /// 钉钉消息
+ ///
+ [Description("钉钉消息")]
+ DingDing,
+ ///
+ /// 邮件提醒
+ ///
+ [Description("邮件提醒")]
+ Email
+ }
+}
diff --git a/Myshipping.Application/Event/CautionNoticeTaskSubscriber.cs b/Myshipping.Application/Event/CautionNoticeTaskSubscriber.cs
new file mode 100644
index 00000000..9fa4cd04
--- /dev/null
+++ b/Myshipping.Application/Event/CautionNoticeTaskSubscriber.cs
@@ -0,0 +1,162 @@
+using Furion;
+using Furion.DependencyInjection;
+using Furion.DistributedIDGenerator;
+using Furion.EventBus;
+using Furion.FriendlyException;
+using Furion.JsonSerialization;
+using MathNet.Numerics.LinearAlgebra.Factorization;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using Myshipping.Application.Entity;
+using Myshipping.Core;
+using NPOI.SS.Formula.Functions;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Myshipping.Application.Event
+{
+ ///
+ /// 重要通知任务订阅
+ ///
+ public class CautionNoticeTaskSubscriber : IEventSubscriber
+ {
+ private IServiceProvider _services { get; }
+ private readonly ILogger _logger;
+ private readonly INamedServiceProvider _namedTaskManageServiceProvider;
+
+ public CautionNoticeTaskSubscriber(IServiceProvider services, ILogger logger,
+ INamedServiceProvider namedTaskManageServiceProvider)
+ {
+ _services = services;
+ _logger = logger;
+
+ _namedTaskManageServiceProvider = namedTaskManageServiceProvider;
+
+ }
+
+ ///
+ /// 新增重要通知任务
+ ///
+ /// 订阅上下文
+ ///
+ [EventSubscribe("CautionNoticeTask:Add")]
+ public async Task CautionNoticeTaskAdd(EventHandlerExecutingContext context)
+ {
+ _logger.LogInformation($"收到更新订阅请求:{context.Source.Payload}");
+
+ var paraObj = context.Source.Payload;
+
+ using var scope = _services.CreateScope();
+
+ var bookingRepo = scope.ServiceProvider.GetRequiredService>();
+ var bookingSlotRepo = scope.ServiceProvider.GetRequiredService>();
+
+ var service = _namedTaskManageServiceProvider.GetService(nameof(TaskManageService));
+
+ DateTime nowDate = DateTime.Now;
+ /*
+ 1、生成重要提醒任务
+ 2、先从订舱订单提取操作OP和销售OP,推送钉钉和邮件提醒。
+ 3、如果没有订舱订单,可以从舱位获取操作OP,推送钉钉和邮件提醒。
+ */
+
+ CautionNoticeTaskDto dto = GetInfo(paraObj);
+
+ //生成任务
+ if (dto.cautionNoticeType == CautionNoticeTaskEnum.WeekAt)
+ {
+ TaskManageOrderMessageInfo messageInfo = new TaskManageOrderMessageInfo
+ {
+ Head = new TaskManageOrderMessageHeadInfo
+ {
+ GID = IDGen.NextID().ToString(),
+ MessageType = "CAUTION_TASK",
+ SenderId = "CautionNoticeTask",
+ SenderName = "重要提醒任务生成",
+ ReceiverId = "TaskManage",
+ ReceiverName = "任务台",
+ RequestDate = nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff"),
+ Version = "1.0",
+ RequestAction = "Add"
+ },
+ Main = new TaskManageOrderMessageMainInfo
+ {
+ TaskType = TaskBaseTypeEnum.CAUTION_NOTICE,
+ }
+ };
+
+ BookingSlotBase slotInfo = null;
+ BookingOrder bookingOrder = null;
+
+ string mblNo = string.Empty;
+ string vesselVoyno = string.Empty;
+ string etd = string.Empty;
+
+ if (dto.bookingSlotId > 0)
+ {
+ slotInfo = bookingSlotRepo.AsQueryable().Filter(null, true).First(x => x.Id == dto.bookingSlotId);
+ }
+
+ if (dto.bookingId > 0)
+ {
+ bookingOrder = bookingRepo.AsQueryable().Filter(null, true).First(x => x.Id == dto.bookingId);
+ }
+
+ messageInfo.Main.TaskTenatId = slotInfo.TenantId;
+ messageInfo.Main.TaskTenatName = slotInfo.TenantName;
+
+ if (slotInfo != null)
+ {
+ if (slotInfo.CARRIERID.Equals("MSK", StringComparison.OrdinalIgnoreCase))
+ {
+ mblNo = slotInfo.SLOT_BOOKING_NO;
+ messageInfo.Main.MBlNo = slotInfo.SLOT_BOOKING_NO;
+ messageInfo.Main.ETD = slotInfo.ETD;
+
+ vesselVoyno = $"{(slotInfo.VESSEL ?? "")}/{slotInfo.VOYNO ?? ""}";
+
+ messageInfo.Main.VesselVoyno = vesselVoyno;
+ messageInfo.Main.TaskUserId = dto.userId.ToString();
+ messageInfo.Main.TaskUserName = dto.userName;
+ messageInfo.Main.CarrierId = slotInfo.CARRIERID;
+ }
+ }
+
+ if (bookingOrder != null)
+ {
+ messageInfo.Main.CustomerId = bookingOrder.CUSTOMERID;
+ messageInfo.Main.CustomerName = bookingOrder.CUSTOMERNAME;
+ }
+
+ messageInfo.Main.TaskTitle = $"重要提醒-计费周发生变更 {vesselVoyno} {etd} BLNo:{mblNo}";
+ messageInfo.Main.TaskDesp = $"重要提醒-计费周发生变更 {vesselVoyno} {etd} BLNo:{mblNo}";
+
+ var rlt = await service.CreateTaskJob(messageInfo);
+ }
+ }
+
+ private CautionNoticeTaskDto GetInfo(object payload)
+ {
+ CautionNoticeTaskDto dto = null;
+
+ try
+ {
+ dto = JSON.Deserialize(JSON.Serialize(payload));
+ }
+ catch(Exception ex)
+ {
+ _logger.LogInformation($"解析订阅参数失败,原因:{ex.Message}");
+
+ throw Oops.Bah($"解析订阅参数失败,原因:{ex.Message}");
+ }
+
+ return dto;
+ }
+ }
+
+
+}
diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs
index 32d3d590..821d2a71 100644
--- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs
+++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs
@@ -63,6 +63,7 @@ namespace Myshipping.Application
private readonly IDjyCustomerService _djyCustomerService;
private readonly IBookingValueAddedService _bookingValueAddedService;
private readonly IBookingLabelService _bookingLabelService;
+
const string CONST_BC_FILE_CODE = "bc";
const string CONST_BC_FILE_NAME = "Booking Confirmation";
@@ -92,6 +93,7 @@ namespace Myshipping.Application
SqlSugarRepository bookingSlotCompareRepository,
SqlSugarRepository bookingOrderContactRepository,
INamedServiceProvider namedBookingOrderServiceProvider,
+
IBookingValueAddedService bookingValueAddedService,
SqlSugarRepository repBookingOrder,
SqlSugarRepository repLabelAllocation,
@@ -119,6 +121,8 @@ namespace Myshipping.Application
_repBookingOrder = repBookingOrder;
_repLabelAllocation = repLabelAllocation;
_bookingLabelService = bookingLabelService;
+
+
}
#region 舱位
@@ -722,6 +726,9 @@ namespace Myshipping.Application
TaskBCInfoDto bcSrcDto = model.Adapt();
TaskBCInfoDto bcTargetDto = dto.DataObj.Adapt();
+ //执行差异重要提醒
+ //await MeasureDiffCautionTask(bcSrcDto, bcTargetDto, model.Id);
+
//提取箱信息
var ctnList = _repCtn.AsQueryable().Filter(null, true)
.Where(x => x.IsDeleted == false && x.TenantId.Value == UserManager.TENANT_ID
@@ -2145,6 +2152,113 @@ namespace Myshipping.Application
return result;
}
+
+ #region 估算差异重要提醒
+ ///
+ /// 估算差异重要提醒
+ ///
+ /// 原舱位详情
+ /// 新舱位详情
+ /// 舱位ID
+ ///
+ [NonAction]
+ public async Task MeasureDiffCautionTask(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId)
+ {
+ if (bcSrcDto.CarrierId.Equals("MSK", StringComparison.OrdinalIgnoreCase))
+ {
+ string srcWeek = bcSrcDto.WeekAt ?? "";
+ string targetWeek = bcTargetDto.WeekAt ?? "";
+
+ //如果计费周不一致需要推送推送任务台生成重要提醒
+ if (!srcWeek.Equals(targetWeek, StringComparison.OrdinalIgnoreCase))
+ {
+ var bookingList = _repAllocation.AsQueryable().Filter(null, true)
+ .Where(x => x.BOOKING_SLOT_ID == slotId && x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToList();
+
+ if (bookingList.Count > 0)
+ {
+ bookingList.ForEach(async ca =>
+ {
+ await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add",
+ new CautionNoticeTaskDto
+ {
+ cautionNoticeType = CautionNoticeTaskEnum.WeekAt,
+ bookingId = ca.BOOKING_ID,
+ bookingSlotId = ca.BOOKING_SLOT_ID,
+ createTime = DateTime.Now,
+ origVal = srcWeek,
+ newVal = targetWeek,
+ tenentId = UserManager.TENANT_ID,
+ userId = UserManager.UserId,
+ userName = UserManager.Name,
+ }));
+
+ });
+ }
+ else
+ {
+ await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add",
+ new CautionNoticeTaskDto
+ {
+ cautionNoticeType = CautionNoticeTaskEnum.WeekAt,
+ bookingSlotId = slotId,
+ createTime = DateTime.Now,
+ origVal = srcWeek,
+ newVal = targetWeek,
+ tenentId = UserManager.TENANT_ID,
+ userId = UserManager.UserId,
+ userName = UserManager.Name,
+ }));
+ }
+ }
+
+ string srcPriceCalcDate = bcSrcDto.PriceCalculationDate.HasValue ? bcSrcDto.PriceCalculationDate.Value.ToString("yyyy-MM-dd") : "";
+ string targePriceCalcDate = bcTargetDto.PriceCalculationDate.HasValue ? bcTargetDto.PriceCalculationDate.Value.ToString("yyyy-MM-dd") : "";
+
+ if (!srcPriceCalcDate.Equals(targePriceCalcDate, StringComparison.OrdinalIgnoreCase))
+ {
+ var bookingList = _repAllocation.AsQueryable().Filter(null, true)
+ .Where(x => x.BOOKING_SLOT_ID == slotId && x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).ToList();
+
+ if (bookingList.Count > 0)
+ {
+ bookingList.ForEach(async ca =>
+ {
+ await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add",
+ new CautionNoticeTaskDto
+ {
+ cautionNoticeType = CautionNoticeTaskEnum.PriceCalcDate,
+ bookingId = ca.BOOKING_ID,
+ bookingSlotId = ca.BOOKING_SLOT_ID,
+ createTime = DateTime.Now,
+ origVal = srcWeek,
+ newVal = targetWeek,
+ tenentId = UserManager.TENANT_ID,
+ userId = UserManager.UserId,
+ userName = UserManager.Name,
+ }));
+
+ });
+ }
+ else
+ {
+ await _publisher.PublishAsync(new ChannelEventSource("CautionNoticeTask:Add",
+ new CautionNoticeTaskDto
+ {
+ cautionNoticeType = CautionNoticeTaskEnum.PriceCalcDate,
+ bookingSlotId = slotId,
+ createTime = DateTime.Now,
+ origVal = srcWeek,
+ newVal = targetWeek,
+ tenentId = UserManager.TENANT_ID,
+ userId = UserManager.UserId,
+ userName = UserManager.Name,
+ }));
+ }
+ }
+ }
+ }
+ #endregion
}
diff --git a/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotMapper.cs b/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotMapper.cs
index 9ef99596..380f68d7 100644
--- a/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotMapper.cs
+++ b/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotMapper.cs
@@ -42,7 +42,8 @@ namespace Myshipping.Application
.Map(dest => dest.PortDischarge, src => src.PORTDISCHARGE)
.Map(dest => dest.Portload, src => src.PORTLOAD)
.Map(dest => dest.TransferPort1, src => src.TRANSFER_PORT_1)
- .Map(dest => dest.TransferPort2, src => src.TRANSFER_PORT_2);
+ .Map(dest => dest.TransferPort2, src => src.TRANSFER_PORT_2)
+ .Map(dest => dest.PriceCalculationDate, src => src.PRICE_CALCULATION_DATE);
config.ForType()
.Map(dest => dest.CarrierId, src => src.CARRIERID)
@@ -73,7 +74,8 @@ namespace Myshipping.Application
.Map(dest => dest.PortDischarge, src => src.PORTDISCHARGE)
.Map(dest => dest.Portload, src => src.PORTLOAD)
.Map(dest => dest.TransferPort1, src => src.TRANSFER_PORT_1)
- .Map(dest => dest.TransferPort2, src => src.TRANSFER_PORT_2);
+ .Map(dest => dest.TransferPort2, src => src.TRANSFER_PORT_2)
+ .Map(dest => dest.PriceCalculationDate, src => src.PRICE_CALCULATION_DATE);
config.ForType()
.Map(dest => dest.CarrierId, src => src.CarrierId)
diff --git a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs
index b5278c81..902d179d 100644
--- a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs
+++ b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs
@@ -153,5 +153,14 @@ namespace Myshipping.Application
/// 请求批次号用来区分对应的哪个批次任务
///
Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId, string reqBatchNo);
+
+ ///
+ /// 估算差异重要提醒
+ ///
+ /// 原舱位详情
+ /// 新舱位详情
+ /// 舱位ID
+ ///
+ Task MeasureDiffCautionTask(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId);
}
}
\ No newline at end of file
diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/CautionNoitce/CautionNoticeTaskDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/CautionNoitce/CautionNoticeTaskDto.cs
new file mode 100644
index 00000000..475fd8d1
--- /dev/null
+++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/CautionNoitce/CautionNoticeTaskDto.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Myshipping.Application
+{
+ public class CautionNoticeTaskDto
+ {
+ ///
+ /// WeekAt-计费周差异 PriceCalcDate-计费周差异
+ ///
+ public CautionNoticeTaskEnum cautionNoticeType { get; set; }
+
+ ///
+ /// 订舱ID
+ ///
+ public Nullable bookingId { get; set; }
+
+ ///
+ /// 舱位ID
+ ///
+ public Nullable bookingSlotId { get; set; }
+
+ ///
+ /// 任务ID
+ ///
+ public string taskPKId { get; set; }
+
+ ///
+ /// 创建日期
+ ///
+ public DateTime createTime { get; set; }
+
+ ///
+ /// 原值
+ ///
+ public string origVal { get; set; }
+
+ ///
+ /// 新值
+ ///
+ public string newVal { get; set; }
+
+ ///
+ /// 租户ID
+ ///
+ public long tenentId { get; set; }
+
+ ///
+ /// 用户ID
+ ///
+ public long userId { get; set; }
+
+ ///
+ /// 用户名称
+ ///
+ public string userName { get; set; }
+ }
+}
diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/CautionNoitce/TaskManageOrderCautionNoticeInfo.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/CautionNoitce/TaskManageOrderCautionNoticeInfo.cs
new file mode 100644
index 00000000..047f76a3
--- /dev/null
+++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/CautionNoitce/TaskManageOrderCautionNoticeInfo.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Myshipping.Application
+{
+ public class TaskManageOrderCautionNoticeInfo
+ {
+ ///
+ /// WeekAt-计费周差异 PriceCalcDate-计费周差异
+ ///
+ public CautionNoticeTaskEnum CautionNoticeType { get; set; }
+
+ ///
+ /// 订舱ID
+ ///
+ public Nullable BookingId { get; set; }
+
+ ///
+ /// 舱位ID
+ ///
+ public Nullable BookingSlotId { get; set; }
+
+ ///
+ /// 任务ID
+ ///
+ public string TaskPKId { get; set; }
+
+ ///
+ /// 创建日期
+ ///
+ public DateTime CreateTime { get; set; }
+
+ ///
+ /// 原值
+ ///
+ public string OrigVal { get; set; }
+
+ ///
+ /// 新值
+ ///
+ public string NewVal { get; set; }
+
+ ///
+ /// 消息列表
+ ///
+ public List NoticeList { get; set; }
+ }
+
+ ///
+ ///
+ ///
+ public class TaskManageOrderCautionNoticeDetailInfo
+ {
+ ///
+ /// 重要提醒消息类型
+ ///
+ public CautionNoticeTypeEnum CautionNoticeType { get; set; }
+
+ ///
+ /// 用户ID
+ ///
+ public string UserId { get; set; }
+
+ ///
+ /// 用户手机号
+ ///
+ public string Mobile { get; set; }
+ }
+}
diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs
index 995af80b..95f6d2b8 100644
--- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs
+++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoDto.cs
@@ -376,5 +376,10 @@ namespace Myshipping.Application
/// 批次号
///
public string BatchNo { get; set; }
+
+ ///
+ /// 计费日期
+ ///
+ public Nullable PriceCalculationDate { get; set; }
}
}