架次和运行时长

This commit is contained in:
孙小云 2026-02-06 14:12:34 +08:00
parent 18832acf17
commit fca4eff00d
2 changed files with 45 additions and 5 deletions

View File

@ -195,6 +195,36 @@ public class TuohengDeviceAttributes {
}
);
/**
* 机场运行数据属性手动维护
*/
// 运行时长小时 - Integer
public static final AttributeKey<Integer> RUNNING_DURATION = AttributeKey.of(
"runningDuration",
Integer.class,
value -> {
if (value == null) return null;
if (value instanceof Number) {
return ((Number) value).intValue();
}
return Integer.parseInt(value.toString());
}
);
// 作业架次 - Integer
public static final AttributeKey<Integer> MISSION_COUNT = AttributeKey.of(
"missionCount",
Integer.class,
value -> {
if (value == null) return null;
if (value instanceof Number) {
return ((Number) value).intValue();
}
return Integer.parseInt(value.toString());
}
);
private TuohengDeviceAttributes() {
// 工具类禁止实例化
}
@ -221,7 +251,9 @@ public class TuohengDeviceAttributes {
HOME_LONGITUDE,
HOME_LATITUDE,
BACKUP_LONGITUDE,
BACKUP_LATITUDE
BACKUP_LATITUDE,
RUNNING_DURATION,
MISSION_COUNT
);
}

View File

@ -266,6 +266,18 @@ public class TuohengBufferDeviceImpl implements IBufferDeviceService {
dto.setBackupLatitude(DEFAULT_LATITUDE);
}
// 设置运行数据从属性中获取 runningDuration missionCount取不到则默认为 0
log.info("---------- 解析运行数据 ----------");
Integer runningDuration = attributes.get(TuohengDeviceAttributes.RUNNING_DURATION)
.orElse(0);
log.info("RUNNING_DURATION 运行时长: {} 小时", runningDuration);
dto.setRunningDuration(runningDuration);
Integer missionCount = attributes.get(TuohengDeviceAttributes.MISSION_COUNT)
.orElse(0);
log.info("MISSION_COUNT 作业架次: {}", missionCount);
dto.setMissionCount(missionCount);
// 设置在线状态 - 基于心跳时间戳判断离线基于无人机mode判断工作状态
telemetry.get(TuohengDeviceTelemetry.STATUS).ifPresentOrElse(statusValue -> {
long lastHeartbeatTime = statusValue.getTimestamp();
@ -476,10 +488,6 @@ public class TuohengBufferDeviceImpl implements IBufferDeviceService {
dto.setAircraftStatus(aircraftStatus);
// 设置作业架次 - 暂时设置为0拓恒设备可能没有这个数据
dto.setMissionCount(0);
log.info("设置作业架次: 0 (拓恒设备暂无此数据)");
log.info("拓恒无人机状态填充完成: aircraftIotDeviceId={}, aircraftStatus={}",
aircraftIotDeviceId, dto.getAircraftStatus());
log.info("========== 拓恒无人机状态填充结束 ==========");