添加舱位取消配套逻辑

master
zhangxiaofeng 8 months ago
parent fe9ad59461
commit ce833c625a

@ -351,7 +351,6 @@ namespace Myshipping.Application
/// </summary> /// </summary>
[SugarColumn(ColumnName = "CANCELLATION_DATE")] [SugarColumn(ColumnName = "CANCELLATION_DATE")]
[Description("Cancellation时间")] [Description("Cancellation时间")]
public string CANCELLATION_DATE { get; set; } public DateTime? CANCELLATION_DATE { get; set; }
} }
} }

@ -54,6 +54,7 @@ namespace Myshipping.Application.Event
var baseList = await _repBase.AsQueryable().Filter(null, true) var baseList = await _repBase.AsQueryable().Filter(null, true)
.Where(x => !x.IsDeleted .Where(x => !x.IsDeleted
&& !x.IS_CANCELLATION
&& x.VESSEL == paraObj.VESSEL && x.VESSEL == paraObj.VESSEL
&& x.VOYNO == paraObj.VOYNO && x.VOYNO == paraObj.VOYNO
&& x.CONTRACT_NO == paraObj.CONTRACT_NO && x.CONTRACT_NO == paraObj.CONTRACT_NO

@ -264,7 +264,7 @@ namespace Myshipping.Application
result.msg = "成功"; result.msg = "成功";
result.ext = id; result.ext = id;
} }
catch(Exception ex) catch (Exception ex)
{ {
result.succ = false; result.succ = false;
result.msg = $"失败,原因:{ex.Message}"; result.msg = $"失败,原因:{ex.Message}";
@ -297,7 +297,7 @@ namespace Myshipping.Application
|| t.EnName.Equals(dto.DataObj.CARRIERID, StringComparison.OrdinalIgnoreCase) || t.EnName.Equals(dto.DataObj.CARRIERID, StringComparison.OrdinalIgnoreCase)
|| t.CnName.Equals(dto.DataObj.CARRIERID, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); || t.CnName.Equals(dto.DataObj.CARRIERID, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if(carrierInfo != null) if (carrierInfo != null)
{ {
dto.DataObj.CARRIER = carrierInfo.CnName?.Trim(); dto.DataObj.CARRIER = carrierInfo.CnName?.Trim();
} }
@ -311,7 +311,7 @@ namespace Myshipping.Application
dto.DataObj.CtnList.ForEach(t => dto.DataObj.CtnList.ForEach(t =>
{ {
if(!string.IsNullOrWhiteSpace(t.CTNALL) && string.IsNullOrWhiteSpace(t.CTNCODE)) if (!string.IsNullOrWhiteSpace(t.CTNALL) && string.IsNullOrWhiteSpace(t.CTNCODE))
{ {
var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.Name) && var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.Name) &&
a.Name.Equals(t.CTNALL, StringComparison.OrdinalIgnoreCase)); a.Name.Equals(t.CTNALL, StringComparison.OrdinalIgnoreCase));
@ -399,13 +399,17 @@ namespace Myshipping.Application
.Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID .Where(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID
&& x.SLOT_ID == model.Id).ToList(); && x.SLOT_ID == model.Id).ToList();
if(ctnList != null) if (ctnList != null)
{ {
bcSrcDto.CtnList = ctnList.GroupBy(x => x.CTNALL) bcSrcDto.CtnList = ctnList.GroupBy(x => x.CTNALL)
.Select(x => .Select(x =>
{ {
return new TaskBCCTNInfoDto { CtnALL = x.Key, CTNNUM = x.ToList() return new TaskBCCTNInfoDto
.Sum(a => a.CTNNUM) }; {
CtnALL = x.Key,
CTNNUM = x.ToList()
.Sum(a => a.CTNNUM)
};
}).ToList(); }).ToList();
} }
@ -473,7 +477,7 @@ namespace Myshipping.Application
} }
//一般更新数据指的是Booking Amendment,需要与舱位进行数据比对 //一般更新数据指的是Booking Amendment,需要与舱位进行数据比对
await PushCompareBCInfo(bcSrcDto, bcTargetDto,id, dto.BatchNo); await PushCompareBCInfo(bcSrcDto, bcTargetDto, id, dto.BatchNo);
} }
else if (dto.OpType == "del") else if (dto.OpType == "del")
{ {
@ -500,7 +504,40 @@ namespace Myshipping.Application
} }
else if (dto.OpType == "cancellation") else if (dto.OpType == "cancellation")
{ {
// 更新标志
var slotNO = dto.DataObj.SLOT_BOOKING_NO;
model = await _repBase.AsQueryable().Filter(null, true).FirstAsync(x => x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID && x.SLOT_BOOKING_NO == slotNO);
if (model == null)
{
throw Oops.Bah($"未找到订舱编号为 {slotNO} 的数据");
}
id = model.Id;
model.IS_CANCELLATION = true;
model.CANCELLATION_DATE = DateTime.Now;
await _repBase.UpdateAsync(model);
// 删除该舱位相关的订舱关联关系
var slotList = await _repAllocation.AsQueryable().Where(a => a.BOOKING_SLOT_ID == id).ToListAsync();
var slotIdList = slotList.Select(s => s.Id);
await _repAllocation.Context.Updateable<BookingSlotAllocation>()
.SetColumns(a => a.IsDeleted == true)
.SetColumns(a => a.UpdatedTime == DateTime.Now)
.SetColumns(a => a.UpdatedUserId == UserManager.UserId)
.SetColumns(a => a.UpdatedUserName == UserManager.Name)
.Where(a => slotIdList.Contains(a.Id))
.ExecuteCommandAsync();
await _repAllocationCtn.Context.Updateable<BookingSlotAllocationCtn>()
.SetColumns(a => a.IsDeleted == true)
.SetColumns(a => a.UpdatedTime == DateTime.Now)
.SetColumns(a => a.UpdatedUserId == UserManager.UserId)
.SetColumns(a => a.UpdatedUserName == UserManager.Name)
.Where(a => slotIdList.Contains(a.SLOT_ALLOC_ID))
.ExecuteCommandAsync();
await InsLog("Cancellation", model.Id, "取消舱位");
} }
//更新库存 //更新库存
@ -703,6 +740,7 @@ namespace Myshipping.Application
// 1. 【舱位基础表】与【箱子表】做关联并根据【舱位主键】、【箱型】做分组统计出【总的箱量】作为queryable1 // 1. 【舱位基础表】与【箱子表】做关联并根据【舱位主键】、【箱型】做分组统计出【总的箱量】作为queryable1
var queryable1 = _repBase.Context.Queryable<BookingSlotBase, BookingSlotCtn>((bas, ctn) => bas.Id == ctn.SLOT_ID) var queryable1 = _repBase.Context.Queryable<BookingSlotBase, BookingSlotCtn>((bas, ctn) => bas.Id == ctn.SLOT_ID)
.Where(bas => bas.IS_CANCELLATION == false)
.WhereIF(!string.IsNullOrEmpty(slotInput.PORTLOAD), bas => bas.PORTLOAD.Contains(slotInput.PORTLOAD)) .WhereIF(!string.IsNullOrEmpty(slotInput.PORTLOAD), bas => bas.PORTLOAD.Contains(slotInput.PORTLOAD))
.WhereIF(!string.IsNullOrEmpty(slotInput.PORTDISCHARGE), bas => bas.PORTLOAD.Contains(slotInput.PORTLOAD)) .WhereIF(!string.IsNullOrEmpty(slotInput.PORTDISCHARGE), bas => bas.PORTLOAD.Contains(slotInput.PORTLOAD))
.WhereIF(!string.IsNullOrEmpty(slotInput.VESSEL), bas => bas.VESSEL.Contains(slotInput.VESSEL)) .WhereIF(!string.IsNullOrEmpty(slotInput.VESSEL), bas => bas.VESSEL.Contains(slotInput.VESSEL))
@ -1004,7 +1042,7 @@ namespace Myshipping.Application
/// <param name="slotId">舱位主键</param> /// <param name="slotId">舱位主键</param>
/// <param name="reqBatchNo">请求批次号用来区分对应的哪个批次任务</param> /// <param name="reqBatchNo">请求批次号用来区分对应的哪个批次任务</param>
/// <returns></returns> /// <returns></returns>
private async Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto,long slotId,string reqBatchNo) private async Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId, string reqBatchNo)
{ {
string batchNo = IDGen.NextID().ToString(); string batchNo = IDGen.NextID().ToString();
@ -1027,7 +1065,7 @@ namespace Myshipping.Application
{ {
SLOT_ID = slotId, SLOT_ID = slotId,
COMPARE_BATCHNO = reqBatchNo, COMPARE_BATCHNO = reqBatchNo,
COMPARE_DIFF_NUM = compareResult.extra.IsExistsDiff? compareResult.extra.ShowDetailList.Count : 0, COMPARE_DIFF_NUM = compareResult.extra.IsExistsDiff ? compareResult.extra.ShowDetailList.Count : 0,
CreatedTime = nowDate, CreatedTime = nowDate,
UpdatedTime = nowDate, UpdatedTime = nowDate,
CreatedUserId = UserManager.UserId, CreatedUserId = UserManager.UserId,
@ -1154,7 +1192,7 @@ namespace Myshipping.Application
result.succ = true; result.succ = true;
result.msg = "导入成功"; result.msg = "导入成功";
} }
catch(Exception ex) catch (Exception ex)
{ {
_logger.LogError($"导入舱位异常,原因:{ex.Message}"); _logger.LogError($"导入舱位异常,原因:{ex.Message}");

@ -311,7 +311,17 @@ namespace Myshipping.Application.Service.BookingSlot.Dto
[Description("舱单截止时间")] [Description("舱单截止时间")]
public DateTime? MANIFEST_CUT_DATE { get; set; } public DateTime? MANIFEST_CUT_DATE { get; set; }
/// <summary>
/// 是否Cancellation
/// </summary>
[Description("是否Cancellation")]
public bool IS_CANCELLATION { get; set; }
/// <summary>
/// Cancellation时间
/// </summary>
[Description("Cancellation时间")]
public DateTime? CANCELLATION_DATE { get; set; }
} }
/// <summary> /// <summary>

Loading…
Cancel
Save