add - FFFF异常值过滤

master
wenjy 1 year ago
parent 98b54eab7f
commit 9afa918010

@ -1,5 +1,6 @@
using Ems.CollectService.Common; using Ems.CollectService.Common;
using Ems.CollectService.Entity; using Ems.CollectService.Entity;
using Ems.CollectService.Entity.config;
using Ems.CollectService.Entity.dto; using Ems.CollectService.Entity.dto;
using Ems.CollectService.SqlSugarCore; using Ems.CollectService.SqlSugarCore;
using NetTaste; using NetTaste;
@ -21,6 +22,8 @@ namespace Ems.CollectService.Analysis
private MsgUtil msgUtil = MsgUtil.Instance; private MsgUtil msgUtil = MsgUtil.Instance;
private AppConfig appConfig = AppConfig.Instance;
//private SqlSugarClient baseService = SqlGenerator.GetMySqlInstance(); //private SqlSugarClient baseService = SqlGenerator.GetMySqlInstance();
private static readonly Lazy<BufferAnalysis> lazy = new Lazy<BufferAnalysis>(() => new BufferAnalysis()); private static readonly Lazy<BufferAnalysis> lazy = new Lazy<BufferAnalysis>(() => new BufferAnalysis());
@ -247,7 +250,7 @@ namespace Ems.CollectService.Analysis
if (double.IsNaN(f_UA)) if (double.IsNaN(f_UA))
{ {
//此处判断a为NaN //此处判断a为NaN
recordDnbInstant.vA = 0; recordDnbInstant.vA = appConfig.virtualValue;
} }
else else
{ {
@ -441,12 +444,35 @@ namespace Ems.CollectService.Analysis
logger.Info($"仪表:{recordDnbInstant.monitorId};解析完成数据:{logInfoStr}"); logger.Info($"仪表:{recordDnbInstant.monitorId};解析完成数据:{logInfoStr}");
recordDnbInstant.collectType = collectType; recordDnbInstant.collectType = collectType;
recordDnbInstant.recordTime = DateTime.Now; recordDnbInstant.recordTime = DateTime.Now;
//var info = await baseService.Insertable<RecordDnbInstant>(recordDnbInstant).ExecuteCommandAsync();
var info = SqlSugarHelper.Db.Insertable<RecordDnbInstant>(recordDnbInstant).ExecuteCommand(); if (appConfig.virtualFlag)
if (info > 0) {
if (recordDnbInstant.vA != appConfig.virtualValue)
{
var info = SqlSugarHelper.Db.Insertable<RecordDnbInstant>(recordDnbInstant).ExecuteCommand();
if (info > 0)
{
logger.Info($"仪表:{recordDnbInstant.monitorId}数据保存成功");
}
}
else
{
logger.Info($"仪表:{recordDnbInstant.monitorId}存在FFFF值不保存该条数据");
}
}
else
{ {
logger.Info($"仪表:{recordDnbInstant.monitorId}数据保存成功");
recordDnbInstant.vA = recordDnbInstant.vA == appConfig.virtualValue ? 0 : recordDnbInstant.vA;
var info = SqlSugarHelper.Db.Insertable<RecordDnbInstant>(recordDnbInstant).ExecuteCommand();
if (info > 0)
{
logger.Info($"仪表:{recordDnbInstant.monitorId}数据保存成功");
}
} }
} }
iFirstMeterID += 70; iFirstMeterID += 70;
}//end for }//end for
@ -611,7 +637,7 @@ namespace Ems.CollectService.Analysis
logInfoStr += $";瞬时流值:{f_FluxInstantValue}"; logInfoStr += $";瞬时流值:{f_FluxInstantValue}";
if (float.IsNaN(f_FluxInstantValue)) if (float.IsNaN(f_FluxInstantValue))
{ {
recordWaterInstant.fluxFlow = 0; recordWaterInstant.fluxFlow = appConfig.virtualValue;
} }
else else
@ -714,13 +740,34 @@ namespace Ems.CollectService.Analysis
logger.Info($"仪表:{recordWaterInstant.monitorId};解析完成数据:{logInfoStr}"); logger.Info($"仪表:{recordWaterInstant.monitorId};解析完成数据:{logInfoStr}");
recordWaterInstant.collectType = collectType; recordWaterInstant.collectType = collectType;
recordWaterInstant.recordTime = DateTime.Now; recordWaterInstant.recordTime = DateTime.Now;
//var info = await baseService.Insertable<RecordWaterInstant>(recordWaterInstant).ExecuteCommandAsync(); if (appConfig.virtualFlag)
{
if (recordWaterInstant.fluxFlow != appConfig.virtualValue)
{
var info = SqlSugarHelper.Db.Insertable<RecordWaterInstant>(recordWaterInstant).ExecuteCommand(); var info = SqlSugarHelper.Db.Insertable<RecordWaterInstant>(recordWaterInstant).ExecuteCommand();
if (info > 0) if (info > 0)
{
logger.Info($"仪表:{recordWaterInstant.monitorId}数据保存成功");
}
}
else
{
logger.Info($"仪表:{recordWaterInstant.monitorId}存在FFFF值不保存该条数据");
}
}
else
{ {
logger.Info($"仪表:{recordWaterInstant.monitorId}数据保存成功"); recordWaterInstant.fluxFlow = recordWaterInstant.fluxFlow == appConfig.virtualValue ? 0 : recordWaterInstant.fluxFlow;
var info = SqlSugarHelper.Db.Insertable<RecordWaterInstant>(recordWaterInstant).ExecuteCommand();
if (info > 0)
{
logger.Info($"仪表:{recordWaterInstant.monitorId}数据保存成功");
}
} }
} }
iFirstMeterID += 58; iFirstMeterID += 58;
}//end for }//end for

@ -45,5 +45,17 @@ namespace Ems.CollectService.Entity.config
get { return iNIFile.IniReadValue("SystemConfig", "mysqlConnStr"); } get { return iNIFile.IniReadValue("SystemConfig", "mysqlConnStr"); }
set { iNIFile.IniWriteValue("SystemConfig", "mysqlConnStr", value.ToString()); } set { iNIFile.IniWriteValue("SystemConfig", "mysqlConnStr", value.ToString()); }
} }
public decimal virtualValue
{
get { return Convert.ToDecimal(iNIFile.IniReadValue("SystemConfig", "virtualValue")); }
set { iNIFile.IniWriteValue("SystemConfig", "virtualValue", value.ToString()); }
}
public bool virtualFlag
{
get { return iNIFile.IniReadValue("SystemConfig", "virtualFlag") == "是" ? true : false; }
set { iNIFile.IniWriteValue("SystemConfig", "virtualFlag", value == true ? "是" : "否"); }
}
} }
} }

Loading…
Cancel
Save