From 3e4ee7b4b2f7f459e27675129aae944983af331f Mon Sep 17 00:00:00 2001 From: xce Date: Sun, 18 Jan 2026 17:18:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=90=8E=E5=88=A0=E9=99=A4=E6=9C=80=E5=90=8E=E4=B8=80?= =?UTF-8?q?=E6=9D=A1=E8=AE=BE=E5=A4=87=E7=8A=B6=E6=80=81=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E5=9B=A0=E4=B8=BA=E6=9C=89=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E8=BF=87=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/agri/framework/interceptor/MqttMessageHandler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/agri-framework/src/main/java/com/agri/framework/interceptor/MqttMessageHandler.java b/agri-framework/src/main/java/com/agri/framework/interceptor/MqttMessageHandler.java index 97f43c6..d4b65bc 100644 --- a/agri-framework/src/main/java/com/agri/framework/interceptor/MqttMessageHandler.java +++ b/agri-framework/src/main/java/com/agri/framework/interceptor/MqttMessageHandler.java @@ -348,7 +348,7 @@ public class MqttMessageHandler implements SmartLifecycle { } if (!isValidStatus) { log.debug("【设备状态包】结构不合法(非8个功能码),跳过Redis写入,deviceId={};payload={}", deviceId, payload); - } else { + } else if(hasAutoOffTask(deviceId)){ // ✅ 8个功能码状态包:无条件写device:latest:{deviceId},避免自动关读不到最新状态 stringRedisTemplate.opsForValue().set( "device:latest:" + deviceId, @@ -472,7 +472,6 @@ public class MqttMessageHandler implements SmartLifecycle { //todo mqttMessageSender.publish(deviceTopic, down.toJSONString()); log.info("【自动关任务】检测仍在运行,已下发关闭:deviceId={}, funcType={}, payload={}", deviceId, funcType, down.toJSONString()); - Boolean deleteSuccess = stringRedisTemplate.delete("device:latest:" + deviceId); } else { log.info("【自动关任务】检测未运行或状态未知,跳过关闭:deviceId={}, funcType={}, current={}", deviceId, funcType, current); }