舱位库存相关调整

master
zhangxiaofeng 7 months ago
parent bac5be504c
commit b3eef4c398

@ -121,6 +121,18 @@ namespace Myshipping.Application
[SugarColumn(ColumnName = "PORTDISCHARGE")]
[Description("卸货港")]
public string PORTDISCHARGE{ get; set; }
/// <summary>
/// 卸货港国家代码
/// </summary>
[SugarColumn(ColumnName = "PORTDISCHARGE_COUNTRY_CODE")]
[Description("卸货港国家代码")]
public string PORTDISCHARGE_COUNTRY_CODE { get; set; }
/// <summary>
/// 卸货港国家名称
/// </summary>
[SugarColumn(ColumnName = "PORTDISCHARGE_COUNTRY")]
[Description("卸货港国家名称")]
public string PORTDISCHARGE_COUNTRY { get; set; }
/// <summary>
/// 中转港1

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using SqlSugar;
using Myshipping.Core.Entity;
using System.ComponentModel;
/*
* @author : whm
@ -87,6 +88,49 @@ namespace Myshipping.Application
[SugarColumn(ColumnName = "PLACEDELIVERY")]
public string PLACEDELIVERY { get; set; }
/// <summary>
/// 装货港代码
/// </summary>
[SugarColumn(ColumnName = "PORTLOADID")]
[Description("装货港代码")]
public string PORTLOADID { get; set; }
/// <summary>
/// 装货港
/// </summary>
[SugarColumn(ColumnName = "PORTLOAD")]
[Description("装货港")]
public string PORTLOAD { get; set; }
/// <summary>
/// 卸货港代码
/// </summary>
[SugarColumn(ColumnName = "PORTDISCHARGEID")]
[Description("卸货港代码")]
public string PORTDISCHARGEID { get; set; }
/// <summary>
/// 卸货港
/// </summary>
[SugarColumn(ColumnName = "PORTDISCHARGE")]
[Description("卸货港")]
public string PORTDISCHARGE { get; set; }
/// <summary>
/// 卸货港国家代码
/// </summary>
[SugarColumn(ColumnName = "PORTDISCHARGE_COUNTRY_CODE")]
[Description("卸货港国家代码")]
public string PORTDISCHARGE_COUNTRY_CODE { get; set; }
/// <summary>
/// 卸货港国家名称
/// </summary>
[SugarColumn(ColumnName = "PORTDISCHARGE_COUNTRY")]
[Description("卸货港国家名称")]
public string PORTDISCHARGE_COUNTRY { get; set; }
/// <summary>
/// 航线代码(船公司)
/// </summary>

@ -27,7 +27,13 @@ namespace Myshipping.Application.Event
[EventSubscribe("BookingSlotStock:Update")]
public async Task BookingSlotStock(EventHandlerExecutingContext context)
{
_logger.LogInformation($"收到更新库存订阅请求:{context.Source.Payload}");
BookingSlotStockUpdateModel paraObj = context.Source.Payload as BookingSlotStockUpdateModel;
await BookingSlotStock(paraObj);
}
public async Task BookingSlotStock(BookingSlotStockUpdateModel paraObj)
{
_logger.LogInformation($"收到更新库存订阅请求:{paraObj.ToJsonString()}");
var _repBase = App.GetService<SqlSugarRepository<BookingSlotBase>>();
var _repCtn = App.GetService<SqlSugarRepository<BookingSlotCtn>>();
@ -35,8 +41,18 @@ namespace Myshipping.Application.Event
var _repAlloc = App.GetService<SqlSugarRepository<BookingSlotAllocation>>();
var _repAllocCtn = App.GetService<SqlSugarRepository<BookingSlotAllocationCtn>>();
var paraObj = context.Source.Payload as BookingSlotStockUpdateModel;
if (string.IsNullOrEmpty(paraObj.VESSEL)
|| string.IsNullOrEmpty(paraObj.VOYNO)
|| string.IsNullOrEmpty(paraObj.CONTRACT_NO)
|| string.IsNullOrEmpty(paraObj.BOOKING_SLOT_TYPE)
|| string.IsNullOrEmpty(paraObj.CARRIERID)
|| string.IsNullOrEmpty(paraObj.PORTLOADID)
|| string.IsNullOrEmpty(paraObj.PORTDISCHARGEID))
{
_logger.LogInformation($"收到更新库存订阅请求:部分参数存在空值,结束");
return;
}
var baseList = await _repBase.AsQueryable().Filter(null, true)
.Where(x => !x.IsDeleted
&& x.TenantId == paraObj.TenantId
@ -45,8 +61,8 @@ namespace Myshipping.Application.Event
&& 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)
&& x.PORTLOADID == paraObj.PORTLOADID
&& x.PORTDISCHARGEID == paraObj.PORTDISCHARGEID)
.OrderByDescending(x => x.UpdatedTime)
.ToListAsync();
@ -58,8 +74,8 @@ namespace Myshipping.Application.Event
&& 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);
&& x.PORTLOADID == paraObj.PORTLOADID
&& x.PORTDISCHARGEID == paraObj.PORTDISCHARGEID);
if (!baseList.Any())
{
@ -70,13 +86,20 @@ namespace Myshipping.Application.Event
}
return;
}
var isInsert = false;
if (stockObj == null)
{
isInsert = true;
var isInsert = stockObj == null;
var idTemp = stockObj?.Id;
stockObj = baseList[0].Adapt(stockObj);
if (isInsert)
{
stockObj.Id = 0;
}
else
{
stockObj.Id = (long)idTemp;
}
// 总舱位数
stockObj.TOTAL_ORDERS = baseList.Count;
@ -212,15 +235,23 @@ namespace Myshipping.Application.Event
/// </summary>
public string CARRIERID { get; set; }
///// <summary>
///// 收货地
///// </summary>
//public string PLACERECEIPT { get; set; }
///// <summary>
///// 交货地
///// </summary>
//public string PLACEDELIVERY { get; set; }
/// <summary>
/// 收货地
/// 装货港代码
/// </summary>
public string PLACERECEIPT { get; set; }
public string PORTLOADID { get; set; }
/// <summary>
/// 交货地
/// 卸货港代码
/// </summary>
public string PLACEDELIVERY { get; set; }
public string PORTDISCHARGEID { get; set; }
/// <summary>
/// 租户Id
/// </summary>

@ -11924,8 +11924,8 @@ namespace Myshipping.Application
x.CONTRACT_NO,
x.VESSEL,
x.VOYNO,
x.PLACERECEIPT,
x.PLACEDELIVERY,
x.PORTLOADID,
x.PORTDISCHARGEID,
x.TenantId
}).ToListAsync();
@ -11958,8 +11958,8 @@ namespace Myshipping.Application
CONTRACT_NO = item.CONTRACT_NO,
VESSEL = item.VESSEL,
VOYNO = item.VOYNO,
PLACERECEIPT = item.PLACERECEIPT,
PLACEDELIVERY = item.PLACEDELIVERY,
PORTLOADID = item.PORTLOADID,
PORTDISCHARGEID = item.PORTDISCHARGEID,
TenantId = item.TenantId
}));
}

@ -151,8 +151,8 @@ namespace Myshipping.Application
|| oldObj.VOYNO != model.VOYNO
|| oldObj.BOOKING_SLOT_TYPE != model.BOOKING_SLOT_TYPE
|| oldObj.CARRIERID != model.CARRIERID
|| oldObj.PLACERECEIPT != model.PLACERECEIPT
|| oldObj.PLACEDELIVERY != model.PLACEDELIVERY)
|| oldObj.PORTLOADID != model.PORTLOADID
|| oldObj.PORTDISCHARGEID != model.PORTDISCHARGEID)
{
isNeedUpdateOldStock = true;
}
@ -169,8 +169,8 @@ namespace Myshipping.Application
CONTRACT_NO = oldObj.CONTRACT_NO,
VESSEL = oldObj.VESSEL,
VOYNO = oldObj.VOYNO,
PLACERECEIPT = oldObj.PLACERECEIPT,
PLACEDELIVERY = oldObj.PLACEDELIVERY,
PORTLOADID = oldObj.PORTLOADID,
PORTDISCHARGEID = oldObj.PORTDISCHARGEID,
TenantId = model.TenantId
}));
}
@ -212,8 +212,8 @@ namespace Myshipping.Application
CONTRACT_NO = model.CONTRACT_NO,
VESSEL = model.VESSEL,
VOYNO = model.VOYNO,
PLACERECEIPT = model.PLACERECEIPT,
PLACEDELIVERY = model.PLACEDELIVERY,
PORTLOADID = model.PORTLOADID,
PORTDISCHARGEID = model.PORTDISCHARGEID,
TenantId = model.TenantId
}));
@ -352,7 +352,7 @@ namespace Myshipping.Application
});
}
// 解析收货地,得到装货港名称及
// 解析收货地,得到装货港名称及五字
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACERECEIPT))
{
var portEnName = dto.DataObj.PLACERECEIPT.Split(',')[0]?.Trim();
@ -378,7 +378,7 @@ namespace Myshipping.Application
{
_logger.LogInformation("收货地为空,订舱编号:{SLOT_BOOKING_NO}", dto.DataObj.SLOT_BOOKING_NO);
}
// 解析交货地,得到为卸货港名称及代码
// 解析交货地,得到为卸货港名称及五字码, 以及国家信息
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACEDELIVERY))
{
var portEnName = dto.DataObj.PLACEDELIVERY.Split(',')[0]?.Trim();
@ -389,6 +389,8 @@ namespace Myshipping.Application
{
dto.DataObj.PORTDISCHARGE = portInfo.EnName;
dto.DataObj.PORTDISCHARGEID = portInfo.EdiCode;
dto.DataObj.PORTDISCHARGE_COUNTRY = portInfo.Country;
dto.DataObj.PORTDISCHARGE_COUNTRY_CODE = portInfo.CountryCode;
}
else
{
@ -521,8 +523,8 @@ namespace Myshipping.Application
|| oldObj.VOYNO != model.VOYNO
|| oldObj.BOOKING_SLOT_TYPE != model.BOOKING_SLOT_TYPE
|| oldObj.CARRIERID != model.CARRIERID
|| oldObj.PLACERECEIPT != model.PLACERECEIPT
|| oldObj.PLACEDELIVERY != model.PLACEDELIVERY)
|| oldObj.PORTLOADID != model.PORTLOADID
|| oldObj.PORTDISCHARGEID != model.PORTDISCHARGEID)
{
isNeedUpdateOldStock = true;
}
@ -538,8 +540,8 @@ namespace Myshipping.Application
CONTRACT_NO = oldObj.CONTRACT_NO,
VESSEL = oldObj.VESSEL,
VOYNO = oldObj.VOYNO,
PLACERECEIPT = oldObj.PLACERECEIPT,
PLACEDELIVERY = oldObj.PLACEDELIVERY,
PORTLOADID = oldObj.PORTLOADID,
PORTDISCHARGEID = oldObj.PORTDISCHARGEID,
TenantId = model.TenantId
}));
}
@ -661,8 +663,8 @@ namespace Myshipping.Application
CONTRACT_NO = model.CONTRACT_NO,
VESSEL = model.VESSEL,
VOYNO = model.VOYNO,
PLACERECEIPT = model.PLACERECEIPT,
PLACEDELIVERY = model.PLACEDELIVERY,
PORTLOADID = model.PORTLOADID,
PORTDISCHARGEID = model.PORTDISCHARGEID,
TenantId = model.TenantId
}));
}
@ -823,6 +825,45 @@ namespace Myshipping.Application
//更新库存
await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", input));
}
/// <summary>
/// 重新计算某租户下面所有的库存
/// </summary>
/// <returns></returns>
[HttpPost("/BookingSlot/refreshAllStock")]
public async Task RefreshAllStock([FromBody] long telentId)
{
var logger = App.GetService<ILogger<BookingSlotStockSubscriber>>();
BookingSlotStockSubscriber subscriber = new BookingSlotStockSubscriber(logger);
var group = await _repBase.AsQueryable().Filter(null, true)
.Where(x => x.TenantId == telentId && x.IsDeleted == false)
.GroupBy(x => new
{
x.VESSEL,
x.VOYNO,
x.CARRIERID,
x.CONTRACT_NO,
x.BOOKING_SLOT_TYPE,
x.PORTLOADID,
x.PORTDISCHARGEID,
x.TenantId
}).Select(x => new
{
x.VESSEL,
x.VOYNO,
x.CARRIERID,
x.CONTRACT_NO,
x.BOOKING_SLOT_TYPE,
x.PORTLOADID,
x.PORTDISCHARGEID,
x.TenantId
}).ToListAsync();
foreach (var item in group)
{
BookingSlotStockUpdateModel model = item.Adapt<BookingSlotStockUpdateModel>();
await subscriber.BookingSlotStock(model);
}
}
#endregion
#region 舱位引入
@ -1048,8 +1089,8 @@ namespace Myshipping.Application
CONTRACT_NO = latestSlot.CONTRACT_NO,
VESSEL = latestSlot.VESSEL,
VOYNO = latestSlot.VOYNO,
PLACERECEIPT = latestSlot.PLACERECEIPT,
PLACEDELIVERY = latestSlot.PLACEDELIVERY,
PORTLOADID = latestSlot.PORTLOADID,
PORTDISCHARGEID = latestSlot.PORTDISCHARGEID,
TenantId = latestSlot.TenantId,
}));
}

@ -197,6 +197,17 @@ namespace Myshipping.Application.Service.BookingSlot.Dto
[Description("卸货港")]
public string PORTDISCHARGE { get; set; }
/// <summary>
/// 卸货港国家代码
/// </summary>
[Description("卸货港国家代码")]
public string PORTDISCHARGE_COUNTRY_CODE { get; set; }
/// <summary>
/// 卸货港国家名称
/// </summary>
[Description("卸货港国家名称")]
public string PORTDISCHARGE_COUNTRY { get; set; }
/// <summary>
/// 中转港1
/// </summary>

@ -1,11 +1,5 @@
using Myshipping.Core;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.Service.BookingSlot.Dto
{
@ -179,6 +173,35 @@ namespace Myshipping.Application.Service.BookingSlot.Dto
/// 交货地
/// </summary>
public string PLACEDELIVERY { get; set; }
/// <summary>
/// 装货港代码
/// </summary>
public string PORTLOADID { get; set; }
/// <summary>
/// 装货港
/// </summary>
public string PORTLOAD { get; set; }
/// <summary>
/// 卸货港代码
/// </summary>
public string PORTDISCHARGEID { get; set; }
/// <summary>
/// 卸货港
/// </summary>
public string PORTDISCHARGE { get; set; }
/// <summary>
/// 卸货港国家代码
/// </summary>
public string PORTDISCHARGE_COUNTRY_CODE { get; set; }
/// <summary>
/// 卸货港国家名称
/// </summary>
public string PORTDISCHARGE_COUNTRY { get; set; }
}

Loading…
Cancel
Save