diff --git a/env.js b/env.js index 6804882..90e2c7b 100644 --- a/env.js +++ b/env.js @@ -9,8 +9,8 @@ const currentEnv = import.meta.env?.MODE || process.env.NODE_ENV; // 环境配置映射 const envConfig = { [ENV.DEV]: { - //baseURL: 'http://192.168.2.59:8081',//http://192.168.2.56:8081 - baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081 + baseURL: 'http://192.168.2.59:8081',//http://192.168.2.56:8081 + //baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081 WS_URL: 'ws://192.168.2.56:9002/ws/', }, [ENV.PROD]: { diff --git a/src/api/deviceAccess.ts b/src/api/deviceAccess.ts index 2d1b934..b821e1d 100644 --- a/src/api/deviceAccess.ts +++ b/src/api/deviceAccess.ts @@ -1,9 +1,28 @@ -import request from '../request'; +import request from './request'; //新增物模型 export function addDeviceModel(data) { return request({ - url: 'system/devicemodel/add', + url: '/system/devicemodel/add', + method: 'post', + data + }); +} + +//物模型列表export function addDeviceModel(data) { +export function getDeviceModelList(params) { + return request({ + url: ' /iot/deviceModel/list', + method: 'get', + params + }); +} + +//物模型修改 + +export function updateDeviceModel(data) { + return request({ + url: '/system/devicemodel/update', method: 'post', data }); diff --git a/src/components/SystemSetting/DeviceAccessPage.tsx b/src/components/SystemSetting/DeviceAccessPage.tsx index 2456d1e..186288e 100644 --- a/src/components/SystemSetting/DeviceAccessPage.tsx +++ b/src/components/SystemSetting/DeviceAccessPage.tsx @@ -1,12 +1,13 @@ import { useState } from 'react'; import { Card, Table, Button, Space, Form, Modal, Input, Select, InputNumber, - Tabs, Tag, Popconfirm, message, Divider, Switch, Empty + Tabs, Tag, Popconfirm, message, Divider, Switch, Empty, Checkbox } from 'antd'; import { PlusOutlined, EditOutlined, DeleteOutlined, ProductOutlined, AppstoreOutlined, SwapOutlined, VideoCameraOutlined } from '@ant-design/icons'; +import { addDeviceModel } from '../../api/deviceAccess.ts'; const { Option } = Select; const { TabPane } = Tabs; @@ -40,24 +41,24 @@ const modelDetailList: Record = { 10: { props: [ - { id: 1, code: 'device_online', name: '在线状态', type: 'bool', rw: 'r', isAlarm: false }, - { id: 2, code: 'record_status', name: '录像状态', type: 'string', rw: 'r', isAlarm: false }, + { id: 1, code: 'device_online', name: '在线状态', type: 'bool', rw: 'r', isAlarm: false, unit: '', required: true, defaultValue: null }, + { id: 2, code: 'record_status', name: '录像状态', type: 'string', rw: 'r', isAlarm: false, unit: '', required: true, defaultValue: null }, ], events: [{ id: 1, code: 'alarm_perimeter', name: '周界入侵告警' }], actions: [{ actionId: 'take_snapshot', actionName: '截图', params: {} }] }, 11: { props: [ - { id: 1, code: 'temp', name: '温度', type: 'float', rw: 'r', isAlarm: true }, - { id: 2, code: 'humi', name: '湿度', type: 'float', rw: 'r', isAlarm: true }, + { id: 1, code: 'temp', name: '温度', type: 'float', rw: 'r', isAlarm: true, unit: '℃', required: true, defaultValue: null }, + { id: 2, code: 'humi', name: '湿度', type: 'float', rw: 'r', isAlarm: true, unit: '%', required: true, defaultValue: null }, ], events: [{ id: 1, code: 'temp_over', name: '超温告警' }], actions: [] }, 12: { props: [ - { id: 1, code: 'battery', name: '电量', type: 'int', rw: 'r', isAlarm: true }, - { id: 2, code: 'voltage', name: '电压', type: 'float', rw: 'r', isAlarm: true }, + { id: 1, code: 'battery', name: '电量', type: 'int', rw: 'r', isAlarm: true, unit: '%', required: true, defaultValue: null }, + { id: 2, code: 'voltage', name: '电压', type: 'float', rw: 'r', isAlarm: true, unit: 'V', required: true, defaultValue: null }, ], events: [{ id: 1, code: 'low_power', name: '低电量告警' }], actions: [] @@ -101,12 +102,12 @@ export default function DeviceAccessPage() { const [itemType, setItemType] = useState<'props' | 'events' | 'actions'>('props'); const [itemForm] = Form.useForm(); - // 指令 + 参数 新增状态 + // 指令 + 参数 + 枚举 const [actionModal, setActionModal] = useState(false); const [currentAction, setCurrentAction] = useState(null); const [paramList, setParamList] = useState([]); - // 字段映射(实时增删改查,实时保存) + // 字段映射 const [mappingList, setMappingList] = useState(mappingInitList); const [mappingModal, setMappingModal] = useState(false); const [mappingForm] = Form.useForm(); @@ -133,35 +134,45 @@ export default function DeviceAccessPage() { setVisible(true); }; - // 提交 + // ===================== 物模型提交(完全匹配你的JSON) ===================== const handleSubmit = () => { form.validateFields().then(values => { if (modalType === 'model') { const submitData = { name: values.name, connectType: values.connectType, - version: "1.0", + version: '1.0', deviceType: values.deviceType, supportProperties: modelDetail.props.map(p => ({ propertyKey: p.code, propertyName: p.name, dataType: p.type, - unit: p.unit || "", - required: true, - defaultValue: null + unit: p.unit || '', + required: p.required ?? true, + defaultValue: p.defaultValue ?? null, + isAlarm: p.isAlarm ?? false })), - supportActions: modelDetail.actions + supportActions: modelDetail.actions.map(act => ({ + actionId: act.actionId, + actionName: act.actionName, + params: act.params || {} + })) }; - console.log("最终提交物模型:", submitData); - message.success("物模型保存成功"); + addDeviceModel(submitData).then(res => { + if (res.code === 200) { + message.success('物模型保存成功'); + } + }); + console.log('✅ 最终提交物模型(完全匹配接口)', submitData); + message.success('物模型保存成功'); } else { - message.success("保存成功"); + message.success('保存成功'); } setVisible(false); }); }; - // 属性/事件 编辑 + // 属性编辑 const openItemModal = (type: 'props' | 'events' | 'actions', record?: any) => { setItemType(type); itemForm.resetFields(); @@ -181,7 +192,7 @@ export default function DeviceAccessPage() { setModelDetail({ ...modelDetail, [type]: list }); }; - // ===================== 字段映射:增删改 立即保存 ===================== + // 字段映射 const openMappingModal = (record?: any) => { mappingForm.resetFields(); if (record) mappingForm.setFieldsValue(record); @@ -211,7 +222,6 @@ export default function DeviceAccessPage() { message.success('字段映射删除成功'); }; - // 获取告警属性 const getAlarmProps = () => modelDetail?.props?.filter(item => item.isAlarm) || []; // 表格列 @@ -243,7 +253,6 @@ export default function DeviceAccessPage() { const modelColumns = [ { title: '模型名称', dataIndex: 'name' }, - { title: '描述', dataIndex: 'desc' }, { title: '操作', render: r => } ]; @@ -261,7 +270,7 @@ export default function DeviceAccessPage() { {activeTab === 'product' && } {activeTab === 'model' &&
} - setVisible(false)} onOk={handleSubmit} destroyOnClose + setVisible(false)} onOk={handleSubmit} destroyOnClose title={modalType === 'device' ? '设备配置' : modalType === 'product' ? '产品配置' : '物模型配置'}>
{modalType === 'device' && ( @@ -344,15 +353,28 @@ export default function DeviceAccessPage() { 属性列表
}, - { title: '操作', render: r => deleteItem('props', r.id)}> } + { + title: '操作', render: r => ( + + + deleteItem('props', r.id)}> + + + + ) + } ]} /> 指令列表
- setItemModal(false)} onOk={saveItem} title="编辑"> + {/* 属性弹窗:完整字段 */} + setItemModal(false)} onOk={saveItem} title="配置属性"> - - - {itemType === 'props' && <>} + + + + + + + {/**/} + + - {/* 指令 + 参数 弹窗 */} + {/* 指令 + 参数 + 枚举 */} x.actionId === currentAction.actionId); - let newActions = []; - if (exists) { - newActions = modelDetail.actions.map(x => x.actionId === currentAction.actionId ? action : x); - } else { - newActions = [...modelDetail.actions, action]; - } - - setModelDetail({ ...modelDetail, actions: newActions }); + setModelDetail({ + ...modelDetail, + actions: exists + ? modelDetail.actions.map(x => x.actionId === currentAction.actionId ? action : x) + : [...modelDetail.actions, action] + }); setActionModal(false); message.success('保存成功'); }} - width={700} + width={750} > -
+
setCurrentAction({ ...currentAction, actionId: e.target.value })} - style={{ width: '48%', marginRight: '4%' }} + style={{ flex: 1 }} /> setCurrentAction({ ...currentAction, actionName: e.target.value })} - style={{ width: '48%' }} + style={{ flex: 1 }} />
- 指令参数 + 指令参数(支持枚举) - {paramList.map((item, index) => ( -
- { + {/* 只保留 1 个参数,不支持新增多行 */} + {paramList.length > 0 && ( +
+ { const arr = [...paramList]; - arr[index].paramKey = e.target.value; + arr[0].paramKey = e.target.value; setParamList(arr); }} /> - { const arr = [...paramList]; - arr[index].type = v; + arr[0].type = v; setParamList(arr); }}> int string - { + { const arr = [...paramList]; - arr[index].desc = e.target.value; + arr[0].desc = e.target.value; setParamList(arr); }} /> - { + { const arr = [...paramList]; - arr[index].defaultValue = e.target.value; + arr[0].defaultValue = e.target.value; + setParamList(arr); + }} /> + { + const arr = [...paramList]; + arr[0].enum = e.target.value.split(',').map(s => s.trim()); setParamList(arr); }} /> -
- ))} + )} + - setMappingModal(false)} onOk={saveMapping} title="字段映射配置"> diff --git a/src/components/SystemSetting/OnlineUser.tsx b/src/components/SystemSetting/OnlineUser.tsx new file mode 100644 index 0000000..24d64b2 --- /dev/null +++ b/src/components/SystemSetting/OnlineUser.tsx @@ -0,0 +1,160 @@ +import React, { useState } from 'react'; +import { + Input, Button, Table, message, Space, Tabs, Card +} from 'antd'; +import { SearchOutlined, ReloadOutlined } from '@ant-design/icons'; + +const { Search } = Input; +const { TabPane } = Tabs; + +// 模拟在线用户数据 +const mockOnlineUsers = [ + { + id: 1, + sessionId: 'c85c6fe7-2e70-47...', + loginName: 'admin', + dept: '研发部门', + host: '127.0.0.1', + location: '内网IP', + os: 'Linux', + browser: 'Firefox 136.0', + loginTime: '2026-05-08 09:46:08' + }, + { + id: 2, + sessionId: '9f6c7d73-f684-4e...', + loginName: 'admin', + dept: '研发部门', + host: '127.0.0.1', + location: '内网IP', + os: 'Windows >=10', + browser: 'Edge 147', + loginTime: '2026-05-08 10:11:27' + } +]; + +const OnlineUserPage = () => { + const [activeTab, setActiveTab] = useState('onlineUser'); // 默认选中在线用户 + const [loading, setLoading] = useState(false); + const [dataSource, setDataSource] = useState(mockOnlineUsers); + const [searchParams, setSearchParams] = useState({ + loginAddress: '', + userName: '' + }); + + // 搜索 + const handleSearch = () => { + setLoading(true); + // 模拟接口请求 + setTimeout(() => { + setLoading(false); + message.success('搜索完成'); + }, 500); + }; + + // 重置 + const handleReset = () => { + setSearchParams({ loginAddress: '', userName: '' }); + setDataSource(mockOnlineUsers); + message.info('已重置搜索条件'); + }; + + // 强退用户 + const handleForceLogout = (record) => { + message.info(`已向会话 ${record.sessionId} 发送强退指令`); + }; + + // 表格列配置 + const columns = [ + { title: '序号', dataIndex: 'id', width: 60 }, + { title: '会话编号', dataIndex: 'sessionId', ellipsis: true }, + { title: '登录名称', dataIndex: 'loginName' }, + { title: '所属部门', dataIndex: 'dept' }, + { title: '主机', dataIndex: 'host' }, + { title: '登录地点', dataIndex: 'location' }, + { title: '操作系统', dataIndex: 'os' }, + { title: '浏览器', dataIndex: 'browser' }, + { title: '登录时间', dataIndex: 'loginTime' }, + { + title: '操作', width: 100, + render: (_, record) => ( + + ) + } + ]; + + return ( +
+ {/* ====================== 顶部 Tabs ====================== */} + + + + + + {/* ====================== Tab 1:在线用户 ====================== */} + {activeTab === 'onlineUser' && ( + + {/* 搜索栏 */} +
+
+ 登录地址 + setSearchParams({ ...searchParams, loginAddress: e.target.value })} + style={{ width: 200 }} + /> +
+
+ 用户名称 + setSearchParams({ ...searchParams, userName: e.target.value })} + style={{ width: 200 }} + /> +
+ + +
+ + {/* 在线用户表格 */} +
`共 ${total} 条`, + showQuickJumper: true + }} + bordered={false} + /> + + )} + + {/* ====================== Tab 2:其他页面(你可以随便改内容) ====================== */} + {activeTab === 'other' && ( + +

其他监控内容

+

这里可以放服务状态、CPU监控、内存监控、接口监控等内容

+
+ )} + + ); +}; + +export default OnlineUserPage; diff --git a/src/components/SystemSetting/StationManage.tsx b/src/components/SystemSetting/StationManage.tsx index a162dc9..d034bde 100644 --- a/src/components/SystemSetting/StationManage.tsx +++ b/src/components/SystemSetting/StationManage.tsx @@ -23,7 +23,7 @@ export default function StationManage() { // 组织列表 const [orgList, setOrgList] = useState([]); - // 🔥 新增:选中的组织ID(用于筛选) + // 🔥 选中的组织ID(用于筛选) const [selectedOrgId, setSelectedOrgId] = useState(undefined); // 获取当前登录用户信息 @@ -50,7 +50,7 @@ export default function StationManage() { total: 0 }); - // ====================== 获取组织列表(根据 userId 过滤) ====================== + // ====================== 获取组织列表 ====================== const getOrgData = () => { const params = { pageNum: 1, @@ -64,14 +64,12 @@ export default function StationManage() { }); }; - // ====================== 获取场站列表(分页 + 组织筛选) ====================== + // ====================== 获取场站列表 ====================== const getStationData = () => { const params = { pageNum: pagination.pageNum, pageSize: pagination.pageSize, - orgId: userInfo?.orgId, - // 🔥 把选中的组织ID传进去 - filterOrgId: selectedOrgId, + orgId: selectedOrgId, // 🔥 最终使用的筛选 orgId }; getStationList(params).then(res => { if (res.code === 200) { @@ -93,26 +91,37 @@ export default function StationManage() { }); }; - // 🔥 组织筛选变化 + // 组织筛选变化 const handleOrgChange = (value: number) => { setSelectedOrgId(value); - setPagination({ ...pagination, pageNum: 1 }); // 筛选重置页码 + setPagination({ ...pagination, pageNum: 1 }); }; - // 🔥 重置筛选 + // 重置筛选 const handleReset = () => { setSelectedOrgId(undefined); setPagination({ ...pagination, pageNum: 1 }); }; - // 初始化加载 + // ====================== 初始化加载 ====================== + useEffect(() => { + getOrgData(); + }, []); + + // 🔥 关键:如果 userInfo.orgId 存在,则默认选中 + useEffect(() => { + if (userInfo?.orgId) { + setSelectedOrgId(userInfo.orgId); + } + }, [userInfo]); + + // 加载数据 useEffect(() => { getStationData(); - getOrgData(); }, [ pagination.pageNum, pagination.pageSize, - selectedOrgId // 🔥 监听筛选变化 + selectedOrgId ]); // ====================== 新增 / 编辑 场站 ====================== @@ -247,28 +256,30 @@ export default function StationManage() { {contextHolder} - {/* 🔥 筛选栏 */} -
- - - -
- + {/* 🔥 筛选栏:只有 userInfo 没有 orgId 时才显示 */} + {!userInfo?.orgId && ( +
+ +
+ )} + +
+
正常 : 停用 }, + { + title: '是否有设备权限', dataIndex: 'deviceOperatePerm', width: 80, + render: (_, s) => s.deviceOperatePerm == true + ? 有权限 + : 无权限 + }, { title: '操作', width: 220, @@ -719,7 +726,22 @@ export default function UserRolePage() { + )} + + + + + diff --git a/src/pages/CleanOptimization.tsx b/src/pages/CleanOptimization.tsx index fa9d183..fa349f5 100644 --- a/src/pages/CleanOptimization.tsx +++ b/src/pages/CleanOptimization.tsx @@ -167,7 +167,6 @@ export default function CleanOptimizationPage() { ¥ diff --git a/src/pages/RealTimeMonitor.tsx b/src/pages/RealTimeMonitor.tsx new file mode 100644 index 0000000..2fbf390 --- /dev/null +++ b/src/pages/RealTimeMonitor.tsx @@ -0,0 +1,283 @@ +import React, { useState } from 'react'; +import { + Card, Row, Col, Statistic, Table, Select, Input, Tag, + Typography, Button +} from 'antd'; +import { + CloudOutlined, CheckCircleOutlined, WarningOutlined, + MinusCircleOutlined, ThunderboltOutlined, + RiseOutlined, SunOutlined, BarChartOutlined +} from '@ant-design/icons'; +import { Line, Bar, Pie } from '@ant-design/charts'; + +const { Option } = Select; +const { Search } = Input; +const { Text, Title } = Typography; + +// 模拟数据 +const deviceList = [ + { id: 1, name: '摄像头 CAM-01', type: '摄像头', status: '正常', data: '35.2 ℃', communication: '通讯正常', updateTime: '2026-04-28 11:32:45' }, + { id: 2, name: '摄像头 CAM-02', type: '摄像头', status: '离线', data: '-', communication: '通讯离线', updateTime: '2026-04-28 12:10:00' }, + { id: 3, name: '摄像头 CAM-03', type: '摄像头', status: '正常', data: '33.9 ℃', communication: '通讯正常', updateTime: '2026-04-28 11:32:45' }, + { id: 4, name: '汇流箱 CMB-A01', type: '汇流箱', status: '预警', data: '46.3 ℃', communication: '通讯正常', updateTime: '2026-04-28 11:32:45' }, + { id: 5, name: '汇流箱 CMB-A02', type: '汇流箱', status: '正常', data: '41.1 ℃', communication: '通讯正常', updateTime: '2026-04-28 11:32:45' }, + { id: 6, name: '逆变器 INV-A01', type: '逆变器', status: '正常', data: '66.8 kW', communication: '通讯正常', updateTime: '2026-04-28 12:00:00' }, + { id: 7, name: '逆变器 INV-A02', type: '逆变器', status: '预警', data: '54.2 kW', communication: '通讯正常', updateTime: '2026-04-28 12:05:00' }, + { id: 8, name: '逆变器 INV-B01', type: '逆变器', status: '正常', data: '22.4 kW', communication: '通讯正常', updateTime: '2026-04-28 11:32:45' }, + { id: 9, name: '电表 METER-01', type: '电表', status: '正常', data: '66.8 kW', communication: '通讯正常', updateTime: '2026-04-28 11:32:45' } +]; + +const powerTrendData = [ + { time: '00:00', power: 50, rated: 1000 }, + { time: '04:00', power: 70, rated: 1000 }, + { time: '08:00', power: 90, rated: 1000 }, + { time: '12:00', power: 110, rated: 1000 }, + { time: '16:00', power: 100, rated: 1000 }, + { time: '20:00', power: 80, rated: 1000 }, + { time: '24:00', power: 60, rated: 1000 } +]; + +const inverterPowerData = [ + { name: 'INV-01', power: 164.2 }, + { name: 'INV-02', power: 166.8 }, + { name: 'INV-03', power: 162.1 }, + { name: 'INV-04', power: 159.7 }, + { name: 'INV-05', power: 159.8 } +]; + +const heatmapData = [ + ['#1677ff', '#52c41a', '#1677ff', '#faad14', '#52c41a', '#1677ff', '#faad14', '#1677ff', '#1677ff', '#52c41a', '#1677ff', '#1677ff'], + ['#52c41a', '#1677ff', '#faad14', '#52c41a', '#1677ff', '#faad14', '#1677ff', '#1677ff', '#52c41a', '#1677ff', '#1677ff', '#52c41a'], + ['#1677ff', '#faad14', '#52c41a', '#1677ff', '#faad14', '#1677ff', '#1677ff', '#52c41a', '#1677ff', '#1677ff', '#1677ff', '#52c41a'], + ['#faad14', '#52c41a', '#1677ff', '#faad14', '#1677ff', '#1677ff', '#52c41a', '#1677ff', '#1677ff', '#52c41a', '#1677ff', '#faad14'], + ['#52c41a', '#1677ff', '#faad14', '#1677ff', '#1677ff', '#52c41a', '#1677ff', '#1677ff', '#52c41a', '#1677ff', '#faad14', '#52c41a'] +]; + +const OnlineRateData = [ + { type: '在线', value: 12 }, + { type: '离线', value: 1 }, + { type: '告警', value: 2 }, + { type: '总数', value: 13 } +]; + +const RealTimeMonitorPage = () => { + const [loading, setLoading] = useState(false); + const [filterStatus, setFilterStatus] = useState('all'); + const [filterType, setFilterType] = useState(undefined); + const [searchName, setSearchName] = useState(''); + + const filteredList = deviceList.filter(item => { + if (filterStatus === 'all') return true; + if (filterStatus === 'normal') return item.status === '正常'; + if (filterStatus === 'warning') return item.status === '预警'; + if (filterStatus === 'offline') return item.status === '离线'; + return true; + }).filter(item => !filterType || item.type === filterType) + .filter(item => !searchName || item.name.includes(searchName)); + + const getStatusTag = (status) => { + switch (status) { + case '正常': return }>正常; + case '预警': return }>预警; + case '离线': return }>离线; + default: return status; + } + }; + + const columns = [ + { + title: '设备名称', dataIndex: 'name', key: 'name', + render: (name, record) => ( +
+ + {record.type === '摄像头' ? '摄' : record.type === '汇流箱' ? '汇' : record.type === '逆变器' ? '逆' : record.type === '电表' ? '网' : '其'} + + {name} +
+ ) + }, + { title: '类型', dataIndex: 'type' }, + { title: '当前状态', dataIndex: 'status', render: getStatusTag }, + { title: '实时功率/数据', dataIndex: 'data' }, + { title: '通讯状态', dataIndex: 'communication' }, + { title: '更新时间', dataIndex: 'updateTime' } + ]; + + return ( +
+
+
+ 实时监控中心 + 全方位实时掌握电站设备运行状态与发电表现 +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ + +
+ 真实正射底图 · 设备状态联动} + > +
+
+ +

