From 24d69db0ec1ae9a715dee1105ba4f133b1b5bf51 Mon Sep 17 00:00:00 2001
From: mmc <1556375442@qq.com>
Date: Wed, 3 Jun 2026 11:06:44 +0800
Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E9=9D=A2=E6=9D=BF=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E4=BC=98=E5=8C=96=20=E5=88=9B=E5=BB=BA=E5=B9=B6?=
=?UTF-8?q?=E6=89=A7=E8=A1=8C=E6=88=90=E5=8A=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/device.ts | 4 ++
src/components/devices/DeviceOverviewPage.tsx | 54 +++++++++++++++----
src/components/devices/DeviceStatusPage.tsx | 2 +-
src/components/devices/RobotTaskPage.tsx | 33 +++++++-----
src/pages/Devices.tsx | 4 +-
5 files changed, 73 insertions(+), 24 deletions(-)
diff --git a/src/api/device.ts b/src/api/device.ts
index 1d5b7d2..9c314a7 100644
--- a/src/api/device.ts
+++ b/src/api/device.ts
@@ -8,6 +8,7 @@ export function getDeviceListApi(data) {
});
}
+
export function getPlaneDeviceList(params) {
return request({
url: '/iot/UAV/getUAVList',
@@ -16,6 +17,9 @@ export function getPlaneDeviceList(params) {
})
}
+//modeStatistics{"0":"空闲中","1":"现场调试","2":"远程调试","3":"固件升级中","4":"作业中"}
+
+
export function getSiteUAVList(siteId) {
return request({
url: '/iot/UAV/getSiteUAVList',
diff --git a/src/components/devices/DeviceOverviewPage.tsx b/src/components/devices/DeviceOverviewPage.tsx
index ce9a7fc..2e71ffa 100644
--- a/src/components/devices/DeviceOverviewPage.tsx
+++ b/src/components/devices/DeviceOverviewPage.tsx
@@ -70,9 +70,10 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
if (!stationId) return;
try {
+ console.log('开始请求设备数据,stationId:', userInfo);
// 1. 同时发请求
const [deviceRes, planeRes] = await Promise.all([
- getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1 }),
+ getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1, orgId: userInfo.orgId }),
getSiteUAVList(stationId),
]);
@@ -343,14 +344,19 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
);
// 顶部统计卡片
+
+ //feStatus; 1任务中 / 2空闲
const dynamicTopCards = useMemo(() => {
const totalDrones = planedevices?.length || 0;
const onlineDrones = planedevices?.filter(d => d.onlineStatus === 1).length || 0;
const totalRobots = devicesAll?.filter(d => d.productName?.includes('巡检')).length || 0;
- const activeRobots = devicesAll?.filter(d => d.productName?.includes('巡检') && d.onlineStatus === 1).length || 0;
+
+ //key 0 有任务 1 无任务
+ const activeRobots = 0;
const totalMowers = devicesAll?.filter(d => d.productName?.includes('割草机')).length || 0;
- const activeMowers = devicesAll?.filter(d => d.productName?.includes('割草机') && d.onlineStatus === 1).length || 0;
- const washDroneStandby = planedevices?.filter(d => d.productName?.includes('清洗') && d.onlineStatus === 1).length || 0;
+ const activeMowers = devices?.filter(d => d.feStatus == 1).length || 0; // 作业中状态数量
+ const washDroneStandby = planedevices?.[0]?.modeStatistics?.["0"] || 0;
+ //key 设备状态:{"0":"空闲中","1":"现场调试","2":"远程调试","3":"固件升级中","4":"作业中"}
@@ -380,7 +386,7 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
title: '除草机器人',
icon: ,
value: `${totalMowers} 台`,
- sub: `作业中 ${activeMowers}`,
+ sub: `任务中 ${activeMowers}`,
color: '#722ED1',
iconBg: '#F9F0FF'
},
@@ -414,6 +420,7 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
// 设备调度列表
const dynamicScheduleList = useMemo(() => {
return devicesAll?.map((d, index) => ({
+ ...d,
id: d.deviceId || index,
name: d.deviceAlias || d.deviceName || d.callsign || '未知设备',
type: d.productName || '未知类型',
@@ -422,7 +429,8 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
capacity_percent: d.capacity_percent || 100,
position: d.position || '站内',
task: d.status === 4 ? '待命' : '作业中',
- comm: d.rssi ? `${d.rssi}dBm` : '良好'
+ comm: d.rssi ? `${d.rssi}dBm` : '良好',
+
})) || [];
}, [devicesAll]);
@@ -533,10 +541,36 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
columns={[
{ title: '装备名称', dataIndex: 'name', width: 140 },
{ title: '类型', dataIndex: 'type', width: 90 },
- { title: '当前状态', dataIndex: 'status', width: 70, render: s => {s} },
- { title: '模式', dataIndex: 'mode', width: 70 },
- { title: '电量', dataIndex: 'capacity_percent', width: 70, render: v => },
- { title: '位置', dataIndex: 'position', width: 90 },
+ {
+ title: '当前状态',
+ dataIndex: 'onlineStatus',
+ width: 70,
+ render: (s) => {
+ const text = s === 1 ? '在线' : '离线';
+ const color = s === 1 ? 'success' : 'default';
+ return {text};
+ }
+ }, {
+ title: '模式', dataIndex: 'feStatus', width: 70, render: (feStatus) => {
+ console.log('feStatus:', feStatus);
+ const text = feStatus == 1 ? '任务中' : feStatus == 2 ? '空闲' : '离线';
+ const color = feStatus === 1 ? 'processing' : feStatus === 2 ? 'success' : 'default';
+ return {text};
+ }
+ },
+ {
+ title: '电量',
+ dataIndex: 'lastrunning',
+ width: 70,
+ render: (lastrunning) => {
+ const v = lastrunning?.battery || 0;
+ return ;
+ }
+ }, { title: '位置', dataIndex: 'position', width: 90 },
{ title: '当前任务', dataIndex: 'task', width: 100 },
{ title: '通讯状态', dataIndex: 'comm', width: 70, render: v => },
{ title: '操作', key: 'action', width: 80, render: () => } />} /> },
diff --git a/src/components/devices/DeviceStatusPage.tsx b/src/components/devices/DeviceStatusPage.tsx
index f7f21b4..dc97503 100644
--- a/src/components/devices/DeviceStatusPage.tsx
+++ b/src/components/devices/DeviceStatusPage.tsx
@@ -77,7 +77,7 @@ export default function DeviceStatusPage({
try {
// 1. 同时发请求
const [deviceRes, planeRes] = await Promise.all([
- getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1 }),
+ getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1, orgId: userInfo.orgId }),
getSiteUAVList(stationId),
]);
diff --git a/src/components/devices/RobotTaskPage.tsx b/src/components/devices/RobotTaskPage.tsx
index 9d83a55..73503c9 100644
--- a/src/components/devices/RobotTaskPage.tsx
+++ b/src/components/devices/RobotTaskPage.tsx
@@ -32,6 +32,7 @@ import { useSelector } from 'react-redux';
import { RootState } from '@/src/store';
import envConfig from '../../../env';
import DeviceController from './DeviceController';
+import { getSiteByOrgId } from '@/src/api/stationManage';
const { Text, Title } = Typography;
const { RangePicker } = DatePicker;
@@ -39,6 +40,7 @@ const { RangePicker } = DatePicker;
export default function RobotTaskPage() {
const { userInfo } = useSelector((state: RootState) => state.user);
const { stationId } = useSelector((state: RootState) => state.station);
+ const [excuteStatus, setExcuteStatus] = useState("stop"); //"stop" "running" "pause"
const fontSmall = 'clamp(10px, 0.7vw, 11px)';
const fontNormal = 'clamp(12px, 0.75vw, 13px)';
@@ -62,10 +64,11 @@ export default function RobotTaskPage() {
const controller = new DeviceController(userInfo, messageApi);
controllerRef.current = controller;
return () => {
- controllerRef.current?.destroy();
+ if (controllerRef.current) {
+ controllerRef.current.destroy?.();
+ }
controllerRef.current = null;
-
- }
+ };
}, [])
@@ -97,7 +100,7 @@ export default function RobotTaskPage() {
if (!stationId) return;
try {
- const deviceRes = await getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1 });
+ const deviceRes = await getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1, orgId: userInfo.orgId });
const devData = deviceRes?.code === 200 ? (deviceRes.rows || []) : [];
setDevices(devData);
} catch (err) {
@@ -144,7 +147,6 @@ export default function RobotTaskPage() {
}
};
useEffect(() => {
- console.log('selectedPathWork changed:', selectedPathWork);
try {
// 1. 没有数据直接清空
@@ -154,7 +156,7 @@ export default function RobotTaskPage() {
}
// 2. 安全解析 JSON
- const data = JSON.parse(selectedPathWork?.jsonData);
+ const data = selectedPathWork?.jsonData;
const path = data?.path || [];
// 3. 空路径提示
@@ -208,7 +210,7 @@ export default function RobotTaskPage() {
let hasPathPoints = false;
try {
if (route.jsonData) {
- const data = JSON.parse(route.jsonData);
+ const data = route.jsonData;
hasPathPoints = data.path && data.path.length > 0;
}
} catch (err) {
@@ -236,7 +238,8 @@ export default function RobotTaskPage() {
const params = {
deviceId: selectedRobotForExecute.serialNumber,
routeId: selectedRouteForExecute.id,
- siteId: stationId
+ siteId: stationId,
+ ...(userInfo?.orgId ? { orgId: userInfo.orgId } : {}),
};
console.log('执行任务参数:', params);
@@ -246,8 +249,8 @@ export default function RobotTaskPage() {
utils.message.success('任务执行成功');
setExecuteModalVisible(false);
setExecutingRobot(selectedRobotForExecute);
- fetchTaskList(); // 刷新任务列表
- controllerRef.current?.connect(selectedRobotForExecute);
+ //fetchTaskList(); // 刷新任务列表
+ controllerRef.current?.connectDevice(selectedRobotForExecute);
} else {
utils.message.error(res.msg || '任务执行失败');
}
@@ -414,8 +417,14 @@ export default function RobotTaskPage() {
{ title: '累计作业里程', value: '12.5', unit: 'km', trend: '较昨日 +1.2', trendColor: '#00B42A', icon: , color: '#722ED1' },
{ title: '任务完成率', value: taskList.length ? Math.round((finishList.length / taskList.length) * 100) : 0, unit: '%', trend: '较昨日 +5%', trendColor: '#00B42A', icon: , color: '#00B42A' },
{ title: '异常告警', value: '2', unit: '次', trend: '较昨日 -1', trendColor: '#00B42A', icon: , color: '#F53F3F' },
- { title: '在线率', value: '98', unit: '%', desc: '良好', icon: , color: '#165DFF' },
- ];
+ {
+ title: '在线率',
+ value: `${devices?.length ? Math.round((devices.filter(d => d.onlineStatus == 1).length / devices.length) * 100) : 0}`,
+ unit: '%',
+ desc: '良好',
+ icon: ,
+ color: '#165DFF'
+ }];
return (
diff --git a/src/pages/Devices.tsx b/src/pages/Devices.tsx
index b4002eb..e2ceb7d 100644
--- a/src/pages/Devices.tsx
+++ b/src/pages/Devices.tsx
@@ -20,6 +20,8 @@ export default function DeviceIndexPage() {
const [devices, setDevices] = useState([]);
const [planedevices, setPlaneDevices] = useState([]);
const [devicesAll, setDevicesAll] = useState([]);
+ const { userInfo } = useSelector((state: RootState) => state.user);
+
const tabs = [
{ key: 'overview', label: '装备总览', icon:
},
@@ -34,7 +36,7 @@ export default function DeviceIndexPage() {
try {
const [deviceRes, planeRes] = await Promise.all([
- getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1 }),
+ getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1, orgId: userInfo.orgId }),
getSiteUAVList(stationId),
]);