feat: 设备管理添加经纬度以及高度和租户
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
||||
import { Card, Button, List, Tag, Spin, message, DatePicker, Segmented, Space } from 'antd';
|
||||
import {
|
||||
CheckCircleOutlined,
|
||||
WarningOutlined,
|
||||
RocketOutlined,
|
||||
CompassOutlined,
|
||||
PieChartOutlined,
|
||||
EnvironmentOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { Line, Pie, Column, Area, Rose } from '@ant-design/plots';
|
||||
import { history } from 'umi';
|
||||
@@ -34,10 +34,10 @@ const MaritimeDashboard: 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 [violationAnalysisData, setViolationAnalysisData] = 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>();
|
||||
@@ -69,6 +69,13 @@ const MaritimeDashboard: React.FC = () => {
|
||||
{ type: '污染排放', value: 8 },
|
||||
{ type: '其他违规', value: 3 },
|
||||
]);
|
||||
|
||||
// 任务类型分布数据
|
||||
setTaskTypeData([
|
||||
{ type: '航线巡检', value: 128 },
|
||||
{ type: '定点监测', value: 76 },
|
||||
{ type: '应急响应', value: 34 },
|
||||
]);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -103,7 +110,6 @@ const MaritimeDashboard: React.FC = () => {
|
||||
setDeviceStats(deviceRes);
|
||||
setTaskStats(taskRes);
|
||||
setTaskTrend(trendRes.taskTrend);
|
||||
setDeviceTrend(trendRes.deviceTrend);
|
||||
// 模拟海事告警数据
|
||||
setAlerts(getMaritimeAlerts());
|
||||
} catch (error) {
|
||||
@@ -139,7 +145,8 @@ const MaritimeDashboard: React.FC = () => {
|
||||
}, [fetchData]);
|
||||
|
||||
const goTo3D = () => {
|
||||
history.push('/map3d');
|
||||
// 传递来源页面,以便从map3d返回时能回到正确的大屏
|
||||
history.push('/map3d?from=maritime');
|
||||
};
|
||||
|
||||
// --- 图表配置 ---
|
||||
@@ -152,16 +159,13 @@ const MaritimeDashboard: 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,
|
||||
@@ -213,18 +217,14 @@ const MaritimeDashboard: React.FC = () => {
|
||||
};
|
||||
|
||||
const columnConfig: any = {
|
||||
data: [
|
||||
{ type: '在线', value: deviceStats?.online || 0 },
|
||||
{ type: '离线', value: deviceStats?.offline || 0 },
|
||||
{ type: '故障', value: deviceStats?.fault || 0 },
|
||||
],
|
||||
data: taskTypeData,
|
||||
xField: 'type',
|
||||
yField: 'value',
|
||||
seriesField: 'type',
|
||||
color: ({ type }: any) => {
|
||||
if (type === '在线') return '#00e5a0';
|
||||
if (type === '故障') return '#ff4d4f';
|
||||
return '#8b9dc3';
|
||||
if (type === '航线巡检') return '#00b4d8';
|
||||
if (type === '定点监测') return '#00e5a0';
|
||||
return '#ff9f43';
|
||||
},
|
||||
label: {
|
||||
text: (datum: any) => datum?.value?.toString() || '0',
|
||||
@@ -236,12 +236,12 @@ const MaritimeDashboard: React.FC = () => {
|
||||
height: 180,
|
||||
};
|
||||
|
||||
const deviceOnlineRateConfig: any = {
|
||||
data: deviceOnlineRateTrendData,
|
||||
const taskCompleteTrendConfig: any = {
|
||||
data: taskCompleteTrendData,
|
||||
xField: 'date',
|
||||
yField: 'value',
|
||||
smooth: true,
|
||||
color: '#00b4d8',
|
||||
color: '#00e5a0',
|
||||
areaStyle: { fillOpacity: 0.2 },
|
||||
xAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } }, grid: null },
|
||||
yAxis: {
|
||||
@@ -353,15 +353,15 @@ const MaritimeDashboard: React.FC = () => {
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card title="设备状态统计" className="panel-card ocean-glass" size="small">
|
||||
<Card title="任务类型统计" className="panel-card ocean-glass" size="small">
|
||||
<div className="chart-wrapper">
|
||||
<Column {...columnConfig} />
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card title="近7日在线率趋势" className="panel-card ocean-glass" size="small">
|
||||
<Card title="近7日任务完成趋势" className="panel-card ocean-glass" size="small">
|
||||
<div className="chart-wrapper">
|
||||
<Area {...deviceOnlineRateConfig} />
|
||||
<Area {...taskCompleteTrendConfig} />
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -408,10 +408,10 @@ const MaritimeDashboard: React.FC = () => {
|
||||
</div>
|
||||
</div>
|
||||
<div className="kpi-card">
|
||||
<div className="kpi-icon anchor"><CheckCircleOutlined /></div>
|
||||
<div className="kpi-icon anchor"><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">
|
||||
|
||||
Reference in New Issue
Block a user