From ffe41fa38be451d5e81cfe10f407dc0d7cb2d816 Mon Sep 17 00:00:00 2001 From: 18923810322 <1666941798@qq.com> Date: Thu, 12 Feb 2026 16:15:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E7=89=A9=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Public/ErpService.cs | 4 ++-- .../Services/Public/MaterialService.cs | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/BarCode.Web.Domain/Services/Public/ErpService.cs b/src/BarCode.Web.Domain/Services/Public/ErpService.cs index ede7c6c..72e7aba 100644 --- a/src/BarCode.Web.Domain/Services/Public/ErpService.cs +++ b/src/BarCode.Web.Domain/Services/Public/ErpService.cs @@ -182,12 +182,12 @@ namespace BarCode.Web.Domain.Services.Public else { var beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); - _logger.LogInformation($"物料拉取-开始时间:{beginTime}"); + _logger.LogInformation($"物料拉取-开始时间(20260212):{beginTime}"); //组装dto var erp_materials_list = mats.Select(x => _mapper.Map(x)).ToList(); _memoryCache.Set(_erpOptions.cache_materail_key, erp_materials_list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(DateTimeUtil.GetTotalMinutesTimeSpan()))); var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); - _logger.LogInformation($"物料拉取-结束时间:{endTime}"); + _logger.LogInformation($"物料拉取-结束时间(20260212):{endTime}"); return ResultList.ReSuccess(erp_materials_list); } diff --git a/src/BarCode.Web.Domain/Services/Public/MaterialService.cs b/src/BarCode.Web.Domain/Services/Public/MaterialService.cs index aa45211..09d4821 100644 --- a/src/BarCode.Web.Domain/Services/Public/MaterialService.cs +++ b/src/BarCode.Web.Domain/Services/Public/MaterialService.cs @@ -231,8 +231,20 @@ namespace BarCode.Web.Domain.Services _logger.LogInformation("同步金蝶新物料-修改物料:成功->" + updateList.Count + "条"); } } + //把数据加到缓存 + var mats2 = await _materialsRepositories.GetEntityList(); + if (mats2.Count != 0) + { + var beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + _logger.LogInformation($"把数据加到缓存-物料拉取-开始时间:{beginTime}"); + //组装dto + var erp_materials_list = mats2.Select(x => _mapper.Map(x)).ToList(); + _memoryCache.Set(_erpOptions.cache_materail_key, erp_materials_list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(DateTimeUtil.GetTotalMinutesTimeSpan()))); + var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); + _logger.LogInformation($"把数据加到缓存物料拉取-结束时间:{endTime}"); - _logger.LogInformation("同步金蝶新物料:结束->" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->添加数量:" + entitys.Count); + _logger.LogInformation("同步金蝶新物料:结束->" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->添加数量:" + entitys.Count); + } return Result.ReSuccess(); } catch (Exception ex)