舱位管理

master
zhangxiaofeng 6 months ago
parent 75db3704f6
commit 78aac30a0a

@ -0,0 +1,78 @@
using Myshipping.Core;
using Myshipping.Core.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.Helper
{
public static class PlaceToPortHelper
{
public static async Task<CodePortLoad> PlaceReceiptToPortload(string portEnName, List<CodePortLoad> cachePortLoad, Func<Task<List<MappingPortLoad>>> cacheMapPortLoadFunc)
{
if (string.IsNullOrEmpty(portEnName))
{
return null;
}
// 匹配方式1精准匹配
var portInfo = cachePortLoad.FirstOrDefault(x => x.EnName.Equals(portEnName, StringComparison.OrdinalIgnoreCase));
if (portInfo != null) return portInfo;
// 匹配方式2起始模糊匹配
portInfo = cachePortLoad.FirstOrDefault(x => x.EnName.StartsWith(portEnName, StringComparison.OrdinalIgnoreCase));
if (portInfo != null) return portInfo;
// 匹配方式3完整模糊匹配
portInfo = cachePortLoad.FirstOrDefault(x => x.EnName.Contains(portEnName, StringComparison.OrdinalIgnoreCase));
if (portInfo != null) return portInfo;
// 匹配方式4精准映射匹配
var mapCachePortLoad = await cacheMapPortLoadFunc();
var map = mapCachePortLoad.FirstOrDefault(x => x.Module == CommonConst.RECEIPT_TO_PORTLOAD
&& x.MapName.Equals(portEnName, StringComparison.OrdinalIgnoreCase));
if (map != null)
{
portInfo = cachePortLoad.FirstOrDefault(x => x.Code == map.Code);
if (portInfo != null) return portInfo;
}
return null;
}
public static async Task<CodePort> PlaceDeliveryToPort(string portEnName, List<CodePort> cachePort, Func<Task<List<MappingPort>>> cacheMapPortFunc)
{
if (string.IsNullOrEmpty(portEnName))
{
return null;
}
// 匹配方式1精准匹配
var portInfo = cachePort.FirstOrDefault(x => x.EnName.Equals(portEnName, StringComparison.OrdinalIgnoreCase));
if (portInfo != null) return portInfo;
// 匹配方式2起始模糊匹配
portInfo = cachePort.FirstOrDefault(x => x.EnName.StartsWith(portEnName, StringComparison.OrdinalIgnoreCase));
if (portInfo != null) return portInfo;
// 匹配方式3完整模糊匹配
portInfo = cachePort.FirstOrDefault(x => x.EnName.Contains(portEnName, StringComparison.OrdinalIgnoreCase));
if (portInfo != null) return portInfo;
// 匹配方式4精准映射匹配
var mapCachePort = await cacheMapPortFunc();
var map = mapCachePort.FirstOrDefault(x => x.Module == CommonConst.DELIVERY_TO_PORT
&& x.MapName.Equals(portEnName, StringComparison.OrdinalIgnoreCase));
if (map != null)
{
portInfo = cachePort.FirstOrDefault(x => x.Code == map.Code);
if (portInfo != null) return portInfo;
}
return null;
}
}
}

