路径规划打点完成 点击任务获取 路径轨迹
This commit is contained in:
20
env.js
20
env.js
@@ -9,11 +9,11 @@ const currentEnv = import.meta.env?.MODE || process.env.NODE_ENV;
|
||||
// 环境配置映射
|
||||
const envConfig = {
|
||||
[ENV.DEV]: {
|
||||
//baseURL: 'http://192.168.2.59:8081',//http://192.168.2.56:8081
|
||||
////baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
|
||||
//WS_URL: 'ws://192.168.2.59:9002/ws/',
|
||||
//mqtt_url: "ws://192.168.2.59:8083/mqtt",
|
||||
//geoserver_url: "http://192.168.2.59:7000/geoserver"
|
||||
baseURL: 'http://192.168.2.59:8081',//http://192.168.2.56:8081
|
||||
//baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
|
||||
WS_URL: 'ws://192.168.2.59:9002/ws/',
|
||||
mqtt_url: "ws://192.168.2.59:8083/mqtt",
|
||||
geoserver_url: "http://192.168.2.59:7000/geoserver"
|
||||
|
||||
//baseURL: 'http://1.95.137.212:8081',//http://192.168.2.56:8081
|
||||
////baseURL: 'https://serviceri.satabot.com',
|
||||
@@ -21,11 +21,11 @@ const envConfig = {
|
||||
//mqtt_url: "ws://1.95.137.212:59021/mqtt",
|
||||
//geoserver_url: "http://1.95.137.212:59018/geoserver"
|
||||
|
||||
baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
|
||||
//baseURL: 'https://serviceri.satabot.com',
|
||||
WS_URL: 'ws://1.95.137.212:59017/ws/',
|
||||
mqtt_url: "ws://1.95.137.212:59021/mqtt",
|
||||
geoserver_url: "http://1.95.137.212:59018/geoserver"
|
||||
//baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
|
||||
////baseURL: 'https://serviceri.satabot.com',
|
||||
//WS_URL: 'ws://1.95.137.212:59017/ws/',
|
||||
//mqtt_url: "ws://1.95.137.212:59021/mqtt",
|
||||
//geoserver_url: "http://1.95.137.212:59018/geoserver"
|
||||
},
|
||||
[ENV.PROD]: {
|
||||
//baseURL: 'https://pvcloudservice.satabot.com',
|
||||
|
||||
@@ -408,15 +408,12 @@ export function addRoute(data) {
|
||||
const config = {
|
||||
url: '/iot/workRecord/add', // 修正为正确的添加接口
|
||||
method: 'post',
|
||||
data
|
||||
data,
|
||||
timeout: 60000,
|
||||
|
||||
};
|
||||
|
||||
// 如果是 FormData,不需要设置 Content-Type,axios 会自动设置
|
||||
if (!(data instanceof FormData)) {
|
||||
config.headers = {
|
||||
'Content-Type': 'application/json'
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
return request(config);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,13 @@ api.interceptors.request.use(
|
||||
if (token && config.headers) {
|
||||
config.headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
if (!(config.data instanceof FormData)) {
|
||||
config.headers['Content-Type'] = 'application/json';
|
||||
} else {
|
||||
// FormData 删除json头,交给axios自动生成multipart
|
||||
delete config.headers['Content-Type'];
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(error: AxiosError) => {
|
||||
|
||||
@@ -57,6 +57,7 @@ import dayjs from 'dayjs';
|
||||
import { MowerAllView } from './MowerAllView';
|
||||
import { useMqtt } from '@/hooks/useMqtt';
|
||||
import envConfig from '../../../env';
|
||||
import { dataUrlToFile } from '@/lib/utils.ts';
|
||||
const { RangePicker } = DatePicker;
|
||||
|
||||
const { Text } = Typography;
|
||||
@@ -565,8 +566,8 @@ export default function DeviceStatusPage({
|
||||
return;
|
||||
}
|
||||
const newPoint = {
|
||||
lon: realtimePosition.lon,
|
||||
lat: realtimePosition.lat,
|
||||
lon: Number(realtimePosition.lon),
|
||||
lat: Number(realtimePosition.lat),
|
||||
};
|
||||
setMarkedPoints([...markedPoints, newPoint]);
|
||||
messageApi.success(`已标记第 ${markedPoints.length + 1} 个点`);
|
||||
@@ -619,10 +620,22 @@ export default function DeviceStatusPage({
|
||||
const result = await response.json();
|
||||
|
||||
if (result) {
|
||||
setPoints(result?.data?.points);
|
||||
const path = result?.data?.path?.map(p => {
|
||||
return {
|
||||
lng: p.lon,
|
||||
lat: p.lat
|
||||
}
|
||||
})
|
||||
setPoints(path);
|
||||
setSavePath({
|
||||
path: result?.data?.path, // 存储返回的路径结果
|
||||
outer: requestParams?.outer?.position,
|
||||
path: path, // 存储返回的路径结果
|
||||
outer: requestParams?.outer?.position?.map(p => {
|
||||
return {
|
||||
lng: p.lon,
|
||||
lat: p.lat
|
||||
}
|
||||
}
|
||||
),
|
||||
planModel: 0,
|
||||
});
|
||||
setCompleteFlag(true);
|
||||
@@ -665,18 +678,29 @@ export default function DeviceStatusPage({
|
||||
// 3. 添加文件
|
||||
if (screenshotDataUrl) {
|
||||
// 将 dataUrl 转换为 Blob
|
||||
const response = await fetch(screenshotDataUrl);
|
||||
const blob = await response.blob();
|
||||
formData.append('file', blob, 'screenshot.jpg');
|
||||
const file = dataUrlToFile(screenshotDataUrl, "screenshot.jpg");
|
||||
console.log("blob", file)
|
||||
|
||||
|
||||
if (file instanceof File) {
|
||||
formData.append('file', file);
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 添加 workRecord
|
||||
const workRecord = {
|
||||
workName: plotName,
|
||||
siteId: stationId,
|
||||
jsonData: JSON.stringify(savePath),
|
||||
jsonData: savePath,
|
||||
};
|
||||
formData.append('workRecord', JSON.stringify(workRecord));
|
||||
formData.append(
|
||||
"workRecord",
|
||||
new Blob([JSON.stringify(workRecord)], {
|
||||
type: "application/json"
|
||||
})
|
||||
);
|
||||
|
||||
//formData.append('workRecord', JSON.stringify(workRecord));
|
||||
|
||||
// 5. 调用保存接口
|
||||
const res = await addRoute(formData);
|
||||
|
||||
@@ -1008,11 +1008,11 @@ export default function RobotTaskPage() {
|
||||
<Space size={4} wrap> {/* Space开启自动换行,小屏按钮自动折行 */}
|
||||
<Button size="small" icon={<DeleteOutlined />} type="primary" style={{ borderRadius: 4 }} onClick={() => setClearNavLine(v => v + 1)}>清空实时轨迹</Button>
|
||||
<Button size="small" icon={<DeleteOutlined />} danger style={{ borderRadius: 4 }} onClick={() => { setPoints([]); setClearPlanLine(v => v + 1); }}>清空规划航线</Button>
|
||||
<Button size="small" icon={<PlusOutlined />} style={{ borderRadius: 4 }}>新增</Button>
|
||||
{/*<Button size="small" icon={<PlusOutlined />} style={{ borderRadius: 4 }}>新增</Button>
|
||||
<Button size="small" icon={<ImportOutlined />} style={{ borderRadius: 4 }}>导入</Button>
|
||||
<Button size="small" icon={<NodeIndexOutlined />} style={{ borderRadius: 4 }}>优化</Button>
|
||||
<Button size="small" icon={<SaveOutlined />} style={{ borderRadius: 4 }}>保存</Button>
|
||||
<Button size="small" icon={<Maximize2 size={12} />} />
|
||||
<Button size="small" icon={<SaveOutlined />} style={{ borderRadius: 4 }}>保存</Button>*/}
|
||||
{/*<Button size="small" icon={<Maximize2 size={12} />} />*/}
|
||||
</Space>
|
||||
}
|
||||
bordered={false}
|
||||
@@ -1635,7 +1635,7 @@ export default function RobotTaskPage() {
|
||||
title={`机器人全景视频 - ${executingRobot.deviceAlias || executingRobot.serialNumber}`}
|
||||
onClose={() => setShowVideo(false)}
|
||||
>
|
||||
<div style={{ height: 'clamp(300px, 30vw, 600px)', overflow: 'hidden' }}>
|
||||
<div style={{ height: 'clamp(300px, 30vw, 600px)', }}>
|
||||
<MowerAllView
|
||||
serialNumber={executingRobot.serialNumber}
|
||||
robotVideo={robotVideo}
|
||||
|
||||
@@ -47,7 +47,8 @@ export function useWebRTCPlayer(deviceId: string, url: string) {
|
||||
v.style.height = '100%';
|
||||
v.style.objectFit = 'contain';
|
||||
videoRef.current = v;
|
||||
const token = "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjFkZTA1ZDU2LTM2NTYtNDdmNS05NjI4LWM1NGZhNjRhOWU4OCJ9.Wpa9LO3fQ9DKV8Ct-VildxD4amrtCzTJWjPCGLgHu60P44PxRsArBSlAKhO9vrErmVRaHLe6_5Z_v5kegg07Aw"
|
||||
const token = "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjdjMjUwODExLTEwYjAtNDVlYS05NzM3LWFiYTc4M2ExZGMzZiJ9.A61n89qWXEYnWZv8l8nntt9Abcp4k2s1_sW-mRa16FLTBFjuWiVsqfZJMGMzXpKN-O4geii1SBp2-2esRmGTGQ"
|
||||
|
||||
|
||||
//const token = localStorage.getItem('videotoken') || JSON.parse(localStorage.getItem('userInfo') || '{}')?.token;
|
||||
const videoUrl = `${url}?token=${token}`;
|
||||
|
||||
@@ -215,3 +215,22 @@ export const exportTable = (columns, dataSource, fileName = "导出数据") => {
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* base64 dataUrl 转 File 对象
|
||||
* @param {string} dataUrl base64图片
|
||||
* @param {string} fileName 文件名
|
||||
* @returns {File}
|
||||
*/
|
||||
export function dataUrlToFile(dataUrl, fileName) {
|
||||
const arr = dataUrl.split(',');
|
||||
const mime = arr[0].match(/:(.*?);/)[1];
|
||||
const bstr = atob(arr[1]);
|
||||
let n = bstr.length;
|
||||
const u8arr = new Uint8Array(n);
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n);
|
||||
}
|
||||
return new File([u8arr], fileName, { type: mime });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user