diff --git a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs
index a1159b9a..3f4da1f0 100644
--- a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs
+++ b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs
@@ -1115,5 +1115,11 @@ public static class MultiLanguageConst
[Description("解析日志异常,原因:{0}")]
public const string BookingSlotAuditLogDeserializeError = "BookingSlot_AuditLogDeserialize_Error";
+ ///
+ /// 执行舱位失败,原因:{0}
+ ///
+ [Description("执行舱位失败,原因:{0}")]
+ public const string BookingSlotApiReceiveError = "BookingSlot_ApiReceive_Error";
+
#endregion
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeVesselService.cs b/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeVesselService.cs
index 5bb0c80d..74e49402 100644
--- a/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeVesselService.cs
+++ b/ds-wms-service/DS.WMS.Core/Code/Interface/ICodeVesselService.cs
@@ -1,6 +1,7 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Code.Dtos;
+using DS.WMS.Core.Op.Dtos;
namespace DS.WMS.Core.Code.Interface;
@@ -73,4 +74,16 @@ public interface ICodeVesselService
///
///
public DataResult BatchDelCodeVessel(IdModel req);
+
+ ///
+ /// 获取所有船名基础数据
+ ///
+ /// 返回船名基础数据列表
+ Task>> GetAllList();
+
+ ///
+ /// 加载缓存
+ ///
+ ///
+ Task> LoadCache(bool isReload = false);
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Code/Method/CodeVesselService.cs b/ds-wms-service/DS.WMS.Core/Code/Method/CodeVesselService.cs
index ddbc4800..0f76bfd1 100644
--- a/ds-wms-service/DS.WMS.Core/Code/Method/CodeVesselService.cs
+++ b/ds-wms-service/DS.WMS.Core/Code/Method/CodeVesselService.cs
@@ -6,8 +6,11 @@ using DS.Module.UserModule;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Code.Interface;
+using DS.WMS.Core.Sys.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
+using Newtonsoft.Json;
+using NPOI.SS.Formula.Functions;
using SqlSugar;
namespace DS.WMS.Core.Code.Method;
@@ -18,6 +21,8 @@ public class CodeVesselService:ICodeVesselService
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
+ private readonly ISysCacheService _sysCacheService;
+
///
///
///
@@ -28,6 +33,7 @@ public class CodeVesselService:ICodeVesselService
db = _serviceProvider.GetRequiredService();
user = _serviceProvider.GetRequiredService();
saasService = _serviceProvider.GetRequiredService();
+ _sysCacheService = _serviceProvider.GetRequiredService();
}
public DataResult> GetListByPage(PageRequest request)
@@ -178,4 +184,31 @@ public class CodeVesselService:ICodeVesselService
}
return DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess);
}
+
+ ///
+ /// 获取所有船名基础数据
+ ///
+ /// 返回船名基础数据列表
+ public async Task>> GetAllList()
+ {
+ var list = await db.Queryable().Where(a => a.Status == StatusEnum.Enable)
+ .Select().ToListAsync();
+
+ if (list.Count > 0)
+ return DataResult>.Success(list);
+
+ return DataResult>.FailedData(list);
+ }
+
+ ///
+ /// 加载缓存
+ ///
+ /// 是否强制加载
+ /// 返回回执
+ public async Task> LoadCache(bool isReload = false)
+ {
+ var list = GetAllList().GetAwaiter().GetResult().Data;
+
+ return await _sysCacheService.LoadCache(JsonConvert.SerializeObject(list),Sys.Method.SysCacheKeyEnum.CommonCodeVessel, isReload);
+ }
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/BookingSlotBaseSaveOutput.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/BookingSlotBaseSaveOutput.cs
index 0104e1d5..b47afb0e 100644
--- a/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/BookingSlotBaseSaveOutput.cs
+++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/BookingSlotBaseSaveOutput.cs
@@ -328,27 +328,27 @@ namespace DS.WMS.Core.Op.Dtos
///
/// 箱型代码
///
- public string CTNCODE { get; set; }
+ public string CtnCode { get; set; }
///
/// 箱型名称
///
- public string CTNALL { get; set; }
+ public string CtnAll { get; set; }
///
/// 箱量
///
- public int CTNNUM { get; set; }
+ public int CtnNum { get; set; }
///
/// 箱号
///
- public string CNTRNO { get; set; }
+ public string CntrNo { get; set; }
///
/// 箱封号
///
- public string SEALNO { get; set; }
+ public string SealNo { get; set; }
///
/// 件数
@@ -358,7 +358,7 @@ namespace DS.WMS.Core.Op.Dtos
///
/// 包装
///
- public string KINDPKGS { get; set; }
+ public string KindPKGs { get; set; }
///
/// 毛重
@@ -373,32 +373,32 @@ namespace DS.WMS.Core.Op.Dtos
///
/// 皮重
///
- public decimal TAREWEIGHT { get; set; }
+ public decimal TareWeight { get; set; }
///
/// 箱状态
///
- public string CTNSTATUS { get; set; }
+ public string CtnStatus { get; set; }
///
/// 称重方式
///
- public string WEIGHTYPE { get; set; }
+ public string WeighType { get; set; }
///
/// 称重重量
///
- public decimal WEIGHKGS { get; set; }
+ public decimal WeighKGS { get; set; }
///
/// 称重联系人
///
- public string WEIGHATTN { get; set; }
+ public string WeighAttn { get; set; }
///
/// 总计箱量
///
- public int TOTALNUM { get; set; }
+ public int TotalNum { get; set; }
}
///
diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/BookingSlotStockUpdateModel.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/BookingSlotStockUpdateModel.cs
index 773e523b..978241ad 100644
--- a/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/BookingSlotStockUpdateModel.cs
+++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/BookingSlotStockUpdateModel.cs
@@ -15,27 +15,32 @@ namespace DS.WMS.Core.Op.Dtos
///
/// 船名
///
- public string VESSEL { get; set; }
+ public string Vessel { get; set; }
///
/// 航次号
///
- public string VOYNO { get; set; }
+ public string Voyno { get; set; }
///
/// 合约号
///
- public string CONTRACT_NO { get; set; }
+ public string ContractNo { get; set; }
///
/// 订舱方式 CONTRACT_ORDER-合约订舱;SPOT_ORDER-SPOT订舱
///
- public string BOOKING_SLOT_TYPE { get; set; }
+ public string BookingSlotType { get; set; }
+
+ ///
+ /// 船公司主键
+ ///
+ public long CarrierId { get; set; }
///
/// 船公司代号
///
- public string CARRIERID { get; set; }
+ public string CarrierCode { get; set; }
/////
///// 收货地
@@ -49,11 +54,11 @@ namespace DS.WMS.Core.Op.Dtos
///
/// 装货港代码
///
- public string PORTLOADID { get; set; }
+ public string PortLoadId { get; set; }
///
/// 卸货港代码
///
- public string PORTDISCHARGEID { get; set; }
+ public string PortDischargeId { get; set; }
///
/// 租户Id
///
diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/ParserBCInfoDto.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/ParserBCInfoDto.cs
index 5c664fc5..ceb8a1ca 100644
--- a/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/ParserBCInfoDto.cs
+++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/ParserBCInfoDto.cs
@@ -408,7 +408,7 @@ namespace DS.WMS.Core.Op.Dtos
///
/// 箱量
///
- public Nullable CTNNUM { get; set; }
+ public Nullable CtnNum { get; set; }
///
/// 件数
diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/TaskManageExcuteResultDto.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/TaskManageExcuteResultDto.cs
new file mode 100644
index 00000000..39eaff13
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/BookingSlot/TaskManageExcuteResultDto.cs
@@ -0,0 +1,199 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DS.WMS.Core.Op.Dtos
+{
+ ///
+ ///
+ ///
+ public class TaskManageExcuteResultDto
+ {
+ ///
+ /// 是否成功 true=成功 false=失败
+ ///
+ public bool succ { get; set; } = false;
+
+ ///
+ /// 状态 0-成功
+ ///
+ public int status { get; set; } = 0;
+
+ ///
+ /// 返回消息
+ ///
+ public string msg { get; set; }
+
+ ///
+ /// 总记录数
+ ///
+ public int total { get; set; }
+
+ ///
+ /// 当前页列表数据
+ ///
+ public object rows { get; set; }
+
+ ///
+ /// 比对详情
+ ///
+ public CompareResultInfo extra { get; set; }
+
+ ///
+ /// 比对展示详情
+ ///
+ public List extra2 { get; set; }
+
+ ///
+ /// 扩展值
+ ///
+ public object extra3 { get; set; }
+
+ ///
+ /// 场站统计详情
+ ///
+ public YardStatInfo yardStatInfo { get; set; }
+ }
+
+ public class CompareResultInfo
+ {
+ ///
+ /// 原数据主键(请求方业务主键)
+ ///
+ public string OrigPKId { get; set; }
+
+ ///
+ /// 比对ID
+ ///
+ public string TaskCompareId { get; set; }
+
+ ///
+ /// 原数据主单号
+ ///
+ public string MBlNo { get; set; }
+
+ ///
+ /// 是否存在差异 true-存在差异 false-一致
+ ///
+ public bool IsExistsDiff { get; set; } = false;
+
+ ///
+ /// 比较时间
+ ///
+ public DateTime CompareTime { get; set; }
+
+ ///
+ /// 明细
+ ///
+ public List DetailList { get; set; }
+
+ ///
+ /// 展示明细
+ ///
+ public List ShowDetailList { get; set; }
+
+ ///
+ /// 人工反馈结果
+ ///
+ public FeedBackResult ManualFeedBackResult { get; set; }
+ }
+
+
+
+ ///
+ ///
+ ///
+ public class TaskManageExcuteCommonResultDto
+ {
+ ///
+ /// 是否成功 true=成功 false=失败
+ ///
+ public bool succ { get; set; } = false;
+
+ ///
+ /// 状态 0-成功
+ ///
+ public int status { get; set; } = 0;
+
+ ///
+ /// 返回消息
+ ///
+ public string msg { get; set; }
+
+ ///
+ /// 总记录数
+ ///
+ public int total { get; set; }
+
+ ///
+ /// 当前页列表数据
+ ///
+ public object rows { get; set; }
+
+ ///
+ /// 扩展值
+ ///
+ public object extra { get; set; }
+
+ ///
+ /// 扩展值2
+ ///
+ public object extra2 { get; set; }
+
+ ///
+ /// 扩展值3
+ ///
+ public object extra3 { get; set; }
+ }
+
+ ///
+ /// 下货纸场站箱信息统计
+ ///
+ public class YardStatInfo
+ {
+ ///
+ /// 总箱数
+ ///
+ public int ContaNum { get; set; }
+
+ ///
+ /// 最新返场日期
+ ///
+ public Nullable LstReturnYardDate { get; set; }
+
+ ///
+ /// 有返场日期箱数
+ ///
+ public int ExistsReturnYardDateCtnNum { get; set; }
+
+ ///
+ /// 有集装箱号的合计数
+ ///
+ public int ExistsCtnNo { get; set; }
+ }
+
+ public class FeedBackResult
+ {
+ ///
+ /// 操作人
+ ///
+ public string OperUser { get; set; }
+
+ ///
+ /// 操作时间
+ ///
+ public DateTime OperTime { get; set; }
+
+ ///
+ /// 备注
+ ///
+ public string OperNote { get; set; }
+
+ ///
+ /// 原因
+ ///
+ public string Reason { get; set; }
+ }
+}
diff --git a/ds-wms-service/DS.WMS.Core/Op/Interface/BookingSlot/IBookingSlotStockService.cs b/ds-wms-service/DS.WMS.Core/Op/Interface/BookingSlot/IBookingSlotStockService.cs
new file mode 100644
index 00000000..24ee9d16
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Op/Interface/BookingSlot/IBookingSlotStockService.cs
@@ -0,0 +1,20 @@
+using DS.Module.Core;
+using DS.WMS.Core.Op.Dtos;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DS.WMS.Core.Op.Interface
+{
+ public interface IBookingSlotStockService
+ {
+ ///
+ /// 计算舱位库存
+ ///
+ /// 请求参数
+ /// 返回回执
+ Task> BookingSlotStock(BookingSlotStockUpdateModel paraObj);
+ }
+}
diff --git a/ds-wms-service/DS.WMS.Core/Op/Interface/SpaceBooking/ISpaceBookingMSKAPIService.cs b/ds-wms-service/DS.WMS.Core/Op/Interface/SpaceBooking/ISpaceBookingMSKAPIService.cs
index 3369c19e..7e12e935 100644
--- a/ds-wms-service/DS.WMS.Core/Op/Interface/SpaceBooking/ISpaceBookingMSKAPIService.cs
+++ b/ds-wms-service/DS.WMS.Core/Op/Interface/SpaceBooking/ISpaceBookingMSKAPIService.cs
@@ -112,5 +112,11 @@ namespace DS.WMS.Core.Op.Interface
/// 返回详情
Task> GetInitInfo();
+
+ ///
+ /// 获取预订舱途径选择
+ ///
+ /// 返回回执
+ Task>> GetBookingChannelSelectShow();
}
}
diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs
index e7ae58b2..8bf03768 100644
--- a/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs
+++ b/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotService.cs
@@ -20,6 +20,18 @@ using SqlSugar.IOC;
using Newtonsoft.Json;
using NLog;
using DS.WMS.Core.Sys.Interface;
+using Microsoft.AspNetCore.Http;
+using LanguageExt.Common;
+using DS.Module.Core.Helpers;
+using NPOI.SS.Formula.Functions;
+using System.Text.RegularExpressions;
+using DS.WMS.Core.Sys.Method;
+using DS.WMS.Core.Map.Dtos;
+using Org.BouncyCastle.Ocsp;
+using DS.WMS.Core.Code.Entity;
+using DS.WMS.Core.Map.Entity;
+using DS.WMS.Core.Code.Dtos;
+using System.Net.Http.Headers;
namespace DS.WMS.Core.Op.Method
{
@@ -32,9 +44,33 @@ namespace DS.WMS.Core.Op.Method
private readonly ISeaExportService _seaExportService;
private readonly IBookingLabelService _bookingLabelService;
private readonly ILogAuditService _logAuditService;
+ private readonly ISysCacheService _sysCacheService;
+ private readonly ISysFileService _sysFileService;
+ private readonly IBookingSlotStockService _bookingSlotStockService;
+ private readonly string bcCompareUrl;
private static readonly NLog.Logger Logger = LogManager.GetCurrentClassLogger();
+ const string CONST_BC_FILE_CODE = "bc";
+ const string CONST_BC_FILE_NAME = "Booking Confirmation";
+
+ const string CONST_BC_NOTICE_FILE_CODE = "bc_notice";
+ const string CONST_BC_NOTICE_FILE_NAME = "Booking Confirmation Notice";
+
+ const string CONST_BC_MODIFY_FILE_CODE = "bc_modify";
+ const string CONST_BC_MODIFY_FILE_NAME = "Booking Amendment";
+
+ const string CONST_BC_MODIFY_NOTICE_FILE_CODE = "bc_modifynotice";
+ const string CONST_BC_MODIFY_NOTICE_FILE_NAME = "Booking Amendment Notice";
+
+ //收货地名称解析装货港港口
+ const string RECEIPT_TO_PORTLOAD = "ReceiptToPortLoad";
+
+ //交货地名称解析卸货港港口
+ const string DELIVERY_TO_PORT = "DeliveryToPort";
+
+
+
public BookingSlotService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
@@ -44,6 +80,11 @@ namespace DS.WMS.Core.Op.Method
_seaExportService = _serviceProvider.GetRequiredService();
_bookingLabelService = _serviceProvider.GetRequiredService();
_logAuditService = _serviceProvider.GetRequiredService();
+ _sysCacheService = _serviceProvider.GetRequiredService();
+ _sysFileService = _serviceProvider.GetRequiredService();
+ _bookingSlotStockService = _serviceProvider.GetRequiredService();
+
+ bcCompareUrl = AppSetting.app(new string[] { "BCCompare", "Url" });
}
#region 保存舱位
@@ -660,5 +701,864 @@ namespace DS.WMS.Core.Op.Method
return DataResult.Success(rtn);
}
#endregion
+
+ #region 舱位接收保存、取消接口
+ ///
+ /// 舱位接收保存、取消接口
+ ///
+ /// 请求详情(JSON)
+ /// BC附件
+ /// BC修改附件
+ /// 返回回执
+ public async Task> ApiReceive(string jsonData, IFormFile file = null, IFormFile modifyFile = null)
+ {
+ long id = 0;
+
+ try
+ {
+ Logger.Log(NLog.LogLevel.Info, $"jsonData={jsonData} 接收请求舱位报文");
+
+ BookingSlotBaseApiDto dto = JsonConvert.DeserializeObject(jsonData);
+
+ DynameFileInfo bcFile = null;
+ DynameFileInfo bcNoticeFile = null;
+
+ if (file != null)
+ {
+ bcFile = new DynameFileInfo
+ {
+ FileBytes = file.ToByteArray(),
+ FileName = file.FileName
+ };
+ }
+
+ if (modifyFile != null)
+ {
+ bcNoticeFile = new DynameFileInfo
+ {
+ FileBytes = modifyFile.ToByteArray(),
+ FileName = modifyFile.FileName
+ };
+ }
+
+ var rlt = await InnerApiReceive(dto, bcFile, bcNoticeFile);
+
+ id = rlt.Data;
+ }
+ catch (Exception ex)
+ {
+ Logger.Log(NLog.LogLevel.Error, $"执行舱位失败,原因:{ex.Message}");
+
+ return DataResult.FailedData(id, string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotApiReceiveError)), ex.Message));
+ }
+
+ if (id == 0)
+ return DataResult.FailedData(id);
+
+ return DataResult.Success(id);
+ }
+ #endregion
+
+ #region 舱位接收保存、取消接口(内部接口)
+ ///
+ /// 舱位接收保存、取消接口(内部接口)
+ ///
+ /// 舱位详情
+ /// 原文件
+ /// 修改文件
+ /// 返回回执
+ public async Task> InnerApiReceive(BookingSlotBaseApiDto dto, DynameFileInfo file = null, DynameFileInfo modifyFile = null)
+ {
+ long id = 0;
+
+ var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
+
+ //接口方法直接调用save、delete等方法会报错,可能因为非token授权登录导致,故重写一遍保存、删除代码
+ if (dto.OpType == "add" || dto.OpType == "update" || dto.OpType == "del" || dto.OpType == "cancellation")
+ {
+ //翻译船公司
+ if (!string.IsNullOrWhiteSpace(dto.DataObj.CarrierCode) && string.IsNullOrWhiteSpace(dto.DataObj.CarrierCode))
+ {
+ var allCarrierList = await _sysCacheService.GetAllCommonCodeFromCache(SysCacheKeyEnum.CommonMappingCarrier);
+
+ if (allCarrierList.Succeeded)
+ {
+ var carrierInfo = allCarrierList.Data.Where(t => t.Code.Equals(dto.DataObj.CarrierCode, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
+
+ if (carrierInfo != null)
+ {
+ dto.DataObj.Carrier = carrierInfo.MapName?.Trim();
+ }
+ }
+ }
+
+ //翻译箱型代码
+ if (dto.DataObj.CtnList != null && dto.DataObj.CtnList.Count > 0 &&
+ dto.DataObj.CtnList.Any(t => string.IsNullOrWhiteSpace(t.CtnCode)))
+ {
+ List ctnCodeList = new List();
+
+ var allCtnCodeList = await _sysCacheService.GetAllCommonCodeFromCache(SysCacheKeyEnum.CommonMappingCarrier);
+
+ if (allCtnCodeList.Succeeded)
+ {
+ ctnCodeList = allCtnCodeList.Data;
+ }
+
+ dto.DataObj.CtnList.ForEach(t =>
+ {
+ if (!string.IsNullOrWhiteSpace(t.CtnAll) && string.IsNullOrWhiteSpace(t.CtnCode))
+ {
+ var ctnCode = ctnCodeList.FirstOrDefault(a => !string.IsNullOrWhiteSpace(a.CtnName) &&
+ a.CtnName.Equals(t.CtnAll, StringComparison.OrdinalIgnoreCase));
+
+ if (ctnCode != null)
+ t.CtnCode = $"{ctnCode.CtnSize}{ctnCode.CtnType}";
+ }
+ });
+ }
+
+ List portCodeList = new List();
+
+ // 解析收货地,得到装货港名称及五字码
+ if (!string.IsNullOrWhiteSpace(dto.DataObj.PlaceReceipt))
+ {
+ var portEnName = dto.DataObj.PlaceReceipt.Split(',')[0]?.Trim();
+
+ //这里CMA的收货地全称放在了括号里面
+ if (dto.DataObj.CarrierCode.Equals("CMA", StringComparison.OrdinalIgnoreCase))
+ {
+ if (!string.IsNullOrWhiteSpace(dto.DataObj.PlaceReceipt))
+ dto.DataObj.PlaceReceipt = dto.DataObj.PlaceReceipt.Replace("(", "(").Replace(")", ")");
+
+ if (dto.DataObj.PlaceReceipt.IndexOf("(") >= 0)
+ {
+ string currStr = Regex.Match(dto.DataObj.PlaceReceipt, "(?<=\\().*(?=\\))").Value?.Trim();
+
+ portEnName = currStr.Split(',')[0]?.Trim();
+ }
+ }
+
+
+ if (!string.IsNullOrWhiteSpace(portEnName))
+ {
+ var allPortCodeList = await _sysCacheService.GetAllCommonCodeFromCache(SysCacheKeyEnum.CommonCodePort);
+
+ if (allPortCodeList.Succeeded)
+ {
+ portCodeList = allPortCodeList.Data;
+ }
+
+ //var cachePortLoad = await _cache.GetAllCodePortLoad();
+ var portInfo = await PlaceReceiptToPortload(portEnName, portCodeList, () => _sysCacheService.GetAllCommonCodeFromCache(SysCacheKeyEnum.CommonCodePort));
+
+ if (!portInfo.Succeeded)
+ {
+ Logger.Log(NLog.LogLevel.Info, $"通过收货地城市名称未匹配到港口信息,订舱编号:{dto.DataObj.SlotBookingNo}");
+ }
+ else
+ {
+ dto.DataObj.PortLoad = portInfo.Data.PortName;
+ dto.DataObj.PortLoadId = portInfo.Data.EdiCode;
+ }
+ }
+ else
+ {
+ Logger.Log(NLog.LogLevel.Info, $"收货地分割后得到的城市名称为空,订舱编号:{dto.DataObj.SlotBookingNo}");
+ }
+ }
+ else
+ {
+ Logger.Log(NLog.LogLevel.Info, $"收货地为空,订舱编号:{dto.DataObj.SlotBookingNo}");
+ }
+
+
+ // 解析交货地,得到为卸货港名称及五字码, 以及国家信息
+ if (!string.IsNullOrWhiteSpace(dto.DataObj.PlaceDelivery))
+ {
+ var portEnName = dto.DataObj.PlaceDelivery.Split(',')[0]?.Trim();
+
+ //这里CMA的收货地全称放在了括号里面
+ if (dto.DataObj.CarrierCode.Equals("CMA", StringComparison.OrdinalIgnoreCase))
+ {
+ if (!string.IsNullOrWhiteSpace(dto.DataObj.PlaceDelivery))
+ dto.DataObj.PlaceDelivery = dto.DataObj.PlaceDelivery.Replace("(", "(").Replace(")", ")");
+
+ if (dto.DataObj.PlaceDelivery.IndexOf("(") >= 0)
+ {
+ string currStr = Regex.Match(dto.DataObj.PlaceDelivery, "(?<=\\().*(?=\\))").Value?.Trim();
+
+ portEnName = currStr.Split(',')[0]?.Trim();
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(portEnName))
+ {
+ if (portCodeList.Count == 0)
+ {
+ var allPortCodeList = await _sysCacheService.GetAllCommonCodeFromCache(SysCacheKeyEnum.CommonCodePort);
+
+ if (allPortCodeList.Succeeded)
+ {
+ portCodeList = allPortCodeList.Data;
+ }
+ }
+
+ var portInfo = await PlaceDeliveryToPort(portEnName, portCodeList, () => _sysCacheService.GetAllCommonCodeFromCache(SysCacheKeyEnum.CommonCodePort));
+
+ if (portInfo.Succeeded)
+ {
+ Logger.Log(NLog.LogLevel.Info, $"通过交货地城市名称未匹配到港口信息,订舱编号:{dto.DataObj.SlotBookingNo}");
+ }
+ else
+ {
+ var allCountryCodeList = await _sysCacheService.GetAllCommonCodeFromCache(SysCacheKeyEnum.CommonCodeCountry);
+
+ if(allCountryCodeList.Succeeded)
+ {
+ var countryInfo = allCountryCodeList.Data.FirstOrDefault(p => p.Id == portInfo.Data.CountryId);
+
+
+ dto.DataObj.PortDischargeCountry = countryInfo?.CountryEnName;
+ dto.DataObj.PortDischargeCountryCode = countryInfo?.CountryCode;
+ }
+
+ dto.DataObj.PortDischarge = portInfo.Data.PortName;
+ dto.DataObj.PortDischargeId = portInfo.Data.EdiCode;
+
+
+
+ }
+ }
+ else
+ {
+ Logger.Log(NLog.LogLevel.Info, $"交货地分割后得到的城市名称为空,订舱编号:{ dto.DataObj.SlotBookingNo}");
+ }
+ }
+ else
+ {
+ Logger.Log(NLog.LogLevel.Info, $"交货地为空,订舱编号:{dto.DataObj.SlotBookingNo}");
+ }
+
+ if (string.IsNullOrWhiteSpace(dto.DataObj.CtnStat))
+ {
+ if (dto.DataObj.CtnList != null && dto.DataObj.CtnList.Count > 0)
+ {
+ dto.DataObj.CtnStat = string.Join(",", dto.DataObj.CtnList.GroupBy(a => a.CtnAll).Select(a =>
+ $"{a.Key}*{a.Select(b => b.CtnNum).Sum()}").ToArray());
+ }
+
+ }
+
+ //自动转换对应标签
+
+ BookingSlotBase model = null;
+ if (dto.OpType == "add")
+ {
+ var c = tenantDb.Queryable().Where(x => x.SlotBookingNo == dto.DataObj.SlotBookingNo).Count();
+ if (c > 0)
+ {
+ //订舱提单号已存在
+ throw new Exception(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotSlotBookingNoExists)));
+ }
+
+ model = dto.DataObj.Adapt();
+ await tenantDb.Insertable(model).ExecuteReturnEntityAsync();
+
+ id = model.Id;
+
+ foreach (var ctn in dto.DataObj.CtnList)
+ {
+ var newCtn = ctn.Adapt();
+ newCtn.SlotId = model.Id;
+ await tenantDb.Insertable(newCtn).ExecuteCommandAsync();
+ }
+
+ //await InsLog("Add", model.Id, "新增舱位");
+
+ string batchNo = GuidHelper.GetSnowflakeId();
+
+ //处理附件
+ if (file != null)
+ {
+ Logger.Log(NLog.LogLevel.Info, $"请求文件名:{file.FileName}");
+
+ var fileRlt = await _sysFileService.SaveFileDirect(model.Id.ToString(), file.FileBytes, batchNo, file.FileName, "bcfiles");
+
+ var fileFullPath = fileRlt.Data;
+
+ Logger.Log(NLog.LogLevel.Info, $"保存文件路径:{fileFullPath}");
+
+ if (!string.IsNullOrWhiteSpace(fileFullPath))
+ {
+ //将格式单附件写入订舱的附件
+ SaveEDIFile(id, fileFullPath, file.FileName, long.Parse(user.TenantId),
+ CONST_BC_FILE_CODE, CONST_BC_FILE_NAME).GetAwaiter();
+ }
+ }
+
+ if (modifyFile != null)
+ {
+ Logger.Log(NLog.LogLevel.Info, $"请求文件名(变更文件):{modifyFile.FileName}");
+
+ var fileRlt = await _sysFileService.SaveFileDirect(model.Id.ToString(), modifyFile.FileBytes, batchNo, modifyFile.FileName, "bcnoticefiles");
+
+ var fileFullPath = fileRlt.Data;
+
+ Logger.Log(NLog.LogLevel.Info, $"保存文件路径(变更文件):{fileFullPath}");
+
+ if (!string.IsNullOrWhiteSpace(fileFullPath))
+ {
+ //将格式单附件写入订舱的附件
+ SaveEDIFile(id, fileFullPath, modifyFile.FileName, long.Parse(user.TenantId),
+ CONST_BC_NOTICE_FILE_CODE, CONST_BC_NOTICE_FILE_NAME).GetAwaiter();
+ }
+ }
+
+ //触发标签自动绑定
+ await GenerateSlotLabel(dto, id);
+ }
+ else if (dto.OpType == "update")
+ {
+ model = await tenantDb.Queryable().FirstAsync(x => x.SlotBookingNo == dto.DataObj.SlotBookingNo);
+ if (model == null)
+ {
+ //throw Oops.Bah($"未找到订舱编号为 {dto.DataObj.SlotBookingNo} 的数据");
+ }
+
+ id = model.Id;
+
+ //生成待比对详情
+ ParserBCInfoDto bcSrcDto = new ParserBCInfoDto();
+
+ try
+ {
+ bcSrcDto = model.Adapt();
+ }
+ catch (Exception ex)
+ {
+ Logger.Log(NLog.LogLevel.Info, $"slotId={model.Id} 映射数据库对象请求对应异常,原因:{ex.Message}");
+
+ //throw Oops.Bah($"slotId={model.Id} 映射数据库对象请求对应异常,原因:{ex.Message}");
+ }
+
+ ParserBCInfoDto bcTargetDto = new ParserBCInfoDto();
+
+ try
+ {
+ bcTargetDto = dto.DataObj.Adapt();
+ }
+ catch (Exception ex)
+ {
+ Logger.Log(NLog.LogLevel.Info, $"slotId={model.Id} 映射推送的舱位请求对应异常,原因:{ex.Message}");
+
+ //throw Oops.Bah($"slotId={model.Id} 映射推送的舱位请求对应异常,原因:{ex.Message}");
+ }
+
+ Logger.Log(NLog.LogLevel.Info, $"slotId={model.Id} 开始处理重要提醒");
+ //执行差异重要提醒
+ //await MeasureDiffCautionTask(bcSrcDto, bcTargetDto, model.Id);
+
+ Logger.Log(NLog.LogLevel.Info, $"slotId={model.Id} 处理重要提醒结束");
+
+ //提取箱信息
+ var ctnList = tenantDb.Queryable()
+ .Where(x => x.SlotId == model.Id).ToList();
+
+ if (ctnList != null)
+ {
+ bcSrcDto.CtnList = ctnList.GroupBy(x => x.CtnAll)
+ .Select(x =>
+ {
+ return new ParserBCCTNInfoDto
+ {
+ CtnALL = x.Key,
+ CtnNum = x.ToList()
+ .Sum(a => a.CtnNum)
+ };
+ }).ToList();
+ }
+
+ if (dto.DataObj.CtnList != null && dto.DataObj.CtnList.Count > 0)
+ {
+ bcTargetDto.CtnList = dto.DataObj.CtnList.GroupBy(x => x.CtnAll)
+ .Select(x =>
+ {
+ return new ParserBCCTNInfoDto
+ {
+ CtnALL = x.Key,
+ CtnNum = x.ToList()
+ .Sum(a => a.CtnNum)
+ };
+ }).ToList();
+ }
+
+ var oldObj = model.Adapt();
+
+ dto.DataObj.Adapt(model);
+
+ // 1.判断新的舱位信息的7个库存统计维度是否发生变化
+ // 2.如果有变化,则需要更新旧的库存信息
+ bool isNeedUpdateOldStock = false;
+ if (oldObj.Vessel != model.Vessel
+ || oldObj.Voyno != model.Voyno
+ || oldObj.BookingSlotType != model.BookingSlotType
+ || oldObj.CarrierId != model.CarrierId
+ || oldObj.PortLoadId != model.PortLoadId
+ || oldObj.PortDischargeId != model.PortDischargeId)
+ {
+ isNeedUpdateOldStock = true;
+ }
+ await tenantDb.Updateable(model).ExecuteCommandAsync();
+
+ if (isNeedUpdateOldStock)
+ {
+ //BookingSlotStock:Update
+ await _bookingSlotStockService.BookingSlotStock(new BookingSlotStockUpdateModel
+ {
+ BookingSlotType = oldObj.BookingSlotType,
+ CarrierCode = oldObj.CarrierCode,
+ ContractNo = oldObj.ContractNo,
+ Vessel = oldObj.Vessel,
+ Voyno = oldObj.Voyno,
+ PortLoadId = oldObj.PortLoadId,
+ PortDischargeId = oldObj.PortDischargeId,
+ TenantId = long.Parse(user.TenantId)
+ });
+ }
+
+ var currCtnList = await tenantDb.Queryable().Where(p => p.SlotId == model.Id).ToListAsync();
+
+ if (currCtnList.Count > 0)
+ {
+ currCtnList.ForEach(async p =>
+ {
+ await tenantDb.Deleteable(p).ExecuteCommandAsync();
+ });
+ }
+
+ foreach (var ctn in dto.DataObj.CtnList)
+ {
+ var newCtn = ctn.Adapt();
+ newCtn.SlotId = model.Id;
+ await tenantDb.Insertable(newCtn).ExecuteCommandAsync();
+ }
+
+ //await InsLog("Update", model.Id, typeof(BookingSlotBaseApiSaveDto), oldObj, dto.DataObj, nameof(BookingSlotBaseApiSaveDto.CtnList), nameof(BookingSlotBaseApiSaveDto.BookingSlotSaleInfoList));
+
+ string batchNo = GuidHelper.GetSnowflakeId();
+
+ //处理附件
+ if (file != null)
+ {
+ Logger.Log(NLog.LogLevel.Info, $"请求文件名:{file.FileName}");
+
+ var fileRlt = await _sysFileService.SaveFileDirect(model.Id.ToString(), file.FileBytes, batchNo, file.FileName, "bcmoidfyfiles");
+
+ var fileFullPath = fileRlt.Data;
+
+ Logger.Log(NLog.LogLevel.Info, $"保存文件路径:{fileFullPath}");
+
+ if (!string.IsNullOrWhiteSpace(fileFullPath))
+ {
+ //将格式单附件写入订舱的附件
+ SaveEDIFile(id, fileFullPath, file.FileName, long.Parse(user.TenantId),
+ CONST_BC_MODIFY_FILE_CODE, CONST_BC_MODIFY_FILE_NAME).GetAwaiter();
+ }
+ }
+
+ if (modifyFile != null)
+ {
+ Logger.Log(NLog.LogLevel.Info, $"请求文件名(变更文件):{modifyFile.FileName}");
+
+ var fileRlt = await _sysFileService.SaveFileDirect(model.Id.ToString(), modifyFile.FileBytes, batchNo, modifyFile.FileName, "bcmodifynoticefiles");
+
+ var fileFullPath = fileRlt.Data;
+
+ Logger.Log(NLog.LogLevel.Info, $"保存文件路径(变更文件):{fileFullPath}");
+
+ if (!string.IsNullOrWhiteSpace(fileFullPath))
+ {
+ //将格式单附件写入订舱的附件
+ SaveEDIFile(id, fileFullPath, modifyFile.FileName, long.Parse(user.TenantId),
+ CONST_BC_MODIFY_NOTICE_FILE_CODE, CONST_BC_MODIFY_NOTICE_FILE_NAME).GetAwaiter();
+ }
+ }
+
+ //一般更新数据指的是Booking Amendment,需要与舱位进行数据比对
+ await PushCompareBCInfo(bcSrcDto, bcTargetDto, id, dto.BatchNo);
+
+ //触发标签自动绑定
+ await GenerateSlotLabel(dto, id);
+ }
+ else if (dto.OpType == "del")
+ {
+ var slotNO = dto.DataObj.SlotBookingNo;
+ model = await tenantDb.Queryable().FirstAsync(x => x.SlotBookingNo == slotNO);
+ if (model == null)
+ {
+ //throw Oops.Bah($"未找到订舱编号为 {slotNO} 的数据");
+ }
+
+ id = model.Id;
+
+ model.Deleted = true;
+ await tenantDb.Updateable(model).ExecuteCommandAsync();
+
+ var ctns = await tenantDb.Queryable().Where(x => x.SlotId == model.Id).ToListAsync();
+ foreach (var ctn in ctns)
+ {
+ ctn.Deleted = true;
+ await tenantDb.Updateable(ctn).ExecuteCommandAsync();
+ }
+
+ //await InsLog("Del", model.Id, "取消舱位");
+ }
+ else if (dto.OpType == "cancellation")
+ {
+ // 更新标志
+ var slotNO = dto.DataObj.SlotBookingNo;
+ model = await tenantDb.Queryable().FirstAsync(x => x.SlotBookingNo == slotNO);
+ if (model == null)
+ {
+ //throw Oops.Bah($"未找到订舱编号为 {slotNO} 的数据");
+ }
+
+ id = model.Id;
+ model.IsCancellation = true;
+ model.CancellationDate = DateTime.Now;
+ await tenantDb.Updateable(model).EnableDiffLogEvent().ExecuteCommandAsync();
+
+ // 删除该舱位相关的订舱关联关系
+ var slotList = await tenantDb.Queryable().Where(a => a.BookingSlotId == id).ToListAsync();
+ var slotIdList = slotList.Select(s => s.Id);
+
+ await tenantDb.Updateable()
+ .SetColumns(a => a.Deleted == true)
+ .SetColumns(a => a.UpdateTime == DateTime.Now)
+ .SetColumns(a => a.UpdateBy == long.Parse(user.UserId))
+ //.SetColumns(a => a.UpdatedUserName == UserManager.Name)
+ .Where(a => slotIdList.Contains(a.Id))
+ .ExecuteCommandAsync();
+
+ await tenantDb.Updateable()
+ .SetColumns(a => a.Deleted == true)
+ .SetColumns(a => a.UpdateTime == DateTime.Now)
+ .SetColumns(a => a.UpdateBy == long.Parse(user.UserId))
+ //.SetColumns(a => a.UpdatedUserName == UserManager.Name)
+ .Where(a => slotIdList.Contains(a.SlotAllocId))
+ .ExecuteCommandAsync();
+
+ //await InsLog("Cancellation", model.Id, "取消舱位");
+ }
+
+ //更新库存
+ await _bookingSlotStockService.BookingSlotStock(new BookingSlotStockUpdateModel
+ {
+ BookingSlotType = model.BookingSlotType,
+ CarrierCode = model.CarrierCode,
+ ContractNo = model.ContractNo,
+ Vessel = model.Vessel,
+ Voyno = model.Voyno,
+ PortLoadId = model.PortLoadId,
+ PortDischargeId = model.PortDischargeId,
+ TenantId = long.Parse(user.TenantId)
+ });
+ }
+ else
+ {
+ //throw Oops.Bah("操作类型参数有误");
+ }
+
+
+ if(id == 0)
+ return DataResult.FailedData(id);
+
+ return DataResult.Success(id);
+ }
+ #endregion
+
+
+ #region 异步写入附件表
+ ///
+ /// 异步写入附件表
+ ///
+ /// 订舱ID
+ /// 文件路径
+ /// 文件名
+ /// 租户ID
+ /// 附件类型代码
+ /// 附件类型名称
+ /// 附件模块代码
+ ///
+ [NonAction]
+ private async Task SaveEDIFile(long boookId, string FilePath, string fileName, long tenantId,
+ string fileTypeCode = "bc", string fileTypeName = "Booking Confirmation", string moudle = "BookingSlot")
+ {
+ /*
+ 直接将附件信息写入附件表
+ */
+ var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
+
+ var newFile = new OpFile
+ {
+ Id = SnowFlakeSingle.Instance.NextId(),
+ FileName = fileName,
+ FilePath = FilePath,
+ TypeCode = fileTypeCode,
+ TypeName = fileTypeName,
+ LinkId = boookId,
+ };
+
+ await tenantDb.Insertable(newFile).ExecuteCommandAsync();
+ }
+ #endregion
+
+ #region 根据收货地港口英文名解析出起始港对象
+ ///
+ /// 根据收货地港口英文名解析出起始港对象
+ ///
+ /// 收货地港口英文名
+ /// 起始港缓存
+ /// 起始港缓存映射
+ /// 起始港对象
+ private async Task> PlaceReceiptToPortload(string portEnName, List cachePortLoad, Func>>> cacheMapPortLoadFunc)
+ {
+ CodePortRes portInfo = null;
+
+ if (string.IsNullOrEmpty(portEnName))
+ {
+ return DataResult.FailedData(portInfo);
+ }
+
+ // 匹配方式1:精准匹配
+ portInfo = cachePortLoad.FirstOrDefault(x => x.PortName.Equals(portEnName, StringComparison.OrdinalIgnoreCase));
+ if (portInfo != null) return DataResult.Success(portInfo);
+
+ // 匹配方式2:起始模糊匹配
+ portInfo = cachePortLoad.FirstOrDefault(x => x.PortName.StartsWith(portEnName, StringComparison.OrdinalIgnoreCase));
+ if (portInfo != null) return DataResult.Success(portInfo);
+
+ // 匹配方式3:完整模糊匹配
+ portInfo = cachePortLoad.FirstOrDefault(x => x.PortName.Contains(portEnName, StringComparison.OrdinalIgnoreCase));
+ if (portInfo != null) return DataResult.Success(portInfo);
+
+ // 匹配方式4:精准映射匹配
+ var mapCachePortLoad = await cacheMapPortLoadFunc();
+ var map = mapCachePortLoad.Data.FirstOrDefault(x => x.Module == RECEIPT_TO_PORTLOAD
+ && x.MapName.Equals(portEnName, StringComparison.OrdinalIgnoreCase));
+
+ if (map != null)
+ {
+ portInfo = cachePortLoad.FirstOrDefault(x => x.Id == map.LinkId);
+
+ if (portInfo != null) return DataResult.Success(portInfo);
+ }
+
+ return DataResult.FailedData(portInfo);
+ }
+ #endregion
+
+ #region 根据交货地港口英文名解析出目的港对象
+ ///
+ /// 根据交货地港口英文名解析出目的港对象
+ ///
+ /// 交货地港口英文名
+ /// 目的港缓存
+ /// 目的港缓存映射
+ /// 目的港对象
+ private async Task> PlaceDeliveryToPort(string portEnName, List cachePort, Func>>> cacheMapPortFunc)
+ {
+ CodePortRes portInfo = null;
+
+ if (string.IsNullOrEmpty(portEnName))
+ {
+ return DataResult.FailedData(portInfo);
+ }
+
+ // 匹配方式1:精准匹配
+ portInfo = cachePort.FirstOrDefault(x => x.PortName.Equals(portEnName, StringComparison.OrdinalIgnoreCase));
+ if (portInfo != null) return DataResult.Success(portInfo);
+
+ // 匹配方式2:起始模糊匹配
+ portInfo = cachePort.FirstOrDefault(x => x.PortName.StartsWith(portEnName, StringComparison.OrdinalIgnoreCase));
+ if (portInfo != null) return DataResult.Success(portInfo);
+
+ // 匹配方式3:完整模糊匹配
+ portInfo = cachePort.FirstOrDefault(x => x.PortName.Contains(portEnName, StringComparison.OrdinalIgnoreCase));
+ if (portInfo != null) return DataResult.Success(portInfo);
+
+ // 匹配方式4:精准映射匹配
+ var mapCachePort = await cacheMapPortFunc();
+ var map = mapCachePort.Data.FirstOrDefault(x => x.Module == DELIVERY_TO_PORT
+ && x.MapName.Equals(portEnName, StringComparison.OrdinalIgnoreCase));
+
+ if (map != null)
+ {
+ portInfo = cachePort.FirstOrDefault(x => x.Id == map.LinkId);
+
+ if (portInfo != null) return DataResult.Success(portInfo);
+ }
+
+ return DataResult.FailedData(portInfo);
+ }
+ #endregion
+
+ #region 推送BC变更比对
+ ///
+ /// 推送BC变更比对
+ ///
+ /// 原舱位详情
+ /// 变更后舱位详情
+ /// 舱位主键
+ /// 请求批次号用来区分对应的哪个批次任务
+ ///
+ [NonAction]
+ public async Task PushCompareBCInfo(ParserBCInfoDto bcSrcDto, ParserBCInfoDto bcTargetDto, long slotId, string reqBatchNo)
+ {
+ var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
+
+ string batchNo = GuidHelper.GetSnowflakeId();
+
+ DateTime bDate = DateTime.Now;
+
+ Logger.Log(NLog.LogLevel.Info, $"批次={batchNo} slotId={slotId} 开始请求比对结果");
+
+ var compareResult = await ExcuteCompare(bcSrcDto, bcTargetDto);
+
+ Logger.Log(NLog.LogLevel.Info, $"批次={batchNo} slotId={slotId} 请求比对结果完成,结果={JsonConvert.SerializeObject(compareResult)}");
+
+ DateTime eDate = DateTime.Now;
+ TimeSpan ts = eDate.Subtract(bDate);
+ var timeDiff = ts.TotalMilliseconds;
+
+ if (compareResult != null)
+ {
+ Logger.Log(NLog.LogLevel.Info, "批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg}", batchNo, timeDiff, compareResult.succ ? "成功" : "失败");
+ }
+
+ if (compareResult != null)
+ {
+ DateTime nowDate = DateTime.Now;
+
+ var hisInfo = tenantDb.Queryable().First(a => a.CompareBatchNo == reqBatchNo);
+
+ if (hisInfo == null)
+ {
+ BookingSlotCompare entity = new BookingSlotCompare
+ {
+ SlotId = slotId,
+ CompareBatchNo = reqBatchNo,
+ CompareDiffNum = compareResult.extra.IsExistsDiff ? compareResult.extra.ShowDetailList.Count : 0,
+ CreateTime = nowDate,
+ UpdateTime = nowDate,
+ CreateBy = long.Parse(user.UserId),
+ //CreatedUserName = UserManager.Name,
+ UpdateBy = long.Parse(user.UserId),
+ //UpdatedUserName = UserManager.Name,
+ CompareType = "BC_MODIFY",
+ CompareRlt = JsonConvert.SerializeObject(compareResult.extra.ShowDetailList),
+ };
+
+ await tenantDb.Insertable(entity).ExecuteCommandAsync();
+ }
+ else
+ {
+ hisInfo.CompareDiffNum = compareResult.extra.IsExistsDiff ? compareResult.extra.ShowDetailList.Count : 0;
+ hisInfo.UpdateTime = nowDate;
+ hisInfo.UpdateBy = long.Parse(user.UserId);
+ //hisInfo.UpdatedUserName = user.UserName;
+
+ hisInfo.CompareRlt = JsonConvert.SerializeObject(compareResult.extra.ShowDetailList);
+
+ await tenantDb.Updateable(hisInfo).UpdateColumns(it =>
+ new
+ {
+ it.CompareDiffNum,
+ it.CompareRlt,
+ it.UpdateTime,
+ it.UpdateBy,
+ //it.UpdatedUserName
+ }).ExecuteCommandAsync();
+ }
+ //throw Oops.Oh($"舱位主键{slotId}请求BC比对失败,返回为空");
+
+ //if (compareResult.extra.ShowDetailList == null || compareResult.extra.ShowDetailList.Count == 0)
+ //{
+ // new EmailNoticeHelper().SendEmailNotice($"MBLNO={bcSrcDto.MBLNo} 与舱位比对差异失败,比对结果为0", $"MBLNO={bcSrcDto.MBLNo} 与舱位比对差异失败,比对结果为0", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
+ //}
+ }
+ else
+ {
+ //new EmailNoticeHelper().SendEmailNotice($"MBLNO={bcSrcDto.MBLNo} 与舱位比对差异失败,未获取到比对结果", $"MBLNO={bcSrcDto.MBLNo} 与舱位比对差异失败,未获取到比对结果", App.Configuration["EmailNoticeDefaultUser"].GetUserEmailList());
+ }
+ }
+ #endregion
+
+ #region 请求BC比对
+ ///
+ /// 请求BC比对
+ ///
+ /// BC详情
+ /// BC变更后详情
+ /// 返回回执
+ [NonAction]
+ public async Task ExcuteCompare(ParserBCInfoDto bcSrcDto, ParserBCInfoDto bcTargetDto)
+ {
+ TaskManageExcuteResultDto model = null;
+ /*
+ 1、读取配置文件中的规则引擎URL
+ 2、填充请求的类,并生成JSON报文
+ 3、POST请求接口,并记录回执。
+ 4、返回信息。
+ */
+
+ var url = bcCompareUrl; //App.Configuration["BCCompareUrl"];
+
+ using (var httpClient = new HttpClient())
+ {
+ try
+ {
+ using (var reduceAttach = new MultipartFormDataContent())
+ {
+ var dataContent = new ByteArrayContent(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bcSrcDto)));
+
+ dataContent.Headers.ContentDisposition = new ContentDispositionHeaderValue($"form-data")
+ {
+ Name = "srcJson"
+ };
+
+ reduceAttach.Add(dataContent);
+
+ var dataContent2 = new ByteArrayContent(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bcTargetDto)));
+
+ dataContent2.Headers.ContentDisposition = new ContentDispositionHeaderValue($"form-data")
+ {
+ Name = "destJson"
+ };
+
+ reduceAttach.Add(dataContent2);
+
+ //请求
+ var response = httpClient.PostAsync(url, reduceAttach).Result;
+
+ var result = response.Content.ReadAsStringAsync().Result;
+
+ model = JsonConvert.DeserializeObject(result);
+
+ Logger.Log(NLog.LogLevel.Info, $"推送BC比返回结果:{JsonConvert.SerializeObject(model)}");
+ }
+ }
+ catch (Exception ex)
+ {
+ Logger.Log(NLog.LogLevel.Error, "推送BC比对异常,原因:{error}", ex.Message);
+
+ // throw Oops.Oh($"推送BC比对异常,原因:{ex.Message}");
+ }
+ }
+
+ return model;
+ }
+ #endregion
}
}
diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotStockService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotStockService.cs
new file mode 100644
index 00000000..1be4c6dc
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Op/Method/BookingSlot/BookingSlotStockService.cs
@@ -0,0 +1,251 @@
+using DS.Module.Core;
+using DS.Module.SqlSugar;
+using DS.Module.UserModule;
+using DS.WMS.Core.Op.Dtos;
+using DS.WMS.Core.Op.Entity;
+using Microsoft.Extensions.DependencyInjection;
+using Newtonsoft.Json;
+using NLog;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Mapster;
+using DS.WMS.Core.Op.Interface;
+
+namespace DS.WMS.Core.Op.Method
+{
+ ///
+ /// 舱位库存
+ ///
+ public class BookingSlotStockService: IBookingSlotStockService
+ {
+ private readonly IServiceProvider _serviceProvider;
+ private readonly ISqlSugarClient db;
+ private readonly IUser user;
+ private readonly ISaasDbService saasService;
+
+ private static readonly NLog.Logger Logger = LogManager.GetCurrentClassLogger();
+
+ ///
+ ///
+ ///
+ ///
+ public BookingSlotStockService(IServiceProvider serviceProvider)
+ {
+ _serviceProvider = serviceProvider;
+ db = _serviceProvider.GetRequiredService();
+ user = _serviceProvider.GetRequiredService();
+ saasService = _serviceProvider.GetRequiredService();
+ }
+
+ ///
+ /// 计算舱位库存
+ ///
+ /// 请求参数
+ /// 返回回执
+ public async Task> BookingSlotStock(BookingSlotStockUpdateModel paraObj)
+ {
+ Logger.Log(NLog.LogLevel.Info, $"收到更新库存订阅请求:{ JsonConvert.SerializeObject(paraObj)}");
+
+ if (string.IsNullOrEmpty(paraObj.Vessel)
+ || string.IsNullOrEmpty(paraObj.Voyno)
+ || string.IsNullOrEmpty(paraObj.ContractNo)
+ || string.IsNullOrEmpty(paraObj.BookingSlotType)
+ || string.IsNullOrEmpty(paraObj.CarrierCode)
+ || string.IsNullOrEmpty(paraObj.PortLoadId)
+ || string.IsNullOrEmpty(paraObj.PortDischargeId))
+ {
+ Logger.Log(NLog.LogLevel.Info, $"收到更新库存订阅请求:部分参数存在空值,结束");
+ return DataResult.FailedData(string.Empty);
+ }
+
+ var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
+
+ var baseList = await tenantDb.Queryable()
+ .Where(x => !x.Deleted
+ //&& x.TenantId == paraObj.TenantId
+ && x.Vessel == paraObj.Vessel
+ && x.Voyno == paraObj.Voyno
+ && x.ContractNo == paraObj.ContractNo
+ && x.BookingSlotType == paraObj.BookingSlotType
+ && x.CarrierCode == paraObj.CarrierCode
+ && x.PortLoadId == paraObj.PortLoadId
+ && x.PortDischargeId == paraObj.PortDischargeId)
+ .OrderByDescending(x => x.UpdateTime)
+ .ToListAsync();
+
+ var stockObj = await tenantDb.Queryable()
+ .FirstAsync(x => !x.Deleted
+ //&& x.TenantId == paraObj.TenantId
+ && x.Vessel == paraObj.Vessel
+ && x.Voyno == paraObj.Voyno
+ && x.ContractNo == paraObj.ContractNo
+ && x.BookingSlotType == paraObj.BookingSlotType
+ && x.CarrierCode == paraObj.CarrierCode
+ && x.PortLoadId == paraObj.PortLoadId
+ && x.PortDischargeId == paraObj.PortDischargeId);
+
+ if (!baseList.Any())
+ {
+ if (stockObj != null)
+ {
+ // 从库存表删除这7项维度的库存数据
+ await tenantDb.Deleteable(stockObj).ExecuteCommandAsync();
+ }
+
+ return DataResult.FailedData(string.Empty);
+ }
+
+ var isInsert = stockObj == null;
+ var idTemp = stockObj?.Id;
+
+ stockObj = baseList[0].Adapt(stockObj);
+
+ if (isInsert)
+ {
+ stockObj.Id = 0;
+ }
+ else
+ {
+ stockObj.Id = (long)idTemp;
+ }
+
+ // 总舱位数
+ stockObj.TotalOrders = baseList.Count;
+
+ // 取消舱位数
+ stockObj.CancelNum = baseList.Count(x => x.IsCancellation);
+
+ // 舱位主键列表
+ var slotBaseIdList = baseList.Select(x => x.Id).ToList();
+
+ // 总的箱型箱量
+ var ctnAllList = await tenantDb.Queryable()
+ .Where(x => !x.Deleted && slotBaseIdList.Contains(x.SlotId))
+ .GroupBy(x => x.CtnAll)
+ .Select(x => new
+ {
+ x.CtnAll,
+ CTNNUM = SqlFunc.AggregateSum(x.CtnNum)
+ }).ToListAsync();
+ stockObj.CtnStat = string.Join(' ', ctnAllList.Select(c => c.CtnAll + "*" + c.CTNNUM));
+
+ // 总箱数
+ stockObj.TotalCtns = ctnAllList.Sum(x => x.CTNNUM);
+
+ // 订舱引用表主键与订舱主表主键
+ var lstAllocKeyList = await tenantDb.Queryable()
+ //.Filter(null, true)
+ .Where(x => !x.Deleted && slotBaseIdList.Contains(x.BookingSlotId))
+ .Select(x => new { x.Id, x.BookingSlotId })
+ .ToListAsync();
+
+ // 如果舱位未被引用过,可以直接确定库存
+ if (!lstAllocKeyList.Any())
+ {
+ // 已使用舱位数
+ stockObj.UseNum = 0;
+ // 已使用的箱型箱量
+ stockObj.UseCtnStat = "";
+ // 已使用的箱数
+ stockObj.UseCtnsNum = 0;
+
+ // 剩余的箱型箱量
+ stockObj.RemainCtnStat = stockObj.CtnStat;
+ // 剩余箱数
+ stockObj.RemainCtnsNum = stockObj.TotalCtns;
+ }
+ else
+ {
+ // 已使用舱位数
+ //stockObj.USE_NUM = lstAllocKeyList.DistinctBy(x => x.BOOKING_SLOT_ID).Count();
+
+ // 订舱引用表主键列表
+ var allocIdList = lstAllocKeyList.Select(x => x.Id).ToList();
+ var allocSlotIdList = lstAllocKeyList.Select(x => x.BookingSlotId).Distinct().ToList();
+ var userCtnNumList = await tenantDb.Queryable().Filter(null, true)
+ .Where(x => !x.Deleted && allocIdList.Contains(x.SlotAllocId))
+ .GroupBy(x => x.SlotAllocId)
+ .Select(x => new
+ {
+ x.SlotAllocId,
+ CTNNUM = SqlFunc.AggregateSum(x.CtnNum)
+ }).ToListAsync();
+ var hasCtnNumList = await tenantDb.Queryable().Filter(null, true)
+ .Where(x => !x.Deleted && allocSlotIdList.Contains(x.SlotId))
+ .GroupBy(x => x.SlotId)
+ .Select(x => new
+ {
+ x.SlotId,
+ CTNNUM = SqlFunc.AggregateSum(x.CtnNum)
+ })
+ .ToListAsync();
+ var useNum = 0;
+ foreach (long slotId in allocSlotIdList)
+ {
+ List temp1 = lstAllocKeyList.Where(x => x.BookingSlotId == slotId).Select(x => x.Id).ToList();
+ var userNum = userCtnNumList.Where(x => temp1.Contains(x.SlotAllocId)).Sum(x => x.CTNNUM);
+ var hasNum = hasCtnNumList.Where(x => x.SlotId == slotId).Sum(x => x.CTNNUM);
+ if (userNum >= hasNum)
+ {
+ useNum++;
+ }
+ }
+ // 已使用舱位数
+ stockObj.UseNum = useNum;
+
+ // 已使用的箱型箱量
+ var userCtnList = await tenantDb.Queryable()
+ .Filter(null, true)
+ .Where(x => !x.Deleted && allocIdList.Contains(x.SlotAllocId))
+ .GroupBy(x => x.CtnAll)
+ .Select(x => new
+ {
+ x.CtnAll,
+ CTNNUM = SqlFunc.AggregateSum(x.CtnNum)
+ }).ToListAsync();
+ stockObj.UseCtnStat = string.Join(' ', userCtnList.Select(c => c.CtnAll + "*" + c.CTNNUM));
+
+ // 已使用的箱数
+ stockObj.UseCtnsNum = userCtnList.Sum(x => x.CTNNUM);
+
+ // 剩余的箱型箱量
+ Dictionary remainCtnList = new(ctnAllList.Count);
+ foreach (var item in ctnAllList)
+ {
+ var useItem = userCtnList.FirstOrDefault(x => x.CtnAll == item.CtnAll);
+ if (useItem == null)
+ {
+ remainCtnList.Add(item.CtnAll, item.CTNNUM);
+ }
+ else
+ {
+ int remainCtnNum = item.CTNNUM - useItem.CTNNUM;
+ if (remainCtnNum > 0)
+ {
+ remainCtnList.Add(item.CtnAll, remainCtnNum);
+ }
+ }
+ }
+ stockObj.RemainCtnStat = string.Join(' ', remainCtnList.Select(x => x.Key + "*" + x.Value));
+
+ // 剩余箱数
+ stockObj.RemainCtnsNum = stockObj.TotalCtns - stockObj.UseCtnsNum;
+ }
+
+ if (isInsert)
+ {
+ await tenantDb.Insertable(stockObj).ExecuteCommandAsync();
+ }
+ else
+ {
+ await tenantDb.Updateable(stockObj).ExecuteCommandAsync();
+ }
+
+ return DataResult.Success(string.Empty);
+ }
+ }
+}
diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/SpaceBooking/SpaceBookingMSKAPIService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/SpaceBooking/SpaceBookingMSKAPIService.cs
index 42af80c9..8c4dbc0a 100644
--- a/ds-wms-service/DS.WMS.Core/Op/Method/SpaceBooking/SpaceBookingMSKAPIService.cs
+++ b/ds-wms-service/DS.WMS.Core/Op/Method/SpaceBooking/SpaceBookingMSKAPIService.cs
@@ -30,6 +30,8 @@ using System.Text.Json.Nodes;
using LanguageExt.Pipes;
using DS.WMS.Core.Op.Interface;
using DS.WMS.Core.Map.Method;
+using Microsoft.Owin.Security.Provider;
+using LanguageExt;
namespace DS.WMS.Core.Op.Method
{
@@ -54,6 +56,7 @@ namespace DS.WMS.Core.Op.Method
const string CONST_MSK_API_COMMODITY_URL = "MSKApiCommodity";
const string CONST_MSK_API_MAPPING_MODULE = "BOOK_MSK_API";
+ const string CONST_MSK_API_CHANNEL_SHOW = "BOOKING_CHANNEL_SELECT_SHOW";
const long CONST_ADMIN_TENANTID = 1288018625843826688;
@@ -2166,5 +2169,27 @@ namespace DS.WMS.Core.Op.Method
return data;
}
#endregion
+
+ #region 获取预订舱途径选择
+ ///
+ /// 获取预订舱途径选择
+ ///
+ /// 返回回执
+ public async Task>> GetBookingChannelSelectShow()
+ {
+ var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
+
+ var rlt = await configService.GetConfig(CONST_MSK_API_CHANNEL_SHOW, long.Parse(user.TenantId), false);
+
+ if (rlt.Succeeded)
+ {
+ var list = rlt.Data.Value.Split(new char[] { ',' }).ToList();
+
+ return DataResult>.Success(list);
+ }
+
+ return DataResult>.FailedData(new List());
+ }
+ #endregion
}
}
diff --git a/ds-wms-service/DS.WMS.Core/Sys/Interface/ISysCacheService.cs b/ds-wms-service/DS.WMS.Core/Sys/Interface/ISysCacheService.cs
new file mode 100644
index 00000000..b0cdf751
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Sys/Interface/ISysCacheService.cs
@@ -0,0 +1,44 @@
+using DS.Module.Core;
+using DS.WMS.Core.Code.Entity;
+using DS.WMS.Core.Map.Entity;
+using DS.WMS.Core.Sys.Method;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DS.WMS.Core.Sys.Interface
+{
+ ///
+ /// 公共缓存
+ ///
+ public interface ISysCacheService
+ {
+ ///
+ /// 获取缓存数据
+ ///
+ /// 数据类型
+ /// 缓存key枚举
+ ///
+ Task>> GetAllCommonCodeFromCache(SysCacheKeyEnum cacheKey);
+
+ ///
+ /// 设置缓存
+ ///
+ /// 被缓存的详情
+ /// 缓存key枚举
+ /// 超期时间(毫米)
+ ///
+ Task> SetCommonCode(object cacheObj, SysCacheKeyEnum cacheKey, int outSecond = 0);
+
+ ///
+ /// 加载缓存
+ ///
+ /// 被缓存的详情
+ /// 缓存key枚举
+ /// 是否强制刷新缓存
+ ///
+ Task> LoadCache(object cacheObj, SysCacheKeyEnum cacheKey, bool isReload = false);
+ }
+}
diff --git a/ds-wms-service/DS.WMS.Core/Sys/Interface/ISysCommonCacheService.cs b/ds-wms-service/DS.WMS.Core/Sys/Interface/ISysCommonCacheService.cs
new file mode 100644
index 00000000..01627715
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Sys/Interface/ISysCommonCacheService.cs
@@ -0,0 +1,18 @@
+using DS.Module.Core;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DS.WMS.Core.Sys.Interface
+{
+ public interface ISysCommonCacheService
+ {
+ ///
+ /// 加载公共缓存数据
+ ///
+ ///
+ Task> LoadCommonCache();
+ }
+}
diff --git a/ds-wms-service/DS.WMS.Core/Sys/Interface/ISysFileService.cs b/ds-wms-service/DS.WMS.Core/Sys/Interface/ISysFileService.cs
index 30251606..dae8c314 100644
--- a/ds-wms-service/DS.WMS.Core/Sys/Interface/ISysFileService.cs
+++ b/ds-wms-service/DS.WMS.Core/Sys/Interface/ISysFileService.cs
@@ -26,5 +26,17 @@ namespace DS.WMS.Core.Sys.Interface
///
///
public DataResult> GetSysFileList(string id);
+
+ ///
+ /// 保存文件并返回文件完整路径
+ ///
+ /// 文件目录KEY
+ /// 文件二进制流
+ /// 批次号
+ /// 文件名称
+ /// 附件类型
+ ///
+ Task> SaveFileDirect(string fileDictKey, byte[] fileBytes, string batchNo,
+ string fileName, string attachFileType);
}
}
diff --git a/ds-wms-service/DS.WMS.Core/Sys/Method/ConfigService.cs b/ds-wms-service/DS.WMS.Core/Sys/Method/ConfigService.cs
index 9aba9c27..2f08c035 100644
--- a/ds-wms-service/DS.WMS.Core/Sys/Method/ConfigService.cs
+++ b/ds-wms-service/DS.WMS.Core/Sys/Method/ConfigService.cs
@@ -106,7 +106,10 @@ public class ConfigService : IConfigService
var data = await db.Queryable().Filter(null, true)
.Where(x => x.Code == code && x.TenantId == tenantId).Select().FirstAsync();
- return DataResult.Success(data);
+ if(data != null)
+ return DataResult.Success(data);
+
+ return DataResult.FailedData(data);
}
#endregion
}
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.Core/Sys/Method/SysCacheService.cs b/ds-wms-service/DS.WMS.Core/Sys/Method/SysCacheService.cs
new file mode 100644
index 00000000..d64fd244
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Sys/Method/SysCacheService.cs
@@ -0,0 +1,154 @@
+using DS.Module.Core;
+using DS.Module.RedisModule;
+using DS.WMS.Core.Code.Entity;
+using DS.WMS.Core.Code.Interface;
+using DS.WMS.Core.Sys.Interface;
+using LanguageExt;
+using Microsoft.Extensions.DependencyInjection;
+using Newtonsoft.Json;
+using NPOI.SS.Formula.Functions;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DS.WMS.Core.Sys.Method
+{
+ public class SysCacheService : ISysCacheService
+ {
+ private readonly IServiceProvider _serviceProvider;
+ private readonly IRedisService _redisService;
+ private readonly ICodeVesselService _codeVesselService;
+
+ public SysCacheService(IServiceProvider serviceProvider)
+ {
+ _serviceProvider = serviceProvider;
+ _redisService = _serviceProvider.GetRequiredService();
+ _codeVesselService = _serviceProvider.GetRequiredService();
+ }
+
+ ///
+ /// 获取缓存数据
+ ///
+ /// 数据类型
+ /// 缓存key枚举
+ /// 返回列表
+ public async Task>> GetAllCommonCodeFromCache(SysCacheKeyEnum cacheKey)
+ {
+ var currVal =_redisService.GetValue>(cacheKey.ToString());
+
+ if (currVal == null)
+ return DataResult>.FailedData(new List());
+
+ return DataResult>.Success(currVal);
+ }
+
+ ///
+ /// 设置缓存
+ ///
+ /// 被缓存的详情
+ /// 缓存key枚举
+ /// 超期时间(毫米)
+ ///
+ public async Task> SetCommonCode(object cacheObj, SysCacheKeyEnum cacheKey, int outSecond = 0)
+ {
+ if (outSecond > 0)
+ _redisService.SetValue(cacheKey.ToString(), JsonConvert.SerializeObject(cacheObj), outSecond);
+
+ _redisService.SetValue(cacheKey.ToString(), JsonConvert.SerializeObject(cacheObj));
+
+ return DataResult.Success(string.Empty);
+ }
+
+ ///
+ /// 加载缓存
+ ///
+ /// 被缓存的详情
+ /// 缓存key枚举
+ /// 是否强制刷新缓存
+ ///
+ public async Task> LoadCache(object cacheObj, SysCacheKeyEnum cacheKey, bool isReload = false)
+ {
+ if (isReload)
+ {
+ if (_redisService.Exists(cacheKey.ToString()))
+ _redisService.DeleteKey(cacheKey.ToString());
+ }
+
+ _redisService.SetValue(cacheKey.ToString(), JsonConvert.SerializeObject(cacheObj));
+
+ return DataResult.Success(string.Empty);
+ }
+ }
+
+ public enum SysCacheKeyEnum
+ {
+ ///
+ /// 船名基础信息
+ ///
+ [Description("船名基础信息")]
+ CommonCodeVessel,
+ ///
+ /// 港口基础信息
+ ///
+ [Description("港口基础信息")]
+ CommonCodePort,
+ ///
+ /// 包装基础信息
+ ///
+ [Description("包装基础信息")]
+ CommonCodePackage,
+ ///
+ /// 运输条款基础信息
+ ///
+ [Description("运输条款基础信息")]
+ CommonCodeService,
+ ///
+ /// 集装箱型基础信息
+ ///
+ [Description("集装箱型基础信息")]
+ CommonCodeCtn,
+ ///
+ /// 付费方式基础信息
+ ///
+ [Description("付费方式基础信息")]
+ CommonCodeFrt,
+ ///
+ /// 国家基础信息
+ ///
+ [Description("国家基础信息")]
+ CommonCodeCountry,
+ ///
+ /// 场站映射信息
+ ///
+ [Description("场站映射信息")]
+ CommonMappingYard,
+ ///
+ /// 集装箱型映射信息
+ ///
+ [Description("集装箱型映射信息")]
+ CommonMappingCtn,
+ ///
+ /// 船公司映射信息
+ ///
+ [Description("船公司映射信息")]
+ CommonMappingCarrier,
+ ///
+ /// 付费方式映射
+ ///
+ [Description("付费方式映射")]
+ CommonMappingFrt,
+ ///
+ /// 船名映射
+ ///
+ [Description("船名映射")]
+ CommonMappingVessel,
+ ///
+ /// 船代映射
+ ///
+ [Description("船代映射")]
+ CommonMappingForwarder
+ }
+}
diff --git a/ds-wms-service/DS.WMS.Core/Sys/Method/SysCommonCacheService.cs b/ds-wms-service/DS.WMS.Core/Sys/Method/SysCommonCacheService.cs
new file mode 100644
index 00000000..e0b8c2b3
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Sys/Method/SysCommonCacheService.cs
@@ -0,0 +1,44 @@
+using DS.Module.Core;
+using DS.Module.RedisModule;
+using DS.WMS.Core.Code.Interface;
+using DS.WMS.Core.Code.Method;
+using DS.WMS.Core.Sys.Interface;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DS.WMS.Core.Sys.Method
+{
+ ///
+ ///
+ ///
+ public class SysCommonCacheService: ISysCommonCacheService
+ {
+ private readonly IServiceProvider _serviceProvider;
+ private readonly IRedisService _redisService;
+ private readonly ICodeVesselService _codeVesselService;
+
+ public SysCommonCacheService(IServiceProvider serviceProvider)
+ {
+ _serviceProvider = serviceProvider;
+ _redisService = _serviceProvider.GetRequiredService();
+ _codeVesselService = _serviceProvider.GetRequiredService();
+ }
+
+ ///
+ /// 加载公共缓存数据
+ ///
+ ///
+ public async Task> LoadCommonCache()
+ {
+ //SysCacheKeyEnum.CommonMappingVessel
+ var codeVessleRlt = await _codeVesselService.LoadCache();
+
+
+ return DataResult.Success(string.Empty);
+ }
+ }
+}
diff --git a/ds-wms-service/DS.WMS.Core/Sys/Method/SysFileService.cs b/ds-wms-service/DS.WMS.Core/Sys/Method/SysFileService.cs
index 9b874852..ab89dbd1 100644
--- a/ds-wms-service/DS.WMS.Core/Sys/Method/SysFileService.cs
+++ b/ds-wms-service/DS.WMS.Core/Sys/Method/SysFileService.cs
@@ -8,10 +8,13 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
+using NLog;
+using NPOI.SS.Formula.Functions;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
@@ -23,6 +26,8 @@ namespace DS.WMS.Core.Sys.Method
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly IWebHostEnvironment _environment;
+ private static readonly NLog.Logger Logger = LogManager.GetCurrentClassLogger();
+
///
///
///
@@ -112,5 +117,64 @@ namespace DS.WMS.Core.Sys.Method
.ToList();
return DataResult>.Success(data, MultiLanguageConst.DataQuerySuccess);
}
+
+ ///
+ /// 保存文件并返回文件完整路径
+ ///
+ /// 文件目录KEY
+ /// 文件二进制流
+ /// 批次号
+ /// 文件名称
+ /// 附件类型
+ ///
+ public async Task> SaveFileDirect(string fileDictKey, byte[] fileBytes, string batchNo,
+ string fileName, string attachFileType)
+ {
+ string fileRoot = AppSetting.app(new string[] { "FileSettings", "BasePath" });
+ string relativePath = AppSetting.app(new string[] { "FileSettings", "RelativePath" });
+
+ if (!string.IsNullOrWhiteSpace(attachFileType))
+ relativePath += $"\\{attachFileType}";
+
+ if (!string.IsNullOrWhiteSpace(fileDictKey))
+ relativePath += $"\\{fileDictKey}";
+
+ relativePath += $"\\{DateTime.Now.ToString("yyyyMMddHHmmssfff")}";
+
+ string filePath = $"{fileRoot}\\{relativePath}";
+
+ string fileFullName = $"{filePath}\\{fileName}";
+
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ {
+ relativePath = relativePath.Replace("\\", "/");
+ filePath = filePath.Replace("\\", "/");
+ fileFullName = fileFullName.Replace("\\", "/");
+ }
+
+ Logger.Log(NLog.LogLevel.Info, "批次={no} 生成文件保存路径完成 路由={filePath} 服务器系统={system}", batchNo, filePath,
+ RuntimeInformation.OSDescription);
+
+ //预先创建目录
+ if (!Directory.Exists(filePath))
+ {
+ Directory.CreateDirectory(filePath);
+ }
+
+ await File.WriteAllBytesAsync(fileFullName, fileBytes);
+
+ string bookFilePath = string.Empty;
+
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ {
+ bookFilePath = System.Text.RegularExpressions.Regex.Match(fileFullName, relativePath.Replace("/", "\\/") + ".*").Value;
+ }
+ else
+ {
+ bookFilePath = System.Text.RegularExpressions.Regex.Match(fileFullName, relativePath.Replace("\\", "\\\\") + ".*").Value;
+ }
+
+ return DataResult.Success(bookFilePath);
+ }
}
}
diff --git a/ds-wms-service/DS.WMS.OpApi/Controllers/SpaceBookingMSKAPIController.cs b/ds-wms-service/DS.WMS.OpApi/Controllers/SpaceBookingMSKAPIController.cs
index 156f7e92..4e68b41c 100644
--- a/ds-wms-service/DS.WMS.OpApi/Controllers/SpaceBookingMSKAPIController.cs
+++ b/ds-wms-service/DS.WMS.OpApi/Controllers/SpaceBookingMSKAPIController.cs
@@ -214,6 +214,17 @@ namespace DS.WMS.OpApi.Controllers
return await _spaceBookingMSKAPIService.GetInitInfo();
}
#endregion
+
+ ///
+ /// 获取预订舱途径选择
+ ///
+ /// 返回结果
+ [HttpGet]
+ [Route("ChannelSelectShow")]
+ public async Task>> GetBookingChannelSelectShow()
+ {
+ return await _spaceBookingMSKAPIService.GetBookingChannelSelectShow();
+ }
}
}
diff --git a/ds-wms-service/DS.WMS.OpApi/Logs/internal-nlog.txt b/ds-wms-service/DS.WMS.OpApi/Logs/internal-nlog.txt
index ef526a07..0b7536b4 100644
--- a/ds-wms-service/DS.WMS.OpApi/Logs/internal-nlog.txt
+++ b/ds-wms-service/DS.WMS.OpApi/Logs/internal-nlog.txt
@@ -334,3 +334,31 @@
2024-07-15 11:55:56.3287 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=E:\MyCode\Dongsheng8\ds-wms-service\DS.WMS.OpApi\bin\Debug\net8.0\nlog.config
2024-07-15 11:55:56.3370 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-07-15 11:55:56.3370 Info Configuration initialized.
+2024-07-17 13:35:24.5417 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-07-17 13:35:24.5552 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-07-17 13:35:24.5552 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-07-17 13:35:24.6444 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
+2024-07-17 13:35:24.6552 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=E:\MyCode\Dongsheng8\ds-wms-service\DS.WMS.OpApi\bin\Debug\net8.0\nlog.config
+2024-07-17 13:35:24.6552 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-07-17 13:35:24.6678 Info Configuration initialized.
+2024-07-17 13:36:20.7200 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-07-17 13:36:20.7312 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-07-17 13:36:20.7312 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-07-17 13:36:20.7429 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
+2024-07-17 13:36:20.7429 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=E:\MyCode\Dongsheng8\ds-wms-service\DS.WMS.OpApi\bin\Debug\net8.0\nlog.config
+2024-07-17 13:36:20.7429 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-07-17 13:36:20.7553 Info Configuration initialized.
+2024-07-17 13:59:03.7262 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-07-17 13:59:03.7262 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-07-17 13:59:03.7399 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-07-17 13:59:03.7399 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
+2024-07-17 13:59:03.7399 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=E:\MyCode\Dongsheng8\ds-wms-service\DS.WMS.OpApi\bin\Debug\net8.0\nlog.config
+2024-07-17 13:59:03.7565 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-07-17 13:59:03.7565 Info Configuration initialized.
+2024-07-17 14:01:25.4803 Info Registered target NLog.Targets.FileTarget(Name=allfile)
+2024-07-17 14:01:25.4922 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
+2024-07-17 14:01:25.4922 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
+2024-07-17 14:01:25.5048 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
+2024-07-17 14:01:25.5048 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=E:\MyCode\Dongsheng8\ds-wms-service\DS.WMS.OpApi\bin\Debug\net8.0\nlog.config
+2024-07-17 14:01:25.5048 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
+2024-07-17 14:01:25.5048 Info Configuration initialized.
diff --git a/ds-wms-service/DS.WMS.OpApi/Program.cs b/ds-wms-service/DS.WMS.OpApi/Program.cs
index c7be932f..75a5e117 100644
--- a/ds-wms-service/DS.WMS.OpApi/Program.cs
+++ b/ds-wms-service/DS.WMS.OpApi/Program.cs
@@ -16,6 +16,8 @@ using Swashbuckle.AspNetCore.SwaggerUI;
using DS.Module.PrintModule;
using DS.Module.DjyRulesEngine;
using DS.Module.RedisModule;
+using DS.WMS.Core.Sys.Interface;
+using DS.WMS.Core.Sys.Method;
var builder = WebApplication.CreateBuilder(args);
var environment = builder.Environment.EnvironmentName;
@@ -50,8 +52,10 @@ builder.Services.AddRedisModuleInstall();//redis
//builder.Services.AddCrawlerModuleInstall();//ٷ
+
var app = builder.Build();
+
// Configure the HTTP request pipeline.
// if (app.Environment.IsDevelopment())
// {
@@ -91,4 +95,6 @@ app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
+//await ServiceLocator.Instance.GetService().LoadCommonCache();
+
app.Run();
\ No newline at end of file
diff --git a/ds-wms-service/DS.WMS.OpApi/appsettings.json b/ds-wms-service/DS.WMS.OpApi/appsettings.json
index 71614810..6fe2f4b5 100644
--- a/ds-wms-service/DS.WMS.OpApi/appsettings.json
+++ b/ds-wms-service/DS.WMS.OpApi/appsettings.json
@@ -93,5 +93,8 @@
},
"RedisInfo": {
"RedisConfig": "127.0.0.1:6379,password=,defaultDatabase=15"
+ },
+ "BCCompare": {
+ "Url": "http://localhost:5110/api/TaskBookingAmendmentParser/ExcuteBookingAmendmentCompare"
}
}