feat(mqtt): 新增星汉设备数据处理规则和解析逻辑- 添加 MqttXinghanCommandType 枚举类,用于识别和处理星汉设备的命令类型

- 新增 MqttXinghanJson 类,用于解析星汉设备的 JSON 数据
- 在 ReceiverMessageHandler 中集成星汉设备数据的处理逻辑
- 添加 XingHanCommandTypeConstants 常量类,定义星汉设备的命令类型常量
- 实现 XinghanDeviceDataRule 类,处理星汉设备主动上报的数据命令
This commit is contained in:
2025-08-21 17:44:06 +08:00
parent 9a6bf05c4b
commit f1a19f95f5
5 changed files with 364 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import com.fuyuanshen.common.json.utils.JsonUtils;
import com.fuyuanshen.common.redis.utils.RedisUtils;
import com.fuyuanshen.global.mqtt.base.MqttRuleContext;
import com.fuyuanshen.global.mqtt.base.MqttRuleEngine;
import com.fuyuanshen.global.mqtt.base.MqttXinghanCommandType;
import com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -69,5 +70,19 @@ public class ReceiverMessageHandler implements MessageHandler {
log.warn("未找到匹配的规则来处理命令类型: {}", val1);
}
}
/* ===== 追加:根据报文内容识别格式并统一解析 ===== */
int intType = MqttXinghanCommandType.computeVirtualCommandType(payloadDict);
if (intType > 0) {
MqttRuleContext newCtx = new MqttRuleContext();
newCtx.setCommandType((byte) intType);
newCtx.setDeviceImei(deviceImei);
newCtx.setPayloadDict(payloadDict);
boolean ok = ruleEngine.executeRule(newCtx);
if (!ok) {
log.warn("新规则引擎未命中, imei={}", deviceImei);
}
}
}
}