首页发电趋势 支持放大

This commit is contained in:
mmc
2026-09-04 10:22:49 +08:00
parent a85497299a
commit c30f0544c2

View File

@@ -7,6 +7,7 @@ import {
MoneyCollectOutlined, MoneyCollectOutlined,
DashboardOutlined, DashboardOutlined,
FullscreenOutlined, FullscreenOutlined,
FullscreenExitOutlined,
RocketOutlined, RocketOutlined,
VideoCameraOutlined, VideoCameraOutlined,
AppstoreOutlined, AppstoreOutlined,
@@ -21,27 +22,57 @@ import { getWeatherData, getWeatherType } from '../lib/utils';
import WeatherDisplay from '../components/Weather'; import WeatherDisplay from '../components/Weather';
import bgMain from '../assets/images/bgmain.jpg'; import bgMain from '../assets/images/bgmain.jpg';
import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../components/recharts'; import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../components/recharts';
// 👇 在这里引入你的工单接口(改成你真实的接口地址) // 👇 在这里引入你的工单接口(改成你真实的接口地址)
import { addWorkOrder } from '../api/workOrder'; import { addWorkOrder } from '../api/workOrder';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { getAlarmList } from '../api/alarmApi'; import { getAlarmList } from '../api/alarmApi';
import { RootState } from '../store'; import { RootState } from '../store';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
const { Text } = Typography; const { Text } = Typography;
export default function StationDashboard() { export default function StationDashboard() {
const { t } = useTranslation(); const { t } = useTranslation();
// 👇 消息提示(修复缺失) // 👇 消息提示(修复缺失)
const [messageApi, contextHolder] = message.useMessage(); const [messageApi, contextHolder] = message.useMessage();
// 👇 获取当前选中的电站(从redux拿,修复缺失) // 👇 获取当前选中的电站(从redux拿,修复缺失)
const { currentStation } = useSelector((state) => state.station); const { currentStation } = useSelector((state) => state.station);
const { userInfo } = useSelector((state) => state.user); const { userInfo } = useSelector((state) => state.user);
const { stationId } = useSelector((state: RootState) => state.station); const { stationId } = useSelector((state: RootState) => state.station);
const [alarmList, setAlarmList] = useState([]); const [alarmList, setAlarmList] = useState([]);
// ========== 发电趋势卡片全屏相关 ==========
const powerTrendCardRef = useRef<HTMLDivElement>(null);
const [isPowerCardFullscreen, setIsPowerCardFullscreen] = useState(false);
const togglePowerCardFullScreen = async () => {
const el = powerTrendCardRef.current;
if (!el) return;
try {
if (!document.fullscreenElement) {
await el.requestFullscreen();
} else {
await document.exitFullscreen();
}
} catch (err) {
console.error('全屏切换异常:', err);
}
};
const handleRefreshPowerTrend = () => {
console.log('刷新发电趋势数据');
// 这里可以写重新请求接口逻辑
};
useEffect(() => {
const onFullScreenChange = () => {
setIsPowerCardFullscreen(!!document.fullscreenElement);
};
document.addEventListener('fullscreenchange', onFullScreenChange);
return () => {
document.removeEventListener('fullscreenchange', onFullScreenChange);
};
}, []);
// =========================================
// 天气数据 // 天气数据
const [weatherdata, setWeatherData] = useState({ const [weatherdata, setWeatherData] = useState({
@@ -58,7 +89,6 @@ export default function StationDashboard() {
report_time: "2026-03-27 12:35:08" report_time: "2026-03-27 12:35:08"
}); });
const weatherType = getWeatherType(weatherdata.weather); const weatherType = getWeatherType(weatherdata.weather);
// 请求天气 // 请求天气
useEffect(() => { useEffect(() => {
const fetchWeather = async () => { const fetchWeather = async () => {
@@ -71,7 +101,6 @@ export default function StationDashboard() {
}; };
fetchWeather(); fetchWeather();
}, []); }, []);
// 模拟数据 // 模拟数据
const stationOverview = { const stationOverview = {
todayEnergy: 4752.0, todayEnergy: 4752.0,
@@ -85,27 +114,22 @@ export default function StationDashboard() {
}; };
// 组件内部 // 组件内部
const navigate = useNavigate(); const navigate = useNavigate();
const deviceStatus = [ const deviceStatus = [
{ name: t('home.combinerBox'), count: "2/2", status: "异常 1" }, { name: t('home.combinerBox'), count: "2/2", status: "异常 1" },
{ name: t('home.inverter'), count: "3/3", status: "异常 1" }, { name: t('home.inverter'), count: "3/3", status: "异常 1" },
{ name: "电表", count: "1/1", status: t('roles.normal') }, { name: "电表", count: "1/1", status: t('roles.normal') },
{ name: t('home.inspectionRobot'), count: "1/1", status: t('roles.normal') } { name: t('home.inspectionRobot'), count: "1/1", status: t('roles.normal') }
]; ];
const patrolRecords = [ const patrolRecords = [
{ name: "升压站安防巡检任务", device: "UAV-01", status: "草稿", time: "04-29T...", person: "张运维" }, { name: "升压站安防巡检任务", device: "UAV-01", status: "草稿", time: "04-29T...", person: "张运维" },
{ name: "B区清洗任务", device: "CLEAN-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: "张运维" } { name: "A区巡检任务", device: "ROBOT-01", status: "已派发", time: "04-29T...", person: "张运维" }
]; ];
const aiAnalysis = [ const aiAnalysis = [
{ type: "AI分析", content: t('home.fixed2AiInverterFixed2TemperatureAbnormalADevice'), desc: "发现2处组件存在异常热斑" }, { 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.invA02MaintenanceInvA02Repair'), desc: "3个组串存在发电异常" },
{ type: t('constants.critical'), content: t('home.a05HotspotPvA05018PvA05020StatusAbnormal'), desc: "整体发电偏差-2.8%" } { type: t('constants.critical'), content: t('home.a05HotspotPvA05018PvA05020StatusAbnormal'), desc: "整体发电偏差-2.8%" }
]; ];
// 图表数据 // 图表数据
const powerTrendData = [ const powerTrendData = [
{ time: '00:00', actual: 1800, predict: 1600 }, { time: '00:00', actual: 1800, predict: 1600 },
@@ -120,7 +144,6 @@ export default function StationDashboard() {
{ time: '20:00', actual: 3000, predict: 2500 }, { time: '20:00', actual: 3000, predict: 2500 },
{ time: '24:00', actual: 1800, predict: 1600 }, { time: '24:00', actual: 1800, predict: 1600 },
]; ];
const irradianceData = [ const irradianceData = [
{ time: '00:00', irradiance: 40, temperature: 14 }, { time: '00:00', irradiance: 40, temperature: 14 },
{ time: '04:00', irradiance: 30, temperature: 12 }, { time: '04:00', irradiance: 30, temperature: 12 },
@@ -141,16 +164,13 @@ export default function StationDashboard() {
{ device: 'INV-04', efficiency: 96.5 }, { device: 'INV-04', efficiency: 96.5 },
{ device: 'INV-05', efficiency: 95.8 }, { device: 'INV-05', efficiency: 95.8 },
]; ];
const taskProgressData = [ const taskProgressData = [
{ name: t('workOrder.completed'), value: 40, color: '#1890ff' }, { name: t('workOrder.completed'), value: 40, color: '#1890ff' },
{ name: '进行中', value: 35, color: '#52c41a' }, { name: '进行中', value: 35, color: '#52c41a' },
{ name: '待开始', value: 20, color: '#faad14' }, { name: '待开始', value: 20, color: '#faad14' },
{ name: t('home.abnormal'), value: 5, color: '#ff4d4f' }, { 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 cardStyle = { borderRadius: 12, border: '1px solid #f0f0f0', boxShadow: '0 2px 8px rgba(0,0,0,0.04)' };
// ============================================== // ==============================================
// 👇 【完整完善】生成清洗工单(核心修复) // 👇 【完整完善】生成清洗工单(核心修复)
// ============================================== // ==============================================
@@ -165,12 +185,12 @@ export default function StationDashboard() {
try { try {
// 严格按照你给的接口字段传参 // 严格按照你给的接口字段传参
const params = { const params = {
id: '', // 主键ID(新增为空) id: '', // 主键ID(新增为空)
orderNo: '', // 工单编号(后端生成) orderNo: '', // 工单编号(后端生成)
orderTitle: '光伏组件清洗工单', // 工单标题 orderTitle: '光伏组件清洗工单', // 工单标题
sourceType: 3, // 来源 3=清洗 sourceType: 3, // 来源 3=清洗
orderType: 3, // 类型 3=清洗 orderType: 3, // 类型 3=清洗
priorityLevel: 2, // 优先级 2=中 priorityLevel: 2, // 优先级 2=中
deviceId: currentStation.id || '', deviceId: currentStation.id || '',
deviceName: currentStation.siteName || '电站', deviceName: currentStation.siteName || '电站',
deviceType: 1, // 设备类型:电站 deviceType: 1, // 设备类型:电站
@@ -186,7 +206,7 @@ export default function StationDashboard() {
deadlineTime: '', deadlineTime: '',
actualStartTime: '', actualStartTime: '',
actualEndTime: '', actualEndTime: '',
orderStatus: 1, // 状态 1=待处理 orderStatus: 1, // 状态 1=待处理
alarmId: '', alarmId: '',
alarmNo: '', alarmNo: '',
taskDescription: '根据电站清洁度建议进行组件清洗,提升发电效率', taskDescription: '根据电站清洁度建议进行组件清洗,提升发电效率',
@@ -196,9 +216,7 @@ export default function StationDashboard() {
handleResult: '', handleResult: '',
handleRemark: '' handleRemark: ''
}; };
const res = await addWorkOrder(params); const res = await addWorkOrder(params);
if (res.code === 0 || res.code === 200) { if (res.code === 0 || res.code === 200) {
messageApi.success(t('home.cleaningOrderGeneratedSuccessfullyFixed2')); messageApi.success(t('home.cleaningOrderGeneratedSuccessfullyFixed2'));
} else { } else {
@@ -220,24 +238,19 @@ export default function StationDashboard() {
if (res.code === 200) { if (res.code === 200) {
setAlarmList(res?.rows || []); setAlarmList(res?.rows || []);
} }
} catch (err) { } catch (err) {
messageApi.error(t('common.loadFailed')); messageApi.error(t('common.loadFailed'));
} finally { } finally {
} }
}; };
useEffect(() => { useEffect(() => {
fetchList() fetchList()
}, [stationId]) }, [stationId])
return ( return (
<div style={{ background: '#f8fafc', padding: '0px', minHeight: '100vh', width: '100%', boxSizing: 'border-box' }}> <div style={{ background: '#f8fafc', padding: '0px', minHeight: '100vh', width: '100%', boxSizing: 'border-box' }}>
{/* 👇 必须加这个,message才能正常显示 */} {/* 👇 必须加这个,message才能正常显示 */}
{contextHolder} {contextHolder}
{/* 顶部统计卡片 */} {/* 顶部统计卡片 */}
<Row gutter={[8, 8]} style={{ margin: '0 4px 0px 4px' }}> <Row gutter={[8, 8]} style={{ margin: '0 4px 0px 4px' }}>
{[ {[
@@ -276,27 +289,45 @@ export default function StationDashboard() {
</Col> </Col>
))} ))}
</Row> </Row>
{/* 主体布局 */} {/* 主体布局 */}
<Row gutter={[8, 8]}> <Row gutter={[8, 8]}>
{/* 左侧图表 */} {/* 左侧图表 */}
<Col xs={24} xl={6}> <Col xs={24} xl={6}>
<Space direction="vertical" size={8} style={{ width: '100%' }}> <Space direction="vertical" size={8} style={{ width: '100%' }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.generationTrend')}</span>} extra={<Space><SyncOutlined /><FullscreenOutlined /></Space>} variant="borderless" style={cardStyle} styles={{ body: { padding: '8px' } }}> {/* ========== 发电趋势卡片,增加ref与全屏逻辑 ========== */}
<div style={{ fontSize: 11, color: '#666', marginBottom: 8 }}>今日发电功率趋势 (kW)</div> <div ref={powerTrendCardRef} style={{ alignItems: 'center', display: "flex", justifyContent: "center" }}>
<UniversalLineChart <Card
data={powerTrendData} title={<span style={{ fontWeight: 800 }}>{t('home.generationTrend')}</span>}
xKey="time" extra={
height={200} <Space>
smooth <SyncOutlined onClick={handleRefreshPowerTrend} style={{ cursor: 'pointer' }} />
dot {isPowerCardFullscreen ? (
backgroundColor="transparent" <FullscreenExitOutlined onClick={togglePowerCardFullScreen} style={{ cursor: 'pointer' }} />
series={[ ) : (
{ key: 'actual', name: t('home.actual'), color: '#165DFF', strokeWidth: 3 }, <FullscreenOutlined onClick={togglePowerCardFullScreen} style={{ cursor: 'pointer' }} />
{ key: 'predict', name: t('home.predict'), color: '#00B42A', strokeWidth: 2 }, )}
]} </Space>
/> }
</Card> variant="borderless"
style={{ ...cardStyle, width: "100%" }}
styles={{ body: { padding: '8px' } }}
>
<div style={{ fontSize: 11, color: '#666', marginBottom: 8 }}>今日发电功率趋势 (kW)</div>
<UniversalLineChart
data={powerTrendData}
xKey="time"
height={isPowerCardFullscreen ? window.innerHeight : 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>
</div>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.irradianceTempTrend')}</span>} variant="borderless" style={cardStyle} styles={{ body: { padding: '8px' } }}> <Card title={<span style={{ fontWeight: 800 }}>{t('home.irradianceTempTrend')}</span>} variant="borderless" style={cardStyle} styles={{ body: { padding: '8px' } }}>
<UniversalLineChart <UniversalLineChart
data={irradianceData} data={irradianceData}
@@ -342,7 +373,6 @@ export default function StationDashboard() {
</Card> </Card>
</Space> </Space>
</Col> </Col>
{/* 中间 */} {/* 中间 */}
<Col xs={24} xl={12}> <Col xs={24} xl={12}>
<Space direction="vertical" size={8} style={{ width: '100%' }}> <Space direction="vertical" size={8} style={{ width: '100%' }}>
@@ -364,18 +394,15 @@ export default function StationDashboard() {
> >
<div style={{ height: "100%", background: '#111827', borderRadius: 8, width: '100%', overflow: 'hidden', position: "relative" }}> <div style={{ height: "100%", background: '#111827', borderRadius: 8, width: '100%', overflow: 'hidden', position: "relative" }}>
{/*<iframe {/*<iframe
src="https://pvs.satabot.com/?platform=web" src="https://pvs.satabot.com/?platform=web"
style={{ width: '100%', height: '100%', border: 'none', borderRadius: '8px', position: "absolute" }} style={{ width: '100%', height: '100%', border: 'none', borderRadius: '8px', position: "absolute" }}
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen allowFullScreen
title={t('home.s20')} title={t('home.s20')}
/>*/} />*/}
<CesiumMap from="other" mapLayer={currentStation?.siteMapName} /> <CesiumMap from="other" mapLayer={currentStation?.siteMapName} />
</div> </div>
</Card> </Card>
<Row gutter={16}> <Row gutter={16}>
<Col span={12}> <Col span={12}>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.recentInspection')}</span>} extra={<Button type="link" size="small">{t('home.fixed2MoreGt')}</Button>} variant="borderless" style={{ ...cardStyle, height: "100%" }} styles={{ body: { padding: '0 12px' } }}> <Card title={<span style={{ fontWeight: 800 }}>{t('home.recentInspection')}</span>} extra={<Button type="link" size="small">{t('home.fixed2MoreGt')}</Button>} variant="borderless" style={{ ...cardStyle, height: "100%" }} styles={{ body: { padding: '0 12px' } }}>
@@ -438,7 +465,6 @@ export default function StationDashboard() {
</Row> </Row>
</Space> </Space>
</Col> </Col>
{/* 右侧 */} {/* 右侧 */}
<Col xs={24} xl={6}> <Col xs={24} xl={6}>
<Space direction="vertical" size={8} style={{ width: '100%' }}> <Space direction="vertical" size={8} style={{ width: '100%' }}>
@@ -507,7 +533,6 @@ export default function StationDashboard() {
</div> </div>
</div> </div>
</Card> </Card>
{/* ====================================== */} {/* ====================================== */}
{/* 👇 清洗建议 + 生成工单按钮(已完善) */} {/* 👇 清洗建议 + 生成工单按钮(已完善) */}
{/* ====================================== */} {/* ====================================== */}