From e20fc5cb55cdf94bf6e08f568feb3bf5825d8bba Mon Sep 17 00:00:00 2001 From: zhangxiaofeng Date: Tue, 30 Jan 2024 11:41:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=88=B1=E4=BD=8D=E5=BA=93=E5=AD=98=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=96=B9=E6=B3=95=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/BookingSlot/BookingSlotStock.cs | 8 ++++++- .../Event/BookingSlotStockSubscriber.cs | 23 +++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Myshipping.Application/Entity/BookingSlot/BookingSlotStock.cs b/Myshipping.Application/Entity/BookingSlot/BookingSlotStock.cs index 2054b26d..d3d24997 100644 --- a/Myshipping.Application/Entity/BookingSlot/BookingSlotStock.cs +++ b/Myshipping.Application/Entity/BookingSlot/BookingSlotStock.cs @@ -123,7 +123,13 @@ namespace Myshipping.Application /// [SugarColumn(ColumnName = "USE_NUM")] public int USE_NUM{ get; set; } - + + /// + /// 取消舱位数 + /// + [SugarColumn(ColumnName = "CANCEL_NUM")] + public int CANCEL_NUM { get; set; } + /// /// 总箱数 /// diff --git a/Myshipping.Application/Event/BookingSlotStockSubscriber.cs b/Myshipping.Application/Event/BookingSlotStockSubscriber.cs index e779a720..a89748d7 100644 --- a/Myshipping.Application/Event/BookingSlotStockSubscriber.cs +++ b/Myshipping.Application/Event/BookingSlotStockSubscriber.cs @@ -83,12 +83,27 @@ namespace Myshipping.Application.Event stockObj.TOTAL_ORDERS = baseList.Count; //总舱位数 var lstBaseId = baseList.Select(x => x.Id).ToList(); - stockObj.TOTAL_CTNS = _repCtn.Where(x => lstBaseId.Contains(x.SLOT_ID)).Count(); //总箱数 + stockObj.TOTAL_CTNS = _repCtn.AsQueryable() + .Filter(null, true) + .Where(x => !x.IsDeleted && lstBaseId.Contains(x.SLOT_ID)) + .Sum(x => x.CTNNUM); //总箱数 - var lstAllocIdList = await _repAlloc.Where(x => lstBaseId.Contains(x.BOOKING_SLOT_ID)).Select(x => x.Id).ToListAsync(); - stockObj.USE_NUM = lstAllocIdList.Count; //使用舱位数 + 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_CTNS_NUM = _repAllocCtn.Where(x => lstAllocIdList.Contains(x.SLOT_ALLOC_ID)).Count(); //使用箱数 + stockObj.USE_NUM = lstAllocKeyList.DistinctBy(x => x.BOOKING_SLOT_ID).Count(); //使用舱位数 + + var lstAllocIdList = lstAllocKeyList.Select(x => x.Id).ToList(); + + stockObj.USE_CTNS_NUM = _repAllocCtn.AsQueryable() + .Filter(null, true) + .Where(x => !x.IsDeleted && lstAllocIdList.Contains(x.SLOT_ALLOC_ID)) + .Sum(x => x.CTNNUM); //使用箱数 + + stockObj.REMAIN_CTNS_NUM = stockObj.TOTAL_CTNS - stockObj.USE_CTNS_NUM; //剩余箱数 await _repStock.UpdateAsync(stockObj);