Explorar el Código

feat: 朴津地图上传&提醒

HeWang hace 8 meses
padre
commit
3e88e0d379
Se han modificado 3 ficheros con 189 adiciones y 25 borrados
  1. 14 1
      electron/main.js
  2. 148 21
      src/views/ReportView.vue
  3. 27 3
      src/views/UpdateStatView.vue

+ 14 - 1
electron/main.js

@@ -445,6 +445,7 @@ ipcMain.handle('process-map-update-files', async (event, {equipmentNo, timeStamp
     timeStamp = Date.now()
     // 记录时间戳
     console.log("timeStamp", timeStamp);
+    const dataDir = "/home/cicv/work/pji_desktop/map_update/data";
     const mapBufDir = "/home/cicv/work/pji_desktop/map_update/data/bag_folder/mapBuf";
     const resultDir = "/home/cicv/work/pji_desktop/map_update/data/bag_folder/result";
     const updateMapDir = "/home/cicv/work/pji_desktop/map_update/data/bag_folder/update_map";
@@ -481,6 +482,9 @@ ipcMain.handle('process-map-update-files', async (event, {equipmentNo, timeStamp
     // 文件路径 - 更新后png
     const updatePngPath = path.join(mapBufDir, "map_update.png");
     console.log("updatePngPath", updatePngPath);
+    // 文件路径 - 更新地图压缩包
+    const updateMapPath = path.join(dataDir, "update.zip");
+    console.log("updateMapPath", updateMapPath);
 
     try {
         // 读取json文件
@@ -527,12 +531,21 @@ ipcMain.handle('process-map-update-files', async (event, {equipmentNo, timeStamp
         let updatePngUrl = res.data.details
         console.log("updatePngUrl", updatePngUrl);
 
+        // 上传 更新地图压缩包
+        res = await uploadMapResult(updateMapPath, uploadUrl);
+        if (!res.success) {
+            return { success: false, message: "Error uploading map results", data: [] }
+        }
+        let updateMapUrl = res.data.details
+        console.log("updateMapUrl", updateMapUrl);
+
         result = {
             "jsonData": parsedData,
             "prePgmUrl": prePgmUrl,
             "prePngUrl": prePngUrl,
             "updatePgmUrl": updatePgmUrl,
-            "updatePngUrl": updatePngUrl
+            "updatePngUrl": updatePngUrl,
+            "updateMapUrl": updateMapUrl,
         }
 
         return { success: true, message: "Evaluation results uploaded successfully", data: result }

+ 148 - 21
src/views/ReportView.vue

@@ -39,7 +39,7 @@
           </el-form>
           <el-button type="primary" @click="updateMap">地图更新</el-button>
           <el-button type="primary" @click="goToUpdateStat">地图更新统计</el-button>
-          <el-button type="primary" @click="mapDialogVisible = true">地图续扫提醒阈值</el-button>
+          <el-button type="primary" @click="getThreshold">地图续扫提醒阈值</el-button>
           <el-button type="primary" @click="goToMapRescan">地图续扫提醒</el-button>
 <!--          <el-button type="primary" @click="goToMapUpdate">地图更新</el-button>-->
 
@@ -57,7 +57,7 @@
             </el-steps>
 
             <template #footer>
-              <el-button @click="goToMapUpdate" :disabled="update_active !== 2">上传地图</el-button>
+              <el-button @click="goToUpdateStat" :disabled="update_active !== 2">上传地图</el-button>
             </template>
           </el-dialog>
 
@@ -70,16 +70,19 @@
           >
             <el-form :model="mapRescanForm">
               <el-form-item label="请输入地图续扫提醒阈值" label-width="170">
-                <el-input v-model="mapRescanForm.name">
-                  <template #suffix>
-                    <i slot="suffix" style="color: #181818">%</i>
-                  </template>
-                </el-input>
+<!--                <el-input v-model="mapRescanForm.value">-->
+<!--                  <template #suffix>-->
+<!--                    <i slot="suffix" style="color: #181818">%</i>-->
+<!--                  </template>-->
+<!--                </el-input>-->
+
+                <el-input-number style="width: 90%; margin-right: 5px; float: left" v-model="mapRescanForm.value" :controls="false" :precision="2" />
+                <span>%</span>
               </el-form-item>
             </el-form>
             <template #footer>
               <div class="dialog-footer">
-                <el-button type="primary" @click="mapDialogVisible = false">
+                <el-button type="primary" @click="setThreshold">
                   确认
                 </el-button>
               </div>
@@ -266,6 +269,40 @@ const goToUpdateStat = () => {
   router.push('/update_stat')
 }
 
+const setThreshold = async () =>{
+  try {
+    const response =  await axios.get('/local/config/update/rescanReminderThreshold?threshold=' + mapRescanForm.value)
+    // console.log(response.data)
+
+    if (!response.data.status) {
+      ElMessage.error("更新地图续扫阈值失败")
+      return
+    }
+    mapDialogVisible.value = false
+  } catch (error) {
+    ElMessage.error("更新地图续扫阈值失败")
+    console.log("Error updating the threshold:", error)
+  }
+}
+
+const getThreshold = async () => {
+  try {
+    const response =  await axios.get('/local/config/query/rescanReminderThreshold')
+    // console.log(response.data)
+
+    if (!response.data.status) {
+      ElMessage.error("获取地图续扫阈值失败")
+      return
+    }
+    mapRescanForm.value = +response.data.data
+    mapDialogVisible.value = true
+  } catch (error) {
+    ElMessage.error("获取地图续扫阈值失败")
+    console.log("Error querying the threshold:", error)
+  }
+}
+
+
 const goToDetail = () => {
   router.push({
     name: 'about',
@@ -289,10 +326,6 @@ const goToTestRecord = () => {
   router.push('/test_record')
 }
 
-const goToPgmViewer = () => {
-  router.push('/pgm_viewer')
-}
-
 const handleClose = (done: () => void) => {
   done()
 }
@@ -396,8 +429,9 @@ const algorithmForm = reactive({
   // resource: '',
   // desc: '',
 })
+
 const mapRescanForm = reactive({
-  name: ''
+  value: 0
 })
 
 const algorithmImport = async () => {
@@ -455,23 +489,35 @@ const updateMap = async () => {
     ElMessage.error("请选择记录!")
     return
   }
+
   // 检查记录是否属于同一机器人
   const isEquipmentSame = isPropertySame(multipleSelection.value, "equipmentId")
   if (!isEquipmentSame) { // 属于多个设备
     ElMessage.error("所选择的记录属于多个设备,请进行检查!")
     return
   }
+
   // 检查记录的mapBuf是否一致
   let ids = multipleSelection.value.map(item => item["id"])
   console.log("ids:",ids)
-  const status = checkMapbufConsistency(ids)
-  if(!status) { // mapBuf不一致
+  let response = await checkMapbufConsistency(ids)
+  console.log("response", response)
+  if(!response.status) {
     ElMessage.error("所选择的记录mapBuf不一致,请重新选择!")
     return
   }
 
+  // 更新设备地图记录
+  response = await updateDeviceMap()
+  console.log("response", response)
+  if(!response.status) {
+    ElMessage.error("数据更新失败,请重试!")
+    return
+  }
+
   // 准备数据
   const currentRow = multipleSelection.value[0]
+  const id = currentRow.id
   const device_id = currentRow.equipmentId
   const device_no = currentRow.equipmentNo
   const device_name = currentRow.equipmentName
@@ -480,6 +526,17 @@ const updateMap = async () => {
   const updateFlag = 0
 
   console.log(device_id, device_no, device_name, device_type, device_no, updateTime, updateFlag)
+  // 检查地图状态(是否可以更新)
+  response = await checkDeviceMapStatus(id, removePerfix(device_no, "pjibot-"), device_name, device_type)
+
+  if (!response.status) {
+    if (response.code === "1001") {
+      ElMessage.error(response.msg)
+    } else {
+      ElMessage.error("地图状态查询失败")
+    }
+    return
+  }
 
   // 开启对话框
   updateDialogVisible.value = true
@@ -490,7 +547,7 @@ const updateMap = async () => {
 
   // 根据id下载地图更新需要的数据(压缩包)
   const idList = ids.reduce((acc, id) => {return acc + "+" + id}, "")
-  const url = "http://localhost:8888/map/download/zip?id=" + ids.flat() // 此处url不受配置的代理规则影响,应传递后端完整url地址
+  const url = "http://localhost:8888/map/download/zip?id=" + ids.flat() + "&deviceNo=" + removePerfix(device_no, "pjibot-")  // 此处url不受配置的代理规则影响,应传递后端完整url地址
 
   const fileName = "data" + idList + ".zip"
   const savePath = "/home/cicv/work/pji_desktop/tmp_download/map_zip/"
@@ -552,8 +609,9 @@ const updateMap = async () => {
             "update_rate": data["jsonData"]["update_perecent"],
             "cumulative_update_rate": data["jsonData"]["origin_update_perecent"],
             "update_time": String(updateTime),
-            "from_scene_list": "1, 2",
-            "update_flag": updateFlag
+            "from_scene_list": JSON.stringify(ids.flat()),
+            "update_flag": updateFlag,
+            "update_map_url": data["updateMapUrl"]
           }
           console.log("map_update_data", map_update_data)
           // 上传数据
@@ -572,16 +630,44 @@ const updateMap = async () => {
   }
 }
 
+const removePerfix = (str, prefix) => {
+  const regex = new RegExp("^" + prefix)
+  return str.replace(regex, "")
+}
+
 const checkMapbufConsistency = async (ids) => {
  try {
    const response =  await axios.post('/local/map/check/mapbuf/consistency', ids)
    console.log(response.data)
-   return response.data.status
+   return response.data
  } catch (error) {
    console.log("Error checking the mapBufs' onsistency:", error)
  }
 }
 
+const updateDeviceMap = async () => {
+  try {
+    const response =  await axios.get('/local/map/update/deviceMap/record')
+    console.log(response.data)
+
+    return response.data
+  } catch (error) {
+    console.log("Error updating the device-map:", error)
+  }
+}
+
+const checkDeviceMapStatus = async (sceneId, deviceNo, deviceName, deviceType) => {
+  try {
+    const response =  await axios.get('/local/map/check/deviceMap/status?sceneId=' + sceneId + '&deviceNo='
+        + deviceNo + '&deviceType=' + deviceType + '&deviceName=' + deviceName)
+    console.log(response.data)
+
+    return response.data
+  } catch (error) {
+    console.log("Error checking the device map's onsistency:", error)
+  }
+}
+
 const handleSelectionChange = (rows: []) => {
   multipleSelection.value = rows
   // 检查记录是否属于同一机器人
@@ -715,7 +801,7 @@ const startSimulation = async (row) => {
     // // 延时
     // setTimeout(() => {}, 500)
     // 开启loading
-    loadingInstance = ElLoading.service({fullscreen: false, target: '.el-dialog', text: "仿真环境启动中..."})
+    loadingInstance = ElLoading.service({fullscreen: false, target: '.el-dialog', text: "仿真环境启动中..."})
     // 执行脚本 - 数据准备,启动容器
     window.electronAPI.startContainer(result.filePath, imageName, containerName);
     // 监听脚本执行状态
@@ -772,9 +858,50 @@ function page() {
       }
   ).then(function (response) {
     tableData.value = response.data.data.content
+    // tableData.value[0] = {
+    //   "id": "1839185047089844228",
+    //   "createTime": "2024-09-26 14:07:40",
+    //   "modifyTime": null,
+    //   "createUserId": "1797180505775411201",
+    //   "modifyUserId": null,
+    //   "createUserName": null,
+    //   "modifyUserName": null,
+    //   "equipmentNo": "pjibot-P1YTYD1M233M00224",
+    //   "taskId": null,
+    //   "equipmentId": "1797860189492219905",
+    //   "triggerId": "1797180767860690945",
+    //   "dataName": "2024-09-26-13-56-44",
+    //   "dataSize": "149215583",
+    //   "dataState": "COMPLETED",
+    //   "dataStateName": "已完成111",
+    //   "triggerName": "无法避障",
+    //   "equipmentType": "YI_DAO_JI_QI_REN",
+    //   "equipmentTypeName": "引导服务机器人",
+    //   "equipmentName": "合肥测试",
+    //   "triggerType": "RULE_RECOGNITION",
+    //   "triggerTypeName": "规则识别",
+    //   "dataFileId": "pjibot/pjibot-P1YNYD1M228000127/data_parse/2024-09-26-13-56-44_obstacledetection_30/",
+    //   "rosFileId": "pjibot/pjibot-P1YNYD1M228000127/data_merge/2024-09-26-13-56-44_obstacledetection_30.bag",
+    //   "callbackTime": "2024-09-26 14:07:40",
+    //   "handleStartTime": "2024-09-26 14:07:40",
+    //   "handleEndTime": "2024-09-26 14:07:40",
+    //   "relationId": null,
+    //   "badCase": "NO_LABEL",
+    //   "badCaseName": "",
+    //   "labels": null,
+    //   "labelNames": null,
+    //   "sceneLabels": null,
+    //   "sceneLabelNames": null,
+    //   "badCaseCreateTime": null,
+    //   "badCaseCreateUserId": null,
+    //   "badCaseCreateUserName": null,
+    //   "sceneCaseCreateUserName": null,
+    //   "sceneCaseCreateUserId": null,
+    //   "sceneCaseCreateTime": null
+    // }
     total.value = response.data.data.totalElements
     // total.value = tableData.value.length
-    // console.log(tableData);
+    console.log(tableData.value);
     // console.log(response.data.data);
   }).catch(function (error) {
     console.log(error);

+ 27 - 3
src/views/UpdateStatView.vue

@@ -83,7 +83,7 @@
 
           <el-table-column width="200" fixed="right" label="操作">
             <template v-slot="scope">
-              <el-button size="small" type="danger" @click="generateWorld(scope.row)" :disabled="scope.row.update_flag!= 0">上传地图</el-button>
+              <el-button :id="'button'+scope.row.id" size="small" type="danger" @click="uploadMap(scope.row)" :disabled="scope.row.update_flag!= 0">上传地图</el-button>
             </template>
 
           </el-table-column>
@@ -112,8 +112,9 @@
 <script lang="ts" setup>
 import {onBeforeMount, reactive, ref} from "vue";
 import axios from "axios";
-import {ElMessage, ElTable} from "element-plus";
+import {ElLoading, ElMessage, ElTable} from "element-plus";
 import moment from "moment/moment";
+import {fa} from "element-plus/es/locale";
 
 
 const multipleTableRef = ref<InstanceType<typeof ElTable>>
@@ -133,6 +134,29 @@ const onSubmit = () => {
   page()
 }
 
+const uploadMap = async (row) => {
+  let id = row.id
+  console.log("id", id)
+  try {
+    // 开启loading
+    let loadingInstance = ElLoading.service({fullscreen: false, target:'.el-table', text: '地图上传中...'})
+    const response = await axios.get('/local/map/update/pji/upload?id=' + id)
+    console.log(response.data)
+    if (!response.data.status) {
+      loadingInstance.close()
+      if (response.data.code === "1002") {
+        ElMessage.error(response.data.message)
+      }
+      return
+    }
+    loadingInstance.close()
+    ElMessage.success(response.data.message)
+    await page()
+  } catch (error) {
+    console.log("Error uploading the pji map:", error)
+  }
+}
+
 // 根据条件筛选结果
 const queryRecordByCondition = async () => {
   let response = await axios.post('/local/map/query/update/record?page=' + currentPage.value + '&pageSize=' + pageSize.value, {
@@ -195,7 +219,7 @@ async function page() {
   //   console.log(error);
   // });
 
-  // 查询算法评价记录
+  // 查询地图更新记录
   let response = await axios.post('/local/map/query/update/record?page=' + currentPage.value + '&pageSize=' + pageSize.value)
 
   if (!response.data.status){ // 不存在