From 89d18ea0da2333ff4066a696264914934684f502 Mon Sep 17 00:00:00 2001 From: mmc <1556375442@qq.com> Date: Mon, 11 May 2026 14:59:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=85=E5=A4=87=20=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 16 + package.json | 1 + src/api/api.ts | 8 +- src/api/device.ts | 8 + src/components/VolcRtcPlayer.jsx | 108 +++ src/components/alerts/AlarmOverview.tsx | 605 +++++++++---- src/components/devices/DeviceOverviewPage.tsx | 236 +++--- src/components/droneplayer.jsx | 34 + src/pages/AIAnalysis.tsx | 800 ++++++++---------- src/pages/Devices.tsx | 74 +- 10 files changed, 1117 insertions(+), 773 deletions(-) create mode 100644 src/components/VolcRtcPlayer.jsx create mode 100644 src/components/droneplayer.jsx diff --git a/package-lock.json b/package-lock.json index 4f2253c..e6b7dc7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@reduxjs/toolkit": "^2.11.2", "@tailwindcss/vite": "^4.1.14", "@vitejs/plugin-react": "^5.0.4", + "@volcengine/rtc": "^4.66.37", "antd": "^5.24.1", "axios": "^1.15.1", "clsx": "^2.1.1", @@ -2477,6 +2478,21 @@ "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/@volcengine/rtc": { + "version": "4.66.37", + "resolved": "https://registry.npmjs.org/@volcengine/rtc/-/rtc-4.66.37.tgz", + "integrity": "sha512-VU/ktMFACfzqjQ4eRUmefKu0DaCmVc2wzsn+vFHSNmwXsbRLsodwjqA34zp/y6vfU6gjsMmCPku2iSV/YQIV/A==", + "license": "BSD-3-Clause", + "dependencies": { + "eventemitter3": "^4.0.7" + } + }, + "node_modules/@volcengine/rtc/node_modules/eventemitter3": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", + "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==", + "license": "MIT" + }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", diff --git a/package.json b/package.json index 21ed66a..28bc4df 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@reduxjs/toolkit": "^2.11.2", "@tailwindcss/vite": "^4.1.14", "@vitejs/plugin-react": "^5.0.4", + "@volcengine/rtc": "^4.66.37", "antd": "^5.24.1", "axios": "^1.15.1", "clsx": "^2.1.1", diff --git a/src/api/api.ts b/src/api/api.ts index fc66694..6c2d6ee 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -180,13 +180,7 @@ export function getWayLine() { } //直播流 -export function getLiveStream(data) { - return api({ - url: '/iot/UAV/liveStream', - method: 'post', - data - }) -} + ///iot/UAV/flightTaskCommand export function postFlightCommmand(data) { return api({ diff --git a/src/api/device.ts b/src/api/device.ts index 781d316..349305d 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -15,3 +15,11 @@ export function getPlaneDeviceList() { }) } +export function getLiveStream(data) { + return request({ + url: '/iot/UAV/liveStream', + method: 'post', + data + }) +} + diff --git a/src/components/VolcRtcPlayer.jsx b/src/components/VolcRtcPlayer.jsx new file mode 100644 index 0000000..a8645ea --- /dev/null +++ b/src/components/VolcRtcPlayer.jsx @@ -0,0 +1,108 @@ +import React, { useEffect, useRef } from "react"; +import { joinRoom, leaveRoom } from "./droneplayer"; +import { postLiveHeartbeat } from "@/api/api"; + +export default function DroneLivePlayer({ streamData, videoMode = "NORMAL" }) { + console.log(streamData) + const containerRef = useRef(null); + const timerRef = useRef(null); + + // ------------ 核心修复:防止异步竞态 ------------ + const isBusyRef = useRef(false); // 正在加入/离开,禁止重复操作 + const mountedRef = useRef(true); // 组件是否挂载 + + useEffect(() => { + mountedRef.current = true; + const container = containerRef.current; + + // 清空容器,防止 DOM 不为空 + if (container) container.innerHTML = ""; + + if (!container || !streamData?.url) return; + + // 解析参数 + const params = new URLSearchParams(streamData.url); + const appId = (params.get("app_id") || params.get("appid") || "").trim(); + const roomId = (params.get("room_id") || params.get("roomid") || "").trim(); + const token = decodeURIComponent((params.get("token") || "").trim()); + const userId = (params.get("user_id") || params.get("uid") || "").trim(); + + if (!appId || !roomId || !token || !userId) return; + + // 心跳 + const liveheartbeat = async () => { + try { + await postLiveHeartbeat({ + sn: streamData.sn, + cameraIndex: streamData.camera_index, + }); + } catch (err) { + console.error("心跳失败", err); + } + }; + + // ---------------- 真正安全的初始化流程 ---------------- + const safeInit = async () => { + // 1. 防止并发:正在忙就直接退出 + if (isBusyRef.current) return; + isBusyRef.current = true; + + try { + // 2. 【强制顺序】先销毁旧房间 + 清心跳 + if (timerRef.current) { + clearInterval(timerRef.current); + timerRef.current = null; + } + leaveRoom(); // 先离开旧房间 + await new Promise((resolve) => setTimeout(resolve, 100)); // 等待 SDK 内部清理完成 + + // 3. 组件已卸载,直接放弃 + if (!mountedRef.current) { + isBusyRef.current = false; + return; + } + + // 4. 加入新房间(此时绝对安全) + await joinRoom(container, appId, roomId, token, userId, videoMode); + + // 5. 开启心跳 + //timerRef.current = setInterval(liveheartbeat, 3000); + //liveheartbeat(); + } catch (err) { + console.error("RTC 初始化失败", err); + } finally { + // 解锁 + isBusyRef.current = false; + } + }; + + safeInit(); + + // ---------------- 清理函数 ---------------- + return () => { + mountedRef.current = false; + + // 清理心跳 + if (timerRef.current) { + clearInterval(timerRef.current); + timerRef.current = null; + } + + // 离开房间 + leaveRoom(); + }; + }, [ + streamData?.url, + streamData?.sn, + streamData?.camera_index, + videoMode, + ]); + + return ( +
+ ); +} diff --git a/src/components/alerts/AlarmOverview.tsx b/src/components/alerts/AlarmOverview.tsx index 3ec66dc..046bc49 100644 --- a/src/components/alerts/AlarmOverview.tsx +++ b/src/components/alerts/AlarmOverview.tsx @@ -1,37 +1,44 @@ import React, { useState } from 'react'; import { Card, Row, Col, Select, DatePicker, Input, Button, Space, Table, Tag, - Statistic, Typography, Modal, Form, Checkbox, message + Statistic, Typography, Modal, Form, Checkbox, message, Switch, Divider, Pagination } from 'antd'; import { - BellOutlined, ClockCircleOutlined, CheckCircleOutlined, ExclamationCircleOutlined + BellOutlined, ClockCircleOutlined, CheckCircleOutlined, ExclamationCircleOutlined, + SearchOutlined, ReloadOutlined, CloseOutlined, InfoCircleOutlined, + SendOutlined, MailOutlined, MessageOutlined, DesktopOutlined, + FileTextOutlined, LineChartOutlined, PieChartOutlined, BarChartOutlined, + RiseOutlined } from '@ant-design/icons'; import { Line, Pie, Bar } from '@ant-design/charts'; const { RangePicker } = DatePicker; -const { Text } = Typography; +const { Text, Title } = Typography; // 级别 + 状态颜色 const levelColor = { - 严重: 'red', - 重要: 'orange', - 一般: 'gold', - 提示: 'blue' + 严重: '#F53F3F', + 重要: '#FF7D00', + 一般: '#F7BA1E', + 提示: '#165DFF' }; const statusColor = { - 处理中: 'processing', - 待处理: 'warning', - 已关闭: 'success' + 处理中: '#165DFF', + 待处理: '#F7BA1E', + 已关闭: '#00B42A' }; // 模拟数据 const mockAlerts = [ - { id: 'DEVICE_OFFLINE_CAM-02', content: '设备离线', device: 'CAM-02', level: '提示', time: '2026-04-28 17:22:04', duration: '1小时23分', status: '待处理', handler: '-' }, - { id: 'INV_TEMP_HIGH_INV-A02', content: '逆变器温度过高', device: 'INV-A02', level: '重要', time: '2026-04-28 17:21:54', duration: '1小时23分', status: '待处理', handler: '-' }, - { id: 'AL-20260428-001', content: 'INV-A02 温度过高', device: 'INV-A02', level: '重要', time: '2026-04-28 10:54:45', duration: '36分钟', status: '待处理', handler: '-' }, - { id: 'AL-20260428-002', content: 'CMB-A01 组串电流异常', device: 'CMB-A01', level: '一般', time: '2026-04-28 10:32:45', duration: '52分钟', status: '处理中', handler: '张运维' }, - { id: 'AL-20260428-003', content: 'CAM-02 视频离线', device: 'CAM-02', level: '提示', time: '2026-04-28 09:32:45', duration: '0分钟', status: '待处理', handler: '-' }, + { id: 'AL20250525001', content: '逆变器停机', device: '逆变器 12 (组串式)', level: '严重', time: '2025-05-25 09:18:32', duration: '2小时18分', status: '处理中', handler: '张运维' }, + { id: 'AL20250525002', content: '发电量下降 > 15%', device: '汇流箱 05', level: '重要', time: '2025-05-25 08:46:11', duration: '3小时50分', status: '处理中', handler: '李工程师' }, + { id: 'AL20250525003', content: '逆变器温度过高', device: '逆变器 07 (组串式)', level: '重要', time: '2025-05-25 07:32:45', duration: '4小时24分', status: '待处理', handler: '-' }, + { id: 'AL20250525004', content: '通信中断', device: '气象站 01', level: '一般', time: '2025-05-25 06:51:20', duration: '5小时05分', status: '待处理', handler: '王运维' }, + { id: 'AL20250525005', content: '数据异常', device: '电表 01 (并网点)', level: '提示', time: '2025-05-25 06:20:18', duration: '3小时36分', status: '已关闭', handler: '赵工程师' }, + { id: 'AL20250525006', content: '发电量下降 > 15%', device: '组串 3-15', level: '重要', time: '2025-05-25 05:45:02', duration: '6小时10分', status: '处理中', handler: '李工程师' }, + { id: 'AL20250525007', content: '逆变器停机', device: '逆变器 03 (组串式)', level: '严重', time: '2025-05-25 04:28:33', duration: '7小时28分', status: '处理中', handler: '张运维' }, + { id: 'AL20250525008', content: '通信中断', device: '智能汇流箱 08', level: '一般', time: '2025-05-25 03:15:47', duration: '2小时18分', status: '已关闭', handler: '王运维' }, ]; // 通知渠道 @@ -43,28 +50,50 @@ const channelOptions = [ ]; export default function AlarmCenterPage() { - const [selectedAlert, setSelectedAlert] = useState(mockAlerts[0]); - const [detailVisible, setDetailVisible] = useState(true); + const [selectedAlert, setSelectedAlert] = useState(null); + const [detailVisible, setDetailVisible] = useState(false); const [confirmModalVisible, setConfirmModalVisible] = useState(false); const [notifyChannels, setNotifyChannels] = useState(['wecom', 'dingtalk', 'email']); const [form] = Form.useForm(); const columns = [ - { title: '告警编号', dataIndex: 'id', width: 180 }, + { + title: '告警编号', + dataIndex: 'id', + width: 140, + render: (text) => {text} + }, { title: '告警内容', dataIndex: 'content', ellipsis: true }, - { title: '来源设备', dataIndex: 'device', width: 120 }, - { title: '告警级别', dataIndex: 'level', width: 100, render: l => {l} }, + { title: '来源设备', dataIndex: 'device', width: 160 }, + { + title: '告警级别', + dataIndex: 'level', + width: 100, + render: (l) => ( + + {l} + + ) + }, { title: '发生时间', dataIndex: 'time', width: 160 }, { title: '持续时长', dataIndex: 'duration', width: 100 }, - { title: '处理状态', dataIndex: 'status', width: 100, render: s => {s} }, + { + title: '处理状态', + dataIndex: 'status', + width: 100, + render: (s) => ( + + + {s} + + ) + }, { title: '负责人', dataIndex: 'handler', width: 100 }, { - title: '操作', width: 120, + title: '操作', + width: 80, render: (_, record) => ( - - - - + ) } ]; @@ -72,206 +101,432 @@ export default function AlarmCenterPage() { // 告警趋势图配置 const trendConfig = { data: [ - { date: '05-19', 严重: 12, 重要: 5, 一般: 3, 提示: 2 }, - { date: '05-20', 严重: 30, 重要: 16, 一般: 9, 提示: 6 }, - { date: '05-21', 严重: 23, 重要: 11, 一般: 7, 提示: 5 }, - { date: '05-22', 严重: 25, 重要: 17, 一般: 10, 提示: 4 }, - { date: '05-23', 严重: 19, 重要: 9, 一般: 13, 提示: 7 }, - { date: '05-24', 严重: 24, 重要: 18, 一般: 16, 提示: 8 }, - { date: '05-25', 严重: 36, 重要: 29, 一般: 22, 提示: 13 } + { date: '05-19', type: '严重', value: 12 }, + { date: '05-19', type: '重要', value: 5 }, + { date: '05-19', type: '一般', value: 3 }, + { date: '05-19', type: '提示', value: 2 }, + { date: '05-20', type: '严重', value: 30 }, + { date: '05-20', type: '重要', value: 16 }, + { date: '05-20', type: '一般', value: 9 }, + { date: '05-20', type: '提示', value: 6 }, + { date: '05-21', type: '严重', value: 23 }, + { date: '05-21', type: '重要', value: 11 }, + { date: '05-21', type: '一般', value: 7 }, + { date: '05-21', type: '提示', value: 5 }, + { date: '05-22', type: '严重', value: 25 }, + { date: '05-22', type: '重要', value: 17 }, + { date: '05-22', type: '一般', value: 10 }, + { date: '05-22', type: '提示', value: 4 }, + { date: '05-23', type: '严重', value: 19 }, + { date: '05-23', type: '重要', value: 9 }, + { date: '05-23', type: '一般', value: 13 }, + { date: '05-23', type: '提示', value: 7 }, + { date: '05-24', type: '严重', value: 24 }, + { date: '05-24', type: '重要', value: 18 }, + { date: '05-24', type: '一般', value: 16 }, + { date: '05-24', type: '提示', value: 8 }, + { date: '05-25', type: '严重', value: 36 }, + { date: '05-25', type: '重要', value: 29 }, + { date: '05-25', type: '一般', value: 22 }, + { date: '05-25', type: '提示', value: 13 }, ], xField: 'date', - yField: ['严重', '重要', '一般', '提示'], - color: ['#ff4d4f', '#faad14', '#52c41a', '#1890ff'], + yField: 'value', + seriesField: 'type', + color: ['#F53F3F', '#FF7D00', '#F7BA1E', '#165DFF'], smooth: true, legend: { position: 'top-left' }, - label: { style: { fill: '#aaa' } } }; // 告警分类占比配置 const pieConfig = { data: [ - { type: '严重', value: 8, percent: 22.2 }, - { type: '重要', value: 12, percent: 33.3 }, - { type: '一般', value: 11, percent: 30.6 }, - { type: '提示', value: 5, percent: 13.9 } + { type: '严重', value: 8 }, + { type: '重要', value: 12 }, + { type: '一般', value: 11 }, + { type: '提示', value: 5 } ], angleField: 'value', colorField: 'type', - color: ['#ff4d4f', '#faad14', '#52c41a', '#1890ff'], + color: ['#F53F3F', '#FF7D00', '#F7BA1E', '#165DFF'], radius: 0.8, innerRadius: 0.6, - label: { - type: 'outer', - content: '{name}\n{percentage:.1%} ({value})' - }, - annotations: [ - { - type: 'text', - style: { - text: '36\n总告警', - x: '50%', - y: '50%', - textAlign: 'center', - fontSize: 20, - fontWeight: 'bold' - } + label: false, + legend: { + position: 'right', + layout: 'vertical', + formatter: (text, item) => { + const d = pieConfig.data.find(d => d.type === text); + const total = pieConfig.data.reduce((a, b) => a + b.value, 0); + return `${text} ${((d!.value / total) * 100).toFixed(1)}% (${d!.value})`; } - ] + }, + statistic: { + title: { + offsetY: -12, + style: { fontSize: '14px', color: '#86909C' }, + content: '总告警' + }, + content: { + offsetY: 12, + style: { fontSize: '24px', fontWeight: '700', color: '#1D2129' }, + content: '36' + } + } }; // 告警来源设备分布 const barConfig = { data: [ - { device: '逆变器', count: 14, percent: 38.9 }, - { device: '汇流箱', count: 8, percent: 22.2 }, - { device: '组串', count: 6, percent: 16.7 }, - { device: '气象站', count: 3, percent: 8.3 }, - { device: '电表', count: 3, percent: 8.3 }, - { device: '其他', count: 2, percent: 5.6 } + { device: '逆变器', count: 14 }, + { device: '汇流箱', count: 8 }, + { device: '组串', count: 6 }, + { device: '气象站', count: 3 }, + { device: '电表', count: 3 }, + { device: '其他', count: 2 } ], xField: 'count', yField: 'device', - colorField: 'device', - color: ['#1890ff', '#40a9ff', '#69c0ff', '#91d5ff', '#bae7ff', '#e6f7ff'], - barWidthRatio: 0.6, + seriesField: 'device', + color: '#165DFF', + barWidthRatio: 0.4, label: { position: 'right', - style: { fill: '#666' }, - content: (item) => `${item.count}(${item.percent}%)` - } + //formatter: (text) => { + // const total = barConfig.data.reduce((a, b) => a + b.count, 0); + // const d = barConfig.data.find(d => d.count === Number(text.count)); + // return `${text.count} (${((Number(text.count) / total) * 100).toFixed(1)}%)`; + //} + }, + legend: false + }; + + // 详情页趋势图配置 + const detailTrendConfig = { + data: [ + { time: '05-25 04:00', type: '功率 (kW)', value: 100 }, + { time: '05-25 05:00', type: '功率 (kW)', value: 120 }, + { time: '05-25 06:00', type: '功率 (kW)', value: 150 }, + { time: '05-25 07:00', type: '功率 (kW)', value: 130 }, + { time: '05-25 08:00', type: '功率 (kW)', value: 140 }, + { time: '05-25 09:00', type: '功率 (kW)', value: 20 }, + { time: '05-25 10:00', type: '功率 (kW)', value: 10 }, + { time: '05-25 04:00', type: '直流电压 (V)', value: 600 }, + { time: '05-25 05:00', type: '直流电压 (V)', value: 610 }, + { time: '05-25 06:00', type: '直流电压 (V)', value: 620 }, + { time: '05-25 07:00', type: '直流电压 (V)', value: 600 }, + { time: '05-25 08:00', type: '直流电压 (V)', value: 610 }, + { time: '05-25 09:00', type: '直流电压 (V)', value: 580 }, + { time: '05-25 10:00', type: '直流电压 (V)', value: 570 }, + { time: '05-25 04:00', type: '温度 (℃)', value: 35 }, + { time: '05-25 05:00', type: '温度 (℃)', value: 38 }, + { time: '05-25 06:00', type: '温度 (℃)', value: 42 }, + { time: '05-25 07:00', type: '温度 (℃)', value: 45 }, + { time: '05-25 08:00', type: '温度 (℃)', value: 48 }, + { time: '05-25 09:00', type: '温度 (℃)', value: 52 }, + { time: '05-25 10:00', type: '温度 (℃)', value: 55 }, + ], + xField: 'time', + yField: 'value', + seriesField: 'type', + color: ['#165DFF', '#00B42A', '#FF7D00'], + smooth: true, + legend: { position: 'top' }, + yAxis: { grid: { line: { style: { lineDash: [4, 4] } } } } }; - // 提交确认告警 const handleConfirmAlarm = () => { form.validateFields().then(values => { - console.log('确认告警:', selectedAlert.id, values.notifyChannels); - message.success('告警已确认,通知将发送至:' + values.notifyChannels.join(',')); + message.success('告警已确认'); setConfirmModalVisible(false); }); }; return ( -
-
+
+ {/* 🔥 核心布局:左侧内容 + 右侧详情 永远一行显示 */} +
+ + {/* 左侧主内容区 */}
-
- - - - - - - - - -
-
- } valueStyle={{ fontSize: 28, fontWeight: 700, color: '#ff4d4f' }} /> -
昨日 28
-
-
- } valueStyle={{ fontSize: 28, fontWeight: 700, color: '#ff4d4f' }} /> -
重要 2
-
-
- } valueStyle={{ fontSize: 28, fontWeight: 700, color: '#faad14' }} /> -
待处理 4
-
-
- } valueStyle={{ fontSize: 28, fontWeight: 700, color: '#52c41a' }} /> -
闭环完成
-
-
- } valueStyle={{ fontSize: 28, fontWeight: 700, color: '#1890ff' }} /> -
时间估算
-
-
-
- -
-
- -
-
- 告警列表(共8条)
- 点击告警查看详情 -
-
- - - - - {detailVisible && selectedAlert && ( -
- -
-
-
-
- - {selectedAlert.content} -
- {selectedAlert.level} -
-
{selectedAlert.id}
-
- -
- -
来源设备
{selectedAlert.device}
-
发生时间
{selectedAlert.time}
-
持续时长
{selectedAlert.duration}
-
处理状态
{selectedAlert.status}
- - - -
-
根因分析建议
-
- 设备离线/网络异常
- 电源或通讯模块故障
- 现场信号弱或采集器异常 -
-
- - -
- - - - + +
+ + + +
告警级别
+ + + +
设备类型
+ + + +
搜索关键词
+ + + +
+ + + - - - - )} - + + + + + + + + + + + +
+ +
+ + +
今日告警总数
+
+ 36 + 较昨日 +28.6% ↑ +
+
昨日 28
+ + + + + + + + +
+ +
+ + +
严重告警
+
+ 8 + 较昨日 +33.3% ↑ +
+
昨日 6
+ + + + + + + + +
+ +
+ + +
处理中
+
+ 12 + 较昨日 +20.0% ↑ +
+
昨日 10
+ + + + + + + + +
+ +
+ + +
已关闭
+
+ 16 + 较昨日 +45.5% ↑ +
+
昨日 11
+ + + + + + + + +
+ +
+ + +
平均响应时长
+
+ 18分32秒 +
+
昨日 21分12秒
+ + + + + + + + + +
+ 告警列表(共 36 条) +
+
+
+ +
+ + + - 更多 }> - + 告警趋势} extra={} style={{ borderRadius: 8 }}> + - 更多 }> - + 告警分类占比} extra={} style={{ borderRadius: 8 }}> + - 更多}> - + 告警来源设备分布} extra={} style={{ borderRadius: 8 }}> + + + {/* 🔥 右侧详情:丝滑滑入动画 */} + {detailVisible && selectedAlert && ( +
+ + 告警详情} + extra={ setDetailVisible(false)} />} + bodyStyle={{ padding: 16 }} + style={{ height: '100%', borderRadius: 8 }} + > +
+
+ +
+
+
+ {selectedAlert.content} + {selectedAlert.level} +
+
告警编号:{selectedAlert.id}
+
+
+ + +
来源设备
{selectedAlert.device}
+
设备类型
逆变器
+
发生时间
{selectedAlert.time}
+
持续时长
{selectedAlert.duration}
+
处理状态
{selectedAlert.status} + +
负责人
+
+ {selectedAlert.handler} + +
+ +
当前处理人
张运维 (2025-05-25 09:22 接收)
+
告警描述
逆变器因内部故障自动停机,当前无功率输出。
+ + + + +
+
+ 根因分析建议 + +
+
    +
  1. 逆变器内部保护触发 (IGBT/继电器故障)
  2. +
  3. 交流侧电压异常或并网不稳定
  4. +
  5. 散热风扇故障导致过温保护
  6. +
