使用线上IoTDB

This commit is contained in:
ChenYi 2025-06-05 14:14:13 +08:00
parent 97f8cdae16
commit 024733062c
4 changed files with 52 additions and 57 deletions

View File

@ -2,7 +2,7 @@
<!-- 定义项目加载属性 --> <!-- 定义项目加载属性 -->
<PropertyGroup> <PropertyGroup>
<!--JiShe.ServicePro版本--> <!--JiShe.ServicePro版本-->
<ServiceProVersion>1.0.5.05 </ServiceProVersion> <ServiceProVersion>1.0.5.08</ServiceProVersion>
<!--Volo Abp 版本--> <!--Volo Abp 版本-->
<VoloAbpVersion>9.1.1</VoloAbpVersion> <VoloAbpVersion>9.1.1</VoloAbpVersion>

View File

@ -72,58 +72,58 @@ namespace JiShe.CollectBus.Plugins
_logger.LogError($"指令初步解析失败,指令内容:{messageHexString}"); _logger.LogError($"指令初步解析失败,指令内容:{messageHexString}");
} }
//登录和心跳的时候需要过滤TCP连接 ////登录和心跳的时候需要过滤TCP连接
if (tB3761.DT?.Fn == (int)FN. || tB3761.DT?.Fn == (int)FN.) //if (tB3761.DT?.Fn == (int)FN.登录 || tB3761.DT?.Fn == (int)FN.心跳)
{ //{
string focusAddress = tB3761.A.Code; // string focusAddress = tB3761.A.Code;
if (string.IsNullOrWhiteSpace(focusAddress))//集中器地址为空,主动关闭连接 // if (string.IsNullOrWhiteSpace(focusAddress))//集中器地址为空,主动关闭连接
{ // {
await tcpSessionClient.CloseAsync(); // await tcpSessionClient.CloseAsync();
_logger.LogError($"指令解析失败,没有找到集中器地址,指令内容:{messageHexString}"); // _logger.LogError($"指令解析失败,没有找到集中器地址,指令内容:{messageHexString}");
return; // return;
} // }
//查找Redis缓存的集中器信息 // //查找Redis缓存的集中器信息
var focusCacheInfos = _freeRedisProvider.Instance.HGet<FocusCacheInfos>(RedisConst.CacheAllFocusInfoHashKey, focusAddress); // var focusCacheInfos = _freeRedisProvider.Instance.HGet<FocusCacheInfos>(RedisConst.CacheAllFocusInfoHashKey, focusAddress);
if (focusCacheInfos == null) // if (focusCacheInfos == null)
{ // {
await tcpSessionClient.CloseAsync(); // await tcpSessionClient.CloseAsync();
_logger.LogError($"TCP连接关闭没有找到集中器地址{focusAddress}的缓存信息"); // _logger.LogError($"TCP连接关闭没有找到集中器地址{focusAddress}的缓存信息");
return; // return;
} // }
//检查集中器的信息的服务器标记是否为空,如果不为空,需要检查是否与当前服务器的标记一致 // //检查集中器的信息的服务器标记是否为空,如果不为空,需要检查是否与当前服务器的标记一致
if (!string.IsNullOrWhiteSpace(focusCacheInfos.ServerTagName) && focusCacheInfos.ServerTagName != _serverApplicationOptions.ServerTagName) // if (!string.IsNullOrWhiteSpace(focusCacheInfos.ServerTagName) && focusCacheInfos.ServerTagName != _serverApplicationOptions.ServerTagName)
{ // {
await tcpSessionClient.CloseAsync(); // await tcpSessionClient.CloseAsync();
_logger.LogError($"TCP连接关闭集中器地址{focusAddress}的服务器标记为:{focusCacheInfos.ServerTagName},当前服务器的标记为:{_serverApplicationOptions.ServerTagName},不一致拒绝连接。"); // _logger.LogError($"TCP连接关闭集中器地址{focusAddress}的服务器标记为:{focusCacheInfos.ServerTagName},当前服务器的标记为:{_serverApplicationOptions.ServerTagName},不一致拒绝连接。");
return; // return;
} // }
int currentTCPConnectionCount = tcpSessionClient.Service.Count; // int currentTCPConnectionCount = tcpSessionClient.Service.Count;
int configTCPConnectionCount = _serverApplicationOptions.TCPConnectionCount;//配置TCP连接数量 // int configTCPConnectionCount = _serverApplicationOptions.TCPConnectionCount;//配置TCP连接数量
_logger.LogWarning($"当前配置连接数量为:{configTCPConnectionCount},当前连接数量为:{currentTCPConnectionCount}"); // _logger.LogWarning($"当前配置连接数量为:{configTCPConnectionCount},当前连接数量为:{currentTCPConnectionCount}");
if (currentTCPConnectionCount >= configTCPConnectionCount) // if (currentTCPConnectionCount >= configTCPConnectionCount)
{ // {
_logger.LogError($"当前连接数量为:{currentTCPConnectionCount},大于配置连接数量{configTCPConnectionCount},将拒绝集中{focusAddress}连接"); // _logger.LogError($"当前连接数量为:{currentTCPConnectionCount},大于配置连接数量{configTCPConnectionCount},将拒绝集中{focusAddress}连接");
await tcpSessionClient.CloseAsync(); // await tcpSessionClient.CloseAsync();
return; // return;
} // }
//缓存更新状态 // //缓存更新状态
focusCacheInfos.LastSurvivalTime = DateTime.Now; // focusCacheInfos.LastSurvivalTime = DateTime.Now;
focusCacheInfos.ServerTagName = _serverApplicationOptions.ServerTagName; // focusCacheInfos.ServerTagName = _serverApplicationOptions.ServerTagName;
focusCacheInfos.OnLineStatus = true; // focusCacheInfos.OnLineStatus = true;
_freeRedisProvider.Instance.HSet<FocusCacheInfos>(RedisConst.CacheAllFocusInfoHashKey, focusAddress, focusCacheInfos); // _freeRedisProvider.Instance.HSet<FocusCacheInfos>(RedisConst.CacheAllFocusInfoHashKey, focusAddress, focusCacheInfos);
//连接成功以后,通知信息到后台 // //连接成功以后,通知信息到后台
Dictionary<ServiceCommunicationTypeEnum, string> channelMessage = new Dictionary<ServiceCommunicationTypeEnum, string>(); // Dictionary<ServiceCommunicationTypeEnum, string> channelMessage = new Dictionary<ServiceCommunicationTypeEnum, string>();
channelMessage.Add(ServiceCommunicationTypeEnum.FocusStatusReceived, focusCacheInfos.Serialize()); // channelMessage.Add(ServiceCommunicationTypeEnum.FocusStatusReceived, focusCacheInfos.Serialize());
_= _producerService.ProduceAsync(KafkaTopicConsts.ServiceCommunicationChannelTopic, channelMessage); // _= _producerService.ProduceAsync(KafkaTopicConsts.ServiceCommunicationChannelTopic, channelMessage);
} //}
//todo 后续可以考虑Redis的bitmap做日活签到。 //todo 后续可以考虑Redis的bitmap做日活签到。

