缓存方式变更

booking_auth_dev
wet 2 years ago
parent 68eb2101a1
commit 3db77474bf

@ -86,6 +86,9 @@ namespace Myshipping.Core.Job
//租户参数
await App.GetService<IDjyTenantParamService>().CacheData();
//系统参数
await App.GetService<ISysConfigService>().GetAllSysConfig();
Log.Information($"缓存公共库完成 {DateTime.Now}");
}
}

@ -692,6 +692,11 @@
EDI映射
</summary>
</member>
<member name="F:Myshipping.Core.CommonConst.DJY_CONST">
<summary>
系统配置
</summary>
</member>
<member name="F:Myshipping.Core.CommonConst.ENTITY_ASSEMBLY_NAME">
<summary>
程序集
@ -7912,12 +7917,10 @@
<param name="code"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Core.Service.SysConfigService.UpdateConfigCache(System.String,System.Object)">
<member name="M:Myshipping.Core.Service.SysConfigService.GetAllSysConfig">
<summary>
更新配置缓存
</summary>
<param name="code"></param>
<param name="value"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Core.Service.SysConfigService.GetDemoEnvFlag">

@ -448,18 +448,10 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet
/// <returns></returns>
public Task SetAllCodeVessel(List<CodeVessel> 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());
}
/// <summary>
@ -721,6 +713,7 @@ public class SysCacheService : ISysCacheService, IDynamicApiController, ISinglet
/// <returns></returns>
public Task SetAllEdiSetting(List<DjyEdiSetting> list)
{
return _cache.SetAsync(CommonConst.CACHE_KEY_DJY_EDI_SETTING, list);
}

@ -850,200 +850,214 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
#region 实现接口,获取公共数据并缓存
[NonAction]
public async Task<List<CodeCarrier>> 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<List<MappingCarrier>> 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<List<CodeVessel>> 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<List<MappingVessel>> 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<List<MappingYard>> 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<List<CodeForwarder>> 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<List<CodeYard>> 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<List<CodePortLoad>> 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<List<CodePort>> 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<List<CodePackage>> 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<List<CodeService>> 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<List<CodeCtn>> 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<List<MappingCtn>> 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<List<CodeFrt>> 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<List<MappingFrt>> 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<List<MappingPortLoad>> 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<List<MappingPort>> 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<List<MappingPackage>> 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<List<MappingService>> 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<List<CodeIssueType>> 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

@ -12,111 +12,111 @@ public interface ICommonDBService
/// 获取船公司
/// </summary>
/// <returns></returns>
Task<List<CodeCarrier>> GetAllCarrier();
Task GetAllCarrier();
/// <summary>
/// 获取船公司映射
/// </summary>
/// <returns></returns>
Task<List<MappingCarrier>> GetAllMappingCarrier();
Task GetAllMappingCarrier();
/// <summary>
/// 获取船名
/// </summary>
/// <returns></returns>
Task<List<CodeVessel>> GetAllVessel();
Task GetAllVessel();
/// <summary>
/// 获取船名映射
/// </summary>
/// <returns></returns>
Task<List<MappingVessel>> GetAllMappingVessel();
Task GetAllMappingVessel();
/// <summary>
/// 获取船代
/// </summary>
/// <returns></returns>
Task<List<CodeForwarder>> GetAllForwarder();
Task GetAllForwarder();
/// <summary>
/// 获取场站
/// </summary>
/// <returns></returns>
Task<List<CodeYard>> GetAllYard();
Task GetAllYard();
/// <summary>
/// 获取场站映射
/// </summary>
/// <returns></returns>
Task<List<MappingYard>> GetAllMappingYard();
Task GetAllMappingYard();
/// <summary>
/// 获取起始港
/// </summary>
/// <returns></returns>
Task<List<CodePortLoad>> GetAllPortload();
Task GetAllPortload();
/// <summary>
/// 获取目的港
/// </summary>
/// <returns></returns>
Task<List<CodePort>> GetAllPort();
Task GetAllPort();
/// <summary>
/// 获取包装
/// </summary>
/// <returns></returns>
Task<List<CodePackage>> GetAllPackage();
Task GetAllPackage();
/// <summary>
/// 获取运输方式
/// </summary>
/// <returns></returns>
Task<List<CodeService>> GetAllService();
Task GetAllService();
/// <summary>
/// 获取箱型
/// </summary>
/// <returns></returns>
Task<List<CodeCtn>> GetAllCtn();
Task GetAllCtn();
/// <summary>
/// 获取箱型映射
/// </summary>
/// <returns></returns>
Task<List<MappingCtn>> GetAllMappingCtn();
Task GetAllMappingCtn();
/// <summary>
/// 付费方式
/// </summary>
/// <returns></returns>
Task<List<CodeFrt>> GetAllFrt();
Task GetAllFrt();
/// <summary>
/// 付费方式映射
/// </summary>
Task<List<MappingFrt>> GetAllMappingFrt();
Task GetAllMappingFrt();
/// <summary>
/// 起始港映射
/// </summary>
Task<List<MappingPortLoad>> GetAllMappingPortLoad();
Task GetAllMappingPortLoad();
/// <summary>
/// 目的港映射
/// </summary>
Task<List<MappingPort>> GetAllMappingPort();
Task GetAllMappingPort();
/// <summary>
/// 包装映射
/// </summary>
Task<List<MappingPackage>> GetAllMappingPackage();
Task GetAllMappingPackage();
/// <summary>
/// 运输服务映射
/// </summary>
Task<List<MappingService>> GetAllMappingService();
Task GetAllMappingService();
/// <summary>
/// 签单方式
/// </summary>
Task<List<CodeIssueType>> GetAllCodeIssueType();
Task GetAllCodeIssueType();
}

@ -156,8 +156,11 @@ public class SysConfigService : ISysConfigService, IDynamicApiController, ITrans
/// <returns></returns>
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);
}
}
/// <summary>

@ -201,17 +201,20 @@ public class SysDictDataService : ISysDictDataService, IDynamicApiController, IT
[NonAction]
public async Task CacheData()
{
var list = await _sysDictDataRep.AsQueryable().InnerJoin<SysDictType>((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<SysDictType>((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);
}
}

@ -21,7 +21,7 @@ namespace Myshipping.Core.Service
private readonly SqlSugarRepository<DjyEdiSetting> _rep;
private readonly ISysCacheService _cacheService;
private readonly ILogger<DjyEdiSetting> _logger;
public DjyEdiSettingService(SqlSugarRepository<DjyEdiSetting> rep, ILogger<DjyEdiSetting> logger, ISysCacheService cacheService)
{
_rep = rep;
@ -136,10 +136,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);
}
}
///// <summary>

@ -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);
}
}
}
}

@ -8,7 +8,7 @@
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>

Loading…
Cancel
Save