缓存处理

booking_auth_dev
wet 2 years ago
parent f324d30d0b
commit e7da66b958

@ -18,73 +18,73 @@ namespace Myshipping.Core.Job
Log.Information($"开始缓存公共库 {DateTime.Now}");
//船公司
await App.GetService<ICommonDBService>().GetAllCarrier();
await App.GetService<ICommonDBService>().GetAllCarrier(true);
//船公司映射
await App.GetService<ICommonDBService>().GetAllMappingCarrier();
await App.GetService<ICommonDBService>().GetAllMappingCarrier(true);
//船名
await App.GetService<ICommonDBService>().GetAllVessel();
await App.GetService<ICommonDBService>().GetAllVessel(true);
//船名映射
await App.GetService<ICommonDBService>().GetAllMappingVessel();
await App.GetService<ICommonDBService>().GetAllMappingVessel(true);
//场站映射
await App.GetService<ICommonDBService>().GetAllMappingYard();
await App.GetService<ICommonDBService>().GetAllMappingYard(true);
//船代
await App.GetService<ICommonDBService>().GetAllForwarder();
await App.GetService<ICommonDBService>().GetAllForwarder(true);
//场站
await App.GetService<ICommonDBService>().GetAllYard();
await App.GetService<ICommonDBService>().GetAllYard(true);
//起始港
await App.GetService<ICommonDBService>().GetAllPortload();
await App.GetService<ICommonDBService>().GetAllPortload(true);
//目的港
await App.GetService<ICommonDBService>().GetAllPort();
await App.GetService<ICommonDBService>().GetAllPort(true);
//包装
await App.GetService<ICommonDBService>().GetAllPackage();
await App.GetService<ICommonDBService>().GetAllPackage(true);
//运输方式
await App.GetService<ICommonDBService>().GetAllService();
await App.GetService<ICommonDBService>().GetAllService(true);
//箱型
await App.GetService<ICommonDBService>().GetAllCtn();
await App.GetService<ICommonDBService>().GetAllCtn(true);
//箱型映射
await App.GetService<ICommonDBService>().GetAllMappingCtn();
await App.GetService<ICommonDBService>().GetAllMappingCtn(true);
//付费方式
await App.GetService<ICommonDBService>().GetAllFrt();
await App.GetService<ICommonDBService>().GetAllFrt(true);
//付费方式映射
await App.GetService<ICommonDBService>().GetAllMappingFrt();
await App.GetService<ICommonDBService>().GetAllMappingFrt(true);
//起始港映射
await App.GetService<ICommonDBService>().GetAllMappingPortLoad();
await App.GetService<ICommonDBService>().GetAllMappingPortLoad(true);
//目的港映射
await App.GetService<ICommonDBService>().GetAllMappingPort();
await App.GetService<ICommonDBService>().GetAllMappingPort(true);
//包装映射
await App.GetService<ICommonDBService>().GetAllMappingPackage();
await App.GetService<ICommonDBService>().GetAllMappingPackage(true);
//运输服务映射
await App.GetService<ICommonDBService>().GetAllMappingService();
await App.GetService<ICommonDBService>().GetAllMappingService(true);
//签单方式
await App.GetService<ICommonDBService>().GetAllCodeIssueType();
await App.GetService<ICommonDBService>().GetAllCodeIssueType(true);
//缓存EDI数据
await App.GetService<IDjyEdiSettingService>().CacheData();
await App.GetService<IDjyEdiSettingService>().CacheData(true);
//缓存字典数据
await App.GetService<ISysDictDataService>().CacheData();
await App.GetService<ISysDictDataService>().CacheData(true);
//租户参数
await App.GetService<IDjyTenantParamService>().CacheData();
await App.GetService<IDjyTenantParamService>().CacheData(true);
//系统参数
await App.GetService<ISysConfigService>().CacheData();

