Files
web-Iot/src/pages/Home.tsx

402 lines
15 KiB
TypeScript
Raw Normal View History

2026-04-17 17:20:41 +08:00
import React from 'react';
import {
Card,
Row,
Col,
Statistic,
Table,
Tag,
Progress,
List,
Button,
Typography,
Space,
2026-04-17 17:20:41 +08:00
} from 'antd';
import {
ThunderboltOutlined,
DashboardOutlined,
DotChartOutlined,
RocketOutlined,
BellOutlined,
CloudUploadOutlined,
2026-04-17 17:20:41 +08:00
} from '@ant-design/icons';
import { DEVICES, ALERTS } from '../constants';
import { useNavigate } from 'react-router-dom';
import { Line, Column } from '@ant-design/charts';
2026-04-17 17:20:41 +08:00
const { Text, Title } = Typography;
const AntdCard = Card as any;
export default function Home() {
const navigate = useNavigate();
// 顶部统计卡片数据(和参考图完全一致)
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 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 },
];
// 辐照度与温度趋势数据
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 },
];
// 逆变器效率数据
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 },
];
// 告警列表数据
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>
);
2026-04-22 09:43:55 +08:00
}