舱位库存相关调整

master
zhangxiaofeng 7 months ago
parent bac5be504c
commit b3eef4c398

@ -121,6 +121,18 @@ namespace Myshipping.Application
[SugarColumn(ColumnName = "PORTDISCHARGE")] [SugarColumn(ColumnName = "PORTDISCHARGE")]
[Description("卸货港")] [Description("卸货港")]
public string PORTDISCHARGE{ get; set; } 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>
/// 中转港1 /// 中转港1

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using SqlSugar; using SqlSugar;
using Myshipping.Core.Entity; using Myshipping.Core.Entity;
using System.ComponentModel;
/* /*
* @author : whm * @author : whm
@ -87,6 +88,49 @@ namespace Myshipping.Application
[SugarColumn(ColumnName = "PLACEDELIVERY")] [SugarColumn(ColumnName = "PLACEDELIVERY")]
public string PLACEDELIVERY { get; set; } 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>
/// 航线代码(船公司) /// 航线代码(船公司)
/// </summary> /// </summary>

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

@ -11924,8 +11924,8 @@ namespace Myshipping.Application
x.CONTRACT_NO, x.CONTRACT_NO,
x.VESSEL, x.VESSEL,
x.VOYNO, x.VOYNO,
x.PLACERECEIPT, x.PORTLOADID,
x.PLACEDELIVERY, x.PORTDISCHARGEID,
x.TenantId x.TenantId
}).ToListAsync(); }).ToListAsync();
@ -11958,8 +11958,8 @@ namespace Myshipping.Application
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, PORTLOADID = item.PORTLOADID,
PLACEDELIVERY = item.PLACEDELIVERY, PORTDISCHARGEID = item.PORTDISCHARGEID,
TenantId = item.TenantId TenantId = item.TenantId
})); }));
} }

@ -151,8 +151,8 @@ namespace Myshipping.Application
|| oldObj.VOYNO != model.VOYNO || oldObj.VOYNO != model.VOYNO
|| oldObj.BOOKING_SLOT_TYPE != model.BOOKING_SLOT_TYPE || oldObj.BOOKING_SLOT_TYPE != model.BOOKING_SLOT_TYPE
|| oldObj.CARRIERID != model.CARRIERID || oldObj.CARRIERID != model.CARRIERID
|| oldObj.PLACERECEIPT != model.PLACERECEIPT || oldObj.PORTLOADID != model.PORTLOADID
|| oldObj.PLACEDELIVERY != model.PLACEDELIVERY) || oldObj.PORTDISCHARGEID != model.PORTDISCHARGEID)
{ {
isNeedUpdateOldStock = true; isNeedUpdateOldStock = true;
} }
@ -169,8 +169,8 @@ namespace Myshipping.Application
CONTRACT_NO = oldObj.CONTRACT_NO, CONTRACT_NO = oldObj.CONTRACT_NO,
VESSEL = oldObj.VESSEL, VESSEL = oldObj.VESSEL,
VOYNO = oldObj.VOYNO, VOYNO = oldObj.VOYNO,
PLACERECEIPT = oldObj.PLACERECEIPT, PORTLOADID = oldObj.PORTLOADID,
PLACEDELIVERY = oldObj.PLACEDELIVERY, PORTDISCHARGEID = oldObj.PORTDISCHARGEID,
TenantId = model.TenantId TenantId = model.TenantId
})); }));
} }
@ -212,8 +212,8 @@ namespace Myshipping.Application
CONTRACT_NO = model.CONTRACT_NO, CONTRACT_NO = model.CONTRACT_NO,
VESSEL = model.VESSEL, VESSEL = model.VESSEL,
VOYNO = model.VOYNO, VOYNO = model.VOYNO,
PLACERECEIPT = model.PLACERECEIPT, PORTLOADID = model.PORTLOADID,
PLACEDELIVERY = model.PLACEDELIVERY, PORTDISCHARGEID = model.PORTDISCHARGEID,
TenantId = model.TenantId TenantId = model.TenantId
})); }));
@ -352,7 +352,7 @@ namespace Myshipping.Application
}); });
} }
// 解析收货地,得到装货港名称及 // 解析收货地,得到装货港名称及五字
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACERECEIPT)) if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACERECEIPT))
{ {
var portEnName = dto.DataObj.PLACERECEIPT.Split(',')[0]?.Trim(); 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); _logger.LogInformation("收货地为空,订舱编号:{SLOT_BOOKING_NO}", dto.DataObj.SLOT_BOOKING_NO);
} }
// 解析交货地,得到为卸货港名称及代码 // 解析交货地,得到为卸货港名称及五字码, 以及国家信息
if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACEDELIVERY)) if (!string.IsNullOrWhiteSpace(dto.DataObj.PLACEDELIVERY))
{ {
var portEnName = dto.DataObj.PLACEDELIVERY.Split(',')[0]?.Trim(); var portEnName = dto.DataObj.PLACEDELIVERY.Split(',')[0]?.Trim();
@ -389,6 +389,8 @@ namespace Myshipping.Application
{ {
dto.DataObj.PORTDISCHARGE = portInfo.EnName; dto.DataObj.PORTDISCHARGE = portInfo.EnName;
dto.DataObj.PORTDISCHARGEID = portInfo.EdiCode; dto.DataObj.PORTDISCHARGEID = portInfo.EdiCode;
dto.DataObj.PORTDISCHARGE_COUNTRY = portInfo.Country;
dto.DataObj.PORTDISCHARGE_COUNTRY_CODE = portInfo.CountryCode;
} }
else else
{ {
@ -521,8 +523,8 @@ namespace Myshipping.Application
|| oldObj.VOYNO != model.VOYNO || oldObj.VOYNO != model.VOYNO
|| oldObj.BOOKING_SLOT_TYPE != model.BOOKING_SLOT_TYPE || oldObj.BOOKING_SLOT_TYPE != model.BOOKING_SLOT_TYPE
|| oldObj.CARRIERID != model.CARRIERID || oldObj.CARRIERID != model.CARRIERID
|| oldObj.PLACERECEIPT != model.PLACERECEIPT || oldObj.PORTLOADID != model.PORTLOADID
|| oldObj.PLACEDELIVERY != model.PLACEDELIVERY) || oldObj.PORTDISCHARGEID != model.PORTDISCHARGEID)
{ {
isNeedUpdateOldStock = true; isNeedUpdateOldStock = true;
} }
@ -538,8 +540,8 @@ namespace Myshipping.Application
CONTRACT_NO = oldObj.CONTRACT_NO, CONTRACT_NO = oldObj.CONTRACT_NO,
VESSEL = oldObj.VESSEL, VESSEL = oldObj.VESSEL,
VOYNO = oldObj.VOYNO, VOYNO = oldObj.VOYNO,
PLACERECEIPT = oldObj.PLACERECEIPT, PORTLOADID = oldObj.PORTLOADID,
PLACEDELIVERY = oldObj.PLACEDELIVERY, PORTDISCHARGEID = oldObj.PORTDISCHARGEID,
TenantId = model.TenantId TenantId = model.TenantId
})); }));
} }
@ -661,8 +663,8 @@ namespace Myshipping.Application
CONTRACT_NO = model.CONTRACT_NO, CONTRACT_NO = model.CONTRACT_NO,
VESSEL = model.VESSEL, VESSEL = model.VESSEL,
VOYNO = model.VOYNO, VOYNO = model.VOYNO,
PLACERECEIPT = model.PLACERECEIPT, PORTLOADID = model.PORTLOADID,
PLACEDELIVERY = model.PLACEDELIVERY, PORTDISCHARGEID = model.PORTDISCHARGEID,
TenantId = model.TenantId TenantId = model.TenantId
})); }));
} }
@ -823,6 +825,45 @@ namespace Myshipping.Application
//更新库存 //更新库存
await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", input)); 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 #endregion
#region 舱位引入 #region 舱位引入
@ -1048,8 +1089,8 @@ namespace Myshipping.Application
CONTRACT_NO = latestSlot.CONTRACT_NO, CONTRACT_NO = latestSlot.CONTRACT_NO,
VESSEL = latestSlot.VESSEL, VESSEL = latestSlot.VESSEL,
VOYNO = latestSlot.VOYNO, VOYNO = latestSlot.VOYNO,
PLACERECEIPT = latestSlot.PLACERECEIPT, PORTLOADID = latestSlot.PORTLOADID,
PLACEDELIVERY = latestSlot.PLACEDELIVERY, PORTDISCHARGEID = latestSlot.PORTDISCHARGEID,
TenantId = latestSlot.TenantId, TenantId = latestSlot.TenantId,
})); }));
} }

@ -197,6 +197,17 @@ namespace Myshipping.Application.Service.BookingSlot.Dto
[Description("卸货港")] [Description("卸货港")]
public string PORTDISCHARGE { get; set; } 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> /// <summary>
/// 中转港1 /// 中转港1
/// </summary> /// </summary>

@ -1,11 +1,5 @@
using Myshipping.Core; using Myshipping.Core;
using SqlSugar;
using System; 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 namespace Myshipping.Application.Service.BookingSlot.Dto
{ {
@ -179,6 +173,35 @@ namespace Myshipping.Application.Service.BookingSlot.Dto
/// 交货地 /// 交货地
/// </summary> /// </summary>
public string PLACEDELIVERY { get; set; } 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