master
douhandong 6 months ago
commit ca002fcf76

@ -1056,7 +1056,7 @@ namespace Myshipping.Application.Entity
/// <summary>
/// 是否为舱位拆票后生成的订舱
/// </summary>
public bool? IsSplit { get; set; }
public bool IsSplit { get; set; }
/// <summary>
/// 分单操作ID

@ -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
{
/// <summary>
/// 重要提醒任务类型枚举
/// </summary>
public enum CautionNoticeTaskEnum
{
/// <summary>
/// 计费周差异
/// </summary>
[Description("计费周差异")]
WeekAt,
/// <summary>
/// 计费日期差异
/// </summary>
[Description("计费日期差异")]
PriceCalcDate
}
public enum CautionNoticeTypeEnum
{
/// <summary>
/// 钉钉消息
/// </summary>
[Description("钉钉消息")]
DingDing,
/// <summary>
/// 邮件提醒
/// </summary>
[Description("邮件提醒")]
Email
}
}

@ -150,6 +150,13 @@ namespace Myshipping.Application.Event
{
// 已使用舱位数
stockObj.USE_NUM = lstAllocKeyList.DistinctBy(x => x.BOOKING_SLOT_ID).Count();
//// 这里要判断使用的箱子与舱位原有的箱子的数量是否一致,在一致的情况下,舱位才算被使用
//foreach (var item in lstAllocKeyList)
//{
//}
//await _repAllocCtn.AsQueryable().Filter(null, true).Where(x => !x.IsDeleted)
// 订舱引用表主键列表
var lstAllocIdList = lstAllocKeyList.Select(x => x.Id).ToList();

@ -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
{
/// <summary>
/// 重要通知任务订阅
/// </summary>
public class CautionNoticeTaskSubscriber : IEventSubscriber
{
private IServiceProvider _services { get; }
private readonly ILogger<CautionNoticeTaskSubscriber> _logger;
private readonly INamedServiceProvider<ITaskManageService> _namedTaskManageServiceProvider;
public CautionNoticeTaskSubscriber(IServiceProvider services, ILogger<CautionNoticeTaskSubscriber> logger,
INamedServiceProvider<ITaskManageService> namedTaskManageServiceProvider)
{
_services = services;
_logger = logger;
_namedTaskManageServiceProvider = namedTaskManageServiceProvider;
}
/// <summary>
/// 新增重要通知任务
/// </summary>
/// <param name="context">订阅上下文</param>
/// <returns></returns>
[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<SqlSugarRepository<BookingOrder>>();
var bookingSlotRepo = scope.ServiceProvider.GetRequiredService<SqlSugarRepository<BookingSlotBase>>();
var service = _namedTaskManageServiceProvider.GetService(nameof(TaskManageService));
DateTime nowDate = DateTime.Now;
/*
1
2OPOP
3OP
*/
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<CautionNoticeTaskDto>(JSON.Serialize(payload));
}
catch(Exception ex)
{
_logger.LogInformation($"解析订阅参数失败,原因:{ex.Message}");
throw Oops.Bah($"解析订阅参数失败,原因:{ex.Message}");
}
return dto;
}
}
}