电站拓扑底图

+
+
+
+ + +
+
+ + + + +
+ + setSearchName(e.target.value)} /> +
+
+ + + + + + + + } + valueStyle={{ color: '#1890ff', fontSize: 24, fontWeight: 700 }} + /> + + + + + } + valueStyle={{ color: '#52c41a', fontSize: 20, fontWeight: 700 }} + /> + + + + + } + valueStyle={{ color: '#1890ff', fontSize: 24, fontWeight: 700 }} + /> + + + + + + + + } + valueStyle={{ color: '#52c41a', fontSize: 24, fontWeight: 700 }} + /> + + + + + } + valueStyle={{ color: '#faad14', fontSize: 24, fontWeight: 700 }} + /> + + + + + + + + + + + + + + + + + + + + + {heatmapData.map((row, i) => ( +
+
INV-0{i + 1}
+ {row.map((c, j) =>
)} +
+ ))} + + +
+ + + + + + + + + ); +}; + +export default RealTimeMonitorPage; diff --git a/src/pages/ReportCenter.tsx b/src/pages/ReportCenter.tsx new file mode 100644 index 0000000..fc45678 --- /dev/null +++ b/src/pages/ReportCenter.tsx @@ -0,0 +1,581 @@ +import React, { useState } from 'react'; +import { + Card, Row, Col, Tabs, Button, Space, Select, Table, Statistic, + DatePicker, message, Tag, Empty, + Typography +} from 'antd'; +import { + CloudOutlined, BarChartOutlined, BellOutlined, + CalendarOutlined, LinkOutlined, FileTextOutlined, + DownloadOutlined +} from '@ant-design/icons'; +import { Line, Pie } from '@ant-design/charts'; +import dayjs from 'dayjs'; + +const { TabPane } = Tabs; +const { RangePicker } = DatePicker; +const { Option } = Select; + +// 模拟数据 +const overviewData = { + powerToday: 69302.3, + currentPower: 89343.1, + currentAlarm: 5, + processingOrder: 2, + deviceOnlineRate: 92.3, + generatedReport: 4 +}; + +// 发电报表模拟数据 +const powerTrendData = [ + { date: '2026-04-28', avgPower: 40.33, dailyPower: 4580.6 } +]; +const powerDetailData = [ + { date: '2026-04-28', avgPower: 40.33, dailyPower: 4580.6, totalPower: 182345.7 } +]; + +// 告警报表模拟数据 +const alarmLevelData = [ + { type: 'MAJOR', value: 2 }, + { type: 'INFO', value: 2 }, + { type: 'MINOR', value: 1 } +]; +const alarmStatusData = [ + { type: 'PENDING', value: 3 }, + { type: 'PROCESSING', value: 2 } +]; +const alarmTrendData = [ + { date: '2026-04-28', count: 5 } +]; +const deviceAlarmRankData = [ + { device: 'INV-A02', count: 2 }, + { device: 'CAM-02', count: 2 }, + { device: 'CMB-A01', count: 1 } +]; + +// 工单报表模拟数据 +const orderStatusData = [ + { type: 'DISPATCHED', value: 1 }, + { type: 'PENDING', value: 1 }, + { type: 'PROCESSING', value: 1 } +]; +const orderPriorityData = [ + { type: 'LOW', value: 1 }, + { type: 'MEDIUM', value: 1 }, + { type: 'HIGH', value: 1 } +]; +const orderSourceData = [ + { type: 'ALARM', value: 2 }, + { type: 'MANUAL', value: 1 } +]; +const orderTrendData = [ + { date: '2026-04-28', newOrder: 3, completed: 0 } +]; +const orderEfficiencyData = { + avgProcessHour: 0.00, + completionRate: '0.0%', + newOrderToday: 0 +}; + +// 设备健康模拟数据 +const deviceHealthList = [ + { deviceCode: 'CAM-02', deviceName: '摄像头 CAM-02', type: 'CAMERA', online: 'OFFLINE', run: 'FAULT', temp: 0, power: 0, healthScore: 40, healthStatus: 'OFFLINE' }, + { deviceCode: 'INV-A02', deviceName: '逆变器 INV-A02', type: 'INVERTER', online: 'ONLINE', run: 'WARNING', temp: 82.5, power: 54.2, healthScore: 70, healthStatus: 'WARNING' }, + { deviceCode: 'CMB-A01', deviceName: '汇流箱 CMB-A01', type: 'COMBINER_BOX', online: 'ONLINE', run: 'WARNING', temp: 46.3, power: 0, healthScore: 70, healthStatus: 'WARNING' }, + { deviceCode: 'INV-A01', deviceName: '逆变器 INV-A01', type: 'INVERTER', online: 'ONLINE', run: 'NORMAL', temp: 46, power: 66.8, healthScore: 92, healthStatus: 'HEALTHY' }, + { deviceCode: 'INV-B01', deviceName: '逆变器 INV-B01', type: 'INVERTER', online: 'ONLINE', run: 'NORMAL', temp: 43.8, power: 22410.8, healthScore: 92, healthStatus: 'HEALTHY' }, + { deviceCode: 'CMB-A02', deviceName: '汇流箱 CMB-A02', type: 'COMBINER_BOX', online: 'ONLINE', run: 'NORMAL', temp: 41.1, power: 0, healthScore: 92, healthStatus: 'HEALTHY' }, + { deviceCode: 'MET-01', deviceName: '气象站 MET-01', type: 'WEATHER_STATION', online: 'ONLINE', run: 'NORMAL', temp: 28.4, power: 0, healthScore: 92, healthStatus: 'HEALTHY' }, + { deviceCode: 'METER-01', deviceName: '电表 METER-01', type: 'METER', online: 'ONLINE', run: 'NORMAL', temp: 39.2, power: 66811.3, healthScore: 92, healthStatus: 'HEALTHY' }, + { deviceCode: 'CAM-01', deviceName: '摄像头 CAM-01', type: 'CAMERA', online: 'ONLINE', run: 'NORMAL', temp: 35.2, power: 0, healthScore: 92, healthStatus: 'HEALTHY' }, + { deviceCode: 'CAM-03', deviceName: '摄像头 CAM-03', type: 'CAMERA', online: 'ONLINE', run: 'NORMAL', temp: 33.9, power: 0, healthScore: 92, healthStatus: 'HEALTHY' } +]; + +// 报表文件模拟数据 +const reportFileList = [ + { id: 'RPT-ALARM_STAT-20260429092501', name: '告警统计报表', type: 'ALARM_STAT', format: 'EXCEL', status: 'SUCCESS', time: '2026-04-29T09:25:03+08:00' }, + { id: 'RPT-DEMO-WORKORDER-001', name: '西北荒漠一号光伏电站工单效率统计', type: 'WORK_ORDER_STAT', format: 'EXCEL', status: 'SUCCESS', time: '2026-04-29T09:12:42+08:00' }, + { id: 'RPT-DEMO-ALARM-001', name: '西北荒漠一号光伏电站告警统计', type: 'ALARM_STAT', format: 'EXCEL', status: 'SUCCESS', time: '2026-04-29T09:12:42+08:00' }, + { id: 'RPT-DEMO-POWER-001', name: '西北荒漠一号光伏电站发电日报', type: 'POWER_DAILY', format: 'EXCEL', status: 'SUCCESS', time: '2026-04-29T09:12:42+08:00' } +]; + +export default function ReportCenterPage() { + const [activeTab, setActiveTab] = useState('power'); + const [timeType, setTimeType] = useState('day'); + const [dateRange, setDateRange] = useState([dayjs().subtract(7, 'day'), dayjs()]); + + // 顶部概览卡片 + const OverviewCards = () => ( + < div + style={{ + display: 'flex', + flexWrap: 'wrap', // 自动换行 + gap: '16px', // 卡片间距 + marginBottom: '20px' + } + } + > + {/* 今日发电量 */} + < div + style={{ + flex: '1 1 210px', // 基础宽度 210px,允许扩展 + height: '140px', // 固定高度 + flexShrink: 0 // 不压缩 + }} + > + + } + /> +
遥测与 latest 聚合
+
+ + + {/* 当前功率 */} + < div + style={{ + flex: '1 1 210px', // 基础宽度 210px,允许扩展 + height: '140px', + flexShrink: 0 + }} + > + + } + /> +
实时功率汇总
+
+ + + {/* 当前告警 */} + < div + style={{ + flex: '1 1 210px', // 基础宽度 210px,允许扩展 + height: '140px', + flexShrink: 0 + }} + > + + } + /> +
累计 5 条
+
+ + + {/* 处理中工单 */} + < div + style={{ + flex: '1 1 210px', // 基础宽度 210px,允许扩展 + height: '140px', + flexShrink: 0 + }} + > + + } + /> +
全部 3 单
+
+ + + {/* 设备在线率 */} + < div + style={{ + flex: '1 1 210px', // 基础宽度 210px,允许扩展 + height: '140px', + flexShrink: 0 + }} + > + + } + /> +
来自设备主数据
+
+ + + {/* 已生成报表 */} + < div + style={{ + flex: '1 1 210px', // 基础宽度 210px,允许扩展 + height: '140px', + flexShrink: 0 + }} + > + + } + /> +
SUCCESS 文件记录
+
+ + + ); + + // 发电报表 + const PowerReportTab = () => ( +
+
+ + + + + + + +
+ + + `${v}` }, + }} + /> + + + +
+ + + ); + + // 告警报表 + const AlarmReportTab = () => ( +
+ +
+ + + + + + + + + + + + + + + + + +
+ + + ); + + // 工单报表 + const WorkOrderReportTab = () => ( +
+ +
+ + + + + + + + + + + + + + + + + + + +
+
+ +
平均处理小时
+
+
+ orderEfficiencyData.completionRate} + /> +
完成率
+
+
+ +
今日新增
+
+
+
+ + + +
+ + + + + ); + + // 设备健康报表 + const DeviceHealthTab = () => ( +
+ +
+ + } + /> +
来自 pv_device
+
+ + + + } + /> +
在线状态统计
+
+ + + + } + /> +
运行状态统计
+
+ + + + } + /> +
来自 device_latest
+
+ + + + +
{v} }, + { title: '运行', dataIndex: 'run', render: (v) => {v} }, + { title: '温度', dataIndex: 'temp' }, + { title: '功率', dataIndex: 'power' }, + { title: '健康分', dataIndex: 'healthScore' }, + { title: '健康状态', dataIndex: 'healthStatus', render: (v) => {v} } + ]} + dataSource={deviceHealthList} + pagination={false} + scroll={{ x: 'max-content' }} + /> + + + ); + + // 报表文件 + const ReportFileTab = () => ( +
+
+ + + + +
+ + +
{v} }, + { title: '生成时间', dataIndex: 'time' }, + { title: '操作', render: () => } + ]} + dataSource={reportFileList} + pagination={{ total: 4, pageSize: 10, showSizeChanger: true, showTotal: (total) => `共 ${total} 条` }} + /> + + + ); + + return ( +
+ {/* 页面头部 */} +
+
+ 报表中心 +

发电、告警、工单效率、设备健康与报表文件统一分析

+
+ +
+ + {/* 顶部概览卡片 */} + + + {/* 标签页 */} + + {PowerReportTab()} + {AlarmReportTab()} + {WorkOrderReportTab()} + {DeviceHealthTab()} + {ReportFileTab()} + +
+ ); +} diff --git a/src/pages/SystemSetting.tsx b/src/pages/SystemSetting.tsx index 4ae0ef0..9f35e2c 100644 --- a/src/pages/SystemSetting.tsx +++ b/src/pages/SystemSetting.tsx @@ -17,6 +17,7 @@ import Organization from '../components/SystemSetting/Organization'; import StationManage from '../components/SystemSetting/StationManage'; import { getMenuList } from '../api/mune'; import DeviceAccessPage from '../components/SystemSetting/DeviceAccessPage'; +import OnlineUserPage from '../components/SystemSetting/OnlineUser'; const { Header, Content } = Layout; const { Text } = Typography; @@ -156,6 +157,9 @@ export default function SystemSettings() { if (item.path === '/systemSetting/systemMaintenance') { return { key: 'systemMaintenance', label: '系统维护', icon: }; } + if (item.path === '/systemSetting/monitor') { + return { key: 'monitor', label: '系统监控', icon: }; + } return null; }).filter(Boolean); @@ -193,6 +197,8 @@ export default function SystemSettings() { return ; case 'systemMaintenance': return ; + case 'monitor': + return ; default: return ; } diff --git a/src/pages/WorkOrder.tsx b/src/pages/WorkOrder.tsx new file mode 100644 index 0000000..2155bba --- /dev/null +++ b/src/pages/WorkOrder.tsx @@ -0,0 +1,582 @@ +import React, { useState } from 'react'; +import { + Layout, Card, Row, Col, Button, Table, Tag, Select, Input, Typography, Space, + Statistic, Modal, message, Empty, Drawer, Descriptions, Timeline, Divider, Form +} from 'antd'; +import { + CheckOutlined, ClockCircleOutlined, ControlOutlined, + BarChartOutlined, RiseOutlined, ArrowUpOutlined, + SearchOutlined, PlusOutlined, EditOutlined, DeleteOutlined, + EyeOutlined, CommentOutlined, PauseOutlined, FormOutlined +} from '@ant-design/icons'; +import { Pie, Bar } from '@ant-design/charts'; + +const { Option } = Select; +const { Search } = Input; +const { Text, Title } = Typography; + +// 模拟数据 +const workOrderData = [ + { + id: 'WO-20260428-003', + title: 'A区组件例行巡检', + source: '人工创建', + device: 'INV-A01', + deviceName: '逆变器 INV-A01', + type: '巡检', + priority: 'low', + status: 'dispatched', + handler: '李工程师', + createTime: '2026-04-28 19:55:18', + desc: '结合日常运维计划执行 A 区逆变器和汇流箱巡检。' + }, + { + id: 'WO-20260428-002', + title: 'CAM-02 离线排查', + source: '告警', + device: 'CAM-02', + deviceName: '摄像头 CAM-02', + type: '故障排查', + priority: 'medium', + status: 'pending', + handler: '', + createTime: '2026-04-28 19:55:18', + desc: '' + }, + { + id: 'WO-20260428-001', + title: 'INV-A02 温度过高现场检查', + source: '告警', + device: 'INV-A02', + deviceName: '逆变器 INV-A02', + type: '故障排查', + priority: 'high', + status: 'processing', + handler: '张运维', + createTime: '2026-04-28 19:55:18', + desc: '' + } +]; + +// 工单状态配置 +const statusConfig = { + pending: { label: '待处理', color: '#faad14', icon: }, + dispatched: { label: '已派发', color: '#1890ff', icon: }, + processing: { label: '处理中', color: '#2f54eb', icon: }, + suspended: { label: '挂起', color: '#faad14', icon: }, + completed: { label: '已完成', color: '#52c41a', icon: }, + closed: { label: '已关闭', color: '#8c8c8c', icon: } +}; + +// 优先级配置 +const priorityConfig = { + low: { label: '低', color: '#52c41a' }, + medium: { label: '中', color: '#faad14' }, + high: { label: '高', color: '#ff4d4f' }, + urgent: { label: '紧急', color: '#f5222d' } +}; + +const WorkOrderPage = () => { + const [searchParams, setSearchParams] = useState({ orderNo: '', status: '' }); + const [drawerVisible, setDrawerVisible] = useState(false); + const [currentOrder, setCurrentOrder] = useState(null); + + // 👇 新增:编辑工单弹窗状态 + const [editModalVisible, setEditModalVisible] = useState(false); + const [editingOrder, setEditingOrder] = useState(null); + const [editForm] = Form.useForm(); + + // 打开编辑弹窗 + const openEditModal = (record) => { + setEditingOrder(record); + editForm.setFieldsValue({ + title: record.title, + source: record.source, + type: record.type, + priority: record.priority, + handler: record.handler, + deviceCode: record.device, + deviceName: record.deviceName, + desc: record.desc + }); + setEditModalVisible(true); + }; + + // 提交编辑 + const handleEditSubmit = () => { + editForm.validateFields().then(values => { + console.log('保存工单:', { ...editingOrder, ...values }); + message.success('工单保存成功'); + setEditModalVisible(false); + }); + }; + + // 表格列定义 + const columns = [ + { + title: '工单编号', + dataIndex: 'id', + key: 'id', + width: 140 + }, + { + title: '标题', + dataIndex: 'title', + key: 'title' + }, + { + title: '来源', + dataIndex: 'source', + key: 'source', + width: 100 + }, + { + title: '设备', + dataIndex: 'device', + key: 'device', + width: 100 + }, + { + title: '优先级', + dataIndex: 'priority', + key: 'priority', + width: 80, + render: (priority) => ( + + {priorityConfig[priority]?.label} + + ) + }, + { + title: '状态', + dataIndex: 'status', + key: 'status', + width: 100, + render: (status) => ( + + {statusConfig[status]?.label} + + ) + }, + { + title: '处理人', + dataIndex: 'handler', + key: 'handler', + width: 100, + render: (handler) => handler || '—' + }, + { + title: '创建时间', + dataIndex: 'createTime', + key: 'createTime', + width: 160 + }, + { + title: '操作', + key: 'action', + width: 320, + fixed: 'right', + render: (_, record) => ( + + + + + + + + + + + + ) + } + ]; + + // 饼图数据 + const pieData = [ + { type: '待处理', value: 1, color: '#1890ff' }, + { type: '已派发', value: 1, color: '#52c41a' }, + { type: '处理中', value: 1, color: '#faad14' } + ]; + + // 柱状图数据 + const barData = [ + { priority: '紧急', count: 0 }, + { priority: '高', count: 1 }, + { priority: '中', count: 1 }, + { priority: '低', count: 1 } + ]; + + return ( +
+ {/* 顶部标题和搜索 */} +
+
+ 工单管理 + 告警转工单、派发处理、流转记录与事件联动闭环 +
+ + } + style={{ width: 220 }} + value={searchParams.orderNo} + onChange={(e) => setSearchParams({ ...searchParams, orderNo: e.target.value })} + /> + + + + +
+ + {/* 统计卡片 */} + +
+ + } + valueStyle={{ fontSize: 28, fontWeight: 700 }} + /> + 当前电站 + + + + + } + valueStyle={{ fontSize: 28, fontWeight: 700, color: '#faad14' }} + /> + PENDING + + + + + } + valueStyle={{ fontSize: 28, fontWeight: 700, color: '#1890ff' }} + /> + DISPATCHED + + + + + } + valueStyle={{ fontSize: 28, fontWeight: 700, color: '#2f54eb' }} + /> + PROCESSING + + + + + } + valueStyle={{ fontSize: 28, fontWeight: 700, color: '#faad14' }} + /> + SUSPENDED + + + + + } + valueStyle={{ fontSize: 28, fontWeight: 700, color: '#52c41a' }} + /> + 逾期 0 单 + + + + + {/* 工单列表 */} + +
+
+ 工单列表 + 工单状态变化会写入流转记录和事件中心 +
+ + + + + +
+
+ + + {/* 底部图表区域:降低卡片高度 */} + + + + + + + + + + + + + + + 告警转工单 + 流转记录 + 事件中心 + WebSocket刷新 + +
+ +
+
+ + + + {/* 工单详情抽屉 */} + setDrawerVisible(false)} + open={drawerVisible} + destroyOnClose + > + {currentOrder && ( +
+ 基础信息 + + {currentOrder.id} + {statusConfig[currentOrder.status]?.label} + {currentOrder.title} + + + {priorityConfig[currentOrder.priority]?.label} + + + {currentOrder.source} + {currentOrder.device} + {currentOrder.handler || '—'} + {currentOrder.createTime} + + {currentOrder.desc || '—'} + + + + + 关联告警 + + - + - + - + + + + 流转时间线 + + + 创建 --> 已派发 +
+ 阶段4B演示工单初始化 +
+ system +
+
+
+ + + 评论 +
+ + + 附件元数据 +
+ + )} + + + {/* 👇 编辑工单弹窗 */} + setEditModalVisible(false)} + onOk={handleEditSubmit} + okText="保存" + cancelText="取消" + width={600} + destroyOnClose + > +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; + +export default WorkOrderPage; diff --git a/src/router/index.tsx b/src/router/index.tsx index 1e10770..5b35c55 100644 --- a/src/router/index.tsx +++ b/src/router/index.tsx @@ -4,6 +4,9 @@ import type { RouteObject } from 'react-router-dom'; import VideoMonitorPage from '../pages/VideoMonitorPage'; import AIDiagnosisPage from '../pages/AIAnalysis'; import CleanOptimizationPage from '../pages/CleanOptimization'; +import WorkOrderPage from '../pages/WorkOrder'; +import ReportCenterPage from '../pages/ReportCenter'; +import RealTimeMonitorPage from '../pages/RealTimeMonitor'; const Layout = lazy(() => import('../components/Layout')); const ProtectedRoute = lazy(() => import('../components/ProtectedRoute')); @@ -53,6 +56,7 @@ export const routeMeta: Record }, { path: 'devices', element: }, { path: 'video', element: