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) {