+
+ +
+
相关趋势
+ +
+ +
+
推荐处理措施
+
    +
  • 现场检查逆变器告警记录及指示灯状态;
  • +
  • 检查散热风扇运行及通风条件;
  • +
  • 检查交流侧电压及并网条件;
  • +
  • 如无法恢复,建议联系厂家或更换模块。
  • +
+
+ +
+
+ +
+
通知与订阅
+ +
短信 + Telegram + 邮件 + + + + + + + )} - {/* 确认告警弹窗 */} , value: '2 / 2', desc: '在线', sub: '可调度 2 架', color: '#1890ff' }, - { title: '巡检机器人', icon: , value: '3 台', desc: '', sub: '执行中 2', color: '#722ed1' }, - { title: '除草机器人', icon: , value: '2 台', desc: '', sub: '作业中 1', color: '#13c2c2' }, - { title: '清洗无人机', icon: , value: '2 架', desc: '', sub: '待命 1', color: '#eb2f96' }, - { title: '设备平均电量', icon: , value: '86%', desc: '', sub: '', color: '#52c41a' }, - { title: '今日任务执行', icon: , value: '12 / 15', desc: '', sub: '完成率 80%', color: '#2f54eb' }, -]; -const scheduleList = [ - { id: 1, name: '无人机机场 A01', type: '无人机机场', status: '在线', mode: '待命', battery: 100, position: '开压站旁', task: '待命', comm: '良好' }, - { id: 2, name: '巡检机器人 RBT-01', type: '巡检机器人', status: '作业中', mode: '自主巡检', battery: 68, position: '区块 B-03', task: '巡检航线 P-02', comm: '良好' }, - { id: 3, name: '巡检机器人 RBT-02', type: '巡检机器人', status: '在线', mode: '待命', battery: 92, position: '区块 D-06', task: '待命', comm: '良好' }, - { id: 4, name: '除草机器人 GR-01', type: '除草机器人', status: '充电中', mode: '回充', battery: 35, position: '充电桩 1', task: '回充中', comm: '良好' }, - { id: 5, name: '清洗无人机 UAV-C01', type: '清洗无人机', status: '作业中', mode: '自主清洗', battery: 72, position: '清洗区 C-05', task: '清洗航线 C-05', comm: '良好' }, - { id: 6, name: '清洗无人机 UAV-C02', type: '清洗无人机', status: '待命', mode: '待命', battery: 96, position: '无人机机场 A01', task: '待命', comm: '良好' }, -]; + const taskTimeline = [ { time: '10:24:18', color: 'blue', text: 'UAV-C01 开始执行清洗航线 C-05', status: '任务开始' }, @@ -60,23 +45,69 @@ const logs = [ // 设备总览组件 export default function DeviceOverviewPage({ devices, planedevices, devicesAll }) { - const [activeTab, setActiveTab] = useState('drone'); - const [selectedDevice, setSelectedDevice] = useState(''); - const [currentDevice, setCurrentDevice] = useState(null); + console.log(devicesAll, "devicesAll") + const [selectedDevice, setSelectedDevice] = useState(null); + const [planeVideo, setPlaneVideo] = useState(''); + + // 动态计算顶部卡片数据 + const dynamicTopCards = React.useMemo(() => { + const totalDrones = planedevices?.length || 0; + const onlineDrones = planedevices?.filter(d => d.onlineStatus === 1).length || 0; + + const totalRobots = devicesAll?.filter(d => d.productName?.includes('巡检')).length || 0; + const activeRobots = devicesAll?.filter(d => d.productName?.includes('巡检') && d.onlineStatus === 1).length || 0; + + const totalMowers = devicesAll?.filter(d => d.productName?.includes('割草机')).length || 0; + const activeMowers = devicesAll?.filter(d => d.productName?.includes('割草机') && d.onlineStatus === 1).length || 0; + + return [ + { title: '无人机机场状态', icon: , value: `${onlineDrones} / ${totalDrones}`, desc: onlineDrones > 0 ? '在线' : '离线', sub: `可调度 ${onlineDrones} 架`, color: '#1890ff' }, + //{ title: '巡检机器人', icon: , value: `${totalRobots} 台`, desc: '', sub: `执行中 ${activeRobots}`, color: '#722ed1' }, + { title: '机器人', icon: , value: `${totalMowers} 台`, desc: '', sub: `作业中 ${activeMowers}`, color: '#13c2c2' }, + { title: '无人机', icon: , value: `${totalDrones} 架`, desc: '', sub: `待命 ${planedevices?.filter(d => d.productName?.includes('清洗') && d.onlineStatus === 1).length || 0}`, color: '#eb2f96' }, + { title: '设备平均电量', icon: , value: '86%', desc: '', sub: '', color: '#52c41a' }, + { title: '今日任务执行', icon: , value: '12 / 15', desc: '', sub: '完成率 80%', color: '#2f54eb' }, + ]; + }, [devicesAll, planedevices]); + + // 动态生成调度列表 + const dynamicScheduleList = React.useMemo(() => { + return devicesAll.map((d, index) => ({ + id: d.deviceId || index, + name: d.deviceAlias || d.deviceName || d.callsign || '未知设备', + type: d.productName || '未知类型', + status: d.onlineStatus === 1 ? '在线' : '离线', + mode: d.status === 4 ? '待命' : '作业中', + battery: d.capacity_percent || 100, + position: d.position || '站内', + task: d.status === 4 ? '待命' : '作业中', + comm: d.rssi ? `${d.rssi}dBm` : '良好' + })); + }, [devicesAll]); - const controlTabs = [ - { key: 'airport', label: '无人机机场' }, - { key: 'robot', label: '巡检机器人' }, - { key: 'mower', label: '除草机器人' }, - { key: 'clean', label: '清洗无人机' }, - { key: 'machine', label: '机械设备' }, - ]; const handleStart = () => message.success('任务已启动'); const handlePause = () => message.info('任务已暂停'); const handleReturn = () => message.info('返航指令已下发'); const handleRecharge = () => message.info('回充指令已下发'); const handleEmergencyStop = () => message.error('已触发急停!'); + const getLiveDefault = () => { + if (!selectedDevice?.gateway_sn) return; + const data = { + getway_sn: selectedDevice?.gateway_sn, + drone_sn: selectedDevice?.device_sn, + getway_camera_list: selectedDevice?.gateway_camera_list ?? [], + drone_camera_list: selectedDevice?.drone_camera_list ?? [], + video_expire: 7200, + quality_type: "adaptive", + } + getLiveStream(data).then(res => { + if (res.code == 200) { + setPlaneVideo(res.data); + } + }) + } + // 数字保留两位小数 const fix2 = (val) => { @@ -85,28 +116,28 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll } }; // 安全取值 - const getVal = (val) => val == "no_rain" ? "无" : '-'; + const getVal = (val) => val == "no_rain" ? "无" : (val || '-'); // 默认选中第一个 useEffect(() => { if (devicesAll && devicesAll.length > 0) { - const first = devicesAll[0]; - setSelectedDevice(first.device_sn); - setCurrentDevice(first); + setSelectedDevice(devicesAll[0]); // 🔥 修复:存整个对象 } }, [devicesAll]); + useEffect(() => { + getLiveDefault(); + }, [selectedDevice]) // 切换设备 - const handleDeviceChange = (sn) => { - setSelectedDevice(sn); - const target = devicesAll.find(item => item.device_sn === sn); - setCurrentDevice(target); + const handleDeviceChange = (id) => { + const target = devicesAll.find(item => (item.device_sn || item.serialNumber) === id); + setSelectedDevice(target || null); // 🔥 修复:存对象 }; return (
- {topCards.map((card, idx) => ( + {dynamicTopCards.map((card, idx) => (
@@ -143,19 +174,19 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll } 装备调度列表} bordered={false} style={{ borderRadius: 12, marginBottom: 16 }}> -
record.id || record.serialNumber || record.device_sn} size="small" pagination={false} columns={[ { title: '装备名称', dataIndex: 'name', width: 160 }, { title: '类型', dataIndex: 'type', width: 100 }, - { title: '当前状态', dataIndex: 'status', width: 80, render: s => {s} }, + { title: '当前状态', dataIndex: 'status', width: 80, render: s => {s} }, { title: '模式', dataIndex: 'mode', width: 80 }, { title: '电量', dataIndex: 'battery', width: 80, render: v => }, { title: '位置', dataIndex: 'position', width: 100 }, { title: '当前任务', dataIndex: 'task', width: 120 }, - { title: '通讯状态', dataIndex: 'comm', width: 80, render: v => }, + { title: '通讯状态', dataIndex: 'comm', width: 80, render: v => }, { title: '操作', key: 'action', width: 100, render: () => 设备控制面板} bordered={false} style={{ borderRadius: 12, marginBottom: 16 }} bodyStyle={{ padding: 16, paddingBottom: 0 }}>
- - - - - - {/* 数据来源和AI建议 */} - - - 数据来源状态} - bordered={false} - style={{ borderRadius: 8, height: '100%' }} - extra={多源数据融合质量} - > - - -
-
UAV
-
无人机
-
数据状态:正常
-
- - -
-
DB
-
SCA
-
数据状态:正常
-
- - - - - -
-
UAV
-
无人机
-
数据状态:正常
-
- - -
-
UAV
-
无人机
-
数据状态:正常
-
- - - - - - - AI建议与处置} - bordered={false} - style={{ borderRadius: 8 }} - extra={按收益、优先级与置信度排序} - > - {/* 👇 加了灰色透明滚动条 */} -
+
( - - - - + title: '收益', + dataIndex: 'expectedGain', + key: 'expectedGain', + render: (g) => {g}, + width: 70 + }, + { + title: '操作', + key: 'action', + width: 70, + render: () => ( + ) }, ]} dataSource={aiRecommendations} pagination={false} size="small" - scroll={{ y: undefined }} /> - {/* 二级入口按钮 */} - -
-
- 二级入口 - 原诊断任务、热斑结果、AI建议、诊断报告保留为操作入口 -
- - - - - - -
-
- - {/* 抽屉详情 */} - AI诊断详情} - placement="right" - onClose={() => setDrawerVisible(false)} - open={drawerVisible} - width={600} - > - {selectedTask && ( -
- -
-
- 任务 - AIT-DEMO-HEALTH-01 -
-
- 算法 - 设备健康演示算法 -
-
- 结果 - RES-DEMO-INV-A02 -
-
- 最高温 - {selectedTask.temp} -
- - -
- 状态 - SUCCESS -
-
- 进度 - 100% -
-
- 等级 - {selectedTask.level} -
-
- 置信度 - 90% -
- - -
- 摘要 -
- 结合遥感数据发现逆变器温度偏高且功率波动,建议检修散热。 -
-
-
- 图片/热成像文件 - -
-
- 方阵A-05
热点异常 · 71.5℃
-
- - -
- 方阵A-12
高温风险 · 68.3℃
-
- - -
- 方阵B-03
疑似遮挡 · 64.8℃
-
- - - -
- 热斑列表 -
- -
- AI JSON摘要 -
-								{`{
-  "demo": true,
-  "metric": [
-    "temperature",
-    "activePower"
-  ]
-}`}
-							
-
- - )} - ); } diff --git a/src/pages/Devices.tsx b/src/pages/Devices.tsx index 11c6202..0c28049 100644 --- a/src/pages/Devices.tsx +++ b/src/pages/Devices.tsx @@ -9,7 +9,6 @@ import { RootState } from '../store'; const { Header, Content } = Layout; const { Text } = Typography; -// 设置状态页面(你后续自己填内容) const DeviceStatusSettingPage = () => (

