diff --git a/src/api/api.ts b/src/api/api.ts index 7975b9f..fc66694 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -1,342 +1,331 @@ import api from './request'; -export function getDeviceListApi(data){ - return api({ - url: `/iot/device/userDevice?tenantName=${data.tenantName}&deptId=${data.deptId}`, - method: 'get', - }); -} + export function getUserList(params) { - return api({ - url: '/system/user/list', - method: 'get', - params - }) + return api({ + url: '/system/user/list', + method: 'get', + params + }) } - - // 作业列表 + +// 作业列表 export function getWorkList(data) { - return api({ - url: `/iot/workRecord/selectByUserId?userId=${data.userId}`, - method: 'get', - }) + return api({ + url: `/iot/workRecord/selectByUserId?userId=${data.userId}`, + method: 'get', + }) } // /iot/deviceTask/save 新建路线 -export function saveDeviceTask(data) { - return api({ - url: `/iot/deviceTask/save`, - method: 'post', - data - }) +export function saveDeviceTask(data) { + return api({ + url: `/iot/deviceTask/save`, + method: 'post', + data + }) } // 获取任务列表 -export function getDeviceTask(data) { - return api({ - url: `/iot/deviceTask/getDevicePlan`, - method: 'post', - data - }) +export function getDeviceTask(data) { + return api({ + url: `/iot/deviceTask/getDevicePlan`, + method: 'post', + data + }) } // 获取任务分布/iot/deviceTask/devicePlanStatistics -export function getTaskDistribution(params) { - return api({ - url: `/iot/deviceTask/devicePlanStatistics`, - method: 'get', - params - }) +export function getTaskDistribution(params) { + return api({ + url: `/iot/deviceTask/devicePlanStatistics`, + method: 'get', + params + }) } //选择某一个数据https://serviceri.satabot.com/iot/workRecord/selectByWorkName?workName=${workName}&_t=${Date.now()} -export function getSingleWork(data) { - return api({ - url: `/iot/workRecord/selectByWorkName?workName=${data.workName}`, - method: 'get', - }) +export function getSingleWork(data) { + return api({ + url: `/iot/workRecord/selectByWorkName?workName=${data.workName}`, + method: 'get', + }) } // 执行结果/iot/deviceTask/devicePlanTaskStatistics -export function getDevicePlanTaskStatistics(params) { - return api({ - url: `/iot/deviceTask/devicePlanTaskStatistics`, - method: 'get', - params - }) +export function getDevicePlanTaskStatistics(params) { + return api({ + url: `/iot/deviceTask/devicePlanTaskStatistics`, + method: 'get', + params + }) } // 获取当前的设备运行路线/iot/deviceTask/concurrentDeviceRoute -export function getConcurrentDeviceRoute (params) { - return api({ - url: `/iot/deviceTask/concurrentDeviceRoute`, - method: 'get', - params - }) +export function getConcurrentDeviceRoute(params) { + return api({ + url: `/iot/deviceTask/concurrentDeviceRoute`, + method: 'get', + params + }) } // 获取作业数据/iot/deviceTask/workStatistics -export function getWorkStatistics(params) { - return api({ - url: `/iot/deviceTask/workStatistics`, - method: 'get', - params - }) +export function getWorkStatistics(params) { + return api({ + url: `/iot/deviceTask/workStatistics`, + method: 'get', + params + }) } // 判断是否能控制 export function getControlRight(params) { - const dataStr = localStorage.getItem('userInfo'); - let parse = JSON.parse(dataStr); - var token=parse?.token; - return api({ - url: `/websocket/judgeConnection`, - method: 'get', - headers: { - Authorization: token // token 正常带上 - }, - params - }) + const dataStr = localStorage.getItem('userInfo'); + let parse = JSON.parse(dataStr); + var token = parse?.token; + return api({ + url: `/websocket/judgeConnection`, + method: 'get', + headers: { + Authorization: token // token 正常带上 + }, + params + }) } // 登录 export function loginApi(data) { - return api({ - url: '/login', - method: 'post', - data - }) + return api({ + url: '/login', + method: 'post', + data + }) } // 可视化面板获取无人机信息 -export function getPlaneDeviceList() { - return api({ - url: '/iot/UAV/getProjectDeviceList', - method: 'get', - }) -} // 获取所有航线 export function getsinglePlan(data) { - return api({ - url: `/iot/UAV/getFlightTask?sn=${data.gateway_sn}`, - method: 'get', - }) + return api({ + url: `/iot/UAV/getFlightTask?sn=${data.gateway_sn}`, + method: 'get', + }) } // 获取航线轨迹 iot/UAV/getFlightTaskTrack export function getsinglePlanTrack(data) { - return api({ - url: `/iot/UAV/getFlightTaskTrack?taskId=${data.uuid}`, - method: 'get', - }) + return api({ + url: `/iot/UAV/getFlightTaskTrack?taskId=${data.uuid}`, + method: 'get', + }) } //上传航线 export function uploadWayLine(data) { - return api({ - url: '/iot/UAV/uploadWayline', - method: 'post', - data: data, // 上传文件必须用 data,不能用 params - headers: { - 'Content-Type': 'multipart/form-data' // 上传文件必加! - } - }) + return api({ + url: '/iot/UAV/uploadWayline', + method: 'post', + data: data, // 上传文件必须用 data,不能用 params + headers: { + 'Content-Type': 'multipart/form-data' // 上传文件必加! + } + }) } //创建航线任务 export function createWaylineTask(data) { - return api({ - url: '/iot/UAV/createFlightTask', - method: 'post', - data: data, - }) + return api({ + url: '/iot/UAV/createFlightTask', + method: 'post', + data: data, + }) } export function updateFlightTaskStatus(taskId, status) { - return api({ - url: '/iot/UAV/updateFlightTaskStatus', - method: 'post', - params: { taskId, status } - }) + return api({ + url: '/iot/UAV/updateFlightTaskStatus', + method: 'post', + params: { taskId, status } + }) } export function getFlightTaskDetail(taskId) { - return api({ - url: '/iot/UAV/getFlightTaskDetail', - method: 'get', - params: { taskId } - }) + return api({ + url: '/iot/UAV/getFlightTaskDetail', + method: 'get', + params: { taskId } + }) } /// 航线列表 export function getWayLine() { - return api({ - url: '/iot/UAV/getWayline', - method: 'get', - }) + return api({ + url: '/iot/UAV/getWayline', + method: 'get', + }) } //直播流 export function getLiveStream(data) { - return api({ - url: '/iot/UAV/liveStream', - method: 'post', - data - }) + return api({ + url: '/iot/UAV/liveStream', + method: 'post', + data + }) } ///iot/UAV/flightTaskCommand export function postFlightCommmand(data) { - return api({ - url: '/iot/UAV/flightTaskCommand', - method: 'post', - data - }) + return api({ + url: '/iot/UAV/flightTaskCommand', + method: 'post', + data + }) } //切换相机 export function changeCamera(data) { - return api({ - url: '/iot/UAV/changeCamera', - method: 'post', - data - }) + return api({ + url: '/iot/UAV/changeCamera', + method: 'post', + data + }) } //直播心跳 export function postLiveHeartbeat(data) { - return api({ - url: `/iot/UAV/liveHeartbeat?sn=${data.sn}&cameraIndex=${data.cameraIndex}`, - method: 'post', - }) + return api({ + url: `/iot/UAV/liveHeartbeat?sn=${data.sn}&cameraIndex=${data.cameraIndex}`, + method: 'post', + }) } //热成像分析 export function getThermalDefault() { - return api({ - url: `/api/thermal/defaults`, - method: 'get', - }) + return api({ + url: `/api/thermal/defaults`, + method: 'get', + }) } //点击分析 export function getThermalAnalyzelt(data) { - return api({ - url: `/api/thermal/analyze`, - method: 'post', - data - }) + return api({ + url: `/api/thermal/analyze`, + method: 'post', + data + }) } //像素点信息/api/thermal/probe export function getThermalProbe(data) { - return api({ - url: `/api/thermal/probe`, - method: 'post', - data - }) + return api({ + url: `/api/thermal/probe`, + method: 'post', + data + }) } //获取报告 export function getThermalReport(data) { - return api({ - url: `/api/thermal/downloadReport`, - method: 'get', - data - }) + return api({ + url: `/api/thermal/downloadReport`, + method: 'get', + data + }) } //下载报告 export function downloadReport(data) { - return api({ - url: `/api/thermal/report`, - method: 'get', - params: data, - }) + return api({ + url: `/api/thermal/report`, + method: 'get', + params: data, + }) } //获取 用户设备任务列表 export function getUserWorkRecord(params) { - return api({ - url: `/iot/workRecord/selectByUserId`, - method: 'get', - params - }) + return api({ + url: `/iot/workRecord/selectByUserId`, + method: 'get', + params + }) } //获取 任务数据 export function getWorkData(params) { - return api({ - url: `/iot/workRecord/selectByWorkName`, - method: 'get', - params - }) + return api({ + url: `/iot/workRecord/selectByWorkName`, + method: 'get', + params + }) } export function getAlimage(params) { - return api({ - url: `/api/thermal/image`, - method: 'get', - params, - //responseType: "blob", // 必须加这个 - }) + return api({ + url: `/api/thermal/image`, + method: 'get', + params, + //responseType: "blob", // 必须加这个 + }) } // 远程遥控 判断是否有权限/forward/device/remoteControl platform:web export function getJurisdiction(data) { - return api({ - url: '/forward/device/remoteControl', - method: 'post', - data - }) + return api({ + url: '/forward/device/remoteControl', + method: 'post', + data + }) } //下载割草任务记录 // export function downloadOperationReport() { - return api({ - url: '/iot/device/generateOperationReport', - method: 'get', - responseType: 'arraybuffer' // 👈 只需要加这一行! - }) + return api({ + url: '/iot/device/generateOperationReport', + method: 'get', + responseType: 'arraybuffer' // 👈 只需要加这一行! + }) } // export function getDeviceIntradayData(params) { - return api({ - url: '/iot/device/getDeviceIntradayData', - method: 'get', + return api({ + url: '/iot/device/getDeviceIntradayData', + method: 'get', params - }) + }) } //释放控制权限/forward/device/releaseControl export function releaseControl(data) { - return api({ - url: '/forward/device/releaseControl', - method: 'post', - data - }) + return api({ + url: '/forward/device/releaseControl', + method: 'post', + data + }) } diff --git a/src/api/device.ts b/src/api/device.ts new file mode 100644 index 0000000..781d316 --- /dev/null +++ b/src/api/device.ts @@ -0,0 +1,17 @@ + +import request from './request'; + +export function getDeviceListApi(data) { + return request({ + url: `/iot/device/userDevice?tenantName=${data.tenantName}&deptId=${data.deptId}`, + method: 'get', + }); +} + +export function getPlaneDeviceList() { + return request({ + url: '/iot/UAV/getProjectDeviceList', + method: 'get', + }) +} + diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index 31b8e1b..8a21e60 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -181,7 +181,7 @@ export default function AppLayout() { /> - + diff --git a/src/components/devices/DeviceOverviewPage.tsx b/src/components/devices/DeviceOverviewPage.tsx new file mode 100644 index 0000000..d0eff8d --- /dev/null +++ b/src/components/devices/DeviceOverviewPage.tsx @@ -0,0 +1,290 @@ +import React, { useState, useEffect } from 'react'; +import { + Layout, Card, Row, Col, Statistic, Tag, Button, Table, + Typography, Space, Progress, Badge, Timeline, message, + Select +} from 'antd'; +import { + EnvironmentOutlined, RobotOutlined, BranchesOutlined, + ThunderboltOutlined, CheckCircleOutlined, PauseOutlined, + RocketOutlined, SyncOutlined, WarningOutlined, + CloudOutlined, ClockCircleOutlined, ReloadOutlined, + AimOutlined, ApiOutlined, SettingOutlined, + PlusOutlined, ArrowRightOutlined, + EditOutlined +} from '@ant-design/icons'; + +import { useSelector } from 'react-redux'; +import { getDeviceListApi, getPlaneDeviceList } from '../../api/device.ts'; +import { RootState } from '@/src/store'; + +const { Content } = Layout; +const { Text, Title } = Typography; + +// 模拟数据 +const topCards = [ + { title: '无人机机场状态', icon: , value: '2 / 2', desc: '在线', sub: '可调度 2 架', color: '#1890ff' }, + { title: '巡检机器人', icon: , value: '3 台', desc: '', sub: '执行中 2', color: '#722ed1' }, + { title: '除草机器人', icon: , value: '2 台', desc: '', sub: '作业中 1', color: '#13c2c2' }, + { title: '清洗无人机', icon: , value: '2 架', desc: '', sub: '待命 1', color: '#eb2f96' }, + { title: '设备平均电量', icon: , value: '86%', desc: '', sub: '', color: '#52c41a' }, + { title: '今日任务执行', icon: , value: '12 / 15', desc: '', sub: '完成率 80%', color: '#2f54eb' }, +]; + +const scheduleList = [ + { id: 1, name: '无人机机场 A01', type: '无人机机场', status: '在线', mode: '待命', battery: 100, position: '开压站旁', task: '待命', comm: '良好' }, + { id: 2, name: '巡检机器人 RBT-01', type: '巡检机器人', status: '作业中', mode: '自主巡检', battery: 68, position: '区块 B-03', task: '巡检航线 P-02', comm: '良好' }, + { id: 3, name: '巡检机器人 RBT-02', type: '巡检机器人', status: '在线', mode: '待命', battery: 92, position: '区块 D-06', task: '待命', comm: '良好' }, + { id: 4, name: '除草机器人 GR-01', type: '除草机器人', status: '充电中', mode: '回充', battery: 35, position: '充电桩 1', task: '回充中', comm: '良好' }, + { id: 5, name: '清洗无人机 UAV-C01', type: '清洗无人机', status: '作业中', mode: '自主清洗', battery: 72, position: '清洗区 C-05', task: '清洗航线 C-05', comm: '良好' }, + { id: 6, name: '清洗无人机 UAV-C02', type: '清洗无人机', status: '待命', mode: '待命', battery: 96, position: '无人机机场 A01', task: '待命', comm: '良好' }, +]; + +const taskTimeline = [ + { time: '10:24:18', color: 'blue', text: 'UAV-C01 开始执行清洗航线 C-05', status: '任务开始' }, + { time: '10:21:35', color: 'orange', text: 'RBT-01 开始执行巡检航线 P-02', status: '任务开始' }, + { time: '10:18:02', color: 'green', text: 'GR-02 开始除草作业 G-01', status: '任务开始' }, + { time: '10:15:47', color: 'gray', text: 'UAV-C02 任务待命就绪', status: '待命就绪' }, + { time: '10:12:33', color: 'blue', text: 'UAV-C01 再次返机补水', status: '返机补给' }, + { time: '09:58:10', color: 'green', text: 'RBT-02 完成巡检航线 P-01', status: '任务完成' }, +]; + +const logs = [ + { time: '10:24:35', device: 'UAV-C01', type: '命令', desc: '起飞指令下发,开始作业' }, + { time: '10:21:40', device: 'RBT-01', type: '命令', desc: '开始巡检任务 P-02' }, + { time: '10:20:11', device: 'UAV-C02', type: '命令', desc: '转入待命状态' }, + { time: '10:18:05', device: 'GR-02', type: '命令', desc: '除草作业开始 G-01' }, + { time: '10:12:35', device: 'UAV-C01', type: '告警', desc: '返航补水' }, + { time: '10:05:22', device: 'RBT-01', type: '事件', desc: '电量较低,建议回充', level: '低电量' }, +]; + +// 设备总览组件 +export default function DeviceOverviewPage({ devices, planedevices, devicesAll }) { + console.log(devicesAll) + const [activeTab, setActiveTab] = useState('drone'); + const [selectedDevice, setSelectedDevice] = useState(''); + + + + const controlTabs = [ + { key: 'airport', label: '无人机机场' }, + { key: 'robot', label: '巡检机器人' }, + { key: 'mower', label: '除草机器人' }, + { key: 'clean', label: '清洗无人机' }, + { key: 'machine', label: '机械设备' }, + ]; + + const handleStart = () => message.success('任务已启动'); + const handlePause = () => message.info('任务已暂停'); + const handleReturn = () => message.info('返航指令已下发'); + const handleRecharge = () => message.info('回充指令已下发'); + const handleEmergencyStop = () => message.error('已触发急停!'); + useEffect(() => { + if (devicesAll.length > 0) { + setSelectedDevice(devicesAll[0].device_sn); + } + }, [devicesAll]) + + return ( + +
+ {topCards.map((card, idx) => ( +
+ +
+
+ {card.icon} +
+
+
{card.title}
+
{card.value}
+ {card.sub &&
{card.sub}
} +
+
+
+
+ ))} +
+ + + + {/* 装备协同态势图 */} + 装备协同态势图} extra={