fix: 逻辑修复完善。

This commit is contained in:
tianyongbao
2026-03-08 13:54:28 +08:00
parent 10cc7e75b3
commit 2e9d48dd83
2 changed files with 109 additions and 10 deletions

View File

@@ -241,10 +241,12 @@ public class AmqpMessageHandlerImpl implements AmqpMessageHandler {
private void handleStatusMessage(JSONObject json) {
String deviceName = json.getStr("deviceName");
String status = json.getStr("status");
log.debug("设备状态: {} - {}", deviceName, status);
// TODO: 更新设备状态
if ("offline".equals(status) && deviceDataHandler != null && deviceName != null) {
deviceDataHandler.handleDeviceOffline(deviceName);
}
}
/**
@@ -253,11 +255,16 @@ public class AmqpMessageHandlerImpl implements AmqpMessageHandler {
private void handleLifeCycleMessage(JSONObject json) {
String deviceName = json.getStr("deviceName");
String action = json.getStr("action");
// 先尝试 status 字段(部分消息格式用 status 而非 action
if (action == null) {
action = json.getStr("status");
}
log.debug("设备{}: {}", "online".equals(action) ? "上线" : "下线", deviceName);
// action: "online" 或 "offline"
// TODO: 更新设备在线状态
if ("offline".equals(action) && deviceDataHandler != null && deviceName != null) {
deviceDataHandler.handleDeviceOffline(deviceName);
}
}
}