From 9e08defcff411632065308c6c3b0f6f12febb854 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 22 八月 2025 08:44:47 +0800
Subject: [PATCH] 去掉SsoAop注解
---
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/MqttMsgParser.java | 43 ++++++++++++++++++++++++++++++++-----------
1 files changed, 32 insertions(+), 11 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..5114ad8 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
@@ -3,6 +3,7 @@
import com.dy.common.mw.protocol.Command;
import com.dy.common.mw.protocol4Mqtt.pSdV1.ProtocolConstantSdV1;
import com.dy.common.mw.protocol4Mqtt.pSdV1.ProtocolParserSdV1;
+import com.dy.common.util.NumUtil;
import org.eclipse.paho.client.mqttv3.MqttMessage;
/**
@@ -11,32 +12,52 @@
* @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){
+ if(topicGrp.length != 5){
throw new Exception("鎺ユ敹鐨刴qtt娑堟伅涓婚涓嶅彲璇嗗埆") ;
}else{
- if(topicGrp[1].equals("sd1")){
- //灞变笢璁惧(鍗忚)锛屼笖鐗堟湰鍙蜂负1
- return new ProtocolParserSdV1().parseSubMsg(topicGrp[2], topic, mqttMsg);
- }else{
- throw new Exception("鎺ユ敹鐨刴qtt娑堟伅涓婚涓崗璁紙鍘傚鍙婄増鏈級涓嶅彲璇嗗埆") ;
+ if(!NumUtil.isPlusIntNumber(topicGrp[4])){
+ throw new Exception("鎺ユ敹鐨刴qtt娑堟伅涓婚涓嶅彲璇嗗埆") ;
}
+ if(Integer.parseInt(topicGrp[4]) <= 0){
+ throw new Exception("鎺ユ敹鐨刴qtt娑堟伅涓婚涓嶅彲璇嗗埆") ;
+ }
+ MqttTopic vo = new MqttTopic() ;
+ vo.orgTag = topicGrp[0] ;
+ vo.protocol = topicGrp[1] ;
+ vo.devId = topicGrp[2] ;
+ vo.type = topicGrp[3] ;
+ vo.no = Integer.parseInt(topicGrp[4]) ;
+ 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.type + "/" + tp.no;
+ }
+
+ 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鍛戒护锛屼絾鏈彁渚涘崗璁�") ;
}
if(com.protocolVersion == null){
throw new Exception("鎺ユ敹鍒癕QTT鍛戒护锛屼絾鏈彁渚涘崗璁増鏈彿") ;
}
- if(com.code != null && com.code.trim().length() != 0){
+ if(com.code == null || com.code.trim().length() == 0){
throw new Exception("鎺ユ敹鍒癕QTT鍛戒护锛屼絾鏈彁渚涘姛鑳界爜") ;
}
if(com.protocol.equals(ProtocolConstantSdV1.protocolName)){
@@ -52,7 +73,7 @@
public static void main(String[] args) {
- String s = "ym/sd1/10000/control/m1" ;
+ String s = "jyg/sd1/2430002404000840/weather/1" ;
String[] ss = s.split("/") ;
for (String s1 : ss) {
System.out.println(s1);
--
Gitblit v1.8.0