From e360d13d03c43fec7b74679e2a546309acdd2f24 Mon Sep 17 00:00:00 2001 From: wenjy Date: Thu, 25 Apr 2024 14:57:21 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E6=B7=BB=E5=8A=A0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BF=87=E6=BB=A4=EF=BC=8C=E5=BD=93=E5=89=8D=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=8E=E5=89=8D=E4=B8=80=E6=9D=A1=E7=9B=B8=E5=B7=AE?= =?UTF-8?q?4000=E4=B8=8D=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ems.CollectService.Analysis/BufferAnalysis.cs | 70 +++++++++++-------- Ems.CollectService/Ems.CollectService.csproj | 1 - Ems.CollectService/Program.cs | 16 ----- 3 files changed, 42 insertions(+), 45 deletions(-) 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(); } }