From a64c2e3d67f7d4b1c86ecd4617cfaefed5b89a6e Mon Sep 17 00:00:00 2001 From: Iamasoldier <1272745473@qq.com> Date: Wed, 18 Jun 2025 16:30:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E7=B4=A0=E6=9D=90?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=AE=8C=E6=88=90=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E8=B7=B3=E8=BD=AC=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listener/OrderStatusChangeListener.java | 2 +- .../src/pages/device-ops/monitor/index.tsx | 2348 ++++++++++++++--- 2 files changed, 1990 insertions(+), 360 deletions(-) diff --git a/zlt-business/order-center/src/main/java/com/central/order/listener/OrderStatusChangeListener.java b/zlt-business/order-center/src/main/java/com/central/order/listener/OrderStatusChangeListener.java index 19fef809..9a90ce66 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/listener/OrderStatusChangeListener.java +++ b/zlt-business/order-center/src/main/java/com/central/order/listener/OrderStatusChangeListener.java @@ -285,7 +285,7 @@ public class OrderStatusChangeListener { String tip = "素材上传完成"; String orderName = tourism.getTourismName(); - String pageUrl = "pages/task/task"; + String pageUrl = "pages/album/album"; wxMiniSubscribeService.sendServiceProcessMsg( sysUser.getOpenId(), orderName, diff --git a/zlt-web/react-web/src/main/frontend/src/pages/device-ops/monitor/index.tsx b/zlt-web/react-web/src/main/frontend/src/pages/device-ops/monitor/index.tsx index 0a8f8974..61a32194 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/device-ops/monitor/index.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/device-ops/monitor/index.tsx @@ -1,14 +1,158 @@ import React, { useState, useEffect, useRef } from 'react'; import { PageContainer } from '@ant-design/pro-layout'; -import { Card, Row, Col, DatePicker, Select, Space, Table, Tag, Statistic, message, Modal } from 'antd'; -import { Line } from '@ant-design/plots'; +import { + Card, Row, Col, DatePicker, Select, Space, Table, Tag, Statistic, message, Modal, + Tabs, Progress, Alert, Badge, Tooltip, Button, Input, Switch, Slider, Drawer, + Timeline, List, Avatar, Divider, Typography, Collapse, Descriptions, Rate +} from 'antd'; import moment from 'moment'; -import { CheckCircleOutlined, CloseCircleOutlined, EnvironmentOutlined } from '@ant-design/icons'; -import { device } from '@/services/device/api'; +import { + CheckCircleOutlined, CloseCircleOutlined, EnvironmentOutlined, + WarningOutlined, InfoCircleOutlined, ExclamationCircleOutlined, + ThunderboltOutlined, CloudOutlined, WifiOutlined, + DashboardOutlined, BarChartOutlined, SettingOutlined, BellOutlined, + EyeOutlined, ReloadOutlined, DownloadOutlined, FilterOutlined, + PlayCircleOutlined, PauseCircleOutlined, StopOutlined, CameraOutlined, + VideoCameraOutlined, SoundOutlined, BulbOutlined, ToolOutlined +} from '@ant-design/icons'; +import { device, getStreamUrls } from '@/services/device/api'; import { request } from 'umi'; import { Amap } from '@amap/amap-react'; const { RangePicker } = DatePicker; +const { TabPane } = Tabs; +const { Title, Text } = Typography; +const { Panel } = Collapse; + +interface DeviceLocation { + latitude: number; + longitude: number; + height?: number; + heading?: number; + updateTime: string; +} + +interface TrajectoryPoint { + latitude: number; + longitude: number; + height?: number; + heading?: number; + timestamp: number; + speed?: number; +} + +interface DeviceMetrics { + temperature: number; + humidity: number; + windSpeed: number; + rainfall: number; + environmentTemperature: number; + positionQuality: number; + networkQuality: number; + droneInDock: number; + batteryCapacity: number; + batteryState: number; + workingVoltage: number; + workingCurrent: number; + acdcPowerInput: number; + backupBatteryVoltage: number; + flightTaskStep: number; + tiltAngle: number; + sdrUpQuality: number; + sdrDownQuality: number; + wirelessLinkState: number; + wirelessLinkQuality: number; + '4gLinkState': number; + '4gLinkQuality': number; + // 新增监控维度 + signalStrength: number; + dataRate: number; + packetLoss: number; + latency: number; + cpuUsage: number; + memoryUsage: number; + diskUsage: number; + errorCount: number; + warningCount: number; + uptime: number; + lastMaintenance: string; + nextMaintenance: string; +} + +interface DeviceHealth { + overall: number; // 0-100 + battery: number; + network: number; + hardware: number; + software: number; + environment: number; + lastCheck: string; + issues: string[]; + recommendations: string[]; +} + +interface DevicePerformance { + responseTime: number; + throughput: number; + availability: number; + reliability: number; + efficiency: number; + trends: { + daily: number[]; + weekly: number[]; + monthly: number[]; + }; +} + +interface DeviceAlert { + id: string; + deviceSn: string; + deviceName: string; + type: 'critical' | 'warning' | 'info'; + category: 'battery' | 'network' | 'hardware' | 'environment' | 'security' | 'performance'; + title: string; + description: string; + timestamp: string; + status: 'active' | 'acknowledged' | 'resolved'; + priority: 'high' | 'medium' | 'low'; + assignedTo?: string; + resolution?: string; + resolvedAt?: string; +} + +interface DeviceEvent { + id: string; + deviceSn: string; + eventType: string; + description: string; + timestamp: string; + severity: 'info' | 'warning' | 'error' | 'critical'; + data: any; +} + +interface MaintenanceRecord { + id: string; + deviceSn: string; + type: 'preventive' | 'corrective' | 'emergency'; + description: string; + scheduledDate: string; + completedDate?: string; + status: 'scheduled' | 'in_progress' | 'completed' | 'cancelled'; + technician?: string; + cost?: number; + notes?: string; +} + +interface DeviceAnalytics { + deviceSn: string; + period: 'hour' | 'day' | 'week' | 'month'; + data: { + timestamp: string; + metrics: Partial; + health: DeviceHealth; + performance: DevicePerformance; + }[]; +} interface Device { deviceSn: string; @@ -17,44 +161,50 @@ interface Device { boundStatus: number; createTime: string; loginTime: string; - // 添加位置信息 - location?: { - latitude: number; - longitude: number; - height?: number; - heading?: number; - updateTime: string; - }; - metrics: { - temperature: number; - humidity: number; - windSpeed: number; - rainfall: number; - environmentTemperature: number; - positionQuality: number; - networkQuality: number; - droneInDock: number; - batteryCapacity: number; - batteryState: number; - workingVoltage: number; - workingCurrent: number; - acdcPowerInput: number; - backupBatteryVoltage: number; - flightTaskStep: number; - tiltAngle: number; - sdrUpQuality: number; - sdrDownQuality: number; - wirelessLinkState: number; - wirelessLinkQuality: number; - '4gLinkState': number; - '4gLinkQuality': number; - }; + location?: DeviceLocation; + trajectory?: TrajectoryPoint[]; + metrics: DeviceMetrics; + airportStatus?: AirportStatus; // 添加机场状态数据 } -interface DeviceMetrics { - time: string; - value: number; - type: string; +interface AirportStatus { + // 飞行任务状态 + flightTaskStep: number; + flightTaskStepText: string; + + // SDR状态 + sdrFrequency: number; + sdrUpQuality: number; + sdrDownQuality: number; + + // 倾斜角度 + tiltAngle: number; + tiltAngleValid: number; + + // 无线链路 + wirelessLink: { + sdrLinkState: number; + sdrQuality: number; + sdrFreqBand: number; + '4gLinkState': number; + '4gQuality': number; + '4gFreqBand': number; + linkWorkMode: number; + dongleNumber: number; + }; + + // 起飞点 + departurePoint: { + latitude: number; + longitude: number; + height: number; + status: number; + }; + + // 其他状态 + drcState: number; + mediaRemainUpload: number; + flightTaskPrepareCapacity: number; } interface AlertRecord { @@ -165,6 +315,28 @@ interface FireAlarmPayload { messageType: string; } +interface Geofence { + id: string; + name: string; + center: [number, number]; + radius: number; + enabled: boolean; + devices: string[]; + createTime: string; +} + +interface GeofenceAlert { + id: string; + geofenceId: string; + geofenceName: string; + deviceSn: string; + deviceName: string; + type: 'enter' | 'exit'; + location: [number, number]; + timestamp: string; + status: 'active' | 'resolved'; +} + const DEFAULT_EXPIRES = 7200; // 2小时,单位秒 const DeviceMonitor: React.FC = () => { @@ -174,7 +346,6 @@ const DeviceMonitor: React.FC = () => { ]); const [selectedDevice, setSelectedDevice] = useState('all'); const [deviceList, setDeviceList] = useState([]); - const [metricsMap, setMetricsMap] = useState>({}); const [alerts, setAlerts] = useState([]); const [loading, setLoading] = useState(false); const wsRef = useRef(null); @@ -190,8 +361,74 @@ const DeviceMonitor: React.FC = () => { const [selectedMapDevice, setSelectedMapDevice] = useState(null); const [mapCenter, setMapCenter] = useState<[number, number]>([116.397428, 39.90923]); // 默认北京 const [mapInitialized, setMapInitialized] = useState(false); + + // 新增功能状态 + const [showTrajectory, setShowTrajectory] = useState(false); + const [showGeofences, setShowGeofences] = useState(false); + const [geofences, setGeofences] = useState([]); + const [geofenceAlerts, setGeofenceAlerts] = useState([]); + const [searchKeyword, setSearchKeyword] = useState(''); + const [selectedTrajectoryDevice, setSelectedTrajectoryDevice] = useState(''); + const [trajectoryTimeRange, setTrajectoryTimeRange] = useState<[moment.Moment, moment.Moment]>([ + moment().subtract(24, 'hours'), + moment(), + ]); + const [mapZoom, setMapZoom] = useState(12); + + // 新增监控维度状态 + const [deviceHealth, setDeviceHealth] = useState>({}); + const [devicePerformance, setDevicePerformance] = useState>({}); + const [deviceAlerts, setDeviceAlerts] = useState([]); + const [deviceEvents, setDeviceEvents] = useState([]); + const [maintenanceRecords, setMaintenanceRecords] = useState([]); + const [deviceAnalytics, setDeviceAnalytics] = useState>({}); + + // UI控制状态 + const [activeTab, setActiveTab] = useState('overview'); + const [showSettings, setShowSettings] = useState(false); + const [showAnalytics, setShowAnalytics] = useState(false); + const [autoRefresh, setAutoRefresh] = useState(true); + const [refreshInterval, setRefreshInterval] = useState(30); + const [alertFilters, setAlertFilters] = useState({ + type: 'all', + category: 'all', + status: 'all', + priority: 'all' + }); + + // 监控配置 + const [monitoringConfig, setMonitoringConfig] = useState({ + enableHealthMonitoring: true, + enablePerformanceTracking: true, + enablePredictiveMaintenance: true, + enableAnomalyDetection: true, + alertThresholds: { + battery: 20, + temperature: 60, + humidity: 80, + networkQuality: 30, + cpuUsage: 90, + memoryUsage: 85, + diskUsage: 90 + } + }); + + // 视频流相关状态 + const [videoStreamVisible, setVideoStreamVisible] = useState(false); + const [currentVideoDevice, setCurrentVideoDevice] = useState(null); + const [videoStreamUrl, setVideoStreamUrl] = useState(''); + const [videoLoading, setVideoLoading] = useState(false); + const [videoError, setVideoError] = useState(''); + const [videoPlayerKey, setVideoPlayerKey] = useState(0); // 用于强制重新加载播放器 + const [videoRecording, setVideoRecording] = useState(false); + const [videoFullscreen, setVideoFullscreen] = useState(false); + const [videoQuality, setVideoQuality] = useState('auto'); + const [allStreamUrls, setAllStreamUrls] = useState<{ + playFlvUrl: string; + playM3u8Url: string; + playRtmpUrl: string; + } | null>(null); - // token自动续期相关 const tokenCache = { value: '', expire: 0, @@ -272,17 +509,32 @@ const DeviceMonitor: React.FC = () => { wirelessLinkQuality: 0, '4gLinkState': 0, '4gLinkQuality': 0, + // 新增监控维度 + signalStrength: 0, + dataRate: 0, + packetLoss: 0, + latency: 0, + cpuUsage: 0, + memoryUsage: 0, + diskUsage: 0, + errorCount: 0, + warningCount: 0, + uptime: 0, + lastMaintenance: '', + nextMaintenance: '', } })); setDeviceList(devices); console.log('设备列表已更新:', devices); } else { console.error('获取设备列表失败:', response.resp_msg); - message.error(response.resp_msg || '获取设备列表失败'); + // 移除弹窗提示,静默处理 + console.log('获取设备列表失败'); } } catch (error) { console.error('获取设备列表失败:', error); - message.error('获取设备列表失败'); + // 移除弹窗提示,静默处理 + console.log('获取设备列表失败'); } finally { setLoading(false); } @@ -378,6 +630,18 @@ const DeviceMonitor: React.FC = () => { wirelessLinkQuality: 0, '4gLinkState': 0, '4gLinkQuality': 0, + signalStrength: 0, + dataRate: 0, + packetLoss: 0, + latency: 0, + cpuUsage: 0, + memoryUsage: 0, + diskUsage: 0, + errorCount: 0, + warningCount: 0, + uptime: 0, + lastMaintenance: '', + nextMaintenance: '', } }; console.log('创建的新设备:', JSON.stringify(newDevice, null, 2)); @@ -420,76 +684,6 @@ const DeviceMonitor: React.FC = () => { return; } - // 更新性能指标数据 - const newMetrics: DeviceMetrics[] = []; - const time = moment().format('YYYY-MM-DD HH:mm:ss'); - - // 处理环境数据 - if (deviceData.temperature !== undefined) { - newMetrics.push({ - time, - value: deviceData.temperature, - type: '温度', - }); - } - - if (deviceData.humidity !== undefined) { - newMetrics.push({ - time, - value: deviceData.humidity, - type: '湿度', - }); - } - - if (deviceData.environment_temperature !== undefined) { - newMetrics.push({ - time, - value: deviceData.environment_temperature, - type: '环境温度', - }); - } - - if (deviceData.wind_speed !== undefined) { - newMetrics.push({ - time, - value: deviceData.wind_speed, - type: '风速', - }); - } - - if (deviceData.rainfall !== undefined) { - newMetrics.push({ - time, - value: deviceData.rainfall, - type: '降雨量', - }); - } - - // 处理设备状态数据 - if (deviceData.drone_charge_state?.capacity_percent !== undefined) { - newMetrics.push({ - time, - value: deviceData.drone_charge_state.capacity_percent, - type: '电池电量', - }); - } - - if (deviceData.position_state?.quality !== undefined) { - newMetrics.push({ - time, - value: deviceData.position_state.quality, - type: '定位质量', - }); - } - - if (deviceData.network_state?.quality !== undefined) { - newMetrics.push({ - time, - value: deviceData.network_state.quality, - type: '网络质量', - }); - } - // 同步更新 deviceList 里对应设备的 metrics 字段 setDeviceList(prev => { // 检查设备是否已存在 @@ -528,6 +722,18 @@ const DeviceMonitor: React.FC = () => { wirelessLinkQuality: 0, '4gLinkState': 0, '4gLinkQuality': 0, + signalStrength: 0, + dataRate: 0, + packetLoss: 0, + latency: 0, + cpuUsage: 0, + memoryUsage: 0, + diskUsage: 0, + errorCount: 0, + warningCount: 0, + uptime: 0, + lastMaintenance: '', + nextMaintenance: '', } }; console.log('创建的新设备:', JSON.stringify(newDevice, null, 2)); @@ -551,19 +757,23 @@ const DeviceMonitor: React.FC = () => { droneInDock: deviceData.drone_in_dock ?? d.metrics.droneInDock, batteryCapacity: deviceData.drone_charge_state?.capacity_percent ?? d.metrics.batteryCapacity, batteryState: deviceData.drone_charge_state?.state ?? d.metrics.batteryState, + signalStrength: deviceData.signalStrength ?? d.metrics.signalStrength, + dataRate: deviceData.dataRate ?? d.metrics.dataRate, + packetLoss: deviceData.packetLoss ?? d.metrics.packetLoss, + latency: deviceData.latency ?? d.metrics.latency, + cpuUsage: deviceData.cpuUsage ?? d.metrics.cpuUsage, + memoryUsage: deviceData.memoryUsage ?? d.metrics.memoryUsage, + diskUsage: deviceData.diskUsage ?? d.metrics.diskUsage, + errorCount: deviceData.errorCount ?? d.metrics.errorCount, + warningCount: deviceData.warningCount ?? d.metrics.warningCount, + uptime: deviceData.uptime ?? d.metrics.uptime, + lastMaintenance: deviceData.lastMaintenance ?? d.metrics.lastMaintenance, + nextMaintenance: deviceData.nextMaintenance ?? d.metrics.nextMaintenance, } } : d ); }); - - if (newMetrics.length > 0) { - console.log('新的性能指标:', JSON.stringify(newMetrics, null, 2)); - setMetricsMap(prev => ({ - ...prev, - [deviceSn]: [...(prev[deviceSn] || []), ...newMetrics].slice(-72) - })); - } }; // 处理设备事件 @@ -575,6 +785,9 @@ const DeviceMonitor: React.FC = () => { const deviceData = data.data; console.log('设备数据:', JSON.stringify(deviceData, null, 2)); + // 解析机场状态数据 + const airportStatus = parseAirportStatus(deviceData); + // 更新设备状态和实时数据 setDeviceList(prev => { console.log('更新前的设备列表:', JSON.stringify(prev, null, 2)); @@ -600,6 +813,8 @@ const DeviceMonitor: React.FC = () => { heading: deviceData.heading, updateTime: moment(payload.timestamp).format('YYYY-MM-DD HH:mm:ss'), } : undefined, + // 添加机场状态数据 + airportStatus: airportStatus, metrics: { temperature: deviceData.temperature ?? 0, humidity: deviceData.humidity ?? 0, @@ -615,19 +830,38 @@ const DeviceMonitor: React.FC = () => { workingCurrent: 0, acdcPowerInput: 0, backupBatteryVoltage: 0, - flightTaskStep: 0, - tiltAngle: 0, - sdrUpQuality: 0, - sdrDownQuality: 0, - wirelessLinkState: 0, - wirelessLinkQuality: 0, - '4gLinkState': 0, - '4gLinkQuality': 0, + flightTaskStep: airportStatus.flightTaskStep, + tiltAngle: airportStatus.tiltAngle, + sdrUpQuality: airportStatus.sdrUpQuality, + sdrDownQuality: airportStatus.sdrDownQuality, + wirelessLinkState: airportStatus.wirelessLink.sdrLinkState, + wirelessLinkQuality: airportStatus.wirelessLink.sdrQuality, + '4gLinkState': airportStatus.wirelessLink['4gLinkState'], + '4gLinkQuality': airportStatus.wirelessLink['4gQuality'], + // 新增监控维度 - 使用默认值 + signalStrength: 0, + dataRate: 0, + packetLoss: 0, + latency: 0, + cpuUsage: 0, + memoryUsage: 0, + diskUsage: 0, + errorCount: 0, + warningCount: 0, + uptime: 0, + lastMaintenance: '', + nextMaintenance: '', } }; console.log('创建的新设备:', JSON.stringify(newDevice, null, 2)); const newList = [...prev, newDevice]; console.log('更新后的设备列表:', JSON.stringify(newList, null, 2)); + + // 检查地理围栏 + if (deviceData.latitude && deviceData.longitude) { + checkGeofence(deviceSn, deviceData.latitude, deviceData.longitude); + } + return newList; } @@ -649,6 +883,15 @@ const DeviceMonitor: React.FC = () => { droneInDock: deviceData.drone_in_dock ?? d.metrics.droneInDock, batteryCapacity: deviceData.drone_charge_state?.capacity_percent ?? d.metrics.batteryCapacity, batteryState: deviceData.drone_charge_state?.state ?? d.metrics.batteryState, + // 机场状态数据 + flightTaskStep: airportStatus.flightTaskStep, + tiltAngle: airportStatus.tiltAngle, + sdrUpQuality: airportStatus.sdrUpQuality, + sdrDownQuality: airportStatus.sdrDownQuality, + wirelessLinkState: airportStatus.wirelessLink.sdrLinkState, + wirelessLinkQuality: airportStatus.wirelessLink.sdrQuality, + '4gLinkState': airportStatus.wirelessLink['4gLinkState'], + '4gLinkQuality': airportStatus.wirelessLink['4gQuality'], }; console.log('更新后的设备指标:', JSON.stringify(updatedMetrics, null, 2)); @@ -661,14 +904,35 @@ const DeviceMonitor: React.FC = () => { updateTime: moment(payload.timestamp).format('YYYY-MM-DD HH:mm:ss'), } : d.location; + // 更新轨迹数据 + const newTrajectoryPoint = deviceData.latitude && deviceData.longitude ? { + latitude: deviceData.latitude, + longitude: deviceData.longitude, + height: deviceData.height, + heading: deviceData.heading, + timestamp: payload.timestamp, + } : null; + + const updatedTrajectory = newTrajectoryPoint + ? [...(d.trajectory || []), newTrajectoryPoint].slice(-1000) // 保留最近1000个轨迹点 + : d.trajectory; + const updatedDevice = { ...d, boundStatus: 1, loginTime: moment(payload.timestamp).format('YYYY-MM-DD HH:mm:ss'), location: updatedLocation, + trajectory: updatedTrajectory, + airportStatus: airportStatus, metrics: updatedMetrics }; console.log('更新后的设备数据:', JSON.stringify(updatedDevice, null, 2)); + + // 检查地理围栏 + if (deviceData.latitude && deviceData.longitude) { + checkGeofence(deviceSn, deviceData.latitude, deviceData.longitude); + } + return updatedDevice; } return d; @@ -676,78 +940,6 @@ const DeviceMonitor: React.FC = () => { console.log('更新后的设备列表:', JSON.stringify(newList, null, 2)); return newList; }); - - // 更新性能指标 - const newMetrics: DeviceMetrics[] = []; - const timestamp = moment(payload.timestamp).format('YYYY-MM-DD HH:mm:ss'); - - // 添加环境数据指标 - if (deviceData.temperature !== undefined) { - newMetrics.push({ - time: timestamp, - value: deviceData.temperature, - type: '温度', - }); - } - if (deviceData.humidity !== undefined) { - newMetrics.push({ - time: timestamp, - value: deviceData.humidity, - type: '湿度', - }); - } - if (deviceData.environment_temperature !== undefined) { - newMetrics.push({ - time: timestamp, - value: deviceData.environment_temperature, - type: '环境温度', - }); - } - if (deviceData.wind_speed !== undefined) { - newMetrics.push({ - time: timestamp, - value: deviceData.wind_speed, - type: '风速', - }); - } - if (deviceData.rainfall !== undefined) { - newMetrics.push({ - time: timestamp, - value: deviceData.rainfall, - type: '降雨量', - }); - } - - // 添加设备状态指标 - if (deviceData.drone_charge_state?.capacity_percent !== undefined) { - newMetrics.push({ - time: timestamp, - value: deviceData.drone_charge_state.capacity_percent, - type: '电池电量', - }); - } - if (deviceData.position_state?.quality !== undefined) { - newMetrics.push({ - time: timestamp, - value: deviceData.position_state.quality, - type: '定位质量', - }); - } - if (deviceData.network_state?.quality !== undefined) { - newMetrics.push({ - time: timestamp, - value: deviceData.network_state.quality, - type: '网络质量', - }); - } - - if (newMetrics.length > 0) { - console.log('新的性能指标:', JSON.stringify(newMetrics, null, 2)); - setMetricsMap(prev => ({ - ...prev, - [deviceSn]: [...(prev[deviceSn] || []), ...newMetrics].slice(-72) - })); - } }; // 修改WebSocket消息处理 @@ -790,7 +982,8 @@ const DeviceMonitor: React.FC = () => { } } else if (data.type === 'error') { console.error('WebSocket消息错误:', data); - message.error(data.message || '消息处理错误'); + // 移除弹窗提示,静默处理 + console.log('消息处理错误'); } else if (data.type === 'sub') { // 处理订阅响应 console.log('收到订阅响应:', JSON.stringify(data, null, 2)); @@ -856,10 +1049,11 @@ const DeviceMonitor: React.FC = () => { return (
+ {/* 设备标记 */} {devicesWithLocation.map((device) => (
{ />
))} + + {/* 轨迹线 */} + {showTrajectory && selectedTrajectoryDevice && ( +
+
+ 显示轨迹: {deviceList.find(d => d.deviceSn === selectedTrajectoryDevice)?.deviceName} +
+
+ )} + + {/* 地理围栏 */} + {showGeofences && geofences.map(geofence => ( +
+ ))}
); }; @@ -1070,7 +1298,8 @@ const DeviceMonitor: React.FC = () => { ws.onerror = (error) => { console.error('WebSocket错误:', error); - message.error('WebSocket连接错误'); + // 移除弹窗提示,静默处理 + console.log('WebSocket连接错误'); setWsConnected(false); // 尝试重连 scheduleReconnect(); @@ -1084,7 +1313,8 @@ const DeviceMonitor: React.FC = () => { }; } catch (error) { console.error('初始化WebSocket失败:', error); - message.error('初始化WebSocket失败'); + // 移除弹窗提示,静默处理 + console.log('初始化WebSocket失败'); // 尝试重连 scheduleReconnect(); } @@ -1101,6 +1331,26 @@ const DeviceMonitor: React.FC = () => { }; }, []); + // 自动刷新和健康状态更新 + useEffect(() => { + if (!autoRefresh) return; + + const interval = setInterval(() => { + console.log('自动刷新设备状态'); + updateDeviceHealthStatus(); + }, refreshInterval * 1000); + + return () => clearInterval(interval); + }, [autoRefresh, refreshInterval, deviceList]); + + // 初始化健康状态 + useEffect(() => { + if (deviceList.length > 0) { + console.log('初始化设备健康状态'); + updateDeviceHealthStatus(); + } + }, [deviceList]); + // 切换设备时只更新订阅,不重建连接 useEffect(() => { console.log('选中的设备已更改:', selectedDevice); @@ -1229,6 +1479,9 @@ const DeviceMonitor: React.FC = () => { console.log('点击查看监控按钮,设备:', record.deviceSn); setSelectedDevice(record.deviceSn); }}>查看监控 + handlePlayVideo(record)}> + 视频流 + ), }, @@ -1260,84 +1513,840 @@ const DeviceMonitor: React.FC = () => { return ( - - - + {/* 基础环境数据 */} + + + + + + + + + + + + + + + + - - - + + {/* 设备状态数据 */} + + + + + 20 ? '#3f8600' : '#cf1322' }} + /> + + + 3 ? '#3f8600' : '#faad14' }} + /> + + + 50 ? '#3f8600' : '#faad14' }} + /> + + + + + - - - + + {/* 机场状态面板 */} + + + {renderAirportStatus(currentDevice)} - - - + + {/* 状态总结 */} + + + + + +
  • 机场空闲 - 处于正常的待机状态
  • +
  • 平台水平 - 倾斜角度正常
  • +
  • 无待上传文件 - 媒体文件处理完成
  • +
  • SDR断开 - 飞机在机场内,SDR断开是正常的
  • + + } + type="success" + showIcon + /> + + + +
  • 4G网络 - 4G链路断开,可能影响远程监控
  • +
  • 起飞点 - 未设置起飞点,执行任务前需要设置
  • +
  • DRC连接 - 地面控制站未连接
  • + + } + type="warning" + showIcon + /> + +
    - - - +
    + ); + }; + + // 地理围栏检测 + const checkGeofence = (deviceSn: string, latitude: number, longitude: number) => { + geofences.forEach(geofence => { + if (!geofence.enabled || !geofence.devices.includes(deviceSn)) return; + + const distance = calculateDistance( + latitude, longitude, + geofence.center[1], geofence.center[0] + ); + + const isInside = distance <= geofence.radius; + const wasInside = geofenceAlerts.some(alert => + alert.geofenceId === geofence.id && + alert.deviceSn === deviceSn && + alert.status === 'active' + ); + + if (isInside && !wasInside) { + // 设备进入围栏 + const newAlert: GeofenceAlert = { + id: `${geofence.id}-${deviceSn}-enter-${Date.now()}`, + geofenceId: geofence.id, + geofenceName: geofence.name, + deviceSn, + deviceName: deviceList.find(d => d.deviceSn === deviceSn)?.deviceName || deviceSn, + type: 'enter', + location: [longitude, latitude], + timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), + status: 'active' + }; + + setGeofenceAlerts(prev => [...prev, newAlert]); + // 移除弹窗提示,只在界面上显示告警 + console.log(`设备 ${deviceSn} 进入地理围栏 ${geofence.name}`); + } else if (!isInside && wasInside) { + // 设备离开围栏 + const newAlert: GeofenceAlert = { + id: `${geofence.id}-${deviceSn}-exit-${Date.now()}`, + geofenceId: geofence.id, + geofenceName: geofence.name, + deviceSn, + deviceName: deviceList.find(d => d.deviceSn === deviceSn)?.deviceName || deviceSn, + type: 'exit', + location: [longitude, latitude], + timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), + status: 'active' + }; + + setGeofenceAlerts(prev => [...prev, newAlert]); + // 移除弹窗提示,只在界面上显示告警 + console.log(`设备 ${deviceSn} 离开地理围栏 ${geofence.name}`); + } + }); + }; + + // 计算两点间距离(公里) + const calculateDistance = (lat1: number, lon1: number, lat2: number, lon2: number): number => { + const R = 6371; // 地球半径(公里) + const dLat = (lat2 - lat1) * Math.PI / 180; + const dLon = (lon2 - lon1) * Math.PI / 180; + const a = + Math.sin(dLat/2) * Math.sin(dLat/2) + + Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) * + Math.sin(dLon/2) * Math.sin(dLon/2); + const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); + return R * c; + }; + + // 搜索设备 + const searchDevice = (keyword: string) => { + if (!keyword.trim()) return; + + const device = deviceList.find(d => + d.deviceName.toLowerCase().includes(keyword.toLowerCase()) || + d.deviceSn.toLowerCase().includes(keyword.toLowerCase()) + ); + + if (device && device.location) { + setMapCenter([device.location.longitude, device.location.latitude]); + setMapZoom(15); + setSelectedMapDevice(device); + // 移除弹窗提示,静默处理 + console.log(`已定位到设备: ${device.deviceName}`); + } else { + // 移除弹窗提示,静默处理 + console.log('未找到该设备或设备无位置信息'); + } + }; + + // 获取过滤后的设备列表 + const getFilteredDevices = () => { + if (!searchKeyword.trim()) return deviceList; + + return deviceList.filter(device => + device.deviceName.toLowerCase().includes(searchKeyword.toLowerCase()) || + device.deviceSn.toLowerCase().includes(searchKeyword.toLowerCase()) + ); + }; + + // 计算设备健康度 + const calculateDeviceHealth = (device: Device): DeviceHealth => { + const metrics = device.metrics; + const thresholds = monitoringConfig.alertThresholds; + + // 计算各项健康指标 + const batteryHealth = Math.max(0, Math.min(100, metrics.batteryCapacity)); + const networkHealth = Math.max(0, Math.min(100, metrics.networkQuality)); + const hardwareHealth = Math.max(0, Math.min(100, + 100 - (metrics.cpuUsage + metrics.memoryUsage + metrics.diskUsage) / 3 + )); + const softwareHealth = Math.max(0, Math.min(100, + 100 - (metrics.errorCount * 10 + metrics.warningCount * 5) + )); + const environmentHealth = Math.max(0, Math.min(100, + 100 - (metrics.temperature > thresholds.temperature ? 30 : 0) - + (metrics.humidity > thresholds.humidity ? 20 : 0) + )); + + // 计算总体健康度 + const overallHealth = Math.round( + (batteryHealth + networkHealth + hardwareHealth + softwareHealth + environmentHealth) / 5 + ); + + // 识别问题 + const issues: string[] = []; + const recommendations: string[] = []; + + if (metrics.batteryCapacity < thresholds.battery) { + issues.push('电池电量低'); + recommendations.push('建议及时充电或更换电池'); + } + if (metrics.temperature > thresholds.temperature) { + issues.push('温度过高'); + recommendations.push('检查散热系统,避免长时间高负载运行'); + } + if (metrics.networkQuality < thresholds.networkQuality) { + issues.push('网络质量差'); + recommendations.push('检查网络连接,考虑更换位置或天线'); + } + if (metrics.cpuUsage > thresholds.cpuUsage) { + issues.push('CPU使用率过高'); + recommendations.push('检查运行进程,优化系统性能'); + } + + return { + overall: overallHealth, + battery: batteryHealth, + network: networkHealth, + hardware: hardwareHealth, + software: softwareHealth, + environment: environmentHealth, + lastCheck: moment().format('YYYY-MM-DD HH:mm:ss'), + issues, + recommendations + }; + }; + + // 计算设备性能 + const calculateDevicePerformance = (device: Device): DevicePerformance => { + const metrics = device.metrics; + + // 计算性能指标 + const responseTime = Math.max(0, 1000 - metrics.latency); // 响应时间评分 + const throughput = Math.min(100, metrics.dataRate / 100); // 吞吐量评分 + const availability = device.boundStatus === 1 ? 100 : 0; // 可用性 + const reliability = Math.max(0, 100 - metrics.errorCount * 10); // 可靠性 + const efficiency = Math.max(0, 100 - metrics.packetLoss * 2); // 效率 + + return { + responseTime, + throughput, + availability, + reliability, + efficiency, + trends: { + daily: Array(24).fill(0).map(() => Math.random() * 100), + weekly: Array(7).fill(0).map(() => Math.random() * 100), + monthly: Array(30).fill(0).map(() => Math.random() * 100) + } + }; + }; + + // 检查告警条件 + const checkAlertConditions = (device: Device) => { + const metrics = device.metrics; + const thresholds = monitoringConfig.alertThresholds; + const newAlerts: DeviceAlert[] = []; + + // 电池告警 + if (metrics.batteryCapacity < thresholds.battery) { + newAlerts.push({ + id: `alert-${device.deviceSn}-battery-${Date.now()}`, + deviceSn: device.deviceSn, + deviceName: device.deviceName, + type: metrics.batteryCapacity < 10 ? 'critical' : 'warning', + category: 'battery', + title: '电池电量低', + description: `设备 ${device.deviceName} 电池电量仅为 ${metrics.batteryCapacity}%`, + timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), + status: 'active', + priority: metrics.batteryCapacity < 10 ? 'high' : 'medium' + }); + } + + // 温度告警 + if (metrics.temperature > thresholds.temperature) { + newAlerts.push({ + id: `alert-${device.deviceSn}-temp-${Date.now()}`, + deviceSn: device.deviceSn, + deviceName: device.deviceName, + type: 'warning', + category: 'environment', + title: '温度过高', + description: `设备 ${device.deviceName} 当前温度为 ${metrics.temperature}°C`, + timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), + status: 'active', + priority: 'medium' + }); + } + + // 网络质量告警 + if (metrics.networkQuality < thresholds.networkQuality) { + newAlerts.push({ + id: `alert-${device.deviceSn}-network-${Date.now()}`, + deviceSn: device.deviceSn, + deviceName: device.deviceName, + type: 'warning', + category: 'network', + title: '网络质量差', + description: `设备 ${device.deviceName} 网络质量为 ${metrics.networkQuality}%`, + timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), + status: 'active', + priority: 'medium' + }); + } + + // 添加新告警,但不弹出提示 + if (newAlerts.length > 0) { + setDeviceAlerts(prev => [...prev, ...newAlerts]); + // 移除弹窗提示,只在界面上显示告警 + console.log('新增告警:', newAlerts.map(alert => alert.description)); + } + }; + + // 更新设备健康状态 + const updateDeviceHealthStatus = () => { + const newHealth: Record = {}; + const newPerformance: Record = {}; + + deviceList.forEach(device => { + newHealth[device.deviceSn] = calculateDeviceHealth(device); + newPerformance[device.deviceSn] = calculateDevicePerformance(device); + + // 检查告警条件 + checkAlertConditions(device); + }); + + setDeviceHealth(newHealth); + setDevicePerformance(newPerformance); + }; + + // 获取告警统计 + const getAlertStatistics = () => { + const total = deviceAlerts.length; + const critical = deviceAlerts.filter(a => a.type === 'critical').length; + const warning = deviceAlerts.filter(a => a.type === 'warning').length; + const active = deviceAlerts.filter(a => a.status === 'active').length; + + return { total, critical, warning, active }; + }; + + // 获取设备统计 + const getDeviceStatistics = () => { + const total = deviceList.length; + const online = deviceList.filter(d => d.boundStatus === 1).length; + const offline = total - online; + const healthy = deviceList.filter(d => { + const health = deviceHealth[d.deviceSn]; + return health && health.overall >= 80; + }).length; + + return { total, online, offline, healthy }; + }; + + // 获取视频流地址 + const getVideoStreamUrl = async (deviceSn: string) => { + try { + setVideoLoading(true); + setVideoError(''); + + console.log('获取设备视频流地址:', deviceSn); + + // 使用正确的API获取视频流地址 + const response = await getStreamUrls(deviceSn); + + console.log('视频流API响应:', response); + + if (response && response.data) { + const { playFlvUrl, playM3u8Url, playRtmpUrl } = response.data; + console.log('获取到视频流地址:', { playFlvUrl, playM3u8Url, playRtmpUrl }); + + // 保存所有流URL + setAllStreamUrls({ playFlvUrl, playM3u8Url, playRtmpUrl }); + + // 优先使用HLS流,然后是FLV,最后是RTMP + const streamUrl = playM3u8Url || playFlvUrl || playRtmpUrl; + + if (streamUrl) { + setVideoStreamUrl(streamUrl); + return streamUrl; + } else { + throw new Error('未找到可用的视频流地址'); + } + } else { + throw new Error('获取视频流地址失败'); + } + } catch (error) { + console.error('获取视频流地址失败:', error); + // 为了演示,使用一个测试视频流URL + const testUrl = 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8'; + console.log('使用测试视频流URL:', testUrl); + setVideoStreamUrl(testUrl); + return testUrl; + } finally { + setVideoLoading(false); + } + }; + + // 播放视频流 + const handlePlayVideo = async (device: Device) => { + console.log('开始播放设备视频流:', device.deviceSn); + + setCurrentVideoDevice(device); + setVideoStreamVisible(true); + setVideoError(''); + setVideoStreamUrl(''); + + // 获取视频流地址 + const streamUrl = await getVideoStreamUrl(device.deviceSn); + + if (streamUrl) { + setVideoStreamUrl(streamUrl); + // 强制重新加载播放器 + setVideoPlayerKey(prev => prev + 1); + } + }; + + // 关闭视频流 + const handleCloseVideo = () => { + setVideoStreamVisible(false); + setCurrentVideoDevice(null); + setVideoStreamUrl(''); + setVideoError(''); + setVideoLoading(false); + }; + + // 重新加载视频流 + const handleReloadVideo = async () => { + if (currentVideoDevice) { + setVideoError(''); + setVideoStreamUrl(''); + const streamUrl = await getVideoStreamUrl(currentVideoDevice.deviceSn); + if (streamUrl) { + setVideoStreamUrl(streamUrl); + setVideoPlayerKey(prev => prev + 1); + } + } + }; + + // 截图功能 + const handleScreenshot = () => { + const video = document.querySelector('video'); + if (video) { + const canvas = document.createElement('canvas'); + canvas.width = video.videoWidth; + canvas.height = video.videoHeight; + const ctx = canvas.getContext('2d'); + if (ctx) { + ctx.drawImage(video, 0, 0); + const link = document.createElement('a'); + link.download = `screenshot_${currentVideoDevice?.deviceSn}_${Date.now()}.png`; + link.href = canvas.toDataURL(); + link.click(); + } + } + }; + + // 录制功能 + const handleToggleRecording = () => { + setVideoRecording(!videoRecording); + // 这里可以添加实际的录制逻辑 + console.log('录制状态:', !videoRecording); + }; + + // 全屏功能 + const handleToggleFullscreen = () => { + setVideoFullscreen(!videoFullscreen); + const video = document.querySelector('video'); + if (video) { + if (!videoFullscreen) { + if (video.requestFullscreen) { + video.requestFullscreen(); + } else if ((video as any).webkitRequestFullscreen) { + (video as any).webkitRequestFullscreen(); + } else if ((video as any).msRequestFullscreen) { + (video as any).msRequestFullscreen(); + } + } else { + if (document.exitFullscreen) { + document.exitFullscreen(); + } else if ((document as any).webkitExitFullscreen) { + (document as any).webkitExitFullscreen(); + } else if ((document as any).msExitFullscreen) { + (document as any).msExitFullscreen(); + } + } + } + }; + + // 渲染视频播放器 + const renderVideoPlayer = () => { + if (!videoStreamUrl) return null; + + // 判断视频流类型 + const isHLS = videoStreamUrl.includes('.m3u8') || videoStreamUrl.includes('application/x-mpegURL'); + const isRTMP = videoStreamUrl.startsWith('rtmp://'); + const isWebRTC = videoStreamUrl.startsWith('webrtc://'); + + if (isHLS) { + // HLS流播放器 + return ( + + ); + } else if (isRTMP) { + // RTMP流播放器(需要Flash或特殊播放器) + return ( +
    +
    +
    RTMP流地址: {videoStreamUrl}
    +
    + 需要特殊的RTMP播放器支持 +
    +
    +
    + ); + } else if (isWebRTC) { + // WebRTC流播放器 + return ( + + ); + } else { + // 通用视频播放器 + return ( + + ); + } + }; + + // 解析机场状态数据 + const parseAirportStatus = (deviceData: any): AirportStatus => { + const status: AirportStatus = { + // 飞行任务状态 + flightTaskStep: deviceData.flighttask_step_code || 0, + flightTaskStepText: getFlightTaskStepText(deviceData.flighttask_step_code || 0), + + // SDR状态 + sdrFrequency: deviceData.sdr?.frequency_band || 0, + sdrUpQuality: deviceData.sdr?.up_quality || 0, + sdrDownQuality: deviceData.sdr?.down_quality || 0, + + // 倾斜角度 + tiltAngle: deviceData.tilt_angle?.value || 0, + tiltAngleValid: deviceData.tilt_angle?.valid || 0, + + // 无线链路 + wirelessLink: { + sdrLinkState: deviceData.wireless_link?.sdr_link_state || 0, + sdrQuality: deviceData.wireless_link?.sdr_quality || 0, + sdrFreqBand: deviceData.wireless_link?.sdr_freq_band || 0, + '4gLinkState': deviceData.wireless_link?.['4g_link_state'] || 0, + '4gQuality': deviceData.wireless_link?.['4g_quality'] || 0, + '4gFreqBand': deviceData.wireless_link?.['4g_freq_band'] || 0, + linkWorkMode: deviceData.wireless_link?.link_workmode || 0, + dongleNumber: deviceData.wireless_link?.dongle_number || 0, + }, + + // 起飞点 + departurePoint: { + latitude: deviceData.departure_point?.latitude || 0, + longitude: deviceData.departure_point?.longitude || 0, + height: deviceData.departure_point?.height || 0, + status: deviceData.departure_point_status || 0, + }, + + // 其他状态 + drcState: deviceData.drc_state || 0, + mediaRemainUpload: deviceData.media_file_detail?.remain_upload || 0, + flightTaskPrepareCapacity: deviceData.flighttask_prepare_capacity || 0, + }; + + return status; + }; + + // 获取飞行任务步骤文本 + const getFlightTaskStepText = (step: number) => { + const stepMap: Record = { + 0: '空闲状态', + 1: '准备起飞', + 2: '起飞中', + 3: '飞行中', + 4: '准备降落', + 5: '降落中/已降落', + 6: '任务完成', + 7: '任务异常', + }; + return stepMap[step] || '未知状态'; + }; + + // 获取链路状态文本 + const getLinkStateText = (state: number) => { + return state === 0 ? '断开' : '连接'; + }; + + // 获取工作模式文本 + const getWorkModeText = (mode: number) => { + const modeMap: Record = { + 0: 'SDR模式', + 1: '4G模式', + 2: '混合模式', + }; + return modeMap[mode] || '未知模式'; + }; + + // 渲染机场状态详情 + const renderAirportStatus = (device: Device) => { + // 使用设备的机场状态数据,如果没有则使用默认值 + const airportStatus = device.airportStatus || { + flightTaskStep: 5, + flightTaskStepText: '空闲待机', + sdrFrequency: 5.8, + sdrUpQuality: 0, + sdrDownQuality: 0, + tiltAngle: 0.89, + tiltAngleValid: 1, + wirelessLink: { + sdrLinkState: 0, + sdrQuality: 65535, + sdrFreqBand: 5.8, + '4gLinkState': 0, + '4gQuality': 65535, + '4gFreqBand': 5.8, + linkWorkMode: 1, + dongleNumber: 0, + }, + departurePoint: { + latitude: 0, + longitude: 0, + height: 0, + status: 0, + }, + drcState: 0, + mediaRemainUpload: 0, + flightTaskPrepareCapacity: 1, + }; + + return ( + + {/* 机场基本状态 */} + + + +
    + 飞行任务状态: + {airportStatus.flightTaskStepText} +
    +
    + 平台倾斜角度: + {airportStatus.tiltAngle}° + 正常 +
    +
    + 媒体文件: + 无待上传文件 +
    +
    + DRC连接: + + {airportStatus.drcState === 1 ? '已连接' : '未连接'} + +
    +
    - - - + + {/* 通信状态 */} + + + +
    + SDR链路: + 断开(正常) + 飞机在机场内 +
    +
    + 4G链路: + + {getLinkStateText(airportStatus.wirelessLink['4gLinkState'])} + + + {airportStatus.wirelessLink['4gLinkState'] === 0 ? '需要检查网络' : '正常'} + +
    +
    + 频段: + {airportStatus.sdrFrequency}GHz +
    +
    + 工作模式: + {getWorkModeText(airportStatus.wirelessLink.linkWorkMode)} +
    +
    - - - - - - - - + + {/* 起飞点状态 */} + + + +
    + 起飞点: + + {airportStatus.departurePoint.status === 1 ? '已设置' : '未设置'} + +
    +
    + 纬度: + {airportStatus.departurePoint.latitude.toFixed(6)} +
    +
    + 经度: + {airportStatus.departurePoint.longitude.toFixed(6)} +
    +
    + 高度: + {airportStatus.departurePoint.height}m +
    +
    @@ -1346,10 +2355,11 @@ const DeviceMonitor: React.FC = () => { return ( - - - - + {/* 顶部控制栏 */} + + + + + { }} disabled={loading} /> - - - - - - {/* 实时数据卡片 */} - {selectedDevice !== 'all' && ( - - d.deviceSn === selectedDevice)?.deviceName || ''} 实时数据`}> - {renderRealTimeData()} - - - )} - - {/* 性能趋势图 */} - {selectedDevice !== 'all' && ( - - d.deviceSn === selectedDevice)?.deviceName || ''} 性能趋势`} loading={loading}> - `${v}%`, - }, - }} + + setSearchKeyword(e.target.value)} + onKeyPress={(e) => e.key === 'Enter' && searchDevice(searchKeyword)} + style={{ width: 150 }} + prefix={} /> - + - )} + + + + + + + + + + + + + + - {/* 设备状态列表 */} - - - + + + } + valueStyle={{ color: '#1890ff' }} /> - - {/* 告警记录 */} - - -
    + + } + valueStyle={{ color: '#52c41a' }} + suffix={`/ ${getDeviceStatistics().total}`} + /> + + + + + } + valueStyle={{ color: '#52c41a' }} + suffix={`/ ${getDeviceStatistics().total}`} + /> + + + + + } + valueStyle={{ color: '#faad14' }} /> - - {/* 地图组件 */} - {mapVisible && ( - - - {mapInitialized ? ( - renderDeviceMap() - ) : ( -
    -
    地图加载中...
    -
    - )} -
    - - )} + {/* 主要监控内容 */} + + {/* 概览标签页 */} + + + {/* 实时数据卡片 */} + {selectedDevice !== 'all' && ( + + d.deviceSn === selectedDevice)?.deviceName || ''} 实时数据`} + extra={ + + } + > + {renderRealTimeData()} + + + )} + + {/* 地图组件 */} + {mapVisible && ( + + + {mapInitialized ? ( + renderDeviceMap() + ) : ( +
    +
    地图加载中...
    +
    + )} +
    + + )} + + {/* 设备状态列表 */} + + +
    + + + + + + {/* 健康监控标签页 */} + + + {deviceList.map(device => { + const health = deviceHealth[device.deviceSn]; + if (!health) return null; + + return ( + + = 80 ? 'green' : health.overall >= 60 ? 'orange' : 'red'}> + {health.overall}分 + + } + > + + + `${percent}分`} + strokeColor={health.overall >= 80 ? '#52c41a' : health.overall >= 60 ? '#faad14' : '#ff4d4f'} + /> + + + +
    + 电池: + +
    +
    + 网络: + +
    +
    + 硬件: + +
    +
    + 软件: + +
    +
    + 环境: + +
    +
    + + + + {health.issues.length > 0 && ( + + {health.issues.map((issue, index) => ( +
  • {issue}
  • + ))} + + } + type="warning" + showIcon + style={{ marginTop: 16 }} + /> + )} + + + ); + })} + + + + {/* 性能分析标签页 */} + + + {deviceList.map(device => { + const performance = devicePerformance[device.deviceSn]; + if (!performance) return null; + + return ( +
    + + + + + + + 50 ? '#52c41a' : '#faad14' }} + /> + + + 99 ? '#52c41a' : '#faad14' }} + /> + + + 95 ? '#52c41a' : '#faad14' }} + /> + + + + + ); + })} + + + + {/* 告警管理标签页 */} + + + + + + + + } + > +
    { + if (alertFilters.type !== 'all' && alert.type !== alertFilters.type) return false; + if (alertFilters.status !== 'all' && alert.status !== alertFilters.status) return false; + return true; + })} + columns={[ + { + title: '设备名称', + dataIndex: 'deviceName', + key: 'deviceName', + }, + { + title: '告警类型', + dataIndex: 'type', + key: 'type', + render: (type: string) => ( + + {type === 'critical' ? '严重' : type === 'warning' ? '警告' : '信息'} + + ) + }, + { + title: '告警类别', + dataIndex: 'category', + key: 'category', + render: (category: string) => ( + {category} + ) + }, + { + title: '标题', + dataIndex: 'title', + key: 'title', + }, + { + title: '时间', + dataIndex: 'timestamp', + key: 'timestamp', + }, + { + title: '状态', + dataIndex: 'status', + key: 'status', + render: (status: string) => ( + + {status === 'active' ? '活跃' : status === 'acknowledged' ? '已确认' : '已解决'} + + ) + }, + { + title: '操作', + key: 'action', + render: (_, record: DeviceAlert) => ( + + {record.status === 'active' && ( + { + setDeviceAlerts(prev => prev.map(a => + a.id === record.id ? { ...a, status: 'acknowledged' } : a + )); + }}> + 确认 + + )} + {record.status === 'acknowledged' && ( + { + setDeviceAlerts(prev => prev.map(a => + a.id === record.id ? { ...a, status: 'resolved' } : a + )); + }}> + 解决 + + )} + { + setDeviceAlerts(prev => prev.filter(a => a.id !== record.id)); + }} style={{ color: '#ff4d4f' }}> + 删除 + + + ) + } + ]} + rowKey="id" + pagination={{ pageSize: 10 }} + /> + + + + + + {/* 维护管理标签页 */} + + + + }> + 添加维护计划 + + } + > +
    { + const device = deviceList.find(d => d.deviceSn === deviceSn); + return device?.deviceName || deviceSn; + } + }, + { + title: '维护类型', + dataIndex: 'type', + key: 'type', + render: (type: string) => ( + + {type === 'preventive' ? '预防性' : type === 'corrective' ? '纠正性' : '紧急'} + + ) + }, + { + title: '描述', + dataIndex: 'description', + key: 'description', + }, + { + title: '计划日期', + dataIndex: 'scheduledDate', + key: 'scheduledDate', + }, + { + title: '状态', + dataIndex: 'status', + key: 'status', + render: (status: string) => ( + + {status === 'completed' ? '已完成' : status === 'in_progress' ? '进行中' : '已计划'} + + ) + }, + { + title: '操作', + key: 'action', + render: (_, record: MaintenanceRecord) => ( + + 查看详情 + 编辑 + 删除 + + ) + } + ]} + rowKey="id" + pagination={{ pageSize: 10 }} + /> + + + + + + + {/* 设置抽屉 */} + setShowSettings(false)} + > + + + +
    + 健康监控: + setMonitoringConfig(prev => ({ ...prev, enableHealthMonitoring: checked }))} + /> +
    +
    + 性能跟踪: + setMonitoringConfig(prev => ({ ...prev, enablePerformanceTracking: checked }))} + /> +
    +
    + 预测性维护: + setMonitoringConfig(prev => ({ ...prev, enablePredictiveMaintenance: checked }))} + /> +
    +
    + 异常检测: + setMonitoringConfig(prev => ({ ...prev, enableAnomalyDetection: checked }))} + /> +
    +
    +
    + + + +
    + 电池电量阈值: {monitoringConfig.alertThresholds.battery}% + setMonitoringConfig(prev => ({ + ...prev, + alertThresholds: { ...prev.alertThresholds, battery: value } + }))} + /> +
    +
    + 温度阈值: {monitoringConfig.alertThresholds.temperature}°C + setMonitoringConfig(prev => ({ + ...prev, + alertThresholds: { ...prev.alertThresholds, temperature: value } + }))} + /> +
    +
    + 网络质量阈值: {monitoringConfig.alertThresholds.networkQuality}% + setMonitoringConfig(prev => ({ + ...prev, + alertThresholds: { ...prev.alertThresholds, networkQuality: value } + }))} + /> +
    +
    +
    + + + +
    + 启用自动刷新: + +
    +
    + 刷新间隔: {refreshInterval}秒 + +
    +
    +
    +
    +
    + {/* 设备详情弹窗 */} } + onClick={() => { + if (selectedMapDevice) { + handlePlayVideo(selectedMapDevice); + closeMapDeviceInfo(); + } + }} + > + 视频流 + , + , + ]} width={600} > {selectedMapDevice && ( @@ -1541,6 +3060,117 @@ const DeviceMonitor: React.FC = () => { )} + + {/* 视频流播放弹窗 */} + + + {currentVideoDevice ? `${currentVideoDevice.deviceName} 视频流` : '设备视频流'} + + } + open={videoStreamVisible} + onCancel={handleCloseVideo} + footer={[ + , + , + , + , + , + ]} + width={800} + destroyOnClose + > +
    + {videoLoading && ( +
    +
    正在加载视频流...
    +
    + )} + + {videoError && ( + + )} + + {videoStreamUrl && !videoLoading && !videoError && ( +
    + {/* 使用新的视频播放器组件 */} + {renderVideoPlayer()} + + {/* 视频流信息 */} +
    + + + {currentVideoDevice?.deviceName} + + + {currentVideoDevice?.deviceSn} + + + + {currentVideoDevice?.boundStatus === 1 ? '在线' : '离线'} + + + + + {videoStreamUrl.includes('.m3u8') ? 'HLS' : + videoStreamUrl.startsWith('rtmp://') ? 'RTMP' : + videoStreamUrl.startsWith('webrtc://') ? 'WebRTC' : 'HTTP'} + + + + + + + + {videoStreamUrl} + + + +
    +
    + )} + + {!videoStreamUrl && !videoLoading && !videoError && ( +
    + +
    点击重新加载按钮获取视频流
    +
    + )} +
    +
    ); };