|
|
|
@ -1849,8 +1849,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input">可选:舱位查询条件</param>
|
|
|
|
|
/// <param name="pageInfo">可选:分页信息</param>
|
|
|
|
|
public async Task<SqlSugarPagedList<BookingSlotBaseWithCtnDto>> GetAvailableSlots([FromQuery] BookingSlotBaseDto input,
|
|
|
|
|
[FromQuery] PageWithTotal pageInfo)
|
|
|
|
|
public async Task<DataResult<SqlSugarPagedList<BookingSlotBaseWithCtnDto>>> GetAvailableSlots(BookingSlotBaseDto input,PageWithTotal pageInfo)
|
|
|
|
|
{
|
|
|
|
|
var result = await GetAvailableSlots(input, null, pageInfo);
|
|
|
|
|
|
|
|
|
@ -1861,7 +1860,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
TotalCount = pageInfo.Total,
|
|
|
|
|
Items = result,
|
|
|
|
|
};
|
|
|
|
|
return pageResult;
|
|
|
|
|
return DataResult<SqlSugarPagedList<BookingSlotBaseWithCtnDto>>.Success(pageResult);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@ -1873,7 +1872,6 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
/// <param name="slotIdListInput">筛选条件2:舱位主键列表</param>
|
|
|
|
|
/// <param name="pageInfo">筛选条件3:分页</param>
|
|
|
|
|
/// <returns>可用的舱位列表(含可用的箱子列表)</returns>
|
|
|
|
|
[NonAction]
|
|
|
|
|
public async Task<List<BookingSlotBaseWithCtnDto>> GetAvailableSlots(BookingSlotBaseDto slotInput = null,
|
|
|
|
|
List<long> slotIdListInput = null,
|
|
|
|
|
PageWithTotal pageInfo = null)
|
|
|
|
@ -3762,6 +3760,86 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
return DataResult.Successed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotDeleteSucc)));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询指定舱位可用的箱子列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="slotId">舱位主键</param>
|
|
|
|
|
/// <returns>可用的箱子列表</returns>
|
|
|
|
|
public async Task<DataResult<List<BookingSlotCtnDto>>> GetAvailableCtnsBySlot(long slotId)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
if (await tenantDb.Queryable<BookingSlotBase>().AnyAsync(x => x.Id == slotId && x.IsCancellation == false) == false)
|
|
|
|
|
{
|
|
|
|
|
//获取舱位失败,舱位不存在或已作废
|
|
|
|
|
throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotCreateRecordDeletedOrNoExists)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 1. 【舱位基础表】与【箱子表】做关联,并根据【舱位主键】、【箱型】做分组,统计出【总的箱量】,作为queryable1
|
|
|
|
|
var queryable1 = tenantDb.Queryable<BookingSlotBase, BookingSlotCtn>((bas, ctn) => bas.Id == ctn.SlotId)
|
|
|
|
|
.Where(bas => bas.IsCancellation == false && bas.Id == slotId)
|
|
|
|
|
.GroupBy((bas, ctn) => new
|
|
|
|
|
{
|
|
|
|
|
bas.Id,
|
|
|
|
|
ctn.CtnCode
|
|
|
|
|
})
|
|
|
|
|
.Select((bas, ctn) => new
|
|
|
|
|
{
|
|
|
|
|
id = bas.Id,
|
|
|
|
|
ctnCode = ctn.CtnCode,
|
|
|
|
|
numAll = SqlFunc.AggregateSum(ctn.CtnNum)
|
|
|
|
|
})
|
|
|
|
|
.MergeTable();
|
|
|
|
|
|
|
|
|
|
// 2. 【已引入舱位表】与【已使用的箱子表】做关联,并根据【舱位主键】、【箱型】做分组,统计出【已使用的箱量】,作为queryable2
|
|
|
|
|
var queryable2 = tenantDb.Queryable<BookingSlotAllocation, BookingSlotAllocationCtn>((alc, ctn) => alc.Id == ctn.SlotAllocId)
|
|
|
|
|
.Where((alc, ctn) => alc.BookingSlotId == slotId)
|
|
|
|
|
.GroupBy((alc, ctn) => new
|
|
|
|
|
{
|
|
|
|
|
alc.BookingSlotId,
|
|
|
|
|
ctn.CtnCode
|
|
|
|
|
})
|
|
|
|
|
.Select((alc, ctn) => new
|
|
|
|
|
{
|
|
|
|
|
id = alc.BookingSlotId,
|
|
|
|
|
ctnCode = ctn.CtnCode,
|
|
|
|
|
numUse = SqlFunc.AggregateSum(ctn.CtnNum)
|
|
|
|
|
})
|
|
|
|
|
.MergeTable();
|
|
|
|
|
|
|
|
|
|
// 3. 将queryable1 左连接 queryable2,使用【总的箱量】减去【已使用的箱量】,得到【剩余的箱量】,添加【剩余的箱量】> 0 的条件,作为queryable3
|
|
|
|
|
var queryable3 = queryable1.LeftJoin(queryable2, (q1, q2) => q1.id == q2.id && q1.ctnCode == q2.ctnCode)
|
|
|
|
|
.Select((q1, q2) => new
|
|
|
|
|
{
|
|
|
|
|
q1.id,
|
|
|
|
|
q1.ctnCode,
|
|
|
|
|
numResidue = SqlFunc.IsNull(q1.numAll - q2.numUse, q1.numAll)
|
|
|
|
|
})
|
|
|
|
|
.MergeTable()
|
|
|
|
|
.Where(r => r.numResidue > 0);
|
|
|
|
|
|
|
|
|
|
// 4. 执行ToList(),得到可用的【舱位主键】、【箱型】、【箱量】列表
|
|
|
|
|
var canUselist = await queryable3.ToListAsync();
|
|
|
|
|
|
|
|
|
|
List<CodeCtnRes> ctnCodeCache = new List<CodeCtnRes>();
|
|
|
|
|
|
|
|
|
|
var allCtnCodeList = await _codeCtnService.GetAllList();
|
|
|
|
|
|
|
|
|
|
if (allCtnCodeList.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
ctnCodeCache = allCtnCodeList.Data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<BookingSlotCtnDto> result = canUselist.Select(c => new BookingSlotCtnDto()
|
|
|
|
|
{
|
|
|
|
|
CtnCode = c.ctnCode,
|
|
|
|
|
CtnNum = c.numResidue,
|
|
|
|
|
CtnAll = ctnCodeCache.FirstOrDefault(e => $"{e.CtnSize}{e.CtnType}" == c.ctnCode)?.CtnName ?? throw new Exception($"舱位信息中存在未收录的箱型:{c.ctnCode},需要在箱型字典中补充"),
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
return DataResult<List<BookingSlotCtnDto>>.Success(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class LetterIndexUtil
|
|
|
|
|