路径规划界面增加视频 封装拖拽组件 和 全景视频组件 设备状态界面增加完成点 机器人任务界面的topcard值的优化
This commit is contained in:
@@ -33,6 +33,7 @@ import {
|
||||
getSiteDeviceTaskHistory,
|
||||
} from '../../api/device';
|
||||
import dayjs from 'dayjs';
|
||||
import DraggableBox from '../Draggable';
|
||||
import utils, { getLocationQuality } from '../../lib/utils';
|
||||
import CesiumMap from '../Map';
|
||||
import { fix2, getVal } from '../../lib/utils';
|
||||
@@ -40,6 +41,9 @@ import { useSelector } from 'react-redux';
|
||||
import { RootState } from '@/src/store';
|
||||
import envConfig from '../../../env';
|
||||
import DeviceController from './DeviceController';
|
||||
import Draggable, { DraggableData, DraggableEvent } from 'react-draggable';
|
||||
import { MowerAllView } from './mowerAllView.jsx';
|
||||
import { useWebRTCPlayer } from '../useWebRTCStream.js';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const { RangePicker } = DatePicker;
|
||||
@@ -54,6 +58,7 @@ export default function RobotTaskPage() {
|
||||
const [taskList, setTaskList] = useState([]);
|
||||
const [arrivedPoint, setArrivedPoint] = useState(null);//完成点
|
||||
|
||||
|
||||
// 设备数据
|
||||
const [devices, setDevices] = useState([]);
|
||||
|
||||
@@ -74,6 +79,7 @@ export default function RobotTaskPage() {
|
||||
|
||||
// 当前执行任务的机器人
|
||||
const [executingRobot, setExecutingRobot] = useState(null);
|
||||
const [showVideo, setShowVideo] = useState(false); // 控制视频组件显示
|
||||
|
||||
// 任务池和历史任务数据
|
||||
const [taskPoolList, setTaskPoolList] = useState([]);
|
||||
@@ -88,7 +94,10 @@ export default function RobotTaskPage() {
|
||||
robot: null,
|
||||
planId: null,
|
||||
});
|
||||
|
||||
const { video: robotVideo, error, ready } = useWebRTCPlayer(
|
||||
executingRobot?.serialNumber ? executingRobot?.serialNumber : '',
|
||||
`webrtc://1.95.137.212/live/livestream/${executingRobot?.serialNumber}`,
|
||||
);
|
||||
const [historyFilterForm, setHistoryFilterForm] = useState({
|
||||
taskStatus: null,
|
||||
robot: null,
|
||||
@@ -96,6 +105,9 @@ export default function RobotTaskPage() {
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const fontSmall = 'clamp(10px, 0.7vw, 11px)';
|
||||
const fontNormal = 'clamp(12px, 0.75vw, 13px)';
|
||||
const fontTitle = 'clamp(14px, 0.85vw, 16px)';
|
||||
@@ -114,6 +126,7 @@ export default function RobotTaskPage() {
|
||||
const controllerRef = useRef<DeviceController | null>(null);
|
||||
const handleFinish = (data) => {
|
||||
setExecute(false);
|
||||
setShowVideo(false); // 任务完成关闭视频
|
||||
utils.message.success('任务已完成');
|
||||
//if (controllerRef.current) {
|
||||
// controllerRef.current.destroy?.();
|
||||
@@ -128,7 +141,6 @@ export default function RobotTaskPage() {
|
||||
|
||||
}
|
||||
const handleFinishEdPoint = (point) => {
|
||||
console.log('到达完成点11111111111', point);
|
||||
setArrivedPoint(point);
|
||||
}
|
||||
|
||||
@@ -139,6 +151,7 @@ export default function RobotTaskPage() {
|
||||
controller.onDeviceInfoUpdate = setRobotRealtimePosition;
|
||||
controller.onIsFinished = handleFinish;
|
||||
controller.handleArrivedPoint = handleFinishEdPoint;
|
||||
|
||||
controller.init();
|
||||
|
||||
|
||||
@@ -377,6 +390,8 @@ export default function RobotTaskPage() {
|
||||
fetchTaskPoolList();
|
||||
fetchTaskHistoryList();
|
||||
controllerRef.current?.connectDevice(selectedRobotForExecute);
|
||||
setShowVideo(true); // 连接成功后自动打开视频
|
||||
|
||||
} else {
|
||||
setExecute(false);
|
||||
|
||||
@@ -804,13 +819,13 @@ export default function RobotTaskPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const groupBoardData = () => {
|
||||
const groupBoardData = useMemo(() => {
|
||||
const waitList = taskList.filter(item => item.taskStaus === 'NEW');
|
||||
const runList = taskList.filter(item => ['EXECUTING', 'PAUSE'].includes(item.taskStaus));
|
||||
const finishList = taskList.filter(item => ['FINISH', 'FAILED'].includes(item.taskStaus));
|
||||
return { waitList, runList, finishList };
|
||||
};
|
||||
const { waitList, runList, finishList } = groupBoardData();
|
||||
}, [taskList]);
|
||||
const { waitList, runList, finishList } = groupBoardData;
|
||||
|
||||
const topCards = [
|
||||
{ title: '今日机器人计划', value: taskList.length, unit: '条', desc: '进行中', icon: <LayoutGrid size={22} />, color: '#165DFF' },
|
||||
@@ -1005,6 +1020,17 @@ export default function RobotTaskPage() {
|
||||
return <span style={{ color: info.color }}>{info.text}</span>;
|
||||
})()}
|
||||
</span>
|
||||
|
||||
{/* 视频开关 */}
|
||||
<span style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
||||
视频:
|
||||
<Switch
|
||||
size="small"
|
||||
checked={showVideo}
|
||||
onChange={setShowVideo}
|
||||
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -1532,6 +1558,23 @@ export default function RobotTaskPage() {
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
{showVideo && executingRobot && (
|
||||
<DraggableBox
|
||||
defaultPosition={{ x: 50, y: 50 }}
|
||||
title={`机器人全景视频 - ${executingRobot.deviceAlias || executingRobot.serialNumber}`}
|
||||
onClose={() => setShowVideo(false)}
|
||||
>
|
||||
<div style={{ height: 'clamp(300px, 30vw, 600px)', overflow: 'hidden' }}>
|
||||
<MowerAllView
|
||||
serialNumber={executingRobot.serialNumber}
|
||||
robotVideo={robotVideo}
|
||||
ready={ready}
|
||||
error={error}
|
||||
/>
|
||||
</div>
|
||||
</DraggableBox>
|
||||
)}
|
||||
</div >
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user