diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 224ce2ea..c4e0e449 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -1163,6 +1163,7 @@ namespace Myshipping.Application throw Oops.Bah(BookingErrorCode.BOOK001); } + _logger.LogInformation($"查找模板:bookingId-{bookingId} TenantId-{order.TenantId}"); var printTemplate = await _repPrintTemplate.AsQueryable().Filter(null, true).FirstAsync(x => x.TenantId == order.TenantId && x.TypeCode == typeCode); if (printTemplate == null) { @@ -1177,6 +1178,7 @@ namespace Myshipping.Application } var fileAbsPath = Path.Combine(dirAbs, printTemplate.FilePath); + _logger.LogInformation($"查找模板文件:{fileAbsPath}"); if (!File.Exists(fileAbsPath)) { throw Oops.Bah(BookingErrorCode.BOOK115); diff --git a/Myshipping.Application/Service/RulesEngine/RulesEngineClientService.cs b/Myshipping.Application/Service/RulesEngine/RulesEngineClientService.cs index 07d311dc..8da78ac8 100644 --- a/Myshipping.Application/Service/RulesEngine/RulesEngineClientService.cs +++ b/Myshipping.Application/Service/RulesEngine/RulesEngineClientService.cs @@ -19,6 +19,8 @@ using Furion.DistributedIDGenerator; using Mapster; using Furion.DataValidation; using Newtonsoft.Json.Linq; +using Myshipping.Core.Service; +using Myshipping.Core.Entity; namespace Myshipping.Application { @@ -31,17 +33,20 @@ namespace Myshipping.Application private readonly SqlSugarRepository _bookingOrderRepository; private readonly SqlSugarRepository _bookingOrderContaRepository; private readonly SqlSugarRepository _bookingOrderContaCargoRepository; + private readonly ISysCacheService _cache; /// /// /// public RulesEngineClientService(SqlSugarRepository bookingOrderRepository, SqlSugarRepository bookingOrderContaRepository, - SqlSugarRepository bookingOrderContaCargoRepository) + SqlSugarRepository bookingOrderContaCargoRepository, + ISysCacheService cache) { _bookingOrderRepository = bookingOrderRepository; _bookingOrderContaRepository = bookingOrderContaRepository; _bookingOrderContaCargoRepository = bookingOrderContaCargoRepository; + _cache = cache; } #region 海运订舱请求规则引擎校验 @@ -244,6 +249,27 @@ namespace Myshipping.Application msgModel.Main.BusinessInfo = model.Adapt(); + //根据卸货港翻译航线信息 + if(!string.IsNullOrWhiteSpace(model.PORTDISCHARGEID)) + { + var laneList = _cache.GetAllRelaPortCarrierLane().GetAwaiter().GetResult(); + var laneInfo = laneList + .FirstOrDefault(p => !string.IsNullOrWhiteSpace(model.CARRIER) && !string.IsNullOrWhiteSpace(p.CarrierCode) && + p.CarrierCode.Equals(model.CARRIER, StringComparison.OrdinalIgnoreCase) && p.PortCode.Equals(model.PORTDISCHARGEID, StringComparison.OrdinalIgnoreCase)); + + if(laneInfo == null) + laneInfo = laneList.FirstOrDefault(p => string.IsNullOrWhiteSpace(p.CarrierCode) && p.PortCode.Equals(model.PORTDISCHARGEID, StringComparison.OrdinalIgnoreCase)); + + if (laneInfo != null) + { + var lineModel = _cache.GetAllCodeLane().GetAwaiter().GetResult().FirstOrDefault(t => t.Code.Equals(laneInfo.LaneCode, StringComparison.OrdinalIgnoreCase)); + + msgModel.Main.BusinessInfo.LaneCode = laneInfo.LaneCode; + msgModel.Main.BusinessInfo.LaneName = lineModel?.CnName; + } + } + + var contaList = await _bookingOrderContaRepository.AsQueryable().Where(x => x.BILLID == model.Id).ToListAsync(); if (contaList.Count > 0) diff --git a/Myshipping.Core/Const/CommonConst.cs b/Myshipping.Core/Const/CommonConst.cs index ec302cd8..20536d35 100644 --- a/Myshipping.Core/Const/CommonConst.cs +++ b/Myshipping.Core/Const/CommonConst.cs @@ -90,6 +90,16 @@ public class CommonConst /// public const string CACHE_KEY_COMMON_DB_FRT = "CommonDbFrt"; + /// + /// 航线 + /// + public const string CACHE_KEY_COMMON_DB_LANE= "CommonDbLane"; + + /// + /// 航线与港口的的关系 + /// + public const string CACHE_KEY_COMMON_DB_LANE_PORT = "CommonDbLanePort"; + /// /// 箱型映射 /// diff --git a/Myshipping.Core/Entity/CommonDB/CodeLane.cs b/Myshipping.Core/Entity/CommonDB/CodeLane.cs new file mode 100644 index 00000000..85b16bc9 --- /dev/null +++ b/Myshipping.Core/Entity/CommonDB/CodeLane.cs @@ -0,0 +1,40 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Core.Entity +{ + [SugarTable("CodeLine")] + [Description("航线")] + public class CodeLane : CommonDbEntity + { + /// + /// 航线代码 + /// + public string Code { get; set; } + + /// + /// 航线类型 SEA-海运 + /// + public string LaneType { get; set; } + + /// + /// 航线英文名称 + /// + public string EnName { get; set; } + + /// + /// 航线中文名称 + /// + public string CnName { get; set; } + + /// + /// 描述 + /// + public string Description { get; set; } + } +} diff --git a/Myshipping.Core/Entity/CommonDB/RelaPortCarrierLine.cs b/Myshipping.Core/Entity/CommonDB/RelaPortCarrierLine.cs new file mode 100644 index 00000000..06343839 --- /dev/null +++ b/Myshipping.Core/Entity/CommonDB/RelaPortCarrierLine.cs @@ -0,0 +1,40 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Core.Entity +{ + [SugarTable("RelaPortCarrierLine")] + [Description("航线与港口的的关系表")] + public class RelaPortCarrierLane : CommonDbEntity + { + /// + /// 航线代码 + /// + public string LaneCode { get; set; } + + /// + /// 船司代码 + /// + public string CarrierCode { get; set; } + + /// + /// 港口代码 + /// + public string PortCode { get; set; } + + /// + /// 模块(公用时为空字符串) + /// + public string Module { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + } +} diff --git a/Myshipping.Core/Job/CacheCommonWorker.cs b/Myshipping.Core/Job/CacheCommonWorker.cs index 60cdda0c..bb34c9e9 100644 --- a/Myshipping.Core/Job/CacheCommonWorker.cs +++ b/Myshipping.Core/Job/CacheCommonWorker.cs @@ -89,6 +89,12 @@ namespace Myshipping.Core.Job //系统参数 await App.GetService().CacheData(); + //航线 + await App.GetService().GetAllLane(true); + + //航线与港口的的关系 + await App.GetService().GetAllRelaPortCarrierLane(true); + Log.Information($"缓存公共库完成 {DateTime.Now}"); } } diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index c20350fd..a24e1646 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -627,6 +627,16 @@ 付费方式 + + + 航线 + + + + + 航线与港口的的关系 + + 箱型映射 @@ -1062,6 +1072,31 @@ 排序 + + + 航线代码 + + + + + 航线类型 SEA-海运 + + + + + 航线英文名称 + + + + + 航线中文名称 + + + + + 描述 + + 代码 @@ -1472,6 +1507,31 @@ 描述 + + + 航线代码 + + + + + 船司代码 + + + + + 港口代码 + + + + + 模块(公用时为空字符串) + + + + + 备注 + + 自定义租户基类实体 @@ -5844,6 +5904,18 @@ + + + 获取公共库 航线 + + + + + + 设置公共库 航线与港口的的关系表 + + + 获取公共库 箱型映射 @@ -6024,6 +6096,18 @@ + + + 设置公共库 航线 + + + + + + 设置公共库 航线与港口的的关系表 + + + 获取租户参数 @@ -6310,6 +6394,18 @@ + + + 获取公共库 航线 + + + + + + 设置公共库 航线与港口的的关系表 + + + 获取公共库 箱型映射 @@ -6400,6 +6496,18 @@ + + + 设置公共库 航线 + + + + + + 设置公共库 航线与港口的的关系表 + + + 设置公共库 箱型映射 @@ -7252,6 +7360,13 @@ 获取模块信息 + + + 获取航线信息 + + + + 代码 @@ -7961,6 +8076,18 @@ + + + 航线 + + + + + + 航线与港口的的关系 + + + 付费方式映射 diff --git a/Myshipping.Core/Service/Cache/ISysCacheService.cs b/Myshipping.Core/Service/Cache/ISysCacheService.cs index e93f0d6d..82c0f48f 100644 --- a/Myshipping.Core/Service/Cache/ISysCacheService.cs +++ b/Myshipping.Core/Service/Cache/ISysCacheService.cs @@ -97,6 +97,18 @@ public interface ISysCacheService /// Task> GetAllCodeFrt(); + /// + /// 获取公共库 航线 + /// + /// + Task> GetAllCodeLane(); + + /// + /// 设置公共库 航线与港口的的关系表 + /// + /// + Task> GetAllRelaPortCarrierLane(); + /// /// 获取公共库 箱型映射 /// @@ -273,6 +285,19 @@ public interface ISysCacheService /// /// Task SetAllCodeIssueType(List list); + + /// + /// 设置公共库 航线 + /// + /// + Task SetAllCodeLane(List list); + + + /// + /// 设置公共库 航线与港口的的关系表 + /// + /// + Task SetAllRelaPortCarrierLane(List list); #endregion #region DJY diff --git a/Myshipping.Core/Service/Cache/SysCacheService.cs b/Myshipping.Core/Service/Cache/SysCacheService.cs index b86e26f9..caa39c4f 100644 --- a/Myshipping.Core/Service/Cache/SysCacheService.cs +++ b/Myshipping.Core/Service/Cache/SysCacheService.cs @@ -387,6 +387,24 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet return _cache.GetAsync>(CommonConst.CACHE_KEY_COMMON_DB_FRT); } + /// + /// 获取公共库 航线 + /// + /// + public Task> GetAllCodeLane() + { + return _cache.GetAsync>(CommonConst.CACHE_KEY_COMMON_DB_LANE); + } + + /// + /// 设置公共库 航线与港口的的关系表 + /// + /// + public Task> GetAllRelaPortCarrierLane() + { + return _cache.GetAsync>(CommonConst.CACHE_KEY_COMMON_DB_LANE_PORT); + } + /// /// 获取公共库 箱型映射 /// @@ -526,6 +544,25 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_FRT, list); } + /// + /// 设置公共库 航线 + /// + /// + public Task SetAllCodeLane(List list) + { + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_LANE, list); + } + + + /// + /// 设置公共库 航线与港口的的关系表 + /// + /// + public Task SetAllRelaPortCarrierLane(List list) + { + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_LANE_PORT, list); + } + /// /// 设置公共库 箱型映射 /// diff --git a/Myshipping.Core/Service/CommonDB/CommonDBService.cs b/Myshipping.Core/Service/CommonDB/CommonDBService.cs index 2091b784..69b142ea 100644 --- a/Myshipping.Core/Service/CommonDB/CommonDBService.cs +++ b/Myshipping.Core/Service/CommonDB/CommonDBService.cs @@ -44,6 +44,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie private readonly SqlSugarRepository _codeIssueTypeRep; private readonly SqlSugarRepository _commonModuleRep; private readonly ILogger _logger; + private readonly SqlSugarRepository _codeLaneRep; + private readonly SqlSugarRepository _relaPortCarrierLaneRep; public CommonDBService(SqlSugarRepository codeCarrierRep, SqlSugarRepository codeVesselRep, SqlSugarRepository codeForwarderRep, @@ -66,7 +68,9 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie SqlSugarRepository codeIssueTypeRep, SqlSugarRepository commonModuleRep, ILogger logger, - ISysCacheService sysCacheService) + ISysCacheService sysCacheService, + SqlSugarRepository codeLaneRep, + SqlSugarRepository relaPortCarrierLaneRep) { _codeCarrierRep = codeCarrierRep; _codeVesselRep = codeVesselRep; @@ -91,7 +95,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie _codeIssueTypeRep = codeIssueTypeRep; _commonModuleRep = commonModuleRep; _logger = logger; - + _codeLaneRep = codeLaneRep; + _relaPortCarrierLaneRep = relaPortCarrierLaneRep; } #endregion @@ -1257,6 +1262,52 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie } + + /// + /// 获取航线信息 + /// + /// + /// + [NonAction] + public async Task GetAllLane(bool flag = false) + { + if (flag) + { + if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_LANE)) + { + var list = await _codeLaneRep.ToListAsync(); + await _sysCacheService.SetAllCodeLane(list); + } + } + else + { + var list = await _codeLaneRep.ToListAsync(); + await _sysCacheService.SetAllCodeLane(list); + } + + + } + + [NonAction] + public async Task GetAllRelaPortCarrierLane(bool flag = false) + { + if (flag) + { + if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_LANE_PORT)) + { + var list = await _relaPortCarrierLaneRep.ToListAsync(); + await _sysCacheService.SetAllRelaPortCarrierLane(list); + } + } + else + { + var list = await _relaPortCarrierLaneRep.ToListAsync(); + await _sysCacheService.SetAllRelaPortCarrierLane(list); + } + + + } + [NonAction] public async Task GetAllMappingCtn(bool flag = false) { diff --git a/Myshipping.Core/Service/CommonDB/ICommonDBService.cs b/Myshipping.Core/Service/CommonDB/ICommonDBService.cs index b0bda9a1..957780b2 100644 --- a/Myshipping.Core/Service/CommonDB/ICommonDBService.cs +++ b/Myshipping.Core/Service/CommonDB/ICommonDBService.cs @@ -92,6 +92,18 @@ public interface ICommonDBService /// Task GetAllFrt(bool flag); + /// + /// 航线 + /// + /// + Task GetAllLane(bool flag); + + /// + /// 航线与港口的的关系 + /// + /// + Task GetAllRelaPortCarrierLane(bool flag); + /// /// 付费方式映射 /// diff --git a/Myshipping.Report/Controllers/ReportController.cs b/Myshipping.Report/Controllers/ReportController.cs index ed1b4318..6bc8d25f 100644 --- a/Myshipping.Report/Controllers/ReportController.cs +++ b/Myshipping.Report/Controllers/ReportController.cs @@ -17,6 +17,8 @@ namespace Myshipping.Report.Controllers { public class ReportController : Controller { + private readonly NLog.Logger log = NLog.LogManager.GetCurrentClassLogger(); + private SqlSugar.SqlSugarClient sqlSugarClient; public ReportController() @@ -59,6 +61,8 @@ namespace Myshipping.Report.Controllers var tmpFile = Path.Combine(savePath, $"{Guid.NewGuid()}{fileExt}"); Request.Files[0].SaveAs(tmpFile); + log.Debug($"临时保存模板文件:{tmpFile}"); + //生成报表 FastReport.Report report = new FastReport.Report(); report.Load(tmpFile); @@ -137,19 +141,25 @@ namespace Myshipping.Report.Controllers [HttpGet] public ActionResult BookingReportJson(long bookingId) { + log.Debug("test"); return Content(GetBookingJson(bookingId)); } [NonAction] private string GetBookingJson(long bookingId) { + log.Debug($"准备获取订舱数据:{bookingId}"); var order = sqlSugarClient.Queryable().First(x => x.Id == bookingId); var ctns = sqlSugarClient.Queryable().Where(x => x.BILLID == bookingId).ToList(); - return JsonConvert.SerializeObject(new + var strObj = JsonConvert.SerializeObject(new { order = order, ctns = ctns }); + + log.Debug($"订舱数据:{strObj}"); + + return strObj; } } } \ No newline at end of file diff --git a/Myshipping.Report/Global.asax.cs b/Myshipping.Report/Global.asax.cs index a373c26b..f3b354b8 100644 --- a/Myshipping.Report/Global.asax.cs +++ b/Myshipping.Report/Global.asax.cs @@ -15,6 +15,8 @@ namespace Myshipping.Report AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); + + } } } diff --git a/Myshipping.Report/Myshipping.Report.csproj b/Myshipping.Report/Myshipping.Report.csproj index 57346410..b1d68c6c 100644 --- a/Myshipping.Report/Myshipping.Report.csproj +++ b/Myshipping.Report/Myshipping.Report.csproj @@ -72,6 +72,9 @@ ..\packages\MySql.Data.8.0.31\lib\net452\MySql.Data.dll + + ..\packages\NLog.5.0.5\lib\net46\NLog.dll + ..\packages\SqlSugar.5.1.3.30\lib\SqlSugar.dll @@ -82,6 +85,7 @@ + ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll @@ -208,6 +212,7 @@ PreserveNewest + PreserveNewest diff --git a/Myshipping.Report/packages.config b/Myshipping.Report/packages.config index 60621510..e237bbd1 100644 --- a/Myshipping.Report/packages.config +++ b/Myshipping.Report/packages.config @@ -22,6 +22,7 @@ +