@ -623,13 +623,9 @@ namespace Myshipping.Application
var portEnName = dto.DataObj.PLACERECEIPT.Split(',')[0]?.Trim();
if (!string.IsNullOrWhiteSpace(portEnName))
{
var cachePort = await _cache.GetAllCodePort();
var cachePortLoad = await _cache.GetAllCodePortLoad();
var portInfo = await PlaceToPortHelper.PlaceReceiptToPortload(portEnName, cachePortLoad, () => _cache.GetAllMappingPortLoad());
var portInfo = cachePort.FirstOrDefault(x => x.EnName.StartsWith(portEnName, StringComparison.OrdinalIgnoreCase));
if (portInfo == null)
{
portInfo = cachePort.FirstOrDefault(x => x.EnName.Contains(portEnName, StringComparison.OrdinalIgnoreCase));
}
if (portInfo == null)
{
_logger.LogInformation("通过收货地城市名称未匹配到港口信息,订舱编号:{SLOT_BOOKING_NO}", dto.DataObj.SLOT_BOOKING_NO);
@ -656,11 +652,8 @@ namespace Myshipping.Application
if (!string.IsNullOrWhiteSpace(portEnName))
{
var cachePort = await _cache.GetAllCodePort();
var portInfo = cachePort.FirstOrDefault(x => x.EnName.StartsWith(portEnName + ',', StringComparison.OrdinalIgnoreCase));
if (portInfo == null)
{
portInfo = cachePort.FirstOrDefault(x => x.EnName.Contains(portEnName, StringComparison.OrdinalIgnoreCase));
}
var portInfo = await PlaceToPortHelper.PlaceDeliveryToPort(portEnName, cachePort, () => _cache.GetAllMappingPort());
if (portInfo == null)
{
@ -1140,6 +1133,7 @@ namespace Myshipping.Application
var list = await _repBase.AsQueryable().Filter(null, true)
.Where(x => x.TenantId == telentId
&& x.IsDeleted == false
&& x.IS_CANCELLATION == false
&& !string.IsNullOrEmpty(x.PLACERECEIPT)
&& !string.IsNullOrEmpty(x.PLACEDELIVERY)
&& (string.IsNullOrEmpty(x.PORTLOADID) || string.IsNullOrEmpty(x.PORTDISCHARGEID)))
@ -1163,9 +1157,10 @@ namespace Myshipping.Application
{
// 解析收货地,得到装货港名称及五字码
var portEnName = item.PLACERECEIPT.Split(',')[0]?.Trim();
if (!string.IsNullOrWhiteSpace(portEnName))
if (!string.IsNullOrWhiteSpace(portEnName)
&& (string.IsNullOrEmpty(item.PORTLOADID) || string.IsNullOrEmpty(item.PORTLOAD)))
{
var portInfo = cachePortLoad.FirstOrDefault(x => x.EnName.Equals(portEnName, StringComparison.OrdinalIgnoreCase));
var portInfo = await PlaceToPortHelper.PlaceReceiptToPortload(portEnName, cachePortLoad, () => _cache.GetAllMappingPortLoad());
if (portInfo != null)
{
if (string.IsNullOrEmpty(item.PORTLOADID))
@ -1189,12 +1184,13 @@ namespace Myshipping.Application
var portEnName2 = item.PLACEDELIVERY.Split(',')[0]?.Trim();
if (!string.IsNullOrWhiteSpace(portEnName2))
{
var portInfo = cachePort.FirstOrDefault(x => x.EnName.StartsWith(portEnName2, StringComparison.OrdinalIgnoreCase));
if (portInfo == null)
{
portInfo = cachePort.FirstOrDefault(x => x.EnName.Contains(portEnName2, StringComparison.OrdinalIgnoreCase));
}
if (portInfo != null)
var portInfo = await PlaceToPortHelper.PlaceDeliveryToPort(portEnName2, cachePort, () => _cache.GetAllMappingPort());
if (portInfo != null
&& (string.IsNullOrEmpty(item.PORTDISCHARGEID)
|| string.IsNullOrEmpty(item.PORTDISCHARGE)
|| string.IsNullOrEmpty(item.PORTDISCHARGE_COUNTRY_CODE)
|| string.IsNullOrEmpty(item.PORTDISCHARGE_COUNTRY)))
{
if (string.IsNullOrEmpty(item.PORTDISCHARGEID))
{
@ -1237,38 +1233,38 @@ namespace Myshipping.Application
x.PORTDISCHARGE_COUNTRY,
}).ExecuteCommandAsync();
var group = updateList.Where(x => !string.IsNullOrEmpty(x.VESSEL)
&& !string.IsNullOrEmpty(x.VOYNO)
&& !string.IsNullOrEmpty(x.CONTRACT_NO)
&& !string.IsNullOrEmpty(x.BOOKING_SLOT_TYPE)
&& !string.IsNullOrEmpty(x.CARRIERID)
&& !string.IsNullOrEmpty(x.PORTLOADID)
&& !string.IsNullOrEmpty(x.PORTDISCHARGEID))
.GroupBy(x => new
{
x.VESSEL,
x.VOYNO,
x.CARRIERID,
x.BOOKING_SLOT_TYPE,
x.PORTDISCHARGEID,
x.PORTLOADID,
x.CONTRACT_NO
}).ToList();
foreach (var item in group)
{
await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new BookingSlotStockUpdateModel
{
BOOKING_SLOT_TYPE = item.Key.BOOKING_SLOT_TYPE,
CARRIERID = item.Key.CARRIERID,
CONTRACT_NO = item.Key.CONTRACT_NO,
VESSEL = item.Key.VESSEL,
VOYNO = item.Key.VOYNO,
PORTLOADID = item.Key.PORTLOADID,
PORTDISCHARGEID = item.Key.PORTDISCHARGEID,
TenantId = UserManager.TENANT_ID
}));
}
//var group = updateList.Where(x => !string.IsNullOrEmpty(x.VESSEL)
// && !string.IsNullOrEmpty(x.VOYNO)
// && !string.IsNullOrEmpty(x.CONTRACT_NO)
// && !string.IsNullOrEmpty(x.BOOKING_SLOT_TYPE)
// && !string.IsNullOrEmpty(x.CARRIERID)
// && !string.IsNullOrEmpty(x.PORTLOADID)
// && !string.IsNullOrEmpty(x.PORTDISCHARGEID))
// .GroupBy(x => new
// {
// x.VESSEL,
// x.VOYNO,
// x.CARRIERID,
// x.BOOKING_SLOT_TYPE,
// x.PORTDISCHARGEID,
// x.PORTLOADID,
// x.CONTRACT_NO
// }).ToList();
//foreach (var item in group)
//{
// await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new BookingSlotStockUpdateModel
// {
// BOOKING_SLOT_TYPE = item.Key.BOOKING_SLOT_TYPE,
// CARRIERID = item.Key.CARRIERID,
// CONTRACT_NO = item.Key.CONTRACT_NO,
// VESSEL = item.Key.VESSEL,
// VOYNO = item.Key.VOYNO,
// PORTLOADID = item.Key.PORTLOADID,
// PORTDISCHARGEID = item.Key.PORTDISCHARGEID,
// TenantId = UserManager.TENANT_ID
// }));
//}
}
}
#endregion
@ -3106,7 +3102,7 @@ namespace Myshipping.Application
BookingSlotBase slotInfo = null;
if(bookingSlotAllocList.Count > 0)
if (bookingSlotAllocList.Count > 0)
{
slotInfo = bookingSlotAllocList.FirstOrDefault().Slot;
}
@ -3114,7 +3110,7 @@ namespace Myshipping.Application
{
slotInfo = _repBase.AsQueryable().Filter(null, true).First(t => t.Id == slotId);
}
if (slotInfo != null)
{
@ -3147,7 +3143,7 @@ namespace Myshipping.Application
}
}
string srcPriceDate = bcSrcDto.PriceCalculationDate.HasValue? bcSrcDto.PriceCalculationDate.Value.ToString("yyyy-MM-dd"): "";
string srcPriceDate = bcSrcDto.PriceCalculationDate.HasValue ? bcSrcDto.PriceCalculationDate.Value.ToString("yyyy-MM-dd") : "";
string targetPriceDate = bcTargetDto.PriceCalculationDate.HasValue ? bcTargetDto.PriceCalculationDate.Value.ToString("yyyy-MM-dd") : "";
//如果原始的没有解析计费日期,就不做提醒了
@ -3359,7 +3355,7 @@ namespace Myshipping.Application
messageInfo.Main.MBlNo = dto.mblNo;
messageInfo.Main.ETD = dto.etd;
messageInfo.Main.TaskTitle = $"重要提醒-{dto.cautionNoticeType.GetDescription()} BLNo:{dto.mblNo} {dto.vessel}/{dto.voyno} {(dto.etd.HasValue? dto.etd.Value.ToString("yyyy-MM-dd"):"")} ";
messageInfo.Main.TaskTitle = $"重要提醒-{dto.cautionNoticeType.GetDescription()} BLNo:{dto.mblNo} {dto.vessel}/{dto.voyno} {(dto.etd.HasValue ? dto.etd.Value.ToString("yyyy-MM-dd") : "")} ";
messageInfo.Main.TaskDesp = $"重要提醒-{dto.cautionNoticeType.GetDescription()} BLNo:{dto.mblNo} {dto.vessel}/{dto.voyno} {(dto.etd.HasValue ? dto.etd.Value.ToString("yyyy-MM-dd") : "")}";
messageInfo.Main.CautionNoticeInfo = new TaskManageOrderCautionNoticeInfo
@ -3473,11 +3469,11 @@ namespace Myshipping.Application
notifyList = new List<CautionNoticeTaskNoitfyDto>()
};
if(!string.IsNullOrWhiteSpace(bcSrcDto.ETD))
if (!string.IsNullOrWhiteSpace(bcSrcDto.ETD))
{
DateTime etd = DateTime.MinValue;
if(DateTime.TryParse(bcSrcDto.ETD,out etd))
if (DateTime.TryParse(bcSrcDto.ETD, out etd))
{
notice.etd = etd;
}

@ -260,6 +260,17 @@ public class CommonConst
public const string CACHE_KEY_BOOKING_LABEL = "BookingLabelList";
#endregion
#region 映射模块
/// <summary>
/// 收货地名称解析装货港港口
/// </summary>
public const string RECEIPT_TO_PORTLOAD = "ReceiptToPortLoad";
/// <summary>
/// 交货地名称解析卸货港港口
/// </summary>
public const string DELIVERY_TO_PORT = "DeliveryToPort";
#endregion
#region 系统运行方式
/// <summary>

@ -822,6 +822,16 @@
标签缓存键
</summary>
</member>
<member name="F:Myshipping.Core.CommonConst.RECEIPT_TO_PORTLOAD">
<summary>
收货地名称解析装货港港口
</summary>
</member>
<member name="F:Myshipping.Core.CommonConst.DELIVERY_TO_PORT">
<summary>
交货地名称解析卸货港港口
</summary>
</member>
<member name="F:Myshipping.Core.CommonConst.RUN_TYPE_HECHUAN">
<summary>
和川(会执行一些和川特有的逻辑)
@ -7340,6 +7350,16 @@
用户Id
</summary>
</member>
<member name="P:Myshipping.Core.Service.GetAuthorizationKeyInput.Authority">
<summary>
权限范围
</summary>
</member>
<member name="P:Myshipping.Core.Service.GetAuthorizationKeyInput.AuthorityType">
<summary>
权限类型(1用户,2公司)
</summary>
</member>
<member name="T:Myshipping.Core.Service.GetTokenByAuthorizationKeyInput">
<summary>
根据授权key 换取token

Loading…
Cancel
Save