From 7d9fb50b4e444ba3afec098ad031e93b4e9ee9ee Mon Sep 17 00:00:00 2001
From: GuLiMmo <2820890765@qq.com>
Date: Wed, 29 Nov 2023 10:20:26 +0800
Subject: [PATCH] 航线库修改/api打包后可修改

---
 src/pages/page-web/projects/tsa.vue |   52 +++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/src/pages/page-web/projects/tsa.vue b/src/pages/page-web/projects/tsa.vue
index 1206a08..7802d04 100644
--- a/src/pages/page-web/projects/tsa.vue
+++ b/src/pages/page-web/projects/tsa.vue
@@ -275,7 +275,7 @@
 
 <script lang="ts" setup>
 import * as Cesium from 'cesium'
-import { computed, onMounted, reactive, ref, watch, WritableComputedRef } from 'vue'
+import { computed, onMounted, reactive, ref, watch, onUnmounted } from 'vue'
 import { EDeviceTypeName, ELocalStorageKey } from '/@/types'
 import rc from '/@/assets/icons/rc.png'
 import { OnlineDevice, EModeCode, OSDVisible, EDockModeCode, DeviceOsd, EDockModeText, EModeText } from '/@/types/device'
@@ -292,6 +292,7 @@
 import { EHmsLevel } from '/@/types/enums'
 import { cesiumOperation } from '/@/hooks/use-cesium-tsa'
 import { convertTimestampToDate, getDateFromTimestamp, isToday, setTodayTime } from '/@/utils/time'
+import { parseJsonFile } from '/@/utils/geo-utils'
 let droneEntity: any
 
 const { appContext } = getCurrentInstance()
@@ -306,7 +307,10 @@
 const onlineDevices = reactive({
   data: [] as OnlineDevice[]
 })
-
+// 机场序列号
+const dock = ref('')
+// 无人机序列号
+const device_dock = ref('')
 const onlineDocks = reactive({
   data: [] as OnlineDevice[]
 })
@@ -351,19 +355,6 @@
         heading: data.deviceInfo[data.currentSn].attitude_head,
       }
       cesium.updateEntityPosition(data.deviceInfo[data.currentSn].longitude, data.deviceInfo[data.currentSn].latitude, 'drone_fly', orientation)
-      // 根据机场状态码判断是否实时更新轨迹航线
-      if (data.dockInfo[data.currentSn] && (data.dockInfo[data.currentSn].basic_osd.mode_code === 3 || data.dockInfo[data.currentSn].basic_osd.mode_code === 4 || data.dockInfo[data.currentSn].basic_osd.mode_code === 5)) {
-        console.log(data, '======', data.dockInfo[data.currentSn], '==========')
-        // 生成新的位置数组
-        const newPositions = Cesium.Cartesian3.fromDegreesArray([oldData.deviceInfo[data.currentSn].longitude, oldData.deviceInfo[data.currentSn].latitude, data.deviceInfo[data.currentSn].longitude, data.deviceInfo[data.currentSn].latitude])
-        previousPositions.value = previousPositions.value.concat(newPositions)
-        //  更新线段的位置
-        const drone_route = cesium.getEntityById('drone_route')
-        drone_route.polyline.positions = previousPositions.value
-      } else {
-        previousPositions.value = []
-        cesium.removeById('drone_route')
-      }
     } else {
       // 无人机图标
       const setting = {
@@ -382,6 +373,10 @@
       }
       cesium.addPoint(setting)
       // 无人机路线轨迹
+      // 判断是否存在done_route
+      if (cesium.getEntityById('drone_route')) {
+        cesium.removeById('drone_route')
+      }
       const routeTrajectory = {
         longitude: 115.85666327144976,
         latitude: 28.62452712442823,
@@ -394,6 +389,22 @@
       }
       cesium.addPolyline(routeTrajectory)
     }
+    // eslint-disable-next-line eqeqeq
+    // 3、4、5的时候代表飞行过程 绘制路线
+    console.log(data.deviceInfo[data.currentSn], 'Aircraft')
+    // eslint-disable-next-line eqeqeq
+    if (data.deviceInfo[data.currentSn].mode_code && (data.deviceInfo[data.currentSn].mode_code == 3 || data.deviceInfo[data.currentSn].mode_code == 4 || data.deviceInfo[data.currentSn].mode_code == 5 || data.deviceInfo[data.currentSn].mode_code == 9)) {
+      const newPositions = Cesium.Cartesian3.fromDegreesArray([data.deviceInfo[data.currentSn].longitude, data.deviceInfo[data.currentSn].latitude])
+      previousPositions.value = previousPositions.value.concat(newPositions)
+      //  更新线段的位置
+      const drone_route = cesium.getEntityById('drone_route')
+      drone_route.polyline.positions = previousPositions.value
+    // eslint-disable-next-line eqeqeq
+    } else if (data.deviceInfo[data.currentSn].mode_code == 0 || data.deviceInfo[data.currentSn].mode_code == 14) {
+      const drone_route = cesium.getEntityById('drone_route')
+      previousPositions.value = []
+      drone_route.polyline.positions = previousPositions.value
+    }
   }
   if (data.currentType === EDeviceTypeName.Dock && data.dockInfo[data.currentSn]) {
     if (snCode.value.includes(data.currentSn)) return
@@ -402,13 +413,14 @@
     const setting = {
       longitude: data.dockInfo[data.currentSn].basic_osd?.longitude,
       latitude: data.dockInfo[data.currentSn].basic_osd?.latitude,
+      id: `drone_dock_${new Date().getTime()}`,
       billboard: {
         image: getResource('dock.png'),
         outlineWidth: 0,
         width: 36,
         height: 36,
         scale: 1.0,
-      }
+      },
     }
     cesium.addPoint(setting)
     // cesium.flyTo(setting)
@@ -450,6 +462,10 @@
   const parent = element?.parentNode as HTMLDivElement
   scorllHeight.value = parent?.clientHeight - parent?.firstElementChild?.clientHeight
   previousPositions.value = []
+})
+
+onUnmounted(() => {
+  cesium.removeAllPoint()
 })
 
 function getOnlineTopo () {
@@ -511,7 +527,9 @@
 }
 
 function switchVisible (e: any, device: OnlineDevice, isDock: boolean, isClick: boolean, sn?: any) {
-  // showDrawer.value = !showDrawer.value
+  dock.value = device.gateway.sn
+  device_dock.value = device.sn
+  // showDrawer.value = !showDr++awer.value
   if (!isClick) {
     e.target.style.cursor = 'not-allowed'
     return

--
Gitblit v1.9.3