|
|
|
@ -1091,7 +1091,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingSlot/refreshAllStock")]
|
|
|
|
|
public async Task RefreshAllStock([FromBody] long telentId)
|
|
|
|
|
public async Task RefreshAllStock([FromQuery] long telentId)
|
|
|
|
|
{
|
|
|
|
|
var n = await _repStock.DeleteAsync(x => x.TenantId == telentId);
|
|
|
|
|
|
|
|
|
@ -1131,18 +1131,18 @@ namespace Myshipping.Application
|
|
|
|
|
/// 根据某租户下面所有收货地、交货地、计算出装货港、卸货港
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost("/BookingSlot/refreshAllPort")]
|
|
|
|
|
public async Task RefreshAllPort([FromBody] long telentId)
|
|
|
|
|
public async Task RefreshAllPort([FromQuery] long? telentId, [FromQuery] int? type)
|
|
|
|
|
{
|
|
|
|
|
var cachePort = await _cache.GetAllCodePort();
|
|
|
|
|
var cachePortLoad = await _cache.GetAllCodePortLoad();
|
|
|
|
|
|
|
|
|
|
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)))
|
|
|
|
|
.Where(x => x.IsDeleted == false && x.IS_CANCELLATION == false)
|
|
|
|
|
.WhereIF(telentId != null, x => x.TenantId == telentId)
|
|
|
|
|
.WhereIF(type == 1, x => !string.IsNullOrEmpty(x.PLACERECEIPT) && (string.IsNullOrEmpty(x.PORTLOADID) || string.IsNullOrEmpty(x.PORTLOAD)))
|
|
|
|
|
.WhereIF(type == 2, x => !string.IsNullOrEmpty(x.PLACEDELIVERY) && (string.IsNullOrEmpty(x.PORTDISCHARGEID) || string.IsNullOrEmpty(x.PORTDISCHARGE)))
|
|
|
|
|
.WhereIF(type == null, x => (!string.IsNullOrEmpty(x.PLACERECEIPT) || !string.IsNullOrEmpty(x.PLACEDELIVERY))
|
|
|
|
|
&& (string.IsNullOrEmpty(x.PORTDISCHARGE) || string.IsNullOrEmpty(x.PORTDISCHARGEID) || string.IsNullOrEmpty(x.PORTLOAD) || string.IsNullOrEmpty(x.PORTLOADID)))
|
|
|
|
|
.Select(x => new BookingSlotBase()
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
@ -1168,82 +1168,101 @@ namespace Myshipping.Application
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
// 解析收货地,得到装货港名称及五字码
|
|
|
|
|
var portEnName = item.PLACERECEIPT.Split(',')[0]?.Trim();
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(portEnName)
|
|
|
|
|
&& (string.IsNullOrEmpty(item.PORTLOADID) || string.IsNullOrEmpty(item.PORTLOAD)))
|
|
|
|
|
if (!string.IsNullOrEmpty(item.PLACERECEIPT))
|
|
|
|
|
{
|
|
|
|
|
var portInfo = await PlaceToPortHelper.PlaceReceiptToPortload(portEnName, cachePortLoad, () => _cache.GetAllMappingPortLoad());
|
|
|
|
|
if (portInfo != null)
|
|
|
|
|
var portEnName = item.PLACERECEIPT.Split(',')[0]?.Trim();
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(portEnName)
|
|
|
|
|
&& (string.IsNullOrEmpty(item.PORTLOADID) || string.IsNullOrEmpty(item.PORTLOAD)))
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(item.PORTLOADID))
|
|
|
|
|
var portInfo = await PlaceToPortHelper.PlaceReceiptToPortload(portEnName, cachePortLoad, () => _cache.GetAllMappingPortLoad());
|
|
|
|
|
if (portInfo != null)
|
|
|
|
|
{
|
|
|
|
|
updateIdSet.Add(item.Id);
|
|
|
|
|
item.PORTLOADID = portInfo.EdiCode;
|
|
|
|
|
//if (string.IsNullOrEmpty(item.PORTLOADID))
|
|
|
|
|
{
|
|
|
|
|
updateIdSet.Add(item.Id);
|
|
|
|
|
item.PORTLOADID = portInfo.EdiCode;
|
|
|
|
|
}
|
|
|
|
|
//if (string.IsNullOrEmpty(item.PORTLOAD))
|
|
|
|
|
{
|
|
|
|
|
//updateIdSet.Add(item.Id);
|
|
|
|
|
item.PORTLOAD = portInfo.EnName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(item.PORTLOAD))
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
updateIdSet.Add(item.Id);
|
|
|
|
|
item.PORTLOAD = portInfo.EnName;
|
|
|
|
|
_logger.LogInformation("通过收货地城市名称未匹配到港口信息,订舱编号:{SLOT_BOOKING_NO}", item.SLOT_BOOKING_NO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("通过收货地城市名称未匹配到港口信息,订舱编号:{SLOT_BOOKING_NO}", item.SLOT_BOOKING_NO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 解析交货地,得到为卸货港名称及五字码, 以及国家信息
|
|
|
|
|
var portEnName2 = item.PLACEDELIVERY.Split(',')[0]?.Trim();
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(portEnName2))
|
|
|
|
|
if (!string.IsNullOrEmpty(item.PLACEDELIVERY))
|
|
|
|
|
{
|
|
|
|
|
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)))
|
|
|
|
|
var portEnName2 = item.PLACEDELIVERY.Split(',')[0]?.Trim();
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(portEnName2))
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(item.PORTDISCHARGEID))
|
|
|
|
|
{
|
|
|
|
|
updateIdSet.Add(item.Id);
|
|
|
|
|
item.PORTDISCHARGEID = portInfo.EdiCode;
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(item.PORTDISCHARGE))
|
|
|
|
|
{
|
|
|
|
|
updateIdSet.Add(item.Id);
|
|
|
|
|
item.PORTDISCHARGE = portInfo.EnName;
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(item.PORTDISCHARGE_COUNTRY_CODE))
|
|
|
|
|
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)))
|
|
|
|
|
{
|
|
|
|
|
updateIdSet.Add(item.Id);
|
|
|
|
|
item.PORTDISCHARGE_COUNTRY_CODE = portInfo.CountryCode;
|
|
|
|
|
//if (string.IsNullOrEmpty(item.PORTDISCHARGEID))
|
|
|
|
|
{
|
|
|
|
|
updateIdSet.Add(item.Id);
|
|
|
|
|
item.PORTDISCHARGEID = portInfo.EdiCode;
|
|
|
|
|
}
|
|
|
|
|
//if (string.IsNullOrEmpty(item.PORTDISCHARGE))
|
|
|
|
|
{
|
|
|
|
|
//updateIdSet.Add(item.Id);
|
|
|
|
|
item.PORTDISCHARGE = portInfo.EnName;
|
|
|
|
|
}
|
|
|
|
|
//if (string.IsNullOrEmpty(item.PORTDISCHARGE_COUNTRY_CODE))
|
|
|
|
|
{
|
|
|
|
|
//updateIdSet.Add(item.Id);
|
|
|
|
|
item.PORTDISCHARGE_COUNTRY_CODE = portInfo.CountryCode;
|
|
|
|
|
}
|
|
|
|
|
//if (string.IsNullOrEmpty(item.PORTDISCHARGE_COUNTRY))
|
|
|
|
|
{
|
|
|
|
|
//updateIdSet.Add(item.Id);
|
|
|
|
|
item.PORTDISCHARGE_COUNTRY = portInfo.Country;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(item.PORTDISCHARGE_COUNTRY))
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
updateIdSet.Add(item.Id);
|
|
|
|
|
item.PORTDISCHARGE_COUNTRY = portInfo.Country;
|
|
|
|
|
_logger.LogInformation("通过交货地城市名称未匹配到港口信息,订舱编号:{SLOT_BOOKING_NO}", item.SLOT_BOOKING_NO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("通过交货地城市名称未匹配到港口信息,订舱编号:{SLOT_BOOKING_NO}", item.SLOT_BOOKING_NO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (updateIdSet.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var updateList = list.Where(x => updateIdSet.Contains(x.Id)).ToList();
|
|
|
|
|
await _repBase.AsUpdateable(updateList).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.PORTLOADID,
|
|
|
|
|
x.PORTDISCHARGEID,
|
|
|
|
|
x.PORTLOAD,
|
|
|
|
|
x.PORTDISCHARGE,
|
|
|
|
|
x.PORTDISCHARGE_COUNTRY_CODE,
|
|
|
|
|
x.PORTDISCHARGE_COUNTRY,
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
await _repBase.AsUpdateable(updateList)
|
|
|
|
|
.UpdateColumnsIF(type == 1, x => new
|
|
|
|
|
{
|
|
|
|
|
x.PORTLOADID,
|
|
|
|
|
x.PORTLOAD,
|
|
|
|
|
})
|
|
|
|
|
.UpdateColumnsIF(type == 2, x => new
|
|
|
|
|
{
|
|
|
|
|
x.PORTDISCHARGEID,
|
|
|
|
|
x.PORTDISCHARGE,
|
|
|
|
|
x.PORTDISCHARGE_COUNTRY_CODE,
|
|
|
|
|
x.PORTDISCHARGE_COUNTRY,
|
|
|
|
|
})
|
|
|
|
|
.UpdateColumnsIF(type == null, x => new
|
|
|
|
|
{
|
|
|
|
|
x.PORTLOADID,
|
|
|
|
|
x.PORTDISCHARGEID,
|
|
|
|
|
x.PORTLOAD,
|
|
|
|
|
x.PORTDISCHARGE,
|
|
|
|
|
x.PORTDISCHARGE_COUNTRY_CODE,
|
|
|
|
|
x.PORTDISCHARGE_COUNTRY,
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
var group = updateList.Where(x => !string.IsNullOrEmpty(x.VESSEL)
|
|
|
|
|
&& !string.IsNullOrEmpty(x.VOYNO)
|
|
|
|
@ -1263,21 +1282,24 @@ namespace Myshipping.Application
|
|
|
|
|
x.CONTRACT_NO,
|
|
|
|
|
x.TenantId
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var item in group)
|
|
|
|
|
_ = Task.Run(async () =>
|
|
|
|
|
{
|
|
|
|
|
await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new BookingSlotStockUpdateModel
|
|
|
|
|
foreach (var item in group)
|
|
|
|
|
{
|
|
|
|
|
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 = item.Key.TenantId
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
await Task.Delay(1000);
|
|
|
|
|
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 = item.Key.TenantId
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|