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

488 lines
21 KiB
TypeScript
Raw Normal View History

2026-05-07 22:04:27 +08:00
import React, { useState } from 'react';
import {
Row, Col, Card, Button, Table, Tag, Typography, Space, Statistic, DatePicker,
Divider,
Flex
} from 'antd';
import {
ReloadOutlined, PlusOutlined, ArrowUpOutlined, CheckCircleOutlined,
CloudOutlined, SunOutlined, MoneyCollectOutlined, CalendarOutlined, DropOutlined
} from '@ant-design/icons';
import { Line, Pie, Bar } from '@ant-design/charts';
import he from '@/dist/assets/Organization-irk1gmLc';
const { Title, Text } = Typography;
// 模拟数据
const smartCleanPlanData = [
{ id: 'plan01', priority: '高', area: '区域15, 01', boost: '4,250 kWh', weather: 88 },
{ id: 'plan02', priority: '高', area: '区域06, 02', boost: '3,180 kWh', weather: 86 },
{ id: 'plan03', priority: '中', area: '区域07, 09', boost: '2,210 kWh', weather: 84 },
];
const workOrderPreviewData = [
{
area: 'A区北侧组件清洗区',
priority: '高',
duration: '2.5 h',
handler: '运维工程师',
planTime: '2026-04-30T20:26:05',
status: '已审批'
},
{
area: 'B区沙尘沉积区',
priority: '中',
duration: '2.5 h',
handler: '清洗班组',
planTime: '2026-05-02T20:26:05',
status: '待确认'
}
];
// 图表配置
const pollutionTrendConfig = {
data: [
{ date: '04-23', 污染指数: 45, 阈值: 50 },
{ date: '04-24', 污染指数: 48, 阈值: 50 },
{ date: '04-26', 污染指数: 52, 阈值: 50 },
{ date: '04-28', 污染指数: 50, 阈值: 50 },
{ date: '04-29', 污染指数: 54, 阈值: 50 },
],
xField: 'date',
yField: ['污染指数', '阈值'],
color: ['#1890ff', '#faad14'],
smooth: true,
legend: { position: 'top-left' },
};
const lossPieConfig = {
data: [
{ type: '灰尘积累', value: 50 },
{ type: '鸟粪遮挡', value: 30 },
{ type: '沙尘污染', value: 15 },
{ type: '其他', value: 5 },
],
angleField: 'value',
colorField: 'type',
color: ['#1890ff', '#ff4d4f', '#faad14', '#d9d9d9'],
radius: 0.8,
innerRadius: 0.6,
label: { type: 'outer' },
};
const compareBarConfig = {
data: [
{ date: 'D-7', 清洗前: 800, 清洗后: 1200, 提升率: 50 },
{ date: 'D-5', 清洗前: 850, 清洗后: 1200, 提升率: 41 },
{ date: 'D-3', 清洗前: 900, 清洗后: 1200, 提升率: 33 },
{ date: 'D-1', 清洗前: 950, 清洗后: 1200, 提升率: 26 },
],
xField: 'date',
yField: ['清洗前', '清洗后'],
color: ['#1890ff', '#52c41a'],
isGroup: true,
};
export default function CleanOptimizationPage() {
const [mapTooltip, setMapTooltip] = useState<any>(null);
const renderPriorityTag = (priority: string) => {
const colorMap: Record<string, string> = { '高': 'red', '中': 'orange', '低': 'green' };
return <Tag color={colorMap[priority]}>{priority}</Tag>;
};
const renderStatusTag = (status: string) => {
const colorMap: Record<string, string> = { '已审批': 'green', '待确认': 'orange' };
return <Tag color={colorMap[status]}>{status}</Tag>;
};
return (
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: 24 }}>
{/* 顶部标题与操作 */}
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 24 }}>
<div>
<Title level={4} style={{ margin: 0, }}>清洗优化管理</Title>
<Text type="secondary">污染热力分布、AI推荐计划、天气资源联动与清洗收益评估</Text>
</div>
<Space>
<Text type="secondary" style={{ marginRight: 16 }}>更新时间: 2026-05-06 09:30</Text>
<Button icon={<ReloadOutlined />}>刷新</Button>
<Button type="primary">生成清洗建议</Button>
<Button>新增计划</Button>
</Space>
</div>
{/* 顶部指标卡片 */}
<Row gutter={16} style={{ marginBottom: 24 }}>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="污染指数"
value={54.0}
precision={1}
prefix={
<div style={{ background: '#fff7e6', borderRadius: '50%', width: 36, height: 36, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<SunOutlined style={{ color: '#faad14', fontSize: 18 }} />
</div>
}
valueStyle={{ fontSize: 28, fontWeight: 700 }}
/>
<div style={{ fontSize: 12, color: '#999' }}>较昨日 <span style={{ color: '#ff4d4f' }}>▼ 5.3</span></div>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="建议清洗区域数"
value={9}
suffix="/ 22"
prefix={
<div style={{ background: '#e6f7ff', borderRadius: '50%', width: 36, height: 36, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<span style={{ color: '#1890ff', fontSize: 18 }}>▦</span>
</div>
}
valueStyle={{ fontSize: 28, fontWeight: 700 }}
/>
<div style={{ fontSize: 12, color: '#999' }}>占比 40%</div>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="预计发电提升"
value={12850}
suffix="kWh"
prefix={
<div style={{ background: '#f6ffed', borderRadius: '50%', width: 36, height: 36, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<ArrowUpOutlined style={{ color: '#52c41a', fontSize: 18 }} />
</div>
}
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#52c41a' }}
/>
<div style={{ fontSize: 12, color: '#999' }}>占昨日发电量 14.2%</div>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="预计收益提升"
value={8278}
prefix={
<div style={{ background: '#f9f0ff', borderRadius: '50%', width: 36, height: 36, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<span style={{ color: '#722ed1', fontSize: 18 }}>¥</span>
</div>
}
valueStyle={{ fontSize: 28, fontWeight: 700 }}
/>
<div style={{ fontSize: 12, color: '#999' }}>按电价 0.568 元/kWh 计算</div>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="上次清洗时间"
value="2025-05-12"
prefix={
<div style={{ background: '#e6f7ff', borderRadius: '50%', width: 36, height: 36, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<CalendarOutlined style={{ color: '#1890ff', fontSize: 18 }} />
</div>
}
valueStyle={{ fontSize: 20, fontWeight: 700 }}
/>
<div style={{ fontSize: 12, color: '#999' }}>距今 24 天</div>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="清洗成本预估"
value={5050}
prefix={
<div style={{ background: '#f9f0ff', borderRadius: '50%', width: 36, height: 36, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<span style={{ color: '#722ed1', fontSize: 18 }}>¥</span>
</div>
}
suffix=""
valueStyle={{ fontSize: 28, fontWeight: 700 }}
/>
<div style={{ fontSize: 12, color: '#999' }}>预计单次清洗总成本</div>
</Card>
</Col>
</Row>
{/* 左侧图表区域 */}
<Row gutter={16} style={{ marginBottom: 24, height: '500px' }}>
<Col span={6} style={{
display: 'flex', flexDirection: 'column', gap: 16, height: '100%', overflowY: 'auto', overflowX: 'hidden', scrollbarWidth: 'thin', scrollbarColor: '#ccc transparent'
}}>
<Card
title={<div style={{ padding: '8px' }}>
<p style={{ color: '#0837A8', margin: 0 }}>污染趋势</p>
<Text type="secondary" style={{ fontSize: 10 }}>近30天污染指数与清洗阈值</Text>
</div>}
bordered={false}
style={{ borderRadius: 8 }}
>
<Line {...pollutionTrendConfig} height={140} />
</Card>
<Card
title={<div style={{ padding: '8px' }}>
<p style={{ color: '#0837A8', margin: 0 }}>发电损失分析</p>
<Text type="secondary" style={{ fontSize: 10 }}>污染类型造成的发电损失占比</Text>
</div>}
bordered={false}
style={{ borderRadius: 8 }}
>
{/* 👇 关键:给图表外层套一层固定宽度 + 居中,防止溢出 */}
<div style={{
width: '100%',
height: 140,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
position: 'relative',
}}>
<Pie
{...lossPieConfig}
height={140}
//width="100%" /* 强制宽度100% */
/>
<div style={{ position: 'absolute', textAlign: 'center' }}>
<div style={{ fontSize: 12, color: '#666' }}>发电损失</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>9,320 kWh</div>
</div>
</div>
</Card>
<Card
title={<div style={{ padding: '8px' }}>
<p style={{ color: '#0837A8', margin: 0 }}>清洗前后对比</p>
<Text type="secondary" style={{ fontSize: 10 }}>近一次建议清洗区域发电恢复测算</Text>
</div>}
bordered={false}
style={{ borderRadius: 8 }}
>
<Bar {...compareBarConfig} height={140} />
</Card>
</Col>
{/* 中间地图区域 */}
<Col span={12} style={{
display: 'flex', flexDirection: 'column', gap: 16, height: '100%',
}}>
<Card
title={<div style={{ padding: '8px' }}>
<p style={{ color: '#0837A8', margin: 0 }}>电站污染分布与建议清洗区块</p>
<div style={{ display: 'flex', alignItems: 'center' }}>
<Text type="secondary" style={{ fontSize: 12 }}>真实正射底图 · 污染热力叠加 · AI调度优先级</Text>
<div style={{ display: 'flex', gap: 16, marginLeft: 16 }}>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 10, height: 10, background: '#52c41a', borderRadius: '50%', marginRight: 4 }}></span>低污染</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 10, height: 10, background: '#faad14', borderRadius: '50%', marginRight: 4 }}></span>中污染</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 10, height: 10, background: '#ff4d4f', borderRadius: '50%', marginRight: 4 }}></span>重污染</span>
</div>
</div>
</div>}
bordered={false}
style={{ borderRadius: 8, height: '100%' }}
>
<div style={{ position: 'relative', height: 380, background: '#f0f2f5', borderRadius: 8, overflow: 'hidden' }}>
{/* 模拟地图区域 */}
<div style={{
width: '100%', height: '100%',
display: 'flex', alignItems: 'center', justifyContent: 'center',
backgroundImage: 'url(https://via.placeholder.com/800x400)',
backgroundSize: 'cover',
backgroundPosition: 'center'
}}>
<div style={{ position: 'absolute', top: 20, left: 80, background: '#ff4d4f', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域01<br />82.3</div>
<div style={{ position: 'absolute', top: 20, left: 160, background: '#ff4d4f', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域02<br />76.8</div>
<div style={{ position: 'absolute', top: 40, left: 240, background: '#faad14', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域03<br />63.2</div>
<div style={{ position: 'absolute', top: 60, left: 320, background: '#52c41a', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域04<br />33.6</div>
<div style={{ position: 'absolute', top: 60, left: 400, background: '#52c41a', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域05<br />19.7</div>
<div style={{ position: 'absolute', top: 120, left: 80, background: '#ff4d4f', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域06<br />88.1</div>
<div style={{ position: 'absolute', top: 120, left: 160, background: '#faad14', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域07<br />68.7</div>
<div style={{ position: 'absolute', top: 120, left: 240, background: '#faad14', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域08<br />51.2</div>
<div style={{ position: 'absolute', top: 120, left: 320, background: '#faad14', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域09<br />72.9</div>
<div style={{ position: 'absolute', top: 120, left: 400, background: '#52c41a', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域10<br />36.8</div>
<div style={{ position: 'absolute', top: 180, left: 80, background: '#52c41a', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域11<br />44.6</div>
<div style={{ position: 'absolute', top: 180, left: 160, background: '#faad14', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域12<br />57.5</div>
<div style={{ position: 'absolute', top: 180, left: 240, background: '#faad14', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域13<br />61.8</div>
<div style={{ position: 'absolute', top: 180, left: 320, background: '#52c41a', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域14<br />42.1</div>
<div style={{ position: 'absolute', top: 240, left: 80, background: '#ff4d4f', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域15<br />85.6</div>
<div style={{ position: 'absolute', top: 240, left: 160, background: '#faad14', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域16<br />49.8</div>
<div style={{ position: 'absolute', top: 240, left: 240, background: '#52c41a', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域17<br />24.5</div>
<div style={{ position: 'absolute', top: 240, left: 320, background: '#52c41a', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域18<br />13.7</div>
<div style={{ position: 'absolute', top: 240, left: 400, background: '#52c41a', color: '#fff', padding: '4px 8px', borderRadius: 4, fontSize: 12 }}>区域19<br />36.3</div>
{/* 模拟 tooltip */}
{mapTooltip && (
<div style={{ position: 'absolute', bottom: 40, left: 80, background: 'rgba(0,0,0,0.7)', color: '#fff', padding: '8px 12px', borderRadius: 8, fontSize: 14 }}>
<div style={{ fontWeight: 700 }}>{mapTooltip.name}</div>
<div style={{ fontSize: 12 }}>{mapTooltip.desc}</div>
</div>
)}
</div>
{/* 地图控制 */}
<div style={{ position: 'absolute', top: 16, left: '50%', transform: 'translateX(-50%)', display: 'flex', alignItems: 'center', gap: 16 }}>
<Text type="secondary" style={{ fontSize: 12 }}>底图缩放</Text>
<Button size="small">适应</Button>
<Button size="small">-</Button>
<Button size="small">+</Button>
<Button size="small">重置</Button>
<div style={{ marginLeft: 16 }}>90%</div>
</div>
</div>
</Card>
</Col>
{/* 右侧面板 */}
<Col span={6} style={{
display: 'flex', flexDirection: 'column', gap: 16, height: '100%', overflowY: 'auto', overflowX: 'hidden', scrollbarWidth: 'thin', scrollbarColor: '#ccc transparent'
}}>
<Card
title={<span style={{ color: '#0837A8', }}>智能清洗建议</span>}
bordered={false}
style={{ borderRadius: 8, marginBottom: 16, flex: 1, display: "flex", flexDirection: "column" }}
extra={<div style={{ display: 'flex', alignItems: 'center' }}><Text type="secondary" style={{ fontSize: 12 }}>优先级、天气适宜度与收益提升联动排序</Text><Tag color="blue" style={{ marginLeft: 8 }}>AI推荐</Tag></div>}
>
{/* 👇 关键:填满卡片 + 超长滚动 */}
<div style={{
flex: 1,
overflow: "auto",
// 滚动条样式 #ccc + 透明
"&::-webkit-scrollbar": { width: "6px" },
"&::-webkit-scrollbar-thumb": { backgroundColor: "#ccc", borderRadius: "3px" },
"&::-webkit-scrollbar-track": { backgroundColor: "transparent" },
}}>
<Table
columns={[
{ title: '计划', dataIndex: 'id', width: 80 },
{ title: '优先级', dataIndex: 'priority', render: renderPriorityTag, width: 80 },
{ title: '建议区域', dataIndex: 'area', width: 100 },
{ title: '预计提升', dataIndex: 'boost', width: 100 },
{ title: '天气', dataIndex: 'weather', width: 80 },
]}
dataSource={smartCleanPlanData}
pagination={false}
size="small"
scroll={{ y: undefined }}
/>
</div>
</Card>
<Card
title={<span style={{ color: '#0837A8', flex: 1 }}>天气与资源参考</span>}
bordered={false}
style={{ borderRadius: 8, marginBottom: 16 }}
extra={<Text type="secondary" style={{ fontSize: 12 }}>未来7天作业窗口、风速、湿度、降水概率</Text>}
>
<div style={{ display: 'flex', gap: 8 }}>
{['05-06', '05-07', '05-08', '05-09'].map((day, idx) => (
<Button key={idx} size="small" style={{ flex: 1 }}>{day}</Button>
))}
</div>
</Card>
<Card
title={<span style={{ color: '#0837A8', flex: 1 }}>清洗方案建议</span>}
bordered={false}
style={{ borderRadius: 8 }}
extra={<Text type="secondary" style={{ fontSize: 12 }}>机器人清洗与人工清洗资源对比</Text>}
>
<div style={{ display: 'flex', gap: 8 }}>
<Button size="small" style={{ flex: 1 }} icon={<span>🤖</span>}>清洗机器人方案</Button>
<Button size="small" style={{ flex: 1 }} icon={<span>👷</span>}>人工清洗方案</Button>
</div>
</Card>
</Col>
</Row>
{/* 工单预览区域 */}
<Card
title={<span style={{ color: '#0837A8', }}>清洗工单预览</span>}
bordered={false}
style={{ borderRadius: 8, marginBottom: 24 }}
extra={<div style={{ display: 'flex', alignItems: 'center' }}><Text type="secondary" style={{ fontSize: 12 }}>AI推荐计划转工单、转任务仍保留现有接口</Text><Button type="link" size="small">新增</Button></div>}
>
<Table
columns={[
{ title: '区域', dataIndex: 'area' },
{ title: '优先级', dataIndex: 'priority', render: renderPriorityTag, width: 100 },
{ title: '预计工时', dataIndex: 'duration', width: 100 },
{ title: '负责人', dataIndex: 'handler', width: 120 },
{ title: '计划时间', dataIndex: 'planTime', width: 180 },
{ title: '状态', dataIndex: 'status', render: renderStatusTag, width: 100 },
{
title: '操作', width: 120, render: () => (
<Space>
<Button type="link" size="small">编辑</Button>
<Button type="link" size="small">生成</Button>
</Space>
)
}
]}
dataSource={workOrderPreviewData}
pagination={false}
/>
</Card>
{/* 清洗影响评估 */}
<Card
title={<span style={{ color: '#0837A8', }}>清洗影响评估</span>}
bordered={false}
style={{ borderRadius: 8, marginBottom: 24 }}
extra={<Text type="secondary" style={{ fontSize: 12 }}>预计用水、耗时、碳减排与作业风险综合判断</Text>}
>
<Row gutter={16}>
<Col span={6}>
<div style={{ padding: 16, background: '#f5f7fa', borderRadius: 8 }}>
<div style={{ fontSize: 12, color: '#666' }}>预计用水量</div>
<div style={{ fontSize: 24, fontWeight: 700, marginTop: 4 }}>18 吨</div>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>节水率 30%(机器人)</div>
</div>
</Col>
<Col span={6}>
<div style={{ padding: 16, background: '#f5f7fa', borderRadius: 8 }}>
<div style={{ fontSize: 12, color: '#666' }}>预计耗时</div>
<div style={{ fontSize: 24, fontWeight: 700, marginTop: 4 }}>12 小时</div>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>并行作业 2 组</div>
</div>
</Col>
<Col span={6}>
<div style={{ padding: 16, background: '#f5f7fa', borderRadius: 8 }}>
<div style={{ fontSize: 12, color: '#666' }}>碳减排量</div>
<div style={{ fontSize: 24, fontWeight: 700, marginTop: 4 }}>6.85 吨</div>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>CO₂ 减排量</div>
</div>
</Col>
<Col span={6}>
<div style={{ padding: 16, background: '#f5f7fa', borderRadius: 8 }}>
<div style={{ fontSize: 12, color: '#666' }}>作业风险</div>
<div style={{ fontSize: 24, fontWeight: 700, marginTop: 4 }}>低风险</div>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>天气和通道安全可控</div>
</div>
</Col>
</Row>
</Card>
{/* 业务入口 */}
<Card bordered={false} style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
<Title level={5} style={{ margin: 0, color: '#0837A8' }}>业务入口</Title>
<Text type="secondary" style={{ fontSize: 12 }}>区域维护、计划审批、任务完成与效果评估仍使用现有接口和权限。</Text>
</div>
<Space>
<Button>新增区域</Button>
<Button>新增计划</Button>
<Button>新增</Button>
</Space>
</div>
</Card>
</div>
);
}