diff --git a/Ems.CollectService.Analysis/BufferAnalysis.cs b/Ems.CollectService.Analysis/BufferAnalysis.cs index 9a4aa7b..e4a3b4a 100644 --- a/Ems.CollectService.Analysis/BufferAnalysis.cs +++ b/Ems.CollectService.Analysis/BufferAnalysis.cs @@ -7,6 +7,7 @@ using NetTaste; using NLog; using SqlSugar; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Data.SqlTypes; using System.Linq; @@ -552,10 +553,13 @@ namespace Ems.CollectService.Analysis { if (recordDnbInstant.zxyg != appConfig.virtualValue) { - var info = SqlSugarHelper.Db.Insertable(recordDnbInstant).ExecuteCommand(); - if (info > 0) + if (FIlterDnbInstant(recordDnbInstant)) { - logger.Info($"仪表:{recordDnbInstant.monitorId}数据保存成功"); + var info = SqlSugarHelper.Db.Insertable(recordDnbInstant).ExecuteCommand(); + if (info > 0) + { + logger.Info($"仪表:{recordDnbInstant.monitorId}数据保存成功"); + } } } else @@ -583,7 +587,7 @@ namespace Ems.CollectService.Analysis } } - private Dictionary monitorInstant = new Dictionary(); + private ConcurrentDictionary monitorInstant = new ConcurrentDictionary(); /// /// 过滤数据,与前一条相差超过4000不进行保存 @@ -608,14 +612,14 @@ namespace Ems.CollectService.Analysis if (!monitorInstant.ContainsKey(dnbInstant.monitorId)) { logger.Info($"本地未获取到{dnbInstant.monitorId};"); - monitorInstant.Add(dnbInstant.monitorId,(decimal)dnbInstant.zxyg); + monitorInstant.TryAdd(dnbInstant.monitorId,(decimal)dnbInstant.zxyg); logger.Info($"本地缓存{dnbInstant.monitorId};数据:{dnbInstant.zxyg}"); break; } logger.Info($"校验判断{dnbInstant.monitorId};"); var lastDnbInstant = monitorInstant[dnbInstant.monitorId]; - logger.Info($"本地缓存{dnbInstant.monitorId};前一条数据:{dnbInstant.zxyg}"); + logger.Info($"本地缓存{dnbInstant.monitorId};前一条数据:{lastDnbInstant}"); /*RecordDnbInstant lastDnbInstant = SqlSugarHelper.Db.Queryable() .OrderByDescending(x => x.collectTime) .First(x => x.monitorId == dnbInstant.monitorId); @@ -654,6 +658,12 @@ namespace Ems.CollectService.Analysis monitorInstant[dnbInstant.monitorId] = (decimal)dnbInstant.zxyg; logger.Info($"更新本地缓存{dnbInstant.monitorId};数据:{dnbInstant.zxyg}"); + + if (zxygRes < 0) + { + logger.Info($"仪表:{dnbInstant.monitorId};与前一条数据相差:{zxygRes};小于0,不进行保存"); + result = false; + } if (zxygRes >= appConfigDifferenceValue) { diff --git a/Ems.CollectService.Entity/BaseMonitorInfo.cs b/Ems.CollectService.Entity/BaseMonitorInfo.cs index 21bd6fd..23aa4e6 100644 --- a/Ems.CollectService.Entity/BaseMonitorInfo.cs +++ b/Ems.CollectService.Entity/BaseMonitorInfo.cs @@ -60,21 +60,7 @@ namespace Ems.CollectService.Entity /// [SugarColumn(ColumnName="grade" )] public int? Grade { get; set; } - /// - /// 建筑类型 - /// - [SugarColumn(ColumnName="build_id" )] - public string BuildId { get; set; } - /// - /// 分项类型 - /// - [SugarColumn(ColumnName="subentry_id" )] - public string SubentryId { get; set; } - /// - /// 业态类型 - /// - [SugarColumn(ColumnName="business_id" )] - public string BusinessId { get; set; } + /// /// 传感器仪表 ///