ab点
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
||||
Select,
|
||||
message,
|
||||
Modal,
|
||||
Switch,
|
||||
} from 'antd';
|
||||
|
||||
import {
|
||||
@@ -74,6 +75,17 @@ export default function DeviceStatusPage({
|
||||
const [planedevices, setPlaneDevices] = useState([]);
|
||||
const [devicesAll, setDevicesAll] = useState([]);
|
||||
const [arrivedPoint, setArrivedPoint] = useState(null);//完成点
|
||||
const [isLoopMode, setIsLoopMode] = useState(true);
|
||||
|
||||
// 开关切换回调
|
||||
const handleChange = (checked: boolean) => {
|
||||
setIsLoopMode(checked);
|
||||
if (checked) {
|
||||
console.log('当前作业方式:回字');
|
||||
} else {
|
||||
console.log('当前作业方式:单点');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 获取数据
|
||||
@@ -582,69 +594,89 @@ export default function DeviceStatusPage({
|
||||
|
||||
// 完成功能 - 调用路径规划接口
|
||||
const handleComplete = async () => {
|
||||
if (markedPoints.length < 3) {
|
||||
messageApi.warning('请至少标记 3 个点');
|
||||
return;
|
||||
}
|
||||
//如果时弓子模式
|
||||
if (isLoopMode) {
|
||||
if (markedPoints.length < 3) {
|
||||
messageApi.warning('请至少标记 3 个点');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 准备路径规划请求参数
|
||||
const positionPoints = [...markedPoints];
|
||||
try {
|
||||
// 准备路径规划请求参数
|
||||
const positionPoints = [...markedPoints];
|
||||
|
||||
|
||||
const requestParams = {
|
||||
reference: {
|
||||
lat: positionPoints[0].lat,
|
||||
lon: positionPoints[0].lon,
|
||||
},
|
||||
heading: 0,
|
||||
outer: {
|
||||
position: positionPoints.map(point => ({
|
||||
lat: point.lat,
|
||||
lon: point.lon,
|
||||
})),
|
||||
sideWidth: 0.0,
|
||||
},
|
||||
holes: [],
|
||||
workType: 0,
|
||||
};
|
||||
const requestParams = {
|
||||
reference: {
|
||||
lat: positionPoints[0].lat,
|
||||
lon: positionPoints[0].lon,
|
||||
},
|
||||
heading: 0,
|
||||
outer: {
|
||||
position: positionPoints.map(point => ({
|
||||
lat: point.lat,
|
||||
lon: point.lon,
|
||||
})),
|
||||
sideWidth: 0.0,
|
||||
},
|
||||
holes: [],
|
||||
workType: 0,
|
||||
};
|
||||
|
||||
const response = await fetch('https://servicepathplan.satabot.com/api/path', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestParams),
|
||||
});
|
||||
const response = await fetch('https://servicepathplan.satabot.com/api/path', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestParams),
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
const result = await response.json();
|
||||
|
||||
if (result) {
|
||||
const path = result?.data?.path?.map(p => {
|
||||
return {
|
||||
lng: p.lon,
|
||||
lat: p.lat
|
||||
}
|
||||
})
|
||||
setPoints(path);
|
||||
setSavePath({
|
||||
path: path, // 存储返回的路径结果
|
||||
outer: requestParams?.outer?.position?.map(p => {
|
||||
if (result) {
|
||||
const path = result?.data?.path?.map(p => {
|
||||
return {
|
||||
lng: p.lon,
|
||||
lat: p.lat
|
||||
}
|
||||
}
|
||||
),
|
||||
planModel: 0,
|
||||
});
|
||||
setCompleteFlag(true);
|
||||
messageApi.success('路径规划完成');
|
||||
})
|
||||
setPoints(path);
|
||||
setSavePath({
|
||||
path: path, // 存储返回的路径结果
|
||||
outer: requestParams?.outer?.position?.map(p => {
|
||||
return {
|
||||
lng: p.lon,
|
||||
lat: p.lat
|
||||
}
|
||||
}
|
||||
),
|
||||
planModel: 0,
|
||||
});
|
||||
setCompleteFlag(true);
|
||||
messageApi.success('路径规划完成');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('路径规划失败:', error);
|
||||
messageApi.error('路径规划失败,请重试');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('路径规划失败:', error);
|
||||
messageApi.error('路径规划失败,请重试');
|
||||
} else {
|
||||
const positionPoints = [...markedPoints].map(item => {
|
||||
return {
|
||||
lng: item.lon,
|
||||
lat: item.lat
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
setPoints(positionPoints);
|
||||
setSavePath({
|
||||
path: positionPoints, // 存储返回的路径结果
|
||||
outer: [],
|
||||
planModel: 2,
|
||||
});
|
||||
setCompleteFlag(true);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// 打开保存模态框
|
||||
@@ -761,6 +793,15 @@ export default function DeviceStatusPage({
|
||||
<Text type="secondary">已标记 {markedPoints.length} 个点</Text>
|
||||
</div>
|
||||
<Space size="middle">
|
||||
<Space>
|
||||
<span>作业方式</span>
|
||||
<Switch
|
||||
size="small"
|
||||
checked={isLoopMode}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
<span>{isLoopMode ? '弓字' : 'AB点'}</span>
|
||||
</Space>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={handleMarkPoint}
|
||||
@@ -778,7 +819,7 @@ export default function DeviceStatusPage({
|
||||
type="primary"
|
||||
ghost
|
||||
onClick={handleComplete}
|
||||
disabled={markedPoints.length < 3}
|
||||
disabled={markedPoints.length < 2}
|
||||
>
|
||||
完成
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user