diff --git a/Ems.CollectService.Analysis/BufferAnalysis.cs b/Ems.CollectService.Analysis/BufferAnalysis.cs index d45b6ba..8aae9eb 100644 --- a/Ems.CollectService.Analysis/BufferAnalysis.cs +++ b/Ems.CollectService.Analysis/BufferAnalysis.cs @@ -39,7 +39,7 @@ namespace Ems.CollectService.Analysis private BufferAnalysis() { - logger.Info($"添加校时指令下发"); + logger.Info($"添加数据校验:当前数据与前一条相差4000不保存"); } /// @@ -522,34 +522,8 @@ namespace Ems.CollectService.Analysis recordDnbInstant.collectType = collectType; recordDnbInstant.recordTime = DateTime.Now; - if (appConfig.virtualFlag) - { - if (recordDnbInstant.zxyg != appConfig.virtualValue) - { - var info = SqlSugarHelper.Db.Insertable(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; + Save_DnbInstant(recordDnbInstant); - var info = SqlSugarHelper.Db.Insertable(recordDnbInstant).ExecuteCommand(); - if (info > 0) - { - logger.Info($"仪表:{recordDnbInstant.monitorId}数据保存成功"); - } - } - - } iFirstMeterID += 70; }//end for @@ -563,6 +537,46 @@ namespace Ems.CollectService.Analysis } + /// + /// 保存数据 + /// + /// + private void Save_DnbInstant(RecordDnbInstant recordDnbInstant) + { + try + { + if (appConfig.virtualFlag) + { + if (recordDnbInstant.zxyg != appConfig.virtualValue) + { + var info = SqlSugarHelper.Db.Insertable(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).ExecuteCommand(); + if (info > 0) + { + logger.Info($"仪表:{recordDnbInstant.monitorId}数据保存成功"); + } + } + }catch(Exception ex) + { + logger.Error($"仪表:{recordDnbInstant.monitorId}数据保存异常:{ex.Message}"); + } + } + /// /// 水表数据 /// diff --git a/Ems.CollectService/Ems.CollectService.csproj b/Ems.CollectService/Ems.CollectService.csproj index 36d81cc..c79154b 100644 --- a/Ems.CollectService/Ems.CollectService.csproj +++ b/Ems.CollectService/Ems.CollectService.csproj @@ -6,7 +6,6 @@ - diff --git a/Ems.CollectService/Program.cs b/Ems.CollectService/Program.cs index 0b35d29..926b22c 100644 --- a/Ems.CollectService/Program.cs +++ b/Ems.CollectService/Program.cs @@ -1,29 +1,14 @@ using Ems.CollectService.Entity.config; -using Ems.CollectService.Redis; -using Ems.CollectService.SqlSugarCore; using Ems.CollectService.Timer; 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.Web; -using SqlSugar; -using StackExchange.Redis; using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection.Metadata; using System.Threading.Tasks; namespace Ems.CollectService { internal class Program { - private static LierdaCracker cracker = new LierdaCracker(); - private static Logger logger = LogManager.GetCurrentClassLogger(); private static TcpServer service = TcpServer.Instance; @@ -49,7 +34,6 @@ namespace Ems.CollectService while (true) { - cracker.Cracker(100); Task.Delay(1000 * 10).Wait(); } }