This commit is contained in:
parent
32de6a11a8
commit
ed1489092b
|
|
@ -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<DockAircraft> 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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue