Commit c3305092 by guoxuejian Committed by gdj

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 9a4ea0d7
......@@ -1703,7 +1703,20 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity>
} else if (DeviceDomainEnum.REMOTER_CONTROL == dbDevice.getDomain()) {
recoverGatewayOnline(dbDevice);
} 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);
}
}
}
......@@ -1731,6 +1744,7 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity>
}
DeviceDTO dbDevice = dbDeviceOpt.get();
log.info("[Auto-Recovery] Recovering gateway {} and sub-device {}", gatewaySn, deviceSn);
GatewayManager gatewayManager = SDKManager.registerDevice(gatewaySn, deviceSn,
dbGateway.getDomain(), dbGateway.getType(),
dbGateway.getSubType(), dbGateway.getThingVersion(), dbDevice.getThingVersion());
......@@ -1764,6 +1778,7 @@ public class DeviceServiceImpl extends ServiceImpl<IDeviceMapper, DeviceEntity>
if (DeviceDomainEnum.DRONE != dbDevice.getDomain()) {
return;
}
log.info("[Auto-Recovery] Recovering independent drone {}", dbDevice.getDeviceSn());
deviceRedisService.setDeviceOnline(dbDevice);
this.subDroneOnlineSubscribeTopic(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