diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs
index 86bf4aac..3cecbd47 100644
--- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs
+++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs
@@ -22,6 +22,7 @@ using Myshipping.Core;
using Myshipping.Core.Service;
using NPOI.XSSF.UserModel;
using SqlSugar;
+using StackExchange.Profiling.Internal;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -319,6 +320,7 @@ namespace Myshipping.Application
}
+
///
/// 直接在台账页数据列表上进行保存
///
@@ -456,6 +458,10 @@ namespace Myshipping.Application
public async Task Detail(long id)
{
var slotBase = await _repBase.FirstOrDefaultAsync(u => u.Id == id);
+ if (slotBase == null)
+ {
+ throw Oops.Oh("未查询到此舱位信息,可能已被删除,请重新查询后重试");
+ }
var ctns = await _repCtn.Where(x => x.SLOT_ID == id).ToListAsync();
var rtn = slotBase.Adapt();
@@ -633,18 +639,24 @@ namespace Myshipping.Application
var portEnName = dto.DataObj.PLACEDELIVERY.Split(',')[0]?.Trim();
if (!string.IsNullOrWhiteSpace(portEnName))
{
- var portInfo = (await _cache.GetAllCodePort()).FirstOrDefault(x => x.EnName.Equals(portEnName, StringComparison.OrdinalIgnoreCase));
- if (portInfo != null)
+ var cachePort = await _cache.GetAllCodePort();
+ var portInfo = cachePort.FirstOrDefault(x => x.EnName.StartsWith(portEnName + ','));
+ if (portInfo == null)
+ {
+ portInfo = cachePort.FirstOrDefault(x => x.EnName.Contains(portEnName));
+ }
+
+ if (portInfo == null)
+ {
+ _logger.LogInformation("通过交货地城市名称未匹配到港口信息,订舱编号:{SLOT_BOOKING_NO}", dto.DataObj.SLOT_BOOKING_NO);
+ }
+ else
{
dto.DataObj.PORTDISCHARGE = portInfo.EnName;
dto.DataObj.PORTDISCHARGEID = portInfo.EdiCode;
dto.DataObj.PORTDISCHARGE_COUNTRY = portInfo.Country;
dto.DataObj.PORTDISCHARGE_COUNTRY_CODE = portInfo.CountryCode;
}
- else
- {
- _logger.LogInformation("通过交货地城市名称未匹配到港口信息,订舱编号:{SLOT_BOOKING_NO}", dto.DataObj.SLOT_BOOKING_NO);
- }
}
else
{
@@ -997,12 +1009,12 @@ namespace Myshipping.Application
if (oldValue != newValue)
{
- var fieldName = descriptor.Name;
- if (!string.IsNullOrWhiteSpace(descriptor.Description))
+ var fieldName = descriptor.Description;
+ if (string.IsNullOrWhiteSpace(fieldName))
{
- //fieldName = descriptor.Description;
- continue;
+ fieldName = descriptor.Name;
}
+
waitInsertLogList.Add(new BookingLogDetail
{
PId = bid,
@@ -1066,6 +1078,8 @@ namespace Myshipping.Application
[HttpPost("/BookingSlot/refreshAllStock")]
public async Task RefreshAllStock([FromBody] long telentId)
{
+ await _repBase.DeleteAsync(x => x.TenantId == UserManager.TENANT_ID);
+
var logger = App.GetService>();
BookingSlotStockSubscriber subscriber = new BookingSlotStockSubscriber(logger);
var group = await _repBase.AsQueryable().Filter(null, true)
@@ -1097,6 +1111,150 @@ namespace Myshipping.Application
await subscriber.BookingSlotStock(model);
}
}
+
+ ///
+ /// 根据某租户下面所有收货地、交货地、计算出装货港、卸货港
+ ///
+ [HttpPost("/BookingSlot/refreshAllPort")]
+ public async Task RefreshAllPort([FromBody] long telentId)
+ {
+ 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
+ && !string.IsNullOrEmpty(x.PLACERECEIPT)
+ && !string.IsNullOrEmpty(x.PLACEDELIVERY)
+ && (string.IsNullOrEmpty(x.PORTLOADID) || string.IsNullOrEmpty(x.PORTDISCHARGEID)))
+ .Select(x => new BookingSlotBase()
+ {
+ Id = x.Id,
+ SLOT_BOOKING_NO = x.SLOT_BOOKING_NO,
+ PLACERECEIPT = x.PLACERECEIPT,
+ PLACEDELIVERY = x.PLACEDELIVERY,
+ PORTLOADID = x.PORTLOADID,
+ PORTDISCHARGEID = x.PORTDISCHARGEID,
+ PORTLOAD = x.PORTLOAD,
+ PORTDISCHARGE = x.PORTDISCHARGE,
+ PORTDISCHARGE_COUNTRY_CODE = x.PORTDISCHARGE_COUNTRY_CODE,
+ PORTDISCHARGE_COUNTRY = x.PORTDISCHARGE_COUNTRY,
+ })
+ .ToListAsync();
+ HashSet updateIdSet = new HashSet();
+
+ foreach (var item in list)
+ {
+ // 解析收货地,得到装货港名称及五字码
+ var portEnName = item.PLACERECEIPT.Split(',')[0]?.Trim();
+ if (!string.IsNullOrWhiteSpace(portEnName))
+ {
+ var portInfo = cachePortLoad.FirstOrDefault(x => x.EnName.Equals(portEnName, StringComparison.OrdinalIgnoreCase));
+ if (portInfo != null)
+ {
+ 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;
+ }
+ }
+ else
+ {
+ _logger.LogInformation("通过收货地城市名称未匹配到港口信息,订舱编号:{SLOT_BOOKING_NO}", item.SLOT_BOOKING_NO);
+ }
+ }
+
+ // 解析交货地,得到为卸货港名称及五字码, 以及国家信息
+ 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)
+ {
+ 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;
+ }
+ }
+ 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();
+
+ 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
#region 舱位引入
@@ -1484,6 +1642,43 @@ namespace Myshipping.Application
#endregion
#region 舱位
+ [HttpPost("/BookingSlot/delete")]
+ public async Task Delete([FromQuery] long id)
+ {
+ var slot = await _repBase.FirstOrDefaultAsync(x => x.Id == id);
+ if (slot == null)
+ {
+ throw Oops.Oh("舱位信息不存在");
+ }
+ await _repBase.UpdateAsync(x => x.Id == id, x => new BookingSlotBase()
+ {
+ IsDeleted = true,
+ UpdatedTime = DateTime.Now,
+ UpdatedUserId = UserManager.UserId,
+ UpdatedUserName = UserManager.Name
+ });
+
+ await _repCtn.UpdateAsync(x => x.SLOT_ID == id, x => new BookingSlotCtn()
+ {
+ IsDeleted = true,
+ UpdatedTime = DateTime.Now,
+ UpdatedUserId = UserManager.UserId,
+ UpdatedUserName = UserManager.Name
+ });
+
+ await _publisher.PublishAsync(new ChannelEventSource("BookingSlotStock:Update", new BookingSlotStockUpdateModel
+ {
+ BOOKING_SLOT_TYPE = slot.BOOKING_SLOT_TYPE,
+ CARRIERID = slot.CARRIERID,
+ CONTRACT_NO = slot.CONTRACT_NO,
+ VESSEL = slot.VESSEL,
+ VOYNO = slot.VOYNO,
+ PORTLOADID = slot.PORTLOADID,
+ PORTDISCHARGEID = slot.PORTDISCHARGEID,
+ TenantId = UserManager.TENANT_ID
+ }));
+ }
+
///
/// 分页查询订舱舱位
///
@@ -1965,13 +2160,15 @@ namespace Myshipping.Application
case 4: slot.CONTRACT_NO = value; break;
case 5: slot.BOOKING_SLOT_TYPE_NAME = value; break;
case 6:
- {
- if (DateTime.TryParse(value, out DateTime temp)) slot.ETD = temp; break;
- }
+ slot.ETD = cell.DateCellValue; break;
+ //{
+ // if (DateTime.TryParse(value, out DateTime temp)) slot.ETD = temp; break;
+ //}
case 7:
- {
- if (DateTime.TryParse(value, out DateTime temp)) slot.ETA = temp; break;
- }
+ slot.ETA = cell.DateCellValue; break;
+ //{
+ // if (DateTime.TryParse(value, out DateTime temp)) slot.ETA = temp; break;
+ //}
case 8: slot.BOOKING_PARTY = value; break;
case 9: slot.PLACERECEIPT = value; break;
case 10: slot.PLACEDELIVERY = value; break;
@@ -1983,23 +2180,28 @@ namespace Myshipping.Application
}
case 14:
{
- if (DateTime.TryParse(value, out DateTime temp)) slot.SI_CUT_DATE = temp; break;
+ //if (DateTime.TryParse(value, out DateTime temp)) slot.SI_CUT_DATE = temp; break;
+ slot.SI_CUT_DATE = cell.DateCellValue; break;
}
case 15:
{
- if (DateTime.TryParse(value, out DateTime temp)) slot.VGM_SUBMISSION_CUT_DATE = temp; break;
+ //if (DateTime.TryParse(value, out DateTime temp)) slot.VGM_SUBMISSION_CUT_DATE = temp; break;
+ slot.VGM_SUBMISSION_CUT_DATE = cell.DateCellValue; break;
}
case 16:
{
- if (DateTime.TryParse(value, out DateTime temp)) slot.CY_CUT_DATE = temp; break;
+ //if (DateTime.TryParse(value, out DateTime temp)) slot.CY_CUT_DATE = temp; break;
+ slot.CY_CUT_DATE = cell.DateCellValue; break;
}
case 17:
{
- if (DateTime.TryParse(value, out DateTime temp)) slot.MANIFEST_CUT_DATE = temp; break;
+ //if (DateTime.TryParse(value, out DateTime temp)) slot.MANIFEST_CUT_DATE = temp; break;
+ slot.MANIFEST_CUT_DATE = cell.DateCellValue; break;
}
case 18:
{
- if (DateTime.TryParse(value, out DateTime temp)) slot.MDGF_CUT_DATE = temp; break;
+ //if (DateTime.TryParse(value, out DateTime temp)) slot.MDGF_CUT_DATE = temp; break;
+ slot.MDGF_CUT_DATE = cell.DateCellValue; break;
}
case 19: slot.LANENAME = value; break; //
case 20:
@@ -2008,11 +2210,13 @@ namespace Myshipping.Application
}
case 21:
{
- if (DateTime.TryParse(value, out DateTime temp)) slot.CreatedTime = temp; break;
+ //if (DateTime.TryParse(value, out DateTime temp)) slot.CreatedTime = temp; break;
+ slot.CreatedTime = cell.DateCellValue; break;
}
case 22:
{
- if (DateTime.TryParse(value, out DateTime temp)) slot.PRICE_CALCULATION_DATE = temp; break;
+ //if (DateTime.TryParse(value, out DateTime temp)) slot.PRICE_CALCULATION_DATE = temp; break;
+ slot.PRICE_CALCULATION_DATE = cell.DateCellValue; break;
}
default: break;
}
@@ -2107,6 +2311,40 @@ namespace Myshipping.Application
result.succ = true;
+ var group = data.Keys.Where(x =>
+ !existsNoList.Contains(x.SLOT_BOOKING_NO)
+ && !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 Event.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
+ }));
+ }
}
catch (Exception ex)
{