订舱删除时,删除已引入的舱位的关联关系

master
zhangxiaofeng 7 months ago
parent 2af1ea9d62
commit eb5030560d

@ -2306,6 +2306,10 @@ namespace Myshipping.Application
{ {
continue; continue;
} }
// 通过租户参数判断这一票的租户是否启用了舱位引入功能
var isCancelAllocationSlot = tenantParamList.FirstOrDefault(x => x.TenantId == order.TenantId && x.ParaCode == TenantParamCode.ENABLE_SLOT_ABILITY)?.ItemCode;
var mblno = order.MBLNO; var mblno = order.MBLNO;
// 将待删除的订舱单id存放到Cache中。目的使用SendBookingOrder()推送订舱单数据前通过Cache判断是否正在走删除逻辑来决定是否推送(如果是正在处理删除逻辑的数据,则不推送) // 将待删除的订舱单id存放到Cache中。目的使用SendBookingOrder()推送订舱单数据前通过Cache判断是否正在走删除逻辑来决定是否推送(如果是正在处理删除逻辑的数据,则不推送)
@ -2349,6 +2353,12 @@ namespace Myshipping.Application
// 取消订阅运踪 // 取消订阅运踪
waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno)); waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno));
if (isCancelAllocationSlot == "YES")
{
// 取消关联舱位
await CancelAllocationSlot(Id);
}
// 记录日志 // 记录日志
var newOrder = order.Adapt<BookingOrder>(); var newOrder = order.Adapt<BookingOrder>();
newOrder.IsDeleted = true; newOrder.IsDeleted = true;
@ -2379,6 +2389,12 @@ namespace Myshipping.Application
// 取消订阅运踪 // 取消订阅运踪
waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno)); waitUnsubscribeBilltrace.Add(new BillTraceUnsubscribeList(Id.ToString(), mblno));
if (isCancelAllocationSlot == "YES")
{
// 取消关联舱位
await CancelAllocationSlot(Id);
}
// 记录日志 // 记录日志
var newOrder = order.Adapt<BookingOrder>(); var newOrder = order.Adapt<BookingOrder>();
newOrder.IsDeleted = true; newOrder.IsDeleted = true;
@ -11866,10 +11882,22 @@ namespace Myshipping.Application
[HttpPost("/BookingOrder/CancelAllocationSlot")] [HttpPost("/BookingOrder/CancelAllocationSlot")]
public async Task CancelAllocationSlot(long id) public async Task CancelAllocationSlot(long id)
{ {
var slotList = await _repSlotAllocation.AsQueryable().Where(a => a.BOOKING_ID == id).ToListAsync(); var slotList = await _repSlotAllocation.AsQueryable().Where(a => a.BOOKING_ID == id).Select(x => new
var slotIdList = slotList.Select(s => s.Id); {
x.Id,
x.BOOKING_SLOT_TYPE,
x.CARRIERID,
x.CONTRACT_NO,
x.VESSEL,
x.VOYNO,
x.PLACERECEIPT,
x.PLACEDELIVERY
}).ToListAsync();
await _repSlotAllocation.Context.Updateable<BookingSlotAllocation>() if (slotList.Count > 0)
{
var slotIdList = slotList.Select(s => s.Id);
await _repSlotAllocation.Context.Updateable<BookingSlotAllocation>()
.SetColumns(a => a.IsDeleted == true) .SetColumns(a => a.IsDeleted == true)
.SetColumns(a => a.UpdatedTime == DateTime.Now) .SetColumns(a => a.UpdatedTime == DateTime.Now)
.SetColumns(a => a.UpdatedUserId == UserManager.UserId) .SetColumns(a => a.UpdatedUserId == UserManager.UserId)
@ -11877,27 +11905,28 @@ namespace Myshipping.Application
.Where(a => slotIdList.Contains(a.Id)) .Where(a => slotIdList.Contains(a.Id))
.ExecuteCommandAsync(); .ExecuteCommandAsync();
await _repSlotAllocationCtn.Context.Updateable<BookingSlotAllocationCtn>() await _repSlotAllocationCtn.Context.Updateable<BookingSlotAllocationCtn>()
.SetColumns(a => a.IsDeleted == true) .SetColumns(a => a.IsDeleted == true)
.SetColumns(a => a.UpdatedTime == DateTime.Now) .SetColumns(a => a.UpdatedTime == DateTime.Now)
.SetColumns(a => a.UpdatedUserId == UserManager.UserId) .SetColumns(a => a.UpdatedUserId == UserManager.UserId)
.SetColumns(a => a.UpdatedUserName == UserManager.Name) .SetColumns(a => a.UpdatedUserName == UserManager.Name)
.Where(a => slotIdList.Contains(a.SLOT_ALLOC_ID)) .Where(a => slotIdList.Contains(a.SLOT_ALLOC_ID))
.ExecuteCommandAsync(); .ExecuteCommandAsync();
// 更新库存 // 更新库存
foreach (var item in slotList) foreach (var item in slotList)
{ {
await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new Event.BookingSlotStockUpdateModel await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new Event.BookingSlotStockUpdateModel
{ {
BOOKING_SLOT_TYPE = item.BOOKING_SLOT_TYPE, BOOKING_SLOT_TYPE = item.BOOKING_SLOT_TYPE,
CARRIERID = item.CARRIERID, CARRIERID = item.CARRIERID,
CONTRACT_NO = item.CONTRACT_NO, CONTRACT_NO = item.CONTRACT_NO,
VESSEL = item.VESSEL, VESSEL = item.VESSEL,
VOYNO = item.VOYNO, VOYNO = item.VOYNO,
PLACERECEIPT = item.PLACERECEIPT, PLACERECEIPT = item.PLACERECEIPT,
PLACEDELIVERY = item.PLACEDELIVERY PLACEDELIVERY = item.PLACEDELIVERY
})); }));
}
} }
} }
#endregion #endregion

Loading…
Cancel
Save