Commit 92645f3f by guoxuejian

feat: enhance auto-recovery logic for drones by distinguishing between…

feat: enhance auto-recovery logic for drones by distinguishing between sub-devices and independent devices
parent 17092f18
...@@ -1698,7 +1698,20 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity> ...@@ -1698,7 +1698,20 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity>
} else if (DeviceDomainEnum.REMOTER_CONTROL == dbDevice.getDomain()) { } else if (DeviceDomainEnum.REMOTER_CONTROL == dbDevice.getDomain()) {
recoverGatewayOnline(dbDevice); recoverGatewayOnline(dbDevice);
} else if (DeviceDomainEnum.DRONE == dbDevice.getDomain()) { } else if (DeviceDomainEnum.DRONE == dbDevice.getDomain()) {
recoverDroneOnline(dbDevice); // 通过 child_sn 反查父设备(数据库中没有 parent_sn 字段,parentSn 只存在于 Redis)
List<DeviceDTO> parentDevices = this.getDevicesByParams(
DeviceQueryParam.builder().childSn(deviceSn).build());
if (!parentDevices.isEmpty()) {
// 子设备无人机:通过父设备(机场/遥控器)恢复整个拓扑
DeviceDTO parentDevice = parentDevices.get(0);
log.info("[Auto-Recovery] Drone {} is a sub-device, recovering via gateway {}",
deviceSn, parentDevice.getDeviceSn());
recoverGatewayOnline(parentDevice);
} else {
// 独立无人机:直接恢复
log.info("[Auto-Recovery] Drone {} is an independent device, recovering directly", deviceSn);
recoverDroneOnline(dbDevice);
}
} }
} }
...@@ -1726,6 +1739,7 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity> ...@@ -1726,6 +1739,7 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity>
} }
DeviceDTO dbDevice = dbDeviceOpt.get(); DeviceDTO dbDevice = dbDeviceOpt.get();
log.info("[Auto-Recovery] Recovering gateway {} and sub-device {}", gatewaySn, deviceSn);
GatewayManager gatewayManager = SDKManager.registerDevice(gatewaySn, deviceSn, GatewayManager gatewayManager = SDKManager.registerDevice(gatewaySn, deviceSn,
dbGateway.getDomain(), dbGateway.getType(), dbGateway.getDomain(), dbGateway.getType(),
dbGateway.getSubType(), dbGateway.getThingVersion(), dbDevice.getThingVersion()); dbGateway.getSubType(), dbGateway.getThingVersion(), dbDevice.getThingVersion());
...@@ -1759,6 +1773,7 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity> ...@@ -1759,6 +1773,7 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity>
if (DeviceDomainEnum.DRONE != dbDevice.getDomain()) { if (DeviceDomainEnum.DRONE != dbDevice.getDomain()) {
return; return;
} }
log.info("[Auto-Recovery] Recovering independent drone {}", dbDevice.getDeviceSn());
deviceRedisService.setDeviceOnline(dbDevice); deviceRedisService.setDeviceOnline(dbDevice);
this.subDroneOnlineSubscribeTopic(dbDevice.getDeviceSn()); this.subDroneOnlineSubscribeTopic(dbDevice.getDeviceSn());
// deviceService.pushDeviceOnlineTopo(dbGateway.getWorkspaceId(), dbGateway.getDeviceSn(), dbDevice.getDeviceSn()); // deviceService.pushDeviceOnlineTopo(dbGateway.getWorkspaceId(), dbGateway.getDeviceSn(), dbDevice.getDeviceSn());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment