jianghaiqing 4 months ago
commit 3615efb9b2

@ -365,8 +365,10 @@ namespace Myshipping.Application
TenantId = model.TenantId
}));
var inputDto = new BookingSlotBaseApiDto {
DataObj = new BookingSlotBaseApiSaveDto {
var inputDto = new BookingSlotBaseApiDto
{
DataObj = new BookingSlotBaseApiSaveDto
{
PORTDISCHARGEID = model.PORTDISCHARGEID,
PORTDISCHARGE = model.PORTDISCHARGE,
PORTLOADID = model.PORTLOADID,
@ -1564,31 +1566,64 @@ namespace Myshipping.Application
})
.MergeTable();
ISugarQueryable<AvailableSlotDto> tragerQueryable;
if (pageInfo == null)
{
// 3. 将queryable1 左连接 queryable2使用【总的箱量】减去【已使用的箱量】得到【剩余的箱量】添加【剩余的箱量】> 0 的条件作为queryable3
tragerQueryable = queryable1.LeftJoin(queryable2, (q1, q2) => q1.id == q2.id && q1.ctnCode == q2.ctnCode)
.Select((q1, q2) => new AvailableSlotDto
{
Id = q1.id,
CtnCode = q1.ctnCode,
CtnAll = q1.numAll,
NumResidue = SqlFunc.IsNull(q1.numAll - q2.numUse, q1.numAll)
})
.MergeTable()
.Where(r => r.NumResidue > 0);
}
else
{
var queryable1Clone = queryable1.Clone();
// 3. 将queryable1 左连接 queryable2使用【总的箱量】减去【已使用的箱量】得到【剩余的箱量】添加【剩余的箱量】> 0 的条件并对Id进行去重作为queryable3
var queryable3 = queryable1.LeftJoin(queryable2, (q1, q2) => q1.id == q2.id && q1.ctnCode == q2.ctnCode)
.Select((q1, q2) => new
{
q1.id,
q1.ctnCode,
q1.numAll,
numResidue = SqlFunc.IsNull(q1.numAll - q2.numUse, q1.numAll)
})
.MergeTable()
.Where(r => r.numResidue > 0);
.Where(r => r.numResidue > 0)
.Select(r => r.id)
.Distinct();
// 4. 执行ToList(),得到可用的【舱位主键】、【箱型】、【箱量】列表
// 4. 执行queryable3得到【可用的舱位主键列表】
RefAsync<int> total = 0;
var canUselist = pageInfo == null
? await queryable3.ToListAsync()
: await queryable3.ToPageListAsync(pageInfo.PageNo, pageInfo.PageSize, total);
var canUseIdList = await queryable3.ToPageListAsync(pageInfo.PageNo, pageInfo.PageSize, total);
if (pageInfo != null)
{
pageInfo.Total = total;
}
// 5. 使用queryable1的副本queryable1Clone左连接queryable2添加【可用的舱位主键列表】作为条件得到queryable4
tragerQueryable = queryable1Clone.LeftJoin(queryable2, (q1, q2) => q1.id == q2.id && q1.ctnCode == q2.ctnCode)
.Select((q1, q2) => new AvailableSlotDto()
{
Id = q1.id,
CtnCode = q1.ctnCode,
CtnAll = q1.numAll,
NumResidue = SqlFunc.IsNull(q1.numAll - q2.numUse, q1.numAll)
})
.MergeTable()
.Where(r => canUseIdList.Contains(r.Id));
}
List<AvailableSlotDto> canUselist = await tragerQueryable.ToListAsync();
// 查询舱位列表
var baseIdList = canUselist.Select(c => c.id);
var baseIdList = canUselist.Select(c => c.Id);
List<BookingSlotBase> baseList = await _repBase.AsQueryable()
.Where(u => baseIdList.Contains(u.Id))
.ToListAsync();
@ -1599,15 +1634,15 @@ namespace Myshipping.Application
List<BookingSlotBaseWithCtnDto> result = baseList.Adapt<List<BookingSlotBaseWithCtnDto>>();
foreach (var item in result)
{
var ctnList = canUselist.Where(c => c.id == item.Id).ToList();
var ctnList = canUselist.Where(c => c.Id == item.Id).ToList();
if (ctnList?.Any() == true)
{
item.CtnList = ctnList.Select(c => new BookingSlotCtnDto()
{
CTNCODE = c.ctnCode,
CTNNUM = c.numResidue,
TOTALNUM = c.numAll,
CTNALL = ctnCodeCache.FirstOrDefault(e => e.Code == c.ctnCode)?.Name ?? throw new Exception($"舱位信息中存在未收录的箱型:{c.ctnCode},需要在箱型字典中补充"),
CTNCODE = c.CtnCode,
CTNNUM = c.NumResidue,
TOTALNUM = c.CtnAll,
CTNALL = ctnCodeCache.FirstOrDefault(e => e.Code == c.CtnCode)?.Name ?? throw new Exception($"舱位信息中存在未收录的箱型:{c.CtnCode},需要在箱型字典中补充"),
}).ToList();
}
}
@ -3771,7 +3806,8 @@ namespace Myshipping.Application
bool isNeedWholeShip = false;
CautionNoticeTaskWholeShipDto cautionNoticeTaskWholeShipDto = new CautionNoticeTaskWholeShipDto {
CautionNoticeTaskWholeShipDto cautionNoticeTaskWholeShipDto = new CautionNoticeTaskWholeShipDto
{
Carrier = slotInfo.CARRIERID,
MBLNo = slotInfo.SLOT_BOOKING_NO
};

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.Service.BookingSlot.Dto
{
public class AvailableSlotDto
{
public long Id { get; set; }
public string CtnCode { get; set; }
public int CtnAll { get; set; }
public int NumResidue { get; set; }
}
}
Loading…
Cancel
Save