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

641 lines
26 KiB
TypeScript
Raw Normal View History

2026-05-09 16:44:39 +08:00
import React, { useState, useEffect } from 'react';
2026-05-14 09:37:15 +08:00
import { Card, Row, Col, Statistic, Button, Space, Tag, Typography, Table } from 'antd';
import {
2026-05-07 20:25:14 +08:00
CloudOutlined, ThunderboltOutlined, BarChartOutlined,
RiseOutlined, BellOutlined, WalletOutlined,
2026-05-11 13:15:28 +08:00
MinusOutlined, PlusOutlined, SyncOutlined,
MoneyCollectOutlined,
2026-05-14 10:47:56 +08:00
DashboardOutlined,
FullscreenOutlined,
RocketOutlined,
VideoCameraOutlined,
AppstoreOutlined,
ExperimentOutlined,
BranchesOutlined,
RobotOutlined
2026-04-17 17:20:41 +08:00
} from '@ant-design/icons';
2026-05-14 10:47:56 +08:00
import { Line, Bar, Pie, } from '@ant-design/charts';
2026-05-12 14:13:54 +08:00
import { getWeatherData, getWeatherType } from '../lib/utils';
import WeatherDisplay from '../components/Weather';
2026-05-14 10:47:56 +08:00
import bgMain from '../assets/images/bgmain.jpg';
2026-05-14 15:15:50 +08:00
import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../components/recharts';
2026-05-09 16:44:39 +08:00
2026-05-11 13:15:28 +08:00
2026-05-07 20:25:14 +08:00
const { Text } = Typography;
2026-05-09 16:44:39 +08:00
2026-05-07 20:25:14 +08:00
export default function StationDashboard() {
2026-05-09 16:44:39 +08:00
const [weatherdata, setWeatherData] = useState({
province: "江苏省",
city: "南通市",
district: "崇川区",
adcode: "320613",
weather: "晴",
weather_icon: "100",
temperature: 18,
wind_direction: "西南风",
wind_power: "2级",
humidity: 53,
report_time: "2026-03-27 12:35:08"
});
2026-05-12 14:13:54 +08:00
const weatherType = getWeatherType(weatherdata.weather);
2026-05-09 16:44:39 +08:00
// 请求天气接口
useEffect(() => {
const fetchWeather = async () => {
try {
const res = await getWeatherData();
setWeatherData(res);
} catch (err) {
console.error("天气接口请求失败", err);
}
};
fetchWeather();
}, []);
2026-05-07 20:25:14 +08:00
// 模拟数据
const stationOverview = {
2026-05-11 13:15:28 +08:00
todayEnergy: 4752.0,
currentPower: 812.6,
systemEfficiency: 82.6,
2026-05-07 20:25:14 +08:00
yesterdayEfficiency: 81.3,
2026-05-11 13:15:28 +08:00
systemAvailability: 99.35,
2026-05-07 20:25:14 +08:00
onlineDevices: "12/13",
2026-05-11 13:15:28 +08:00
alarmCount: 8,
costSaved: 36540
2026-05-07 20:25:14 +08:00
};
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 = [
2026-05-14 15:54:40 +08:00
{ name: "升压站安防巡检任务", device: "UAV-01", status: "草稿", time: "04-29T...", person: "张运维" },
{ name: "B区清洗任务", device: "CLEAN-01", status: "待执行", time: "04-29T...", person: "张运维" },
{ name: "A区巡检任务", device: "ROBOT-01", status: "已派发", time: "04-29T...", person: "张运维" }
];
2026-05-07 20:25:14 +08:00
const aiAnalysis = [
2026-05-14 15:54:40 +08:00
{ type: "AI分析", content: "AI发现逆变器温度与组串电流存在轻微异常,建议优先复核A区设备。", desc: "发现2处组件存在异常热斑" },
{ type: "严重", content: "INV-A02散热检修建议:建议检查INV-A02散热风扇、风道和运行负载,持续高温时转维修工单。", desc: "3个组串存在发电异常" },
{ type: "严重", content: "A05阵列热斑处置建议:建议现场复核PV-A05-018至PV-A05-020组件接线和旁路二极管状态,必要时更换异常组件。", desc: "整体发电偏差-2.8%" }
];
2026-05-09 15:02:31 +08:00
// 图表配置 —— 终极美化版(渐变+紧凑+高级)
2026-05-14 15:15:50 +08:00
const powerTrendData = [
{ time: '00:00', actual: 1800, predict: 1600 },
{ time: '04:00', actual: 1500, predict: 1400 },
{ time: '06:00', actual: 8000, predict: 7500 },
{ time: '08:00', actual: 32000, predict: 30000 },
{ time: '10:00', actual: 58000, predict: 56000 },
{ time: '12:00', actual: 62000, predict: 60000 },
{ time: '14:00', actual: 59000, predict: 57000 },
{ time: '16:00', actual: 42000, predict: 40000 },
{ time: '18:00', actual: 12000, predict: 10000 },
{ time: '20:00', actual: 3000, predict: 2500 },
{ time: '24:00', actual: 1800, predict: 1600 },
];
2026-05-14 09:37:15 +08:00
2026-05-14 15:15:50 +08:00
const irradianceData = [
{ time: '00:00', irradiance: 40, temperature: 14 },
{ time: '04:00', irradiance: 30, temperature: 12 },
{ time: '06:00', irradiance: 180, temperature: 16 },
{ time: '08:00', irradiance: 460, temperature: 21 },
{ time: '10:00', irradiance: 780, temperature: 27 },
{ time: '12:00', irradiance: 860, temperature: 31 },
{ time: '14:00', irradiance: 820, temperature: 30 },
{ time: '16:00', irradiance: 620, temperature: 26 },
{ time: '18:00', irradiance: 220, temperature: 20 },
{ time: '20:00', irradiance: 60, temperature: 16 },
{ time: '24:00', irradiance: 40, temperature: 14 },
];
const invEfficiencyData = [
{ device: 'INV-01', efficiency: 98.6 },
{ device: 'INV-02', efficiency: 97.8 },
{ device: 'INV-03', efficiency: 97.2 },
{ device: 'INV-04', efficiency: 96.5 },
{ device: 'INV-05', efficiency: 95.8 },
];
2026-05-07 20:25:14 +08:00
2026-05-14 15:15:50 +08:00
const taskProgressData = [
{ name: '已完成', value: 40, color: '#1890ff' },
{ name: '进行中', value: 35, color: '#52c41a' },
{ name: '待开始', value: 20, color: '#faad14' },
{ name: '异常', value: 5, color: '#ff4d4f' },
];
2026-05-07 20:25:14 +08:00
2026-05-14 10:47:56 +08:00
const cardStyle = { borderRadius: 12, border: '1px solid #f0f0f0', boxShadow: '0 2px 8px rgba(0,0,0,0.04)' };
// 顶部卡片微型图表配置
const tinyAreaConfig = {
height: 40,
autoFit: true,
data: [264, 417, 438, 887, 309, 397, 550, 575, 563, 430, 525, 592, 492, 467, 513, 546, 983, 340, 539, 243, 226, 192],
smooth: true,
areaStyle: { fill: 'l(270) 0:#ffffff 0.5:#165DFF 1:#165DFF', fillOpacity: 0.1 },
line: { color: '#165DFF' },
};
const tinyColumnConfig = {
height: 40,
autoFit: true,
data: [274, 337, 81, 497, 666, 219, 269],
color: '#00B42A',
};
2026-05-07 20:25:14 +08:00
return (
2026-05-14 10:47:56 +08:00
<div style={{ background: '#f8fafc', padding: '16px', minHeight: '100vh', width: '100%', boxSizing: 'border-box' }}>
2026-05-14 09:37:15 +08:00
<Row gutter={[16, 16]} style={{ margin: '0 16px 16px 16px' }}>
{[
{ title: '今日发电量', value: '4,752', unit: 'kWh', sub: '日目标 5,000 kWh', color: '#00B42A', bg: '#E8FFEA', icon: <ThunderboltOutlined /> },
{ title: '当前功率', value: '812.6', unit: 'kW', sub: '装机容量 1,000 kWp', color: '#165DFF', bg: '#E8F3FF', icon: <DashboardOutlined /> },
{ title: 'Performance Ratio', value: '82.6%', unit: '', sub: '昨日 81.3% ↑1.3%', color: '#00B42A', bg: '#E8FFEA', icon: <BarChartOutlined /> },
{ title: '系统可用率', value: '99.35%', unit: '', sub: '昨日 99.12% ↑0.23%', color: '#165DFF', bg: '#E8F3FF', icon: <RiseOutlined /> },
{ title: '告警数量', value: '8', unit: '', sub: '未处理 5 / 已处理 3', color: '#F53F3F', bg: '#FFF1F0', icon: <BellOutlined /> },
{ title: '节省运维成本', value: '¥ 36,540', unit: '', sub: '本月累计节省', color: '#FF7D00', bg: '#FFF7E8', icon: <MoneyCollectOutlined /> },
].map((item, idx) => (
2026-05-14 16:25:10 +08:00
<Col key={idx} style={{
flex: '0 0 auto', // 关键:不拉伸
width: '240px', // 固定卡片宽度
maxWidth: '240px',
minWidth: '240px'
}}>
<Card
bordered={false}
style={{ ...cardStyle, height: "100%" }}
bodyStyle={{ padding: '16px' }}
>
2026-05-14 09:37:15 +08:00
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
2026-05-14 16:25:10 +08:00
<div style={{ color: '#000', fontSize: '14px', fontWeight: 600, marginBottom: 8 }}>{item.title}</div>
2026-05-14 09:37:15 +08:00
<div style={{ display: 'flex', alignItems: 'baseline' }}>
2026-05-14 16:25:10 +08:00
<span style={{ color: item.color, fontSize: '24px', fontWeight: 800 }}>{item.value}</span>
{item.unit && <span style={{ color: '#666', fontSize: '14px', marginLeft: 4 }}>{item.unit}</span>}
2026-05-14 09:37:15 +08:00
</div>
2026-05-14 16:25:10 +08:00
<div style={{ fontSize: '12px', color: '#999', marginTop: 8 }}>{item.sub}</div>
2026-05-11 13:15:28 +08:00
</div>
2026-05-14 09:37:15 +08:00
<div style={{
width: 50, height: 50, background: item.bg, borderRadius: '50%',
display: 'flex', justifyContent: 'center', alignItems: 'center',
boxShadow: `0 2px 8px ${item.color}1A`
}}>
{React.cloneElement(item.icon as React.ReactElement, { style: { fontSize: 28, color: item.color } })}
2026-05-11 13:15:28 +08:00
</div>
</div>
2026-05-14 09:37:15 +08:00
</Card>
</Col>
))}
</Row>
2026-05-14 10:47:56 +08:00
{/* 主体布局 */}
<Row gutter={[16, 16]}>
{/* 左侧:图表列 */}
<Col xs={24} xl={6}>
<Space direction="vertical" size={16} style={{ width: '100%' }}>
<Card title={<span style={{ fontWeight: 800 }}>发电趋势</span>} extra={<Space><SyncOutlined /><FullscreenOutlined /></Space>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<div style={{ fontSize: 12, color: '#666', marginBottom: 12 }}>今日发电功率趋势 (kW)</div>
2026-05-14 15:15:50 +08:00
<UniversalLineChart
data={powerTrendData}
xKey="time"
height={220}
smooth
dot
backgroundColor="transparent"
series={[
{
key: 'actual',
name: '实际',
color: '#165DFF',
strokeWidth: 3,
},
{
key: 'predict',
name: '预测',
color: '#00B42A',
strokeWidth: 2,
},
]}
/> </Card>
2026-05-14 10:47:56 +08:00
<Card title={<span style={{ fontWeight: 800 }}>辐照度与温度趋势</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
2026-05-14 15:15:50 +08:00
<UniversalLineChart
data={irradianceData}
xKey="time"
height={220}
smooth
dot
backgroundColor="transparent"
series={[
{
key: 'irradiance',
name: '辐照度',
color: '#165DFF',
strokeWidth: 3,
},
{
key: 'temperature',
name: '温度',
color: '#00B42A',
strokeWidth: 2,
},
]}
/> </Card>
2026-05-14 10:47:56 +08:00
<Card title={<span style={{ fontWeight: 800 }}>逆变器效率对比</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
2026-05-14 15:15:50 +08:00
<UniversalBarChart
data={invEfficiencyData}
xKey="device"
height={220}
backgroundColor="transparent"
barSize={28}
radius={[6, 6, 0, 0]}
series={[
{
key: 'efficiency',
name: '效率',
color: '#165DFF',
},
]}
/> </Card>
2026-05-14 10:47:56 +08:00
<Card title={<span style={{ fontWeight: 800 }}>运维任务进度</span>} extra={<Button type="link" size="small">更多 &gt;</Button>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<div style={{ display: 'flex', alignItems: 'center' }}>
2026-05-14 15:15:50 +08:00
<UniversalPieChart
data={taskProgressData}
width={220}
height={220}
innerRadius={45}
outerRadius={70}
backgroundColor="transparent"
/> <div style={{ flex: 1, paddingLeft: 12 }}>
2026-05-14 10:47:56 +08:00
<div style={{ textAlign: 'center' }}>
<div style={{ fontSize: 12, color: '#999' }}>总任务</div>
<div style={{ fontSize: 20, fontWeight: 800 }}>12</div>
</div>
</div>
</div>
</Card>
</Space>
</Col>
2026-05-14 10:47:56 +08:00
{/* 中间:底图与状态 */}
<Col xs={24} xl={12}>
<Space direction="vertical" size={16} style={{ width: '100%' }}>
<Card
title={
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<span style={{ fontWeight: 800 }}>电站概览</span>
<div style={{ display: 'flex', gap: 16, fontSize: 12 }}>
2026-05-07 20:25:14 +08:00
<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>
</div>
2026-05-14 10:47:56 +08:00
}
bordered={false}
style={cardStyle}
bodyStyle={{ padding: 0, position: 'relative', overflow: 'hidden', height: 500 }}
2026-05-07 20:25:14 +08:00
>
2026-05-14 10:47:56 +08:00
<div style={{ height: "100%", background: '#111827', borderRadius: 8, width: '100%', overflow: 'hidden', position: "relative" }}>
<iframe
src="https://pvs.satabot.com/?platform=web"
2026-05-12 14:13:54 +08:00
style={{
2026-05-14 10:47:56 +08:00
width: '100%',
height: '100%',
border: 'none',
borderRadius: '8px',
position: "absolute",
2026-05-12 14:13:54 +08:00
}}
2026-05-14 10:47:56 +08:00
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
title="外部系统"
/>
</div>
{/* 背景图层 */}
{/*<div style={{
width: '100%', height: '100%',
background: `url(${bgMain}) center/cover no-repeat`,
backgroundColor: '#f0f2f5',
position: 'relative'
}}>*/}
{/* 信息点 */}
{/*<div style={{ position: 'absolute', top: '15%', left: '20%', background: 'rgba(0,0,0,0.6)', color: '#fff', padding: '4px 10px', borderRadius: 20, fontSize: 12 }}>
<CloudOutlined style={{ marginRight: 4 }} /> 气象站 · <span style={{ color: '#52c41a' }}>正常</span>
</div>
<div style={{ position: 'absolute', top: '10%', left: '60%', background: 'rgba(0,0,0,0.6)', color: '#fff', padding: '4px 10px', borderRadius: 20, fontSize: 12 }}>
<RocketOutlined style={{ marginRight: 4 }} /> 无人机 · <span style={{ color: '#52c41a' }}>正常</span>
</div>
<div style={{ position: 'absolute', top: '20%', left: '80%', background: 'rgba(0,0,0,0.6)', color: '#fff', padding: '4px 10px', borderRadius: 20, fontSize: 12 }}>
<VideoCameraOutlined style={{ marginRight: 4 }} /> 摄像头 12 · <span style={{ color: '#52c41a' }}>正常</span>
</div>
<div style={{ position: 'absolute', top: '40%', left: '45%', background: 'rgba(0,0,0,0.6)', color: '#fff', padding: '6px 12px', borderRadius: 20, fontSize: 13, border: '1px solid #165DFF' }}>
<AppstoreOutlined style={{ marginRight: 4 }} /> 组件阵列 · <span style={{ color: '#52c41a' }}>正常</span>
</div>
<div style={{ position: 'absolute', bottom: '30%', left: '30%', background: 'rgba(0,0,0,0.6)', color: '#fff', padding: '4px 10px', borderRadius: 20, fontSize: 12 }}>
<ThunderboltOutlined style={{ marginRight: 4 }} /> 逆变器 5 · <span style={{ color: '#52c41a' }}>正常</span>
</div>
<div style={{ position: 'absolute', bottom: '20%', left: '50%', background: 'rgba(0,0,0,0.6)', color: '#fff', padding: '4px 10px', borderRadius: 20, fontSize: 12 }}>
<BranchesOutlined style={{ marginRight: 4 }} /> 汇流箱 20 · <span style={{ color: '#52c41a' }}>正常</span>
</div>
<div style={{ position: 'absolute', bottom: '15%', left: '70%', background: 'rgba(0,0,0,0.6)', color: '#fff', padding: '4px 10px', borderRadius: 20, fontSize: 12 }}>
<RobotOutlined style={{ marginRight: 4 }} /> 巡检机器人 · <span style={{ color: '#52c41a' }}>正常</span>
</div>*/}
{/*</div>*/}
</Card>
2026-05-09 16:44:39 +08:00
2026-05-14 10:47:56 +08:00
<Row gutter={16}>
<Col span={12}>
2026-05-14 15:54:40 +08:00
<Card title={<span style={{ fontWeight: 800 }}>近期巡检记录</span>} extra={<Button type="link" size="small">更多 &gt;</Button>} bordered={false} style={{ ...cardStyle, height: "100%" }} bodyStyle={{ padding: '0 12px' }}>
2026-05-14 10:47:56 +08:00
<Table
dataSource={patrolRecords}
pagination={false}
size="small"
columns={[
{ title: '巡检类型', dataIndex: 'name', key: 'name', ellipsis: true },
2026-05-14 15:54:40 +08:00
{ title: '巡检时间', dataIndex: 'time', key: 'time', },
{ title: '巡检人员', dataIndex: 'person', key: 'person', render: (t) => t.substring(0, 10) },
2026-05-14 10:47:56 +08:00
{ title: '状态', dataIndex: 'status', key: 'status', render: (s) => <span style={{ color: '#52c41a', fontSize: 12 }}>● 已完成</span> },
]}
/>
</Card>
</Col>
<Col span={12}>
2026-05-14 15:54:40 +08:00
<Card
title={<span style={{ fontWeight: 800 }}>AI 分析摘要</span>}
bordered={false}
style={{ ...cardStyle, height: "100%" }} bodyStyle={{ padding: '12px' }}
>
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
{/* 热点检测 */}
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
<div style={{
width: 56,
height: 56,
borderRadius: 12,
background: 'rgba(114, 46, 209, 0.1)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0
}}>
<ThunderboltOutlined style={{ fontSize: 24, color: '#722ed1' }} />
</div>
<div>
<div style={{ fontSize: 16, fontWeight: 600, color: '#1D2129' }}>热点检测</div>
<div style={{ fontSize: 14, color: '#4E5969', marginTop: 4 }}>
发现 <span style={{ color: '#165DFF', fontWeight: 600 }}>2</span> 处组件存在异常热斑
</div>
</div>
</div>
<Button type="link" size="small" style={{ color: '#165DFF' }}>查看详情</Button>
</div>
2026-05-14 15:54:40 +08:00
{/* 组串异常 */}
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
<div style={{
width: 56,
height: 56,
borderRadius: 12,
background: 'rgba(82, 196, 26, 0.1)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0
}}>
<AppstoreOutlined style={{ fontSize: 24, color: '#52c41a' }} />
</div>
<div>
<div style={{ fontSize: 16, fontWeight: 600, color: '#1D2129' }}>组串异常</div>
<div style={{ fontSize: 14, color: '#4E5969', marginTop: 4 }}>
<span style={{ color: '#165DFF', fontWeight: 600 }}>3</span> 个组串存在发电异常
</div>
</div>
</div>
<Button type="link" size="small" style={{ color: '#165DFF' }}>查看详情</Button>
</div>
2026-05-14 15:54:40 +08:00
{/* 发电偏差分析 */}
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
<div style={{
width: 56,
height: 56,
borderRadius: 12,
background: 'rgba(22, 93, 255, 0.1)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0
}}>
<RiseOutlined style={{ fontSize: 24, color: '#165DFF' }} />
</div>
<div>
<div style={{ fontSize: 16, fontWeight: 600, color: '#1D2129' }}>发电偏差分析</div>
<div style={{ fontSize: 14, color: '#4E5969', marginTop: 4 }}>
整体发电偏差 <span style={{ color: '#165DFF', fontWeight: 600 }}>-2.8%</span>
</div>
</div>
</div>
<Button type="link" size="small" style={{ color: '#165DFF' }}>查看详情</Button>
2026-05-07 20:25:14 +08:00
</div>
</div>
2026-05-14 10:47:56 +08:00
</Card>
</Col>
</Row>
</Space>
</Col>
{/* 右侧:状态与分析 */}
<Col xs={24} xl={6}>
<Space direction="vertical" size={16} style={{ width: '100%' }}>
2026-05-14 15:54:40 +08:00
<Card
title={<span style={{ fontWeight: 800 }}>实时告警</span>}
extra={<Button type="link" size="small">更多 &gt;</Button>}
bordered={false}
style={cardStyle}
bodyStyle={{ padding: '12px' }}
>
{/* 表头 */}
<div style={{
display: 'flex',
justifyContent: 'space-between',
marginBottom: 12,
padding: '0 4px 8px',
borderBottom: '1px solid #f0f0f0',
fontSize: 13,
color: '#666'
}}>
<span style={{ flex: 3 }}>告警内容</span>
<span style={{ flex: 1, textAlign: 'center' }}>级别</span>
<span style={{ flex: 1.5, textAlign: 'right' }}>发生时间</span>
</div>
{realtimeAlerts.map((alert, idx) => {
// 映射级别颜色和圆点颜色
let dotColor, tagColor;
if (alert.level === '严重') {
dotColor = '#ff4d4f';
tagColor = 'error';
} else if (alert.level === '重要') {
dotColor = '#fa8c16';
tagColor = 'warning';
} else {
dotColor = '#1677ff';
tagColor = 'processing';
}
return (
<div
key={idx}
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
marginBottom: 12,
padding: '0 4px',
borderBottom: idx < realtimeAlerts.length - 1 ? '1px solid #f5f5f5' : 'none',
paddingBottom: 8
}}
>
{/* 告警内容(带圆点) */}
<div style={{ display: 'flex', alignItems: 'center', flex: 3, minWidth: 0 }}>
<div style={{
width: 12,
height: 12,
borderRadius: '50%',
backgroundColor: dotColor,
marginRight: 8,
flexShrink: 0
}} />
<span style={{ fontSize: 13, fontWeight: 500, whiteSpace: 'normal', wordBreak: 'break-all' }}>
{alert.type}
</span>
</div>
{/* 级别标签 */}
<div style={{ flex: 1, textAlign: 'center' }}>
<Tag color={tagColor} style={{ fontSize: 12 }}>{alert.level}</Tag>
</div>
{/* 发生时间 */}
<div style={{ flex: 1.5, textAlign: 'right', fontSize: 13, color: '#333' }}>
{alert.time}
</div>
2026-05-07 20:25:14 +08:00
</div>
2026-05-14 15:54:40 +08:00
);
})}
2026-05-14 10:47:56 +08:00
</Card>
2026-05-14 15:54:40 +08:00
<Card
title={<span style={{ fontWeight: 800 }}>设备在线状态</span>}
extra={<Button type="link" size="small">更多 &gt;</Button>}
bordered={false}
style={cardStyle}
bodyStyle={{ padding: '12px' }}
>
<Row gutter={[16, 16]}>
2026-05-14 10:47:56 +08:00
{[
{ name: '组件阵列', count: '320/320', icon: <AppstoreOutlined /> },
{ name: '逆变器', count: '5/5', icon: <ThunderboltOutlined /> },
{ name: '汇流箱', count: '20/20', icon: <BranchesOutlined /> },
{ name: '气象站', count: '1/1', icon: <CloudOutlined /> },
{ name: '摄像头', count: '12/12', icon: <VideoCameraOutlined /> },
{ name: '环境传感器', count: '8/8', icon: <ExperimentOutlined /> },
{ name: '无人机', count: '1/1', icon: <RocketOutlined /> },
{ name: '巡检机器人', count: '1/1', icon: <RobotOutlined /> },
].map((item, idx) => (
2026-05-14 15:54:40 +08:00
<Col span={6} key={idx} style={{ display: 'flex', alignItems: 'center' }}>
{/* 绿色圆形图标 */}
<div style={{
width: 20,
height: 20,
borderRadius: '50%',
border: '2px solid #52c41a',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
marginRight: 12,
flexShrink: 0
}}>
<div style={{ fontSize: 12, color: '#52c41a' }}>
{item.icon}
</div>
</div>
{/* 名称+在线数 */}
<div style={{ textAlign: 'left' }}>
<div style={{ fontSize: 12, color: '#333', fontWeight: 600 }}>
{item.name}
</div>
<div style={{ fontSize: 10, color: '#52c41a', fontWeight: 700, marginTop: 4 }}>
{item.count}
</div>
</div>
2026-05-14 10:47:56 +08:00
</Col>
2026-05-07 20:25:14 +08:00
))}
2026-05-14 10:47:56 +08:00
</Row>
</Card>
<Card title={<span style={{ fontWeight: 800 }}>天气信息</span>} extra={<Button type="link" size="small">详细 &gt;</Button>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
2026-05-14 15:54:40 +08:00
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'start', gap: 20 }}>
2026-05-14 10:47:56 +08:00
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
2026-05-14 15:54:40 +08:00
<WeatherDisplay type={weatherType} />
<div style={{ flex: 1, flexDirection: "row" }}>
<div style={{ fontSize: 28, fontWeight: 800, color: '#1890ff' }}>
{weatherdata.temperature}℃
</div>
<div style={{ fontSize: 14, color: '#333', marginBottom: 6 }}>
{weatherdata.weather}
</div>
2026-05-07 20:25:14 +08:00
</div>
2026-05-14 10:47:56 +08:00
</div>
2026-05-14 15:54:40 +08:00
<div style={{ fontSize: 12, color: '#666', lineHeight: 1.6 }}>
<div>湿度 {weatherdata.humidity}%</div>
<div>{weatherdata.wind_direction} {weatherdata.wind_power}</div>
<div>{weatherdata.city} · {weatherdata.district}</div>
2026-05-14 10:47:56 +08:00
</div>
</div>
</Card>
2026-05-07 20:25:14 +08:00
2026-05-14 10:47:56 +08:00
<Card title={<span style={{ fontWeight: 800 }}>清洗建议</span>} extra={<Button type="link" size="small">更多 &gt;</Button>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 16, marginBottom: 16 }}>
<div style={{ width: 80, height: 80, position: 'relative' }}>
2026-05-14 15:54:40 +08:00
<UniversalPieChart
data={[
{ name: '清洁度', value: 85, color: '#00B42A' },
{ name: '待清洗', value: 15, color: '#E8FFEA' },
]}
width="100%"
height="100%"
innerRadius={20}
outerRadius={26}
showTooltip={false}
showLegend={false}
showLabel={false}
/>
2026-05-14 10:47:56 +08:00
</div>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 12, color: '#666', marginBottom: 4 }}>建议清洗时间: <span style={{ color: '#165DFF' }}>3天内</span></div>
<div style={{ fontSize: 12, color: '#666', marginBottom: 4 }}>预计提升发电量: <span style={{ color: '#00B42A' }}>2.6 %</span></div>
<div style={{ fontSize: 12, color: '#666' }}>预计提升电量: <span style={{ color: '#00B42A' }}>120 kWh/天</span></div>
</div>
</div>
<Button type="primary" block style={{ borderRadius: 8, height: 36 }} onClick={() => message.success('清洗工单已生成')}>生成清洗工单</Button>
</Card>
</Space>
</Col>
2026-05-14 10:47:56 +08:00
</Row>
</div>
);
2026-04-22 09:43:55 +08:00
}