From 011e96933bc0334c9d7daa1585ca579f6fb4b234 Mon Sep 17 00:00:00 2001 From: wenjy Date: Mon, 3 Jun 2024 09:53:57 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E7=94=B5=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E9=80=9A=E8=BF=87=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=89=8D=E4=B8=80=E6=9D=A1=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ems.CollectService.Analysis/BufferAnalysis.cs | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Ems.CollectService.Analysis/BufferAnalysis.cs b/Ems.CollectService.Analysis/BufferAnalysis.cs index e4a3b4a..c10e5ab 100644 --- a/Ems.CollectService.Analysis/BufferAnalysis.cs +++ b/Ems.CollectService.Analysis/BufferAnalysis.cs @@ -587,7 +587,7 @@ namespace Ems.CollectService.Analysis } } - private ConcurrentDictionary monitorInstant = new ConcurrentDictionary(); + //private ConcurrentDictionary monitorInstant = new ConcurrentDictionary(); /// /// 过滤数据,与前一条相差超过4000不进行保存 @@ -609,7 +609,7 @@ namespace Ems.CollectService.Analysis break; } - if (!monitorInstant.ContainsKey(dnbInstant.monitorId)) + /*if (!monitorInstant.ContainsKey(dnbInstant.monitorId)) { logger.Info($"本地未获取到{dnbInstant.monitorId};"); monitorInstant.TryAdd(dnbInstant.monitorId,(decimal)dnbInstant.zxyg); @@ -618,17 +618,18 @@ namespace Ems.CollectService.Analysis } logger.Info($"校验判断{dnbInstant.monitorId};"); - var lastDnbInstant = monitorInstant[dnbInstant.monitorId]; - logger.Info($"本地缓存{dnbInstant.monitorId};前一条数据:{lastDnbInstant}"); - /*RecordDnbInstant lastDnbInstant = SqlSugarHelper.Db.Queryable() + var lastDnbInstant = monitorInstant[dnbInstant.monitorId];*/ + + RecordDnbInstant lastDnbInstant = SqlSugarHelper.Db.Queryable() .OrderByDescending(x => x.collectTime) .First(x => x.monitorId == dnbInstant.monitorId); if (lastDnbInstant == null) { + logger.Info($"设备{dnbInstant.monitorId};前一条数据为空"); break; - }*/ - + } + BaseMonitorInfo monitorInfo = SqlSugarHelper.Db.Queryable() .First(x => x.MonitorId == dnbInstant.monitorId); @@ -648,16 +649,16 @@ namespace Ems.CollectService.Analysis monitorInfo.Ct = 1; } - decimal? lastZxyg = lastDnbInstant * monitorInfo.Pt * monitorInfo.Ct; + decimal? lastZxyg = lastDnbInstant.zxyg * monitorInfo.Pt * monitorInfo.Ct; decimal? dnbInstantZxyg = dnbInstant.zxyg * monitorInfo.Pt * monitorInfo.Ct; decimal? zxygRes = dnbInstantZxyg - lastZxyg; var appConfigDifferenceValue = appConfig.differenceValue == 0 ? 4000 : appConfig.differenceValue; - logger.Info($"仪表:{dnbInstant.monitorId};PT:{monitorInfo.Pt};CT:{monitorInfo.Ct};当前数据:{dnbInstant.zxyg};上一条数据:{lastDnbInstant}"); + logger.Info($"仪表:{dnbInstant.monitorId};PT:{monitorInfo.Pt};CT:{monitorInfo.Ct};当前数据:{dnbInstant.zxyg};上一条数据:{lastDnbInstant.zxyg};相差:{zxygRes}"); - monitorInstant[dnbInstant.monitorId] = (decimal)dnbInstant.zxyg; - logger.Info($"更新本地缓存{dnbInstant.monitorId};数据:{dnbInstant.zxyg}"); + //monitorInstant[dnbInstant.monitorId] = (decimal)dnbInstant.zxyg; + //logger.Info($"更新本地缓存{dnbInstant.monitorId};数据:{dnbInstant.zxyg}"); if (zxygRes < 0) {