From 024733062c51e4117234fe685165d1d31ce32e17 Mon Sep 17 00:00:00 2001 From: ChenYi <296215406@outlook.com> Date: Thu, 5 Jun 2025 14:14:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=BA=BF=E4=B8=8AIoTDB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Directory.Build.props | 2 +- .../Plugins/TcpMonitor.cs | 88 +++++++++---------- .../appsettings.json | 7 +- web/JiShe.CollectBus.Host/appsettings.json | 12 +-- 4 files changed, 52 insertions(+), 57 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 33557c4..64df1da 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ - 1.0.5.05 + 1.0.5.08 9.1.1 diff --git a/services/JiShe.CollectBus.Application/Plugins/TcpMonitor.cs b/services/JiShe.CollectBus.Application/Plugins/TcpMonitor.cs index 5244e57..f84dd55 100644 --- a/services/JiShe.CollectBus.Application/Plugins/TcpMonitor.cs +++ b/services/JiShe.CollectBus.Application/Plugins/TcpMonitor.cs @@ -72,58 +72,58 @@ namespace JiShe.CollectBus.Plugins _logger.LogError($"指令初步解析失败,指令内容:{messageHexString}"); } - //登录和心跳的时候,需要过滤TCP连接 - if (tB3761.DT?.Fn == (int)FN.登录 || tB3761.DT?.Fn == (int)FN.心跳) - { - string focusAddress = tB3761.A.Code; - if (string.IsNullOrWhiteSpace(focusAddress))//集中器地址为空,主动关闭连接 - { - await tcpSessionClient.CloseAsync(); - _logger.LogError($"指令解析失败,没有找到集中器地址,指令内容:{messageHexString}"); - return; - } + ////登录和心跳的时候,需要过滤TCP连接 + //if (tB3761.DT?.Fn == (int)FN.登录 || tB3761.DT?.Fn == (int)FN.心跳) + //{ + // string focusAddress = tB3761.A.Code; + // if (string.IsNullOrWhiteSpace(focusAddress))//集中器地址为空,主动关闭连接 + // { + // await tcpSessionClient.CloseAsync(); + // _logger.LogError($"指令解析失败,没有找到集中器地址,指令内容:{messageHexString}"); + // return; + // } - //查找Redis缓存的集中器信息 - var focusCacheInfos = _freeRedisProvider.Instance.HGet(RedisConst.CacheAllFocusInfoHashKey, focusAddress); - if (focusCacheInfos == null) - { - await tcpSessionClient.CloseAsync(); - _logger.LogError($"TCP连接关闭,没有找到集中器地址{focusAddress}的缓存信息"); - return; - } + // //查找Redis缓存的集中器信息 + // var focusCacheInfos = _freeRedisProvider.Instance.HGet(RedisConst.CacheAllFocusInfoHashKey, focusAddress); + // if (focusCacheInfos == null) + // { + // await tcpSessionClient.CloseAsync(); + // _logger.LogError($"TCP连接关闭,没有找到集中器地址{focusAddress}的缓存信息"); + // return; + // } - //检查集中器的信息的服务器标记是否为空,如果不为空,需要检查是否与当前服务器的标记一致 - if (!string.IsNullOrWhiteSpace(focusCacheInfos.ServerTagName) && focusCacheInfos.ServerTagName != _serverApplicationOptions.ServerTagName) - { - await tcpSessionClient.CloseAsync(); - _logger.LogError($"TCP连接关闭,集中器地址{focusAddress}的服务器标记为:{focusCacheInfos.ServerTagName},当前服务器的标记为:{_serverApplicationOptions.ServerTagName},不一致拒绝连接。"); - return; - } + // //检查集中器的信息的服务器标记是否为空,如果不为空,需要检查是否与当前服务器的标记一致 + // if (!string.IsNullOrWhiteSpace(focusCacheInfos.ServerTagName) && focusCacheInfos.ServerTagName != _serverApplicationOptions.ServerTagName) + // { + // await tcpSessionClient.CloseAsync(); + // _logger.LogError($"TCP连接关闭,集中器地址{focusAddress}的服务器标记为:{focusCacheInfos.ServerTagName},当前服务器的标记为:{_serverApplicationOptions.ServerTagName},不一致拒绝连接。"); + // return; + // } - int currentTCPConnectionCount = tcpSessionClient.Service.Count; - int configTCPConnectionCount = _serverApplicationOptions.TCPConnectionCount;//配置TCP连接数量 + // int currentTCPConnectionCount = tcpSessionClient.Service.Count; + // int configTCPConnectionCount = _serverApplicationOptions.TCPConnectionCount;//配置TCP连接数量 - _logger.LogWarning($"当前配置连接数量为:{configTCPConnectionCount},当前连接数量为:{currentTCPConnectionCount}"); + // _logger.LogWarning($"当前配置连接数量为:{configTCPConnectionCount},当前连接数量为:{currentTCPConnectionCount}"); - if (currentTCPConnectionCount >= configTCPConnectionCount) - { - _logger.LogError($"当前连接数量为:{currentTCPConnectionCount},大于配置连接数量{configTCPConnectionCount},将拒绝集中{focusAddress}连接"); - await tcpSessionClient.CloseAsync(); - return; - } + // if (currentTCPConnectionCount >= configTCPConnectionCount) + // { + // _logger.LogError($"当前连接数量为:{currentTCPConnectionCount},大于配置连接数量{configTCPConnectionCount},将拒绝集中{focusAddress}连接"); + // await tcpSessionClient.CloseAsync(); + // return; + // } - //缓存更新状态 - focusCacheInfos.LastSurvivalTime = DateTime.Now; - focusCacheInfos.ServerTagName = _serverApplicationOptions.ServerTagName; - focusCacheInfos.OnLineStatus = true; + // //缓存更新状态 + // focusCacheInfos.LastSurvivalTime = DateTime.Now; + // focusCacheInfos.ServerTagName = _serverApplicationOptions.ServerTagName; + // focusCacheInfos.OnLineStatus = true; - _freeRedisProvider.Instance.HSet(RedisConst.CacheAllFocusInfoHashKey, focusAddress, focusCacheInfos); + // _freeRedisProvider.Instance.HSet(RedisConst.CacheAllFocusInfoHashKey, focusAddress, focusCacheInfos); - //连接成功以后,通知信息到后台 - Dictionary channelMessage = new Dictionary(); - channelMessage.Add(ServiceCommunicationTypeEnum.FocusStatusReceived, focusCacheInfos.Serialize()); - _= _producerService.ProduceAsync(KafkaTopicConsts.ServiceCommunicationChannelTopic, channelMessage); - } + // //连接成功以后,通知信息到后台 + // Dictionary channelMessage = new Dictionary(); + // channelMessage.Add(ServiceCommunicationTypeEnum.FocusStatusReceived, focusCacheInfos.Serialize()); + // _= _producerService.ProduceAsync(KafkaTopicConsts.ServiceCommunicationChannelTopic, channelMessage); + //} //todo 后续可以考虑Redis的bitmap做日活签到。 diff --git a/services/JiShe.CollectBus.DbMigrator/appsettings.json b/services/JiShe.CollectBus.DbMigrator/appsettings.json index 987ba94..bc9289e 100644 --- a/services/JiShe.CollectBus.DbMigrator/appsettings.json +++ b/services/JiShe.CollectBus.DbMigrator/appsettings.json @@ -4,10 +4,11 @@ }, "IoTDBOptions": { "UserName": "root", - "Password": "root", - "ClusterList": [ "192.168.5.9:6667" ], + "Password": "Lixiao@1980", + "TreeModelClusterList": [ "47.110.53.196:6667", "47.110.60.222:6667", "47.110.62.104:6667" ], + "TableModelClusterList": [ "47.110.53.196:6667", "47.110.60.222:6667", "47.110.62.104:6667" ], "PoolSize": 32, - "DataBaseName": "energy", + "TableModelDataBaseName": "energy", "OpenDebugMode": true, "UseTableSessionPoolByDefault": false } diff --git a/web/JiShe.CollectBus.Host/appsettings.json b/web/JiShe.CollectBus.Host/appsettings.json index 3708b77..8e8cb13 100644 --- a/web/JiShe.CollectBus.Host/appsettings.json +++ b/web/JiShe.CollectBus.Host/appsettings.json @@ -14,12 +14,6 @@ "UseEnergyDB": true, "PrintLog": true }, - //"Redis": { - // "Configuration": "192.168.5.9:6380,password=1q2w3e!@#,syncTimeout=30000,abortConnect=false,connectTimeout=30000,allowAdmin=true", - // "MaxPoolSize": "50", - // "DefaultDB": "14", - // "HangfireDB": "13" - //}, "Kafka": { "BootstrapServers": "192.168.5.9:29092,192.168.5.9:39092,192.168.5.9:49092", "EnableFilter": true, @@ -33,9 +27,9 @@ }, "IoTDBOptions": { "UserName": "root", - "Password": "root", - "TreeModelClusterList": [ "121.42.175.177:16667" ], - "TableModelClusterList": [ "121.42.175.177:16667" ], + "Password": "Lixiao@1980", + "TreeModelClusterList": [ "47.110.53.196:6667", "47.110.60.222:6667", "47.110.62.104:6667" ], + "TableModelClusterList": [ "47.110.53.196:6667", "47.110.60.222:6667", "47.110.62.104:6667" ], "PoolSize": 32, "TableModelDataBaseName": "energy", "OpenDebugMode": true,