From ed1489092b1e363162bbaeab134c326c3ef44267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B0=8F=E4=BA=91?= Date: Thu, 29 Jan 2026 09:21:19 +0800 Subject: [PATCH] xx --- .../device/service/impl/BufferDeviceImpl.java | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/ruoyi/device/service/impl/BufferDeviceImpl.java b/src/main/java/com/ruoyi/device/service/impl/BufferDeviceImpl.java index 80e1bb7..3154cc1 100644 --- a/src/main/java/com/ruoyi/device/service/impl/BufferDeviceImpl.java +++ b/src/main/java/com/ruoyi/device/service/impl/BufferDeviceImpl.java @@ -115,7 +115,7 @@ public class BufferDeviceImpl implements IBufferDeviceService } - AircraftDetailDTO aircraftDetailDTO = getChangeAbleAirDetailDTO(airDevice.getIotDeviceId()); + AircraftDetailDTO aircraftDetailDTO = getChangeAbleAirDetailDTO(airDevice.getIotDeviceId(), device.getIotDeviceId()); /** * 设置无人机状态 */ @@ -147,8 +147,21 @@ public class BufferDeviceImpl implements IBufferDeviceService Device device = deviceDomain.selectDeviceByDeviceId(aircraft.getDeviceId()); log.info("selectDeviceByDeviceId {}",JSON.toJSONString(device)); + // 查找无人机关联的机场 + List dockAircrafts = dockAircraftDomain.selectDockAircraftByAircraftId(aircraftId); + String dockDeviceIotId = null; + if (!CollectionUtils.isEmpty(dockAircrafts)) { + DockAircraft dockAircraft = dockAircrafts.get(0); + Dock dock = dockDomain.selectDockByDockId(dockAircraft.getDockId()); + if (dock != null) { + Device dockDevice = deviceDomain.selectDeviceByDeviceId(dock.getDeviceId()); + if (dockDevice != null) { + dockDeviceIotId = dockDevice.getIotDeviceId(); + } + } + } - AircraftDetailDTO dto = getChangeAbleAirDetailDTO(device.getIotDeviceId()); + AircraftDetailDTO dto = getChangeAbleAirDetailDTO(device.getIotDeviceId(), dockDeviceIotId); dto.setAircraftId(aircraft.getAircraftId()); dto.setAircraftName(aircraft.getAircraftName()); dto.setSnNumber(device.getDeviceSn()); @@ -472,12 +485,16 @@ public class BufferDeviceImpl implements IBufferDeviceService } } - private AircraftDetailDTO getChangeAbleAirDetailDTO(String deviceIotId) + private AircraftDetailDTO getChangeAbleAirDetailDTO(String aircraftDeviceIotId, String dockDeviceIotId) { AircraftDetailDTO dto = new AircraftDetailDTO(); - AttributeMap attributeMap = thingsBoardDomain.getPredefinedDeviceAttributes(deviceIotId); - TelemetryMap telemetryMap = thingsBoardDomain.getPredefinedDeviceTelemetry(deviceIotId); + AttributeMap attributeMap = thingsBoardDomain.getPredefinedDeviceAttributes(aircraftDeviceIotId); + TelemetryMap telemetryMap = thingsBoardDomain.getPredefinedDeviceTelemetry(aircraftDeviceIotId); + + + AttributeMap attributeDockMap = thingsBoardDomain.getPredefinedDeviceAttributes(dockDeviceIotId); + TelemetryMap telemetryDockMap = thingsBoardDomain.getPredefinedDeviceTelemetry(dockDeviceIotId); //设置aircraftStatus // drone_in_dock 表示是否在舱外 @@ -486,7 +503,7 @@ public class BufferDeviceImpl implements IBufferDeviceService // 任务中 和 调试, 这两个状态用机场的, 暂时不要用离线状态 // - String aircraftStatus = determineAircraftStatus(attributeMap, telemetryMap); + String aircraftStatus = determineAircraftStatus(attributeMap, telemetryDockMap); dto.setAircraftStatus(aircraftStatus); // 从 TelemetryMap 中获取 total_flight_sorties 赋予 missionCount @@ -524,8 +541,8 @@ public class BufferDeviceImpl implements IBufferDeviceService /** * 根据设备属性和遥测数据确定无人机状态 * - * @param attributeMap 设备属性映射 - * @param telemetryMap 设备遥测数据映射 + * @param attributeMap 无人机 属性映射 + * @param telemetryMap 机场 遥测数据映射 * @return 无人机状态字符串 */ private String determineAircraftStatus(AttributeMap attributeMap, TelemetryMap telemetryMap) {