diff --git a/Myshipping.Application/Entity/BookingSlot/BookingSlotStock.cs b/Myshipping.Application/Entity/BookingSlot/BookingSlotStock.cs index d3d24997..80667997 100644 --- a/Myshipping.Application/Entity/BookingSlot/BookingSlotStock.cs +++ b/Myshipping.Application/Entity/BookingSlot/BookingSlotStock.cs @@ -20,109 +20,120 @@ namespace Myshipping.Application /// 船名 /// [SugarColumn(ColumnName = "VESSEL")] - public string VESSEL{ get; set; } - + public string VESSEL { get; set; } + /// /// 航次号 /// [SugarColumn(ColumnName = "VOYNO")] - public string VOYNO{ get; set; } - + public string VOYNO { get; set; } + /// /// 合约号 /// [SugarColumn(ColumnName = "CONTRACT_NO")] - public string CONTRACT_NO{ get; set; } - + public string CONTRACT_NO { get; set; } + /// /// 订舱方式 CONTRACT_ORDER-合约订舱;SPOT_ORDER-SPOT订舱 /// [SugarColumn(ColumnName = "BOOKING_SLOT_TYPE")] - public string BOOKING_SLOT_TYPE{ get; set; } - + public string BOOKING_SLOT_TYPE { get; set; } + /// /// 订舱方式名称 CONTRACT_ORDER-合约订舱;SPOT_ORDER-SPOT订舱 /// [SugarColumn(ColumnName = "BOOKING_SLOT_TYPE_NAME")] - public string BOOKING_SLOT_TYPE_NAME{ get; set; } - + public string BOOKING_SLOT_TYPE_NAME { get; set; } + /// /// 订舱抬头 /// [SugarColumn(ColumnName = "BOOKING_PARTY")] - public string BOOKING_PARTY{ get; set; } - + public string BOOKING_PARTY { get; set; } + /// /// 船公司代号 /// [SugarColumn(ColumnName = "CARRIERID")] - public string CARRIERID{ get; set; } - + public string CARRIERID { get; set; } + /// /// 船公司 /// [SugarColumn(ColumnName = "CARRIER")] - public string CARRIER{ get; set; } - + public string CARRIER { get; set; } + /// /// 预计开船日期 /// [SugarColumn(ColumnName = "ETD")] - public DateTime? ETD{ get; set; } - + public DateTime? ETD { get; set; } + /// /// 预计到港日期 /// [SugarColumn(ColumnName = "ETA")] - public DateTime? ETA{ get; set; } - + public DateTime? ETA { get; set; } + + /// + /// 收货地 + /// + [SugarColumn(ColumnName = "PLACERECEIPT")] + public string PLACERECEIPT { get; set; } + /// + /// 交货地 + /// + [SugarColumn(ColumnName = "PLACEDELIVERY")] + public string PLACEDELIVERY { get; set; } + /// /// 航线代码(船公司) /// [SugarColumn(ColumnName = "LANECODE")] - public string LANECODE{ get; set; } - + public string LANECODE { get; set; } + /// /// 航线名称(船公司) /// [SugarColumn(ColumnName = "LANENAME")] - public string LANENAME{ get; set; } - + public string LANENAME { get; set; } + /// /// 所在周数 /// [SugarColumn(ColumnName = "WEEK_AT")] - public string WEEK_AT{ get; set; } - + public string WEEK_AT { get; set; } + /// /// 箱型箱量 /// [SugarColumn(ColumnName = "CTN_STAT")] - public string CTN_STAT{ get; set; } - + public string CTN_STAT { get; set; } + /// /// 使用箱型箱量 /// [SugarColumn(ColumnName = "USE_CTN_STAT")] - public string USE_CTN_STAT{ get; set; } - + public string USE_CTN_STAT { get; set; } + /// /// 剩余箱型箱量 /// [SugarColumn(ColumnName = "REMAIN_CTN_STAT")] - public string REMAIN_CTN_STAT{ get; set; } - + public string REMAIN_CTN_STAT { get; set; } + /// /// 总舱位数 /// [SugarColumn(ColumnName = "TOTAL_ORDERS")] - public int TOTAL_ORDERS{ get; set; } - + public int TOTAL_ORDERS { get; set; } + /// /// 使用舱位数 /// [SugarColumn(ColumnName = "USE_NUM")] - public int USE_NUM{ get; set; } + public int USE_NUM { get; set; } /// /// 取消舱位数 @@ -134,25 +145,25 @@ namespace Myshipping.Application /// 总箱数 /// [SugarColumn(ColumnName = "TOTAL_CTNS")] - public int TOTAL_CTNS{ get; set; } - + public int TOTAL_CTNS { get; set; } + /// /// 使用箱数 /// [SugarColumn(ColumnName = "USE_CTNS_NUM")] - public int USE_CTNS_NUM{ get; set; } - + public int USE_CTNS_NUM { get; set; } + /// /// 剩余箱数 /// [SugarColumn(ColumnName = "REMAIN_CTNS_NUM")] - public int REMAIN_CTNS_NUM{ get; set; } + public int REMAIN_CTNS_NUM { get; set; } /// /// 租户名称 /// [SugarColumn(ColumnName = "TenantName")] - public string TenantName{ get; set; } - + public string TenantName { get; set; } + } } \ No newline at end of file diff --git a/Myshipping.Application/Event/BookingSlotStockSubscriber.cs b/Myshipping.Application/Event/BookingSlotStockSubscriber.cs index 45febf4d..8653f8fc 100644 --- a/Myshipping.Application/Event/BookingSlotStockSubscriber.cs +++ b/Myshipping.Application/Event/BookingSlotStockSubscriber.cs @@ -58,7 +58,9 @@ namespace Myshipping.Application.Event && x.VOYNO == paraObj.VOYNO && x.CONTRACT_NO == paraObj.CONTRACT_NO && x.BOOKING_SLOT_TYPE == paraObj.BOOKING_SLOT_TYPE - && x.CARRIERID == paraObj.CARRIERID) + && x.CARRIERID == paraObj.CARRIERID + && x.PLACEDELIVERY == paraObj.PLACEDELIVERY + && x.PLACERECEIPT == paraObj.PLACERECEIPT) .OrderByDescending(x => x.UpdatedTime) .ToListAsync(); if (!baseList.Any()) @@ -73,7 +75,9 @@ namespace Myshipping.Application.Event && x.VOYNO == paraObj.VOYNO && x.CONTRACT_NO == paraObj.CONTRACT_NO && x.BOOKING_SLOT_TYPE == paraObj.BOOKING_SLOT_TYPE - && x.CARRIERID == paraObj.CARRIERID); + && x.CARRIERID == paraObj.CARRIERID + && x.PLACEDELIVERY == paraObj.PLACEDELIVERY + && x.PLACERECEIPT == paraObj.PLACERECEIPT); if (stockObj == null) { stockObj = new BookingSlotStock(); @@ -104,18 +108,38 @@ namespace Myshipping.Application.Event // 总箱数 stockObj.TOTAL_CTNS = ctnAllList.Sum(x => x.CTNNUM); + // 订舱引用表主键与订舱主表主键 var lstAllocKeyList = await _repAlloc.AsQueryable() .Filter(null, true) .Where(x => !x.IsDeleted && lstBaseId.Contains(x.BOOKING_SLOT_ID)) .Select(x => new { x.Id, x.BOOKING_SLOT_ID }) .ToListAsync(); - // 已使用舱位数 - stockObj.USE_NUM = lstAllocKeyList.DistinctBy(x => x.BOOKING_SLOT_ID).Count(); - var lstAllocIdList = lstAllocKeyList.Select(x => x.Id).ToList(); + // 如果舱位未被引用过,可以直接确定库存 + if (!lstAllocKeyList.Any()) + { + // 已使用舱位数 + stockObj.USE_NUM = 0; + // 已使用的箱型箱量 + stockObj.USE_CTN_STAT = ""; + // 已使用的箱数 + stockObj.USE_CTNS_NUM = 0; + + // 剩余的箱型箱量 + stockObj.REMAIN_CTN_STAT = stockObj.CTN_STAT; + // 剩余箱数 + stockObj.REMAIN_CTNS_NUM = stockObj.TOTAL_CTNS; + } + else + { + // 已使用舱位数 + stockObj.USE_NUM = lstAllocKeyList.DistinctBy(x => x.BOOKING_SLOT_ID).Count(); + + // 订舱引用表主键列表 + var lstAllocIdList = lstAllocKeyList.Select(x => x.Id).ToList(); - // 已使用的箱型箱量 - var userCtnList = await _repAllocCtn.AsQueryable() + // 已使用的箱型箱量 + var userCtnList = await _repAllocCtn.AsQueryable() .Filter(null, true) .Where(x => !x.IsDeleted && lstAllocIdList.Contains(x.SLOT_ALLOC_ID)) .GroupBy(x => x.CTNALL) @@ -124,33 +148,35 @@ namespace Myshipping.Application.Event x.CTNALL, CTNNUM = SqlFunc.AggregateSum(x.CTNNUM) }).ToListAsync(); - stockObj.USE_CTN_STAT = string.Join(' ', userCtnList.Select(c => c.CTNALL + "*" + c.CTNNUM)); + stockObj.USE_CTN_STAT = string.Join(' ', userCtnList.Select(c => c.CTNALL + "*" + c.CTNNUM)); - // 已使用的箱数 - stockObj.USE_CTNS_NUM = userCtnList.Sum(x => x.CTNNUM); + // 已使用的箱数 + stockObj.USE_CTNS_NUM = userCtnList.Sum(x => x.CTNNUM); - // 剩余的箱型箱量 - Dictionary remainCtnList = new(ctnAllList.Count); - foreach (var item in ctnAllList) - { - var useItem = userCtnList.FirstOrDefault(x => x.CTNALL == item.CTNALL); - if (useItem == null) - { - remainCtnList.Add(item.CTNALL, item.CTNNUM); - } - else + // 剩余的箱型箱量 + Dictionary remainCtnList = new(ctnAllList.Count); + foreach (var item in ctnAllList) { - int remainCtnNum = item.CTNNUM - useItem.CTNNUM; - if (remainCtnNum > 0) + var useItem = userCtnList.FirstOrDefault(x => x.CTNALL == item.CTNALL); + if (useItem == null) { - remainCtnList.Add(item.CTNALL, remainCtnNum); + remainCtnList.Add(item.CTNALL, item.CTNNUM); + } + else + { + int remainCtnNum = item.CTNNUM - useItem.CTNNUM; + if (remainCtnNum > 0) + { + remainCtnList.Add(item.CTNALL, remainCtnNum); + } } } + stockObj.REMAIN_CTN_STAT = string.Join(' ', remainCtnList.Select(x => x.Key + "*" + x.Value)); + + // 剩余箱数 + stockObj.REMAIN_CTNS_NUM = stockObj.TOTAL_CTNS - stockObj.USE_CTNS_NUM; } - stockObj.REMAIN_CTN_STAT = string.Join(' ', remainCtnList.Select(x => x.Key + "*" + x.Value)); - // 剩余箱数 - stockObj.REMAIN_CTNS_NUM = stockObj.TOTAL_CTNS - stockObj.USE_CTNS_NUM; await _repStock.UpdateAsync(stockObj); } @@ -186,5 +212,14 @@ namespace Myshipping.Application.Event /// 船公司代号 /// public string CARRIERID { get; set; } + + /// + /// 收货地 + /// + public string PLACERECEIPT { get; set; } + /// + /// 交货地 + /// + public string PLACEDELIVERY { get; set; } } } diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 065aab2b..b6a9dac7 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -140,7 +140,7 @@ namespace Myshipping.Application private readonly SqlSugarRepository _repBookingStatusSubscribe; private readonly SqlSugarRepository _repextendstate; - + private readonly IServiceWorkFlowManageService _serviceWorkFlowManageService; private readonly IDjyUserConfigService _djyUserConfigService; @@ -161,7 +161,7 @@ namespace Myshipping.Application const string CONST_ONE_SOFILE_CATE_CODE = "one_so_file_template"; const string PRINT_DATASOURCE_KEY = "booking_order"; - + public BookingOrderService(SqlSugarRepository rep, SqlSugarRepository repCtn, SqlSugarRepository ctndetailrep, SqlSugarRepository bookinglog, SqlSugarRepository bookinglogdetail, SqlSugarRepository bookingremark, @@ -11437,7 +11437,9 @@ namespace Myshipping.Application CARRIERID = item.CARRIERID, CONTRACT_NO = item.CONTRACT_NO, VESSEL = item.VESSEL, - VOYNO = item.VOYNO + VOYNO = item.VOYNO, + PLACERECEIPT = item.PLACERECEIPT, + PLACEDELIVERY = item.PLACEDELIVERY })); } } @@ -11888,7 +11890,7 @@ namespace Myshipping.Application #endregion - + } } diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs index df93743d..46e1243a 100644 --- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs @@ -169,7 +169,9 @@ namespace Myshipping.Application CARRIERID = model.CARRIERID, CONTRACT_NO = model.CONTRACT_NO, VESSEL = model.VESSEL, - VOYNO = model.VOYNO + VOYNO = model.VOYNO, + PLACERECEIPT = model.PLACERECEIPT, + PLACEDELIVERY = model.PLACEDELIVERY })); return await Detail(model.Id); @@ -491,7 +493,9 @@ namespace Myshipping.Application CARRIERID = model.CARRIERID, CONTRACT_NO = model.CONTRACT_NO, VESSEL = model.VESSEL, - VOYNO = model.VOYNO + VOYNO = model.VOYNO, + PLACERECEIPT = model.PLACERECEIPT, + PLACEDELIVERY = model.PLACEDELIVERY })); } else @@ -873,7 +877,9 @@ namespace Myshipping.Application CARRIERID = latestSlot.CARRIERID, CONTRACT_NO = latestSlot.CONTRACT_NO, VESSEL = latestSlot.VESSEL, - VOYNO = latestSlot.VOYNO + VOYNO = latestSlot.VOYNO, + PLACERECEIPT = latestSlot.PLACERECEIPT, + PLACEDELIVERY = latestSlot.PLACEDELIVERY })); } } diff --git a/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotStockPageInput.cs b/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotStockPageInput.cs index 1bc6eb2b..1220c927 100644 --- a/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotStockPageInput.cs +++ b/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotStockPageInput.cs @@ -165,6 +165,17 @@ namespace Myshipping.Application.Service.BookingSlot.Dto /// 剩余箱数 /// public int REMAIN_CTNS_NUM { get; set; } + + /// + /// 收货地 + /// + public string PLACERECEIPT { get; set; } + + /// + /// 交货地 + /// + public string PLACEDELIVERY { get; set; } + }