Files
web-Iot/src/pages/AIAnalysis.tsx
2026-05-14 10:47:56 +08:00

472 lines
21 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { useState } from 'react';
import {
Row, Col, Card, Button, Tag, Table, Typography, Space, Statistic, message, Divider, Tooltip
} from 'antd';
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 = [
{ 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 = [
{ 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 = [
{ 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: '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: 'value',
seriesField: 'type',
color: ['#165DFF', '#00B42A', '#F53F3F'],
smooth: true,
lineStyle: (type: string) => {
if (type === '最差组件') return { lineDash: [4, 4] };
return { lineWidth: 2 };
},
legend: { position: 'top' },
yAxis: { label: { formatter: (v: string) => `${v}%` } },
};
const generationPerformanceConfig = {
data: [
{ 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: 'value',
seriesField: 'type',
color: ['#165DFF', '#00B42A', '#86909C'],
smooth: true,
lineStyle: (type: string) => {
if (type === '理论发电') return { lineDash: [4, 4] };
return { lineWidth: 2 };
},
legend: { position: 'top' },
};
export default function AIDiagnosisPage() {
const cardStyle = { borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.05)' };
// 状态标签渲染
const renderStatusTag = (status: string) => {
const colorMap: Record<string, string> = {
'异常': '#F53F3F',
'正常': '#00B42A',
'轻微': '#F7BA1E',
};
return <span style={{ color: colorMap[status] }}>{status}</span>;
};
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: '0px 24px' }}>
<div style={{ display: 'flex', paddingBottom: "12px" }}>
<div style={{ padding: '20px 0px 0' }}>
<Typography.Title level={4} style={{ margin: 0 }}>AI诊断分析</Typography.Title>
</div>
</div>
<Row
gutter={[12, 12]}
style={{
marginBottom: 16,
flexWrap: 'wrap',
}}
>
{[
{ title: 'PR值', value: '82.6%', trend: '较昨日 -1.3%', icon: <RiseOutlined />, color: '#00B42A', bg: '#E8FFEA', trendColor: '#F53F3F' },
{ title: '发电偏差', value: '-4.35%', trend: '较昨日 -1.02%', icon: <FallOutlined />, color: '#F53F3F', bg: '#FFF1F0', trendColor: '#F53F3F' },
{ 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', unit: '分', trend: '较昨日 -1.7', icon: <CheckCircleOutlined />, color: '#00B42A', bg: '#E8FFEA', trendColor: '#F53F3F' },
{ title: '预测发电量', value: '4,821', unit: 'kWh', trend: '较昨日 +2.6% ↑', icon: <ThunderboltOutlined />, color: '#00B42A', bg: '#E8FFEA', trendColor: '#00B42A' },
].map((item, index) => (
<Col key={index} style={{ minWidth: '168px', flex: '1 0 auto', }}>
<Card
bordered={false}
bodyStyle={{ padding: '16px' }}
style={{ borderRadius: 8, height: 120 }}
>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', height: '100%' }}>
<div>
<div style={{ fontSize: 14, color: '#4E5969', marginBottom: 8 }}>{item.title}</div>
<div style={{ fontSize: 24, fontWeight: 700, color: item.color, display: 'flex', alignItems: 'baseline', gap: 4 }}>
{item.value}
{item.unit && <span style={{ fontSize: 14, fontWeight: 400 }}>{item.unit}</span>}
</div>
<div style={{ fontSize: 12, color: item.trendColor || '#86909C', marginTop: 8 }}>
{item.trend}
</div>
</div>
<div style={{
width: 48,
height: 48,
background: item.bg,
borderRadius: '50%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}>
{React.cloneElement(item.icon, { style: { fontSize: 24, color: item.color } })}
</div>
</div>
</Card>
</Col>
))}
</Row>
{/* 第二排:热成像分析 和 组串异常定位 */}
<Row gutter={12} style={{ marginBottom: 16 }}>
<Col span={10}>
<Card
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}
bodyStyle={{ padding: 16 }}
style={cardStyle}
>
<Row gutter={[12, 12]}>
{thermalImagingData.map((item, idx) => (
<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', 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>
</div>
</Card>
</Col>
<Col span={14}>
<Card
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}
bodyStyle={{ padding: 16 }}
style={cardStyle}
>
<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', 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>
</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>
</Col>
</Row>
</Card>
</Col>
</Row>
{/* 第三排:衰减分析、发电表现、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} autoFit={true}
/>
</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={{ fontSize: 14, fontWeight: 700 }}>AI 诊断与处置</span>}
bordered={false}
bodyStyle={{ padding: 0 }}
style={{ borderRadius: 8, height: '100%', display: 'flex', flexDirection: 'column' }}
>
<div style={{ flex: 1, overflow: 'auto', padding: '0 8px' }}>
<Table
columns={[
{ 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"
/>
<Divider style={{ margin: '8px 0' }} />
<Table
columns={[
{ title: '建议措施', dataIndex: 'measure', key: 'measure' },
{
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"
/>
</div>
</Card>
</Col>
</Row>
</div>
);
}