告警详情和 总览界面 修改 布局调整

This commit is contained in:
mmc
2026-04-28 11:01:54 +08:00
parent f5f27b7668
commit c08278190a
14 changed files with 2207 additions and 868 deletions

View File

@@ -1,218 +1,401 @@
import React from 'react';
import {
Card,
Row,
Col,
Statistic,
Table,
Tag,
Progress,
List,
Button,
Typography,
Space,
import {
Card,
Row,
Col,
Statistic,
Table,
Tag,
Progress,
List,
Button,
Typography,
Space,
} from 'antd';
import {
ThunderboltOutlined,
DashboardOutlined,
DotChartOutlined,
RocketOutlined,
BellOutlined,
CloudUploadOutlined,
import {
ThunderboltOutlined,
DashboardOutlined,
DotChartOutlined,
RocketOutlined,
BellOutlined,
CloudUploadOutlined,
} from '@ant-design/icons';
import { DEVICES, ALERTS } from '../constants';
import { useNavigate } from 'react-router-dom';
import { Line, Column } from '@ant-design/charts';
const { Text, Title } = Typography;
const AntdCard = Card as any;
export default function Home() {
const navigate = useNavigate();
const navigate = useNavigate();
const stats = [
{ title: '芯片温度', value: 32.08, icon: <DashboardOutlined />, color: '#ff4d4f', suffix: '℃' },
{ title: '设备电流', value: 0, icon: <ThunderboltOutlined />, color: '#1677ff', suffix: 'A' },
{ title: '设备电压', value: 0, icon: <DotChartOutlined />, color: '#fa8c16', suffix: 'V' },
{ title: '设备数量', value: DEVICES.length, icon: <RocketOutlined />, color: '#52c41a', suffix: '' },
{ title: '告警数量', value: ALERTS.filter(a => !a.handled).length, icon: <BellOutlined />, color: '#ff4d4f', suffix: '' },
{ title: '上报事件', value: 1, icon: <CloudUploadOutlined />, color: '#52c41a', suffix: '' },
];
// 顶部统计卡片数据(和参考图完全一致)
const topStats = [
{
title: '今日发电量',
value: 4752,
suffix: 'kWh',
extra: <span style={{ color: '#52c41a', fontSize: 12 }}>日目标 5,000 kWh</span>,
percent: 95,
color: '#52c41a'
},
{
title: '当前功率',
value: 812.6,
suffix: 'kW',
extra: <span style={{ color: '#888', fontSize: 12 }}>装机容量 1,000 kWp</span>,
color: '#1890ff'
},
{
title: 'Performance Ratio(PR)',
value: 82.6,
suffix: '%',
extra: <span style={{ color: '#888', fontSize: 12 }}>昨日 81.3% 环比 ↑1.3%</span>,
color: '#13c2c2'
},
{
title: '系统可用率',
value: 99.35,
suffix: '%',
extra: <span style={{ color: '#888', fontSize: 12 }}>昨日 99.12% 环比 ↑0.23%</span>,
color: '#52c41a'
},
{
title: '告警数量',
value: 8,
extra: <span style={{ color: '#888', fontSize: 12 }}>未处理 5 / 已处理 3</span>,
color: '#ff4d4f'
},
{
title: '节省运维成本',
value: 36540,
prefix: '¥',
extra: <span style={{ color: '#888', fontSize: 12 }}>本月累计节省</span>,
color: '#faad14'
},
];
const columns = [
{
title: 'Node / 标识',
dataIndex: 'name',
key: 'name',
render: (text: string, record: any) => (
<Space direction="vertical" size={2}>
<Text strong style={{ fontSize: 13 }}>{text}</Text>
<Text type="secondary" style={{ fontSize: 11, fontFamily: 'monospace' }}>{record.id}</Text>
</Space>
),
},
{
title: 'Status / 状态',
dataIndex: 'status',
key: 'status',
width: 110,
render: (status: string) => (
<Tag
color={status === 'online' ? 'success' : status === 'alert' ? 'error' : 'default'}
style={{
borderRadius: 4,
fontSize: 11,
fontWeight: 600,
padding: '2px 8px'
}}
>
{status.toUpperCase()}
</Tag>
),
},
{
title: 'Batt / 电量',
dataIndex: 'battery',
key: 'battery',
width: 140,
render: (percent: number) => (
<Progress
percent={percent}
size="small"
status={percent < 20 ? 'exception' : 'active'}
strokeColor={percent < 20 ? '#ff4d4f' : '#52c41a'}
/>
),
},
{
title: 'Load / 负载',
dataIndex: 'cpu',
key: 'cpu',
width: 100,
render: (cpu: number) => (
<Text style={{ fontFamily: 'monospace', fontSize: 12 }}>{cpu}%</Text>
),
},
{
title: 'Ping / 延迟',
key: 'ping',
width: 100,
align: 'right',
render: () => <Text style={{ fontFamily: 'monospace', fontSize: 12 }}>12ms</Text>,
},
];
// 发电趋势图数据
const powerTrendData = [
{ time: '00:00', actual: 0, forecast: 0 },
{ time: '06:00', actual: 200, forecast: 180 },
{ time: '09:00', actual: 800, forecast: 750 },
{ time: '12:00', actual: 1100, forecast: 1050 },
{ time: '15:00', actual: 900, forecast: 920 },
{ time: '18:00', actual: 300, forecast: 280 },
{ time: '24:00', actual: 0, forecast: 0 },
];
return (
<div style={{ padding: '16px' }}>
{/* 统计卡片 */}
<Row gutter={[16, 16]}>
{stats.map((stat, idx) => (
<Col xs={12} sm={12} md={8} lg={4} xl={4} key={idx}>
<AntdCard
size="small"
bordered={false}
hoverable
style={{
borderRadius: 10,
boxShadow: '0 2px 12px rgba(0,0,0,0.06)',
transition: 'all 0.3s',
}}
bodyStyle={{ padding: '16px 14px' }}
>
<Statistic
title={<span style={{ fontSize: 12, color: '#666', fontWeight: 500 }}>{stat.title}</span>}
value={stat.value}
precision={idx === 0 ? 2 : 0}
valueStyle={{
color: '#1f2329',
fontWeight: 600,
fontSize: 22,
marginTop: 4,
}}
prefix={React.cloneElement(stat.icon as React.ReactElement, {
style: { color: stat.color, fontSize: 16, marginRight: 6 },
})}
suffix={<span style={{ fontSize: 13, color: '#888' }}>{stat.suffix}</span>}
/>
</AntdCard>
</Col>
))}
</Row>
// 辐照度与温度趋势数据
const irradianceData = [
{ time: '00:00', irradiance: 0, temp: 20 },
{ time: '06:00', irradiance: 200, temp: 22 },
{ time: '09:00', irradiance: 800, temp: 28 },
{ time: '12:00', irradiance: 1050, temp: 35 },
{ time: '15:00', irradiance: 750, temp: 32 },
{ time: '18:00', irradiance: 200, temp: 26 },
{ time: '24:00', irradiance: 0, temp: 21 },
];
<Row gutter={[16, 16]} style={{ marginTop: 4 }}>
{/* 设备表格 */}
<Col xs={24} lg={16}>
<AntdCard
title={<span style={{ fontSize: 14, fontWeight: 600 }}>核心节点实时清单</span>}
bordered={false}
style={{ borderRadius: 10, boxShadow: '0 2px 12px rgba(0,0,0,0.06)' }}
bodyStyle={{ padding: 0 }}
>
<Table
size="middle"
columns={columns}
dataSource={DEVICES.map(d => ({ ...d, key: d.id }))}
pagination={false}
onRow={(record) => ({
onClick: () => navigate('/devices'),
style: { cursor: 'pointer' },
})}
rowHoverable
/>
</AntdCard>
</Col>
// 逆变器效率数据
const inverterData = [
{ name: 'INV-01', value: 98.2 },
{ name: 'INV-02', value: 97.6 },
{ name: 'INV-03', value: 98.9 },
{ name: 'INV-04', value: 97.1 },
{ name: 'INV-05', value: 98.0 },
];
{/* 告警列表 */}
<Col xs={24} lg={8}>
<Card
title={<span style={{ fontSize: 14, fontWeight: 600 }}>当日重点警报</span>}
extra={
<Button type="text" danger size="small" style={{ fontWeight: 500 }}>
一键清除
</Button>
}
bordered={false}
style={{ borderRadius: 10, boxShadow: '0 2px 12px rgba(0,0,0,0.06)' }}
bodyStyle={{ padding: 0, height: 460, overflowY: 'auto' }}
>
<List
dataSource={ALERTS.slice(0, 10)}
renderItem={(alert) => (
<List.Item
style={{
padding: '12px 16px',
borderBottom: '1px solid #f5f5f5',
cursor: 'pointer',
}}
hoverable
>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 6 }}>
<Tag
color={alert.type === 'critical' ? 'error' : alert.type === 'warning' ? 'warning' : 'processing'}
style={{
borderRadius: 4,
fontSize: 11,
fontWeight: 600,
padding: '0 6px',
}}
>
{alert.type}
</Tag>
<Text type="secondary" style={{ fontSize: 11 }}>
{alert.time.split(' ')[1]}
</Text>
</div>
<Text style={{ fontSize: 13, fontWeight: 500, lineHeight: 1.4 }}>
{alert.message}
</Text>
<Text type="secondary" style={{ fontSize: 11, marginTop: 4, display: 'block' }}>
设备:{alert.deviceName}
</Text>
</List.Item>
)}
/>
</Card>
</Col>
</Row>
</div>
);
// 告警列表数据
const alertList = [
{ key: 1, content: 'INV-03 逆变直流电压异常', level: '严重', time: '10:24:15' },
{ key: 2, content: '组串 String-07 绝缘电阻低', level: '重要', time: '10:18:42' },
{ key: 3, content: '汇流箱 Combiner-12 过温', level: '重要', time: '10:12:33' },
{ key: 4, content: '气象站辐照度传感器离线', level: '次要', time: '09:58:11' },
{ key: 5, content: '组件温度异常偏高', level: '次要', time: '09:41:28' },
];
// 巡检记录数据
const patrolData = [
{ key: 1, type: '日常巡检', time: '2025-05-23 09:30', person: '张运维', status: '已完成' },
{ key: 2, type: '无人机巡检', time: '2025-05-22 14:15', person: '无人机01号', status: '已完成' },
{ key: 3, type: '夜间巡检', time: '2025-05-21 20:45', person: '李班长', status: '已完成' },
{ key: 4, type: '专项巡检', time: '2025-05-20 10:20', person: '王技术员', status: '已完成' },
{ key: 5, type: '日常巡检', time: '2025-05-19 09:25', person: '张运维', status: '已完成' },
];
return (
<div style={{ padding: '16px', background: '#f4f7f9', minHeight: '100%' }}>
{/* 顶部统计卡片 */}
<Row gutter={[16, 16]} style={{ marginBottom: 16 }}>
{topStats.map((stat, idx) => (
<Col xs={24} sm={12} md={8} lg={4} key={idx}>
<AntdCard
size="small"
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
>
<Statistic
title={<span style={{ fontSize: 13, color: '#666' }}>{stat.title}</span>}
value={stat.value}
precision={stat.value % 1 !== 0 ? 1 : 0}
valueStyle={{ color: '#1f2329', fontWeight: 600, fontSize: 20 }}
prefix={stat.prefix}
suffix={stat.suffix}
/>
<div style={{ marginTop: 4, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
{stat.extra}
{stat.percent && <Progress percent={stat.percent} size="small" style={{ width: 60 }} />}
</div>
</AntdCard>
</Col>
))}
</Row>
<Row gutter={[16, 16]}>
{/* 左侧图表区域 */}
<Col xs={24} lg={6}>
{/* 发电趋势 */}
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>今日发电功率趋势</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', marginBottom: 16 }}
extra={<Space size="small"><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#52c41a' }}>■</span> 实际功率</span><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#1890ff' }}>■</span> 预测功率</span></Space>}
>
<Line
data={powerTrendData}
xField="time"
yField="actual"
smooth
color="#52c41a"
style={{ height: 120 }}
yAxis={{ min: 0, max: 1250 }}
/>
</AntdCard>
{/* 辐照度与温度趋势 */}
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>辐照度与温度趋势</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', marginBottom: 16 }}
extra={<Space size="small"><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#fa8c16' }}>■</span> 辐照度(W/m²)</span><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#1890ff' }}>■</span> 环境温度(℃)</span></Space>}
>
<Line
data={irradianceData}
xField="time"
yField="irradiance"
smooth
color="#fa8c16"
style={{ height: 120 }}
yAxis={{ min: 0, max: 1250 }}
/>
</AntdCard>
{/* 逆变器效率对比 */}
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>逆变器效率对比</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
>
<Column
data={inverterData}
xField="name"
yField="value"
color="#1890ff"
style={{ height: 120 }}
yAxis={{ min: 60, max: 100 }}
/>
</AntdCard>
</Col>
{/* 中间:电站概览 */}
<Col xs={24} lg={12}>
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>电站概览</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', height: '100%' }}
extra={<Space size="small"><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#52c41a' }}>●</span> 正常</span><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#ff4d4f' }}>●</span> 告警</span><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#888' }}>●</span> 离线</span><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#faad14' }}>●</span> 维护中</span></Space>}
>
{/* 这里替换成你的电站3D图 */}
<div style={{ width: '100%', height: 400, background: '#e6f7ff', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
电站3D概览图(可替换为你的图片/地图组件)
</div>
</AntdCard>
</Col>
{/* 右侧信息面板 */}
<Col xs={24} lg={6}>
{/* 实时告警 */}
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>实时告警</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', marginBottom: 16 }}
extra={<Button type="link" size="small">更多&gt;</Button>}
>
<List
size="small"
dataSource={alertList}
renderItem={(item) => (
<List.Item style={{ padding: '8px 0', borderBottom: '1px solid #f0f0f0' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<div>
<span style={{ fontSize: 12 }}>{item.content}</span>
</div>
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
<Tag color={item.level === '严重' ? 'error' : item.level === '重要' ? 'warning' : 'default'} size="small" style={{ fontSize: 10 }}>{item.level}</Tag>
<span style={{ fontSize: 11, color: '#888' }}>{item.time}</span>
</div>
</div>
</List.Item>
)}
/>
</AntdCard>
{/* 设备在线状态 */}
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>设备在线状态</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', marginBottom: 16 }}
extra={<Button type="link" size="small">更多&gt;</Button>}
>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 8 }}>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>组件阵列</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>320/320</span></div>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>逆变器</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>5/5</span></div>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>汇流箱</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>20/20</span></div>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>气象站</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>1/1</span></div>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>摄像头</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>12/12</span></div>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>环境传感器</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>8/8</span></div>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>无人机</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>1/1</span></div>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>巡检机器人</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>1/1</span></div>
</div>
</AntdCard>
{/* 天气信息 */}
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>天气信息</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', marginBottom: 16 }}
extra={<Button type="link" size="small">详细&gt;</Button>}
>
<div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
<span style={{ fontSize: 32 }}>☀️</span>
<div>
<div style={{ fontSize: 24, fontWeight: 600 }}>28℃</div>
<div style={{ fontSize: 12, color: '#888' }}>晴</div>
</div>
<div style={{ fontSize: 11, color: '#888', marginLeft: 16 }}>
<div>辐照度: 815 W/m²</div>
<div>组件温度: 45.6℃</div>
<div>环境温度: 28.3℃</div>
<div>风速: 2.6 m/s</div>
<div>风向: 东南风</div>
<div>湿度: 56%</div>
</div>
</div>
</AntdCard>
{/* 清洗建议 */}
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>清洗建议</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
extra={<Button type="link" size="small">更多&gt;</Button>}
>
<div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
<Progress percent={85} type="circle" size={60} strokeColor="#52c41a" />
<div>
<div style={{ fontSize: 12 }}>建议清洗时间: 3 天内</div>
<div style={{ fontSize: 12 }}>预计提升发电量: 2.6%</div>
<div style={{ fontSize: 12 }}>预计提升电量: 120 kWh/天</div>
<Button type="primary" size="small" style={{ marginTop: 8 }}>生成清洗工单</Button>
</div>
</div>
</AntdCard>
</Col>
</Row>
{/* 底部:运维任务/巡检记录/AI分析 */}
<Row gutter={[16, 16]} style={{ marginTop: 16 }}>
<Col xs={24} lg={6}>
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>运维任务进度</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
extra={<Button type="link" size="small">更多&gt;</Button>}
>
<div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
<Progress percent={58} type="circle" size={80} strokeColor="#52c41a" successPercent={25} />
<div style={{ fontSize: 12 }}>
<div><span style={{ color: '#52c41a' }}>●</span> 已完成 7 (58%)</div>
<div><span style={{ color: '#faad14' }}>●</span> 进行中 3 (25%)</div>
<div><span style={{ color: '#1890ff' }}>●</span> 待开始 2 (17%)</div>
<div><span style={{ color: '#ff4d4f' }}>●</span> 已延期 0 (0%)</div>
</div>
</div>
</AntdCard>
</Col>
<Col xs={24} lg={12}>
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>近期巡检记录</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
extra={<Button type="link" size="small">更多&gt;</Button>}
>
<Table
size="small"
dataSource={patrolData}
pagination={false}
columns={[
{ title: '巡检类型', dataIndex: 'type', key: 'type', width: 80 },
{ title: '巡检时间', dataIndex: 'time', key: 'time', width: 120 },
{ title: '巡检人员', dataIndex: 'person', key: 'person', width: 100 },
{ title: '状态', dataIndex: 'status', key: 'status', render: (status) => <Tag color="success" size="small">{status}</Tag> },
]}
/>
</AntdCard>
</Col>
<Col xs={24} lg={6}>
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>AI分析摘要</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
>
<List
size="small"
dataSource={[
{ title: '热点检测', desc: '发现 2 处组件存在异常热斑', link: '查看详情' },
{ title: '组串异常', desc: '3 个组串存在发电异常', link: '查看详情' },
{ title: '发电偏差分析', desc: '整体发电偏差 -2.8%', link: '查看详情' },
]}
renderItem={(item) => (
<List.Item style={{ padding: '8px 0', borderBottom: '1px solid #f0f0f0' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<div>
<div style={{ fontSize: 12, fontWeight: 500 }}>{item.title}</div>
<div style={{ fontSize: 11, color: '#888' }}>{item.desc}</div>
</div>
<Button type="link" size="small">{item.link}</Button>
</div>
</List.Item>
)}
/>
</AntdCard>
</Col>
</Row>
</div>
);
}