mirror of
https://gitee.com/beecue/fastbee.git
synced 2026-09-20 11:52:08 +08:00
refactor(规则引擎): topic转换失败修复
This commit is contained in:
@@ -149,7 +149,11 @@ public class TopicsUtils {
|
||||
@SneakyThrows
|
||||
public String parseSerialNumber(String topic) {
|
||||
String[] values = topic.split("/");
|
||||
return values[2];
|
||||
// 从topic分段中按长度识别设备编号,设备编号通常长度>9
|
||||
return Arrays.stream(values)
|
||||
.filter(s -> s.length() > 9)
|
||||
.findFirst()
|
||||
.orElseGet(() -> values.length > 2 ? values[2] : values[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -118,7 +118,7 @@ public class MqttPublish implements MqttHandler {
|
||||
reportBo.setTopicName(context.getTopic());
|
||||
reportBo.setData(context.getPayload().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
if (topicName.contains("property")) {
|
||||
if (reportBo.getTopicName().contains("property")) {
|
||||
deviceReportMessageService.parseReportMsg(reportBo);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user