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

412 lines
15 KiB
TypeScript
Raw Normal View History

import React, { useState } from 'react';
import {
Card, Row, Col, Tabs, Button, Space, Select, Table, Statistic,
2026-05-11 11:59:17 +08:00
DatePicker, message, Tag, Typography,
Radio, Checkbox, Divider
} from 'antd';
import {
CloudOutlined, BarChartOutlined, BellOutlined,
2026-05-11 11:59:17 +08:00
CalendarOutlined, FileTextOutlined,
DownloadOutlined, ArrowUpOutlined, CheckCircleOutlined,
ClockCircleOutlined, WarningOutlined, FileExcelOutlined,
FilePdfOutlined, MailOutlined, SendOutlined, SettingOutlined,
RobotOutlined
} from '@ant-design/icons';
2026-05-11 11:59:17 +08:00
import { Line, Bar, Pie } from '@ant-design/charts';
import dayjs from 'dayjs';
const { TabPane } = Tabs;
const { RangePicker } = DatePicker;
const { Option } = Select;
2026-05-11 11:59:17 +08:00
const { Text, Title } = Typography;
2026-05-11 11:59:17 +08:00
// 模拟数据(完全匹配参考图)
const overviewCards = [
{ title: '本月发电量', value: '138.6', unit: 'MWh', rate: '+6.2%', rateUp: true, color: '#52c41a' },
{ title: 'PR均值', value: '82.8', unit: '%', rate: '+1.1%', rateUp: true, color: '#1890ff' },
{ title: '运维工单完成率', value: '93.4', unit: '%', desc: '本月累计 126 单', color: '#1890ff' },
{ title: '告警闭环率', value: '94.2', unit: '%', desc: '严重告警 8 条', color: '#faad14' },
{ title: '清洗收益提升', value: '+7.6', unit: '%', desc: '预估增发 12,850 kWh', color: '#52c41a' },
{ title: '自动生成报告', value: '24', unit: '份', desc: '本月累计', color: '#722ed1' },
];
2026-05-11 11:59:17 +08:00
const monthlyPowerData = [
{ date: '05-01', generation: 6, predicted: 8, pr: 105 },
{ date: '05-06', generation: 7, predicted: 9, pr: 108 },
{ date: '05-11', generation: 3, predicted: 7, pr: 102 },
{ date: '05-16', generation: 8, predicted: 10, pr: 112 },
{ date: '05-21', generation: 9, predicted: 10, pr: 110 },
{ date: '05-26', generation: 7, predicted: 9, pr: 108 },
{ date: '05-31', generation: 5, predicted: 7, pr: 105 },
];
2026-05-11 11:59:17 +08:00
const powerMeteorologyData = [
{ date: '05-05-05', generation: 70, irradiance: 60, temp: 20 },
{ date: '05-12-05', generation: 60, irradiance: 50, temp: 22 },
{ date: '05-19-05', generation: 65, irradiance: 65, temp: 25 },
{ date: '05-26-05', generation: 55, irradiance: 55, temp: 23 },
];
2026-05-11 11:59:17 +08:00
const orderAlarmData = [
{ date: '05-05-05', newOrder: 80, completed: 60, alarmCount: 10, closedRate: 80 },
{ date: '05-12-05', newOrder: 100, completed: 80, alarmCount: 20, closedRate: 85 },
{ date: '05-19-05', newOrder: 70, completed: 50, alarmCount: 15, closedRate: 90 },
{ date: '05-26-05', newOrder: 90, completed: 70, alarmCount: 18, closedRate: 92 },
];
2026-05-11 11:59:17 +08:00
const aiAnalysisData = [
{ type: '热斑识别', value: 36 },
{ type: '异常组串', value: 8 },
{ type: '推荐清洗区块', value: 8 },
{ type: '视频异常事件', value: 6 },
];
const reportFileList = [
2026-05-11 11:59:17 +08:00
{ name: '电站月报', date: '2025年05月', type: '发电报表', status: '已生成', operator: '张运维', time: '2025-05-31 08:15' },
{ name: '周运维总结', date: '2025年05月', type: '运维报表', status: '已生成', operator: '系统自动', time: '2025-05-26 09:10' },
{ name: 'AI诊断日报', date: '2025年05月', type: 'AI分析报告', status: '生成中', operator: '系统自动', time: '2025-05-31 07:30' },
{ name: '告警闭环周报', date: '2025年05月', type: '告警报表', status: '已生成', operator: '李工程师', time: '2025-05-31 09:00' },
{ name: '清洗效果报告', date: '2025年05月', type: '运维报表', status: '已生成', operator: '王运维', time: '2025-05-28 10:20' },
];
2026-05-11 11:59:17 +08:00
const reportTemplates = [
{ name: '月度经营报告', desc: '综合经营分析与收益评估模板', icon: <BarChartOutlined />, color: '#1890ff' },
{ name: '设备健康分析报告', desc: '设备健康与故障分析模板', icon: <WarningOutlined />, color: '#faad14' },
{ name: '清洗优化效果报告', desc: '清洗前后对比与收益分析模板', icon: <CloudOutlined />, color: '#52c41a' },
{ name: '巡检与机器人作业报告', desc: '巡检与机器人作业统计模板', icon: <RobotOutlined />, color: '#722ed1' },
];
2026-05-11 11:59:17 +08:00
export default function ReportCenterPage() {
const [activeTab, setActiveTab] = useState('overview');
const [reportCycle, setReportCycle] = useState('month');
const [reportType, setReportType] = useState('all');
const [dateRange, setDateRange] = useState([dayjs('2025-05-01'), dayjs('2025-05-31')]);
2026-05-11 11:59:17 +08:00
return (
<div style={{ padding: 20, background: '#f5f7fa', minHeight: '100vh' }}>
{/* 页面头部标签 */}
<Tabs activeKey={activeTab} onChange={setActiveTab} style={{ marginBottom: 20 }}>
<TabPane tab="报表总览" key="overview" />
<TabPane tab="发电报表" key="power" />
<TabPane tab="运维报表" key="operation" />
<TabPane tab="告警报表" key="alarm" />
<TabPane tab="AI分析报告" key="ai" />
</Tabs>
2026-05-11 11:59:17 +08:00
{/* 顶部统计卡片 */}
<Row gutter={16} style={{ marginBottom: 20 }}>
{overviewCards.map((card, idx) => (
<Col span={4} key={idx}>
<Card bordered={false} style={{ borderRadius: 8, height: 120 }}>
<Statistic
title={card.title}
value={card.value}
precision={card.title === 'PR均值' ? 1 : 1}
suffix={card.unit}
valueStyle={{ color: card.color, fontSize: 28, fontWeight: 700 }}
/>
{card.rate && (
<Text type="secondary" style={{ fontSize: 12 }}>
环比 <span style={{ color: card.rateUp ? '#52c41a' : '#ff4d4f' }}>{card.rate}</span>
</Text>
)}
{card.desc && (
<Text type="secondary" style={{ fontSize: 12, display: 'block' }}>
{card.desc}
</Text>
)}
</Card>
</Col>
))}
</Row>
2026-05-11 11:59:17 +08:00
{/* 筛选栏 */}
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 20, gap: 16, flexWrap: 'wrap' }}>
<Select value={reportCycle} onChange={setReportCycle} style={{ width: 120 }}>
<Option value="day">日报</Option>
<Option value="week">周报</Option>
<Option value="month">月报</Option>
</Select>
<Select value={reportType} onChange={setReportType} style={{ width: 120 }}>
<Option value="all">全部</Option>
<Option value="power">发电报表</Option>
<Option value="operation">运维报表</Option>
<Option value="alarm">告警报表</Option>
<Option value="ai">AI分析报告</Option>
</Select>
<RangePicker
value={dateRange}
onChange={setDateRange}
2026-05-11 11:59:17 +08:00
style={{ flex: 1, maxWidth: 300 }}
/>
<Space>
2026-05-11 11:59:17 +08:00
<Button type="primary" icon={<FileTextOutlined />}>生成报表</Button>
<Button icon={<FilePdfOutlined />}>导出PDF</Button>
<Button icon={<FileExcelOutlined />}>导出Excel</Button>
</Space>
</div>
2026-05-11 11:59:17 +08:00
<Row gutter={16}>
{/* 左侧主内容区 */}
<Col span={16}>
{/* 月度综合经营分析 */}
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 16 }} title="月度综合经营分析">
<Line
2026-05-11 11:59:17 +08:00
data={monthlyPowerData}
xField="date"
2026-05-11 11:59:17 +08:00
yField={['generation', 'predicted', 'pr']}
seriesField="type"
color={['#52c41a', '#1890ff', '#fa8c16']}
lineStyle={(datum) => {
if (datum.type === 'pr') return { lineDash: [4, 4] };
return {};
}}
tooltip={{
formatter: (datum) => {
return {
name: datum.date,
data: [
{ name: '发电量(MWh)', value: datum.generation },
{ name: '预测发电(MWh)', value: datum.predicted },
{ name: 'PR(%)', value: datum.pr }
]
};
}
}}
legend={{
items: [
{ name: '发电量(MWh)', marker: { symbol: 'line', style: { stroke: '#52c41a' } } },
{ name: '预测发电(MWh)', marker: { symbol: 'line', style: { stroke: '#1890ff', lineDash: [4, 4] } } },
{ name: 'PR(%)', marker: { symbol: 'line', style: { stroke: '#fa8c16' } } },
]
}}
yAxis={[
{
label: { formatter: (v) => `${v}` },
name: '发电量',
},
{
label: { formatter: (v) => `${v}%` },
name: 'PR',
position: 'right',
}
]}
height={200}
/>
2026-05-11 11:59:17 +08:00
<Row gutter={16} style={{ marginTop: 16 }}>
<Col span={6}>
<Statistic title="本月累计发电量" value={138.6} suffix="MWh" />
</Col>
<Col span={6}>
<Statistic title="理论发电量" value={166.8} suffix="MWh" />
</Col>
<Col span={6}>
<Statistic title="PR均值" value={82.8} suffix="%" />
</Col>
<Col span={6}>
<Statistic title="发电偏差" value={-3.4} suffix="%" valueStyle={{ color: '#ff4d4f' }} />
</Col>
<Col span={6}>
<Statistic title="平均辐照度" value={5.3} suffix="kWh/㎡/天" />
</Col>
</Row>
</Card>
2026-05-11 11:59:17 +08:00
{/* 发电与气象 + 工单与告警 */}
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col span={12}>
<Card bordered={false} style={{ borderRadius: 8 }} title="发电与气象统计">
<Bar
data={powerMeteorologyData}
xField="date"
yField={['generation', 'irradiance', 'temp']}
color={['#1890ff', '#52c41a', '#fa8c16']}
legend={{ position: 'top' }}
height={180}
/>
2026-05-11 11:59:17 +08:00
</Card>
</Col>
<Col span={12}>
<Card bordered={false} style={{ borderRadius: 8 }} title="工单与告警闭环分析">
<Bar
data={orderAlarmData}
xField="date"
yField={['newOrder', 'completed', 'alarmCount', 'closedRate']}
color={['#1890ff', '#52c41a', '#fa8c16', '#722ed1']}
legend={{ position: 'top' }}
height={180}
/>
2026-05-11 11:59:17 +08:00
</Card>
</Col>
</Row>
{/* AI分析成果统计 */}
<Card bordered={false} style={{ borderRadius: 8 }} title="AI分析成果统计">
<Row gutter={16}>
<Col span={8}>
<Pie
data={aiAnalysisData}
angleField="value"
colorField="type"
color={['#1890ff', '#52c41a', '#fa8c16', '#722ed1']}
radius={0.7}
innerRadius={0.6}
height={180}
/>
2026-05-11 11:59:17 +08:00
</Col>
<Col span={16}>
<Row gutter={16}>
{aiAnalysisData.map((item, idx) => (
<Col span={12} key={idx}>
<Statistic title={item.type} value={item.value} suffix="个" />
</Col>
))}
</Row>
</Col>
</Row>
</Card>
</Col>
2026-05-11 11:59:17 +08:00
{/* 右侧边栏 */}
<Col span={8}>
{/* 报表目录 / 快捷下载 */}
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 16 }} title={
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span>报表目录 / 快捷下载</span>
<Button type="link">更多 </Button>
</div>
}>
<Table
2026-05-11 11:59:17 +08:00
rowKey="name"
columns={[
2026-05-11 11:59:17 +08:00
{ title: '报表名称', dataIndex: 'name' },
{
title: '状态', dataIndex: 'status', render: (v) => (
<Tag color={v === '已生成' ? 'green' : v === '生成中' ? 'orange' : 'default'}>{v}</Tag>
)
},
{
title: '操作', render: () => (
<Space>
<Button type="link" size="small">查看</Button>
<Button type="link" size="small">下载</Button>
</Space>
)
}
]}
2026-05-11 11:59:17 +08:00
dataSource={reportFileList.slice(0, 4)}
pagination={false}
2026-05-11 11:59:17 +08:00
size="small"
/>
</Card>
2026-05-11 11:59:17 +08:00
{/* 模板中心 */}
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 16 }} title={
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span>模板中心</span>
<Button type="link">更多 </Button>
</div>
}>
<Row gutter={16}>
{reportTemplates.map((tpl, idx) => (
<Col span={12} key={idx}>
<Card bordered={false} size="small" style={{ background: '#fafafa', borderRadius: 8 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<div style={{ width: 32, height: 32, borderRadius: 4, background: `${tpl.color}15`, color: tpl.color, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
{tpl.icon}
</div>
<div>
<div style={{ fontSize: 13, fontWeight: 500 }}>{tpl.name}</div>
<div style={{ fontSize: 11, color: '#666' }}>{tpl.desc}</div>
</div>
</div>
</Card>
</Col>
))}
</Row>
</Card>
2026-05-11 11:59:17 +08:00
{/* 报表生成记录 */}
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 16 }} title={
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span>报表生成记录</span>
<Button type="link">更多 </Button>
</div>
}>
<Table
rowKey="name"
columns={[
{ title: '报表名称', dataIndex: 'name' },
{ title: '生成时间', dataIndex: 'time' },
{ title: '生成人', dataIndex: 'operator' },
{ title: '类型', dataIndex: 'type' },
{
title: '状态', dataIndex: 'status', render: (v) => (
<Tag color={v === '已生成' ? 'green' : v === '生成中' ? 'orange' : 'default'}>{v}</Tag>
)
},
{
title: '操作', render: () => (
<Space>
<Button type="link" size="small">查看</Button>
<Button type="link" size="small">下载</Button>
</Space>
)
}
]}
dataSource={reportFileList}
pagination={false}
size="small"
/>
</Card>
2026-05-11 11:59:17 +08:00
{/* 订阅与分发 */}
<Card bordered={false} style={{ borderRadius: 8 }} title="订阅与分发">
<div style={{ marginBottom: 16 }}>
<Text strong>订阅人员</Text>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }}>
{['张运维', '李工程师', '王运维', '陈经理'].map((name, idx) => (
<div key={idx} style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
<div style={{ width: 32, height: 32, borderRadius: '50%', background: '#e6f7ff', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
{name.charAt(0)}
</div>
<Text style={{ fontSize: 12 }}>{name}</Text>
</div>
))}
<Text type="secondary">+2</Text>
</div>
</div>
2026-05-11 11:59:17 +08:00
<Divider style={{ margin: '12px 0' }} />
2026-05-11 11:59:17 +08:00
<div style={{ marginBottom: 16 }}>
<Text strong>分发渠道(可多选)</Text>
<div style={{ display: 'flex', gap: 16, marginTop: 8 }}>
<Checkbox checked>
<MailOutlined style={{ marginRight: 4 }} /> 邮件
</Checkbox>
<Checkbox checked>
<SendOutlined style={{ marginRight: 4 }} /> Telegram
</Checkbox>
<Checkbox checked>
<BellOutlined style={{ marginRight: 4 }} /> 系统通知
</Checkbox>
</div>
</div>
2026-05-11 11:59:17 +08:00
<Divider style={{ margin: '12px 0' }} />
2026-05-11 11:59:17 +08:00
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Text strong>发送计划</Text>
<Button type="link" icon={<SettingOutlined />}>编辑</Button>
</div>
<Card size="small" style={{ marginTop: 8, background: '#f6ffed', borderColor: '#b7eb8f' }}>
<Text>每周一 09:00 自动发送</Text>
</Card>
</Card>
</Col>
</Row>
</div>
);
}