import React, { useState, useEffect } from 'react'; import { Card, Row, Col, Statistic, Button, Space, Tag, Typography, Table } from 'antd'; import { CloudOutlined, ThunderboltOutlined, BarChartOutlined, RiseOutlined, BellOutlined, WalletOutlined, MinusOutlined, PlusOutlined, SyncOutlined, MoneyCollectOutlined, DashboardOutlined } from '@ant-design/icons'; import { Line, Bar, Pie } from '@ant-design/charts'; import { getWeatherData, getWeatherType } from '../lib/utils'; import WeatherDisplay from '../components/Weather'; const { Text } = Typography; export default function StationDashboard() { 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" }); const weatherType = getWeatherType(weatherdata.weather); // 请求天气接口 useEffect(() => { const fetchWeather = async () => { try { const res = await getWeatherData(); setWeatherData(res); } catch (err) { console.error("天气接口请求失败", err); } }; fetchWeather(); }, []); // 模拟数据 const stationOverview = { todayEnergy: 4752.0, currentPower: 812.6, systemEfficiency: 82.6, yesterdayEfficiency: 81.3, systemAvailability: 99.35, onlineDevices: "12/13", alarmCount: 8, costSaved: 36540 }; const realtimeAlerts = [ { level: "INFO", type: "设备离线", time: "04-28 18:44" }, { level: "严重", type: "逆变器温度过高", time: "04-28 18:44" } ]; const deviceStatus = [ { name: "汇流箱", count: "2/2", status: "异常 1" }, { name: "逆变器", count: "3/3", status: "异常 1" }, { name: "电表", count: "1/1", status: "正常" }, { name: "巡检机器人", count: "1/1", status: "正常" } ]; 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..." } ]; const aiAnalysis = [ { type: "AI分析", content: "AI发现逆变器温度与组串电流存在轻微异常,建议优先复核A区设备。" }, { type: "严重", content: "INV-A02散热检修建议:建议检查INV-A02散热风扇、风道和运行负载,持续高温时转维修工单。" }, { type: "严重", content: "A05阵列热斑处置建议:建议现场复核PV-A05-018至PV-A05-020组件接线和旁路二极管状态,必要时更换异常组件。" } ]; // 图表配置 —— 终极美化版(渐变+紧凑+高级) const powerTrendConfig = { data: [ { time: "00:00", type: "实际", value: 1800 }, { time: "00:00", type: "预测", value: 1600 }, { time: "04:00", type: "实际", value: 1500 }, { time: "04:00", type: "预测", value: 1400 }, { time: "06:00", type: "实际", value: 8000 }, { time: "06:00", type: "预测", value: 7500 }, { time: "08:00", type: "实际", value: 32000 }, { time: "08:00", type: "预测", value: 30000 }, { time: "10:00", type: "实际", value: 58000 }, { time: "10:00", type: "预测", value: 56000 }, { time: "12:00", type: "实际", value: 62000 }, { time: "12:00", type: "预测", value: 60000 }, { time: "14:00", type: "实际", value: 59000 }, { time: "14:00", type: "预测", value: 57000 }, { time: "16:00", type: "实际", value: 42000 }, { time: "16:00", type: "预测", value: 40000 }, { time: "18:00", type: "实际", value: 12000 }, { time: "18:00", type: "预测", value: 10000 }, { time: "20:00", type: "实际", value: 3000 }, { time: "20:00", type: "预测", value: 2500 }, { time: "24:00", type: "实际", value: 1800 }, { time: "24:00", type: "预测", value: 1600 } ], xField: 'time', yField: 'value', seriesField: 'type', smooth: true, color: ['#165DFF', '#00B42A'], // ✅ 两条线颜色 lineStyle: { lineWidth: 2 }, point: { size: 5, shape: 'circle' }, area: false, legend: { position: 'top-left' }, yAxis: { min: 0, max: 68000 }, }; const irradianceConfig = { // 👇 我已经帮你把数据改成支持多色的格式 data: [ { time: "00:00", name: "辐照度", value: 40 }, { time: "00:00", name: "温度", value: 14 }, { time: "04:00", name: "辐照度", value: 30 }, { time: "04:00", name: "温度", value: 12 }, { time: "06:00", name: "辐照度", value: 180 }, { time: "06:00", name: "温度", value: 16 }, { time: "08:00", name: "辐照度", value: 460 }, { time: "08:00", name: "温度", value: 21 }, { time: "10:00", name: "辐照度", value: 780 }, { time: "10:00", name: "温度", value: 27 }, { time: "12:00", name: "辐照度", value: 860 }, { time: "12:00", name: "温度", value: 31 }, { time: "14:00", name: "辐照度", value: 820 }, { time: "14:00", name: "温度", value: 30 }, { time: "16:00", name: "辐照度", value: 620 }, { time: "16:00", name: "温度", value: 26 }, { time: "18:00", name: "辐照度", value: 220 }, { time: "18:00", name: "温度", value: 20 }, { time: "20:00", name: "辐照度", value: 60 }, { time: "20:00", name: "温度", value: 16 }, { time: "24:00", name: "辐照度", value: 40 }, { time: "24:00", name: "温度", value: 14 }, ], xField: "time", yField: "value", // 现在只用一个 value seriesField: "name", // 按 name 区分两条线 smooth: true, color: ["#165DFF", "#00B42A"], point: { size: 5, shape: "circle", }, area: false, animation: { appear: { animation: "path-in", duration: 1500, }, }, grid: { line: { style: { stroke: "#eee", lineWidth: 0.5, }, }, }, legend: { position: "top-left", }, yAxis: { min: 0, max: 900, tickCount: 6, }, }; const invEfficiencyConfig = { data: [ { 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 } ], // 恢复为竖向柱状图:X轴是设备,Y轴是效率 xField: 'device', yField: 'efficiency', // 每个柱子不同颜色,效率越高越亮 color: ({ efficiency }) => { if (efficiency >= 98) return '#00B42A'; // 亮绿(最高效) if (efficiency >= 97) return '#52C41A'; // 草绿 if (efficiency >= 96) return '#1890FF'; // 天蓝 if (efficiency >= 95) return '#4080FF'; // 蓝色 return '#808695'; // 灰色(最低效) }, barStyle: { radius: [4, 4, 0, 0] // 顶部圆角,和第二张图效果一致 }, // 标签放在柱子顶部,显示百分比 label: { position: 'top', style: { fontSize: 11, fill: '#333', fontWeight: 600 }, formatter: (item) => `${item}%` }, // Y轴从60开始(和第二张图的刻度一致),让柱子更饱满 yAxis: { min: 60, max: 100, tickCount: 5, // 控制刻度数量,显示60/70/80/90/100 label: { formatter: (v) => `${v}` } }, // 隐藏X轴上的线,保持简洁 xAxis: { line: null }, grid: { line: { style: { stroke: '#eee', lineWidth: 0.5 } } }, animation: { appear: { animation: 'scale-in-y', duration: 1000 } } }; 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 (
{/* 顶部统计卡片 */} {[ { title: '今日发电量', value: '4,752', unit: 'kWh', sub: '日目标 5,000 kWh', color: '#00B42A', bg: '#E8FFEA', icon: }, { title: '当前功率', value: '812.6', unit: 'kW', sub: '装机容量 1,000 kWp', color: '#165DFF', bg: '#E8F3FF', icon: }, { title: 'Performance Ratio', value: '82.6%', unit: '', sub: '昨日 81.3% ↑1.3%', color: '#00B42A', bg: '#E8FFEA', icon: }, { title: '系统可用率', value: '99.35%', unit: '', sub: '昨日 99.12% ↑0.23%', color: '#165DFF', bg: '#E8F3FF', icon: }, { title: '告警数量', value: '8', unit: '', sub: '未处理 5 / 已处理 3', color: '#F53F3F', bg: '#FFF1F0', icon: }, { title: '节省运维成本', value: '¥ 36,540', unit: '', sub: '本月累计节省', color: '#FF7D00', bg: '#FFF7E8', icon: }, ].map((item, idx) => (
{item.title}
{item.value} {item.unit && {item.unit}}
{item.sub}
{React.cloneElement(item.icon as React.ReactElement, { style: { fontSize: 28, color: item.color } })}
))}
{/* 主体:左侧图表 + 中间电站 + 右侧告警 —— 强制一行不换行 */} {/* 左侧图表列 - 最终完美版:不溢出 + 一定可见 */} 发电趋势} bordered={false} style={{ borderRadius: 8, flex: 1, padding: 0 }} bodyStyle={{ padding: '8px 12px' }} > 辐照度与温度} bordered={false} style={{ borderRadius: 8, flex: 1, padding: 0 }} bodyStyle={{ padding: '8px 12px' }} > 逆变器效率} bordered={false} style={{ borderRadius: 8, flex: 1, padding: 0 }} bodyStyle={{ padding: '8px 12px' }} > 运维任务进度} bordered={false} style={{ borderRadius: 8, flex: 1, padding: 0 }} bodyStyle={{ padding: '8px 12px' }} >
电站概览
GeoTIFF 正射底图 · 设备点位叠加
} bordered={false} style={{ ...cardStyle, height: '100%', padding: '12px' }} bodyStyle={{ height: "86%" }} >
正常 告警 离线 维护中
{/* 65% */}