Files
web-Iot/src/pages/Home.tsx
2026-09-02 15:13:22 +08:00

549 lines
25 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { useState, useEffect, useRef } from 'react';
import { Card, Row, Col, Statistic, Button, Space, Tag, Typography, Table, message } from 'antd';
import {
CloudOutlined, ThunderboltOutlined, BarChartOutlined,
RiseOutlined, BellOutlined, WalletOutlined,
MinusOutlined, PlusOutlined, SyncOutlined,
MoneyCollectOutlined,
DashboardOutlined,
FullscreenOutlined,
RocketOutlined,
VideoCameraOutlined,
AppstoreOutlined,
ExperimentOutlined,
BranchesOutlined,
RobotOutlined
} from '@ant-design/icons';
import { useNavigate } from 'react-router-dom';
import { Line, Bar, Pie } from '@ant-design/charts';
import CesiumMap from '../components/Map';
import { getWeatherData, getWeatherType } from '../lib/utils';
import WeatherDisplay from '../components/Weather';
import bgMain from '../assets/images/bgmain.jpg';
import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../components/recharts';
// 👇 在这里引入你的工单接口(改成你真实的接口地址)
import { addWorkOrder } from '../api/workOrder';
import { useSelector } from 'react-redux';
import { getAlarmList } from '../api/alarmApi';
import { RootState } from '../store';
import { useTranslation } from 'react-i18next';
const { Text } = Typography;
export default function StationDashboard() {
const { t } = useTranslation();
// 👇 消息提示(修复缺失)
const [messageApi, contextHolder] = message.useMessage();
// 👇 获取当前选中的电站(从redux拿,修复缺失)
const { currentStation } = useSelector((state) => state.station);
const { userInfo } = useSelector((state) => state.user);
const { stationId } = useSelector((state: RootState) => state.station);
const [alarmList, setAlarmList] = useState([]);
// 天气数据
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 navigate = useNavigate();
const deviceStatus = [
{ name: t('home.combinerBox'), count: "2/2", status: "异常 1" },
{ name: t('home.inverter'), count: "3/3", status: "异常 1" },
{ name: "电表", count: "1/1", status: t('roles.normal') },
{ name: t('home.inspectionRobot'), count: "1/1", status: t('roles.normal') }
];
const patrolRecords = [
{ 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: "张运维" }
];
const aiAnalysis = [
{ type: "AI分析", content: t('home.fixed2AiInverterFixed2TemperatureAbnormalADevice'), desc: "发现2处组件存在异常热斑" },
{ type: t('constants.critical'), content: t('home.invA02MaintenanceInvA02Repair'), desc: "3个组串存在发电异常" },
{ type: t('constants.critical'), content: t('home.a05HotspotPvA05018PvA05020StatusAbnormal'), desc: "整体发电偏差-2.8%" }
];
// 图表数据
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 },
];
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 },
];
const taskProgressData = [
{ name: t('workOrder.completed'), value: 40, color: '#1890ff' },
{ name: '进行中', value: 35, color: '#52c41a' },
{ name: '待开始', value: 20, color: '#faad14' },
{ name: t('home.abnormal'), value: 5, color: '#ff4d4f' },
];
const cardStyle = { borderRadius: 12, border: '1px solid #f0f0f0', boxShadow: '0 2px 8px rgba(0,0,0,0.04)' };
// ==============================================
// 👇 【完整完善】生成清洗工单(核心修复)
// ==============================================
// ==============================================
// 【正确匹配接口字段】生成清洗工单
// ==============================================
const handleaddOrder = async () => {
if (!currentStation) {
messageApi.warning(t('home.pleaseSelectStation'));
return;
}
try {
// 严格按照你给的接口字段传参
const params = {
id: '', // 主键ID(新增为空)
orderNo: '', // 工单编号(后端生成)
orderTitle: '光伏组件清洗工单', // 工单标题
sourceType: 3, // 来源 3=清洗
orderType: 3, // 类型 3=清洗
priorityLevel: 2, // 优先级 2=中
deviceId: currentStation.id || '',
deviceName: currentStation.siteName || '电站',
deviceType: 1, // 设备类型:电站
siteId: currentStation.id || '',
siteName: currentStation.siteName || '',
orgId: currentStation?.orgId || '',
assigneeId: '',
assigneeName: '',
collaboratorIds: '',
collaboratorNames: '',
planStartTime: '',
planEndTime: '',
deadlineTime: '',
actualStartTime: '',
actualEndTime: '',
orderStatus: 1, // 状态 1=待处理
alarmId: '',
alarmNo: '',
taskDescription: '根据电站清洁度建议进行组件清洗,提升发电效率',
aiSuggestion: '系统自动生成清洗建议,预计提升发电量2.6%',
requiredEquipment: '清洗设备、水枪、抹布',
estimatedImpact: '2.6', // 影响发电量(%) 数字
handleResult: '',
handleRemark: ''
};
const res = await addWorkOrder(params);
if (res.code === 0 || res.code === 200) {
messageApi.success(t('home.cleaningOrderGeneratedSuccessfullyFixed2'));
} else {
messageApi.error(res.msg || '❌ 工单生成失败');
}
} catch (error) {
messageApi.error(t('home.failedFixed2'));
console.error(error);
}
};
const fetchList = async () => {
try {
const data = {
pageNum: 1,
pageSize: 999999,
siteId: stationId
}
const res = await getAlarmList(data);
if (res.code === 200) {
setAlarmList(res?.rows || []);
}
} catch (err) {
messageApi.error(t('common.loadFailed'));
} finally {
}
};
useEffect(() => {
fetchList()
}, [stationId])
return (
<div style={{ background: '#f8fafc', padding: '0px', minHeight: '100vh', width: '100%', boxSizing: 'border-box' }}>
{/* 👇 必须加这个,message才能正常显示 */}
{contextHolder}
{/* 顶部统计卡片 */}
<Row gutter={[8, 8]} style={{ margin: '0 4px 0px 4px' }}>
{[
{ title: t('home.todayGeneration'), value: '4,752', unit: t('home.kWh'), sub: '日目标 5,000 kWh', color: '#00B42A', bg: '#E8FFEA', icon: <ThunderboltOutlined /> },
{ title: t('home.currentPower'), 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: t('home.systemAvailability'), value: '99.35%', unit: '', sub: '昨日 99.12% ↑0.23%', color: '#165DFF', bg: '#E8F3FF', icon: <RiseOutlined /> },
{ title: t('home.alertCount'), value: alarmList.length, unit: '', sub: `未处理 ${alarmList.filter(item => item.handleStatus == 1).length} / 已关闭 ${alarmList.filter(item => item.handleStatus == 2).length}`, color: '#F53F3F', bg: '#FFF1F0', icon: <BellOutlined /> },
{ title: t('home.costSaving'), value: '¥ 36,540', unit: '', sub: t('home.monthlyAccumulated'), color: '#FF7D00', bg: '#FFF7E8', icon: <MoneyCollectOutlined /> },
].map((item, idx) => (
<Col key={idx} style={{
flex: '1 1 auto',
width: 'clamp(180px, 15vw, 240px)',
maxWidth: '240px',
minWidth: '160px'
}}>
<Card bordered={false} style={{ ...cardStyle, height: "100%" }} bodyStyle={{ padding: '12px' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
<div style={{ color: '#000', fontSize: '13px', fontWeight: 600, marginBottom: 4 }}>{item.title}</div>
<div style={{ display: 'flex', alignItems: 'baseline' }}>
<span style={{ color: item.color, fontSize: 'clamp(18px, 1.5vw, 22px)', fontWeight: 800 }}>{item.value}</span>
{item.unit && <span style={{ color: '#666', fontSize: '12px', marginLeft: 4 }}>{item.unit}</span>}
</div>
<div style={{ fontSize: '11px', color: '#999', marginTop: 4 }}>{item.sub}</div>
</div>
<div style={{
width: 40, height: 40, background: item.bg, borderRadius: '50%',
display: 'flex', justifyContent: 'center', alignItems: 'center',
boxShadow: `0 2px 8px ${item.color}1A`
}}>
{React.cloneElement(item.icon, { style: { fontSize: 22, color: item.color } })}
</div>
</div>
</Card>
</Col>
))}
</Row>
{/* 主体布局 */}
<Row gutter={[8, 8]}>
{/* 左侧图表 */}
<Col xs={24} xl={6}>
<Space direction="vertical" size={8} style={{ width: '100%' }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.generationTrend')}</span>} extra={<Space><SyncOutlined /><FullscreenOutlined /></Space>} bordered={false} style={cardStyle} bodyStyle={{ padding: '8px' }}>
<div style={{ fontSize: 11, color: '#666', marginBottom: 8 }}>今日发电功率趋势 (kW)</div>
<UniversalLineChart
data={powerTrendData}
xKey="time"
height={200}
smooth
dot
backgroundColor="transparent"
series={[
{ key: 'actual', name: t('home.actual'), color: '#165DFF', strokeWidth: 3 },
{ key: 'predict', name: t('home.predict'), color: '#00B42A', strokeWidth: 2 },
]}
/>
</Card>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.irradianceTempTrend')}</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: '8px' }}>
<UniversalLineChart
data={irradianceData}
xKey="time"
height={200}
smooth
dot
backgroundColor="transparent"
series={[
{ key: 'irradiance', name: t('home.irradiance'), color: '#165DFF', strokeWidth: 3 },
{ key: 'temperature', name: t('home.temperature'), color: '#00B42A', strokeWidth: 2 },
]}
/>
</Card>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.inverterEfficiency')}</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<UniversalBarChart
data={invEfficiencyData}
xKey="device"
height={220}
backgroundColor="transparent"
barSize={28}
radius={[6, 6, 0, 0]}
series={[{ key: 'efficiency', name: '效率', color: '#165DFF' }]}
/>
</Card>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.maintenanceProgress')}</span>} extra={<Button type="link" size="small">{t('home.fixed2MoreGt')}</Button>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<div style={{ display: 'flex', alignItems: 'center' }}>
<UniversalPieChart
data={taskProgressData}
width={220}
height={220}
innerRadius={45}
outerRadius={70}
backgroundColor="transparent"
/>
<div style={{ flex: 1, paddingLeft: 12 }}>
<div style={{ textAlign: 'center' }}>
<div style={{ fontSize: 12, color: '#999' }}>{t('home.taskSuspended2Fixed2')}</div>
<div style={{ fontSize: 20, fontWeight: 800 }}>12</div>
</div>
</div>
</div>
</Card>
</Space>
</Col>
{/* 中间 */}
<Col xs={24} xl={12}>
<Space direction="vertical" size={8} style={{ width: '100%' }}>
<Card
title={
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<span style={{ fontWeight: 800 }}>{t('home.stationOverview')}</span>
<div style={{ display: 'flex', gap: 16, fontSize: 12 }}>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 8, height: 8, borderRadius: '50%', background: '#52c41a', marginRight: 4 }}></span>{t('roles.normal')}</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 8, height: 8, borderRadius: '50%', background: '#ff4d4f', marginRight: 4 }}></span>{t('constants.sourceAlert')}</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 8, height: 8, borderRadius: '50%', background: '#888', marginRight: 4 }}></span>{t('devices.offline')}</span>
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 8, height: 8, borderRadius: '50%', background: '#faad14', marginRight: 4 }}></span>{t('home.underMaintenance')}</span>
</div>
</div>
}
bordered={false}
style={cardStyle}
bodyStyle={{ padding: 0, position: 'relative', overflow: 'hidden', height: 500 }}
>
<div style={{ height: "100%", background: '#111827', borderRadius: 8, width: '100%', overflow: 'hidden', position: "relative" }}>
{/*<iframe
src="https://pvs.satabot.com/?platform=web"
style={{ width: '100%', height: '100%', border: 'none', borderRadius: '8px', position: "absolute" }}
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
title={t('home.s20')}
/>*/}
<CesiumMap from="other" />
</div>
</Card>
<Row gutter={16}>
<Col span={12}>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.recentInspection')}</span>} extra={<Button type="link" size="small">{t('home.fixed2MoreGt')}</Button>} bordered={false} style={{ ...cardStyle, height: "100%" }} bodyStyle={{ padding: '0 12px' }}>
<Table
dataSource={patrolRecords}
pagination={false}
size="small"
columns={[
{ title: t('home.InspectionType'), dataIndex: 'name', key: 'name', ellipsis: true },
{ title: t('home.InspectionTime'), dataIndex: 'time', key: 'time' },
{ title: t('home.InspectionPerson'), dataIndex: 'person', key: 'person', render: (t) => t.substring(0, 10) },
{ title: t('roles.status'), dataIndex: 'status', key: 'status', render: () => <span style={{ color: '#52c41a', fontSize: 12 }}>{t('home.completedFixed2')}</span> },
]}
/>
</Card>
</Col>
<Col span={12}>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.aiAnalysisSummary')}</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' }}>{t('home.detectFixed2')}</div>
<div style={{ fontSize: 14, color: '#4E5969', marginTop: 4 }}>{t('home.s4')}<span style={{ color: '#165DFF', fontWeight: 600 }}>2</span>{t('home.abnormalFixed2HotspotFixed2')}</div>
</div>
</div>
<Button type="link" size="small" style={{ color: '#165DFF' }}>{t('common.viewDetail')}</Button>
</div>
<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' }}>{t('home.abnormalFixed2')}</div>
<div style={{ fontSize: 14, color: '#4E5969', marginTop: 4 }}><span style={{ color: '#165DFF', fontWeight: 600 }}>3</span>{t('home.generationFixed2AbnormalFixed2')}</div>
</div>
</div>
<Button type="link" size="small" style={{ color: '#165DFF' }}>{t('common.viewDetail')}</Button>
</div>
<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' }}>{t('home.fixed2GenerationDeviation')}</div>
<div style={{ fontSize: 14, color: '#4E5969', marginTop: 4 }}>{t('home.generationDeviationFixed2')}<span style={{ color: '#165DFF', fontWeight: 600 }}>-2.8%</span></div>
</div>
</div>
<Button type="link" size="small" style={{ color: '#165DFF' }}>{t('common.viewDetail')}</Button>
</div>
</div>
</Card>
</Col>
</Row>
</Space>
</Col>
{/* 右侧 */}
<Col xs={24} xl={6}>
<Space direction="vertical" size={8} style={{ width: '100%' }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('alerts.realtimeAlert')}</span>} extra={<Button type="link" size="small" onClick={() => navigate('/alerts/all')}>{t('home.fixed2MoreGt')}</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 }}>{t('alerts.alarmContent')}</span>
<span style={{ flex: 1, textAlign: 'center' }}>{t('alerts.level')}</span>
<span style={{ flex: 1.5, textAlign: 'right' }}>{t('alerts.occurTime')}</span>
</div>
{alarmList.slice(0, 2).map((alert, idx) => {
let dotColor = alert.alarmLevel === 'ERROR' ? '#ff4d4f' : alert.alarmLevel === 'WARNING' ? '#fa8c16' : '#1677ff';
let tagColor = alert.alarmLevel === 'ERROR' ? 'error' : alert.alarmLevel === 'WARNING' ? 'warning' : 'processing';
return (
<div key={idx} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12, padding: '0 4px', borderBottom: idx < 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 }}>{alert.alarmTitle}</span>
</div>
<div style={{ flex: 1, textAlign: 'center' }}>
<Tag color={tagColor} style={{ fontSize: 12 }}>{alert.alarmLevel}</Tag>
</div>
<div style={{ flex: 1.5, textAlign: 'right', fontSize: 13 }}>{alert.createTime}</div>
</div>
);
})}
</Card>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.deviceOnlineStatus')}</span>} extra={<Button type="link" size="small">{t('home.fixed2MoreGt')}</Button>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<Row gutter={[16, 16]}>
{[
{ name: t('home.solarPanel'), count: '320/320', icon: <AppstoreOutlined /> },
{ name: t('home.inverter'), count: '5/5', icon: <ThunderboltOutlined /> },
{ name: t('home.combinerBox'), count: '20/20', icon: <BranchesOutlined /> },
{ name: t('home.WeatherStation'), count: '1/1', icon: <CloudOutlined /> },
{ name: t('devices.camera'), count: '12/12', icon: <VideoCameraOutlined /> },
{ name: t('home.environmentalSensor'), count: '8/8', icon: <ExperimentOutlined /> },
{ name: t('constants.uav'), count: '1/1', icon: <RocketOutlined /> },
{ name: t('home.inspectionRobot'), count: '1/1', icon: <RobotOutlined /> },
].map((item, idx) => (
<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>
<div style={{ fontSize: 12, fontWeight: 600 }}>{item.name}</div>
<div style={{ fontSize: 10, color: '#52c41a', fontWeight: 700, marginTop: 4 }}>{item.count}</div>
</div>
</Col>
))}
</Row>
</Card>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.weatherInfo')}</span>} extra={<Button type="link" size="small">{t('home.gt')}</Button>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'start', gap: 20 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
<WeatherDisplay type={weatherType} />
<div>
<div style={{ fontSize: 28, fontWeight: 800, color: '#1890ff' }}>{weatherdata.temperature}℃</div>
<div style={{ fontSize: 14, color: '#333' }}>{weatherdata.weather}</div>
</div>
</div>
<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>
</div>
</div>
</Card>
{/* ====================================== */}
{/* 👇 清洗建议 + 生成工单按钮(已完善) */}
{/* ====================================== */}
<Card title={<span style={{ fontWeight: 800 }}>{t('clean.cleaningSuggestion')}</span>} extra={<Button type="link" size="small">{t('home.fixed2MoreGt')}</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' }}>
<UniversalPieChart
data={[
{ name: '清洁度', value: 85, color: '#00B42A' },
{ name: t('clean.pending'), value: 15, color: '#E8FFEA' },
]}
width="100%"
height="100%"
innerRadius={20}
outerRadius={26}
showTooltip={false}
showLegend={false}
showLabel={false}
/>
</div>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 12, color: '#666', marginBottom: 4 }}>{t('home.cleaningFixed2Time')}<span style={{ color: '#165DFF' }}>{t('home.3')}</span></div>
<div style={{ fontSize: 12, color: '#666', marginBottom: 4 }}>{t('home.fixed2Battery')}<span style={{ color: '#00B42A' }}>2.6 %</span></div>
<div style={{ fontSize: 12, color: '#666' }}>{t('home.battery')}<span style={{ color: '#00B42A' }}>{t('home.120')}</span></div>
</div>
</div>
<Button
type="primary"
block
style={{ borderRadius: 8, height: 36 }}
onClick={handleaddOrder}
>{t('home.generateCleanOrder')}</Button>
</Card>
</Space>
</Col>
</Row>
</div>
);
}