|
|
|
@ -1,27 +1,12 @@
|
|
|
|
|
using Furion;
|
|
|
|
|
using Furion.EventBus;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Furion.RemoteRequest.Extensions;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Myshipping.Application.ConfigOption;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Myshipping.Application.Service.BookingOrder.Dto;
|
|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using NPOI.OpenXmlFormats.Wordprocessing;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Yitter.IdGenerator;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application.Event
|
|
|
|
|
{
|
|
|
|
@ -53,56 +38,58 @@ namespace Myshipping.Application.Event
|
|
|
|
|
var paraObj = context.Source.Payload as BookingSlotStockUpdateModel;
|
|
|
|
|
|
|
|
|
|
var baseList = await _repBase.AsQueryable().Filter(null, true)
|
|
|
|
|
.Where(x => !x.IsDeleted
|
|
|
|
|
&& !x.IS_CANCELLATION
|
|
|
|
|
&& x.VESSEL == paraObj.VESSEL
|
|
|
|
|
&& x.VOYNO == paraObj.VOYNO
|
|
|
|
|
&& x.CONTRACT_NO == paraObj.CONTRACT_NO
|
|
|
|
|
&& x.BOOKING_SLOT_TYPE == paraObj.BOOKING_SLOT_TYPE
|
|
|
|
|
&& x.CARRIERID == paraObj.CARRIERID
|
|
|
|
|
&& x.PLACEDELIVERY == paraObj.PLACEDELIVERY
|
|
|
|
|
&& x.PLACERECEIPT == paraObj.PLACERECEIPT)
|
|
|
|
|
.OrderByDescending(x => x.UpdatedTime)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
var stockObj = await _repStock.AsQueryable()
|
|
|
|
|
.Filter(null, true)
|
|
|
|
|
.FirstAsync(x => !x.IsDeleted
|
|
|
|
|
&& x.VESSEL == paraObj.VESSEL
|
|
|
|
|
&& x.VOYNO == paraObj.VOYNO
|
|
|
|
|
&& x.CONTRACT_NO == paraObj.CONTRACT_NO
|
|
|
|
|
&& x.BOOKING_SLOT_TYPE == paraObj.BOOKING_SLOT_TYPE
|
|
|
|
|
&& x.CARRIERID == paraObj.CARRIERID
|
|
|
|
|
&& x.PLACEDELIVERY == paraObj.PLACEDELIVERY
|
|
|
|
|
&& x.PLACERECEIPT == paraObj.PLACERECEIPT);
|
|
|
|
|
.Where(x => !x.IsDeleted
|
|
|
|
|
&& x.TenantId == paraObj.TenantId
|
|
|
|
|
&& x.VESSEL == paraObj.VESSEL
|
|
|
|
|
&& x.VOYNO == paraObj.VOYNO
|
|
|
|
|
&& x.CONTRACT_NO == paraObj.CONTRACT_NO
|
|
|
|
|
&& x.BOOKING_SLOT_TYPE == paraObj.BOOKING_SLOT_TYPE
|
|
|
|
|
&& x.CARRIERID == paraObj.CARRIERID
|
|
|
|
|
&& x.PLACEDELIVERY == paraObj.PLACEDELIVERY
|
|
|
|
|
&& x.PLACERECEIPT == paraObj.PLACERECEIPT)
|
|
|
|
|
.OrderByDescending(x => x.UpdatedTime)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
var stockObj = await _repStock.AsQueryable().Filter(null, true)
|
|
|
|
|
.FirstAsync(x => !x.IsDeleted
|
|
|
|
|
&& x.TenantId == paraObj.TenantId
|
|
|
|
|
&& x.VESSEL == paraObj.VESSEL
|
|
|
|
|
&& x.VOYNO == paraObj.VOYNO
|
|
|
|
|
&& x.CONTRACT_NO == paraObj.CONTRACT_NO
|
|
|
|
|
&& x.BOOKING_SLOT_TYPE == paraObj.BOOKING_SLOT_TYPE
|
|
|
|
|
&& x.CARRIERID == paraObj.CARRIERID
|
|
|
|
|
&& x.PLACEDELIVERY == paraObj.PLACEDELIVERY
|
|
|
|
|
&& x.PLACERECEIPT == paraObj.PLACERECEIPT);
|
|
|
|
|
|
|
|
|
|
if (!baseList.Any())
|
|
|
|
|
{
|
|
|
|
|
// 从库存表删除这7项维度的库存数据
|
|
|
|
|
|
|
|
|
|
if (stockObj != null)
|
|
|
|
|
{
|
|
|
|
|
// 从库存表删除这7项维度的库存数据
|
|
|
|
|
await _repStock.DeleteAsync(x => x.Id == stockObj.Id);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var isInsert = false;
|
|
|
|
|
if (stockObj == null)
|
|
|
|
|
{
|
|
|
|
|
stockObj = new BookingSlotStock();
|
|
|
|
|
stockObj.Id = YitIdHelper.NextId();
|
|
|
|
|
await _repStock.InsertAsync(stockObj);
|
|
|
|
|
isInsert = true;
|
|
|
|
|
stockObj = baseList[0].Adapt(stockObj);
|
|
|
|
|
stockObj.Id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var bkId = stockObj.Id;
|
|
|
|
|
baseList[0].Adapt(stockObj);
|
|
|
|
|
stockObj.Id = bkId;
|
|
|
|
|
|
|
|
|
|
// 总舱位数
|
|
|
|
|
stockObj.TOTAL_ORDERS = baseList.Count;
|
|
|
|
|
|
|
|
|
|
var lstBaseId = baseList.Select(x => x.Id).ToList();
|
|
|
|
|
// 取消舱位数
|
|
|
|
|
stockObj.CANCEL_NUM = baseList.Count(x => x.IS_CANCELLATION);
|
|
|
|
|
|
|
|
|
|
// 舱位主键列表
|
|
|
|
|
var slotBaseIdList = baseList.Select(x => x.Id).ToList();
|
|
|
|
|
|
|
|
|
|
// 总的箱型箱量
|
|
|
|
|
var ctnAllList = await _repCtn.AsQueryable().Filter(null, true)
|
|
|
|
|
.Where(x => !x.IsDeleted && lstBaseId.Contains(x.SLOT_ID))
|
|
|
|
|
.Where(x => !x.IsDeleted && slotBaseIdList.Contains(x.SLOT_ID))
|
|
|
|
|
.GroupBy(x => x.CTNALL)
|
|
|
|
|
.Select(x => new
|
|
|
|
|
{
|
|
|
|
@ -117,7 +104,7 @@ namespace Myshipping.Application.Event
|
|
|
|
|
// 订舱引用表主键与订舱主表主键
|
|
|
|
|
var lstAllocKeyList = await _repAlloc.AsQueryable()
|
|
|
|
|
.Filter(null, true)
|
|
|
|
|
.Where(x => !x.IsDeleted && lstBaseId.Contains(x.BOOKING_SLOT_ID))
|
|
|
|
|
.Where(x => !x.IsDeleted && slotBaseIdList.Contains(x.BOOKING_SLOT_ID))
|
|
|
|
|
.Select(x => new { x.Id, x.BOOKING_SLOT_ID })
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
@ -183,8 +170,14 @@ namespace Myshipping.Application.Event
|
|
|
|
|
stockObj.REMAIN_CTNS_NUM = stockObj.TOTAL_CTNS - stockObj.USE_CTNS_NUM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _repStock.UpdateAsync(stockObj);
|
|
|
|
|
if (isInsert)
|
|
|
|
|
{
|
|
|
|
|
await _repStock.InsertAsync(stockObj);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
await _repStock.UpdateAsync(stockObj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|