fix(ops): strictly control heartbeat logic to prevent ghost online status
This commit is contained in:
@@ -272,9 +272,16 @@ public class BadgeDeviceStatusServiceImpl implements BadgeDeviceStatusService, I
|
||||
}
|
||||
|
||||
// 如果之前是 OFFLINE,转为 IDLE
|
||||
// 如果当前状态为空,初始化为 IDLE
|
||||
BadgeDeviceStatusEnum newStatus = currentStatus;
|
||||
if (currentStatus == null || currentStatus == BadgeDeviceStatusEnum.OFFLINE) {
|
||||
if (currentStatus == null) {
|
||||
newStatus = BadgeDeviceStatusEnum.IDLE;
|
||||
} else if (currentStatus == BadgeDeviceStatusEnum.OFFLINE) {
|
||||
// 如果已标记为离线,心跳不再自动复活设备
|
||||
// 必须依赖 IoT 上线事件或定时对账 Job 来恢复在线状态
|
||||
// 这样做是为了防止因离线事件和心跳包乱序(幽灵心跳)导致的“假在线”问题
|
||||
log.debug("设备处于离线状态但收到心跳,保持离线状态: deviceId={}", deviceId);
|
||||
newStatus = BadgeDeviceStatusEnum.OFFLINE;
|
||||
}
|
||||
|
||||
// 更新状态
|
||||
|
||||
Reference in New Issue
Block a user