View File

@ -4,10 +4,11 @@
}, },
"IoTDBOptions": { "IoTDBOptions": {
"UserName": "root", "UserName": "root",
"Password": "root", "Password": "Lixiao@1980",
"ClusterList": [ "192.168.5.9:6667" ], "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, "PoolSize": 32,
"DataBaseName": "energy", "TableModelDataBaseName": "energy",
"OpenDebugMode": true, "OpenDebugMode": true,
"UseTableSessionPoolByDefault": false "UseTableSessionPoolByDefault": false
} }

View File

@ -14,12 +14,6 @@
"UseEnergyDB": true, "UseEnergyDB": true,
"PrintLog": 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": { "Kafka": {
"BootstrapServers": "192.168.5.9:29092,192.168.5.9:39092,192.168.5.9:49092", "BootstrapServers": "192.168.5.9:29092,192.168.5.9:39092,192.168.5.9:49092",
"EnableFilter": true, "EnableFilter": true,
@ -33,9 +27,9 @@
}, },
"IoTDBOptions": { "IoTDBOptions": {
"UserName": "root", "UserName": "root",
"Password": "root", "Password": "Lixiao@1980",
"TreeModelClusterList": [ "121.42.175.177:16667" ], "TreeModelClusterList": [ "47.110.53.196:6667", "47.110.60.222:6667", "47.110.62.104:6667" ],
"TableModelClusterList": [ "121.42.175.177:16667" ], "TableModelClusterList": [ "47.110.53.196:6667", "47.110.60.222:6667", "47.110.62.104:6667" ],
"PoolSize": 32, "PoolSize": 32,
"TableModelDataBaseName": "energy", "TableModelDataBaseName": "energy",
"OpenDebugMode": true, "OpenDebugMode": true,