@ -896,9 +896,17 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
#region 实现接口,获取公共数据并缓存
[NonAction]
public async Task GetAllCarrier()
public async Task GetAllCarrier(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_CARRIER))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_CARRIER))
{
var list = await _codeCarrierRep.ToListAsync();
await _sysCacheService.SetAllCodeCarrier(list);
}
}
else
{
var list = await _codeCarrierRep.ToListAsync();
await _sysCacheService.SetAllCodeCarrier(list);
@ -907,202 +915,375 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie
[NonAction]
public async Task GetAllMappingCarrier()
public async Task GetAllMappingCarrier(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_CARRIER))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_CARRIER))
{
var list = await _mappingCarrierRep.ToListAsync();
await _sysCacheService.SetAllMappingCarrier(list);
}
}
else
{
var list = await _mappingCarrierRep.ToListAsync();
await _sysCacheService.SetAllMappingCarrier(list);
}
}
[NonAction]
public async Task GetAllVessel()
public async Task GetAllVessel(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_VESSEL))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_VESSEL))
{
var list = await _codeVesselRep.ToListAsync();
await _sysCacheService.SetAllCodeVessel(list);
}
}
else
{
var list = await _codeVesselRep.ToListAsync();
await _sysCacheService.SetAllCodeVessel(list);
}
}
[NonAction]
public async Task GetAllMappingVessel()
public async Task GetAllMappingVessel(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_VESSEL))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_VESSEL))
{
var list = await _mappingVesselRep.ToListAsync();
await _sysCacheService.SetAllMappingVessel(list);
}
}
else
{
var list = await _mappingVesselRep.ToListAsync();
await _sysCacheService.SetAllMappingVessel(list);
}
}
[NonAction]
public async Task GetAllMappingYard()
public async Task GetAllMappingYard(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_YARD))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_YARD))
{
var list = await _mappingYardRep.ToListAsync();
await _sysCacheService.SetAllMappingYard(list);
}
}
else
{
var list = await _mappingYardRep.ToListAsync();
await _sysCacheService.SetAllMappingYard(list);
}
}
[NonAction]
public async Task GetAllForwarder()
public async Task GetAllForwarder(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_FORWARDER))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_FORWARDER))
{
var list = await _codeForwarderRep.ToListAsync();
await _sysCacheService.SetAllCodeForwarder(list);
}
}
else
{
var list = await _codeForwarderRep.ToListAsync();
await _sysCacheService.SetAllCodeForwarder(list);
}
}
[NonAction]
public async Task GetAllYard()
public async Task GetAllYard(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_YARD))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_YARD))
{
var list = await _codeYardRep.ToListAsync();
await _sysCacheService.SetAllCodeYard(list);
}
}
else
{
var list = await _codeYardRep.ToListAsync();
await _sysCacheService.SetAllCodeYard(list);
}
}
[NonAction]
public async Task GetAllPortload()
public async Task GetAllPortload(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_PORTLOAD))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_PORTLOAD))
{
var list = await _codePortLoadrRep.ToListAsync();
await _sysCacheService.SetAllCodePortLoad(list);
}
}
else
{
var list = await _codePortLoadrRep.ToListAsync();
await _sysCacheService.SetAllCodePortLoad(list);
}
}
[NonAction]
public async Task GetAllPort()
public async Task GetAllPort(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_PORT))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_PORT))
{
var list = await _codePortRep.ToListAsync();
await _sysCacheService.SetAllCodePort(list);
}
}
else
{
var list = await _codePortRep.ToListAsync();
await _sysCacheService.SetAllCodePort(list);
}
}
[NonAction]
public async Task GetAllPackage()
public async Task GetAllPackage(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_PACKAGE))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_PACKAGE))
{
var list = await _codePackageRep.ToListAsync();
await _sysCacheService.SetAllCodePackage(list);
}
}
else
{
var list = await _codePackageRep.ToListAsync();
await _sysCacheService.SetAllCodePackage(list);
}
}
[NonAction]
public async Task GetAllService()
public async Task GetAllService(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_SERVICE))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_SERVICE))
{
var list = await _codeServiceRep.ToListAsync();
await _sysCacheService.SetAllCodeService(list);
}
}
else
{
var list = await _codeServiceRep.ToListAsync();
await _sysCacheService.SetAllCodeService(list);
}
}
[NonAction]
public async Task GetAllCtn()
public async Task GetAllCtn(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_CTN))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_CTN))
{
var list = await _codeCtnRep.ToListAsync();
await _sysCacheService.SetAllCodeCtn(list);
}
}
else
{
var list = await _codeCtnRep.ToListAsync();
await _sysCacheService.SetAllCodeCtn(list);
}
}
[NonAction]
public async Task GetAllMappingCtn()
public async Task GetAllMappingCtn(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_CTN))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_CTN))
{
var list = await _mappingCtnRep.ToListAsync();
await _sysCacheService.SetAllMappingCtn(list);
}
}
else
{
var list = await _mappingCtnRep.ToListAsync();
await _sysCacheService.SetAllMappingCtn(list);
}
}
[NonAction]
public async Task GetAllFrt()
public async Task GetAllFrt(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_FRT))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_FRT))
{
var list = await _codeFrtRep.ToListAsync();
await _sysCacheService.SetAllCodeFrt(list);
}
}
else
{
var list = await _codeFrtRep.ToListAsync();
await _sysCacheService.SetAllCodeFrt(list);
}
}
[NonAction]
public async Task GetAllMappingFrt()
public async Task GetAllMappingFrt(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_FRT))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_FRT))
{
var list = await _mappingFrtRep.ToListAsync();
await _sysCacheService.SetAllMappingFrt(list);
}
}
else
{
var list = await _mappingFrtRep.ToListAsync();
await _sysCacheService.SetAllMappingFrt(list);
}
}
[NonAction]
public async Task GetAllMappingPortLoad()
public async Task GetAllMappingPortLoad(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_PORTLOAD))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_PORTLOAD))
{
var list = await _mappingPortLoadRep.ToListAsync();
await _sysCacheService.SetAllMappingPortLoad(list);
}
}
else
{
var list = await _mappingPortLoadRep.ToListAsync();
await _sysCacheService.SetAllMappingPortLoad(list);
}
}
[NonAction]
public async Task GetAllMappingPort()
public async Task GetAllMappingPort(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_PORT))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_PORT))
{
var list = await _mappingPortRep.ToListAsync();
await _sysCacheService.SetAllMappingPort(list);
}
}
else
{
var list = await _mappingPortRep.ToListAsync();
await _sysCacheService.SetAllMappingPort(list);
}
}
[NonAction]
public async Task GetAllMappingPackage()
public async Task GetAllMappingPackage(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_PACKAGE))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_PACKAGE))
{
var list = await _mappingPackageRep.ToListAsync();
await _sysCacheService.SetAllMappingPackage(list);
}
}
else
{
var list = await _mappingPackageRep.ToListAsync();
await _sysCacheService.SetAllMappingPackage(list);
}
}
[NonAction]
public async Task GetAllMappingService()
public async Task GetAllMappingService(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_SERVICE))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_SERVICE))
{
var list = await _mappingServiceRep.ToListAsync();
await _sysCacheService.SetAllMappingService(list);
}
}
else
{
var list = await _mappingServiceRep.ToListAsync();
await _sysCacheService.SetAllMappingService(list);
}
}
[NonAction]
public async Task GetAllCodeIssueType()
public async Task GetAllCodeIssueType(bool flag = false)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_CODEISSUETYPE))
if (flag)
{
if (!_sysCacheService.Exists(CommonConst.CACHE_KEY_COMMON_DB_MAPPING_CODEISSUETYPE))
{
var list = await _codeIssueTypeRep.ToListAsync();
await _sysCacheService.SetAllCodeIssueType(list);
}
}
else
{
var list = await _codeIssueTypeRep.ToListAsync();
await _sysCacheService.SetAllCodeIssueType(list);
}
}
#endregion

