From be69901c0ad8ffacaf5b948ccca11b350a9d11c5 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 20 八月 2025 10:44:20 +0800
Subject: [PATCH] 修改bug
---
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/mqtt/MqttManager.java | 53 +++++++++++++++++++++++++++++------------------------
1 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/mqtt/MqttManager.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/mqtt/MqttManager.java
index 8085e91..1c92e9d 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/mqtt/MqttManager.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/mqtt/MqttManager.java
@@ -64,34 +64,39 @@
throw new Exception("Mqtt杩炴帴姹犺幏寰楄闃呰繛鎺ヤ笉鍙敤");
}
subClients.add(clientSub) ;
+
// 璁㈤槄涓婚
- for(int i = 0; i < this.configVo.subTopics.length; i++){
- for(int j = 0 ; j < this.configVo.protocolAndDeviceIds.length; j++){
- clientSub.subscribe(ServerProperties.orgTag + "/"
- + this.configVo.protocolAndDeviceIds[j] + "/"
- + this.configVo.subTopics[i],
- this.configVo.subTopicsQos[i],
- //姣忎竴涓闃呬富棰橀兘鏈変竴涓狹qttMessageListener瀹炰緥
- new MqttMessageListener(new MqttNotify(){
- @Override
- public void notify(String devId, MqttNotifyInfo... infos) {
- if(devId != null && infos != null && infos.length > 0){
- for(MqttNotifyInfo info : infos){
- if(info instanceof DevOnLineInfo){
- DevOnLineInfo onLineSt = (DevOnLineInfo)info;
- if(onLineSt.onLine != null && onLineSt.onLine.booleanValue()){
- DevStatusDealer.onLine(devId, ((DevOnLineInfo)info).protocol);
- }else{
- DevStatusDealer.offLine(devId);
+ if(this.configVo.subTopics != null && this.configVo.subTopics.length > 0){
+ if(this.configVo.protocolAndDeviceIds != null || this.configVo.protocolAndDeviceIds.length > 0){
+ for(int i = 0; i < this.configVo.subTopics.length; i++){
+ for(int j = 0 ; j < this.configVo.protocolAndDeviceIds.length; j++){
+ clientSub.subscribe(ServerProperties.orgTag + "/"
+ + this.configVo.protocolAndDeviceIds[j] + "/"
+ + this.configVo.subTopics[i],
+ this.configVo.subTopicsQos[i],
+ //姣忎竴涓闃呬富棰橀兘鏈変竴涓狹qttMessageListener瀹炰緥
+ new MqttMessageListener(new MqttNotify(){
+ @Override
+ public void notify(String devId, MqttNotifyInfo... infos) {
+ if(devId != null && infos != null && infos.length > 0){
+ for(MqttNotifyInfo info : infos){
+ if(info instanceof DevOnLineInfo){
+ DevOnLineInfo onLineSt = (DevOnLineInfo)info;
+ if(onLineSt.onLine != null && onLineSt.onLine.booleanValue()){
+ DevStatusDealer.onLine(devId, ((DevOnLineInfo)info).protocol);
+ }else{
+ DevStatusDealer.offLine(devId);
+ }
+ } else if(info instanceof DevRunInfo){
+ DevStatusDealer.setStatus(devId, (DevRunInfo)info);
+ }
}
- } else if(info instanceof DevRunInfo){
- DevStatusDealer.setStatus(devId, (DevRunInfo)info);
}
}
- }
- }
- })
- );
+ })
+ );
+ }
+ }
}
}
}
--
Gitblit v1.8.0