diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml index dfffa3f2..6c022278 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml @@ -4531,11 +4531,10 @@ - + erp:基础数据-物料-分页查询 - diff --git a/src/WMS.Web.Domain/Services/Public/ErpService.cs b/src/WMS.Web.Domain/Services/Public/ErpService.cs index 83f75d02..a749fce7 100644 --- a/src/WMS.Web.Domain/Services/Public/ErpService.cs +++ b/src/WMS.Web.Domain/Services/Public/ErpService.cs @@ -40,17 +40,19 @@ namespace WMS.Web.Domain.Services.Public private ILogger _logger; private ERPGWSoapClient _client; private readonly IMemoryCache _memoryCache; - private readonly ISingleDataService _singleDataService; - private readonly ILoginRepositories _loginRepositories; private readonly IBasicsRepositories _basicsRepositories; + public readonly string cache_materail_key = "erp_materials_list"; + public readonly string cache_org_key = "erp_org_list"; + public readonly string cache_supplier_key = "erp_supplier_list"; + public readonly string cache_customer_key = "erp_customer_list"; + public readonly string cache_stock_key = "erp_stock_list"; + public readonly string cache_substock_key = "erp_substock_list"; public ErpService( IMapper mapper, IOptions erpOptions, IOptions appOptions, ILogger logger, - IMemoryCache memoryCache, - ISingleDataService singleDataService, - ILoginRepositories loginRepositories, IBasicsRepositories basicsRepositories) + IMemoryCache memoryCache, IBasicsRepositories basicsRepositories) { this._basicsRepositories = basicsRepositories; this._erpOptions = erpOptions?.Value; @@ -58,8 +60,6 @@ namespace WMS.Web.Domain.Services.Public this._mapper = mapper; this._logger = logger; this._memoryCache = memoryCache; - this._singleDataService = singleDataService; - this._loginRepositories = loginRepositories; } /// @@ -798,11 +798,10 @@ namespace WMS.Web.Domain.Services.Public try { //1.获取缓存中的物料数据; - var cache_key = "erp_materials_list"; - var materials = _memoryCache.Get>(cache_key); + var materials = _memoryCache.Get>(cache_materail_key); if (materials == null || materials.Count == 0) { - return await this.BillQueryForMaterialPagedList(cache_key); + return await this.BillQueryForMaterialPagedList(); } else { @@ -825,9 +824,8 @@ namespace WMS.Web.Domain.Services.Public /// public async Task> BillQueryForMaterial(int id) { - //1.获取缓存中的物料数据; - var cache_key = "erp_materials_list"; - var materials = _memoryCache.Get>(cache_key); + //1.获取缓存中的物料数据 + var materials = _memoryCache.Get>(cache_materail_key); if (materials == null || materials.Count == 0) return Result.ReSuccess(null); //2.通过ID取当前物料列表中的 @@ -840,7 +838,7 @@ namespace WMS.Web.Domain.Services.Public { //把取到的数据放集合中并重新给缓存 materials.Add(mater); - _memoryCache.Set(cache_key, materials, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(12))); + _memoryCache.Set(cache_materail_key, materials, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromDays(3))); return Result.ReSuccess(mater); } else @@ -853,9 +851,8 @@ namespace WMS.Web.Domain.Services.Public /// /// erp:基础数据-物料-分页查询 /// - /// /// - private async Task> BillQueryForMaterialPagedList(string cache_key) + private async Task> BillQueryForMaterialPagedList() { //2.先登录金蝶-拿到token var token_result = await this.Init(); @@ -914,7 +911,7 @@ namespace WMS.Web.Domain.Services.Public var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); _logger.LogInformation($"物料拉取-结束时间:{endTime}"); //5.物料集合进行缓存 - _memoryCache.Set(cache_key, erp_materials_list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromDays(7))); + _memoryCache.Set(cache_materail_key, erp_materials_list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromDays(3))); _logger.LogInformation($"物料拉取-总条数:{erp_materials_list.Count}"); return ResultList.ReSuccess(erp_materials_list); } @@ -986,8 +983,7 @@ namespace WMS.Web.Domain.Services.Public try { //1.获取缓存中的组织数据; - var cache_key = "erp_org_list"; - var orgs = _memoryCache.Get>(cache_key); + var orgs = _memoryCache.Get>(cache_org_key); if (orgs == null || orgs.Count == 0) { @@ -1029,7 +1025,7 @@ namespace WMS.Web.Domain.Services.Public } //5.组织集合进行缓存 - _memoryCache.Set(cache_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(12))); + _memoryCache.Set(cache_org_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromDays(3))); _logger.LogInformation($"组织拉取-总条数:{list.Count}"); return ResultList.ReSuccess(list); @@ -1055,8 +1051,7 @@ namespace WMS.Web.Domain.Services.Public try { //1.获取缓存中的供应商数据; - var cache_key = "erp_supplier_list"; - var suppliers = _memoryCache.Get>(cache_key); + var suppliers = _memoryCache.Get>(cache_supplier_key); if (suppliers == null || suppliers.Count == 0) { @@ -1098,7 +1093,7 @@ namespace WMS.Web.Domain.Services.Public } //5.供应商集合进行缓存 - _memoryCache.Set(cache_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(12))); + _memoryCache.Set(cache_supplier_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromDays(3))); _logger.LogInformation($"供应商拉取-总条数:{list.Count}"); return ResultList.ReSuccess(list); @@ -1123,8 +1118,7 @@ namespace WMS.Web.Domain.Services.Public try { //1.获取缓存中的供应商数据; - var cache_key = "erp_customer_list"; - var customers = _memoryCache.Get>(cache_key); + var customers = _memoryCache.Get>(cache_customer_key); if (customers == null || customers.Count == 0) { @@ -1177,7 +1171,7 @@ namespace WMS.Web.Domain.Services.Public var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); _logger.LogInformation($"供应商拉取-结束时间:{endTime}"); //5.供应商集合进行缓存 - _memoryCache.Set(cache_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(12))); + _memoryCache.Set(cache_customer_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromDays(3))); _logger.LogInformation($"供应商拉取-总条数:{list.Count}"); return ResultList.ReSuccess(list); @@ -1202,8 +1196,7 @@ namespace WMS.Web.Domain.Services.Public try { //1.获取缓存中的仓库数据; - var cache_key = "erp_supplier_list"; - var stocks = _memoryCache.Get>(cache_key); + var stocks = _memoryCache.Get>(cache_stock_key); if (stocks == null || stocks.Count == 0) { //2.先登录金蝶-拿到token @@ -1240,7 +1233,7 @@ namespace WMS.Web.Domain.Services.Public } //5.供应商集合进行缓存 - _memoryCache.Set(cache_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(12))); + _memoryCache.Set(cache_stock_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromDays(3))); _logger.LogInformation($"仓库拉取-总条数:{list.Count}"); return ResultList.ReSuccess(list); } @@ -1265,8 +1258,7 @@ namespace WMS.Web.Domain.Services.Public try { //1.获取缓存中的仓库数据; - var cache_key = "erp_substock_list"; - var stocks = _memoryCache.Get>(cache_key); + var stocks = _memoryCache.Get>(cache_substock_key); if (stocks == null || stocks.Count == 0) { var token_result = await this.Init(); @@ -1297,7 +1289,7 @@ namespace WMS.Web.Domain.Services.Public } //5.供应商集合进行缓存 只有查询全部的时候才缓存 - _memoryCache.Set(cache_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(12))); + _memoryCache.Set(cache_substock_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromDays(3))); _logger.LogInformation($"子仓库拉取-总条数:{list.Count}"); return ResultList.ReSuccess(list); }