This commit is contained in:
parent
f733eff2ea
commit
296af4f342
|
|
@ -7,7 +7,6 @@ import com.ruoyi.device.domain.api.*;
|
||||||
import com.ruoyi.device.domain.model.*;
|
import com.ruoyi.device.domain.model.*;
|
||||||
import com.ruoyi.device.domain.model.thingsboard.AttributeMap;
|
import com.ruoyi.device.domain.model.thingsboard.AttributeMap;
|
||||||
import com.ruoyi.device.domain.model.thingsboard.TelemetryMap;
|
import com.ruoyi.device.domain.model.thingsboard.TelemetryMap;
|
||||||
import com.ruoyi.device.domain.model.thingsboard.TelemetryValue;
|
|
||||||
import com.ruoyi.device.domain.model.thingsboard.constants.DeviceAttributes;
|
import com.ruoyi.device.domain.model.thingsboard.constants.DeviceAttributes;
|
||||||
import com.ruoyi.device.domain.model.thingsboard.constants.DeviceTelemetry;
|
import com.ruoyi.device.domain.model.thingsboard.constants.DeviceTelemetry;
|
||||||
import com.ruoyi.device.service.api.IBufferDeviceService;
|
import com.ruoyi.device.service.api.IBufferDeviceService;
|
||||||
|
|
@ -27,7 +26,6 @@ import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -573,20 +571,16 @@ public class BufferDeviceImpl implements IBufferDeviceService
|
||||||
.map(telemetryValue -> telemetryValue.getValue())
|
.map(telemetryValue -> telemetryValue.getValue())
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
// 从机场遥测数据中获取 total_flight_time,根据更新时间判断无人机是否开机
|
// 从 telemetryAirportMap 中取 total_flight_time, 如果时间是在一分钟以内更新的,则为开机,否则为关机
|
||||||
// 如果 total_flight_time 在1分钟以内更新,则认为无人机开机,否则关机
|
|
||||||
boolean isPowerOn = false;
|
// 获取无人机是否开机: {"0":"关机","1":"开机"}
|
||||||
Optional<TelemetryValue<Integer>> totalFlightTimeOpt = telemetryMap.get(DeviceTelemetry.Total_Flight_Time);
|
Integer deviceOnlineStatus = telemetryMap.get(DeviceTelemetry.Sub_Device_Online_Status)
|
||||||
if (totalFlightTimeOpt.isPresent()) {
|
.map(telemetryValue -> telemetryValue.getValue())
|
||||||
long updateTimestamp = totalFlightTimeOpt.get().getTimestamp();
|
.orElse(null);
|
||||||
long currentTimestamp = System.currentTimeMillis();
|
|
||||||
long timeDiff = currentTimestamp - updateTimestamp;
|
|
||||||
// 1分钟 = 60000 毫秒
|
|
||||||
isPowerOn = timeDiff <= 60000;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据舱内/舱外和开机/关机状态确定无人机状态
|
// 根据舱内/舱外和开机/关机状态确定无人机状态
|
||||||
boolean isInCabin = droneInDock != null && droneInDock == 1;
|
boolean isInCabin = droneInDock != null && droneInDock == 1;
|
||||||
|
boolean isPowerOn = deviceOnlineStatus != null && deviceOnlineStatus == 1;
|
||||||
|
|
||||||
if (isInCabin) {
|
if (isInCabin) {
|
||||||
// 舱内
|
// 舱内
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue