jianghaiqing 4 months ago
commit 3615efb9b2

@ -365,8 +365,10 @@ namespace Myshipping.Application
TenantId = model.TenantId TenantId = model.TenantId
})); }));
var inputDto = new BookingSlotBaseApiDto { var inputDto = new BookingSlotBaseApiDto
DataObj = new BookingSlotBaseApiSaveDto { {
DataObj = new BookingSlotBaseApiSaveDto
{
PORTDISCHARGEID = model.PORTDISCHARGEID, PORTDISCHARGEID = model.PORTDISCHARGEID,
PORTDISCHARGE = model.PORTDISCHARGE, PORTDISCHARGE = model.PORTDISCHARGE,
PORTLOADID = model.PORTLOADID, PORTLOADID = model.PORTLOADID,
@ -816,9 +818,9 @@ namespace Myshipping.Application
if (string.IsNullOrWhiteSpace(dto.DataObj.CTN_STAT)) if (string.IsNullOrWhiteSpace(dto.DataObj.CTN_STAT))
{ {
if(dto.DataObj.CtnList != null && dto.DataObj.CtnList.Count > 0) if (dto.DataObj.CtnList != null && dto.DataObj.CtnList.Count > 0)
{ {
dto.DataObj.CTN_STAT = string.Join(",",dto.DataObj.CtnList.GroupBy(a => a.CTNALL).Select(a => dto.DataObj.CTN_STAT = string.Join(",", dto.DataObj.CtnList.GroupBy(a => a.CTNALL).Select(a =>
$"{a.Key}*{a.Select(b => b.CTNNUM).Sum()}").ToArray()); $"{a.Key}*{a.Select(b => b.CTNNUM).Sum()}").ToArray());
} }
@ -1047,7 +1049,7 @@ namespace Myshipping.Application
await PushCompareBCInfo(bcSrcDto, bcTargetDto, id, dto.BatchNo); await PushCompareBCInfo(bcSrcDto, bcTargetDto, id, dto.BatchNo);
//触发标签自动绑定 //触发标签自动绑定
await GenerateSlotLabel(dto,id); await GenerateSlotLabel(dto, id);
} }
else if (dto.OpType == "del") else if (dto.OpType == "del")
{ {
@ -1564,31 +1566,64 @@ namespace Myshipping.Application
}) })
.MergeTable(); .MergeTable();
// 3. 将queryable1 左连接 queryable2使用【总的箱量】减去【已使用的箱量】得到【剩余的箱量】添加【剩余的箱量】> 0 的条件作为queryable3 ISugarQueryable<AvailableSlotDto> tragerQueryable;
var queryable3 = queryable1.LeftJoin(queryable2, (q1, q2) => q1.id == q2.id && q1.ctnCode == q2.ctnCode)
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 .Select((q1, q2) => new
{ {
q1.id, q1.id,
q1.ctnCode,
q1.numAll,
numResidue = SqlFunc.IsNull(q1.numAll - q2.numUse, q1.numAll) numResidue = SqlFunc.IsNull(q1.numAll - q2.numUse, q1.numAll)
}) })
.MergeTable() .MergeTable()
.Where(r => r.numResidue > 0); .Where(r => r.numResidue > 0)
.Select(r => r.id)
.Distinct();
// 4. 执行ToList(),得到可用的【舱位主键】、【箱型】、【箱量】列表 // 4. 执行queryable3得到【可用的舱位主键列表】
RefAsync<int> total = 0; RefAsync<int> total = 0;
var canUselist = pageInfo == null var canUseIdList = await queryable3.ToPageListAsync(pageInfo.PageNo, pageInfo.PageSize, total);
? await queryable3.ToListAsync()
: 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));
if (pageInfo != null)
{
pageInfo.Total = total;
} }
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() List<BookingSlotBase> baseList = await _repBase.AsQueryable()
.Where(u => baseIdList.Contains(u.Id)) .Where(u => baseIdList.Contains(u.Id))
.ToListAsync(); .ToListAsync();
@ -1599,15 +1634,15 @@ namespace Myshipping.Application
List<BookingSlotBaseWithCtnDto> result = baseList.Adapt<List<BookingSlotBaseWithCtnDto>>(); List<BookingSlotBaseWithCtnDto> result = baseList.Adapt<List<BookingSlotBaseWithCtnDto>>();
foreach (var item in result) 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) if (ctnList?.Any() == true)
{ {
item.CtnList = ctnList.Select(c => new BookingSlotCtnDto() item.CtnList = ctnList.Select(c => new BookingSlotCtnDto()
{ {
CTNCODE = c.ctnCode, CTNCODE = c.CtnCode,
CTNNUM = c.numResidue, CTNNUM = c.NumResidue,
TOTALNUM = c.numAll, TOTALNUM = c.CtnAll,
CTNALL = ctnCodeCache.FirstOrDefault(e => e.Code == c.ctnCode)?.Name ?? throw new Exception($"舱位信息中存在未收录的箱型:{c.ctnCode},需要在箱型字典中补充"), CTNALL = ctnCodeCache.FirstOrDefault(e => e.Code == c.CtnCode)?.Name ?? throw new Exception($"舱位信息中存在未收录的箱型:{c.CtnCode},需要在箱型字典中补充"),
}).ToList(); }).ToList();
} }
} }
@ -1809,7 +1844,7 @@ namespace Myshipping.Application
newSlotAllocation.SELLING_PRICE = generateModel.SELLING_PRICE; newSlotAllocation.SELLING_PRICE = generateModel.SELLING_PRICE;
newSlotAllocation.SPLIT_OR_MERGE_FLAG = generateModel.SplitOrMerge; newSlotAllocation.SPLIT_OR_MERGE_FLAG = generateModel.SplitOrMerge;
if(generateModel.SplitOrMerge == 1 || generateModel.SplitOrMerge == 2) if (generateModel.SplitOrMerge == 1 || generateModel.SplitOrMerge == 2)
{ {
newSlotAllocation.ALLO_BILL_NO = generateModel.NewMBlNo; newSlotAllocation.ALLO_BILL_NO = generateModel.NewMBlNo;
} }
@ -3116,7 +3151,7 @@ namespace Myshipping.Application
/// <returns>返回订舱ID</returns> /// <returns>返回订舱ID</returns>
private async Task<long> GenerateBookingOrder(BookingSlotBase bookingSlotBase, private async Task<long> GenerateBookingOrder(BookingSlotBase bookingSlotBase,
List<BookingFile> bookingSlotFileList, List<BookingFile> bookingSlotFileList,
BookingGenerateDto generateModel,string masterBookingSlotNo) BookingGenerateDto generateModel, string masterBookingSlotNo)
{ {
long id = 0; long id = 0;
@ -3188,7 +3223,7 @@ namespace Myshipping.Application
//bkModel.IsSplit = selectNum != allNum; //bkModel.IsSplit = selectNum != allNum;
bkModel.SPLIT_OR_MERGE_FLAG = selectNum != allNum ? 1 : 0; bkModel.SPLIT_OR_MERGE_FLAG = selectNum != allNum ? 1 : 0;
if(!string.IsNullOrWhiteSpace(masterBookingSlotNo)) if (!string.IsNullOrWhiteSpace(masterBookingSlotNo))
bkModel.SPLIT_OR_MERGE_FLAG = 2; bkModel.SPLIT_OR_MERGE_FLAG = 2;
//拆票逻辑 //拆票逻辑
@ -3526,7 +3561,7 @@ namespace Myshipping.Application
var bkNoList = list.Select(x => x.BOOKING_ID).ToList(); var bkNoList = list.Select(x => x.BOOKING_ID).ToList();
var bkList = _repBookingOrder.AsQueryable().Filter(null, true).Where(a => bkNoList.Contains(a.Id) && a.TenantId == tenantId && a.IsDeleted == false).ToList(); var bkList = _repBookingOrder.AsQueryable().Filter(null, true).Where(a => bkNoList.Contains(a.Id) && a.TenantId == tenantId && a.IsDeleted == false).ToList();
if(bkList.Count > 0) if (bkList.Count > 0)
{ {
dto.BookingOrderList = bkList.Select(x => x.Id).ToList(); dto.BookingOrderList = bkList.Select(x => x.Id).ToList();
} }
@ -3623,7 +3658,7 @@ namespace Myshipping.Application
var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false var bookingInfo = _repBookingOrder.AsQueryable().Filter(null, true).First(x => x.Id == ca.Alloc.BOOKING_ID && x.IsDeleted == false
&& x.TenantId == UserManager.TENANT_ID); && x.TenantId == UserManager.TENANT_ID);
CreateTask(CautionNoticeTaskEnum.WeekAt, bcSrcDto, userList, bookingInfo, slotInfo, srcWeek, targetWeek, $"提单号:{bcSrcDto.MBLNo} \r\n计费周变更了 \r\n原{srcWeek} \r\n新{targetWeek}",true); CreateTask(CautionNoticeTaskEnum.WeekAt, bcSrcDto, userList, bookingInfo, slotInfo, srcWeek, targetWeek, $"提单号:{bcSrcDto.MBLNo} \r\n计费周变更了 \r\n原{srcWeek} \r\n新{targetWeek}", true);
}); });
} }
else if (slotInfo != null) else if (slotInfo != null)
@ -3771,7 +3806,8 @@ namespace Myshipping.Application
bool isNeedWholeShip = false; bool isNeedWholeShip = false;
CautionNoticeTaskWholeShipDto cautionNoticeTaskWholeShipDto = new CautionNoticeTaskWholeShipDto { CautionNoticeTaskWholeShipDto cautionNoticeTaskWholeShipDto = new CautionNoticeTaskWholeShipDto
{
Carrier = slotInfo.CARRIERID, Carrier = slotInfo.CARRIERID,
MBLNo = slotInfo.SLOT_BOOKING_NO MBLNo = slotInfo.SLOT_BOOKING_NO
}; };
@ -3865,7 +3901,7 @@ namespace Myshipping.Application
} }
else else
{ {
if(cautionNoticeTaskWholeShipDto.IsVesselChange) if (cautionNoticeTaskWholeShipDto.IsVesselChange)
{ {
if (bookingSlotAllocList.Count > 0) if (bookingSlotAllocList.Count > 0)
{ {
@ -4046,7 +4082,7 @@ namespace Myshipping.Application
/// <param name="targetVal">变更值</param> /// <param name="targetVal">变更值</param>
/// <param name="notifyContent">提示信息</param> /// <param name="notifyContent">提示信息</param>
private void CreateTask(CautionNoticeTaskEnum cautionNoticeType, TaskBCInfoDto bcSrcDto, List<SysUser> userList, BookingOrder bookingInfo, private void CreateTask(CautionNoticeTaskEnum cautionNoticeType, TaskBCInfoDto bcSrcDto, List<SysUser> userList, BookingOrder bookingInfo,
BookingSlotBase bookingSlotInfo, string srcVal, string targetVal, string notifyContent,bool isAutoSendNotice) BookingSlotBase bookingSlotInfo, string srcVal, string targetVal, string notifyContent, bool isAutoSendNotice)
{ {
List<long> userIdList = new List<long>(); List<long> userIdList = new List<long>();
@ -4149,15 +4185,15 @@ namespace Myshipping.Application
try try
{ {
var model =_repBase.AsQueryable().Filter(null, true) var model = _repBase.AsQueryable().Filter(null, true)
.First(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID && x.SLOT_BOOKING_NO == slotBookingNo && x.CARRIERID == CarrierId); .First(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID && x.SLOT_BOOKING_NO == slotBookingNo && x.CARRIERID == CarrierId);
if(model == null) if (model == null)
throw Oops.Bah("舱位信息不存在"); throw Oops.Bah("舱位信息不存在");
id = model.Id; id = model.Id;
} }
catch(Exception ex) catch (Exception ex)
{ {
_logger.LogInformation($"订舱编号检索舱位信息失败,原因:{ex.Message}"); _logger.LogInformation($"订舱编号检索舱位信息失败,原因:{ex.Message}");
} }
@ -4377,7 +4413,7 @@ namespace Myshipping.Application
} }
} }
List<Tuple<string, long, string >> rltList = new List<Tuple<string, long,string>>(); List<Tuple<string, long, string>> rltList = new List<Tuple<string, long, string>>();
list.ForEach(m => list.ForEach(m =>
{ {
@ -4426,7 +4462,7 @@ namespace Myshipping.Application
/// <param name="dto">舱位详情</param> /// <param name="dto">舱位详情</param>
/// <param name="id">舱位ID</param> /// <param name="id">舱位ID</param>
/// <returns></returns> /// <returns></returns>
private async Task GenerateSlotLabel(BookingSlotBaseApiDto dto,long id) private async Task GenerateSlotLabel(BookingSlotBaseApiDto dto, long id)
{ {
try try
{ {
@ -4440,7 +4476,7 @@ namespace Myshipping.Application
List<BookingLabelBaseDto> ruleList = new List<BookingLabelBaseDto>(); List<BookingLabelBaseDto> ruleList = new List<BookingLabelBaseDto>();
if(labelList.Count > 0) if (labelList.Count > 0)
{ {
for (int i = 0; i < labelList.Count; i++) for (int i = 0; i < labelList.Count; i++)
{ {
@ -4458,11 +4494,11 @@ namespace Myshipping.Application
{ {
var operEnum = (LabelRegexOperEnum)System.Enum.Parse(typeof(LabelRegexOperEnum), regList[j].oper); var operEnum = (LabelRegexOperEnum)System.Enum.Parse(typeof(LabelRegexOperEnum), regList[j].oper);
if (regList[j].name.Equals("PORTLOADID",StringComparison.OrdinalIgnoreCase)) if (regList[j].name.Equals("PORTLOADID", StringComparison.OrdinalIgnoreCase))
{ {
isSucc = CheckLabel("PORTLOADID", dto.DataObj.PORTLOADID, regList[j].val, regList[j].master, operEnum); isSucc = CheckLabel("PORTLOADID", dto.DataObj.PORTLOADID, regList[j].val, regList[j].master, operEnum);
if(isSucc) if (isSucc)
{ {
ruleList.Add(labelList[i]); ruleList.Add(labelList[i]);
break; break;
@ -4557,7 +4593,7 @@ namespace Myshipping.Application
} }
} }
if(isSucc) if (isSucc)
{ {
_logger.LogInformation($"标签对应到有效规则,{labelList[i].Name}"); _logger.LogInformation($"标签对应到有效规则,{labelList[i].Name}");
} }
@ -4601,7 +4637,7 @@ namespace Myshipping.Application
} }
#endregion #endregion
private bool CheckLabel(string name,string val,string checkVal, bool isMaster, LabelRegexOperEnum operEnum) private bool CheckLabel(string name, string val, string checkVal, bool isMaster, LabelRegexOperEnum operEnum)
{ {
if (operEnum == LabelRegexOperEnum.equal) if (operEnum == LabelRegexOperEnum.equal)
{ {
@ -4619,7 +4655,7 @@ namespace Myshipping.Application
} }
else if (operEnum == LabelRegexOperEnum.like) else if (operEnum == LabelRegexOperEnum.like)
{ {
if (!string.IsNullOrWhiteSpace(val) && val.Contains(checkVal,StringComparison.OrdinalIgnoreCase)) if (!string.IsNullOrWhiteSpace(val) && val.Contains(checkVal, StringComparison.OrdinalIgnoreCase))
{ {
return true; return true;
} }

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