From b2c928eac40c4b7f495f8164eeb59005219fa350 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 11 六月 2025 17:55:29 +0800
Subject: [PATCH] 1、MQTT协议,增加设备参数命令及相关数据; 2、完善上行数据值对象; 3、完善其他代码。

---
 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/MqttMsgParser.java |   31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/MqttMsgParser.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/MqttMsgParser.java
index 15ec6b0..5a03f7e 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/MqttMsgParser.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/MqttMsgParser.java
@@ -11,25 +11,38 @@
  * @Description
  */
 public class MqttMsgParser {
-    public MqttSubMsg parseSubMsg(String topic, MqttMessage mqttMsg) throws Exception {
+    public static MqttTopic parseSubTopic(String topic) throws Exception {
         if(topic != null && topic.trim().length() != 0){
             String[] topicGrp = topic.split("/") ;
             if(topicGrp.length != 4){
                 throw new Exception("鎺ユ敹鐨刴qtt娑堟伅涓婚涓嶅彲璇嗗埆") ;
             }else{
-                if(topicGrp[1].equals("sd1")){
-                    //灞变笢璁惧(鍗忚)锛屼笖鐗堟湰鍙蜂负1
-                    return new ProtocolParserSdV1().parseSubMsg(topicGrp[2], topic, mqttMsg);
-                }else{
-                    throw new Exception("鎺ユ敹鐨刴qtt娑堟伅涓婚涓崗璁紙鍘傚鍙婄増鏈級涓嶅彲璇嗗埆") ;
-                }
+                MqttTopic vo = new MqttTopic() ;
+                vo.orgTag = topicGrp[0] ;
+                vo.protocol = topicGrp[1] ;
+                vo.devId = topicGrp[2] ;
+                vo.name = topicGrp[3] ;
+                return vo ;
             }
         }else{
-            throw new Exception("鎺ユ敹鐨刴qtt娑堟伅涓婚涓虹┖") ;
+            throw new Exception("鎺ユ敹鐨刴qtt娑堟伅涓婚涓嶅悎娉�") ;
         }
     }
 
-    public MqttPubMsg createPubMsg(String orgTag, Command com) throws Exception {
+    public static String createPubTopic(MqttTopic tp) throws Exception {
+        return tp.orgTag + "/" + tp.protocol + "/" + tp.devId + "/" + tp.name;
+    }
+
+    public static MqttSubMsg parseSubMsg(MqttTopic subTopic, MqttMessage mqttMsg, MqttCallback callback) throws Exception {
+        if(subTopic.protocol.equals(ProtocolConstantSdV1.protocolName + ProtocolConstantSdV1.protocolVer)){
+            //灞变笢璁惧(鍗忚)锛屼笖鐗堟湰鍙蜂负1
+            return new ProtocolParserSdV1().parseSubMsg(subTopic, mqttMsg, callback);
+        }else{
+            throw new Exception("鎺ユ敹鐨刴qtt娑堟伅涓婚涓崗璁紙鍘傚鍙婄増鏈級涓嶅彲璇嗗埆") ;
+        }
+    }
+
+    public static MqttPubMsg createPubMsg(String orgTag, Command com) throws Exception {
         if(com.protocol == null && com.protocol.trim().length() != 0){
             throw new Exception("鎺ユ敹鍒癕QTT鍛戒护锛屼絾鏈彁渚涘崗璁�") ;
         }

--
Gitblit v1.8.0