From ddc18e1787057abd2e2bded373dd3e12be5dc0b8 Mon Sep 17 00:00:00 2001 From: CZ Date: Tue, 25 Jun 2024 10:56:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E7=94=B5=E8=AE=A2=E5=8D=95=E4=B8=AD?= =?UTF-8?q?=E6=8D=A2=E7=94=B5=E8=AE=A2=E5=8D=95=E5=8F=96=E4=BA=91=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E8=AE=A2=E5=8D=95=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/Cloud/Client/CloudClientMgr.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Service/Cloud/Client/CloudClientMgr.cs b/Service/Cloud/Client/CloudClientMgr.cs index f162388..4d3b3e9 100644 --- a/Service/Cloud/Client/CloudClientMgr.cs +++ b/Service/Cloud/Client/CloudClientMgr.cs @@ -1,9 +1,13 @@ using Autofac; +using Entity.DbModel.Station; using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.Redis; using log4net; +using Newtonsoft.Json; using Repository.Station; +using Service.Cloud.Msg; +using Service.Cloud.Msg.Host.Req; using Service.Init; namespace Service.Cloud.Client; @@ -14,6 +18,7 @@ public class CloudClientMgr private static readonly ILog Log = LogManager.GetLogger(typeof(CloudClientMgr)); public static CloudClient? CloudClient { get; set; } + private static DateTime _dateTime = DateTime.Now.AddSeconds(-30); public static void Init() { CloudClient = AppInfo.Container.Resolve(); @@ -36,7 +41,7 @@ public class CloudClientMgr RedisHelper? redisHelper = AppInfo.Container.Resolve(); BinInfoRepository binInfoRepository = AppInfo.Container.Resolve(); - /*redisHelper?.GetSubscriber().Subscribe("UploadTelemetryData", (channel, value) => + redisHelper?.GetSubscriber().Subscribe("UploadTelemetryData", (channel, value) => { try { @@ -80,6 +85,13 @@ public class CloudClientMgr ot = 0xFF, bt = DateTime.Now }; + + if ((DateTime.Now - _dateTime).TotalSeconds <= 30) + { + return; + } + + _dateTime = DateTime.Now; CloudClient?.SendChargeDevDataInfo(req); } } @@ -88,6 +100,6 @@ public class CloudClientMgr { Log.Info("error", e); } - });*/ + }); } }