|
@@ -42,7 +42,6 @@
|
|
|
<el-button type="primary" @click="mapDialogVisible = true">地图续扫提醒阈值</el-button>
|
|
|
<el-button type="primary" @click="goToMapRescan">地图续扫提醒</el-button>
|
|
|
|
|
|
-
|
|
|
<el-dialog
|
|
|
v-model="updateDialogVisible"
|
|
|
title="地图更新"
|
|
@@ -51,7 +50,7 @@
|
|
|
:close-on-click-modal="false"
|
|
|
>
|
|
|
<el-steps style="max-width: 600px" :active="update_active" finish-status="success">
|
|
|
- <el-step title="数据格式检查"/>
|
|
|
+ <el-step title="数据拉取"/>
|
|
|
<el-step title="地图生成"/>
|
|
|
</el-steps>
|
|
|
|
|
@@ -221,7 +220,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import {onBeforeMount, ref} from "vue";
|
|
|
+import {onBeforeMount, ref, nextTick} from "vue";
|
|
|
import axios from "axios";
|
|
|
import {reactive} from 'vue'
|
|
|
import {ElTable, ElLoading, ElMessage} from "element-plus";
|
|
@@ -283,7 +282,7 @@ const beforeUpload = (file) => {
|
|
|
//上传文件失败
|
|
|
const errorMessage = (response) => {
|
|
|
return ElMessage({
|
|
|
- message: "文件上传失败,请联系管理员",
|
|
|
+ message: "文件上传失败",
|
|
|
type: "error",
|
|
|
offset: 60
|
|
|
})
|
|
@@ -374,28 +373,69 @@ const isPropertySame= (array, propertyName) => {
|
|
|
return true; // 所有值都是相同的
|
|
|
}
|
|
|
|
|
|
-const updateMap = () => {
|
|
|
+const updateMap = async () => {
|
|
|
+ // 检查选择的记录数量
|
|
|
if (multipleSelection.value.length == 0) {
|
|
|
- ElMessage.error("请选择记录!");
|
|
|
- return;
|
|
|
+ ElMessage.error("请选择记录!")
|
|
|
+ return
|
|
|
}
|
|
|
+ // 检查记录是否属于同一机器人
|
|
|
const isEquipmentSame = isPropertySame(multipleSelection.value, "equipmentId")
|
|
|
- if (!isEquipmentSame) {
|
|
|
- ElMessage.error("所选择的记录属于多个设备,请进行检查!");
|
|
|
- return;
|
|
|
- } else {
|
|
|
- updateDialogVisible.value = true;
|
|
|
- console.log(JSON.stringify(multipleSelection.value))
|
|
|
+ if (!isEquipmentSame) { // 属于多个设备
|
|
|
+ ElMessage.error("所选择的记录属于多个设备,请进行检查!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 检查记录的mapBuf是否一致
|
|
|
+ const ids = multipleSelection.value.map(item => item["id"])
|
|
|
+ console.log("ids:",ids)
|
|
|
+ const status = checkMapbufConsistency(ids)
|
|
|
+ if(!status) { // mapBuf不一致
|
|
|
+ ElMessage.error("所选择的记录mapBuf不一致,请重新选择!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 开启对话框
|
|
|
+ updateDialogVisible.value = true
|
|
|
+ await nextTick()
|
|
|
+
|
|
|
+ // 根据id下载地图更新需要的数据(压缩包)
|
|
|
+ const id = ids[0]
|
|
|
+ const url = "http://127.0.0.1:8888/map/downloadmapzipfile?id=" + id
|
|
|
+ const fileName = "data-" + id + ".zip"
|
|
|
+ const savePath = "/home/cicv/work/pji_desktop/tmp_download/map_zip"
|
|
|
+
|
|
|
+ // 开启loading
|
|
|
+ const loadingInstance = ElLoading.service({fullscreen: false, target: '.el-dialog'})
|
|
|
+ const result = await window.electronAPI.downloadFile(url, fileName, savePath);
|
|
|
+ if (!result.success) { // 下载失败
|
|
|
+ console.error('File download failed:', result.error);
|
|
|
+ ElMessage.error("地图更新数据拉取失败!");
|
|
|
+ } else { // 下载成功
|
|
|
+ console.log('File downloaded successfully:', result.filePath);
|
|
|
+ // 关闭loading
|
|
|
+ loadingInstance.close()
|
|
|
+ // 更新步骤条状态
|
|
|
+ update_active.value = 1
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const checkMapbufConsistency = async (ids) => {
|
|
|
+ try {
|
|
|
+ const response = await axios.post('http://127.0.0.1:8888/map/checkmapbufconsistency', ids)
|
|
|
+ console.log(response.data)
|
|
|
+ return response.data.status
|
|
|
+ } catch (error) {
|
|
|
+ console.log("Error checking the mapBufs' onsistency:", error)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const handleSelectionChange = (rows: []) => {
|
|
|
multipleSelection.value = rows
|
|
|
+ // 检查记录是否属于同一机器人
|
|
|
const isEquipmentSame = isPropertySame(rows, "equipmentId")
|
|
|
if (!isEquipmentSame) {
|
|
|
ElMessage.error("所选择的记录属于多个设备,请进行检查!");
|
|
|
} else {
|
|
|
- console.log(JSON.stringify(multipleSelection.value))
|
|
|
+ // console.log(JSON.stringify(multipleSelection.value))
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -433,50 +473,54 @@ const rviz = () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
const generateWorld = async (row) => {
|
|
|
const id = row.id
|
|
|
const equipmentNo = row.equipmentNo
|
|
|
const sceneNo = "scene-" + id
|
|
|
- console.log("id", id);
|
|
|
+ const url = "http://127.0.0.1:8888/map/downloadmapbagfile?id=" + id
|
|
|
+ const fileName = "map-" + id + ".bag"
|
|
|
+ const savePath = "/home/cicv/work/pji_desktop/tmp_download/map_bag"
|
|
|
+ console.log("id", id)
|
|
|
|
|
|
+ // 拼接world文件上传url
|
|
|
uploadUrl.value = "http://127.0.0.1:8888/world/uploadworldfile?equipmentNo=" + equipmentNo + "&sceneNo=" + sceneNo
|
|
|
console.log("uploadUrl.value=" + uploadUrl.value)
|
|
|
|
|
|
console.log("Starting download: map.bag...")
|
|
|
+ // 开启对话框
|
|
|
worldDialogVisible.value = true
|
|
|
|
|
|
- const url = "http://127.0.0.1:8888/map/downloadmapbagfile?id=" + id
|
|
|
- const fileName = "map-" + id + ".bag"
|
|
|
- const savePath = "/home/cicv/work/pji_desktop/tmp_download/map_bag"
|
|
|
-
|
|
|
+ // 下载map.bag
|
|
|
const result = await window.electronAPI.downloadFile(url, fileName, savePath);
|
|
|
- if (!result.success) {
|
|
|
+ if (!result.success) { // 下载失败
|
|
|
console.error('File download failed:', result.error);
|
|
|
ElMessage.error("地图bag数据拉取失败!");
|
|
|
- } else {
|
|
|
+ } else { // 下载成功
|
|
|
console.log('File downloaded successfully:', result.filePath);
|
|
|
+ // 更新步骤条状态
|
|
|
world_active.value = 1
|
|
|
console.log("Starting world generation...")
|
|
|
+ // 执行脚本
|
|
|
window.electronAPI.generateWorld(result.filePath);
|
|
|
+ // 开启loading
|
|
|
const loadingInstance = ElLoading.service({fullscreen: false, target: '.el-dialog'})
|
|
|
-
|
|
|
+ // 监听脚本执行状态
|
|
|
window.electronAPI.onGenerateWorldResult( (event, result) => {
|
|
|
- loadingInstance.close()
|
|
|
- if (result.success) {
|
|
|
+ if (result.success) { // 脚本执行成功
|
|
|
console.log('Script execution completed successfully.')
|
|
|
+ // 关闭loading
|
|
|
+ loadingInstance.close()
|
|
|
// 使用 Electron 进行文件删除操作
|
|
|
window.electronAPI.deleteFile(fileName, savePath)
|
|
|
-
|
|
|
// 监听删除文件的响应
|
|
|
window.electronAPI.onDeleteFileResponse((event, response) => {
|
|
|
- if (response.success) {
|
|
|
+ if (response.success) { // 删除成功
|
|
|
console.log("File deleted successfully.")
|
|
|
- } else {
|
|
|
+ } else { // 删除失败
|
|
|
console.log(`Error: ${response.message}`)
|
|
|
}
|
|
|
})
|
|
|
- } else {
|
|
|
+ } else { // 脚本执行过程中发生错误
|
|
|
console.error('Script execution failed.');
|
|
|
ElMessage.error("world生成发生错误!");
|
|
|
}
|
|
@@ -484,7 +528,6 @@ const generateWorld = async (row) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
const queryLine = reactive({
|
|
|
dataName: '',
|
|
|
equipmentName: '',
|