import React, { useState, useEffect } from 'react'; import { Card, Row, Col, Statistic, Button, Space, Tag, Typography } from 'antd'; import { CloudOutlined, ThunderboltOutlined, BarChartOutlined, RiseOutlined, BellOutlined, WalletOutlined, MinusOutlined, PlusOutlined, SyncOutlined } from '@ant-design/icons'; import { Line, Bar, Pie } from '@ant-design/charts'; import { getWeatherData } from '../lib/utils'; 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" }); // 请求天气接口 useEffect(() => { const fetchWeather = async () => { try { const res = await getWeatherData(); setWeatherData(res); } catch (err) { console.error("天气接口请求失败", err); } }; fetchWeather(); }, []); // 模拟数据 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" } ]; 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 } ], // 关键:纠正坐标轴 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轴从90开始,让柱子更饱满 yAxis: { min: 90, max: 100, tickCount: 6, label: { formatter: (v) => `${v}%` } }, 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 (
{/* 顶部一排6个卡片 —— 等宽、不换行、自适应 */} 今日发电量} value={stationOverview.todayEnergy} precision={1} valueStyle={{ color: '#1890ff', fontSize: 24, fontWeight: 800 }} prefix={} suffix="kWh" />
日发电实时累计
当前功率} value={stationOverview.currentPower} precision={1} valueStyle={{ color: '#1890ff', fontSize: 24, fontWeight: 800 }} prefix={} suffix="kW" />
装机容量 100.0 MWp
系统效率 PR} value={stationOverview.systemEfficiency} precision={1} valueStyle={{ color: '#52c41a', fontSize: 24, fontWeight: 800 }} prefix={} suffix="%" />
昨日 {stationOverview.yesterdayEfficiency}% +1.3%
系统可用率} value={stationOverview.systemAvailability} precision={2} valueStyle={{ color: '#faad14', fontSize: 24, fontWeight: 800 }} prefix={} suffix="%" />
在线设备 {stationOverview.onlineDevices}
告警数量} value={stationOverview.alarmCount} valueStyle={{ color: '#ff4d4f', fontSize: 24, fontWeight: 800 }} prefix={} suffix="条" />
今日新增 0 条
节省运维成本} value={stationOverview.costSaved} valueStyle={{ color: '#1890ff', fontSize: 24, fontWeight: 800 }} prefix="¥" />
清洗收益 + 工单闭环估算
{/* 主体:左侧图表 + 中间电站 + 右侧告警 —— 强制一行不换行 */} {/* 左侧图表列 - 最终完美版:不溢出 + 一定可见 */} 发电趋势} 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' }} >
正常 告警 离线 维护中
65%
{/* 右侧:实时告警 */} {/* 实时告警 */} 实时告警
} 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) => (
{alert.level} {alert.type}
{alert.time}
))} {/* 设备在线状态 */} 设备在线状态} bordered={false} style={{ borderRadius: 8, boxShadow: '0 1px 2px rgba(0,0,0,0.05)', padding: '4px 8px' }} bodyStyle={{ padding: 4 }} > {deviceStatus.map((item, idx) => (
{item.count}
{item.name}
{item.status}
))}
天气信息} bordered={false} style={{ borderRadius: 8, boxShadow: '0 1px 2px rgba(0,0,0,0.05)', padding: '4px 8px' }} bodyStyle={{ padding: 4 }} >
{/* 右侧文字 */}
{weatherdata.temperature}℃
{weatherdata.weather}
湿度 {weatherdata.humidity}%
{weatherdata.wind_direction} {weatherdata.wind_power}
{weatherdata.city} | {weatherdata.district}
{/* 清洗建议 */} 清洗建议 } bordered={false} style={{ borderRadius: 8, boxShadow: '0 1px 2px rgba(0,0,0,0.05)', padding: '4px 8px' }} bodyStyle={{ padding: 4 }} >
46
分
污染指数中等,建议3天内安排B区清洗。
预计收益 ¥ 8,278
近期巡检记录} bordered={false} style={{ ...cardStyle, height: '100%' }} bodyStyle={{ padding: 12, height: '66%', overflow: 'auto', scrollbarWidth: 'thin', scrollbarColor: '#ccc transparent' }} > {patrolRecords.map((item, idx) => (
{item.name}
{item.device}
{item.status}
))}
AI分析摘要} bordered={false} style={{ ...cardStyle, height: '100%' }} bodyStyle={{ padding: 12, height: '66%', overflow: 'auto', scrollbarWidth: 'thin', scrollbarColor: '#ccc transparent' }} > {aiAnalysis.map((item, idx) => (
{item.type} {item.content}
))}
); }