@ -12,111 +12,111 @@ public interface ICommonDBService
/// 获取船公司
/// </summary>
/// <returns></returns>
Task GetAllCarrier();
Task GetAllCarrier(bool flag);
/// <summary>
/// 获取船公司映射
/// </summary>
/// <returns></returns>
Task GetAllMappingCarrier();
Task GetAllMappingCarrier(bool flag);
/// <summary>
/// 获取船名
/// </summary>
/// <returns></returns>
Task GetAllVessel();
Task GetAllVessel(bool flag);
/// <summary>
/// 获取船名映射
/// </summary>
/// <returns></returns>
Task GetAllMappingVessel();
Task GetAllMappingVessel(bool flag);
/// <summary>
/// 获取船代
/// </summary>
/// <returns></returns>
Task GetAllForwarder();
Task GetAllForwarder(bool flag);
/// <summary>
/// 获取场站
/// </summary>
/// <returns></returns>
Task GetAllYard();
Task GetAllYard(bool flag);
/// <summary>
/// 获取场站映射
/// </summary>
/// <returns></returns>
Task GetAllMappingYard();
Task GetAllMappingYard(bool flag);
/// <summary>
/// 获取起始港
/// </summary>
/// <returns></returns>
Task GetAllPortload();
Task GetAllPortload(bool flag);
/// <summary>
/// 获取目的港
/// </summary>
/// <returns></returns>
Task GetAllPort();
Task GetAllPort(bool flag);
/// <summary>
/// 获取包装
/// </summary>
/// <returns></returns>
Task GetAllPackage();
Task GetAllPackage(bool flag);
/// <summary>
/// 获取运输方式
/// </summary>
/// <returns></returns>
Task GetAllService();
Task GetAllService(bool flag);
/// <summary>
/// 获取箱型
/// </summary>
/// <returns></returns>
Task GetAllCtn();
Task GetAllCtn(bool flag);
/// <summary>
/// 获取箱型映射
/// </summary>
/// <returns></returns>
Task GetAllMappingCtn();
Task GetAllMappingCtn(bool flag);
/// <summary>
/// 付费方式
/// </summary>
/// <returns></returns>
Task GetAllFrt();
Task GetAllFrt(bool flag);
/// <summary>
/// 付费方式映射
/// </summary>
Task GetAllMappingFrt();
Task GetAllMappingFrt(bool flag);
/// <summary>
/// 起始港映射
/// </summary>
Task GetAllMappingPortLoad();
Task GetAllMappingPortLoad(bool flag);
/// <summary>
/// 目的港映射
/// </summary>
Task GetAllMappingPort();
Task GetAllMappingPort(bool flag);
/// <summary>
/// 包装映射
/// </summary>
Task GetAllMappingPackage();
Task GetAllMappingPackage(bool flag);
/// <summary>
/// 运输服务映射
/// </summary>
Task GetAllMappingService();
Task GetAllMappingService(bool flag);
/// <summary>
/// 签单方式
/// </summary>
Task GetAllCodeIssueType();
Task GetAllCodeIssueType(bool flag);
}

