修改延时任务存最后一条设备信息的逻辑
parent
d6cfe99710
commit
9fc3b1d372
|
|
@ -342,12 +342,11 @@ public class MqttMessageHandler implements SmartLifecycle {
|
||||||
for (String validCode : VALID_FUNC_CODES) {
|
for (String validCode : VALID_FUNC_CODES) {
|
||||||
if (!payloadObj.containsKey(validCode)) {
|
if (!payloadObj.containsKey(validCode)) {
|
||||||
isValidStatus = false;
|
isValidStatus = false;
|
||||||
|
log.debug("【设备状态包】结构不合法(非8个功能码),跳过Redis写入,deviceId={};payload={}", deviceId, payload);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isValidStatus) {
|
if(hasAutoOffTask(deviceId) && isValidStatus){
|
||||||
log.debug("【设备状态包】结构不合法(非8个功能码),跳过Redis写入,deviceId={};payload={}", deviceId, payload);
|
|
||||||
} else if(hasAutoOffTask(deviceId)){
|
|
||||||
// ✅ 8个功能码状态包:无条件写device:latest:{deviceId},避免自动关读不到最新状态
|
// ✅ 8个功能码状态包:无条件写device:latest:{deviceId},避免自动关读不到最新状态
|
||||||
stringRedisTemplate.opsForValue().set(
|
stringRedisTemplate.opsForValue().set(
|
||||||
"device:latest:" + deviceId,
|
"device:latest:" + deviceId,
|
||||||
|
|
@ -469,7 +468,7 @@ public class MqttMessageHandler implements SmartLifecycle {
|
||||||
|
|
||||||
String deviceTopic = "dtu/" + deviceId + "/down";
|
String deviceTopic = "dtu/" + deviceId + "/down";
|
||||||
//todo
|
//todo
|
||||||
mqttMessageSender.publish(deviceTopic, down.toJSONString());
|
// mqttMessageSender.publish(deviceTopic, down.toJSONString());
|
||||||
log.info("【自动关任务】检测仍在运行,已下发关闭:deviceId={}, funcType={}, payload={}", deviceId, funcType, down.toJSONString());
|
log.info("【自动关任务】检测仍在运行,已下发关闭:deviceId={}, funcType={}, payload={}", deviceId, funcType, down.toJSONString());
|
||||||
} else {
|
} else {
|
||||||
log.info("【自动关任务】检测未运行或状态未知,跳过关闭:deviceId={}, funcType={}, current={}", deviceId, funcType, current);
|
log.info("【自动关任务】检测未运行或状态未知,跳过关闭:deviceId={}, funcType={}, current={}", deviceId, funcType, current);
|
||||||
|
|
@ -538,7 +537,7 @@ public class MqttMessageHandler implements SmartLifecycle {
|
||||||
// 4. 转发指令到设备
|
// 4. 转发指令到设备
|
||||||
String deviceTopic = "dtu/" + deviceId + "/down";
|
String deviceTopic = "dtu/" + deviceId + "/down";
|
||||||
//todo
|
//todo
|
||||||
mqttMessageSender.publish(deviceTopic, payload);
|
// mqttMessageSender.publish(deviceTopic, payload);
|
||||||
log.info("【指令转发】前端{} → 设备{}的{}功能", clientId, deviceId, funcType);
|
log.info("【指令转发】前端{} → 设备{}的{}功能", clientId, deviceId, funcType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue