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

511 lines
18 KiB
TypeScript
Raw Normal View History

2026-04-17 17:20:41 +08:00
import React from 'react';
2026-05-07 20:25:14 +08:00
import { Card, Row, Col, Statistic, Button, Space, Tag, Typography } from 'antd';
import {
2026-05-07 20:25:14 +08:00
CloudOutlined, ThunderboltOutlined, BarChartOutlined,
RiseOutlined, BellOutlined, WalletOutlined,
MinusOutlined, PlusOutlined, SyncOutlined
2026-04-17 17:20:41 +08:00
} from '@ant-design/icons';
2026-05-07 20:25:14 +08:00
import { Line, Bar, Pie } from '@ant-design/charts';
import { getOverflowOptions } from 'antd/es/_util/placements';
2026-05-07 20:25:14 +08:00
const { Text } = Typography;
2026-05-07 20:25:14 +08:00
export default function StationDashboard() {
// 模拟数据
const stationOverview = {
todayEnergy: 45.9,
currentPower: 66811.3,
systemEfficiency: 66.8,
yesterdayEfficiency: 81.3,
systemAvailability: 92.31,
onlineDevices: "12/13",
alarmCount: 5,
costSaved: 8278
};
const realtimeAlerts = [
{ level: "INFO", type: "设备离线", time: "04-28 18:44" },
{ level: "严重", type: "逆变器温度过高", time: "04-28 18:44" }
];
2026-05-07 20:25:14 +08:00
const deviceStatus = [
{ name: "汇流箱", count: "2/2", status: "异常 1" },
{ name: "逆变器", count: "3/3", status: "异常 1" },
{ name: "电表", count: "1/1", status: "正常" },
{ name: "巡检机器人", count: "1/1", status: "正常" }
];
2026-05-07 20:25:14 +08:00
const patrolRecords = [
{ name: "升压站安防巡检任务", device: "UAV-01", status: "草稿", time: "04-29T..." },
{ name: "B区清洗任务", device: "CLEAN-01", status: "待执行", time: "04-29T..." },
{ name: "A区巡检任务", device: "ROBOT-01", status: "已派发", time: "04-29T..." }
];
2026-05-07 20:25:14 +08:00
const aiAnalysis = [
{ type: "AI分析", content: "AI发现逆变器温度与组串电流存在轻微异常,建议优先复核A区设备。" },
{ type: "严重", content: "INV-A02散热检修建议:建议检查INV-A02散热风扇、风道和运行负载,持续高温时转维修工单。" },
{ type: "严重", content: "A05阵列热斑处置建议:建议现场复核PV-A05-018至PV-A05-020组件接线和旁路二极管状态,必要时更换异常组件。" }
];
2026-05-07 20:25:14 +08:00
// 图表配置
const powerTrendConfig = {
data: [
{ time: "00:00", actual: 2000, predict: 1800 },
{ time: "08:00", actual: 35000, predict: 33000 },
{ time: "16:00", actual: 55000, predict: 53000 },
{ time: "24:00", actual: 2000, predict: 1800 }
],
xField: 'time',
yField: ['actual', 'predict'],
color: ['#1890ff', '#52c41a'],
areaStyle: { fillOpacity: 0.15 },
legend: { position: 'top-left' }
};
const irradianceConfig = {
data: [
{ time: "00:00", irradiance: 50, temperature: 15 },
{ time: "08:00", irradiance: 400, temperature: 20 },
{ time: "16:00", irradiance: 800, temperature: 30 },
{ time: "24:00", irradiance: 50, temperature: 15 }
],
xField: 'time',
yField: ['irradiance', 'temperature'],
color: ['#1890ff', '#52c41a'],
areaStyle: { fillOpacity: 0.15 },
legend: { position: 'top-left' }
};
const invEfficiencyConfig = {
data: [
{ device: 'INV-01', efficiency: 98 },
{ device: 'INV-03', efficiency: 97 },
{ device: 'INV-05', efficiency: 96 },
{ device: 'INV-07', efficiency: 95 },
{ device: 'INV-09', efficiency: 94 }
],
xField: 'device',
yField: 'efficiency',
color: '#1890ff',
label: { position: 'top' }
};
const taskProgressConfig = {
data: [
{ type: '已完成', value: 40 },
{ type: '进行中', value: 35 },
{ type: '待开始', value: 20 },
{ type: '异常', value: 5 }
],
angleField: 'value',
colorField: 'type',
color: ['#1890ff', '#52c41a', '#faad14', '#ff4d4f'],
radius: 0.8,
innerRadius: 0.6,
legend: { position: 'right' }
};
const cardStyle = { borderRadius: 8, };
return (
2026-05-07 20:25:14 +08:00
<div style={{ background: '#f0f2f5', minHeight: '100vh', width: '100%', boxSizing: 'border-box', overflow: "hidden" }}>
{/* 顶部一排6个卡片 —— 等宽、不换行、自适应 */}
<Row
gutter={[16, 16]}
style={{
marginBottom: 16,
width: '100%',
margin: '0 0 16px 0',
flexWrap: 'nowrap',
overflow: 'hidden'
}}
>
<Col flex="1 1 16.666%">
<Card bordered={false} style={cardStyle}>
<Statistic title={<span style={{ color: '#000', fontSize: 14, fontWeight: 600 }}>今日发电量</span>}
value={stationOverview.todayEnergy} precision={1} valueStyle={{ color: '#1890ff', fontSize: 24, fontWeight: 800 }} prefix={<CloudOutlined style={{ fontSize: 20 }} />} suffix="kWh" />
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>日发电实时累计</div>
</Card>
</Col>
<Col flex="1 1 16.666%">
<Card bordered={false} style={cardStyle}>
<Statistic title={<span style={{ color: '#000', fontSize: 14, fontWeight: 600 }}>当前功率</span>}
value={stationOverview.currentPower} precision={1} valueStyle={{ color: '#1890ff', fontSize: 24, fontWeight: 800 }} prefix={<ThunderboltOutlined style={{ fontSize: 20 }} />} suffix="kW" />
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>装机容量 100.0 MWp</div>
</Card>
</Col>
<Col flex="1 1 16.666%">
<Card bordered={false} style={cardStyle}>
<Statistic title={<span style={{ color: '#000', fontSize: 14, fontWeight: 600 }}>系统效率 PR</span>}
value={stationOverview.systemEfficiency} precision={1} valueStyle={{ color: '#52c41a', fontSize: 24, fontWeight: 800 }} prefix={<BarChartOutlined style={{ fontSize: 20 }} />} suffix="%" />
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>昨日 {stationOverview.yesterdayEfficiency}% +1.3%</div>
</Card>
</Col>
<Col flex="1 1 16.666%">
<Card bordered={false} style={cardStyle}>
<Statistic title={<span style={{ color: '#000', fontSize: 14, fontWeight: 600 }}>系统可用率</span>}
value={stationOverview.systemAvailability} precision={2} valueStyle={{ color: '#faad14', fontSize: 24, fontWeight: 800 }} prefix={<RiseOutlined style={{ fontSize: 20 }} />} suffix="%" />
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>在线设备 {stationOverview.onlineDevices}</div>
</Card>
</Col>
<Col flex="1 1 16.666%">
<Card bordered={false} style={cardStyle}>
<Statistic title={<span style={{ color: '#000', fontSize: 14, fontWeight: 600 }}>告警数量</span>}
value={stationOverview.alarmCount} valueStyle={{ color: '#ff4d4f', fontSize: 24, fontWeight: 800 }} prefix={<BellOutlined style={{ fontSize: 20 }} />} suffix="条" />
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>今日新增 0 条</div>
</Card>
</Col>
<Col flex="1 1 16.666%">
<Card bordered={false} style={cardStyle}>
<Statistic title={<span style={{ color: '#000', fontSize: 14, fontWeight: 600 }}>节省运维成本</span>}
value={stationOverview.costSaved} valueStyle={{ color: '#1890ff', fontSize: 24, fontWeight: 800 }} prefix="¥" />
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>清洗收益 + 工单闭环估算</div>
</Card>
</Col>
</Row>
2026-05-07 20:25:14 +08:00
{/* 主体:左侧图表 + 中间电站 + 右侧告警 —— 强制一行不换行 */}
<Row
gutter={[16, 16]}
style={{
width: '100%',
margin: 0,
flexWrap: 'nowrap',
height: 'calc(100vh - 167px)',
}}
>
{/* 左侧图表列 - 最终完美版:不溢出 + 一定可见 */}
<Col xs={24} lg={6} style={{ flex: '0 0 25%', padding: '0 8px', display: 'flex', flexDirection: 'column', height: '100%', gap: "8px", overflowX: 'hidden', overflowY: 'auto', scrollbarWidth: 'thin', scrollbarColor: '#ccc transparent' }}>
<Card
title="发电趋势"
bordered={false}
style={{
...cardStyle,
flex: 1,
padding: '8px 12px',
display: 'flex',
flexDirection: 'column',
boxSizing: 'border-box'
}}
bodyStyle={{ padding: 8 }}
>
<Line
2026-05-07 20:25:14 +08:00
{...powerTrendConfig}
height={100} /* 图表安全高度 */
autoFit={true}
style={{ width: '100%' }}
/>
2026-05-07 20:25:14 +08:00
</Card>
<Card
title="辐照度与温度"
bordered={false}
style={{
...cardStyle,
flex: 1,
padding: '8px 12px',
display: 'flex',
flexDirection: 'column',
boxSizing: 'border-box'
}}
bodyStyle={{ padding: 8 }}
>
<Line
2026-05-07 20:25:14 +08:00
{...irradianceConfig}
height={100} /* 图表安全高度 */
autoFit={true}
style={{ width: '100%' }}
/>
2026-05-07 20:25:14 +08:00
</Card>
<Card
title="逆变器效率"
bordered={false}
style={{
...cardStyle,
flex: 1,
padding: '8px 12px',
display: 'flex',
flexDirection: 'column',
boxSizing: 'border-box'
}}
bodyStyle={{ padding: 8 }}
>
2026-05-07 20:25:14 +08:00
<Bar
{...invEfficiencyConfig}
height={100} /* 图表安全高度 */
autoFit={true}
style={{ width: '100%' }}
/>
2026-05-07 20:25:14 +08:00
</Card>
2026-05-07 20:25:14 +08:00
<Card
title="运维任务进度"
bordered={false}
style={{
...cardStyle,
flex: 1,
padding: '8px 12px',
display: 'flex',
flexDirection: 'column',
boxSizing: 'border-box'
}}
bodyStyle={{ padding: 8 }}
>
2026-05-07 20:25:14 +08:00
<Pie
{...taskProgressConfig}
height={100} /* 图表安全高度 */
autoFit={true}
style={{ width: '100%' }}
/>
</Card>
</Col>
2026-05-07 20:25:14 +08:00
<Col style={{ flex: '1 1 auto', }}>
<Row gutter={16} style={{ marginBottom: 8, height: '75%' }}>
<Col style={{ flex: '0 0 auto', width: '75%', height: "100%" }}>
<Card
title={
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
<div style={{ fontWeight: 500 }}>电站概览</div>
<div style={{ fontSize: 12, color: '#999' }}>GeoTIFF 正射底图 · 设备点位叠加</div>
</div>
2026-05-07 20:25:14 +08:00
</div>
}
bordered={false}
style={{ ...cardStyle, height: '100%', padding: '12px' }}
>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 12 }}>
<div style={{ display: 'flex', gap: 12, fontSize: 12 }}>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 8, height: 8, borderRadius: '50%', background: '#52c41a', marginRight: 4 }}></span>正常</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 8, height: 8, borderRadius: '50%', background: '#ff4d4f', marginRight: 4 }}></span>告警</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 8, height: 8, borderRadius: '50%', background: '#888', marginRight: 4 }}></span>离线</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 8, height: 8, borderRadius: '50%', background: '#faad14', marginRight: 4 }}></span>维护中</span>
</div>
<Space size="small">
<Button size="small">适应</Button>
<Button size="small" icon={<MinusOutlined />} />
<Button size="small" icon={<PlusOutlined />} />
<Button size="small" icon={<SyncOutlined />}>重置</Button>
<span style={{ fontSize: 12 }}>65%</span>
</Space>
</div>
<div style={{ height: 360, background: '#111827', borderRadius: 8, width: '100%' }} />
</Card>
</Col>
{/* 右侧:实时告警 */}
<Col
xs={24}
lg={6}
style={{
flex: '0 0 25%',
height: "100%",
overflow: 'auto',
scrollbarWidth: 'thin',
scrollbarColor: '#ccc transparent',
display: 'flex',
flexDirection: 'column',
gap: '12px' // 缩小卡片间距
}}
>
{/* 实时告警 */}
<Card
title={
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<span style={{ fontWeight: 600, fontSize: 14 }}>实时告警</span> {/* 缩小标题 */}
<Button type="link" style={{ padding: 0, fontSize: 12 }}>更多</Button>
</div>
}
bordered={false}
style={{
borderRadius: 8,
boxShadow: '0 1px 2px rgba(0,0,0,0.05)',
padding: '4px 8px'
}}
bodyStyle={{ padding: 4 }}
>
{realtimeAlerts.map((alert, idx) => (
<div
key={idx}
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
marginBottom: idx === realtimeAlerts.length - 1 ? 0 : 8, // 缩小行间距
fontSize: 12
}}
>
<div style={{ display: 'flex', alignItems: 'center' }}>
<Tag
color={alert.level === 'INFO' ? 'success' : 'error'}
style={{
borderRadius: 12,
padding: '0 6px',
marginRight: 8,
display: 'flex',
alignItems: 'center',
gap: 4,
fontSize: 10
}}
>
<span style={{ width: 6, height: 6, borderRadius: '50%', background: '#fff' }}></span>
{alert.level}
</Tag>
<span style={{ fontSize: 12 }}>{alert.type}</span> {/* 缩小 */}
</div>
<span style={{ color: '#666', fontSize: 12 }}>{alert.time}</span>
</div>
))}
</Card>
{/* 设备在线状态 */}
<Card
title={<span style={{ fontWeight: 600, fontSize: 14 }}>设备在线状态</span>}
bordered={false}
style={{
borderRadius: 8,
boxShadow: '0 1px 2px rgba(0,0,0,0.05)',
padding: '4px 8px'
}}
bodyStyle={{ padding: 4 }}
>
<Row gutter={[8, 8]}>
{deviceStatus.map((item, idx) => (
<Col span={12} key={idx}>
<div
style={{
padding: '8px 4px',
background: '#f5f7fa',
borderRadius: 6,
border: '1px solid #e8e8e8'
}}
>
<div style={{ fontSize: 14, color: '#333', marginBottom: 2 }}>
<span style={{ color: item.status === '正常' ? '#52c41a' : '#faad14' }}>{item.count}</span>
</div>
<div style={{ fontSize: 12, color: '#333', marginBottom: 2 }}>{item.name}</div>
<div style={{ fontSize: 10, color: item.status === '正常' ? '#52c41a' : '#faad14' }}>{item.status}</div>
</div>
</Col>
))}
</Row>
</Card>
{/* 天气信息 */}
<Card
title={<span style={{ fontWeight: 600, fontSize: 14 }}>天气信息</span>}
bordered={false}
style={{
borderRadius: 8,
boxShadow: '0 1px 2px rgba(0,0,0,0.05)',
padding: '4px 8px'
}}
bodyStyle={{ padding: 4 }}
>
<div style={{ display: 'flex', alignItems: 'center' }}>
<CloudOutlined style={{ fontSize: 32, color: '#1890ff', marginRight: 12 }} />
<div style={{ display: 'flex', flexDirection: 'row', gap: 12, alignItems: 'center' }}>
<div>
2026-05-07 20:25:14 +08:00
<div style={{ fontSize: 24, fontWeight: 600, color: '#1890ff' }}>22℃</div>
<div style={{ fontSize: 14, color: '#666', marginBottom: 2 }}>阴天</div>
</div>
2026-05-07 20:25:14 +08:00
<div>
<div style={{ fontSize: 11, color: '#999' }}>辐照度 89 W/m²</div>
<div style={{ fontSize: 11, color: '#999' }}>风速 4.1 m/s</div>
<div style={{ fontSize: 11, color: '#999' }}>中卫市</div>
</div>
2026-05-07 20:25:14 +08:00
</div>
2026-05-07 20:25:14 +08:00
</div>
</Card>
2026-05-07 20:25:14 +08:00
{/* 清洗建议 */}
<Card
title={
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<span style={{ fontWeight: 600, fontSize: 14 }}>清洗建议</span>
<Button type="link" style={{ padding: 0, fontSize: 12 }}>详情</Button>
</div>
}
bordered={false}
style={{
borderRadius: 8,
boxShadow: '0 1px 2px rgba(0,0,0,0.05)',
padding: '4px 8px'
}}
bodyStyle={{ padding: 4 }}
>
<div style={{ display: 'flex', alignItems: 'center' }}>
<div style={{ position: 'relative', width: 80, height: 80, marginRight: 12 }}>
<Pie
data={[{ type: '污染指数', value: 46 }]}
angleField="value"
colorField="type"
color={['#52c41a']}
radius={0.8}
innerRadius={0.7}
height={80}
autoFit={true}
/>
<div style={{ position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)', textAlign: 'center' }}>
<div style={{ fontSize: 24, fontWeight: 600, color: '#1890ff' }}>46</div>
<div style={{ fontSize: 12, color: '#666' }}>分</div>
</div>
</div>
<div>
<div style={{ fontSize: 12, color: '#333', marginBottom: 4 }}>污染指数中等,建议3天内安排B区清洗。</div>
<div style={{ fontSize: 11, color: '#999' }}>预计收益 ¥ 8,278</div>
</div>
</div>
</Card>
</Col>
2026-05-07 20:25:14 +08:00
</Row>
<Row gutter={16} style={{ height: '25%' }} >
<Col xs={12} style={{ height: '100%' }}>
<Card title="近期巡检记录" bordered={false} style={{ ...cardStyle, height: '100%' }} bodyStyle={{ padding: 12, height: '66%', overflow: 'auto', scrollbarWidth: 'thin', scrollbarColor: '#ccc transparent' }}>
{patrolRecords.map((item, idx) => (
<div key={idx} style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 10 }}>
<div>
2026-05-07 20:25:14 +08:00
<div style={{ fontSize: 13 }}>{item.name}</div>
<div style={{ fontSize: 12, color: '#999' }}>{item.device}</div>
</div>
<div style={{ display: 'flex', alignItems: 'center' }}>
<Tag size="small">{item.status}</Tag>
</div>
</div>
2026-05-07 20:25:14 +08:00
))}
</Card>
</Col>
<Col xs={12} style={{ height: '100%', }}>
<Card title="AI分析摘要" bordered={false} style={{ ...cardStyle, height: '100%' }} bodyStyle={{ padding: 12, height: '66%', overflow: 'auto', scrollbarWidth: 'thin', scrollbarColor: '#ccc transparent' }}>
{aiAnalysis.map((item, idx) => (
<div key={idx} style={{ display: 'flex', marginBottom: 10 }}>
<Tag color={item.type === 'AI分析' ? 'blue' : 'red'} style={{ marginRight: 8 }}>{item.type}</Tag>
<span style={{ fontSize: 12 }}>{item.content}</span>
</div>
))}
</Card>
</Col>
</Row>
</Col>
2026-05-07 20:25:14 +08:00
</Row >
</div >
);
2026-04-22 09:43:55 +08:00
}