@ -1545,7 +1545,7 @@ namespace Myshipping.Application
//陈冠宇提订舱编号不允许重复
if (!string.IsNullOrWhiteSpace(input.CUSTNO))
{
var et = await _rep.AsQueryable().Filter(null, true).AnyAsync(x => x.IsDeleted == false && x.CUSTNO == input.CUSTNO && x.TenantId == UserManager.TENANT_ID && x.ParentId == 0 && x.Id != input.Id);
var et = await _rep.AsQueryable().Filter(null, true).AnyAsync(x => x.IsDeleted == false && x.IsSplit == false && x.CUSTNO == input.CUSTNO && x.TenantId == UserManager.TENANT_ID && x.ParentId == 0 && x.Id != input.Id);
if (et)
{
throw Oops.Bah("当前订舱编号已存在,请勿重复录入!");

@ -861,7 +861,7 @@ namespace Myshipping.Application
/// <summary>
/// 是否为舱位拆票后生成的订舱
/// </summary>
public bool? IsSplit { get; set; }
public bool IsSplit { get; set; }
/// <summary>
/// 分单操作ID

@ -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<BookingSlotCompare> bookingSlotCompareRepository,
SqlSugarRepository<BookingOrderContact> bookingOrderContactRepository,
INamedServiceProvider<IBookingOrderService> namedBookingOrderServiceProvider,
IBookingValueAddedService bookingValueAddedService,
SqlSugarRepository<BookingOrder> repBookingOrder,
SqlSugarRepository<BookingLabelAllocation> 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>();
TaskBCInfoDto bcTargetDto = dto.DataObj.Adapt<TaskBCInfoDto>();
//执行差异重要提醒
//await MeasureDiffCautionTask(bcSrcDto, bcTargetDto, model.Id);
//提取箱信息
var ctnList = _repCtn.AsQueryable().Filter(null, true)
.Where(x => x.IsDeleted == false && x.TenantId.Value == UserManager.TENANT_ID
@ -1971,19 +1978,20 @@ namespace Myshipping.Application
var selectNum = generateModel.CtnList.Sum(x => x.CTNNUM);
var allNum = await _repCtn.AsQueryable().Where(x => x.SLOT_ID == generateModel.SlotId).SumAsync(x => x.CTNNUM);
bkModel.IsSplit = selectNum != allNum;
if (bkModel.IsSplit == true)
if (bkModel.IsSplit)
{
var sql = _repBookingOrder.AsQueryable().Where(" MBLNO like @mblno+'_' ", new { mblno = custNo }).ToSqlString();
var currentOrder = await _repBookingOrder.AsQueryable().Where(" MBLNO like @mblno+'_' ", new { mblno = custNo })
var sql = _repBookingOrder.AsQueryable().Where(" MBLNO like @mblno ", new { mblno = custNo + '_' }).OrderByDescending(x => x.Id).Select(x => x.MBLNO).ToSqlString();
var currentMblno = await _repBookingOrder.AsQueryable().Where(" MBLNO like @mblno ", new { mblno = custNo + '_' })
.OrderByDescending(x => x.Id)
.Select(x => x.MBLNO)
.FirstAsync();
if (currentOrder == null)
if (currentMblno == null)
{
bkModel.MBLNO = custNo + "A";
}
else
{
var lastLetter = currentOrder.MBLNO.Substring(currentOrder.MBLNO.Length - 1, 1)[0];
var lastLetter = currentMblno.Substring(currentMblno.Length - 1, 1)[0];
var newMblno = custNo + LetterIndexUtil.GetNextLetter(lastLetter);
bkModel.MBLNO = newMblno;
}
@ -2275,6 +2283,113 @@ namespace Myshipping.Application
return result;
}
#region 估算差异重要提醒
/// <summary>
/// 估算差异重要提醒
/// </summary>
/// <param name="bcSrcDto">原舱位详情</param>
/// <param name="bcTargetDto">新舱位详情</param>
/// <param name="slotId">舱位ID</param>
/// <returns></returns>
[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
}

@ -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<BookingSlotBaseApiSaveDto, TaskBCInfoDto>()
.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<TaskBCInfoReadDto, TaskBCInfoDto>()
.Map(dest => dest.CarrierId, src => src.CarrierId)

@ -150,5 +150,14 @@ namespace Myshipping.Application
/// <param name="reqBatchNo">请求批次号用来区分对应的哪个批次任务</param>
/// <returns></returns>
Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId, string reqBatchNo);
/// <summary>
/// 估算差异重要提醒
/// </summary>
/// <param name="bcSrcDto">原舱位详情</param>
/// <param name="bcTargetDto">新舱位详情</param>
/// <param name="slotId">舱位ID</param>
/// <returns></returns>
Task MeasureDiffCautionTask(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId);
}
}

@ -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
{
/// <summary>
/// WeekAt-计费周差异 PriceCalcDate-计费周差异
/// </summary>
public CautionNoticeTaskEnum cautionNoticeType { get; set; }
/// <summary>
/// 订舱ID
/// </summary>
public Nullable<long> bookingId { get; set; }
/// <summary>
/// 舱位ID
/// </summary>
public Nullable<long> bookingSlotId { get; set; }
/// <summary>
/// 任务ID
/// </summary>
public string taskPKId { get; set; }
/// <summary>
/// 创建日期
/// </summary>
public DateTime createTime { get; set; }
/// <summary>
/// 原值
/// </summary>
public string origVal { get; set; }
/// <summary>
/// 新值
/// </summary>
public string newVal { get; set; }
/// <summary>
/// 租户ID
/// </summary>
public long tenentId { get; set; }
/// <summary>
/// 用户ID
/// </summary>
public long userId { get; set; }
/// <summary>
/// 用户名称
/// </summary>
public string userName { get; set; }
}
}

@ -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
{
/// <summary>
/// WeekAt-计费周差异 PriceCalcDate-计费周差异
/// </summary>
public CautionNoticeTaskEnum CautionNoticeType { get; set; }
/// <summary>
/// 订舱ID
/// </summary>
public Nullable<long> BookingId { get; set; }
/// <summary>
/// 舱位ID
/// </summary>
public Nullable<long> BookingSlotId { get; set; }
/// <summary>
/// 任务ID
/// </summary>
public string TaskPKId { get; set; }
/// <summary>
/// 创建日期
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 原值
/// </summary>
public string OrigVal { get; set; }
/// <summary>
/// 新值
/// </summary>
public string NewVal { get; set; }
/// <summary>
/// 消息列表
/// </summary>
public List<TaskManageOrderCautionNoticeDetailInfo> NoticeList { get; set; }
}
/// <summary>
///
/// </summary>
public class TaskManageOrderCautionNoticeDetailInfo
{
/// <summary>
/// 重要提醒消息类型
/// </summary>
public CautionNoticeTypeEnum CautionNoticeType { get; set; }
/// <summary>
/// 用户ID
/// </summary>
public string UserId { get; set; }
/// <summary>
/// 用户手机号
/// </summary>
public string Mobile { get; set; }
}
}

@ -376,5 +376,10 @@ namespace Myshipping.Application
/// 批次号
/// </summary>
public string BatchNo { get; set; }
/// <summary>
/// 计费日期
/// </summary>
public Nullable<DateTime> PriceCalculationDate { get; set; }
}
}

Loading…
Cancel
Save