Quellcode durchsuchen

阶段提交:iotm ,iots

yf_zn vor 1 Jahr
Ursprung
Commit
c9f55c1a7c

+ 11 - 6
src/main/java/com/yunfeiyun/agmp/iots/core/manager/MqttManager.java

@@ -106,16 +106,21 @@ public class MqttManager {
         log.info("【创建MqttCore实例】 mqttCore: {} connectionId:{} devSize:{}", mqttCore,connectionId,devices.size());
         List<MqttTopicValue> mqttTopicValues=new ArrayList<>();
         for(IotDevice iotDevice:devices){
-            MqttTopicValue mqttTopicValue=new MqttTopicValue();
-            mqttTopicValue.setDevCode(iotDevice.getDevCode());
-            mqttTopicValue.setDevId(iotDevice.getDevBid());
-            mqttTopicValue.setTopic(deviceTopicService.getTopic(serviceName, iotDevice.getDevCode()));
-            mqttTopicValues.add(mqttTopicValue);
+
+            String[] topics= deviceTopicService.getTopic(serviceName, iotDevice.getDevCode());
+            for(String s: topics){
+                MqttTopicValue mqttTopicValue=new MqttTopicValue();
+                mqttTopicValue.setDevCode(iotDevice.getDevCode());
+                mqttTopicValue.setDevId(iotDevice.getDevBid());
+                mqttTopicValue.setTopic(s);
+                mqttTopicValues.add(mqttTopicValue);
+            }
+
         }
 
         String[] topics=new String[mqttTopicValues.size()];
         if(mqttTopicValues!=null&&!mqttTopicValues.isEmpty()){
-            for(int i=0;i<devices.size();i++){
+            for(int i=0;i<mqttTopicValues.size();i++){
                 topics[i]=mqttTopicValues.get(i).getTopic();
                 System.out.println("xxxxxxxxxxxxxxxxxxxxx"+mqttTopicValues.get(i).getTopic());
             }

+ 2 - 2
src/main/java/com/yunfeiyun/agmp/iots/core/mqtt/DeviceTopicService.java

@@ -101,7 +101,7 @@ public class DeviceTopicService {
         }
     }
 
-    public String getTopic(String serviceName,String deviceCode) {
+    public String[] getTopic(String serviceName,String deviceCode) {
         if(StringUtils.isEmpty(deviceCode)){
             return null;
         }
@@ -111,7 +111,7 @@ public class DeviceTopicService {
         MqttTopicValue mqttTopicValue=new MqttTopicValue();
         mqttTopicValue.setDevCode(deviceCode);
         mqttTopicValues.add(mqttTopicValue);
-        return getBatchTopic(serviceName,mqttTopicValues)[0];
+        return getBatchTopic(serviceName,mqttTopicValues);
     }
 
     private String[] getHKBatchSubTopic() {