diff --git a/src/api/device.ts b/src/api/device.ts
index 9c314a7..970a83a 100644
--- a/src/api/device.ts
+++ b/src/api/device.ts
@@ -313,4 +313,37 @@ export function pauseRoute(data) {
})
}
+//恢复任务
+
+export function recoverRoute(data) {
+ return request({
+ url: `/iot/deviceTask/recoveryTask`,
+ method: 'post',
+ data
+
+ })
+}
+
+//当前执行和待执行的任务
+
+export function getDeviceTastPool(data) {
+ return request({
+ url: `/iot/deviceTask/deviceTaskPool`,
+ method: 'post',
+ data
+
+ })
+}
+//获取历史任务
+export function getSiteDeviceTaskHistory(data) {
+ return request({
+ url: `/iot/deviceTas/getSiteDeviceTaskHistory`,
+ method: 'post',
+ data
+
+ })
+}
+
+
+
diff --git a/src/components/devices/DeviceOverviewPage.tsx b/src/components/devices/DeviceOverviewPage.tsx
index 2e71ffa..385e1f7 100644
--- a/src/components/devices/DeviceOverviewPage.tsx
+++ b/src/components/devices/DeviceOverviewPage.tsx
@@ -425,7 +425,7 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
name: d.deviceAlias || d.deviceName || d.callsign || '未知设备',
type: d.productName || '未知类型',
status: d.onlineStatus === 1 ? '在线' : '离线',
- mode: d.status === 4 ? '待命' : '作业中',
+ mode: d.feStatus == 1 ? '作业中' : d.feStatus == 2 ? '空闲' : d.mode_code == 0 ? '空闲' : d.mode_code == 1 ? '现场调试' : d.mode_code == 2 ? '远程调试' : d.mode_code == 3 ? '固件升级中' : '作业中',
capacity_percent: d.capacity_percent || 100,
position: d.position || '站内',
task: d.status === 4 ? '待命' : '作业中',
@@ -551,19 +551,23 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
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';
+ title: '模式', dataIndex: 'mode', width: 70, render: (text) => {
+ let color = 'default';
+ if (text === '作业中') color = 'processing';
+ if (text === '空闲') color = 'success';
+ if (text === '空闲中') color = 'success';
+ if (text === '现场调试') color = 'warning';
+ if (text === '远程调试') color = 'warning';
+ if (text === '固件升级中') color = 'error';
return {text};
}
},
{
title: '电量',
- dataIndex: 'lastrunning',
+ dataIndex: 'lastRunningStatus',
width: 70,
- render: (lastrunning) => {
- const v = lastrunning?.battery || 0;
+ render: (lastRunningStatus) => {
+ const v = lastRunningStatus?.battery || 100;
return ;
}
}, { title: '位置', dataIndex: 'position', width: 90 },
- { title: '当前任务', dataIndex: 'task', width: 100 },
- { title: '通讯状态', dataIndex: 'comm', width: 70, render: v => },
+ //{ title: '当前任务', dataIndex: 'task', width: 100 },
+ { title: '通讯状态', dataIndex: 'comm', width: 100, render: v => },
{ title: '操作', key: 'action', width: 80, render: () => } />} /> },
]}
dataSource={dynamicScheduleList}
@@ -822,12 +826,12 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
- 本次作业耗时} value={45} suffix="min" valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }} />
+ 累计作业面积} value={45} suffix="min" valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }} />
- 预计剩余时间} value={12} suffix="min" valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }} />
+ 累计作业时长} value={12} suffix="min" valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }} />
diff --git a/src/components/devices/RobotTaskPage.tsx b/src/components/devices/RobotTaskPage.tsx
index 73503c9..c7d38ff 100644
--- a/src/components/devices/RobotTaskPage.tsx
+++ b/src/components/devices/RobotTaskPage.tsx
@@ -9,7 +9,8 @@ import {
import {
PlusOutlined, ImportOutlined, NodeIndexOutlined,
SaveOutlined, PlayCircleOutlined, EyeOutlined,
- DeleteOutlined
+ DeleteOutlined,
+ CloseOutlined
} from '@ant-design/icons';
import {
Car, Navigation, Wind, Thermometer, Droplets, Satellite,
@@ -22,7 +23,12 @@ import {
getPlaneDeviceListAll, saveDeviceTask, getRobotTaskList,
deleteDeviceTask,
getSiteDevice,
- excuetRoute
+ excuetRoute,
+ cancelRoute,
+ pauseRoute,
+ recoverRoute,
+ getDeviceTastPool,
+ getSiteDeviceTaskHistory,
} from '../../api/device';
import dayjs from 'dayjs';
import utils from '../../lib/utils';
@@ -32,7 +38,6 @@ 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;
@@ -94,6 +99,26 @@ export default function RobotTaskPage() {
// 当前执行任务的机器人
const [executingRobot, setExecutingRobot] = useState(null);
+ // 任务池和历史任务数据
+ const [taskPoolList, setTaskPoolList] = useState([]);
+ const [taskHistoryList, setTaskHistoryList] = useState([]);
+
+ // 当前激活的Tab
+ const [activeTab, setActiveTab] = useState('task'); // 'task' for 任务列表, 'pool' for 任务池, 'history' for 历史任务
+
+ // 任务池和历史任务筛选表单
+ const [poolFilterForm, setPoolFilterForm] = useState({
+ taskStatus: null,
+ robot: null,
+ planId: null,
+ });
+
+ const [historyFilterForm, setHistoryFilterForm] = useState({
+ taskStatus: null,
+ robot: null,
+ dateRange: null,
+ });
+
// 获取数据
const fetchAllData = async () => {
@@ -264,12 +289,134 @@ export default function RobotTaskPage() {
resetFiltersAndRefresh();
};
+ // 获取任务池数据
+ const fetchTaskPoolList = async () => {
+ if (!stationId) return;
+ try {
+ const params = {
+ userId: userInfo?.userId,
+ siteId: stationId,
+ orgId: userInfo?.orgId,
+ };
+ if (poolFilterForm.taskStatus) {
+ params.taskStaus = poolFilterForm.taskStatus;
+ }
+ if (poolFilterForm.robot?.serialNumber) {
+ params.deviceId = poolFilterForm.robot.serialNumber;
+ }
+ if (poolFilterForm.planId) {
+ params.planId = poolFilterForm.planId;
+ }
+
+ const res = await getDeviceTastPool(params);
+ if (res.code === 200) {
+ setTaskPoolList(res.rows || []);
+ }
+ } catch (err) {
+ console.error('获取任务池失败:', err);
+ }
+ };
+
+ // 获取历史任务数据
+ const fetchTaskHistoryList = async () => {
+ if (!stationId) return;
+ try {
+ const params = {
+ userId: userInfo?.userId,
+ siteId: stationId,
+ orgId: userInfo?.orgId,
+ };
+ if (historyFilterForm.taskStatus) {
+ params.taskStaus = historyFilterForm.taskStatus;
+ }
+ if (historyFilterForm.robot?.serialNumber) {
+ params.deviceId = historyFilterForm.robot.serialNumber;
+ }
+ if (historyFilterForm.dateRange && historyFilterForm.dateRange.length === 2) {
+ params.startTime = historyFilterForm.dateRange[0].format('YYYY-MM-DD HH:mm:ss');
+ params.endTime = historyFilterForm.dateRange[1].format('YYYY-MM-DD HH:mm:ss');
+ }
+
+ const res = await getSiteDeviceTaskHistory(params);
+ if (res.code === 200) {
+ setTaskHistoryList(res.data || []);
+ }
+ } catch (err) {
+ console.error('获取历史任务失败:', err);
+ }
+ };
+
+ // 取消任务
+ const handleCancelTask = async (task) => {
+ try {
+ const params = {
+ //id: task.id,
+ deviceId: task.deviceId,
+ //siteId: stationId,
+ };
+ const res = await cancelRoute(params);
+ if (res.code === 200) {
+ utils.message.success('任务已取消');
+ fetchTaskList();
+ fetchTaskPoolList();
+ } else {
+ utils.message.error(res.msg || '取消失败');
+ }
+ } catch (err) {
+ console.error('取消任务失败:', err);
+ utils.message.error('取消任务异常');
+ }
+ };
+
+ // 暂停任务
+ const handlePauseTask = async (task) => {
+ try {
+ const params = {
+ id: task.id,
+ deviceId: task.deviceId,
+ siteId: stationId,
+ };
+ const res = await pauseRoute(params);
+ if (res.code === 200) {
+ utils.message.success('任务已暂停');
+ fetchTaskList();
+ fetchTaskPoolList();
+ } else {
+ utils.message.error(res.msg || '暂停失败');
+ }
+ } catch (err) {
+ console.error('暂停任务失败:', err);
+ utils.message.error('暂停任务异常');
+ }
+ };
+
+ // 恢复任务
+ const handleRecoverTask = async (task) => {
+ try {
+ const params = {
+ id: task.id,
+ deviceId: task.deviceId,
+ siteId: stationId,
+ };
+ const res = await recoverRoute(params);
+ if (res.code === 200) {
+ utils.message.success('任务已恢复');
+ fetchTaskList();
+ fetchTaskPoolList();
+ } else {
+ utils.message.error(res.msg || '恢复失败');
+ }
+ } catch (err) {
+ console.error('恢复任务失败:', err);
+ utils.message.error('恢复任务异常');
+ }
+ };
+
useEffect(() => {
if (stationId) {
fetchRouteList();
- fetchTaskList()
}
}, [stationId]);
@@ -280,6 +427,20 @@ export default function RobotTaskPage() {
}
}, [filterForm, stationId]);
+ // 监听任务池筛选条件变化
+ useEffect(() => {
+ if (stationId) {
+ fetchTaskPoolList();
+ }
+ }, [poolFilterForm, stationId]);
+
+ // 监听历史任务筛选条件变化
+ useEffect(() => {
+ if (stationId) {
+ fetchTaskHistoryList();
+ }
+ }, [historyFilterForm, stationId]);
+
const taskColumns = [
{
title: '任务名称',
@@ -371,7 +532,8 @@ export default function RobotTaskPage() {
width: 100,
fixed: 'right',
render: (_, record) => (
-
+
+
handleDelete(record.id)}
@@ -387,11 +549,124 @@ export default function RobotTaskPage() {
删除
+
)
}
];
+ // 任务池表格列
+ const taskPoolColumns = [
+
+ {
+ title: '设备',
+ dataIndex: 'deviceId',
+ width: 150,
+ },
+ {
+ title: '状态',
+ dataIndex: 'taskStaus',
+ width: 100,
+ render: (status, record) => {
+ const statusMap = {
+ 'NEW': { color: 'default', text: '新建' },
+ 'EXECUTING': { color: 'processing', text: '执行中' },
+ 'PAUSE': { color: 'warning', text: '暂停中' },
+ 'FINISH': { color: 'success', text: '执行成功' },
+ 'FAILED': { color: 'error', text: '执行失败' }
+ };
+ const item = statusMap[status] || { color: 'default', text: '未知' };
+ return {item.text};
+ }
+ },
+ {
+ title: '创建时间',
+ dataIndex: 'createTime',
+ width: 170,
+ },
+ {
+ title: '操作',
+ width: 50,
+ fixed: 'right',
+ render: (_, record) => (
+
+ {record.taskStaus === 'NEW' && (
+ handleCancelTask(record)}
+ okText="确定"
+ cancelText="取消"
+ >
+ } // 这里加了取消图标
+ >取消
+
+ )}
+ {record.taskStaus === 'EXECUTING' && (
+ handlePauseTask(record)}
+ okText="确定"
+ cancelText="取消"
+ >
+
+
+ )}
+ {record.taskStaus === 'PAUSE' && (
+ handleRecoverTask(record)}
+ okText="确定"
+ cancelText="取消"
+ >
+
+
+ )}
+
+ )
+ }
+ ];
+
+ // 历史任务表格列
+ const taskHistoryColumns = [
+ {
+ title: '任务名称',
+ dataIndex: 'planName',
+ width: 160,
+ ellipsis: true,
+ },
+ {
+ title: '设备',
+ dataIndex: 'deviceId',
+ width: 150,
+ },
+ {
+ title: '状态',
+ dataIndex: 'taskStaus',
+ width: 100,
+ render: (status, record) => {
+ const statusMap = {
+ 'FINISH': { color: 'success', text: '执行成功' },
+ 'FAILED': { color: 'error', text: '执行失败' },
+ 'CANCELLED': { color: 'default', text: '已取消' }
+ };
+ const item = statusMap[status] || { color: 'default', text: '未知' };
+ return {item.text};
+ }
+ },
+ {
+ title: '开始时间',
+ dataIndex: 'startTime',
+ width: 170,
+ render: t => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
+ },
+ {
+ title: '结束时间',
+ dataIndex: 'finishTime',
+ width: 170,
+ render: t => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
+ }
+ ];
+
const handleRowClick = (record) => {
if (record.longitude && record.latitude) {
setFocusLocation({
@@ -526,84 +801,218 @@ export default function RobotTaskPage() {
- {/* 机器人任务列表 + 右侧 新建任务加号按钮 */}
+ {/* 机器人任务模块,带Tab切换 */}
- 机器人任务列表
-
- {
- setFilterForm(prev => ({ ...prev, dateRange: dates }));
- }}
- />
-
-
- }
size="small"
bordered={false}
- bodyStyle={{ padding: 0, display: 'flex', flexDirection: 'column', height: "calc(100% - 40px)", overflow: "auto" }}
- style={{ ...cardStyle, maxHeight: "250px", flex: 1, marginBottom: 0 }}
+ bodyStyle={{ padding: 0, display: 'flex', flexDirection: 'column', height: "calc(100%)", overflow: "auto" }}
+ style={{ ...cardStyle, maxHeight: "300px", flex: 1, marginBottom: 0 }}
>
- ({
- onClick: () => handleRowClick(record),
- style: { cursor: 'pointer' }
- })}
+ style={{ padding: '0 12px' }}
+ items={[
+ {
+ key: 'task',
+ label: '任务列表',
+ },
+ {
+ key: 'pool',
+ label: '任务池',
+ },
+ {
+ key: 'history',
+ label: '历史任务',
+ }
+ ]}
+ tabBarExtraContent={
+
+ setIsTaskModalOpen(true)}
+ />
+
+ }
/>
+
+
+ {/* 任务列表Tab */}
+ {activeTab === 'task' && (
+ <>
+
+ {
+ setFilterForm(prev => ({ ...prev, dateRange: dates }));
+ }}
+ />
+ {
+ setFilterForm(prev => ({ ...prev, taskStatus: val }));
+ }}
+ />
+ ({
+ value: item.serialNumber,
+ label: item.deviceAlias || item.deviceName
+ }))}
+ value={filterForm.robot?.serialNumber}
+ onChange={(val) => {
+ if (!val) {
+ setFilterForm(prev => ({ ...prev, robot: null }));
+ return;
+ }
+ const robot = devices.find(i => i.serialNumber === val);
+ setFilterForm(prev => ({ ...prev, robot: robot }));
+ }}
+ />
+
+
({
+ onClick: () => handleRowClick(record),
+ style: { cursor: 'pointer' }
+ })}
+ />
+ >
+ )}
+
+ {/* 任务池Tab */}
+ {activeTab === 'pool' && (
+ <>
+
+ {
+ setPoolFilterForm(prev => ({ ...prev, taskStatus: val }));
+ }}
+ />
+ ({
+ value: item.serialNumber,
+ label: item.deviceAlias || item.deviceName
+ }))}
+ value={poolFilterForm.robot?.serialNumber}
+ onChange={(val) => {
+ if (!val) {
+ setPoolFilterForm(prev => ({ ...prev, robot: null }));
+ return;
+ }
+ const robot = devices.find(i => i.serialNumber === val);
+ setPoolFilterForm(prev => ({ ...prev, robot: robot }));
+ }}
+ />
+
+
+ >
+ )}
+
+ {/* 历史任务Tab */}
+ {activeTab === 'history' && (
+ <>
+
+ {
+ setHistoryFilterForm(prev => ({ ...prev, dateRange: dates }));
+ }}
+ showTime
+ />
+ {
+ setHistoryFilterForm(prev => ({ ...prev, taskStatus: val }));
+ }}
+ />
+ ({
+ value: item.serialNumber,
+ label: item.deviceAlias || item.deviceName
+ }))}
+ value={historyFilterForm.robot?.serialNumber}
+ onChange={(val) => {
+ if (!val) {
+ setHistoryFilterForm(prev => ({ ...prev, robot: null }));
+ return;
+ }
+ const robot = devices.find(i => i.serialNumber === val);
+ setHistoryFilterForm(prev => ({ ...prev, robot: robot }));
+ }}
+ />
+
+
+ >
+ )}
+