设置状态页面(/devices/status)

@@ -24,50 +23,62 @@ export default function DeviceIndexPage() { const [devicesAll, setDevicesAll] = useState([]); const tabs = [ - { key: 'overview', label: '装备总览', icon: , path: '/devices/overview' }, - { key: 'status', label: '设置状态', icon: , path: '/devices/status' }, + { key: 'overview', label: '装备总览', icon: }, + { key: 'status', label: '设置状态', icon: }, ]; - const renderContent = () => { - if (activeTab === 'overview') return ; - if (activeTab === 'status') return ; - return null; - }; - const getPlaneList = () => { - getPlaneDeviceList().then(res => { - if (res?.code == 200) { - const drones = res?.data?.detail; - setPlaneDevices(drones); - setDevicesAll([...devices, ...drones]); - } - }); - }; + // 👇 核心修复:同时请求 + 同时合并 + const fetchAllData = async () => { + if (!userInfo?.username) return; - const getDevice = () => { - const data = { tenantName: userInfo.username, deptId: 1 }; - getDeviceListApi(data).then(res => { - if (res?.code == 200 && res?.data?.length) { - setDevices(res.data); - setDevicesAll([...planedevices, ...res.data.data]); - } - }); + try { + // 1. 同时发请求 + const [deviceRes, planeRes] = await Promise.all([ + getDeviceListApi({ tenantName: userInfo.username, deptId: 1 }), + getPlaneDeviceList(), + ]); + + // 2. 处理设备数据 + const devData = deviceRes?.code === 200 ? (deviceRes.data || []) : []; + const planeData = planeRes?.code === 200 ? (planeRes.data?.detail || []) : []; + + // 3. 分别保存 + setDevices(devData); + setPlaneDevices(planeData); + + // 4. 最终合并(只执行一次!) + setDevicesAll([...devData, ...planeData]); + + } catch (err) { + console.error('数据请求失败', err); + } }; useEffect(() => { - getDevice(); - getPlaneList(); - }, []); + fetchAllData(); + }, [userInfo]); + const renderContent = () => { + if (activeTab === 'overview') { + return ; + } + if (activeTab === 'status') return ; + return null; + }; return (
-
+
装备控制 装备总览、状态监控与参数配置
-
+
- {renderContent()}