获取统计数据成功
This commit is contained in:
@@ -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
|
||||
<Card title={<div style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 14, fontWeight: 600 }}><RobotOutlined style={{ color: '#165DFF' }} />机器人作业状态</div>} bordered={false} style={{ borderRadius: 12, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', border: '1px solid #f0f0f0' }}>
|
||||
<Row gutter={16} style={{ alignItems: 'center' }}>
|
||||
<Col span={8}>
|
||||
<div style={{ padding: '8px 12px', borderRadius: 8, background: '#f8fafc', textAlign: 'center' }}>
|
||||
<Statistic title={<span style={{ fontSize: 12, color: '#86909C' }}>累计里程</span>} value={128.5} suffix="km" valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }} />
|
||||
<div style={{ padding: '12px 16px', borderRadius: 10, background: '#F7F8FA', textAlign: 'center', border: '1px solid transparent', transition: 'all 0.2s' }}
|
||||
onMouseEnter={e => {
|
||||
e.currentTarget.style.background = '#E8F3FF';
|
||||
e.currentTarget.style.borderColor = '#165DFF';
|
||||
}}
|
||||
onMouseLeave={e => {
|
||||
e.currentTarget.style.background = '#F7F8FA';
|
||||
e.currentTarget.style.borderColor = 'transparent';
|
||||
}}
|
||||
>
|
||||
<Statistic
|
||||
title={<span style={{ fontSize: 11, color: '#666666', fontWeight: 400 }}>累计作业里程</span>}
|
||||
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 }}
|
||||
/>
|
||||
</div>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<div style={{ padding: '8px 12px', borderRadius: 8, background: '#f8fafc', textAlign: 'center' }}>
|
||||
<Statistic title={<span style={{ fontSize: 12, color: '#86909C' }}>累计作业面积</span>} value={45} suffix="min" valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }} />
|
||||
<div style={{ padding: '12px 16px', borderRadius: 10, background: '#F7F8FA', textAlign: 'center', border: '1px solid transparent', transition: 'all 0.2s' }}
|
||||
onMouseEnter={e => {
|
||||
e.currentTarget.style.background = '#E8F3FF';
|
||||
e.currentTarget.style.borderColor = '#165DFF';
|
||||
}}
|
||||
onMouseLeave={e => {
|
||||
e.currentTarget.style.background = '#F7F8FA';
|
||||
e.currentTarget.style.borderColor = 'transparent';
|
||||
}}
|
||||
>
|
||||
<Statistic
|
||||
title={<span style={{ fontSize: 11, color: '#666666', fontWeight: 400 }}>累计作业面积</span>}
|
||||
value={Number(deviceStatistics?.workArea || 0).toFixed(2)}
|
||||
suffix="㎡"
|
||||
valueStyle={{ fontSize: 20, fontWeight: 700, color: '#165DFF', marginTop: 4 }}
|
||||
/>
|
||||
</div>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<div style={{ padding: '8px 12px', borderRadius: 8, background: '#f8fafc', textAlign: 'center' }}>
|
||||
<Statistic title={<span style={{ fontSize: 12, color: '#86909C' }}>累计作业时长</span>} value={12} suffix="min" valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }} />
|
||||
<div style={{ padding: '12px 16px', borderRadius: 10, background: '#F7F8FA', textAlign: 'center', border: '1px solid transparent', transition: 'all 0.2s' }}
|
||||
onMouseEnter={e => {
|
||||
e.currentTarget.style.background = '#E8F3FF';
|
||||
e.currentTarget.style.borderColor = '#165DFF';
|
||||
}}
|
||||
onMouseLeave={e => {
|
||||
e.currentTarget.style.background = '#F7F8FA';
|
||||
e.currentTarget.style.borderColor = 'transparent';
|
||||
}}
|
||||
>
|
||||
<Statistic
|
||||
title={<span style={{ fontSize: 11, color: '#666666', fontWeight: 400 }}>累计作业时长</span>}
|
||||
value={Number(deviceStatistics?.time || 0).toFixed(2)}
|
||||
suffix="min"
|
||||
valueStyle={{ fontSize: 20, fontWeight: 700, color: '#165DFF', marginTop: 4 }}
|
||||
/>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
Reference in New Issue
Block a user