|
|
|
@ -7,6 +7,7 @@ using NetTaste;
|
|
|
|
|
using NLog;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data.SqlTypes;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net.Sockets;
|
|
|
|
@ -25,6 +26,8 @@ namespace Ems.CollectService.Analysis
|
|
|
|
|
|
|
|
|
|
private AppConfig appConfig = AppConfig.Instance;
|
|
|
|
|
|
|
|
|
|
private JsonChange jsonChange = JsonChange.Instance;
|
|
|
|
|
|
|
|
|
|
//private SqlSugarClient baseService = SqlGenerator.GetMySqlInstance();
|
|
|
|
|
|
|
|
|
|
private static readonly Lazy<BufferAnalysis> lazy = new Lazy<BufferAnalysis>(() => new BufferAnalysis());
|
|
|
|
@ -576,10 +579,12 @@ namespace Ems.CollectService.Analysis
|
|
|
|
|
}
|
|
|
|
|
}catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logger.Error($"仪表:{recordDnbInstant.monitorId}数据保存异常:{ex.Message}");
|
|
|
|
|
logger.Info($"仪表:{recordDnbInstant.monitorId}数据保存异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Dictionary<string, decimal> monitorInstant = new Dictionary<string, decimal>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 过滤数据,与前一条相差超过4000不进行保存
|
|
|
|
|
/// </summary>
|
|
|
|
@ -589,15 +594,36 @@ namespace Ems.CollectService.Analysis
|
|
|
|
|
{
|
|
|
|
|
bool result = true;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
RecordDnbInstant lastDnbInstant = SqlSugarHelper.Db.Queryable<RecordDnbInstant>()
|
|
|
|
|
|
|
|
|
|
List<string> filterMonitorId = new List<string>(){ "E0076_0100", "E0076_0200", "E0076_0300", "E0076_0400" };
|
|
|
|
|
if (!filterMonitorId.Contains(dnbInstant.monitorId))
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!monitorInstant.ContainsKey(dnbInstant.monitorId))
|
|
|
|
|
{
|
|
|
|
|
logger.Info($"本地未获取到{dnbInstant.monitorId};");
|
|
|
|
|
monitorInstant.Add(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}");
|
|
|
|
|
/*RecordDnbInstant lastDnbInstant = SqlSugarHelper.Db.Queryable<RecordDnbInstant>()
|
|
|
|
|
.OrderByDescending(x => x.collectTime)
|
|
|
|
|
.First(x => x.monitorId == dnbInstant.monitorId);
|
|
|
|
|
|
|
|
|
|
if (lastDnbInstant == null)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
BaseMonitorInfo monitorInfo = SqlSugarHelper.Db.Queryable<BaseMonitorInfo>()
|
|
|
|
|
.First(x => x.MonitorId == dnbInstant.monitorId);
|
|
|
|
@ -618,18 +644,34 @@ namespace Ems.CollectService.Analysis
|
|
|
|
|
monitorInfo.Ct = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
decimal? lastZxyg = lastDnbInstant.zxyg * monitorInfo.Pt * monitorInfo.Ct;
|
|
|
|
|
decimal? lastZxyg = lastDnbInstant * monitorInfo.Pt * monitorInfo.Ct;
|
|
|
|
|
|
|
|
|
|
decimal? dnbInstantZxyg = dnbInstant.zxyg * monitorInfo.Pt * monitorInfo.Ct;
|
|
|
|
|
|
|
|
|
|
decimal? zxygRes = dnbInstantZxyg - lastZxyg;
|
|
|
|
|
var appConfigDifferenceValue = appConfig.differenceValue == 0 ? 4000 : appConfig.differenceValue;
|
|
|
|
|
if ( zxygRes >= appConfigDifferenceValue)
|
|
|
|
|
logger.Info($"仪表:{dnbInstant.monitorId};PT:{monitorInfo.Pt};CT:{monitorInfo.Ct};当前数据:{dnbInstant.zxyg};上一条数据:{lastDnbInstant}");
|
|
|
|
|
|
|
|
|
|
monitorInstant[dnbInstant.monitorId] = (decimal)dnbInstant.zxyg;
|
|
|
|
|
logger.Info($"更新本地缓存{dnbInstant.monitorId};数据:{dnbInstant.zxyg}");
|
|
|
|
|
|
|
|
|
|
if (zxygRes >= appConfigDifferenceValue)
|
|
|
|
|
{
|
|
|
|
|
logger.Info($"仪表:{dnbInstant.monitorId}与上一条数据相差超过4000,不进行保存");
|
|
|
|
|
logger.Info($"仪表:{dnbInstant.monitorId};与前一条数据相差:{zxygRes};超过4000,不进行保存");
|
|
|
|
|
result = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*if (dnbInstant.zxyg == 0)
|
|
|
|
|
{
|
|
|
|
|
logger.Info($"仪表:{dnbInstant.monitorId}数据为0,不进行保存");
|
|
|
|
|
result = false;
|
|
|
|
|
}*/
|
|
|
|
|
} while (false);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
logger.Info($"仪表:{dnbInstant.monitorId}数据过滤异常:{e.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|