change - 添加数据过滤,当前数据与前一条相差4000不保存

master
wenjy 9 months ago
parent 2f6559ee90
commit e360d13d03

@ -39,7 +39,7 @@ namespace Ems.CollectService.Analysis
private BufferAnalysis() private BufferAnalysis()
{ {
logger.Info($"添加校时指令下发"); logger.Info($"添加数据校验当前数据与前一条相差4000不保存");
} }
/// <summary> /// <summary>
@ -522,34 +522,8 @@ namespace Ems.CollectService.Analysis
recordDnbInstant.collectType = collectType; recordDnbInstant.collectType = collectType;
recordDnbInstant.recordTime = DateTime.Now; recordDnbInstant.recordTime = DateTime.Now;
if (appConfig.virtualFlag) Save_DnbInstant(recordDnbInstant);
{
if (recordDnbInstant.zxyg != appConfig.virtualValue)
{
var info = SqlSugarHelper.Db.Insertable<RecordDnbInstant>(recordDnbInstant).ExecuteCommand();
if (info > 0)
{
logger.Info($"仪表:{recordDnbInstant.monitorId}数据保存成功");
}
}
else
{
logger.Info($"仪表:{recordDnbInstant.monitorId}存在FFFF值不保存该条数据");
}
}
else
{
recordDnbInstant.zxyg = recordDnbInstant.zxyg == appConfig.virtualValue ? 0 : recordDnbInstant.zxyg;
var info = SqlSugarHelper.Db.Insertable<RecordDnbInstant>(recordDnbInstant).ExecuteCommand();
if (info > 0)
{
logger.Info($"仪表:{recordDnbInstant.monitorId}数据保存成功");
}
}
} }
iFirstMeterID += 70; iFirstMeterID += 70;
}//end for }//end for
@ -563,6 +537,46 @@ namespace Ems.CollectService.Analysis
} }
/// <summary>
/// 保存数据
/// </summary>
/// <param name="recordDnbInstant"></param>
private void Save_DnbInstant(RecordDnbInstant recordDnbInstant)
{
try
{
if (appConfig.virtualFlag)
{
if (recordDnbInstant.zxyg != appConfig.virtualValue)
{
var info = SqlSugarHelper.Db.Insertable<RecordDnbInstant>(recordDnbInstant).ExecuteCommand();
if (info > 0)
{
logger.Info($"仪表:{recordDnbInstant.monitorId}数据保存成功");
}
}
else
{
logger.Info($"仪表:{recordDnbInstant.monitorId}存在FFFF值不保存该条数据");
}
}
else
{
recordDnbInstant.zxyg = recordDnbInstant.zxyg == appConfig.virtualValue ? 0 : recordDnbInstant.zxyg;
var info = SqlSugarHelper.Db.Insertable<RecordDnbInstant>(recordDnbInstant).ExecuteCommand();
if (info > 0)
{
logger.Info($"仪表:{recordDnbInstant.monitorId}数据保存成功");
}
}
}catch(Exception ex)
{
logger.Error($"仪表:{recordDnbInstant.monitorId}数据保存异常:{ex.Message}");
}
}
/// <summary> /// <summary>
/// 水表数据 /// 水表数据
/// </summary> /// </summary>

@ -6,7 +6,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Lierda.WPFHelper" Version="1.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
</ItemGroup> </ItemGroup>

@ -1,29 +1,14 @@
using Ems.CollectService.Entity.config; using Ems.CollectService.Entity.config;
using Ems.CollectService.Redis;
using Ems.CollectService.SqlSugarCore;
using Ems.CollectService.Timer; using Ems.CollectService.Timer;
using Ems.CollectService.TouchSocket; using Ems.CollectService.TouchSocket;
using Lierda.WPFHelper;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Logging;
using Newtonsoft.Json;
using NLog; using NLog;
using NLog.Web;
using SqlSugar;
using StackExchange.Redis;
using System; using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection.Metadata;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Ems.CollectService namespace Ems.CollectService
{ {
internal class Program internal class Program
{ {
private static LierdaCracker cracker = new LierdaCracker();
private static Logger logger = LogManager.GetCurrentClassLogger(); private static Logger logger = LogManager.GetCurrentClassLogger();
private static TcpServer service = TcpServer.Instance; private static TcpServer service = TcpServer.Instance;
@ -49,7 +34,6 @@ namespace Ems.CollectService
while (true) while (true)
{ {
cracker.Cracker(100);
Task.Delay(1000 * 10).Wait(); Task.Delay(1000 * 10).Wait();
} }
} }

Loading…
Cancel
Save