feat: 设备管理添加经纬度以及高度和租户
This commit is contained in:
@@ -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">
|
||||
|
||||
+143
-208
@@ -3,10 +3,9 @@ import { Spin, Empty, message, Tooltip, Tabs, Progress, Modal } from 'antd';
|
||||
import type { TabsProps } from 'antd';
|
||||
import {
|
||||
CloseOutlined,
|
||||
EnvironmentOutlined,
|
||||
HomeOutlined,
|
||||
RocketOutlined,
|
||||
VideoCameraOutlined,
|
||||
HomeOutlined,
|
||||
ThunderboltOutlined,
|
||||
DashboardOutlined,
|
||||
SignalFilled,
|
||||
@@ -15,95 +14,59 @@ import {
|
||||
UnorderedListOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { deviceApi } from '@/services/device';
|
||||
import { ordersApi } from '@/services/orders';
|
||||
import { saveMission, MissionType } from '@/services/mission';
|
||||
import useDeviceSSE from '../hooks/useDeviceSSE';
|
||||
import styles from './RightPanel.less';
|
||||
|
||||
interface RightPanelProps {
|
||||
visible: boolean;
|
||||
tourism: any;
|
||||
device: any; // 直接接收选中的设备
|
||||
onClose: () => void;
|
||||
onControlClick: (device: any, realtimeData: any) => void;
|
||||
onTaskPanelOpen?: (device: any, dockData: any, tourismId?: number) => void; // 打开任务管理面板回调
|
||||
onTaskPanelOpen?: (device: any, dockData: any) => void; // 打开任务管理面板回调
|
||||
viewer?: any; // Cesium Viewer 实例
|
||||
Cesium?: any; // Cesium 库
|
||||
}
|
||||
|
||||
const RightPanel: React.FC<RightPanelProps> = ({
|
||||
visible,
|
||||
tourism,
|
||||
device,
|
||||
onClose,
|
||||
onControlClick,
|
||||
onTaskPanelOpen,
|
||||
viewer,
|
||||
Cesium
|
||||
}) => {
|
||||
const [deviceList, setDeviceList] = useState<any[]>([]);
|
||||
const [selectedDeviceSn, setSelectedDeviceSn] = useState<string>('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [takeoffLoading, setTakeoffLoading] = useState(false);
|
||||
|
||||
const { realtimeData, sseConnected, connectSSE, disconnectSSE } = useDeviceSSE();
|
||||
|
||||
const fetchDeviceList = async (tourismId: number) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const deviceSns = await ordersApi.getDeviceSnsByTourismId(tourismId);
|
||||
if (!deviceSns || deviceSns.length === 0) {
|
||||
setDeviceList([]);
|
||||
return;
|
||||
}
|
||||
const promises = deviceSns.map((sn: string) =>
|
||||
deviceApi.deviceList({ page: 1, limit: 1, deviceSn: sn })
|
||||
);
|
||||
const results = await Promise.all(promises);
|
||||
const devices = results
|
||||
.map((res: any) => (res.data && res.data.length > 0 ? res.data[0] : null))
|
||||
.filter((device: any) => device !== null);
|
||||
setDeviceList(devices);
|
||||
if (devices.length > 0) {
|
||||
setSelectedDeviceSn(devices[0].deviceSn || '');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.error('获取设备列表失败');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
// 当设备变化时,连接SSE
|
||||
useEffect(() => {
|
||||
if (device?.deviceSn && visible) {
|
||||
connectSSE(device.deviceSn);
|
||||
}
|
||||
};
|
||||
return () => {
|
||||
if (device?.deviceSn) {
|
||||
disconnectSSE(device.deviceSn);
|
||||
}
|
||||
};
|
||||
}, [device?.deviceSn, visible]);
|
||||
|
||||
useEffect(() => {
|
||||
if (visible && tourism?.id) fetchDeviceList(tourism.id);
|
||||
else { setDeviceList([]); setSelectedDeviceSn(''); }
|
||||
}, [visible, tourism?.id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedDeviceSn && visible) connectSSE(selectedDeviceSn);
|
||||
return () => { if (selectedDeviceSn) disconnectSSE(selectedDeviceSn); };
|
||||
}, [selectedDeviceSn, visible]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!visible && selectedDeviceSn) disconnectSSE(selectedDeviceSn);
|
||||
if (!visible && device?.deviceSn) {
|
||||
disconnectSSE(device.deviceSn);
|
||||
}
|
||||
}, [visible]);
|
||||
|
||||
const handleDeviceSelect = (deviceSn: string) => {
|
||||
if (deviceSn !== selectedDeviceSn) {
|
||||
setSelectedDeviceSn(deviceSn);
|
||||
}
|
||||
};
|
||||
|
||||
// 关闭面板时,主动断开SSE连接
|
||||
const handleClose = () => {
|
||||
// 先断开SSE连接
|
||||
if (selectedDeviceSn) {
|
||||
disconnectSSE(selectedDeviceSn);
|
||||
if (device?.deviceSn) {
|
||||
disconnectSSE(device.deviceSn);
|
||||
}
|
||||
// 然后调用父组件的关闭回调
|
||||
onClose();
|
||||
};
|
||||
|
||||
const selectedDevice = deviceList.find((d) => d.deviceSn === selectedDeviceSn);
|
||||
const dockData = realtimeData?.rawData?.dockData;
|
||||
const battery = realtimeData?.battery ?? 0;
|
||||
|
||||
@@ -156,10 +119,9 @@ const RightPanel: React.FC<RightPanelProps> = ({
|
||||
try {
|
||||
// 创建一键起飞任务(后端会自动执行起飞命令)
|
||||
const res = await saveMission({
|
||||
deviceSn: selectedDeviceSn,
|
||||
deviceSn: device?.deviceSn,
|
||||
missionType: MissionType.TAKEOFF,
|
||||
missionName: '一键起飞任务',
|
||||
tourismId: tourism?.id,
|
||||
targetLatitude: dockLatitude,
|
||||
targetLongitude: dockLongitude,
|
||||
targetHeight: targetHeight,
|
||||
@@ -176,7 +138,6 @@ const RightPanel: React.FC<RightPanelProps> = ({
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('一键起飞任务创建失败:', error);
|
||||
// 更详细的错误信息
|
||||
let errorMsg = '一键起飞任务创建失败';
|
||||
if (error.response) {
|
||||
const data = error.response.data;
|
||||
@@ -212,169 +173,143 @@ const RightPanel: React.FC<RightPanelProps> = ({
|
||||
<div className={styles.titleRow}>
|
||||
<div className={styles.titleInfo}>
|
||||
<div className={styles.mainTitle}>
|
||||
<EnvironmentOutlined className={styles.icon} />
|
||||
{tourism?.tourismName || '景区详情'}
|
||||
<HomeOutlined className={styles.icon} />
|
||||
{device?.deviceName || device?.deviceSn || '设备详情'}
|
||||
</div>
|
||||
<div className={styles.subTitle}>
|
||||
{realtimeData?.online ? 'ONLINE' : 'OFFLINE'}
|
||||
</div>
|
||||
<div className={styles.subTitle}>{deviceList.length} DEVICES ONLINE</div>
|
||||
</div>
|
||||
<button className={styles.closeBtn} onClick={handleClose}><CloseOutlined /></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{deviceList.length > 0 && (
|
||||
<div className={styles.deviceList}>
|
||||
<div className={styles.scrollContainer}>
|
||||
{deviceList.map((device) => {
|
||||
const isSelected = device.deviceSn === selectedDeviceSn;
|
||||
const isDeviceOnline = realtimeData?.deviceSn === device.deviceSn && realtimeData?.online;
|
||||
return (
|
||||
<div
|
||||
key={device.deviceSn}
|
||||
className={`${styles.deviceItem} ${isSelected ? styles.active : ''}`}
|
||||
onClick={() => handleDeviceSelect(device.deviceSn)}
|
||||
>
|
||||
<div className={styles.iconWrapper}>
|
||||
<HomeOutlined className={styles.icon} />
|
||||
<Tooltip title={isDeviceOnline ? '在线' : '离线'}>
|
||||
<div className={`${styles.statusDot} ${isDeviceOnline ? styles.online : ''}`} />
|
||||
</Tooltip>
|
||||
</div>
|
||||
<div className={styles.name}>{device.deviceName || device.deviceSn}</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className={styles.content}>
|
||||
<Spin spinning={loading}>
|
||||
{!selectedDevice ? (
|
||||
<Empty description="暂无设备数据" image={Empty.PRESENTED_IMAGE_SIMPLE} />
|
||||
) : (
|
||||
<Tabs
|
||||
defaultActiveKey="1"
|
||||
className={styles.customTabs}
|
||||
items={[
|
||||
{
|
||||
key: '1',
|
||||
label: <span><DashboardOutlined />综合状态</span>,
|
||||
children: (
|
||||
<div className={styles.detailContainer}>
|
||||
{/* Block A: 机库信息 */}
|
||||
<div className={styles.section}>
|
||||
<div className={styles.sectionHeader}>
|
||||
<span>机库信息 / DOCK INFO</span>
|
||||
<button
|
||||
className={styles.takeoffBtn}
|
||||
disabled={takeoffLoading || dockData?.mode_code === 1 || dockData?.drone_in_dock === 0}
|
||||
onClick={handleTakeoff}
|
||||
>
|
||||
{takeoffLoading ? <LoadingOutlined /> : <RocketOutlined />} 一键起飞
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* 状态卡片 */}
|
||||
<div className={styles.statusCard}>
|
||||
<div className={styles.statusHeader}>
|
||||
<span className={styles.statusTitle}>{selectedDevice?.deviceName || selectedDevice?.deviceSn}</span>
|
||||
<span className={`${styles.statusTag} ${realtimeData?.online ? styles.success : styles.error}`}>
|
||||
{realtimeData?.online ? '在线' : '离线'}
|
||||
</span>
|
||||
</div>
|
||||
<div className={styles.grid}>
|
||||
{renderItem('机库SN', selectedDevice?.deviceSn)}
|
||||
{renderItem('运行模式', dockData?.mode_code === 1 ? '工作' : '待机', '', dockData?.mode_code === 1 ? 'warning' : 'success')}
|
||||
{renderItem('舱门', dockData?.cover_state === 1 ? '开启' : '关闭')}
|
||||
{renderItem('告警', dockData?.alarm_state === 1 ? '告警' : '正常', '', dockData?.alarm_state === 1 ? 'error' : 'success')}
|
||||
{renderItem('急停', dockData?.emergency_stop_state === 1 ? '触发' : '正常', '', dockData?.emergency_stop_state === 1 ? 'error' : 'success')}
|
||||
{renderItem('推杆', dockData?.putter_state === 1 ? '展开' : '收起')}
|
||||
</div>
|
||||
</div>
|
||||
{!device ? (
|
||||
<Empty description="暂无设备数据" image={Empty.PRESENTED_IMAGE_SIMPLE} />
|
||||
) : (
|
||||
<Tabs
|
||||
defaultActiveKey="1"
|
||||
className={styles.customTabs}
|
||||
items={[
|
||||
{
|
||||
key: '1',
|
||||
label: <span><DashboardOutlined />综合状态</span>,
|
||||
children: (
|
||||
<div className={styles.detailContainer}>
|
||||
{/* Block A: 机库信息 */}
|
||||
<div className={styles.section}>
|
||||
<div className={styles.sectionHeader}>
|
||||
<span>机库信息 / DOCK INFO</span>
|
||||
<button
|
||||
className={styles.takeoffBtn}
|
||||
disabled={takeoffLoading || dockData?.mode_code === 1 || dockData?.drone_in_dock === 0}
|
||||
onClick={handleTakeoff}
|
||||
>
|
||||
{takeoffLoading ? <LoadingOutlined /> : <RocketOutlined />} 一键起飞
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Block B: 无人机信息 */}
|
||||
<div className={styles.section}>
|
||||
<div className={styles.sectionHeader}>无人机信息 / DRONE INFO</div>
|
||||
<div className={styles.grid}>
|
||||
{renderItem('无人机SN', dockData?.sub_device?.device_sn || '--')}
|
||||
{renderItem('连接状态', dockData?.sub_device?.device_online_status === 1 ? '在线' : '离线', '', dockData?.sub_device?.device_online_status === 1 ? 'success' : 'normal')}
|
||||
{renderItem('在库状态', dockData?.drone_in_dock === 1 ? '在库' : '外出', '', dockData?.drone_in_dock === 1 ? 'success' : 'warning')}
|
||||
{renderItem('对频状态', dockData?.sub_device?.device_paired === 1 ? '已对频' : '未对频')}
|
||||
{renderItem('RTK卫星', dockData?.position_state?.rtk_number, '颗')}
|
||||
{renderItem('定位状态', dockData?.position_state?.is_fixed === 2 ? '固定解' : '非固定', '', dockData?.position_state?.is_fixed === 2 ? 'success' : 'warning')}
|
||||
{renderItem('网络信号', dockData?.network_state?.type === 2 ? '4G' : 'WiFi')}
|
||||
{renderItem('网络质量', dockData?.network_state?.quality, '/5')}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 操作区 */}
|
||||
<div className={styles.actions}>
|
||||
<div className={styles.actionRow}>
|
||||
<button className={styles.primary} onClick={() => onControlClick(selectedDevice, realtimeData)}>
|
||||
<VideoCameraOutlined /> 进入操控台
|
||||
</button>
|
||||
<button className={styles.task} onClick={() => onTaskPanelOpen?.(selectedDevice, dockData, tourism?.id)}>
|
||||
<UnorderedListOutlined /> 任务管理
|
||||
</button>
|
||||
</div>
|
||||
{/* 状态卡片 */}
|
||||
<div className={styles.statusCard}>
|
||||
<div className={styles.statusHeader}>
|
||||
<span className={styles.statusTitle}>{device?.deviceName || device?.deviceSn}</span>
|
||||
<span className={`${styles.statusTag} ${realtimeData?.online ? styles.success : styles.error}`}>
|
||||
{realtimeData?.online ? '在线' : '离线'}
|
||||
</span>
|
||||
</div>
|
||||
<div className={styles.grid}>
|
||||
{renderItem('机库SN', device?.deviceSn)}
|
||||
{renderItem('运行模式', dockData?.mode_code === 1 ? '工作' : '待机', '', dockData?.mode_code === 1 ? 'warning' : 'success')}
|
||||
{renderItem('舱门', dockData?.cover_state === 1 ? '开启' : '关闭')}
|
||||
{renderItem('告警', dockData?.alarm_state === 1 ? '告警' : '正常', '', dockData?.alarm_state === 1 ? 'error' : 'success')}
|
||||
{renderItem('急停', dockData?.emergency_stop_state === 1 ? '触发' : '正常', '', dockData?.emergency_stop_state === 1 ? 'error' : 'success')}
|
||||
{renderItem('推杆', dockData?.putter_state === 1 ? '展开' : '收起')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: <span><ThunderboltOutlined />详细状态</span>,
|
||||
children: (
|
||||
<div className={styles.detailContainer}>
|
||||
{/* Block A: 机库环境与电气 */}
|
||||
<div className={styles.section}>
|
||||
<div className={styles.sectionHeader}>机库环境与电气 / DOCK ENV & POWER</div>
|
||||
<div className={styles.grid}>
|
||||
{renderItem('环境温度', dockData?.environment_temperature, '°C')}
|
||||
{renderItem('机库温度', dockData?.temperature, '°C')}
|
||||
{renderItem('环境湿度', dockData?.humidity, '%')}
|
||||
{renderItem('风速', dockData?.wind_speed, 'm/s')}
|
||||
{renderItem('降雨量', dockData?.rainfall, 'mm')}
|
||||
{renderItem('累计运行', formatValue(Math.floor((dockData?.acc_time ?? 0) / 3600), 'h'))}
|
||||
{renderItem('供电电压', dockData?.electric_supply_voltage, 'V')}
|
||||
{renderItem('输入功率', formatValue(dockData?.acdc_power_input, 'W'))}
|
||||
{renderItem('工作电流', formatValue((dockData?.working_current ?? 0) / 1000, 'A'))}
|
||||
{renderItem('备电电压', formatValue((dockData?.backup_battery?.voltage ?? 0) / 1000, 'V'))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Block B: 无人机详细状态 */}
|
||||
<div className={styles.section}>
|
||||
<div className={styles.sectionHeader}>无人机详细状态 / DRONE DETAIL</div>
|
||||
|
||||
{/* 电池大图标 */}
|
||||
<div style={{display:'flex', alignItems:'center', marginBottom: 16, background:'rgba(255,255,255,0.05)', padding:12, borderRadius:4}}>
|
||||
<div style={{marginRight:16}}>
|
||||
<div style={{fontSize:12, color:'rgba(255,255,255,0.6)'}}>BATTERY</div>
|
||||
<div style={{fontSize:24, fontWeight:'bold', color:battery<20?'#ff4d4f':'#00ff88'}}>{battery}%</div>
|
||||
</div>
|
||||
<div style={{flex:1}}>
|
||||
<Progress percent={battery} showInfo={false} strokeColor={battery<20?'#ff4d4f':'#00ff88'} trailColor="rgba(255,255,255,0.1)" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={styles.grid}>
|
||||
{renderItem('电池电压', formatValue((dockData?.drone_battery_maintenance_info?.batteries?.[0]?.voltage ?? 0) / 1000, 'V'))}
|
||||
{renderItem('电池温度', realtimeData?.temperature, '°C')}
|
||||
{renderItem('充电状态', dockData?.drone_charge_state?.state === 1 ? '充电中' : '未充电')}
|
||||
{renderItem('加热状态', dockData?.drone_battery_maintenance_info?.heat_state === 1 ? '加热中' : '未加热')}
|
||||
{renderItem('维护状态', dockData?.drone_battery_maintenance_info?.maintenance_state === 1 ? '维护中' : '正常')}
|
||||
{renderItem('存储模式', dockData?.battery_store_mode === 1 ? '计划模式' : '普通')}
|
||||
</div>
|
||||
{/* Block B: 无人机信息 */}
|
||||
<div className={styles.section}>
|
||||
<div className={styles.sectionHeader}>无人机信息 / DRONE INFO</div>
|
||||
<div className={styles.grid}>
|
||||
{renderItem('无人机SN', dockData?.sub_device?.device_sn || '--')}
|
||||
{renderItem('连接状态', dockData?.sub_device?.device_online_status === 1 ? '在线' : '离线', '', dockData?.sub_device?.device_online_status === 1 ? 'success' : 'normal')}
|
||||
{renderItem('在库状态', dockData?.drone_in_dock === 1 ? '在库' : '外出', '', dockData?.drone_in_dock === 1 ? 'success' : 'warning')}
|
||||
{renderItem('对频状态', dockData?.sub_device?.device_paired === 1 ? '已对频' : '未对频')}
|
||||
{renderItem('RTK卫星', dockData?.position_state?.rtk_number, '颗')}
|
||||
{renderItem('定位状态', dockData?.position_state?.is_fixed === 2 ? '固定解' : '非固定', '', dockData?.position_state?.is_fixed === 2 ? 'success' : 'warning')}
|
||||
{renderItem('网络信号', dockData?.network_state?.type === 2 ? '4G' : 'WiFi')}
|
||||
{renderItem('网络质量', dockData?.network_state?.quality, '/5')}
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
</Spin>
|
||||
|
||||
{/* 操作区 */}
|
||||
<div className={styles.actions}>
|
||||
<div className={styles.actionRow}>
|
||||
<button className={styles.primary} onClick={() => onControlClick(device, realtimeData)}>
|
||||
<VideoCameraOutlined /> 进入操控台
|
||||
</button>
|
||||
<button className={styles.task} onClick={() => onTaskPanelOpen?.(device, dockData)}>
|
||||
<UnorderedListOutlined /> 任务管理
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: <span><ThunderboltOutlined />详细状态</span>,
|
||||
children: (
|
||||
<div className={styles.detailContainer}>
|
||||
{/* Block A: 机库环境与电气 */}
|
||||
<div className={styles.section}>
|
||||
<div className={styles.sectionHeader}>机库环境与电气 / DOCK ENV & POWER</div>
|
||||
<div className={styles.grid}>
|
||||
{renderItem('环境温度', dockData?.environment_temperature, '°C')}
|
||||
{renderItem('机库温度', dockData?.temperature, '°C')}
|
||||
{renderItem('环境湿度', dockData?.humidity, '%')}
|
||||
{renderItem('风速', dockData?.wind_speed, 'm/s')}
|
||||
{renderItem('降雨量', dockData?.rainfall, 'mm')}
|
||||
{renderItem('累计运行', formatValue(Math.floor((dockData?.acc_time ?? 0) / 3600), 'h'))}
|
||||
{renderItem('供电电压', dockData?.electric_supply_voltage, 'V')}
|
||||
{renderItem('输入功率', formatValue(dockData?.acdc_power_input, 'W'))}
|
||||
{renderItem('工作电流', formatValue((dockData?.working_current ?? 0) / 1000, 'A'))}
|
||||
{renderItem('备电电压', formatValue((dockData?.backup_battery?.voltage ?? 0) / 1000, 'V'))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Block B: 无人机详细状态 */}
|
||||
<div className={styles.section}>
|
||||
<div className={styles.sectionHeader}>无人机详细状态 / DRONE DETAIL</div>
|
||||
|
||||
{/* 电池大图标 */}
|
||||
<div style={{display:'flex', alignItems:'center', marginBottom: 16, background:'rgba(255,255,255,0.05)', padding:12, borderRadius:4}}>
|
||||
<div style={{marginRight:16}}>
|
||||
<div style={{fontSize:12, color:'rgba(255,255,255,0.6)'}}>BATTERY</div>
|
||||
<div style={{fontSize:24, fontWeight:'bold', color:battery<20?'#ff4d4f':'#00ff88'}}>{battery}%</div>
|
||||
</div>
|
||||
<div style={{flex:1}}>
|
||||
<Progress percent={battery} showInfo={false} strokeColor={battery<20?'#ff4d4f':'#00ff88'} trailColor="rgba(255,255,255,0.1)" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={styles.grid}>
|
||||
{renderItem('电池电压', formatValue((dockData?.drone_battery_maintenance_info?.batteries?.[0]?.voltage ?? 0) / 1000, 'V'))}
|
||||
{renderItem('电池温度', realtimeData?.temperature, '°C')}
|
||||
{renderItem('充电状态', dockData?.drone_charge_state?.state === 1 ? '充电中' : '未充电')}
|
||||
{renderItem('加热状态', dockData?.drone_battery_maintenance_info?.heat_state === 1 ? '加热中' : '未加热')}
|
||||
{renderItem('维护状态', dockData?.drone_battery_maintenance_info?.maintenance_state === 1 ? '维护中' : '正常')}
|
||||
{renderItem('存储模式', dockData?.battery_store_mode === 1 ? '计划模式' : '普通')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
+1
-4
@@ -52,7 +52,6 @@ interface TaskPanelProps {
|
||||
Cesium?: any;
|
||||
droneData?: DroneData | null; // 从父组件接收无人机数据(SSE已在CesiumContainer中订阅)
|
||||
dockData?: any; // 机库数据,用于检查 mode_code
|
||||
tourismId?: number; // 景区ID
|
||||
}
|
||||
|
||||
// 获取任务状态图标
|
||||
@@ -102,7 +101,6 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
||||
Cesium,
|
||||
droneData, // 从父组件接收,无需自己订阅SSE
|
||||
dockData, // 机库数据,包含 mode_code
|
||||
tourismId, // 景区ID
|
||||
}) => {
|
||||
const deviceSn = device?.deviceSn;
|
||||
|
||||
@@ -440,7 +438,6 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
||||
const res = await saveMission({
|
||||
deviceSn: deviceSn!,
|
||||
missionType: MissionType.WAYLINE,
|
||||
tourismId: tourismId,
|
||||
waylineId: selectedRoute.routeId,
|
||||
waylineName: selectedRoute.routeName,
|
||||
});
|
||||
@@ -460,7 +457,7 @@ const TaskPanel: React.FC<TaskPanelProps> = ({
|
||||
} finally {
|
||||
setCreateLoading(false);
|
||||
}
|
||||
}, [selectedRouteId, routeList, deviceSn, tourismId, isDockIdle, loadMissionsByDevice]);
|
||||
}, [selectedRouteId, routeList, deviceSn, isDockIdle, loadMissionsByDevice]);
|
||||
|
||||
// 判断是否为视频文件
|
||||
const isVideoFile = useCallback((fileType?: string) => {
|
||||
|
||||
@@ -9,12 +9,12 @@ declare global {
|
||||
}
|
||||
|
||||
interface AmapContainerProps {
|
||||
tourismList: any[];
|
||||
onTourismClick: (tourism: any) => void;
|
||||
deviceList: any[];
|
||||
onDeviceClick: (device: any) => void;
|
||||
}
|
||||
|
||||
const AmapContainer: React.FC<AmapContainerProps> = (props) => {
|
||||
const { tourismList, onTourismClick } = props;
|
||||
const { deviceList, onDeviceClick } = props;
|
||||
const mapRef = useRef<HTMLDivElement>(null);
|
||||
const mapInstanceRef = useRef<any>(null);
|
||||
const markersRef = useRef<Map<string, any>>(new Map());
|
||||
@@ -107,37 +107,37 @@ const AmapContainer: React.FC<AmapContainerProps> = (props) => {
|
||||
};
|
||||
}, []);
|
||||
|
||||
// 更新景区标记
|
||||
// 更新设备标记
|
||||
useEffect(() => {
|
||||
if (!mapInstanceRef.current || !tourismList.length) return;
|
||||
if (!mapInstanceRef.current || !deviceList.length) return;
|
||||
|
||||
// 清除旧标记
|
||||
markersRef.current.forEach((marker, key) => {
|
||||
if (key.startsWith('tourism_')) {
|
||||
if (key.startsWith('device_')) {
|
||||
marker.setMap(null);
|
||||
markersRef.current.delete(key);
|
||||
}
|
||||
});
|
||||
|
||||
// 验证并过滤有效的景区坐标(只显示有经纬度的景区)
|
||||
const validTourisms = tourismList.filter((tourism) => {
|
||||
const lat = parseFloat(tourism.latitude);
|
||||
const lng = parseFloat(tourism.longitude);
|
||||
// 验证并过滤有效的设备坐标(只显示有经纬度的设备)
|
||||
const validDevices = deviceList.filter((device) => {
|
||||
const lat = parseFloat(device.latitude);
|
||||
const lng = parseFloat(device.longitude);
|
||||
return !isNaN(lat) && !isNaN(lng) && lat !== 0 && lng !== 0;
|
||||
});
|
||||
|
||||
// 如果没有有效景区,不进行后续操作
|
||||
if (validTourisms.length === 0) {
|
||||
// 如果没有有效设备,不进行后续操作
|
||||
if (validDevices.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 添加景区标记
|
||||
validTourisms.forEach((tourism) => {
|
||||
const lng = parseFloat(tourism.longitude);
|
||||
const lat = parseFloat(tourism.latitude);
|
||||
// 添加设备标记
|
||||
validDevices.forEach((device) => {
|
||||
const lng = parseFloat(device.longitude);
|
||||
const lat = parseFloat(device.latitude);
|
||||
|
||||
// 根据 status 状态设置颜色:1=绿色(启用),0=红色(禁用)
|
||||
const fillColor = tourism.status === 1 ? '#52c41a' : '#ff4d4f';
|
||||
// 设备默认显示绿色
|
||||
const fillColor = '#52c41a';
|
||||
|
||||
const marker = new window.AMap.CircleMarker({
|
||||
center: [lng, lat],
|
||||
@@ -151,13 +151,13 @@ const AmapContainer: React.FC<AmapContainerProps> = (props) => {
|
||||
});
|
||||
|
||||
// 添加点击事件
|
||||
marker.on('click', () => onTourismClick(tourism));
|
||||
marker.on('click', () => onDeviceClick(device));
|
||||
|
||||
// 添加信息窗体
|
||||
const infoWindow = new window.AMap.InfoWindow({
|
||||
content: `<div style="padding: 8px;">
|
||||
<h4 style="margin: 0 0 8px 0;">${tourism.tourismName || '景区'}</h4>
|
||||
<p style="margin: 0; color: #666;">${tourism.tourismAddress || ''}</p>
|
||||
<h4 style="margin: 0 0 8px 0;">${device.deviceName || device.deviceSn || '设备'}</h4>
|
||||
<p style="margin: 0; color: #666;">SN: ${device.deviceSn || ''}</p>
|
||||
</div>`,
|
||||
offset: new window.AMap.Pixel(0, -30),
|
||||
});
|
||||
@@ -171,9 +171,9 @@ const AmapContainer: React.FC<AmapContainerProps> = (props) => {
|
||||
});
|
||||
|
||||
marker.setMap(mapInstanceRef.current);
|
||||
markersRef.current.set(`tourism_${tourism.id}`, marker);
|
||||
markersRef.current.set(`device_${device.deviceSn}`, marker);
|
||||
});
|
||||
}, [tourismList, onTourismClick, mapReady]);
|
||||
}, [deviceList, onDeviceClick, mapReady]);
|
||||
|
||||
return <div ref={mapRef} style={{ width: '100%', height: '100%' }} />;
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ import TaskPanel from './3d/BottomPanel/TaskPanel';
|
||||
import TilesetPanel from './3d/TilesetPanel';
|
||||
import { useTilesetLoader, TilesetConfig } from './3d/hooks/useTilesetLoader';
|
||||
import { useDroneSSE } from './3d/hooks/useDroneSSE';
|
||||
import { getModelsByTourismId, convertToTilesetConfig } from '@/services/threeDModel';
|
||||
import { getModelsByDeviceSn, convertToTilesetConfig } from '@/services/threeDModel';
|
||||
|
||||
// 动态导入Cesium
|
||||
let Cesium: any = null;
|
||||
@@ -19,20 +19,20 @@ const DEFAULT_GLOBAL_VIEW = {
|
||||
};
|
||||
|
||||
interface CesiumContainerProps {
|
||||
tourismList: any[];
|
||||
externalSelectedTourism?: any; // 接收外部选择的景区
|
||||
deviceList: any[];
|
||||
externalSelectedDevice?: any; // 接收外部选择的设备
|
||||
onClearSelection?: () => void; // 清空选择的回调
|
||||
}
|
||||
|
||||
const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
const { tourismList, externalSelectedTourism, onClearSelection } = props;
|
||||
const { deviceList, externalSelectedDevice, onClearSelection } = props;
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const viewerRef = useRef<any>(null);
|
||||
const entitiesRef = useRef<Map<string, any>>(new Map());
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
// 3D 模式专属状态
|
||||
const [selectedTourism, setSelectedTourism] = useState<any>(null);
|
||||
const [selectedDevice, setSelectedDevice] = useState<any>(null);
|
||||
const [rightPanelVisible, setRightPanelVisible] = useState(false);
|
||||
const [leftPanelVisible, setLeftPanelVisible] = useState(false);
|
||||
|
||||
@@ -44,7 +44,6 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
const [taskPanelVisible, setTaskPanelVisible] = useState(false);
|
||||
const [taskPanelDevice, setTaskPanelDevice] = useState<any>(null);
|
||||
const [taskPanelDockData, setTaskPanelDockData] = useState<any>(null);
|
||||
const [taskPanelTourismId, setTaskPanelTourismId] = useState<number | undefined>(undefined);
|
||||
|
||||
// 无人机SSE订阅(用于在3D地球上显示无人机位置)
|
||||
const [droneDeviceSn, setDroneDeviceSn] = useState<string>('');
|
||||
@@ -60,7 +59,7 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
|
||||
// 3D Tiles 模型管理
|
||||
const [tilesetPanelVisible, setTilesetPanelVisible] = useState(false);
|
||||
const [currentTourismModels, setCurrentTourismModels] = useState<TilesetConfig[]>([]); // 当前景区的所有模型配置
|
||||
const [currentDeviceModels, setCurrentDeviceModels] = useState<TilesetConfig[]>([]); // 当前设备的所有模型配置
|
||||
const [modelLoading, setModelLoading] = useState(false);
|
||||
const [terrainLoading, setTerrainLoading] = useState(false); // 是否正在加载高程地形
|
||||
const terrainLoadedRef = useRef(false); // 是否已加载高程地形
|
||||
@@ -73,19 +72,19 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
setTilesetVisible,
|
||||
} = useTilesetLoader();
|
||||
|
||||
// 相机飞到景区
|
||||
const flyToTourism = useCallback((tourism: any) => {
|
||||
// 相机飞到设备位置
|
||||
const flyToDevice = useCallback((device: any) => {
|
||||
if (!viewerRef.current || !Cesium) return;
|
||||
// 检查 viewer 是否已销毁
|
||||
if (viewerRef.current.isDestroyed?.()) return;
|
||||
|
||||
const lon = parseFloat(tourism.longitude);
|
||||
const lat = parseFloat(tourism.latitude);
|
||||
const lon = parseFloat(device.longitude);
|
||||
const lat = parseFloat(device.latitude);
|
||||
|
||||
if (isNaN(lon) || isNaN(lat)) return;
|
||||
|
||||
viewerRef.current.camera.flyTo({
|
||||
destination: Cesium.Cartesian3.fromDegrees(lon, lat, 10000), // 5000km 高度
|
||||
destination: Cesium.Cartesian3.fromDegrees(lon, lat, 10000), // 10000m 高度
|
||||
orientation: {
|
||||
heading: 0,
|
||||
pitch: Cesium.Math.toRadians(-90), // 垂直俯视
|
||||
@@ -200,29 +199,29 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* 加载景区绑定的模型
|
||||
* 加载设备绑定的模型
|
||||
* 【优化】采用"先飞后加载"策略,用户点击后立即飞行,模型异步加载
|
||||
* 策略:
|
||||
* 1. 相机飞行已在 handleTourismSelect 中执行,此处专注于加载
|
||||
* 1. 相机飞行已在 handleDeviceSelect 中执行,此处专注于加载
|
||||
* 2. 高程和模型并行准备,减少等待时间
|
||||
* 3. 模型加载完成后,平滑调整到最佳观察视角
|
||||
*/
|
||||
const loadTourismModels = useCallback(async (tourismId: number): Promise<boolean> => {
|
||||
const loadDeviceModels = useCallback(async (deviceSn: string): Promise<boolean> => {
|
||||
if (!viewerRef.current || !Cesium) {
|
||||
console.log('Viewer或Cesium未准备好');
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log('开始查询景区模型, tourismId:', tourismId);
|
||||
console.log('开始查询设备模型, deviceSn:', deviceSn);
|
||||
setModelLoading(true);
|
||||
|
||||
// 先卸载之前的模型
|
||||
unloadAllTilesets(viewerRef.current);
|
||||
setCurrentTourismModels([]);
|
||||
setCurrentDeviceModels([]);
|
||||
|
||||
try {
|
||||
const res = await getModelsByTourismId(tourismId);
|
||||
console.log('查询景区模型结果:', res);
|
||||
const res = await getModelsByDeviceSn(deviceSn);
|
||||
console.log('查询设备模型结果:', res);
|
||||
|
||||
const modelList = res.datas || res.data; // 兼容两种返回格式
|
||||
if (res.resp_code === 0 && modelList && modelList.length > 0) {
|
||||
@@ -230,7 +229,7 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
console.log('转换后的模型配置:', configs);
|
||||
|
||||
// 保存所有模型配置(供模型面板使用)
|
||||
setCurrentTourismModels(configs);
|
||||
setCurrentDeviceModels(configs);
|
||||
|
||||
// 【优化】并行执行:高程加载和模型配置准备
|
||||
const firstModelTerrainType = configs[0]?.position?.terrainType;
|
||||
@@ -244,7 +243,7 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
const configsToLoad = configs.slice(0, autoLoadCount);
|
||||
|
||||
if (configs.length > autoLoadCount) {
|
||||
message.info(`景区共有 ${configs.length} 个模型,已自动加载第 1 个,其他可通过模型面板加载`);
|
||||
message.info(`设备共有 ${configs.length} 个模型,已自动加载第 1 个,其他可通过模型面板加载`);
|
||||
}
|
||||
|
||||
// 等待高程加载完成(通常很快,或者已缓存)
|
||||
@@ -272,7 +271,7 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
}
|
||||
|
||||
// 【优化】模型加载完成后,平滑调整到最佳观察视角
|
||||
// 使用较短的动画时间,因为相机已经在景区附近了
|
||||
// 使用较短的动画时间,因为相机已经在设备附近了
|
||||
if (firstTileset && viewerRef.current && !viewerRef.current.isDestroyed?.()) {
|
||||
try {
|
||||
viewerRef.current.flyTo(firstTileset, {
|
||||
@@ -291,42 +290,42 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
setModelLoading(false);
|
||||
return loadedCount > 0;
|
||||
} else {
|
||||
console.log('该景区没有绑定模型或查询结果为空');
|
||||
console.log('该设备没有绑定模型或查询结果为空');
|
||||
setModelLoading(false);
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载景区模型失败:', error);
|
||||
console.error('加载设备模型失败:', error);
|
||||
setModelLoading(false);
|
||||
return false;
|
||||
}
|
||||
}, [loadTileset, unloadAllTilesets, switchToElevationTerrain]);
|
||||
|
||||
// 处理景区点击
|
||||
// 处理设备点击
|
||||
// 优化策略:先飞行后加载,提升用户体验
|
||||
const handleTourismSelect = useCallback((tourism: any) => {
|
||||
setSelectedTourism(tourism);
|
||||
const handleDeviceSelect = useCallback((device: any) => {
|
||||
setSelectedDevice(device);
|
||||
setRightPanelVisible(true);
|
||||
// 切换景区时,关闭左侧操控台
|
||||
// 切换设备时,关闭左侧操控台
|
||||
setLeftPanelVisible(false);
|
||||
|
||||
// 【优化】立即飞到景区位置,不等待模型加载
|
||||
// 【优化】立即飞到设备位置,不等待模型加载
|
||||
// 这样用户点击后立刻能看到视角变化,体验更流畅
|
||||
flyToTourism(tourism);
|
||||
flyToDevice(device);
|
||||
|
||||
// 【优化】异步加载模型,不阻塞飞行动画
|
||||
// 模型加载完成后会自动调整到最佳视角
|
||||
if (tourism.id) {
|
||||
loadTourismModels(tourism.id);
|
||||
if (device.deviceSn) {
|
||||
loadDeviceModels(device.deviceSn);
|
||||
}
|
||||
}, [flyToTourism, loadTourismModels]);
|
||||
}, [flyToDevice, loadDeviceModels]);
|
||||
|
||||
// 处理外部选择变化
|
||||
useEffect(() => {
|
||||
if (externalSelectedTourism && !loading) {
|
||||
handleTourismSelect(externalSelectedTourism);
|
||||
if (externalSelectedDevice && !loading) {
|
||||
handleDeviceSelect(externalSelectedDevice);
|
||||
}
|
||||
}, [externalSelectedTourism, loading, handleTourismSelect]);
|
||||
}, [externalSelectedDevice, loading, handleDeviceSelect]);
|
||||
|
||||
// 清除无人机图层
|
||||
const clearDroneLayers = useCallback(() => {
|
||||
@@ -387,10 +386,9 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
}, [droneDeviceSn, disconnectDroneSSE, resetDroneData, clearDroneLayers]);
|
||||
|
||||
// 处理从右侧面板点击"任务管理"
|
||||
const handleOpenTaskPanel = useCallback((device: any, dockData: any, tourismId?: number) => {
|
||||
const handleOpenTaskPanel = useCallback((device: any, dockData: any) => {
|
||||
setTaskPanelDevice(device);
|
||||
setTaskPanelDockData(dockData);
|
||||
setTaskPanelTourismId(tourismId);
|
||||
setTaskPanelVisible(true);
|
||||
}, []);
|
||||
|
||||
@@ -553,7 +551,7 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
// 关闭右侧面板
|
||||
const handleRightPanelClose = useCallback(() => {
|
||||
setRightPanelVisible(false);
|
||||
setSelectedTourism(null);
|
||||
setSelectedDevice(null);
|
||||
setLeftPanelVisible(false); // 同时也关闭左侧
|
||||
|
||||
// 【修复】断开无人机SSE连接并清除图层
|
||||
@@ -568,7 +566,7 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
if (viewerRef.current) {
|
||||
unloadAllTilesets(viewerRef.current);
|
||||
}
|
||||
setCurrentTourismModels([]);
|
||||
setCurrentDeviceModels([]);
|
||||
setTilesetPanelVisible(false);
|
||||
|
||||
// 【修复】重置地形为椭球地形(快速响应,避免地形问题)
|
||||
@@ -578,7 +576,7 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
terrainLoadedRef.current = false;
|
||||
}
|
||||
|
||||
// 【修复】通知父组件清空景区选择框
|
||||
// 【修复】通知父组件清空设备选择框
|
||||
onClearSelection?.();
|
||||
|
||||
flyToGlobal();
|
||||
@@ -612,8 +610,8 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
// 切换模型可见性
|
||||
const handleToggleTilesetVisible = useCallback((id: string, visible: boolean) => {
|
||||
setTilesetVisible(id, visible);
|
||||
// 更新当前景区模型配置状态
|
||||
setCurrentTourismModels(prev =>
|
||||
// 更新当前设备模型配置状态
|
||||
setCurrentDeviceModels(prev =>
|
||||
prev.map(c => c.id === id ? { ...c, visible } : c)
|
||||
);
|
||||
}, [setTilesetVisible]);
|
||||
@@ -736,34 +734,35 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
};
|
||||
}, []);
|
||||
|
||||
// 更新景区标记
|
||||
// 更新设备标记
|
||||
useEffect(() => {
|
||||
if (loading || !viewerRef.current || !Cesium || !tourismList.length) return;
|
||||
if (loading || !viewerRef.current || !Cesium || !deviceList.length) return;
|
||||
|
||||
const viewer = viewerRef.current;
|
||||
|
||||
entitiesRef.current.forEach((entity, key) => {
|
||||
if (key.startsWith('tourism_')) {
|
||||
if (key.startsWith('device_')) {
|
||||
viewer.entities.remove(entity);
|
||||
entitiesRef.current.delete(key);
|
||||
}
|
||||
});
|
||||
|
||||
const validTourisms = tourismList.filter((tourism) => {
|
||||
const lat = parseFloat(tourism.latitude);
|
||||
const lng = parseFloat(tourism.longitude);
|
||||
const validDevices = deviceList.filter((device) => {
|
||||
const lat = parseFloat(device.latitude);
|
||||
const lng = parseFloat(device.longitude);
|
||||
return !isNaN(lat) && !isNaN(lng) && lat !== 0 && lng !== 0;
|
||||
});
|
||||
|
||||
if (validTourisms.length === 0) return;
|
||||
if (validDevices.length === 0) return;
|
||||
|
||||
validTourisms.forEach((tourism) => {
|
||||
const lon = parseFloat(tourism.longitude);
|
||||
const lat = parseFloat(tourism.latitude);
|
||||
const pointColor = tourism.status === 1 ? '#52c41a' : '#ff4d4f';
|
||||
validDevices.forEach((device) => {
|
||||
const lon = parseFloat(device.longitude);
|
||||
const lat = parseFloat(device.latitude);
|
||||
// 设备默认显示绿色
|
||||
const pointColor = '#52c41a';
|
||||
|
||||
const entity = viewer.entities.add({
|
||||
id: `tourism_${tourism.id}`,
|
||||
id: `device_${device.deviceSn}`,
|
||||
position: Cesium.Cartesian3.fromDegrees(lon, lat, 0),
|
||||
point: {
|
||||
pixelSize: 20,
|
||||
@@ -773,7 +772,7 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
||||
},
|
||||
label: {
|
||||
text: tourism.tourismName || '景区',
|
||||
text: device.deviceName || device.deviceSn || '设备',
|
||||
font: '14px sans-serif',
|
||||
fillColor: Cesium.Color.WHITE,
|
||||
outlineColor: Cesium.Color.BLACK,
|
||||
@@ -785,13 +784,13 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
},
|
||||
properties: {
|
||||
tourismData: tourism,
|
||||
deviceData: device,
|
||||
},
|
||||
});
|
||||
|
||||
entitiesRef.current.set(`tourism_${tourism.id}`, entity);
|
||||
entitiesRef.current.set(`device_${device.deviceSn}`, entity);
|
||||
});
|
||||
}, [tourismList, loading]);
|
||||
}, [deviceList, loading]);
|
||||
|
||||
// 点击事件
|
||||
useEffect(() => {
|
||||
@@ -806,9 +805,9 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
const pickedObject = viewer.scene.pick(movement.position);
|
||||
if (Cesium.defined(pickedObject) && pickedObject.id) {
|
||||
const entity = pickedObject.id;
|
||||
const tourismData = entity.properties?.tourismData?.getValue();
|
||||
if (tourismData) {
|
||||
handleTourismSelect(tourismData);
|
||||
const deviceData = entity.properties?.deviceData?.getValue();
|
||||
if (deviceData) {
|
||||
handleDeviceSelect(deviceData);
|
||||
}
|
||||
}
|
||||
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
||||
@@ -832,7 +831,7 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
handler.destroy();
|
||||
document.body.style.cursor = 'default';
|
||||
};
|
||||
}, [loading, handleTourismSelect]);
|
||||
}, [loading, handleDeviceSelect]);
|
||||
|
||||
return (
|
||||
<div style={{ width: '100%', height: '100%', position: 'relative' }}>
|
||||
@@ -898,8 +897,8 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 3D模型管理按钮 - 当景区有绑定模型时显示 */}
|
||||
{!loading && currentTourismModels.length > 0 && (
|
||||
{/* 3D模型管理按钮 - 当设备有绑定模型时显示 */}
|
||||
{!loading && currentDeviceModels.length > 0 && (
|
||||
<Tooltip title="3D模型管理">
|
||||
<Button
|
||||
type="primary"
|
||||
@@ -921,7 +920,7 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
<TilesetPanel
|
||||
visible={tilesetPanelVisible}
|
||||
tilesets={tilesets}
|
||||
configs={currentTourismModels}
|
||||
configs={currentDeviceModels}
|
||||
onLoad={handleLoadTileset}
|
||||
onUnload={handleUnloadTileset}
|
||||
onFlyTo={handleFlyToTileset}
|
||||
@@ -942,7 +941,7 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
{/* 右侧数据面板 */}
|
||||
<RightPanel
|
||||
visible={rightPanelVisible}
|
||||
tourism={selectedTourism}
|
||||
device={selectedDevice}
|
||||
onClose={handleRightPanelClose}
|
||||
onControlClick={handleOpenControl}
|
||||
onTaskPanelOpen={handleOpenTaskPanel}
|
||||
@@ -959,7 +958,6 @@ const CesiumContainer: React.FC<CesiumContainerProps> = (props) => {
|
||||
Cesium={Cesium}
|
||||
droneData={droneData}
|
||||
dockData={taskPanelDockData}
|
||||
tourismId={taskPanelTourismId}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -5,27 +5,27 @@ import styles from './index.less';
|
||||
|
||||
interface MapContainerProps {
|
||||
mode: '2d' | '3d';
|
||||
tourismList: any[];
|
||||
onTourismClick: (tourism: any) => void;
|
||||
selectedTourism?: any;
|
||||
deviceList: any[];
|
||||
onDeviceClick: (device: any) => void;
|
||||
selectedDevice?: any;
|
||||
onClearSelection?: () => void; // 清空选择的回调
|
||||
}
|
||||
|
||||
const MapContainer: React.FC<MapContainerProps> = (props) => {
|
||||
const { mode, tourismList, onTourismClick, selectedTourism, onClearSelection } = props;
|
||||
const { mode, deviceList, onDeviceClick, selectedDevice, onClearSelection } = props;
|
||||
|
||||
return (
|
||||
<div className={styles.mapContainer}>
|
||||
{/* 2D地图 - 高德 */}
|
||||
{mode === '2d' && (
|
||||
<AmapContainer tourismList={tourismList} onTourismClick={onTourismClick} />
|
||||
<AmapContainer deviceList={deviceList} onDeviceClick={onDeviceClick} />
|
||||
)}
|
||||
|
||||
{/* 3D地图 - Cesium(内部处理点击,显示底部面板) */}
|
||||
{mode === '3d' && (
|
||||
<CesiumContainer
|
||||
tourismList={tourismList}
|
||||
externalSelectedTourism={selectedTourism}
|
||||
deviceList={deviceList}
|
||||
externalSelectedDevice={selectedDevice}
|
||||
onClearSelection={onClearSelection}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.tourismSelect {
|
||||
.deviceSelect {
|
||||
width: 320px;
|
||||
|
||||
:global {
|
||||
@@ -149,7 +149,7 @@
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.tourismSelect {
|
||||
.deviceSelect {
|
||||
width: 260px;
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tourismSelect {
|
||||
.deviceSelect {
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@
|
||||
}
|
||||
|
||||
// 下拉弹窗样式
|
||||
.tourismSelectPopup {
|
||||
.deviceSelectPopup {
|
||||
:global {
|
||||
.ant-select-dropdown {
|
||||
background-color: rgba(10, 20, 30, 0.95);
|
||||
|
||||
@@ -7,29 +7,38 @@ import {
|
||||
FullscreenOutlined,
|
||||
FullscreenExitOutlined,
|
||||
GlobalOutlined,
|
||||
EnvironmentOutlined,
|
||||
HomeOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { history } from 'umi';
|
||||
import { history, useLocation } from 'umi';
|
||||
import MapContainer from './components/MapContainer';
|
||||
import { ordersApi } from '@/services/orders';
|
||||
import { deviceApi } from '@/services/device';
|
||||
import { tenantApi } from '@/services/tenant';
|
||||
import styles from './index.less';
|
||||
|
||||
const { Option } = Select;
|
||||
|
||||
const Map3D: React.FC = () => {
|
||||
const [tourismList, setTourismList] = useState<any[]>([]);
|
||||
const location = useLocation();
|
||||
const [deviceList, setDeviceList] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [isFullscreen, setIsFullscreen] = useState(false);
|
||||
const [params, setParams] = useState<{ tenantId?: string; includeChildren?: boolean }>({});
|
||||
const [portalReady, setPortalReady] = useState(false);
|
||||
|
||||
// 用于 3D 模式下的外部选择控制
|
||||
const [selectedTourism, setSelectedTourism] = useState<any>(null);
|
||||
const [selectedDevice, setSelectedDevice] = useState<any>(null);
|
||||
|
||||
// 首次进入时,默认按"当前租户 + 包含下级租户"查询
|
||||
useEffect(() => {
|
||||
setPortalReady(true);
|
||||
|
||||
// 保存来源页面到sessionStorage(用于重新登录后恢复)
|
||||
const searchParams = new URLSearchParams(location.search);
|
||||
const from = searchParams.get('from');
|
||||
if (from) {
|
||||
sessionStorage.setItem('map3d_from', from);
|
||||
}
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
let tenantId: string | undefined;
|
||||
@@ -69,51 +78,61 @@ const Map3D: React.FC = () => {
|
||||
return () => document.removeEventListener('fullscreenchange', onFullscreenChange);
|
||||
}, []);
|
||||
|
||||
// 获取景区列表
|
||||
const fetchTourismList = async () => {
|
||||
// 获取设备列表
|
||||
const fetchDeviceList = async () => {
|
||||
if (!params.tenantId) {
|
||||
return;
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
const response = await ordersApi.tourism({
|
||||
current: 1,
|
||||
pageSize: 1000,
|
||||
...params,
|
||||
const response = await deviceApi.deviceList({
|
||||
page: 1,
|
||||
limit: 1000,
|
||||
tenantId: params.tenantId,
|
||||
includeChildren: params.includeChildren,
|
||||
});
|
||||
setTourismList(response.data || []);
|
||||
setDeviceList(response.data || []);
|
||||
} catch (error) {
|
||||
message.error('获取景区列表失败');
|
||||
message.error('获取设备列表失败');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 景区点击事件 - 3D模式下不跳转,直接在地图上展示
|
||||
const handleTourismClick = (tourism: any) => {
|
||||
setSelectedTourism(tourism);
|
||||
// 设备点击事件 - 3D模式下不跳转,直接在地图上展示
|
||||
const handleDeviceClick = (device: any) => {
|
||||
setSelectedDevice(device);
|
||||
};
|
||||
|
||||
// 下拉框选择事件
|
||||
const handleDropdownSelect = (tourismId: number) => {
|
||||
const tourism = tourismList.find(t => t.id === tourismId);
|
||||
if (!tourism) return;
|
||||
setSelectedTourism(tourism);
|
||||
const handleDropdownSelect = (deviceSn: string) => {
|
||||
const device = deviceList.find(d => d.deviceSn === deviceSn);
|
||||
if (!device) return;
|
||||
setSelectedDevice(device);
|
||||
};
|
||||
|
||||
// 清空景区选择
|
||||
// 清空设备选择
|
||||
const handleClearSelection = () => {
|
||||
setSelectedTourism(null);
|
||||
setSelectedDevice(null);
|
||||
};
|
||||
|
||||
// 返回大屏 - 返回到进入时的来源页面
|
||||
const goBack = () => {
|
||||
// 检查是否有历史记录可以返回
|
||||
if (window.history.length > 1) {
|
||||
history.goBack();
|
||||
// 优先从URL参数获取来源,其次从sessionStorage获取(用于重新登录后恢复)
|
||||
const searchParams = new URLSearchParams(location.search);
|
||||
const from = searchParams.get('from') || sessionStorage.getItem('map3d_from');
|
||||
|
||||
// 清除sessionStorage中的来源记录
|
||||
sessionStorage.removeItem('map3d_from');
|
||||
|
||||
// 根据来源返回对应大屏
|
||||
if (from === 'maritime') {
|
||||
history.push('/maritime');
|
||||
} else if (from === 'dashboard') {
|
||||
history.push('/dashboard');
|
||||
} else {
|
||||
// 没有历史记录时返回默认首页
|
||||
// 默认返回路由配置的首页(当前是/maritime)
|
||||
history.push('/');
|
||||
}
|
||||
};
|
||||
@@ -129,17 +148,17 @@ const Map3D: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 租户ID获取后,加载景区列表
|
||||
// 租户ID获取后,加载设备列表
|
||||
useEffect(() => {
|
||||
if (params.tenantId) {
|
||||
fetchTourismList();
|
||||
fetchDeviceList();
|
||||
}
|
||||
}, [params.tenantId]);
|
||||
|
||||
// 过滤有效景区 (有经纬度)
|
||||
const validTourismList = tourismList.filter(t => {
|
||||
const lat = parseFloat(t.latitude);
|
||||
const lon = parseFloat(t.longitude);
|
||||
// 过滤有效设备 (有经纬度)
|
||||
const validDeviceList = deviceList.filter(d => {
|
||||
const lat = parseFloat(d.latitude);
|
||||
const lon = parseFloat(d.longitude);
|
||||
return !isNaN(lat) && !isNaN(lon) && lat !== 0 && lon !== 0;
|
||||
});
|
||||
|
||||
@@ -161,25 +180,25 @@ const Map3D: React.FC = () => {
|
||||
|
||||
<Select
|
||||
showSearch
|
||||
placeholder="请选择景区进入..."
|
||||
placeholder="请选择设备进入..."
|
||||
optionFilterProp="children"
|
||||
value={selectedTourism?.id}
|
||||
value={selectedDevice?.deviceSn}
|
||||
onChange={handleDropdownSelect}
|
||||
allowClear
|
||||
onClear={handleClearSelection}
|
||||
filterOption={(input, option) =>
|
||||
(option?.children as unknown as string).toLowerCase().indexOf(input.toLowerCase()) >= 0
|
||||
}
|
||||
className={styles.tourismSelect}
|
||||
suffixIcon={<EnvironmentOutlined style={{ color: '#00f0ff' }} />}
|
||||
classNames={{ popup: { root: styles.tourismSelectPopup } }}
|
||||
className={styles.deviceSelect}
|
||||
suffixIcon={<HomeOutlined style={{ color: '#00f0ff' }} />}
|
||||
classNames={{ popup: { root: styles.deviceSelectPopup } }}
|
||||
>
|
||||
{validTourismList.map(t => (
|
||||
<Option key={t.id} value={t.id}>{t.tourismName}</Option>
|
||||
{validDeviceList.map(d => (
|
||||
<Option key={d.deviceSn} value={d.deviceSn}>{d.deviceName || d.deviceSn}</Option>
|
||||
))}
|
||||
</Select>
|
||||
|
||||
<Badge status="success" text={`共${tourismList.length}个景区`} className={styles.statsBadge} />
|
||||
<Badge status="success" text={`共${deviceList.length}个设备`} className={styles.statsBadge} />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -195,7 +214,7 @@ const Map3D: React.FC = () => {
|
||||
|
||||
const headerRight = (
|
||||
<Space size={10} className={styles.headerRight}>
|
||||
<Button icon={<ReloadOutlined />} onClick={fetchTourismList} loading={loading}>
|
||||
<Button icon={<ReloadOutlined />} onClick={fetchDeviceList} loading={loading}>
|
||||
刷新
|
||||
</Button>
|
||||
<Button icon={isFullscreen ? <FullscreenExitOutlined /> : <FullscreenOutlined />} onClick={toggleFullscreen}>
|
||||
@@ -214,9 +233,9 @@ const Map3D: React.FC = () => {
|
||||
<div className={styles.mapWrapper}>
|
||||
<MapContainer
|
||||
mode="3d"
|
||||
tourismList={tourismList}
|
||||
onTourismClick={handleTourismClick}
|
||||
selectedTourism={selectedTourism}
|
||||
deviceList={deviceList}
|
||||
onDeviceClick={handleDeviceClick}
|
||||
selectedDevice={selectedDevice}
|
||||
onClearSelection={handleClearSelection}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -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