@ -18,5 +18,7 @@ public interface ISysDictDataService
Task UpdateDictData(UpdateDictDataInput input);
Task<List<SysDictData>> GetDictDataByCode(string code);
Task CacheData();
Task CacheData(bool falg);
}

@ -199,10 +199,26 @@ public class SysDictDataService : ISysDictDataService, IDynamicApiController, IT
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
[NonAction]
public async Task CacheData()
public async Task CacheData(bool falg=false)
{
if (!_cache.Exists(CommonConst.CACHE_KEY_COMMON_DB_DICT_DATA))
if (falg)
{
if (!_cache.Exists(CommonConst.CACHE_KEY_COMMON_DB_DICT_DATA))
{
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,
IsFront = t.IsFront
}).ToListAsync();
await _cache.SetAllDictData(list);
}
} else {
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,
@ -216,7 +232,10 @@ public class SysDictDataService : ISysDictDataService, IDynamicApiController, IT
}).ToListAsync();
await _cache.SetAllDictData(list);
}
}
}

@ -135,15 +135,28 @@ namespace Myshipping.Core.Service
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
[NonAction]
public async Task CacheData()
public async Task CacheData(bool flag = false)
{
if (!_cacheService.Exists(CommonConst.CACHE_KEY_DJY_EDI_SETTING))
if (flag)
{
if (!_cacheService.Exists(CommonConst.CACHE_KEY_DJY_EDI_SETTING))
{
var list = _rep.AsQueryable().Filter(null, true).ToList();
await _cacheService.SetAllEdiSetting(list);
}
}
else
{
var list = _rep.AsQueryable().Filter(null, true).ToList();
await _cacheService.SetAllEdiSetting(list);
}
}
///// <summary>
///// 获取EDI参数设置列表
///// </summary>

@ -14,6 +14,7 @@ namespace Myshipping.Core.Service
Task<DjyEdiSetting> Get([FromQuery] GetDjyEdiSettingInput input);
//Task<dynamic> List([FromQuery] QueryDjyEdiSettingInput input);
Task CacheData();
Task CacheData(bool flag);
}
}

@ -89,7 +89,7 @@ namespace Myshipping.Core.Service
throw Oops.Oh(ErrorCode.Param008);
}
var list = await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.Id != input.Id);
var list = await _rep.FirstOrDefaultAsync(x => x.ParaCode == input.ParaCode && x.Id != input.Id);
if (list != null)
{
throw Oops.Oh(ErrorCode.Param004);
@ -314,14 +314,24 @@ namespace Myshipping.Core.Service
}
#endregion
public async Task CacheData()
public async Task CacheData(bool flag = false)
{
if (!_cache.Exists(CommonConst.CACHE_KEY_COMMON_DB_TENANT_PARAM_VALUE))
if (flag)
{
if (!_cache.Exists(CommonConst.CACHE_KEY_COMMON_DB_TENANT_PARAM_VALUE))
{
var list = await _valuerep.AsQueryable().Filter(null, true).ToListAsync();
await _cache.SetAllTenantParam(list);
}
}
else
{
var list = await _valuerep.AsQueryable().Filter(null, true).ToListAsync();
await _cache.SetAllTenantParam(list);
}
}
}
}

@ -18,6 +18,8 @@ namespace Myshipping.Core.Service
Task UpdateParamItem(DjyTenantParamItem input);
Task DeleteParamItem(long Id);
Task CacheData();
Task CacheData(bool flag);
}
}
Loading…
Cancel
Save