feat: 设备管理添加经纬度以及高度和租户

This commit is contained in:
2026-01-04 20:17:44 +08:00
parent fb40fce9cd
commit f88c1c9836
264 changed files with 684 additions and 14746 deletions
+32 -32
View File
@@ -2,11 +2,11 @@ import React, { useState, useEffect, useCallback, useMemo } from 'react';
import { Card, Button, List, Tag, Spin, message, DatePicker, Segmented, Space } from 'antd';
import {
DesktopOutlined,
CheckCircleOutlined,
WarningOutlined,
RocketOutlined,
EnvironmentOutlined,
PieChartOutlined
PieChartOutlined,
FieldTimeOutlined
} from '@ant-design/icons';
import { Line, Pie, Column, Area, Rose } from '@ant-design/plots';
import { history } from 'umi';
@@ -28,10 +28,10 @@ const Dashboard: React.FC = () => {
const [deviceStats, setDeviceStats] = useState<DeviceStats | null>(null);
const [taskStats, setTaskStats] = useState<TaskStats | null>(null);
const [taskTrend, setTaskTrend] = useState<TrendItem[]>([]);
const [deviceTrend, setDeviceTrend] = useState<TrendItem[]>([]);
const [alerts, setAlerts] = useState<AlertItem[]>([]);
const [annualData, setAnnualData] = useState<any[]>([]);
const [failureAnalysisData, setFailureAnalysisData] = useState<any[]>([]);
const [taskTypeData, setTaskTypeData] = useState<any[]>([]);
const [taskStatType, setTaskStatType] = useState<'day' | 'month' | 'year'>('day');
const [taskStatDate, setTaskStatDate] = useState(dayjs());
const [tenantId, setTenantId] = useState<string | undefined>();
@@ -63,6 +63,13 @@ const Dashboard: React.FC = () => {
{ type: '人为取消', value: 10 },
{ type: '其他', value: 5 },
]);
// 任务类型分布数据
setTaskTypeData([
{ type: '航线任务', value: 156 },
{ type: '一键起飞', value: 89 },
{ type: '手动控制', value: 45 },
]);
}, []);
useEffect(() => {
@@ -97,7 +104,6 @@ const Dashboard: React.FC = () => {
setDeviceStats(deviceRes);
setTaskStats(taskRes);
setTaskTrend(trendRes.taskTrend);
setDeviceTrend(trendRes.deviceTrend);
setAlerts(getMockAlerts());
} catch (error) {
console.error('获取数据失败:', error);
@@ -121,7 +127,8 @@ const Dashboard: React.FC = () => {
}, [fetchData]);
const goTo3D = () => {
history.push('/map3d');
// 传递来源页面,以便从map3d返回时能回到正确的大屏
history.push('/map3d?from=dashboard');
};
// --- 图表配置 ---
@@ -134,16 +141,13 @@ const Dashboard: React.FC = () => {
]);
}, [taskTrend]);
const deviceOnlineRateTrendData = useMemo(() => {
return deviceTrend.map((t) => {
const total = t.total || 0;
const online = t.online || 0;
return {
date: t.date,
value: total > 0 ? Math.round((online / total) * 100) : 0,
};
});
}, [deviceTrend]);
// 近7日任务完成数趋势数据
const taskCompleteTrendData = useMemo(() => {
return taskTrend.map((t) => ({
date: t.date,
value: t.completed || 0,
}));
}, [taskTrend]);
const taskTrendConfig: any = {
data: taskTrendSeriesData,
@@ -184,18 +188,14 @@ const Dashboard: React.FC = () => {
};
const columnConfig: any = {
data: [
{ type: '在线', value: deviceStats?.online || 0, color: '#00ff88' },
{ type: '离线', value: deviceStats?.offline || 0, color: '#8b9dc3' },
{ type: '故障', value: deviceStats?.fault || 0, color: '#ff4d4f' },
],
data: taskTypeData,
xField: 'type',
yField: 'value',
seriesField: 'type',
color: ({ type }: any) => {
if(type === '在线') return '#00ff88';
if(type === '故障') return '#ff4d4f';
return '#8b9dc3';
if(type === '航线任务') return '#00d4ff';
if(type === '一键起飞') return '#00ff88';
return '#ffb800';
},
label: {
text: (datum: any) => datum?.value?.toString() || '0',
@@ -207,12 +207,12 @@ const Dashboard: React.FC = () => {
height: 180,
};
const deviceOnlineRateConfig: any = {
data: deviceOnlineRateTrendData,
const taskCompleteTrendConfig: any = {
data: taskCompleteTrendData,
xField: 'date',
yField: 'value',
smooth: true,
color: '#00d4ff',
color: '#00ff88',
areaStyle: { fillOpacity: 0.15 },
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } }, grid: null },
yAxis: {
@@ -319,15 +319,15 @@ const Dashboard: React.FC = () => {
</div>
</Card>
<Card title="设备状态统计" className="panel-card glass-panel" size="small">
<Card title="任务类型统计" className="panel-card glass-panel" size="small">
<div className="chart-wrapper">
<Column {...columnConfig} />
</div>
</Card>
<Card title="近7日在线率趋势" className="panel-card glass-panel" size="small">
<Card title="近7日任务完成趋势" className="panel-card glass-panel" size="small">
<div className="chart-wrapper">
<Area {...deviceOnlineRateConfig} />
<Area {...taskCompleteTrendConfig} />
</div>
</Card>
@@ -374,10 +374,10 @@ const Dashboard: React.FC = () => {
</div>
</div>
<div className="kpi-card">
<div className="kpi-icon green"><CheckCircleOutlined /></div>
<div className="kpi-icon green"><EnvironmentOutlined /></div>
<div className="kpi-info">
<div className="label">在线率</div>
<div className="value">{deviceStats?.onlineRate || 0}<small>%</small></div>
<div className="label">景区总数</div>
<div className="value">{deviceStats?.tourismCount || 0}</div>
</div>
</div>
<div className="kpi-card">