diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 9075f669..889a2da2 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -81,7 +81,7 @@ namespace Myshipping.Application private readonly SqlSugarRepository _repBookingStatus; const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING"; - const string CONST_MAPPING_MODULE_ROUTE = "BOOK_OR_CLOSING_ROUTE"; + const string CONST_MAPPING_MODULE_ROUTE = "BOOK_OR_CLOSING_RT"; public BookingOrderService(SqlSugarRepository rep, SqlSugarRepository repCtn, SqlSugarRepository ctndetailrep, SqlSugarRepository bookinglog, SqlSugarRepository bookinglogdetail, SqlSugarRepository bookingremark, diff --git a/Myshipping.Core/Job/CacheCommonWorker.cs b/Myshipping.Core/Job/CacheCommonWorker.cs index 6b2f438d..f6aa5ef5 100644 --- a/Myshipping.Core/Job/CacheCommonWorker.cs +++ b/Myshipping.Core/Job/CacheCommonWorker.cs @@ -86,6 +86,9 @@ namespace Myshipping.Core.Job //租户参数 await App.GetService().CacheData(); + //系统参数 + await App.GetService().GetAllSysConfig(); + Log.Information($"缓存公共库完成 {DateTime.Now}"); } } diff --git a/Myshipping.Core/Service/Cache/SysCacheService.cs b/Myshipping.Core/Service/Cache/SysCacheService.cs index 460eebd6..d4ead2de 100644 --- a/Myshipping.Core/Service/Cache/SysCacheService.cs +++ b/Myshipping.Core/Service/Cache/SysCacheService.cs @@ -448,18 +448,10 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllCodeVessel(List list) { - try - { - _logger.LogInformation("接收到缓存船名"); - return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_VESSEL, list.ToJsonString()); - } - catch (Exception ex) - { - - _logger.LogError("缓存船名异常:" + ex); - throw Oops.Oh(ex); - } - + + return _cache.SetAsync(CommonConst.CACHE_KEY_COMMON_DB_VESSEL, list.ToJsonString()); + + } /// @@ -721,6 +713,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet /// public Task SetAllEdiSetting(List list) { + return _cache.SetAsync(CommonConst.CACHE_KEY_DJY_EDI_SETTING, list); } diff --git a/Myshipping.Core/Service/CommonDB/CommonDBService.cs b/Myshipping.Core/Service/CommonDB/CommonDBService.cs index a4a8ad9f..ad0dcce7 100644 --- a/Myshipping.Core/Service/CommonDB/CommonDBService.cs +++ b/Myshipping.Core/Service/CommonDB/CommonDBService.cs @@ -850,200 +850,214 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie #region 实现接口,获取公共数据并缓存 [NonAction] - public async Task> GetAllCarrier() + public async Task GetAllCarrier() { - var list = await _codeCarrierRep.ToListAsync(); - await _sysCacheService.SetAllCodeCarrier(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_CARRIER")) + { + var list = await _codeCarrierRep.ToListAsync(); + await _sysCacheService.SetAllCodeCarrier(list); + } } [NonAction] - public async Task> GetAllMappingCarrier() + public async Task GetAllMappingCarrier() { - - var list = await _mappingCarrierRep.ToListAsync(); - await _sysCacheService.SetAllMappingCarrier(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_MAPPING_CARRIER")) + { + var list = await _mappingCarrierRep.ToListAsync(); + await _sysCacheService.SetAllMappingCarrier(list); + } } [NonAction] - public async Task> GetAllVessel() + public async Task GetAllVessel() { - try + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_VESSEL")) { - _logger.LogInformation("缓存船名!"); var list = await _codeVesselRep.ToListAsync(); _logger.LogInformation(list.ToJsonString()); await _sysCacheService.SetAllCodeVessel(list); - return list; - } - catch (Exception ex) - { - _logger.LogError("船名" + ex); - throw; } - } [NonAction] - public async Task> GetAllMappingVessel() + public async Task GetAllMappingVessel() { - - var list = await _mappingVesselRep.ToListAsync(); - await _sysCacheService.SetAllMappingVessel(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_MAPPING_VESSEL")) + { + var list = await _mappingVesselRep.ToListAsync(); + await _sysCacheService.SetAllMappingVessel(list); + } } [NonAction] - public async Task> GetAllMappingYard() + public async Task GetAllMappingYard() { - - var list = await _mappingYardRep.ToListAsync(); - await _sysCacheService.SetAllMappingYard(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_MAPPING_YARD")) + { + var list = await _mappingYardRep.ToListAsync(); + await _sysCacheService.SetAllMappingYard(list); + } } [NonAction] - public async Task> GetAllForwarder() + public async Task GetAllForwarder() { - var list = await _codeForwarderRep.ToListAsync(); - await _sysCacheService.SetAllCodeForwarder(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_FORWARDER")) + { + var list = await _codeForwarderRep.ToListAsync(); + await _sysCacheService.SetAllCodeForwarder(list); + } } [NonAction] - public async Task> GetAllYard() + public async Task GetAllYard() { - - var list = await _codeYardRep.ToListAsync(); - await _sysCacheService.SetAllCodeYard(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_YARD")) + { + var list = await _codeYardRep.ToListAsync(); + await _sysCacheService.SetAllCodeYard(list); + } } [NonAction] - public async Task> GetAllPortload() + public async Task GetAllPortload() { - - var list = await _codePortLoadrRep.ToListAsync(); - await _sysCacheService.SetAllCodePortLoad(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_PORTLOAD")) + { + var list = await _codePortLoadrRep.ToListAsync(); + await _sysCacheService.SetAllCodePortLoad(list); + } } [NonAction] - public async Task> GetAllPort() + public async Task GetAllPort() { - - var list = await _codePortRep.ToListAsync(); - await _sysCacheService.SetAllCodePort(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_PORT")) + { + var list = await _codePortRep.ToListAsync(); + await _sysCacheService.SetAllCodePort(list); + } } [NonAction] - public async Task> GetAllPackage() + public async Task GetAllPackage() { - - var list = await _codePackageRep.ToListAsync(); - await _sysCacheService.SetAllCodePackage(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_PACKAGE")) + { + var list = await _codePackageRep.ToListAsync(); + await _sysCacheService.SetAllCodePackage(list); + } } [NonAction] - public async Task> GetAllService() + public async Task GetAllService() { - - var list = await _codeServiceRep.ToListAsync(); - await _sysCacheService.SetAllCodeService(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_SERVICE")) + { + var list = await _codeServiceRep.ToListAsync(); + await _sysCacheService.SetAllCodeService(list); + } } [NonAction] - public async Task> GetAllCtn() + public async Task GetAllCtn() { - - var list = await _codeCtnRep.ToListAsync(); - await _sysCacheService.SetAllCodeCtn(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_CTN")) + { + var list = await _codeCtnRep.ToListAsync(); + await _sysCacheService.SetAllCodeCtn(list); + } } [NonAction] - public async Task> GetAllMappingCtn() + public async Task GetAllMappingCtn() { - - var list = await _mappingCtnRep.ToListAsync(); - await _sysCacheService.SetAllMappingCtn(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_MAPPING_CTN")) + { + var list = await _mappingCtnRep.ToListAsync(); + await _sysCacheService.SetAllMappingCtn(list); + } } [NonAction] - public async Task> GetAllFrt() + public async Task GetAllFrt() { - - var list = await _codeFrtRep.ToListAsync(); - await _sysCacheService.SetAllCodeFrt(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_FRT")) + { + var list = await _codeFrtRep.ToListAsync(); + await _sysCacheService.SetAllCodeFrt(list); + } } [NonAction] - public async Task> GetAllMappingFrt() + public async Task GetAllMappingFrt() { - - var list = await _mappingFrtRep.ToListAsync(); - await _sysCacheService.SetAllMappingFrt(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_MAPPING_FRT")) + { + var list = await _mappingFrtRep.ToListAsync(); + await _sysCacheService.SetAllMappingFrt(list); + } } [NonAction] - public async Task> GetAllMappingPortLoad() + public async Task GetAllMappingPortLoad() { - - var list = await _mappingPortLoadRep.ToListAsync(); - await _sysCacheService.SetAllMappingPortLoad(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_MAPPING_PORTLOAD")) + { + var list = await _mappingPortLoadRep.ToListAsync(); + await _sysCacheService.SetAllMappingPortLoad(list); + } } [NonAction] - public async Task> GetAllMappingPort() + public async Task GetAllMappingPort() { - - var list = await _mappingPortRep.ToListAsync(); - await _sysCacheService.SetAllMappingPort(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_MAPPING_PORT")) + { + var list = await _mappingPortRep.ToListAsync(); + await _sysCacheService.SetAllMappingPort(list); + } } [NonAction] - public async Task> GetAllMappingPackage() + public async Task GetAllMappingPackage() { - - var list = await _mappingPackageRep.ToListAsync(); - await _sysCacheService.SetAllMappingPackage(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_MAPPING_PACKAGE")) + { + var list = await _mappingPackageRep.ToListAsync(); + await _sysCacheService.SetAllMappingPackage(list); + } } [NonAction] - public async Task> GetAllMappingService() + public async Task GetAllMappingService() { - - var list = await _mappingServiceRep.ToListAsync(); - await _sysCacheService.SetAllMappingService(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_MAPPING_SERVICE")) + { + var list = await _mappingServiceRep.ToListAsync(); + await _sysCacheService.SetAllMappingService(list); + } } [NonAction] - public async Task> GetAllCodeIssueType() + public async Task GetAllCodeIssueType() { - var list = await _codeIssueTypeRep.ToListAsync(); - await _sysCacheService.SetAllCodeIssueType(list); - return list; + if (!_sysCacheService.Exists("CommonConst.CACHE_KEY_COMMON_DB_MAPPING_CODEISSUETYPE")) + { + var list = await _codeIssueTypeRep.ToListAsync(); + await _sysCacheService.SetAllCodeIssueType(list); + } } #endregion diff --git a/Myshipping.Core/Service/CommonDB/ICommonDBService.cs b/Myshipping.Core/Service/CommonDB/ICommonDBService.cs index 3f524920..00904fea 100644 --- a/Myshipping.Core/Service/CommonDB/ICommonDBService.cs +++ b/Myshipping.Core/Service/CommonDB/ICommonDBService.cs @@ -12,111 +12,111 @@ public interface ICommonDBService /// 获取船公司 /// /// - Task> GetAllCarrier(); + Task GetAllCarrier(); /// /// 获取船公司映射 /// /// - Task> GetAllMappingCarrier(); + Task GetAllMappingCarrier(); /// /// 获取船名 /// /// - Task> GetAllVessel(); + Task GetAllVessel(); /// /// 获取船名映射 /// /// - Task> GetAllMappingVessel(); + Task GetAllMappingVessel(); /// /// 获取船代 /// /// - Task> GetAllForwarder(); + Task GetAllForwarder(); /// /// 获取场站 /// /// - Task> GetAllYard(); + Task GetAllYard(); /// /// 获取场站映射 /// /// - Task> GetAllMappingYard(); + Task GetAllMappingYard(); /// /// 获取起始港 /// /// - Task> GetAllPortload(); + Task GetAllPortload(); /// /// 获取目的港 /// /// - Task> GetAllPort(); + Task GetAllPort(); /// /// 获取包装 /// /// - Task> GetAllPackage(); + Task GetAllPackage(); /// /// 获取运输方式 /// /// - Task> GetAllService(); + Task GetAllService(); /// /// 获取箱型 /// /// - Task> GetAllCtn(); + Task GetAllCtn(); /// /// 获取箱型映射 /// /// - Task> GetAllMappingCtn(); + Task GetAllMappingCtn(); /// /// 付费方式 /// /// - Task> GetAllFrt(); + Task GetAllFrt(); /// /// 付费方式映射 /// - Task> GetAllMappingFrt(); + Task GetAllMappingFrt(); /// /// 起始港映射 /// - Task> GetAllMappingPortLoad(); + Task GetAllMappingPortLoad(); /// /// 目的港映射 /// - Task> GetAllMappingPort(); + Task GetAllMappingPort(); /// /// 包装映射 /// - Task> GetAllMappingPackage(); + Task GetAllMappingPackage(); /// /// 运输服务映射 /// - Task> GetAllMappingService(); + Task GetAllMappingService(); /// /// 签单方式 /// - Task> GetAllCodeIssueType(); + Task GetAllCodeIssueType(); } diff --git a/Myshipping.Core/Service/Config/SysConfigService.cs b/Myshipping.Core/Service/Config/SysConfigService.cs index 4a00f044..bb8c1f94 100644 --- a/Myshipping.Core/Service/Config/SysConfigService.cs +++ b/Myshipping.Core/Service/Config/SysConfigService.cs @@ -156,8 +156,11 @@ public class SysConfigService : ISysConfigService, IDynamicApiController, ITrans /// public async Task GetAllSysConfig() { - var list = await _sysConfigRep.Where(u => u.GroupCode != CommonConst.DJY_CONST).ToListAsync(); - await _sysCacheService.SetAsync(CommonConst.DJY_CONST, list); + if (!_sysCacheService.Exists(CommonConst.DJY_CONST)) { + var list = await _sysConfigRep.Where(u => u.GroupCode != CommonConst.DJY_CONST).ToListAsync(); + await _sysCacheService.SetAsync(CommonConst.DJY_CONST, list); + } + } /// diff --git a/Myshipping.Core/Service/Dict/SysDictDataService.cs b/Myshipping.Core/Service/Dict/SysDictDataService.cs index 0645615f..d59ed835 100644 --- a/Myshipping.Core/Service/Dict/SysDictDataService.cs +++ b/Myshipping.Core/Service/Dict/SysDictDataService.cs @@ -201,17 +201,20 @@ public class SysDictDataService : ISysDictDataService, IDynamicApiController, IT [NonAction] public async Task CacheData() { - var list = await _sysDictDataRep.AsQueryable().InnerJoin((d, t) => d.TypeId == t.Id).Filter(null, true).Where((d, t) => t.Status == CommonStatus.ENABLE && d.Status == CommonStatus.ENABLE).Select((d, t) => new DictDataDto + if (!_cache.Exists("CommonConst.CACHE_KEY_COMMON_DB_DICT_DATA")) { - Id = d.Id, - TypeName = t.Name, - TypeCode = t.Code, - Value = d.Value, - Code = d.Code, - Sort = d.Sort, - Remark = d.Remark - }).ToListAsync(); - await _cache.SetAllDictData(list); + var list = await _sysDictDataRep.AsQueryable().InnerJoin((d, t) => d.TypeId == t.Id).Filter(null, true).Where((d, t) => t.Status == CommonStatus.ENABLE && d.Status == CommonStatus.ENABLE).Select((d, t) => new DictDataDto + { + Id = d.Id, + TypeName = t.Name, + TypeCode = t.Code, + Value = d.Value, + Code = d.Code, + Sort = d.Sort, + Remark = d.Remark + }).ToListAsync(); + await _cache.SetAllDictData(list); + } } diff --git a/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs b/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs index dcdb658e..f47aef8c 100644 --- a/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs +++ b/Myshipping.Core/Service/DjyEdiSetting/DjyEdiSettingService.cs @@ -22,7 +22,7 @@ namespace Myshipping.Core.Service private readonly SqlSugarRepository _rep; private readonly ISysCacheService _cacheService; private readonly ILogger _logger; - + public DjyEdiSettingService(SqlSugarRepository rep, ILogger logger, ISysCacheService cacheService) { _rep = rep; @@ -144,10 +144,11 @@ namespace Myshipping.Core.Service [NonAction] public async Task CacheData() { - _logger.LogInformation($"准备缓存EDI参数……"); - var list = _rep.AsQueryable().Filter(null, true).ToList(); - await _cacheService.SetAllEdiSetting(list); - _logger.LogInformation($"缓存EDI参数完成"); + if (!_cacheService.Exists("CommonConst.CACHE_KEY_DJY_EDI_SETTING")) + { + var list = _rep.AsQueryable().Filter(null, true).ToList(); + await _cacheService.SetAllEdiSetting(list); + } } ///// diff --git a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs index b0439dde..48fba2ac 100644 --- a/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs +++ b/Myshipping.Core/Service/DjyTenantParam/DjyTenantParamService.cs @@ -316,9 +316,12 @@ namespace Myshipping.Core.Service public async Task CacheData() { - var list = await _valuerep.AsQueryable().Filter(null, true).ToListAsync(); + if (!_cache.Exists("CommonConst.CACHE_KEY_COMMON_DB_TENANT_PARAM_VALUE")) + { + var list = await _valuerep.AsQueryable().Filter(null, true).ToListAsync(); - await _cache.SetAllTenantParam(list); + await _cache.SetAllTenantParam(list); + } } } } diff --git a/Myshipping.Report/Myshipping.Report.csproj.user b/Myshipping.Report/Myshipping.Report.csproj.user index 5831b7bf..c54031d1 100644 --- a/Myshipping.Report/Myshipping.Report.csproj.user +++ b/Myshipping.Report/Myshipping.Report.csproj.user @@ -8,7 +8,7 @@ - Debug|Any CPU + Release|Any CPU