From 21702f04d1344756cc45970fba4c8b046532a29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B0=8F=E4=BA=91?= Date: Wed, 21 Jan 2026 19:21:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A3=9E=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E9=95=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../thingsboard/constants/DeviceTelemetry.java | 16 ++++++++++++++++ .../device/service/impl/BufferDeviceImpl.java | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/main/java/com/ruoyi/device/domain/model/thingsboard/constants/DeviceTelemetry.java b/src/main/java/com/ruoyi/device/domain/model/thingsboard/constants/DeviceTelemetry.java index 86bedd4..274d4f7 100644 --- a/src/main/java/com/ruoyi/device/domain/model/thingsboard/constants/DeviceTelemetry.java +++ b/src/main/java/com/ruoyi/device/domain/model/thingsboard/constants/DeviceTelemetry.java @@ -443,6 +443,21 @@ public class DeviceTelemetry { } ); + /** + * 总飞行时长(单位:秒) + */ + public static final TelemetryKey Total_Flight_Time = TelemetryKey.of( + "total_flight_time", + Integer.class, + value -> { + if (value == null) return null; + if (value instanceof Number) { + return ((Number) value).intValue(); + } + return Integer.parseInt(value.toString()); + } + ); + /** @@ -470,6 +485,7 @@ public class DeviceTelemetry { FlightTask_Step_Code, Sub_Device_Online_Status, Total_Flight_Sorties, + Total_Flight_Time, Drone_Charge_State_State, Drone_In_Dock, Acc_Time, 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 ee97b85..824e32c 100644 --- a/src/main/java/com/ruoyi/device/service/impl/BufferDeviceImpl.java +++ b/src/main/java/com/ruoyi/device/service/impl/BufferDeviceImpl.java @@ -190,6 +190,17 @@ public class BufferDeviceImpl implements IBufferDeviceService } }); + // 飞行时长 - 从 total_flight_time 获取秒数并转换为天 + telemetryMap.get(DeviceTelemetry.Total_Flight_Time) + .ifPresent(telemetryValue -> { + Integer seconds = telemetryValue.getValue(); + if (seconds != null) { + // 将秒转换为天:秒 / (60 * 60 * 24) + Integer days = seconds / (60 * 60 * 24); + dto.setFlightDuration(days); + } + }); + return dto; }