From 4450ece685a480401b9a97fd1ad45a12c7c13b01 Mon Sep 17 00:00:00 2001 From: wet <1034391973@qq.com> Date: Sun, 23 Apr 2023 17:26:47 +0800 Subject: [PATCH] 1 --- .../BookingOrderSeaeEdiService.cs | 4 + Myshipping.Core/Const/CommonConst.cs | 4 + Myshipping.Core/Job/CacheCommonWorker.cs | 3 + Myshipping.Core/Myshipping.Core.xml | 20 +++++ .../Service/Cache/ISysCacheService.cs | 15 ++++ .../Service/Cache/SysCacheService.cs | 18 +++- .../Service/CommonDB/CommonDBService.cs | 85 ++++++++++++++++++- .../Service/CommonDB/Dto/CodeForwarderDto.cs | 29 +++++++ .../Service/CommonDB/ICommonDBService.cs | 2 + 9 files changed, 178 insertions(+), 2 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrderSeaeEdi/BookingOrderSeaeEdiService.cs b/Myshipping.Application/Service/BookingOrderSeaeEdi/BookingOrderSeaeEdiService.cs index 9c493cb7..a11220a2 100644 --- a/Myshipping.Application/Service/BookingOrderSeaeEdi/BookingOrderSeaeEdiService.cs +++ b/Myshipping.Application/Service/BookingOrderSeaeEdi/BookingOrderSeaeEdiService.cs @@ -241,6 +241,10 @@ namespace Myshipping.Application MDATA mDATA = new MDATA(); List CTNDATA = new List(); mDATA = order.Adapt(); + var FORWARDER = mDATA.FORWARDER; + mDATA.FORWARDER = _cache.GetAllMappingForwarder().Result.Where(x => x.Code == FORWARDER && x.Module == "cangdan").Select(x => x.MapCode).FirstOrDefault() == null ? + _cache.GetAllCodeForwarder().Result.Where(x => x.Code == FORWARDER).Select(x => x.Name).FirstOrDefault() : + _cache.GetAllMappingForwarder().Result.Where(x => x.Code == FORWARDER && x.Module == "cangdan").Select(x => x.MapCode).FirstOrDefault(); CTNDATA = ctns.Adapt>(); custEDIDtos.Add( new CustEDIDto diff --git a/Myshipping.Core/Const/CommonConst.cs b/Myshipping.Core/Const/CommonConst.cs index ce719415..455c189d 100644 --- a/Myshipping.Core/Const/CommonConst.cs +++ b/Myshipping.Core/Const/CommonConst.cs @@ -144,6 +144,10 @@ public class CommonConst /// public const string CACHE_KEY_COMMON_DB_MAPPING_YARD = "CommonDbMappingYard"; /// + /// 船代映射 + /// + public const string CACHE_KEY_COMMON_DB_MAPPING_FORWARDER = "CommonDbMappingForwarder"; + /// /// 起始港映射 /// public const string CACHE_KEY_COMMON_DB_MAPPING_PORTLOAD = "CommonDbMappingPortLoad"; diff --git a/Myshipping.Core/Job/CacheCommonWorker.cs b/Myshipping.Core/Job/CacheCommonWorker.cs index 83eda428..10ec74a3 100644 --- a/Myshipping.Core/Job/CacheCommonWorker.cs +++ b/Myshipping.Core/Job/CacheCommonWorker.cs @@ -80,6 +80,9 @@ namespace Myshipping.Core.Job //签单映射 await App.GetService().GetAllMappingIssueType(true); + //船代映射 + await App.GetService().GetAllMappingForwarder(true); + //缓存EDI数据 await App.GetService().CacheData(true); diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index 1aeba5b0..668f7421 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -982,6 +982,26 @@ 备注 + + + 代码 + + + + + 模块 + + + + + 映射code + + + + + 备注 + + 代码 diff --git a/Myshipping.Core/Service/Cache/ISysCacheService.cs b/Myshipping.Core/Service/Cache/ISysCacheService.cs index f2edfd28..121a3bc7 100644 --- a/Myshipping.Core/Service/Cache/ISysCacheService.cs +++ b/Myshipping.Core/Service/Cache/ISysCacheService.cs @@ -145,6 +145,13 @@ public interface ISysCacheService /// /// Task> GetAllMappingYard(); + + + /// + /// 获取公共库 船代映射 + /// + /// + Task> GetAllMappingForwarder(); /// /// 设置公共库 船公司 /// @@ -233,6 +240,11 @@ public interface ISysCacheService /// /// Task SetAllMappingYard(List list); + /// + /// 设置公共库 船代映射 + /// + /// + Task SetAllMappingForwarder(List list); /// /// 设置公共库 起始港映射 @@ -304,6 +316,9 @@ public interface ISysCacheService /// Task SetAllMappingIssueType(List list); + + + /// /// 设置公共库 航线 /// diff --git a/Myshipping.Core/Service/Cache/SysCacheService.cs b/Myshipping.Core/Service/Cache/SysCacheService.cs index 1901e087..67b92192 100644 --- a/Myshipping.Core/Service/Cache/SysCacheService.cs +++ b/Myshipping.Core/Service/Cache/SysCacheService.cs @@ -458,7 +458,14 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet { return _cache.GetAsync>(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_YARD); } - + /// + /// 获取公共库 船代映射 + /// + /// + public Task> GetAllMappingForwarder() + { + return _cache.GetAsync>(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_YARD); + } /// /// 设置公共库 船公司 @@ -625,6 +632,15 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet { return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_YARD, list); } + + /// + /// 设置公共库 船代映射 + /// + /// + public Task SetAllMappingForwarder(List list) + { + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_FORWARDER, list); + } /// /// 设置公共库 起始港映射 /// diff --git a/Myshipping.Core/Service/CommonDB/CommonDBService.cs b/Myshipping.Core/Service/CommonDB/CommonDBService.cs index f8660a39..46b9d3f4 100644 --- a/Myshipping.Core/Service/CommonDB/CommonDBService.cs +++ b/Myshipping.Core/Service/CommonDB/CommonDBService.cs @@ -48,6 +48,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie private readonly SqlSugarRepository _codeLaneRep; private readonly SqlSugarRepository _relaPortCarrierLaneRep; private readonly SqlSugarRepository _codeCountryRep; + private readonly SqlSugarRepository _mappingForwarder; public CommonDBService(SqlSugarRepository codeCarrierRep, SqlSugarRepository codeVesselRep, SqlSugarRepository codeForwarderRep, @@ -74,7 +75,8 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie SqlSugarRepository codeLaneRep, SqlSugarRepository relaPortCarrierLaneRep, SqlSugarRepository mappingIssueTypeRep, - SqlSugarRepository codeCountryRep) + SqlSugarRepository codeCountryRep, + SqlSugarRepository mappingForwarder) { _codeCarrierRep = codeCarrierRep; _codeVesselRep = codeVesselRep; @@ -103,6 +105,7 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie _relaPortCarrierLaneRep = relaPortCarrierLaneRep; _codeCountryRep = codeCountryRep; _mappingIssueTypeRep= mappingIssueTypeRep; + _mappingForwarder = mappingForwarder; } #endregion @@ -381,6 +384,66 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie await GetAllForwarder(); } + + + + /// + /// 获取船代映射 + /// + [HttpGet("/commondb/mappingforwarderlist")] + public async Task MappingForwarderList([FromQuery] MappingQueryDto input) + { + //数量太多,不允许查询全部 + if (string.IsNullOrEmpty(input.Module) || input.Module.Length < 1) + { + throw Oops.Bah("请传入模块查询"); + } + + List list = await _sysCacheService.GetAllMappingForwarder(); + + var queryList = list.Where(x => x.Module == input.Module) + .WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) + || x.MapCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)); + if (queryList.Count() > 20) + { + return queryList.Take(input.Limit).OrderBy(x => x.Sort).ToList(); + } + return queryList.OrderBy(x => x.Sort).ToList(); + } + + /// + /// 新增编辑船代映射信息 + /// + [HttpPost("/commondb/addorupdateforwarderlist")] + public async Task AddOrUpdateMappingForwarder([FromBody] MappingForwarderDto dto) + { + + var list = await _sysCacheService.GetAllMappingForwarder(); + var count = list.Where(x => x.Code == dto.Code && x.Module == dto.Module && x.GID != dto.GID).Count(); + if (count > 0) + { + throw Oops.Bah(ErrorCode.D1006); + } + var entity = dto.Adapt(); + if (string.IsNullOrWhiteSpace(dto.GID)) + { + entity.GID = Guid.NewGuid().ToString(); + entity.CreateTime = DateTime.Now; + entity.CreateUser = UserManager.DjyUserId; + await _mappingForwarder.InsertAsync(entity); + } + else + { + entity.CreateTime = list.Where(x => x.GID == dto.GID).Select(x => x.CreateTime).FirstOrDefault(); + entity.CreateUser = list.Where(x => x.GID == dto.GID).Select(x => x.CreateUser).FirstOrDefault(); + entity.ModifyTime = DateTime.Now; + entity.ModifyUser = UserManager.DjyUserId; + await _mappingForwarder.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + } + await GetAllMappingForwarder(); + } + + #endregion #region 场站 @@ -2015,6 +2078,26 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie await _sysCacheService.SetAllMappingIssueType(list); } + } + + [NonAction] + public async Task GetAllMappingForwarder(bool flag = false) + { + if (flag) + { + if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_FORWARDER)) + { + var list = await _mappingForwarder.AsQueryable().OrderBy(x => x.MapCode).ToListAsync(); + await _sysCacheService.SetAllMappingForwarder(list); + } + } + else + { + var list = await _mappingForwarder.AsQueryable().OrderBy(x => x.MapCode).ToListAsync(); + await _sysCacheService.SetAllMappingForwarder(list); + } + + } #endregion diff --git a/Myshipping.Core/Service/CommonDB/Dto/CodeForwarderDto.cs b/Myshipping.Core/Service/CommonDB/Dto/CodeForwarderDto.cs index c58178fc..ee3c86aa 100644 --- a/Myshipping.Core/Service/CommonDB/Dto/CodeForwarderDto.cs +++ b/Myshipping.Core/Service/CommonDB/Dto/CodeForwarderDto.cs @@ -36,4 +36,33 @@ namespace Myshipping.Core.Service.CommonDB.Dto public int Sort { get; set; } public string ShowCode { get; set; } } + public class MappingForwarderDto + { + + public string GID { get; set; } + /// + /// 代码 + /// + public string Code { get; set; } + + /// + /// 模块 + /// + public string Module { get; set; } + + /// + /// 映射code + /// + public string MapCode { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + /// + /// 排序 + /// + public int Sort { get; set; } + } } diff --git a/Myshipping.Core/Service/CommonDB/ICommonDBService.cs b/Myshipping.Core/Service/CommonDB/ICommonDBService.cs index d3f6f628..16ce0a37 100644 --- a/Myshipping.Core/Service/CommonDB/ICommonDBService.cs +++ b/Myshipping.Core/Service/CommonDB/ICommonDBService.cs @@ -142,6 +142,8 @@ public interface ICommonDBService Task GetAllMappingIssueType(bool flag); + Task GetAllMappingForwarder(bool flag = false); + /// /// 保存航线信息 ///