mqtt通讯修改 增加模板 计算属性

This commit is contained in:
LEED
2025-03-09 12:39:52 +08:00
parent 20c17b772d
commit 6a8cbff440
41 changed files with 2359 additions and 31 deletions

View File

@@ -276,7 +276,7 @@ public interface XinDaConstant {
String GEC6100D = "MODBUS-JSON-GEC6100D";
String SGZ = "SGZ";
String CH = "CH";
String GONGKONGBANG_HTSZ = "GONGKONGBANG-HTSZ";
String IECF6113 = "IECF6113";
}

View File

@@ -27,6 +27,7 @@ public enum TopicType {
SERVICE_INVOKE_REPLY(0,8,"/service/reply", "订阅功能调用返回结果"),
FIRMWARE_UPGRADE_REPLY(0,9,"/upgrade/reply", "订阅设备OTA升级结果"),
MESSAGE_POST(0,26,"/message/post","订阅设备上报消息"),
PROPERTY_XINDA_DEV(0,28,"/json/dev/", "订阅属性"),
/*** 通用设备订阅主题(平台下发)***/
FUNCTION_GET(1,17,"/function/get", "发布功能"),
@@ -36,7 +37,7 @@ public enum TopicType {
STATUS_POST(1,11,"/status/post","发布状态"),
NTP_GET(1,15,"/ntp/get","发布时钟同步"),
INFO_GET(1,18,"/info/get","发布设备信息"),
FUNCTION_XINDA_DOWN(1,29,"/json/down/", "发布功能"),
/*** 视频监控设备转协议发布 ***/
DEV_INFO_POST(3,19,"/info/post","设备端发布设备信息"),

View File

@@ -55,6 +55,24 @@ public class TopicsUtils {
}
}
public String buildNewTopic(String serialNumber, TopicType type) {
/*
* 订阅属性:
* 如果启动emq 则为 /property/post/+
* 如果启动netty的mqttBroker 则为 /property/post/{serialNumber}
*
* 发布都为/{productId}/property/get/{serialNumber}
*/
if (com.xinda.common.utils.StringUtils.isEmpty(serialNumber)) {
serialNumber = "+";
}
if (type.getType() == 0) {
return enabled ? type.getTopicSuffix() : XinDaConstant.MQTT.PREDIX + type.getTopicSuffix() + serialNumber;
} else {
return type.getTopicSuffix() + serialNumber;
}
}
/**
* 获取所有可订阅的主题
@@ -151,6 +169,12 @@ public class TopicsUtils {
return values[2];
}
@SneakyThrows
public String parseNewSerialNumber(String topic) {
String[] values = topic.split("/");
return values[3];
}
/**
* 获取topic 判断字段 name
**/
@@ -163,6 +187,15 @@ public class TopicsUtils {
}
}
public String parseNewTopicName(String topic) {
String[] values = topic.split("/");
if (values.length >2){
return "/"+ values[1] + "/" + values[2];
}else {
return null;
}
}
/**
* 获取topic 判断字段 name
**/