diff --git a/src/api/device.ts b/src/api/device.ts index 970a83a..75e4cdf 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -344,6 +344,27 @@ export function getSiteDeviceTaskHistory(data) { }) } +//获取统计数据/iot/device/getDeviceIntradayData + +export function getDeviceStatistics(data) { + return request({ + url: `/iot/device/getDeviceRunStatistics`, + method: 'get', + params: data + }) +} + +//getDeviceTotalData + + +export function getDeviceTotalData(data) { + return request({ + url: `/iot/device/getDeviceTotalData`, + method: 'get', + params: data + }) +} + diff --git a/src/components/VolcRtcPlayer.jsx b/src/components/VolcRtcPlayer.jsx index 8140f1c..3e4de07 100644 --- a/src/components/VolcRtcPlayer.jsx +++ b/src/components/VolcRtcPlayer.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useRef } from "react"; import { DroneRTC } from "./droneplayer"; -import { postLiveHeartbeat } from "@/api/api"; + export default function DroneLivePlayer({ streamData, diff --git a/src/components/devices/DeviceOverviewPage.tsx b/src/components/devices/DeviceOverviewPage.tsx index 385e1f7..de83363 100644 --- a/src/components/devices/DeviceOverviewPage.tsx +++ b/src/components/devices/DeviceOverviewPage.tsx @@ -22,7 +22,7 @@ import AgoraTextTest from '../AgoraRtc.tsx'; import { useWebRTCPlayer } from '../useWebRTCStream.tsx'; import VideoPlayer from '../VideoPlayer.tsx.tsx'; import CesiumMap from '../Map.jsx'; -import { getUAVState, getSiteDevice, getSiteUAVList, getsinglePlan, getRobotTaskList } from '@/api/device.ts'; +import { getUAVState, getSiteDevice, getSiteUAVList, getsinglePlan, getRobotTaskList, getDeviceTotalData } from '@/api/device.ts'; import dayjs from 'dayjs'; import { useMqtt } from '@/hooks/useMqtt'; import { useSelector } from 'react-redux'; @@ -64,6 +64,7 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS const [planedevices, setPlaneDevices] = useState([]); const [devicesAll, setDevicesAll] = useState([]); const [taskStats, setTaskStats] = useState({ completed: 12, total: 15 }); + const [deviceStatistics, setDeviceStatistics] = useState(null); // 获取数据 const fetchAllData = async () => { @@ -106,11 +107,7 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS console.error('数据请求失败', err); } }; - const freePlaneData = useMemo(() => { - if (!planedevices) return; - const data = planedevices.filter(item => item.modeStatistics !== 'running').length || 0; - return data; - }, [planedevices]) + useEffect(() => { fetchAllData(); @@ -189,6 +186,18 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS }, [devicesAll, selectedSn]); const isUAV = !!selectedDevice?.gateway_sn; + useEffect(() => { + if (isUAV || !selectedDevice?.serialNumber) return; + const params = { + deviceId: selectedDevice?.serialNumber, + + } + getDeviceTotalData(params).then((res) => { + if (res.code == 200) { + setDeviceStatistics(res.data || {}) + } + }) + }, [selectedDevice]) // ======================== 核心优化:视频用设备对象(绝不随MQTT刷新)======================== const videoDevice = useMemo(() => { @@ -820,18 +829,60 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS 机器人作业状态} bordered={false} style={{ borderRadius: 12, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', border: '1px solid #f0f0f0' }}> -
- 累计里程} value={128.5} suffix="km" valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }} /> +
{ + e.currentTarget.style.background = '#E8F3FF'; + e.currentTarget.style.borderColor = '#165DFF'; + }} + onMouseLeave={e => { + e.currentTarget.style.background = '#F7F8FA'; + e.currentTarget.style.borderColor = 'transparent'; + }} + > + 累计作业里程} + value={deviceStatistics?.distance ? Number(deviceStatistics.distance).toFixed(2) : Number(deviceStatistics?.workArea / 0.7 || 0).toFixed(2)} + suffix="m" + valueStyle={{ fontSize: 20, fontWeight: 700, color: '#165DFF', marginTop: 4 }} + />
-
- 累计作业面积} value={45} suffix="min" valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }} /> +
{ + e.currentTarget.style.background = '#E8F3FF'; + e.currentTarget.style.borderColor = '#165DFF'; + }} + onMouseLeave={e => { + e.currentTarget.style.background = '#F7F8FA'; + e.currentTarget.style.borderColor = 'transparent'; + }} + > + 累计作业面积} + value={Number(deviceStatistics?.workArea || 0).toFixed(2)} + suffix="㎡" + valueStyle={{ fontSize: 20, fontWeight: 700, color: '#165DFF', marginTop: 4 }} + />
-
- 累计作业时长} value={12} suffix="min" valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }} /> +
{ + e.currentTarget.style.background = '#E8F3FF'; + e.currentTarget.style.borderColor = '#165DFF'; + }} + onMouseLeave={e => { + e.currentTarget.style.background = '#F7F8FA'; + e.currentTarget.style.borderColor = 'transparent'; + }} + > + 累计作业时长} + value={Number(deviceStatistics?.time || 0).toFixed(2)} + suffix="min" + valueStyle={{ fontSize: 20, fontWeight: 700, color: '#165DFF', marginTop: 4 }} + />