From 5988f745d44c6e2133f1c1f626f128cc318dd053 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 21 May 2024 14:01:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=87=8D=E8=A6=81=E6=8F=90=E9=86=92=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Enum/CautionNoticeTaskEnum.cs | 40 +++++ .../Event/CautionNoticeTaskSubscriber.cs | 162 ++++++++++++++++++ .../Service/BookingSlot/BookingSlotService.cs | 114 ++++++++++++ .../BookingSlot/Dto/BookingSlotMapper.cs | 6 +- .../BookingSlot/IBookingSlotService.cs | 9 + .../CautionNoitce/CautionNoticeTaskDto.cs | 61 +++++++ .../TaskManageOrderCautionNoticeInfo.cs | 72 ++++++++ .../TaskManagePlat/Dtos/TaskBCInfoDto.cs | 5 + 8 files changed, 467 insertions(+), 2 deletions(-) create mode 100644 Myshipping.Application/Enum/CautionNoticeTaskEnum.cs create mode 100644 Myshipping.Application/Event/CautionNoticeTaskSubscriber.cs create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/CautionNoitce/CautionNoticeTaskDto.cs create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/CautionNoitce/TaskManageOrderCautionNoticeInfo.cs 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; } } } From cf47327db865978f56430a486391a84e988274d9 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Tue, 21 May 2024 14:56:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=88=B1=E4=BD=8D=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Application/Entity/BookingOrder.cs | 2 +- .../Event/BookingSlotStockSubscriber.cs | 7 +++++++ .../Service/BookingOrder/BookingOrderService.cs | 2 +- .../Service/BookingOrder/Dto/BookingOrderDto.cs | 2 +- .../Service/BookingSlot/BookingSlotService.cs | 11 ++++++----- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Myshipping.Application/Entity/BookingOrder.cs b/Myshipping.Application/Entity/BookingOrder.cs index c172e6f6..4ad8c9ee 100644 --- a/Myshipping.Application/Entity/BookingOrder.cs +++ b/Myshipping.Application/Entity/BookingOrder.cs @@ -1056,7 +1056,7 @@ namespace Myshipping.Application.Entity /// /// 是否为舱位拆票后生成的订舱 /// - public bool? IsSplit { get; set; } + public bool IsSplit { get; set; } /// /// 分单操作ID diff --git a/Myshipping.Application/Event/BookingSlotStockSubscriber.cs b/Myshipping.Application/Event/BookingSlotStockSubscriber.cs index b6d85122..5c5b3384 100644 --- a/Myshipping.Application/Event/BookingSlotStockSubscriber.cs +++ b/Myshipping.Application/Event/BookingSlotStockSubscriber.cs @@ -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(); diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index ab89e6f8..ce016f51 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -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("当前订舱编号已存在,请勿重复录入!"); diff --git a/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs index 1b2c7fd1..7f3aede8 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/BookingOrderDto.cs @@ -861,7 +861,7 @@ namespace Myshipping.Application /// /// 是否为舱位拆票后生成的订舱 /// - public bool? IsSplit { get; set; } + public bool IsSplit { get; set; } /// /// 分单操作ID diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs index 9151578d..173e5d8d 100644 --- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs @@ -1971,19 +1971,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; }