舱位库存统计方法更新

optimize
zhangxiaofeng 10 months ago
parent 8b44436685
commit e20fc5cb55

@ -123,7 +123,13 @@ namespace Myshipping.Application
/// </summary>
[SugarColumn(ColumnName = "USE_NUM")]
public int USE_NUM{ get; set; }
/// <summary>
/// 取消舱位数
/// </summary>
[SugarColumn(ColumnName = "CANCEL_NUM")]
public int CANCEL_NUM { get; set; }
/// <summary>
/// 总箱数
/// </summary>

@ -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);

Loading…
Cancel
Save