装备 完善

This commit is contained in:
mmc
2026-05-11 14:59:36 +08:00
parent 2ee7d1183d
commit 89d18ea0da
10 changed files with 1117 additions and 773 deletions

16
package-lock.json generated
View File

@@ -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",

View File

@@ -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",

View File

@@ -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({

View File

@@ -15,3 +15,11 @@ export function getPlaneDeviceList() {
})
}
export function getLiveStream(data) {
return request({
url: '/iot/UAV/liveStream',
method: 'post',
data
})
}

View File

@@ -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 (
<div
ref={containerRef}
className="rounded"
style={{ width: "100%", height: "100%", background: "#000" }}
/>
);
}

View File

@@ -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<any>(mockAlerts[0]);
const [detailVisible, setDetailVisible] = useState(true);
const [selectedAlert, setSelectedAlert] = useState<any>(null);
const [detailVisible, setDetailVisible] = useState(false);
const [confirmModalVisible, setConfirmModalVisible] = useState(false);
const [notifyChannels, setNotifyChannels] = useState<string[]>(['wecom', 'dingtalk', 'email']);
const [form] = Form.useForm();
const columns = [
{ title: '告警编号', dataIndex: 'id', width: 180 },
{
title: '告警编号',
dataIndex: 'id',
width: 140,
render: (text) => <Text style={{ color: '#165DFF' }}>{text}</Text>
},
{ title: '告警内容', dataIndex: 'content', ellipsis: true },
{ title: '来源设备', dataIndex: 'device', width: 120 },
{ title: '告警级别', dataIndex: 'level', width: 100, render: l => <Tag color={levelColor[l]}>{l}</Tag> },
{ title: '来源设备', dataIndex: 'device', width: 160 },
{
title: '告警级别',
dataIndex: 'level',
width: 100,
render: (l) => (
<Tag color={levelColor[l]} style={{ borderRadius: 2, border: 'none', color: '#fff' }}>
{l}
</Tag>
)
},
{ title: '发生时间', dataIndex: 'time', width: 160 },
{ title: '持续时长', dataIndex: 'duration', width: 100 },
{ title: '处理状态', dataIndex: 'status', width: 100, render: s => <Tag color={statusColor[s]}>{s}</Tag> },
{
title: '处理状态',
dataIndex: 'status',
width: 100,
render: (s) => (
<span style={{ color: statusColor[s], display: 'flex', alignItems: 'center' }}>
<span style={{ width: 6, height: 6, borderRadius: '50%', background: statusColor[s], marginRight: 8 }}></span>
{s}
</span>
)
},
{ title: '负责人', dataIndex: 'handler', width: 100 },
{
title: '操作', width: 120,
title: '操作',
width: 80,
render: (_, record) => (
<Space>
<Button type="link" onClick={() => { setSelectedAlert(record); setDetailVisible(true); }}>查看</Button>
<Button type="link">更多</Button>
</Space>
<Button type="link" onClick={() => { setSelectedAlert(record); setDetailVisible(true); }}>查看</Button>
)
}
];
@@ -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 (
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: '0 24px 24px' }}>
<div style={{ display: 'flex', gap: 16, marginTop: 16, width: '100%' }}>
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: '16px 24px' }}>
{/* 🔥 核心布局:左侧内容 + 右侧详情 永远一行显示 */}
<div style={{ display: 'flex', width: '100%', gap: 16, flexWrap: 'nowrap' }}>
{/* 左侧主内容区 */}
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ width: "100%" }}>
<Card style={{ borderRadius: 8, border: 'none', marginBottom: 16 }} bodyStyle={{ padding: '16px' }}>
<Row gutter={16} align="middle">
<Col><Select placeholder="告警级别" style={{ width: 120 }} /></Col>
<Col><Select placeholder="告警类型" style={{ width: 120 }} /></Col>
<Col><Select placeholder="设备类型" style={{ width: 120 }} /></Col>
<Col><RangePicker placeholder={['开始', '结束']} style={{ width: 240 }} /></Col>
<Col><Select placeholder="处理状态" style={{ width: 120 }} /></Col>
<Col flex="auto"><Input placeholder="搜索告警编号/内容/设备" style={{ width: '100%' }} /></Col>
<Col><Space><Button>重置</Button><Button type="primary">查询</Button></Space></Col>
</Row>
</Card>
<div style={{ display: "flex", gap: "16px", marginBottom: 16, width: "100%" }}>
<div style={{ flex: 1 }}><Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '12px 0 0 0' }}>
<Statistic title="今日告警总数" value={5} prefix={<BellOutlined style={{ color: '#ff4d4f' }} />} valueStyle={{ fontSize: 28, fontWeight: 700, color: '#ff4d4f' }} />
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>昨日 28</div>
</Card></div>
<div style={{ flex: 1 }}><Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
<Statistic title="严重告警" value={0} prefix={<ExclamationCircleOutlined style={{ color: '#ff4d4f' }} />} valueStyle={{ fontSize: 28, fontWeight: 700, color: '#ff4d4f' }} />
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>重要 2</div>
</Card></div>
<div style={{ flex: 1 }}><Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
<Statistic title="处理中" value={1} prefix={<ClockCircleOutlined style={{ color: '#faad14' }} />} valueStyle={{ fontSize: 28, fontWeight: 700, color: '#faad14' }} />
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>待处理 4</div>
</Card></div>
<div style={{ flex: 1 }}><Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
<Statistic title="已关闭" value={0} prefix={<CheckCircleOutlined style={{ color: '#52c41a' }} />} valueStyle={{ fontSize: 28, fontWeight: 700, color: '#52c41a' }} />
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>闭环完成</div>
</Card></div>
<div style={{ flex: 1 }}><Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
<Statistic title="平均响应" value="49分钟" prefix={<ClockCircleOutlined style={{ color: '#1890ff' }} />} valueStyle={{ fontSize: 28, fontWeight: 700, color: '#1890ff' }} />
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>时间估算</div>
</Card></div>
</div>
</div>
<div style={{ display: 'flex', gap: 16, width: '100%', flexWrap: 'nowrap', alignItems: 'stretch', marginBottom: 16 }}>
<div style={{ flex: 1, minWidth: 0 }}>
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 16, height: '100%' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
<div>
<Typography.Text strong style={{ fontSize: 16, color: '#0837A8', fontWeight: 800 }}>告警列表(共8条)</Typography.Text><br />
<Text type="secondary" style={{ fontSize: 12 }}>点击告警查看详情</Text>
</div>
</div>
<Table rowKey="id" columns={columns} dataSource={mockAlerts} pagination={{ pageSize: 8 }} scroll={{ x: 'max-content' }} style={{ width: '100%' }} />
</Card>
</div>
{detailVisible && selectedAlert && (
<div style={{ width: 360, flexShrink: 0, display: 'flex', flexDirection: 'column' }}>
<Card title="告警详情" bordered={false} style={{ borderRadius: 8, height: '100%', display: 'flex', flexDirection: 'column', overflow: 'hidden' }} bodyStyle={{ padding: '16px', display: 'flex', flexDirection: 'column', flex: 1, overflow: 'hidden' }}>
<div style={{ flex: 1, overflow: 'auto', paddingRight: 8 }}>
<div style={{ marginBottom: 20 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div style={{ display: 'flex', alignItems: 'center' }}>
<ExclamationCircleOutlined style={{ color: '#ff4d4f', marginRight: 8 }} />
<span style={{ fontSize: 16, fontWeight: 500 }}>{selectedAlert.content}</span>
</div>
<Tag color={levelColor[selectedAlert.level]}>{selectedAlert.level}</Tag>
</div>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>{selectedAlert.id}</div>
</div>
<div style={{ background: '#fafafa', borderRadius: 8, padding: 16, marginBottom: 16 }}>
<Row gutter={[16, 16]}>
<Col span={12}><div style={{ fontSize: 12, color: '#888' }}>来源设备</div><div>{selectedAlert.device}</div></Col>
<Col span={12}><div style={{ fontSize: 12, color: '#888' }}>发生时间</div><div>{selectedAlert.time}</div></Col>
<Col span={12}><div style={{ fontSize: 12, color: '#888' }}>持续时长</div><div>{selectedAlert.duration}</div></Col>
<Col span={12}><div style={{ fontSize: 12, color: '#888' }}>处理状态</div><div>{selectedAlert.status}</div></Col>
</Row>
</div>
<div style={{ marginBottom: 16 }}>
<div style={{ fontWeight: 500, marginBottom: 8 }}>根因分析建议</div>
<div style={{ fontSize: 12, color: '#666', lineHeight: 1.7 }}>
设备离线/网络异常<br />
电源或通讯模块故障<br />
现场信号弱或采集器异常
</div>
</div>
</div>
<div style={{ marginTop: 12, paddingTop: 12, borderTop: '1px solid #f0f0f0' }}>
<Space direction="vertical" style={{ width: '100%' }}>
<Button type="primary" block onClick={() => setConfirmModalVisible(true)}>确认告警</Button>
<Button block>标记处理中</Button>
<Button block danger>关闭告警</Button>
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col span={24}>
<Card bordered={false} bodyStyle={{ padding: '16px 24px' }} style={{ borderRadius: 8 }}>
<Row gutter={[24, 16]} align="middle">
<Col>
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>告警级别</div>
<Select defaultValue="全部" style={{ width: 120 }} options={[{ value: '全部', label: '全部' }]} />
</Col>
<Col>
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>告警类型</div>
<Select defaultValue="全部" style={{ width: 120 }} options={[{ value: '全部', label: '全部' }]} />
</Col>
<Col>
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>设备类型</div>
<Select defaultValue="全部" style={{ width: 120 }} options={[{ value: '全部', label: '全部' }]} />
</Col>
<Col>
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>时间范围</div>
<RangePicker showTime style={{ width: 320 }} defaultValue={[null, null]} />
</Col>
<Col>
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>处理状态</div>
<Select defaultValue="全部" style={{ width: 120 }} options={[{ value: '全部', label: '全部' }]} />
</Col>
<Col flex="auto">
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>搜索关键词</div>
<Input placeholder="请输入告警编号/内容" style={{ width: '100%' }} />
</Col>
<Col>
<div style={{ height: 22 }}></div>
<Space>
<Button style={{ borderRadius: 8 }}>重置</Button>
<Button type="primary" style={{ borderRadius: 8, background: '#165DFF' }}>查询</Button>
</Space>
</div>
</Card>
</div>
)}
</div>
</Col>
</Row>
</Card>
</Col>
</Row>
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col flex="1">
<Card bordered={false} bodyStyle={{ padding: 16 }} style={{ borderRadius: 8 }}>
<Row align="middle" gutter={16}>
<Col>
<div style={{ width: 48, height: 48, background: '#FFF1F0', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<BellOutlined style={{ fontSize: 24, color: '#F53F3F' }} />
</div>
</Col>
<Col>
<div style={{ fontSize: 14, color: '#4E5969' }}>今日告警总数</div>
<div style={{ display: 'flex', alignItems: 'baseline' }}>
<span style={{ fontSize: 28, fontWeight: 700, color: '#F53F3F', marginRight: 8 }}>36</span>
<span style={{ fontSize: 12, color: '#F53F3F' }}>较昨日 +28.6% ↑</span>
</div>
<div style={{ fontSize: 12, color: '#86909C' }}>昨日 28</div>
</Col>
</Row>
</Card>
</Col>
<Col flex="1">
<Card bordered={false} bodyStyle={{ padding: 16 }} style={{ borderRadius: 8 }}>
<Row align="middle" gutter={16}>
<Col>
<div style={{ width: 48, height: 48, background: '#FFF1F0', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<ExclamationCircleOutlined style={{ fontSize: 24, color: '#F53F3F' }} />
</div>
</Col>
<Col>
<div style={{ fontSize: 14, color: '#4E5969' }}>严重告警</div>
<div style={{ display: 'flex', alignItems: 'baseline' }}>
<span style={{ fontSize: 28, fontWeight: 700, color: '#F53F3F', marginRight: 8 }}>8</span>
<span style={{ fontSize: 12, color: '#F53F3F' }}>较昨日 +33.3% ↑</span>
</div>
<div style={{ fontSize: 12, color: '#86909C' }}>昨日 6</div>
</Col>
</Row>
</Card>
</Col>
<Col flex="1">
<Card bordered={false} bodyStyle={{ padding: 16 }} style={{ borderRadius: 8 }}>
<Row align="middle" gutter={16}>
<Col>
<div style={{ width: 48, height: 48, background: '#FFF7E8', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<ClockCircleOutlined style={{ fontSize: 24, color: '#FF7D00' }} />
</div>
</Col>
<Col>
<div style={{ fontSize: 14, color: '#4E5969' }}>处理中</div>
<div style={{ display: 'flex', alignItems: 'baseline' }}>
<span style={{ fontSize: 28, fontWeight: 700, color: '#FF7D00', marginRight: 8 }}>12</span>
<span style={{ fontSize: 12, color: '#FF7D00' }}>较昨日 +20.0% ↑</span>
</div>
<div style={{ fontSize: 12, color: '#86909C' }}>昨日 10</div>
</Col>
</Row>
</Card>
</Col>
<Col flex="1">
<Card bordered={false} bodyStyle={{ padding: 16 }} style={{ borderRadius: 8 }}>
<Row align="middle" gutter={16}>
<Col>
<div style={{ width: 48, height: 48, background: '#E8FFEA', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<CheckCircleOutlined style={{ fontSize: 24, color: '#00B42A' }} />
</div>
</Col>
<Col>
<div style={{ fontSize: 14, color: '#4E5969' }}>已关闭</div>
<div style={{ display: 'flex', alignItems: 'baseline' }}>
<span style={{ fontSize: 28, fontWeight: 700, color: '#00B42A', marginRight: 8 }}>16</span>
<span style={{ fontSize: 12, color: '#00B42A' }}>较昨日 +45.5% ↑</span>
</div>
<div style={{ fontSize: 12, color: '#86909C' }}>昨日 11</div>
</Col>
</Row>
</Card>
</Col>
<Col flex="1">
<Card bordered={false} bodyStyle={{ padding: 16 }} style={{ borderRadius: 8 }}>
<Row align="middle" gutter={16}>
<Col>
<div style={{ width: 48, height: 48, background: '#E8F3FF', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<ReloadOutlined style={{ fontSize: 24, color: '#165DFF' }} />
</div>
</Col>
<Col>
<div style={{ fontSize: 14, color: '#4E5969' }}>平均响应时长</div>
<div style={{ display: 'flex', alignItems: 'baseline' }}>
<span style={{ fontSize: 28, fontWeight: 700, color: '#165DFF', marginRight: 8 }}>18<span style={{ fontSize: 14 }}>分</span>32<span style={{ fontSize: 14 }}>秒</span></span>
</div>
<div style={{ fontSize: 12, color: '#86909C' }}>昨日 21分12秒</div>
</Col>
</Row>
</Card>
</Col>
</Row>
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col flex="auto" style={{ minWidth: 0 }}>
<Card bordered={false} bodyStyle={{ padding: '16px 24px' }} style={{ height: '100%', borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
<Title level={5} style={{ margin: 0, fontSize: 14, color: '#4E5969' }}>告警列表(共 36 条)</Title>
</div>
<Table
rowSelection={{ type: 'checkbox' }}
columns={columns}
dataSource={mockAlerts}
pagination={false}
size="middle"
scroll={{ x: 'max-content' }}
/>
<div style={{ display: 'flex', justifyContent: 'center', marginTop: 16 }}>
<Pagination total={36} showSizeChanger showQuickJumper defaultCurrent={1} size="small" />
</div>
</Card>
</Col>
</Row>
<Row gutter={16}>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="告警趋势" extra={<Button type="link">更多 </Button>}>
<Line {...trendConfig} height={180} />
<Card bordered={false} title={<span style={{ fontSize: 14, fontWeight: 700 }}>告警趋势</span>} extra={<Button type="link" size="small">更多 <RiseOutlined /></Button>} style={{ borderRadius: 8 }}>
<Line {...trendConfig} height={220} />
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="告警分类占比" extra={<Button type="link">更多 </Button>}>
<Pie {...pieConfig} height={180} />
<Card bordered={false} title={<span style={{ fontSize: 14, fontWeight: 700 }}>告警分类占比</span>} extra={<Button type="link" size="small">更多 <PieChartOutlined /></Button>} style={{ borderRadius: 8 }}>
<Pie {...pieConfig} height={220} />
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="告警来源设备分布" extra={<Button type="link">更多</Button>}>
<Bar {...barConfig} height={180} />
<Card bordered={false} title={<span style={{ fontSize: 14, fontWeight: 700 }}>告警来源设备分布</span>} extra={<Button type="link" size="small">更多 <BarChartOutlined /></Button>} style={{ borderRadius: 8 }}>
<Bar {...barConfig} height={220} />
</Card>
</Col>
</Row>
</div>
{/* 🔥 右侧详情:丝滑滑入动画 */}
{detailVisible && selectedAlert && (
<div
style={{
width: 380,
flexShrink: 0,
animation: detailVisible ? 'slideIn 0.3s ease-out forwards' : 'none',
}}
>
<style>
{`
@keyframes slideIn {
from { transform: translateX(40px); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
`}
</style>
<Card
bordered={false}
title={<span style={{ fontSize: 14, fontWeight: 700 }}>告警详情</span>}
extra={<CloseOutlined style={{ cursor: 'pointer' }} onClick={() => setDetailVisible(false)} />}
bodyStyle={{ padding: 16 }}
style={{ height: '100%', borderRadius: 8 }}
>
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 20 }}>
<div style={{ width: 40, height: 40, background: '#FFF1F0', borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center', marginRight: 12 }}>
<ExclamationCircleOutlined style={{ fontSize: 20, color: '#F53F3F' }} />
</div>
<div style={{ flex: 1 }}>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
<span style={{ fontSize: 16, fontWeight: 700 }}>{selectedAlert.content}</span>
<Tag color={levelColor[selectedAlert.level]} style={{ borderRadius: 2, border: 'none', color: '#fff' }}>{selectedAlert.level}</Tag>
</div>
<div style={{ fontSize: 12, color: '#86909C' }}>告警编号:{selectedAlert.id}</div>
</div>
</div>
<Row gutter={[16, 12]} style={{ marginBottom: 24 }}>
<Col span={12}><div style={{ fontSize: 12, color: '#86909C' }}>来源设备</div><div style={{ fontSize: 13 }}>{selectedAlert.device}</div></Col>
<Col span={12}><div style={{ fontSize: 12, color: '#86909C' }}>设备类型</div><div style={{ fontSize: 13 }}>逆变器</div></Col>
<Col span={12}><div style={{ fontSize: 12, color: '#86909C' }}>发生时间</div><div style={{ fontSize: 13 }}>{selectedAlert.time}</div></Col>
<Col span={12}><div style={{ fontSize: 12, color: '#86909C' }}>持续时长</div><div style={{ fontSize: 13 }}>{selectedAlert.duration}</div></Col>
<Col span={12}><div style={{ fontSize: 12, color: '#86909C' }}>处理状态</div><Tag color="blue" style={{ border: 'none' }}>{selectedAlert.status}</Tag></Col>
<Col span={12}>
<div style={{ fontSize: 12, color: '#86909C' }}>负责人</div>
<div style={{ display: 'flex', alignItems: 'center' }}>
<span style={{ fontSize: 13, marginRight: 8 }}>{selectedAlert.handler}</span>
<Button type="link" size="small" style={{ padding: 0 }}>转派</Button>
</div>
</Col>
<Col span={24}><div style={{ fontSize: 12, color: '#86909C' }}>当前处理人</div><div style={{ fontSize: 13 }}>张运维 (2025-05-25 09:22 接收)</div></Col>
<Col span={24}><div style={{ fontSize: 12, color: '#86909C' }}>告警描述</div><div style={{ fontSize: 13 }}>逆变器因内部故障自动停机,当前无功率输出。</div></Col>
</Row>
<Divider style={{ margin: '16px 0' }} />
<div style={{ marginBottom: 20 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12 }}>
<span style={{ fontSize: 14, fontWeight: 700 }}>根因分析建议</span>
<Button size="small" type="primary" ghost icon={<InfoCircleOutlined />} style={{ fontSize: 12 }}>AI 诊断分析</Button>
</div>
<ol style={{ paddingLeft: 16, fontSize: 12, color: '#4E5969', lineHeight: '20px' }}>
<li>逆变器内部保护触发 (IGBT/继电器故障)</li>
<li>交流侧电压异常或并网不稳定</li>
<li>散热风扇故障导致过温保护</li>
</ol>
</div>
<div style={{ marginBottom: 20 }}>
<div style={{ fontSize: 14, fontWeight: 700, marginBottom: 12 }}>相关趋势</div>
<Line {...detailTrendConfig} height={160} />
</div>
<div style={{ marginBottom: 24 }}>
<div style={{ fontSize: 14, fontWeight: 700, marginBottom: 12 }}>推荐处理措施</div>
<ul style={{ paddingLeft: 16, fontSize: 12, color: '#4E5969', lineHeight: '20px', listStyleType: 'decimal' }}>
<li>现场检查逆变器告警记录及指示灯状态;</li>
<li>检查散热风扇运行及通风条件;</li>
<li>检查交流侧电压及并网条件;</li>
<li>如无法恢复,建议联系厂家或更换模块。</li>
</ul>
<div style={{ textAlign: 'right', marginTop: 8 }}>
<Button type="primary" size="small">生成工单</Button>
</div>
</div>
<div style={{ marginBottom: 24 }}>
<div style={{ fontSize: 14, fontWeight: 700, marginBottom: 12 }}>通知与订阅</div>
<Row align="middle" gutter={16} style={{ fontSize: 12 }}>
<Col><Space><MessageOutlined style={{ color: '#00B42A' }} />短信</Space> <Switch size="small" defaultChecked /></Col>
<Col><Space><DesktopOutlined style={{ color: '#165DFF' }} />Telegram</Space> <Switch size="small" defaultChecked /></Col>
<Col><Space><MailOutlined style={{ color: '#FF7D00' }} />邮件</Space> <Switch size="small" defaultChecked /></Col>
</Row>
</div>
<Button type="primary" block style={{ height: 40, background: '#165DFF', borderRadius: 4 }}>标记为已解决</Button>
</Card>
</div>
)}
</div>
{/* 确认告警弹窗 */}
<Modal
title="确认告警"
open={confirmModalVisible}

View File

@@ -15,30 +15,15 @@ import {
} from '@ant-design/icons';
import { useSelector } from 'react-redux';
import { getDeviceListApi, getPlaneDeviceList } from '../../api/device.ts';
import { getDeviceListApi, getLiveStream, getPlaneDeviceList } from '../../api/device.ts';
import { RootState } from '@/src/store';
import DroneLivePlayer from '../VolcRtcPlayer.jsx';
const { Content } = Layout;
const { Text, Title } = Typography;
// 模拟数据
const topCards = [
{ title: '无人机机场状态', icon: <EnvironmentOutlined />, value: '2 / 2', desc: '在线', sub: '可调度 2 架', color: '#1890ff' },
{ title: '巡检机器人', icon: <RobotOutlined />, value: '3 台', desc: '', sub: '执行中 2', color: '#722ed1' },
{ title: '除草机器人', icon: <BranchesOutlined />, value: '2 台', desc: '', sub: '作业中 1', color: '#13c2c2' },
{ title: '清洗无人机', icon: <CloudOutlined />, value: '2 架', desc: '', sub: '待命 1', color: '#eb2f96' },
{ title: '设备平均电量', icon: <ThunderboltOutlined />, value: '86%', desc: '', sub: '', color: '#52c41a' },
{ title: '今日任务执行', icon: <CheckCircleOutlined />, 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: <EnvironmentOutlined />, value: `${onlineDrones} / ${totalDrones}`, desc: onlineDrones > 0 ? '在线' : '离线', sub: `可调度 ${onlineDrones} 架`, color: '#1890ff' },
//{ title: '巡检机器人', icon: <RobotOutlined />, value: `${totalRobots} 台`, desc: '', sub: `执行中 ${activeRobots}`, color: '#722ed1' },
{ title: '机器人', icon: <BranchesOutlined />, value: `${totalMowers} 台`, desc: '', sub: `作业中 ${activeMowers}`, color: '#13c2c2' },
{ title: '无人机', icon: <CloudOutlined />, value: `${totalDrones} 架`, desc: '', sub: `待命 ${planedevices?.filter(d => d.productName?.includes('清洗') && d.onlineStatus === 1).length || 0}`, color: '#eb2f96' },
{ title: '设备平均电量', icon: <ThunderboltOutlined />, value: '86%', desc: '', sub: '', color: '#52c41a' },
{ title: '今日任务执行', icon: <CheckCircleOutlined />, 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 (
<Content style={{ maxWidth: 1800, margin: '0 auto', }}>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '16px', marginBottom: 20 }}>
{topCards.map((card, idx) => (
{dynamicTopCards.map((card, idx) => (
<div key={idx} style={{ flex: 1 }}>
<Card bordered={false} style={{ borderRadius: 12, boxShadow: '0 2px 8px rgba(0,0,0,0.05)', height: '110px', display: 'flex', alignItems: 'center' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 12, width: '100%' }}>
@@ -143,19 +174,19 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll }
</Card>
<Card title={<><SettingOutlined /> 装备调度列表</>} bordered={false} style={{ borderRadius: 12, marginBottom: 16 }}>
<Table rowKey="id" size="small" pagination={false}
<Table rowKey={(record) => 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 => <Tag color={s === '作业中' ? 'processing' : s === '在线' ? 'success' : 'default'}>{s}</Tag> },
{ title: '当前状态', dataIndex: 'status', width: 80, render: s => <Tag color={s === '作业中' || s === '在线' ? 'success' : 'default'}>{s}</Tag> },
{ title: '模式', dataIndex: 'mode', width: 80 },
{ title: '电量', dataIndex: 'battery', width: 80, render: v => <Progress percent={v} size="small" status={v < 40 ? 'exception' : 'active'} /> },
{ title: '位置', dataIndex: 'position', width: 100 },
{ title: '当前任务', dataIndex: 'task', width: 120 },
{ title: '通讯状态', dataIndex: 'comm', width: 80, render: v => <Badge status="success" text={v} /> },
{ title: '通讯状态', dataIndex: 'comm', width: 80, render: v => <Badge status={v.includes('-') ? 'warning' : 'success'} text={v} /> },
{ title: '操作', key: 'action', width: 100, render: () => <Space><Button size="small" type="text" icon={<EditOutlined />} /><Button size="small" type="text" icon={<SettingOutlined />} /></Space> }
]}
dataSource={scheduleList}
dataSource={dynamicScheduleList}
scroll={{ x: 'max-content' }}
/>
</Card>
@@ -177,91 +208,78 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll }
<Col xs={24} lg={10}>
<Card title={<> 设备控制面板</>} bordered={false} style={{ borderRadius: 12, marginBottom: 16 }} bodyStyle={{ padding: 16, paddingBottom: 0 }}>
<Select
style={{ width: 180, marginBottom: 10 }}
style={{ width: 220, marginBottom: 10 }}
placeholder="请选择设备"
value={selectedDevice}
value={selectedDevice?.device_sn || selectedDevice?.serialNumber}
onChange={handleDeviceChange}
showSearch // 👈 开启搜索
allowClear // 允许删除/清空
optionFilterProp="label" // 👈 按设备名称搜索
filterOption={(input, option) =>
option.label.toLowerCase().includes(input.toLowerCase())
}
options={devicesAll.map(item => ({
value: item.device_sn,
label: item.callsign || '未知设备'
value: item.device_sn || item.serialNumber,
label: item.deviceAlias || item.drone_callsign || item.callsign || item.deviceName || '未知设备'
}))}
/>
{currentDevice && (
{selectedDevice && (
<Row gutter={16}>
<Col span={12}>
<div style={{ marginBottom: 24 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 16 }}>
<span style={{ fontSize: 24, color: '#1890ff' }}><RocketOutlined /></span>
<span style={{ fontSize: 16, fontWeight: 600 }}>{currentDevice.drone_callsign || currentDevice.callsign}</span>
<Tag color={currentDevice.onlineStatus === 1 ? "success" : "default"} size="small">
{currentDevice.onlineStatus == 1 ? "在线" : "离线"}
<span style={{ fontSize: 16, fontWeight: 600 }}>{selectedDevice.deviceAlias || selectedDevice.drone_callsign || selectedDevice.callsign || selectedDevice.deviceName}</span>
<Tag color={selectedDevice.onlineStatus === 1 ? "success" : "default"} size="small">
{selectedDevice.onlineStatus == 1 ? "在线" : "离线"}
</Tag>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 6 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
<span style={{ color: '#52c41a' }}><ThunderboltOutlined /></span>
<span style={{ fontSize: 12 }}>电量 {fix2(currentDevice.capacity_percent)}%</span>
<span style={{ fontSize: 12 }}>电量 {fix2(selectedDevice.capacity_percent || 100)}%</span>
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
<span style={{ fontSize: 12 }}>温度</span>
<span style={{ color: '#faad14' }}>{fix2(currentDevice.environment_temperature)}℃</span>
<span style={{ color: '#faad14' }}>{fix2(selectedDevice.environment_temperature || 25)}℃</span>
</div>
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, marginBottom: 12, maxHeight: "100px", overflow: "auto", scrollbarWidth: 'thin', scrollbarColor: '#ccc transparent' }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>机场编号</span>
<span style={{ fontSize: 12 }}>{getVal(currentDevice.gateway_sn)}</span>
<span style={{ color: '#666', fontSize: 12 }}>产品类型</span>
<span style={{ fontSize: 12 }}>{getVal(selectedDevice.productName)}</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>设备SN</span>
<span style={{ fontSize: 12 }}>{getVal(currentDevice.device_sn)}</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>高度</span>
<span style={{ fontSize: 12 }}>{fix2(currentDevice.height)} m</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>风速</span>
<span style={{ fontSize: 12 }}>{fix2(currentDevice.wind_speed)} m/s</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>离家距离</span>
<span style={{ fontSize: 12 }}>{fix2(currentDevice.home_distance)} m</span>
</div>
{/* 经纬度 */}
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>经纬度</span>
<span style={{ fontSize: 12 }}>{(fix2(currentDevice.longitude), fix2(currentDevice.latitude))}</span>
</div>
{/* 无人机状态 */}
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>信号</span>
<span style={{ fontSize: 12 }}>
{currentDevice.network_state?.quality === 'good' ? '好' : currentDevice.network_state?.quality === 'better' ? '较好' : currentDevice.network_state?.quality === 'moderate' ? '一般' : currentDevice.network_state?.quality === 'poor' ? '较差' : currentDevice.network_state?.quality === 'too_pool' ? '差' : '无信号'}
</span>
</div>
{/* RTK 信息 */}
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#1890ff', fontSize: 12 }}>RTK 状态</span>
<span style={{ fontSize: 12 }}>
{currentDevice.position_state?.is_fixed === 'fixing_successful' ? '固定' : '未固定'}
</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>GPS卫星</span>
<span style={{ fontSize: 12 }}>{getVal(currentDevice.position_state?.gps_number)}</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>RTK卫星</span>
<span style={{ fontSize: 12 }}>{getVal(currentDevice.position_state?.rtk_number)}</span>
<span style={{ fontSize: 12 }}>{getVal(selectedDevice.device_sn || selectedDevice.serialNumber)}</span>
</div>
{selectedDevice.activeTime && (
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>激活时间</span>
<span style={{ fontSize: 12 }}>{selectedDevice.activeTime}</span>
</div>
)}
{selectedDevice.firmwareVersion && (
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>固件版本</span>
<span style={{ fontSize: 12 }}>v{selectedDevice.firmwareVersion}</span>
</div>
)}
{selectedDevice.device_sn && (
<>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>高度</span>
<span style={{ fontSize: 12 }}>{fix2(selectedDevice.height)} m</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>风速</span>
<span style={{ fontSize: 12 }}>{fix2(selectedDevice.wind_speed)} m/s</span>
</div>
</>
)}
</div>
@@ -280,10 +298,12 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll }
<span style={{ fontSize: 14, fontWeight: 500, color: "#666" }}>实时画面</span>
<span style={{ fontSize: 13, color: '#999' }}>实时监控</span>
</div>
<div style={{ width: '100%', height: 160, background: '#000 url(https://picsum.photos/seed/droneview/800/400) center/cover', borderRadius: 8, position: 'relative', overflow: 'hidden' }}>
<div style={{ width: '100%', height: 160, borderRadius: 8, position: 'relative', overflow: 'hidden', background: '#000' }}>
<DroneLivePlayer streamData={planeVideo?.[0] || null} />
<div style={{ position: 'absolute', bottom: 0, left: 0, right: 0, background: 'rgba(0,0,0,0.6)', color: '#fff', display: 'flex', justifyContent: 'space-between', padding: '8px 12px', fontSize: 14 }}>
<span>高度 {fix2(currentDevice.height)}m</span>
<span>风速 {fix2(currentDevice.wind_speed)}m/s</span>
<span>高度 {fix2(selectedDevice.height)}m</span>
<span>风速 {fix2(selectedDevice.wind_speed)}m/s</span>
</div>
</div>
</div>
@@ -309,15 +329,15 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll }
<div style={{ marginBottom: 12 }}>
<div style={{ fontSize: 16, fontWeight: 600, color: '#1890ff', marginBottom: 12 }}>建议操作</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 2, padding: '16px', borderRadius: 12, border: '1px solid #e8e8e8' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}><div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ color: '#1890ff' }}>⦿</span><span style={{ fontSize: 16 }}>优先执行巡检航线 P-03</span></div><svg t="1778317171240" className="icon" viewBox="0 0 1024 1024" width="20" height="20"><path d="M384.32 797.512a30.088 30.088 0 0 1-21.288-51.392L597.144 512 363.032 277.816a30.088 30.088 0 0 1 0-42.568 30.088 30.088 0 0 1 42.568 0l255.392 255.464a30.088 30.088 0 0 1 0 42.568L405.6 788.696a30.04 30.04 0 0 1-21.28 8.816z" fill="#666666"></path></svg></div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}><div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ color: '#1890ff' }}>⦿</span><span style={{ fontSize: 16 }}>先行安排除草任务 G-02</span></div><svg t="1778317171240" className="icon" viewBox="0 0 1024 1024" width="20" height="20"><path d="M384.32 797.512a30.088 30.088 0 0 1-21.288-51.392L597.144 512 363.032 277.816a30.088 30.088 0 0 1 0-42.568 30.088 30.088 0 0 1 42.568 0l255.392 255.464a30.088 30.088 0 0 1 0 42.568L405.6 788.696a30.04 30.04 0 0 1-21.28 8.816z" fill="#666666"></path></svg></div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}><div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ color: '#1890ff' }}>⦿</span><span style={{ fontSize: 16 }}>建议生成清洗工单</span></div><svg t="1778317171240" className="icon" viewBox="0 0 1024 1024" width="20" height="20"><path d="M384.32 797.512a30.088 30.088 0 0 1-21.288-51.392L597.144 512 363.032 277.816a30.088 30.088 0 0 1 0-42.568 30.088 30.088 0 0 1 42.568 0l255.392 255.464a30.088 30.088 0 0 1 0 42.568L405.6 788.696a30.04 30.04 0 0 1-21.28 8.816z" fill="#666666"></path></svg></div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}><div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ color: '#1890ff' }}>⦿</span><span style={{ fontSize: 16 }}>优先执行巡检航线 P-03</span></div><ArrowRightOutlined style={{ color: '#666' }} /></div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}><div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ color: '#1890ff' }}>⦿</span><span style={{ fontSize: 16 }}>先行安排除草任务 G-02</span></div><ArrowRightOutlined style={{ color: '#666' }} /></div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}><div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ color: '#1890ff' }}>⦿</span><span style={{ fontSize: 16 }}>建议生成清洗工单</span></div><ArrowRightOutlined style={{ color: '#666' }} /></div>
</div>
</div>
</Col>
<Col span={10}>
<div style={{ display: 'flex', flexDirection: 'column', paddingBottom: "12px", gap: 16, height: '100%', justifyContent: "end" }}>
<div style={{ display: 'flex', gap: 12 }}>
<div style={{ display: 'flex', gap: 12, flexWrap: "wrap" }}>
<Button type="primary" size="large" style={{ flex: 1, borderRadius: 8, fontSize: 16 }}>生成任务</Button>
<Button size="large" style={{ flex: 1, borderRadius: 8, fontSize: 16, border: '1px solid #1890ff', color: '#1890ff' }}>AI优化路径</Button>
</div>
@@ -330,10 +350,10 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll }
<Card title="环境与飞行条件" bordered={false} style={{ borderRadius: 12, marginBottom: 16 }}>
<div style={{ display: "flex", justifyContent: "space-between", gap: 12, alignItems: "center" }}>
<div style={{ display: "flex", border: "1px solid #e8e8e8", borderRadius: 12, overflow: "hidden", flex: 1 }}>
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px", borderRight: "1px solid #e8e8e8" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>风速</div><div style={{ fontSize: 14, fontWeight: 700, color: '#222', marginTop: 2 }}>{fix2(currentDevice?.wind_speed)} m/s</div></div>
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px", borderRight: "1px solid #e8e8e8" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>温度</div><div style={{ fontSize: 14, fontWeight: 700, color: '#222', marginTop: 2 }}>{fix2(currentDevice?.environment_temperature)}℃</div></div>
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px", borderRight: "1px solid #e8e8e8" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>降雨</div><div style={{ fontSize: 14, fontWeight: 700, color: '#222', marginTop: 2 }}>{getVal(currentDevice?.rainfall)}</div></div>
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>RTK</div><div style={{ fontSize: 14, fontWeight: 700, color: '#52c41a', marginTop: 2 }}>{currentDevice?.position_state?.is_fixed === 'fixing_successful' ? '固定' : '未固定'}</div></div>
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px", borderRight: "1px solid #e8e8e8" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>风速</div><div style={{ fontSize: 14, fontWeight: 700, color: '#222', marginTop: 2 }}>{fix2(selectedDevice?.wind_speed)} m/s</div></div>
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px", borderRight: "1px solid #e8e8e8" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>温度</div><div style={{ fontSize: 14, fontWeight: 700, color: '#222', marginTop: 2 }}>{fix2(selectedDevice?.environment_temperature)}℃</div></div>
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px", borderRight: "1px solid #e8e8e8" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>降雨</div><div style={{ fontSize: 14, fontWeight: 700, color: '#222', marginTop: 2 }}>{getVal(selectedDevice?.rainfall)}</div></div>
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>RTK</div><div style={{ fontSize: 14, fontWeight: 700, color: '#52c41a', marginTop: 2 }}>{selectedDevice?.position_state?.is_fixed === 'fixing_successful' ? '固定' : '未固定'}</div></div>
</div>
<div style={{ width: 110, padding: '12px 8px', borderRadius: 8, background: '#f6ffed', border: '1px solid #b7eb8f', textAlign: 'center', display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 4 }}>
<div style={{ fontSize: 14, fontWeight: 700, color: '#52c41a' }}>适宜执行</div>

