change - 电过滤改为通过数据库获取前一条数据

master
wenjy 8 months ago
parent 2ebb5b9222
commit 011e96933b

@ -587,7 +587,7 @@ namespace Ems.CollectService.Analysis
} }
} }
private ConcurrentDictionary<string, decimal> monitorInstant = new ConcurrentDictionary<string, decimal>(); //private ConcurrentDictionary<string, decimal> monitorInstant = new ConcurrentDictionary<string, decimal>();
/// <summary> /// <summary>
/// 过滤数据与前一条相差超过4000不进行保存 /// 过滤数据与前一条相差超过4000不进行保存
@ -609,7 +609,7 @@ namespace Ems.CollectService.Analysis
break; break;
} }
if (!monitorInstant.ContainsKey(dnbInstant.monitorId)) /*if (!monitorInstant.ContainsKey(dnbInstant.monitorId))
{ {
logger.Info($"本地未获取到{dnbInstant.monitorId};"); logger.Info($"本地未获取到{dnbInstant.monitorId};");
monitorInstant.TryAdd(dnbInstant.monitorId,(decimal)dnbInstant.zxyg); monitorInstant.TryAdd(dnbInstant.monitorId,(decimal)dnbInstant.zxyg);
@ -618,17 +618,18 @@ namespace Ems.CollectService.Analysis
} }
logger.Info($"校验判断{dnbInstant.monitorId};"); logger.Info($"校验判断{dnbInstant.monitorId};");
var lastDnbInstant = monitorInstant[dnbInstant.monitorId]; var lastDnbInstant = monitorInstant[dnbInstant.monitorId];*/
logger.Info($"本地缓存{dnbInstant.monitorId};前一条数据:{lastDnbInstant}");
/*RecordDnbInstant lastDnbInstant = SqlSugarHelper.Db.Queryable<RecordDnbInstant>() RecordDnbInstant lastDnbInstant = SqlSugarHelper.Db.Queryable<RecordDnbInstant>()
.OrderByDescending(x => x.collectTime) .OrderByDescending(x => x.collectTime)
.First(x => x.monitorId == dnbInstant.monitorId); .First(x => x.monitorId == dnbInstant.monitorId);
if (lastDnbInstant == null) if (lastDnbInstant == null)
{ {
logger.Info($"设备{dnbInstant.monitorId};前一条数据为空");
break; break;
}*/ }
BaseMonitorInfo monitorInfo = SqlSugarHelper.Db.Queryable<BaseMonitorInfo>() BaseMonitorInfo monitorInfo = SqlSugarHelper.Db.Queryable<BaseMonitorInfo>()
.First(x => x.MonitorId == dnbInstant.monitorId); .First(x => x.MonitorId == dnbInstant.monitorId);
@ -648,16 +649,16 @@ namespace Ems.CollectService.Analysis
monitorInfo.Ct = 1; 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? dnbInstantZxyg = dnbInstant.zxyg * monitorInfo.Pt * monitorInfo.Ct;
decimal? zxygRes = dnbInstantZxyg - lastZxyg; decimal? zxygRes = dnbInstantZxyg - lastZxyg;
var appConfigDifferenceValue = appConfig.differenceValue == 0 ? 4000 : appConfig.differenceValue; 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; //monitorInstant[dnbInstant.monitorId] = (decimal)dnbInstant.zxyg;
logger.Info($"更新本地缓存{dnbInstant.monitorId};数据:{dnbInstant.zxyg}"); //logger.Info($"更新本地缓存{dnbInstant.monitorId};数据:{dnbInstant.zxyg}");
if (zxygRes < 0) if (zxygRes < 0)
{ {

Loading…
Cancel
Save