View File

@@ -0,0 +1,34 @@
import VERTC, { RoomProfileType, StreamIndex } from "@volcengine/rtc";
let engine;
export async function joinRoom(container, appId, roomId, token, userId) {
console.info('joinRoom...');
const engine = VERTC.createEngine(appId);
await engine.joinRoom(token, roomId, { userId }, {
isAutoPublish: true,
isAutoSubscribeAudio: true,
isAutoSubscribeVideo: true,
roomProfileType: RoomProfileType.meeting,
});
engine.on(VERTC.events.onUserPublishStream, async (e) => {
if (!container) return;
// 清空旧内容
container.innerHTML = '';
await engine.setUserVisibility(false);
engine.setRemoteVideoPlayer(StreamIndex.STREAM_INDEX_MAIN, {
userId: e.userId,
renderDom: container,
visible: true,
});
});
}
export async function leaveRoom() {
if (engine) await engine.leaveRoom();
}

View File

@@ -1,548 +1,446 @@
import React, { useState } from 'react';
import {
Row, Col, Card, Button, Tag, Table, Drawer, Typography, Space, Statistic, message
Row, Col, Card, Button, Tag, Table, Typography, Space, Statistic, message, Divider, Tooltip
} from 'antd';
import { ReloadOutlined, PlusOutlined, ArrowDownOutlined, ArrowUpOutlined, CheckCircleOutlined, ExclamationCircleOutlined, LineHeightOutlined } from '@ant-design/icons';
import { Line, Bar, Pie } from '@ant-design/charts';
import he from '@/dist/assets/Organization-irk1gmLc';
import {
ReloadOutlined, InfoCircleOutlined, ThunderboltOutlined,
LineChartOutlined, AppstoreOutlined, BellOutlined,
CheckCircleOutlined, CalendarOutlined, ArrowUpOutlined,
ArrowDownOutlined, RiseOutlined, FallOutlined, ScanOutlined,
DatabaseOutlined, CloudOutlined, RestOutlined
} from '@ant-design/icons';
import { Line, Area } from '@ant-design/charts';
const { Title, Text } = Typography;
// 模拟数据
const aiSummaryData = [
{ diagnosis: '热斑检测', status: '异常', confidence: '92%', impact: '高', conclusion: '检测到36处热斑疑似点' },
{ diagnosis: '组串失配', status: '异常', confidence: '90%', impact: '高', conclusion: '8串组串存在异常' },
{ diagnosis: '遮挡风险', status: '轻微', confidence: '78%', impact: '中', conclusion: '局部遮挡影响2%发电量' },
{ diagnosis: '组件衰减', status: '异常', confidence: '86%', impact: '中', conclusion: '平均衰减率-5.32%' },
{ diagnosis: '逆变器效率', status: '正常', confidence: '93%', impact: '低', conclusion: '运行效率稳定' },
{ diagnosis: '清洗收益', status: '建议', confidence: '88%', impact: '中', conclusion: '建议优先清洗B区' },
{ key: '1', diagnosis: '热斑检测', status: '异常', confidence: '92%', impact: '高', conclusion: '检测到 36 处热斑疑似点' },
{ key: '2', diagnosis: '组串失配', status: '异常', confidence: '90%', impact: '高', conclusion: '8 串组串存在异常' },
{ key: '3', diagnosis: '遮挡风险', status: '轻微', confidence: '78%', impact: '中', conclusion: '局部遮挡影响 2% 发电量' },
{ key: '4', diagnosis: '组件衰减', status: '异常', confidence: '86%', impact: '中', conclusion: '平均衰减率 -5.32%' },
{ key: '5', diagnosis: '逆变器效率异常', status: '正常', confidence: '93%', impact: '低', conclusion: '所有逆变器运行正常' },
];
const aiRecommendations = [
{ measure: '处理劣质组件', priority: '高', expectedGain: '+2.15%', confidence: '92%' },
{ measure: '排查异常组串', priority: '高', expectedGain: '+1.85%', confidence: '90%' },
{ measure: '清洗受遮挡区域', priority: '中', expectedGain: '+0.45%', confidence: '78%' },
{ measure: '跟踪衰减组件', priority: '中', expectedGain: '+0.35%', confidence: '86%' },
{ measure: '持续监控逆变器效率', priority: '低', expectedGain: '+0.10%', confidence: '93%' },
{ measure: '复核电压波动点', priority: '中', expectedGain: '+0.28%', confidence: '82%' },
{ key: '1', measure: '处理热斑组件', priority: '高', expectedGain: '+2.15%', confidence: '92%' },
{ key: '2', measure: '排查异常组串', priority: '高', expectedGain: '+1.85%', confidence: '90%' },
{ key: '3', measure: '清洗受遮挡区域', priority: '中', expectedGain: '+0.45%', confidence: '78%' },
{ key: '4', measure: '跟踪衰减较大组件', priority: '中', expectedGain: '+0.35%', confidence: '86%' },
{ key: '5', measure: '持续监控逆变器效率', priority: '低', expectedGain: '+0.10%', confidence: '93%' },
];
const thermalImagingData = [
{ title: '热斑异常', name: '方阵A-05', temp: '71.5℃', image: '' },
{ title: '高温风险', name: '方阵A-12', temp: '68.3℃', image: '' },
{ title: '疑似遮挡', name: '方阵B-03', temp: '64.8℃', image: '' },
{ title: '热斑异常', name: '方阵C-07', temp: '67.2℃', image: '' },
{ title: '轻微升温', name: '方阵D-11', temp: '58.9℃', image: '' },
{ title: '组件衰减', name: '方阵E-18', temp: '62.4℃', image: '' },
{ name: '方阵 A-05', temp: '71.5℃', id: 'A05' },
{ name: '方阵 A-12', temp: '68.3℃', id: 'A12' },
{ name: '方阵 B-03', temp: '64.8℃', id: 'B03' },
{ name: '方阵 C-07', temp: '67.2℃', id: 'C07' },
];
// 图表配置
const degradationConfig = {
data: [
{ date: 'D1', 平均衰减率: 0, 最佳组件: 0, 最差组件: -1 },
{ date: 'D4', 平均衰减率: -1, 最佳组件: -0.5, 最差组件: -2 },
{ date: 'D7', 平均衰减率: -1.5, 最佳组件: -0.8, 最差组件: -3 },
{ date: 'D10', 平均衰减率: -2, 最佳组件: -1, 最差组件: -4 },
{ date: 'D13', 平均衰减率: -2.5, 最佳组件: -1.2, 最差组件: -5 },
{ date: 'D16', 平均衰减率: -3, 最佳组件: -1.5, 最差组件: -6 },
{ date: 'D19', 平均衰减率: -3.5, 最佳组件: -1.8, 最差组件: -7 },
{ date: 'D22', 平均衰减率: -4, 最佳组件: -2, 最差组件: -8 },
{ date: 'D25', 平均衰减率: -4.5, 最佳组件: -2.2, 最差组件: -9 },
{ date: 'D28', 平均衰减率: -5.32, 最佳组件: -2.5, 最差组件: -10 },
{ date: '2024-01', type: '平均衰减率', value: 0 },
{ date: '2024-04', type: '平均衰减率', value: -1.2 },
{ date: '2024-07', type: '平均衰减率', value: -2.5 },
{ date: '2024-10', type: '平均衰减率', value: -3.8 },
{ date: '2025-01', type: '平均衰减率', value: -4.5 },
{ date: '2025-05', type: '平均衰减率', value: -5.32 },
{ date: '2024-01', type: '最佳组件', value: 0 },
{ date: '2024-04', type: '最佳组件', value: -0.5 },
{ date: '2024-07', type: '最佳组件', value: -1.0 },
{ date: '2024-10', type: '最佳组件', value: -1.5 },
{ date: '2025-01', type: '最佳组件', value: -2.0 },
{ date: '2025-05', type: '最佳组件', value: -2.5 },
{ date: '2024-01', type: '最差组件', value: -1.0 },
{ date: '2024-04', type: '最差组件', value: -2.5 },
{ date: '2024-07', type: '最差组件', value: -4.0 },
{ date: '2024-10', type: '最差组件', value: -6.5 },
{ date: '2025-01', type: '最差组件', value: -8.0 },
{ date: '2025-05', type: '最差组件', value: -10.2 },
],
xField: 'date',
yField: ['平均衰减率', '最佳组件', '最差组件'],
color: ['#1890ff', '#52c41a', '#faad14'],
yField: 'value',
seriesField: 'type',
color: ['#165DFF', '#00B42A', '#F53F3F'],
smooth: true,
areaStyle: { fillOpacity: 0.15 },
legend: { position: 'top-left' },
lineStyle: (type: string) => {
if (type === '最差组件') return { lineDash: [4, 4] };
return { lineWidth: 2 };
},
legend: { position: 'top' },
yAxis: { label: { formatter: (v: string) => `${v}%` } },
};
const generationConfig = {
const generationPerformanceConfig = {
data: [
{ time: '00:00', 实际发电: 50, 预测发电: 60, 理论发电: 80 },
{ time: '03:00', 实际发电: 50, 预测发电: 60, 理论发电: 80 },
{ time: '06:00', 实际发电: 100, 预测发电: 120, 理论发电: 150 },
{ time: '09:00', 实际发电: 800, 预测发电: 900, 理论发电: 1000 },
{ time: '12:00', 实际发电: 1400, 预测发电: 1600, 理论发电: 1800 },
{ time: '15:00', 实际发电: 1200, 预测发电: 1400, 理论发电: 1600 },
{ time: '18:00', 实际发电: 600, 预测发电: 700, 理论发电: 800 },
{ time: '21:00', 实际发电: 100, 预测发电: 120, 理论发电: 150 },
{ time: '24:00', 实际发电: 50, 预测发电: 60, 理论发电: 80 },
{ time: '27:00', 实际发电: 50, 预测发电: 60, 理论发电: 80 },
{ time: '00:00', type: '实际发电', value: 0 },
{ time: '03:00', type: '实际发电', value: 0 },
{ time: '06:00', type: '实际发电', value: 100 },
{ time: '09:00', type: '实际发电', value: 800 },
{ time: '12:00', type: '实际发电', value: 1400 },
{ time: '15:00', type: '实际发电', value: 1200 },
{ time: '18:00', type: '实际发电', value: 400 },
{ time: '21:00', type: '实际发电', value: 0 },
{ time: '24:00', type: '实际发电', value: 0 },
{ time: '00:00', type: '预测发电', value: 0 },
{ time: '03:00', type: '预测发电', value: 0 },
{ time: '06:00', type: '预测发电', value: 150 },
{ time: '09:00', type: '预测发电', value: 950 },
{ time: '12:00', type: '预测发电', value: 1650 },
{ time: '15:00', type: '预测发电', value: 1350 },
{ time: '18:00', type: '预测发电', value: 550 },
{ time: '21:00', type: '预测发电', value: 0 },
{ time: '24:00', type: '预测发电', value: 0 },
{ time: '00:00', type: '理论发电', value: 0 },
{ time: '03:00', type: '理论发电', value: 0 },
{ time: '06:00', type: '理论发电', value: 200 },
{ time: '09:00', type: '理论发电', value: 1100 },
{ time: '12:00', type: '理论发电', value: 1800 },
{ time: '15:00', type: '理论发电', value: 1500 },
{ time: '18:00', type: '理论发电', value: 650 },
{ time: '21:00', type: '理论发电', value: 0 },
{ time: '24:00', type: '理论发电', value: 0 },
],
xField: 'time',
yField: ['实际发电', '预测发电', '理论发电'],
color: ['#1890ff', '#52c41a', '#faad14'],
yField: 'value',
seriesField: 'type',
color: ['#165DFF', '#00B42A', '#86909C'],
smooth: true,
areaStyle: { fillOpacity: 0.15 },
lineStyle: (type: string) => {
if (type === '理论发电') return { lineDash: [4, 4] };
return { lineWidth: 2 };
},
legend: { position: 'top' },
};
export default function AIDiagnosisPage() {
const [drawerVisible, setDrawerVisible] = useState(false);
const [selectedTask, setSelectedTask] = useState<any>(null);
const cardStyle = { borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.05)' };
// 状态标签渲染
const renderStatusTag = (status: string) => {
const statusMap: Record<string, React.ReactNode> = {
'异常': <Tag color="red">异常</Tag>,
'正常': <Tag color="green">正常</Tag>,
'轻微': <Tag color="orange">轻微</Tag>,
'建议': <Tag color="blue">建议</Tag>,
const colorMap: Record<string, string> = {
'异常': '#F53F3F',
'正常': '#00B42A',
'轻微': '#F7BA1E',
};
return statusMap[status] || <Tag>{status}</Tag>;
return <span style={{ color: colorMap[status] }}>{status}</span>;
};
const renderPriorityTag = (priority: string) => {
const colorMap: Record<string, string> = { '高': 'red', '中': 'orange', '低': 'green' };
return <Tag color={colorMap[priority]}>{priority}</Tag>;
const renderImpactTag = (impact: string) => {
const colorMap: Record<string, string> = { '高': '#F53F3F', '中': '#FF7D00', '低': '#00B42A' };
return <span style={{ color: colorMap[impact] }}>{impact}</span>;
};
return (
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: 24 }}>
{/* 顶部标题和操作 */}
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 24 }}>
<div>
<Title level={4} style={{ margin: 0 }}>AI诊断分析</Title>
<Text type="secondary">无人机热成像、组串异常定位、发电偏差与AI处置建议</Text>
</div>
<Space>
<Button icon={<ReloadOutlined />}>刷新</Button>
<Button type="primary" icon={<PlusOutlined />}>新建诊断任务</Button>
</Space>
</div>
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: '16px 24px' }}>
{/* 顶部指标卡片 */}
<Row gutter={16} style={{ marginBottom: 24 }}>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="PR值"
value={82.6}
precision={1}
suffix="%"
valueStyle={{ color: '#52c41a', fontSize: 28, fontWeight: 700 }}
prefix={<div style={{ background: '#e6f7ff', borderRadius: '50%', width: 36, height: 36, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>AI</div>}
/>
<div style={{ fontSize: 12, color: '#999' }}>较昨日 -1.3% <ArrowDownOutlined style={{ color: '#ff4d4f' }} /></div>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="发电偏差"
value={-4.35}
precision={2}
suffix="%"
valueStyle={{ color: '#ff4d4f', fontSize: 28, fontWeight: 700 }}
prefix={<ArrowDownOutlined />}
/>
<div style={{ fontSize: 12, color: '#999' }}>较昨日 -1.02% <ArrowDownOutlined style={{ color: '#ff4d4f' }} /></div>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="异常组串数量"
value={8}
suffix="组"
valueStyle={{ color: '#faad14', fontSize: 28, fontWeight: 700 }}
prefix={<div style={{ background: '#fff7e6', borderRadius: '50%', width: 36, height: 36, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>▦</div>}
/>
<div style={{ fontSize: 12, color: '#999' }}>较昨日 +2 <ArrowUpOutlined style={{ color: '#52c41a' }} /></div>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="热斑疑似数量"
value={36}
suffix="处"
valueStyle={{ color: '#ff4d4f', fontSize: 28, fontWeight: 700 }}
prefix={<div style={{ background: '#fff2f0', borderRadius: '50%', width: 36, height: 36, display: 'flex', alignItems: 'center', justifyContent: 'center' }}><span style={{ width: 8, height: 8, borderRadius: '50%', background: '#ff4d4f' }}></span></div>}
/>
<div style={{ fontSize: 12, color: '#999' }}>较昨日 +5 <ArrowUpOutlined style={{ color: '#52c41a' }} /></div>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="健康度评分"
value={86.3}
precision={1}
suffix="分"
valueStyle={{ color: '#52c41a', fontSize: 28, fontWeight: 700 }}
prefix={<CheckCircleOutlined style={{ color: '#52c41a' }} />}
/>
<div style={{ fontSize: 12, color: '#999' }}>较昨日 -1.7 <ArrowDownOutlined style={{ color: '#ff4d4f' }} /></div>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="预测发电量"
value={4821}
suffix="kWh"
valueStyle={{ color: '#722ed1', fontSize: 28, fontWeight: 700 }}
prefix={<div style={{ background: '#f9f0ff', borderRadius: '50%', width: 36, height: 36, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>⚡</div>}
/>
<div style={{ fontSize: 12, color: '#999' }}>较昨日 +2.6% <ArrowUpOutlined style={{ color: '#52c41a' }} /></div>
</Card>
</Col>
<Row gutter={12} style={{ marginBottom: 16 }}>
{[
{ title: 'PR值', value: '82.6%', trend: '较昨日 -1.3%', icon: <RiseOutlined />, color: '#00B42A', bg: '#E8FFEA' },
{ title: '发电偏差', value: '-4.35%', trend: '较昨日 -1.02%', icon: <FallOutlined />, color: '#F53F3F', bg: '#FFF1F0' },
{ title: '异常组串数量', value: '8', trend: '较昨日 +2 ↑', icon: <AppstoreOutlined />, color: '#F53F3F', bg: '#FFF1F0', trendColor: '#F53F3F' },
{ title: '热斑疑似数量', value: '36', trend: '较昨日 +5 ↑', icon: <BellOutlined />, color: '#F53F3F', bg: '#FFF1F0', trendColor: '#F53F3F' },
{ title: '健康度评分', value: '86.3分', trend: '较昨日 -1.7', icon: <CheckCircleOutlined />, color: '#00B42A', bg: '#E8FFEA' },
{ title: '预测发电量', value: '4,821kWh', trend: '较昨日 +2.6% ↑', icon: <ThunderboltOutlined />, color: '#00B42A', bg: '#E8FFEA', trendColor: '#00B42A' },
].map((item, index) => (
<Col span={4} key={index}>
<Card bordered={false} bodyStyle={{ padding: 16 }} style={cardStyle}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
<div style={{ fontSize: 14, color: '#4E5969', marginBottom: 8 }}>{item.title}</div>
<div style={{ fontSize: 24, fontWeight: 700, color: item.color }}>
{item.value.includes('分') ? <>{item.value.replace('分', '')}<span style={{ fontSize: 14 }}>分</span></> :
item.value.includes('kWh') ? <>{item.value.replace('kWh', '')}<span style={{ fontSize: 14 }}>kWh</span></> : item.value}
</div>
<div style={{ fontSize: 12, color: item.trendColor || '#86909C', marginTop: 8 }}>
{item.trend} {item.trend.includes('-') && <FallOutlined />}
</div>
</div>
<div style={{ width: 48, height: 48, background: item.bg, borderRadius: '50%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
{React.cloneElement(item.icon as React.ReactElement, { style: { fontSize: 24, color: item.color } })}
</div>
</div>
</Card>
</Col>
))}
</Row>
{/* 热成像和组串定位 */}
<Row gutter={16} style={{ marginBottom: 24 }}>
<Col span={12}>
{/* 第二排:热成像分析 和 组串异常定位 */}
<Row gutter={12} style={{ marginBottom: 16 }}>
<Col span={10}>
<Card
title={<span style={{ color: '#0837A8', fontWeight: 800 }}>热成像分析(无人机巡检)</span>}
title={<span style={{ fontSize: 14, fontWeight: 700 }}>热成像分析(无人机巡检)<InfoCircleOutlined style={{ marginLeft: 4, color: '#86909C' }} /></span>}
extra={<Text type="secondary" style={{ fontSize: 12 }}>巡检时间:2025-05-20 09:30 <CalendarOutlined /></Text>}
bordered={false}
style={{ borderRadius: 8 }}
extra={<Text type="secondary" style={{ fontSize: 12 }}>巡检时间:2026-05-06 09:30</Text>}
bodyStyle={{ padding: 16 }}
style={cardStyle}
>
<Row gutter={[12, 12]}>
{thermalImagingData.map((item, idx) => (
<Col span={8} key={idx}>
<div style={{ position: 'relative', background: '#f0f2f5', borderRadius: 8, height: 120, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<div style={{ position: 'absolute', top: 8, left: 8, background: item.title === '热斑异常' ? '#ff4d4f' : item.title === '高温风险' ? '#faad14' : item.title === '疑似遮挡' ? '#1890ff' : '#52c41a', color: '#fff', padding: '2px 6px', borderRadius: 4, fontSize: 12 }}>
{item.title}
</div>
<div style={{ position: 'absolute', bottom: 8, left: 8 }}>
<div style={{ fontSize: 14, fontWeight: 800 }}>{item.name}</div>
<div style={{ fontSize: 12, color: '#666' }}>{item.temp}</div>
<Col span={6} key={idx}>
<div style={{ background: '#111827', borderRadius: 4, height: 140, position: 'relative', overflow: 'hidden' }}>
<div style={{ width: '100%', height: '100%', background: 'linear-gradient(45deg, #4c0000, #ff0000, #ffff00)', opacity: 0.8 }} />
<div style={{ position: 'absolute', bottom: 8, right: 8, background: 'rgba(0,0,0,0.6)', color: '#fff', padding: '2px 6px', borderRadius: 2, fontSize: 10 }}>
{item.temp}
</div>
</div>
<div style={{ textAlign: 'center', marginTop: 8, fontSize: 12, color: '#4E5969' }}>{item.name}</div>
</Col>
))}
</Row>
<div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 16, fontSize: 12, color: '#999' }}>
<div style={{ display: 'flex', gap: 16 }}>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 10, height: 10, borderRadius: '50%', background: '#ff4d4f', marginRight: 4 }}></span>热斑疑似点</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 10, height: 10, borderRadius: '50%', background: '#faad14', marginRight: 4 }}></span>高温区域</span>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginTop: 20 }}>
<div style={{ display: 'flex', gap: 16, fontSize: 12 }}>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 8, height: 8, borderRadius: '50%', background: '#F53F3F', marginRight: 4 }}></span>热斑疑似点</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 8, height: 2, border: '1px dashed #F53F3F', marginRight: 4 }}></span>高温区域</span>
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<span style={{ fontSize: 12, color: '#86909C' }}>温度范围:25℃ ~ 85℃</span>
<div style={{ width: 100, height: 8, background: 'linear-gradient(to right, #0000ff, #00ff00, #ffff00, #ff0000)', borderRadius: 4 }} />
</div>
<span>温度范围:25℃ - 85℃</span>
</div>
</Card>
</Col>
<Col span={12}>
<Col span={14}>
<Card
title={<span style={{ color: '#0837A8', fontWeight: 800 }}>组串异常定位</span>}
title={<span style={{ fontSize: 14, fontWeight: 700 }}>组串异常定位<InfoCircleOutlined style={{ marginLeft: 4, color: '#86909C' }} /></span>}
extra={<div style={{ fontSize: 12, color: '#86909C' }}>总组串数:160 | 异常组串:<span style={{ color: '#F53F3F' }}>8</span></div>}
bordered={false}
style={{ borderRadius: 8, height: "100%" }}
extra={<div style={{ display: 'flex', alignItems: 'center' }}><Text type="secondary" style={{ fontSize: 12 }}>20列 × 8排二维矩阵,点击点位查看详情</Text><Tag color="red" style={{ marginLeft: 8 }}>异常组串:8</Tag></div>}
bodyStyle={{ padding: 16 }}
style={cardStyle}
>
<div style={{ display: 'flex', gap: 16 }}>
<div style={{ flex: 1 }}>
{/* 组串矩阵模拟 */}
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(20, 1fr)', gap: 4 }}>
{Array.from({ length: 8 }).map((_, row) =>
Array.from({ length: 20 }).map((_, col) => {
const isNormal = true;
const isLight = (row === 4 && col === 2);
const isAbnormal = (row === 1 && col === 1) || (row === 1 && col === 10) || (row === 3 && col === 15) || (row === 5 && col === 18);
const isSevere = (row === 0 && col === 8) || (row === 3 && col === 8);
let bgColor = '#91d5ff'; // 正常
if (isLight) bgColor = '#e6f7ff';
if (isAbnormal) bgColor = '#faad14';
if (isSevere) bgColor = '#ff4d4f';
return (
<div
key={`${row}-${col}`}
style={{
width: 16, height: 16, background: bgColor, borderRadius: 2, cursor: 'pointer'
}}
onClick={() => {
setSelectedTask({
id: `A-${col + 1}`,
temp: isSevere ? '75℃' : '68℃',
deviation: '-18.6%',
count: 3,
level: isSevere ? '严重异常' : '异常'
});
setDrawerVisible(true);
}}
/>
);
})
)}
<Row gutter={24}>
<Col flex="auto">
<div style={{ display: 'grid', gridTemplateColumns: '30px repeat(20, 1fr)', gap: 4 }}>
<div></div>
{Array.from({ length: 20 }).map((_, i) => (
<div key={i} style={{ fontSize: 10, color: '#86909C', textAlign: 'center' }}>{String(i + 1).padStart(2, '0')}</div>
))}
{['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'].map((row) => (
<React.Fragment key={row}>
<div style={{ fontSize: 10, color: '#86909C', display: 'flex', alignItems: 'center' }}>{row}排</div>
{Array.from({ length: 20 }).map((_, col) => {
let color = '#E8F3FF';
let icon = null;
if (row === 'B' && col === 3) { color = '#F53F3F'; icon = <span style={{ color: '#fff', fontSize: 10 }}>!</span>; }
if (row === 'B' && col === 17) { color = '#F53F3F'; icon = <span style={{ color: '#fff', fontSize: 10 }}>!</span>; }
if (row === 'C' && col === 15) { color = '#FF7D00'; icon = <span style={{ color: '#fff', fontSize: 10 }}>!</span>; }
if (row === 'E' && col === 4) { color = '#FF7D00'; icon = <span style={{ color: '#fff', fontSize: 10 }}>!</span>; }
if (row === 'F' && col === 11) { color = '#FF7D00'; icon = <span style={{ color: '#fff', fontSize: 10 }}>!</span>; }
if (row === 'G' && col === 1) { color = '#56C1FF'; }
if (row === 'H' && col === 10) { color = '#86909C'; }
return (
<div key={`${row}-${col}`} style={{ width: '100%', height: 14, background: color, borderRadius: 1, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
{icon}
</div>
);
})}
</React.Fragment>
))}
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 16, fontSize: 12 }}>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 10, height: 10, background: '#91d5ff', marginRight: 4 }}></span>正常</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 10, height: 10, background: '#e6f7ff', marginRight: 4 }}></span>轻微异常</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 10, height: 10, background: '#faad14', marginRight: 4 }}></span>异常</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 10, height: 10, background: '#ff4d4f', marginRight: 4 }}></span>严重异常</span>
<div style={{ display: 'flex', gap: 16, marginTop: 16, fontSize: 12 }}>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 12, height: 12, background: '#E8F3FF', marginRight: 4 }}></span>正常</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 12, height: 12, background: '#56C1FF', marginRight: 4 }}></span>轻微异常</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 12, height: 12, background: '#FF7D00', marginRight: 4 }}></span>异常</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 12, height: 12, background: '#F53F3F', marginRight: 4 }}></span>严重异常</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 12, height: 12, background: '#86909C', marginRight: 4 }}></span>离线</span>
</div>
</div>
<div style={{ width: 180, borderLeft: '1px solid #f0f0f0', paddingLeft: 16 }}>
<div style={{ marginBottom: 12 }}>
<div style={{ fontWeight: 800, marginBottom: 4 }}>A-03</div>
<div style={{ fontSize: 12, color: '#999', marginBottom: 2 }}>温度 <span style={{ color: '#ff4d4f' }}>75℃</span></div>
<div style={{ fontSize: 12, color: '#999', marginBottom: 2 }}>发电偏差 <span style={{ color: '#ff4d4f' }}>-18.6%</span></div>
<div style={{ fontSize: 12, color: '#999', marginBottom: 2 }}>历史异常 3 次</div>
<div style={{ fontSize: 12, color: '#ff4d4f' }}>等级:严重异常</div>
</Col>
<Col style={{ width: 160 }}>
<div style={{ fontSize: 12, fontWeight: 700, marginBottom: 12 }}>异常类型统计</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Space><BellOutlined style={{ color: '#F53F3F' }} />严重异常</Space>
<span style={{ fontWeight: 700, color: '#F53F3F' }}>2</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Space><InfoCircleOutlined style={{ color: '#FF7D00' }} />异常</Space>
<span style={{ fontWeight: 700, color: '#FF7D00' }}>4</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Space><div style={{ width: 14, height: 14, background: '#56C1FF', borderRadius: 2 }} />轻微异常</Space>
<span style={{ fontWeight: 700, color: '#56C1FF' }}>2</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Space><div style={{ width: 14, height: 14, background: '#86909C', borderRadius: 2 }} />离线</Space>
<span style={{ fontWeight: 700, color: '#86909C' }}>0</span>
</div>
</div>
<Button type="primary" block size="small" onClick={() => setDrawerVisible(true)}>查看详情</Button>
</div>
</div>
</Col>
</Row>
</Card>
</Col>
</Row>
{/* 图表和表格 */}
<Row gutter={16} style={{ marginBottom: 24, height: '285px' }}>
{/* 第三排:衰减分析、发电表现、AI总结建议 (等高设计) */}
<Row gutter={12} style={{ marginBottom: 16 }}>
{/* 左侧:2个图表 + 数据来源 */}
<Col span={16}>
<Row gutter={12}>
{/* 组件衰减分析 */}
<Col span={12}>
<Card
title={
<span style={{ fontSize: 14, fontWeight: 700 }}>
组件衰减分析
<InfoCircleOutlined style={{ marginLeft: 4, color: '#86909C' }} />
</span>
}
bordered={false}
bodyStyle={{ padding: 16, display: 'flex', flexDirection: 'column', flex: 1 }}
style={{ borderRadius: 8, height: '320px', display: 'flex', flexDirection: 'column' }}
>
<div style={{ flex: 1 }}>
<Line {...degradationConfig} height={220} />
</div>
<div style={{ textAlign: 'right', marginTop: 8, fontSize: 12, color: '#4E5969' }}>
当前平均衰减率 <span style={{ fontWeight: 700 }}>-5.32%</span>
</div>
</Card>
</Col>
{/* 发电表现分析 */}
<Col span={12}>
<Card
title={
<span style={{ fontSize: 14, fontWeight: 700 }}>
发电表现分析
<InfoCircleOutlined style={{ marginLeft: 4, color: '#86909C' }} />
</span>
}
bordered={false}
bodyStyle={{ padding: 16, display: 'flex', flexDirection: 'column', flex: 1 }}
style={{ borderRadius: 8, height: '320px', display: 'flex', flexDirection: 'column' }}
>
<div style={{ display: 'flex', gap: 16, flex: 1 }}>
<div style={{ flex: 1 }}>
<Line {...generationPerformanceConfig} height={220} />
</div>
<div style={{ width: 100, fontSize: 12, display: 'flex', flexDirection: 'column', justifyContent: 'center', gap: 12 }}>
<div>
<div style={{ color: '#86909C' }}>当日实际发电</div>
<div style={{ fontWeight: 700, color: '#165DFF' }}>4,752 <span style={{ fontSize: 10 }}>kWh</span></div>
</div>
<div>
<div style={{ color: '#86909C' }}>当日预测发电</div>
<div style={{ fontWeight: 700, color: '#00B42A' }}>4,960 <span style={{ fontSize: 10 }}>kWh</span></div>
</div>
<div>
<div style={{ color: '#86909C' }}>发电偏差</div>
<div style={{ fontWeight: 700, color: '#F53F3F' }}>-4.35%</div>
</div>
<div>
<div style={{ color: '#86909C' }}>PR 值</div>
<div style={{ fontWeight: 700, color: '#1D2129' }}>82.6%</div>
</div>
</div>
</div>
</Card>
</Col>
</Row>
{/* 数据来源 */}
<Row gutter={12} style={{ marginTop: 12 }}>
<Col span={24}>
<Card
bordered={false}
bodyStyle={{ padding: 16 }}
style={{ borderRadius: 8 }}
>
<div style={{ fontSize: 14, fontWeight: 700, marginBottom: 16 }}>数据来源</div>
<Row gutter={12}>
{[
{ title: '无人机热成像', time: '2025-05-20 09:30', icon: <ScanOutlined /> },
{ title: 'SCADA历史数据', time: '2025-05-20 00:00 - 09:45', icon: <DatabaseOutlined /> },
{ title: '气象数据', time: '2025-05-20 00:00 - 09:45', icon: <CloudOutlined /> },
{ title: '清洗记录', time: '2025-05-12', label: '最近清洗', icon: <RestOutlined /> },
].map((source, idx) => (
<Col span={6} key={idx}>
<div
style={{
background: '#f5f7fa',
padding: '12px 16px',
borderRadius: 8,
display: 'flex',
alignItems: 'center',
gap: 12,
}}
>
<div style={{ fontSize: 24, color: '#165DFF' }}>{source.icon}</div>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 13, fontWeight: 700, color: '#1D2129' }}>{source.title}</div>
<div style={{ fontSize: 11, color: '#86909C' }}>
{source.label || '数据时间'}:{source.time}
</div>
<div style={{ fontSize: 11, color: '#00B42A', marginTop: 2 }}>
<CheckCircleOutlined /> 数据状态:正常
</div>
</div>
</div>
</Col>
))}
</Row>
</Card>
</Col>
</Row>
</Col>
{/* 右侧:AI 诊断与处置 */}
<Col span={8}>
<Card
title={<span style={{ color: '#0837A8', fontWeight: 800 }}>组件衰减分析</span>}
title={<span style={{ fontSize: 14, fontWeight: 700 }}>AI 诊断与处置</span>}
bordered={false}
style={{ borderRadius: 8 }}
bodyStyle={{ padding: 0 }}
style={{ borderRadius: 8, height: '100%', display: 'flex', flexDirection: 'column' }}
>
<Line {...degradationConfig} height={180} />
</Card>
</Col>
<Col span={8}>
<Card
title={<span style={{ color: '#0837A8', fontWeight: 800 }}>发电表现分析</span>}
bordered={false}
style={{ borderRadius: 8 }}
>
<Line {...generationConfig} height={180} />
</Card>
</Col>
<Col span={8} style={{ height: '100%' }}>
<Card
title={<span style={{ color: '#0837A8', fontWeight: 800 }}>AI诊断总结</span>}
bordered={false}
style={{ borderRadius: 8, height: '100%' }}
extra={<Text type="secondary" style={{ fontSize: 12 }}>模型置信度与影响程度</Text>}
>
{/* 👇 加了灰色透明滚动条 */}
<div style={{
height: "200px",
overflow: "auto",
scrollbarWidth: 'thin', scrollbarColor: '#ccc transparent'
}}>
<div style={{ flex: 1, overflow: 'auto', padding: '0 8px' }}>
<Table
columns={[
{ title: '诊断项', dataIndex: 'diagnosis', width: 100 },
{ title: '状态', dataIndex: 'status', render: renderStatusTag, width: 80 },
{ title: '置信度', dataIndex: 'confidence', width: 80 },
{ title: '影响', dataIndex: 'impact', width: 60 },
{ title: '结论', dataIndex: 'conclusion' },
{ title: '诊断项', dataIndex: 'diagnosis', key: 'diagnosis', width: 100 },
{ title: '状态', dataIndex: 'status', key: 'status', render: renderStatusTag, width: 60 },
{ title: '影响', dataIndex: 'impact', key: 'impact', render: renderImpactTag, width: 60 },
{ title: '详情', dataIndex: 'conclusion', key: 'conclusion' },
]}
dataSource={aiSummaryData}
pagination={false}
size="small"
scroll={{ y: undefined }} // 关闭内部滚动,使用外层滚动
/>
</div>
</Card>
</Col>
</Row>
{/* 数据来源和AI建议 */}
<Row gutter={16} style={{ marginTop: 16 }}>
<Col span={12}>
<Card
title={<span style={{ color: '#0837A8', fontWeight: 800 }}>数据来源状态</span>}
bordered={false}
style={{ borderRadius: 8, height: '100%' }}
extra={<Text type="secondary" style={{ fontSize: 12 }}>多源数据融合质量</Text>}
>
<Row gutter={16}>
<Col span={12}>
<div style={{ textAlign: 'center', padding: 12, background: '#f5f7fa', borderRadius: 8 }}>
<div style={{ fontSize: 16, fontWeight: 800, color: '#1890ff' }}>UAV</div>
<div style={{ fontSize: 12, marginTop: 4 }}>无人机</div>
<div style={{ fontSize: 10, color: '#52c41a' }}>数据状态:正常</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: 12, background: '#f5f7fa', borderRadius: 8 }}>
<div style={{ fontSize: 16, fontWeight: 800, color: '#1890ff' }}>DB</div>
<div style={{ fontSize: 12, marginTop: 4 }}>SCA</div>
<div style={{ fontSize: 10, color: '#52c41a' }}>数据状态:正常</div>
</div>
</Col>
</Row>
<Row gutter={16} style={{ marginTop: 16 }}>
<Col span={12}>
<div style={{ textAlign: 'center', padding: 12, background: '#f5f7fa', borderRadius: 8 }}>
<div style={{ fontSize: 16, fontWeight: 800, color: '#1890ff' }}>UAV</div>
<div style={{ fontSize: 12, marginTop: 4 }}>无人机</div>
<div style={{ fontSize: 10, color: '#52c41a' }}>数据状态:正常</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: 12, background: '#f5f7fa', borderRadius: 8 }}>
<div style={{ fontSize: 16, fontWeight: 800, color: '#1890ff' }}>UAV</div>
<div style={{ fontSize: 12, marginTop: 4 }}>无人机</div>
<div style={{ fontSize: 10, color: '#52c41a' }}>数据状态:正常</div>
</div>
</Col>
</Row>
</Card>
</Col>
<Col span={12}>
<Card
title={<span style={{ color: '#0837A8', fontWeight: 800 }}>AI建议与处置</span>}
bordered={false}
style={{ borderRadius: 8 }}
extra={<Text type="secondary" style={{ fontSize: 12 }}>按收益、优先级与置信度排序</Text>}
>
{/* 👇 加了灰色透明滚动条 */}
<div style={{
height: 220,
overflow: "auto",
scrollbarWidth: 'thin', scrollbarColor: '#ccc transparent'
}}>
<Divider style={{ margin: '8px 0' }} />
<Table
columns={[
{ title: '建议措施', dataIndex: 'measure' },
{ title: '优先级', dataIndex: 'priority', render: renderPriorityTag, width: 80 },
{ title: '预计收益', dataIndex: 'expectedGain', width: 80 },
{ title: '置信度', dataIndex: 'confidence', width: 80 },
{ title: '建议措施', dataIndex: 'measure', key: 'measure' },
{
title: '操作', width: 120, render: () => (
<Space>
<Button type="link" size="small">详情</Button>
<Button type="link" size="small">工单</Button>
</Space>
title: '收益',
dataIndex: 'expectedGain',
key: 'expectedGain',
render: (g) => <span style={{ color: '#00B42A' }}>{g}</span>,
width: 70
},
{
title: '操作',
key: 'action',
width: 70,
render: () => (
<Button
type="primary"
size="small"
style={{ fontSize: 11, borderRadius: 4 }}
>
工单
</Button>
)
},
]}
dataSource={aiRecommendations}
pagination={false}
size="small"
scroll={{ y: undefined }}
/>
</div>
</Card>
</Col>
</Row>
{/* 二级入口按钮 */}
<Card bordered={false} style={{ borderRadius: 8, marginTop: 16 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
<div>
<Title level={5} style={{ margin: 0, color: '#0837A8' }}>二级入口</Title>
<Text type="secondary" style={{ fontSize: 12 }}>原诊断任务、热斑结果、AI建议、诊断报告保留为操作入口</Text>
</div>
<Space>
<Button onClick={() => message.info('跳转到诊断任务')}>诊断任务</Button>
<Button onClick={() => message.info('跳转到热斑结果')}>热斑结果</Button>
<Button onClick={() => message.info('跳转到AI建议')}>AI建议</Button>
<Button onClick={() => message.info('跳转到诊断报告')}>诊断报告</Button>
</Space>
</div>
</Card>
{/* 抽屉详情 */}
<Drawer
title={<span style={{ color: '#0837A8', fontWeight: 800 }}>AI诊断详情</span>}
placement="right"
onClose={() => setDrawerVisible(false)}
open={drawerVisible}
width={600}
>
{selectedTask && (
<div>
<Row gutter={16} style={{ marginBottom: 24 }}>
<Col span={12}>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 8 }}>
<Text strong>任务</Text>
<Text>AIT-DEMO-HEALTH-01</Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 8 }}>
<Text strong>算法</Text>
<Text>设备健康演示算法</Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 8 }}>
<Text strong>结果</Text>
<Text>RES-DEMO-INV-A02</Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 8 }}>
<Text strong>最高温</Text>
<Text>{selectedTask.temp}</Text>
</div>
</Col>
<Col span={12}>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 8 }}>
<Text strong>状态</Text>
<Text>SUCCESS</Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 8 }}>
<Text strong>进度</Text>
<Text>100%</Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 8 }}>
<Text strong>等级</Text>
<Text>{selectedTask.level}</Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 8 }}>
<Text strong>置信度</Text>
<Text>90%</Text>
</div>
</Col>
</Row>
<div style={{ marginBottom: 24 }}>
<Text strong>摘要</Text>
<div style={{ background: '#f5f7fa', padding: 12, borderRadius: 8, marginTop: 8 }}>
结合遥感数据发现逆变器温度偏高且功率波动,建议检修散热。
</div>
</div>
<div style={{ marginBottom: 24 }}>
<Text strong>图片/热成像文件</Text>
<Row gutter={16} style={{ marginTop: 12 }}>
<Col span={8}>
<div style={{ background: '#f0f2f5', borderRadius: 8, height: 100, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<Text type="secondary">方阵A-05<br />热点异常 · 71.5℃</Text>
</div>
</Col>
<Col span={8}>
<div style={{ background: '#f0f2f5', borderRadius: 8, height: 100, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<Text type="secondary">方阵A-12<br />高温风险 · 68.3℃</Text>
</div>
</Col>
<Col span={8}>
<div style={{ background: '#f0f2f5', borderRadius: 8, height: 100, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<Text type="secondary">方阵B-03<br />疑似遮挡 · 64.8℃</Text>
</div>
</Col>
</Row>
</div>
<div style={{ marginBottom: 24 }}>
<Text strong>热斑列表</Text>
<Table
columns={[
{ title: '热斑编码', dataIndex: 'id' },
{ title: '组件', dataIndex: 'component' },
{ title: '最高温', dataIndex: 'temp' },
{ title: '温差', dataIndex: 'diff' },
{ title: '等级', dataIndex: 'level' },
]}
dataSource={[]}
pagination={false}
size="small"
/>
</div>
<div>
<Text strong>AI JSON摘要</Text>
<pre style={{ background: '#111827', color: '#fff', padding: 12, borderRadius: 8, marginTop: 8, fontSize: 12 }}>
{`{
"demo": true,
"metric": [
"temperature",
"activePower"
]
}`}
</pre>
</div>
</div>
)}
</Drawer>
</div>
);
}

View File

@@ -9,7 +9,6 @@ import { RootState } from '../store';
const { Header, Content } = Layout;
const { Text } = Typography;
// 设置状态页面(你后续自己填内容)
const DeviceStatusSettingPage = () => (
<div style={{ padding: 20 }}>
<h2>设置状态页面(/devices/status)</h2>
@@ -24,50 +23,62 @@ export default function DeviceIndexPage() {
const [devicesAll, setDevicesAll] = useState([]);
const tabs = [
{ key: 'overview', label: '装备总览', icon: <AppstoreOutlined />, path: '/devices/overview' },
{ key: 'status', label: '设置状态', icon: <SettingOutlined />, path: '/devices/status' },
{ key: 'overview', label: '装备总览', icon: <AppstoreOutlined /> },
{ key: 'status', label: '设置状态', icon: <SettingOutlined /> },
];
const renderContent = () => {
if (activeTab === 'overview') return <DeviceOverviewPage devices={devices} planedevices={planedevices} devicesAll={devicesAll} />;
if (activeTab === 'status') return <DeviceStatusSettingPage />;
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 <DeviceOverviewPage
devices={devices}
planedevices={planedevices}
devicesAll={devicesAll}
/>;
}
if (activeTab === 'status') return <DeviceStatusSettingPage />;
return null;
};
return (
<Layout style={{ minHeight: '100vh', background: '#fff', overflow: 'hidden' }}>
<div style={{ display: 'flex', paddingBottom: "12px" }}>
<div style={{ padding: '20px 24px 0' }}>
<div style={{ padding: '20px 24px 0', flexShrink: 0 }}>
<Typography.Title level={4} style={{ margin: 0 }}>装备控制</Typography.Title>
<Text type="secondary"> 装备总览、状态监控与参数配置</Text>
</div>
<Header style={{ background: '#fff', padding: 0, borderBottom: '1px solid #f0f0f0', position: 'sticky', top: 0, zIndex: 10 }}>
<Header style={{ flex: 1, background: '#fff', padding: 0, borderBottom: '1px solid #f0f0f0' }}>
<Menu
mode="horizontal"
selectedKeys={[activeTab]}
@@ -78,13 +89,12 @@ export default function DeviceIndexPage() {
</Header>
</div>
<Content style={{
maxHeight: 'calc(100vh - 64px)',
overflowY: 'auto',
background: '#f5f7fa',
padding: '20px',
scrollbarWidth: "none"
scrollbarWidth: "thin"
}}>
{renderContent()}
</Content>