From 71627d89045c5bf3c50030751d93ae519f5dbb8d Mon Sep 17 00:00:00 2001
From: jihongshun <1151753686@qq.com>
Date: 星期三, 20 八月 2025 17:25:50 +0800
Subject: [PATCH] 航点列表 中化建 右侧联动 待测试联调

---
 src/views/system/project/components/addPorjectDialog.vue |  920 +++++++++++++++++++++++---------------------------------
 1 files changed, 378 insertions(+), 542 deletions(-)

diff --git a/src/views/system/project/components/addPorjectDialog.vue b/src/views/system/project/components/addPorjectDialog.vue
index fa4de99..df93c17 100644
--- a/src/views/system/project/components/addPorjectDialog.vue
+++ b/src/views/system/project/components/addPorjectDialog.vue
@@ -10,15 +10,13 @@
           <el-col :span=6>
               <el-card class="noScroll">
                 <div class="chooseModel">
-                  <!-- <el-button type="primary" @click='chooseModel'>娣诲姞璁惧</el-button> -->
                   <div class="fontJust">璁惧鍒楄〃</div>
                    <el-button @click="addDevice"> 鏂板</el-button>
-                   <el-button @click="draw"> 娓叉煋</el-button>
-                   <el-button @click="test"> 杞崲</el-button>
-                   <el-button @click="huixian"> 0.0</el-button>
+                   <el-button @click="lineSet"> 鑸嚎璁剧疆</el-button>
                   <el-table
                     :data="tableData"
                     max-height = '180'
+                    :row-key="getRowKeys"
                     style="width: 100%">
                     <el-table-column
                       prop="deviceName"
@@ -49,9 +47,9 @@
                   <div class="fontJust">宸℃鐐圭洰褰�</div>
                   <el-tree
                     class="filter-tree"
+                    node-key="id"
                     :data="treeData"
                     :props="defaultProps"
-                    draggable  
                     default-expand-all
                     ref="tree">
                   </el-tree>
@@ -69,12 +67,86 @@
     </el-dialog>
      <chooseDeviceDialog v-if="showDevice" @cancel ='cancel' @dealChooseArr="dealChooseArr" ></chooseDeviceDialog>
      <chooseModelDialog v-if="showModel" @cancelModel ='cancelModel' @receiveModel="receiveModel" :deviceId="deviceId"></chooseModelDialog>
+     <el-drawer
+      title="鑸嚎璁剧疆"
+      :visible.sync="drawer"
+      direction="rtl">
+      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
+        <el-form-item label="璧烽鐖崌" prop="region">
+          <el-select v-model="ruleForm.region" placeholder="璇烽�夋嫨璧烽鐖崌">
+            <el-option label="鍨傜洿" value="鍨傜洿"></el-option>
+            <el-option label="鍊炬枩" value="鍊炬枩"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="鍏ㄥ眬鑸嚎閫熷害" prop="region">
+          <div class="speed-control">
+            <el-input-number
+              v-model="ruleForm.speed"
+              :min="0"
+              :max="50"
+              :step="1"
+              controls-position="both"
+              @change="handleChange"
+            />
+            <span class="unit">m/s</span>
+          </div>
+        </el-form-item>
+        <el-form-item label="璧烽閫熷害" prop="fly">
+          <div class="speed-control">
+            <el-input-number
+              v-model="ruleForm.flySpeed"
+              :min="0"
+              :max="50"
+              :step="1"
+              controls-position="both"
+              @change="handleChange"
+            />
+            <span class="unit">m/s</span>
+          </div>
+        </el-form-item>
+        <el-form-item label="鑸偣绫诲瀷" prop="region1">
+          <el-select v-model="ruleForm.region1" placeholder="璇烽�夋嫨鑸偣绫诲瀷">
+            <el-option label="鍗忚皟杞集锛屼笉杩囩偣锛屾彁鍓嶈浆寮�" value="鍗忚皟杞集锛屼笉杩囩偣锛屾彁鍓嶈浆寮�"></el-option>
+            <el-option label="鐩寸嚎椋炶锛岄琛屽櫒鍒扮偣鍋�" value="鐩寸嚎椋炶锛岄琛屽櫒鍒扮偣鍋�"></el-option>
+            <el-option label="骞虫粦杩囩偣锛屾彁鍓嶈浆寮�" value="骞虫粦杩囩偣锛屾彁鍓嶈浆寮�"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="椋炶鍣ㄥ亸鑸妯″紡" prop="region2">
+          <el-select v-model="ruleForm.region2" placeholder="璇烽�夋嫨椋炶鍣ㄥ亸鑸妯″紡">
+            <el-option label="娌胯埅绾挎柟鍚�" value="娌胯埅绾挎柟鍚�"></el-option>
+            <el-option label="鎵嬪姩鎺у埗" value="鎵嬪姩鎺у埗"></el-option>
+            <el-option label="閿佸畾褰撳墠鍋忚埅瑙�" value="閿佸畾褰撳墠鍋忚埅瑙�"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="鑸偣闂翠簯鍙颁刊浠拌鎺у埗妯″紡" prop="region3">
+          <el-select v-model="ruleForm.region3" placeholder="璇烽�夋嫨鑸偣闂翠簯鍙颁刊浠拌鎺у埗妯″紡">
+            <el-option label="鎵嬪姩鎺у埗" value="鎵嬪姩鎺у埗"></el-option>
+            <el-option label="渚濈収姣忎釜鑸偣璁剧疆" value="渚濈収姣忎釜鑸偣璁剧疆"></el-option>
+          </el-select>
+        </el-form-item>
+         <el-form-item label="瀹屾垚鍔ㄤ綔" prop="region4">
+          <el-select v-model="ruleForm.region4" placeholder="璇烽�夋嫨瀹屾垚鍔ㄤ綔">
+            <el-option label="鑷姩杩旇埅" value="鑷姩杩旇埅"></el-option>
+            <el-option label="杩斿洖鑸嚎璧峰鐐规偓鍋�" value="杩斿洖鑸嚎璧峰鐐规偓鍋�"></el-option>
+            <el-option label="閫�鍑鸿埅绾挎ā寮�" value="閫�鍑鸿埅绾挎ā寮�"></el-option>
+            <el-option label="鍘熷湴闄嶈惤" value="鍘熷湴闄嶈惤"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" @click="submitForm('ruleForm')">淇濆瓨</el-button>
+          <el-button @click="resetForm('ruleForm')">鍙栨秷</el-button>
+        </el-form-item>
+      </el-form>
+    </el-drawer>
   </div>
 </template>
 <script>
 import CesiumMap from "../../../../utils/components/cesium-map.vue";
 import chooseDeviceDialog from './chooseDeviceDialog.vue';
 import chooseModelDialog from './chooseModelDialog.vue';
+import { obtainRealData ,buildKmz} from "@/api/system/template"
+let rotationAngle = Cesium.Math.toRadians(0)
+let lastConnectPolyline 
 export  default{
   components: {
     CesiumMap,
@@ -85,257 +157,7 @@
     return{
        dialogVisible :true,
         tableData: [],
-        treeData:[
-    {
-        "createBy": null,
-        "createTime": null,
-        "updateBy": null,
-        "updateTime": null,
-        "remark": null,
-        "id": "3c5fc76c46c54c1187ff0bbcc092194b",
-        "modelId": "6257cf734cf94c7caae0dee2ac2231d1",
-        "deviceName": "璁惧3",
-        "deviceType": null,
-        "longitude": 125.01255362568844,
-        "latitude": 46.40803605631184,
-        "altitude": -0.029793403136164368,
-        "belongingRoute": "绾胯矾3",
-        "face": 30,
-        "label": "璁惧3",
-        "children":[
-            {
-                "id": "197f211797aa9f32",
-                "label": "鍦伴潰鐐�0",
-                "longitude": 125.01254690233337,
-                "latitude": 46.408037041988585,
-                "height": 5.517266389025914,
-                "children": [
-                    {
-                        "id": "197f211797afb196",
-                        "label": "绌轰腑鐐�0",
-                        "longitude": 125.01240358310912,
-                        "latitude": 46.40814584281285,
-                        "height": 6.971525719304772
-                    }
-                ]
-            },
-            {
-                "id": "197f211797af91d9",
-                "label": "鍦伴潰鐐�1",
-                "longitude": 125.01254808759698,
-                "latitude": 46.4080365594918,
-                "height": 7.385339183474696,
-                "children": [
-                    {
-                        "id": "197f211797afdb9a",
-                        "label": "绌轰腑鐐�1",
-                        "longitude": 125.0125163640242,
-                        "latitude": 46.407960727919516,
-                        "height": 10.451384666363694
-                    }
-                ]
-            },
-            {
-                "id": "197f211797afab31",
-                "label": "鍦伴潰鐐�2",
-                "longitude": 125.01255947706582,
-                "latitude": 46.408036885119245,
-                "height": 7.42469267651616,
-                "children": [
-                    {
-                        "id": "197f211797a61300",
-                        "label": "绌轰腑鐐�2",
-                        "longitude": 125.0128655208287,
-                        "latitude": 46.4080332165472,
-                        "height": 14.51791089195843
-                    }
-                ]
-            },
-            {
-                "id": "197f211797af21e7",
-                "label": "鍦伴潰鐐�3",
-                "longitude": 125.01256023273389,
-                "latitude": 46.408036999460684,
-                "height": 5.5171023712317435,
-                "children": [
-                    {
-                        "id": "197f211797a19b34",
-                        "label": "绌轰腑鐐�3",
-                        "longitude": 125.01277085845463,
-                        "latitude": 46.40822397536244,
-                        "height": 16.06139535507995
-                    }
-                ]
-            }
-        ]
-    },
-    {
-        "createBy": null,
-        "createTime": null,
-        "updateBy": null,
-        "updateTime": null,
-        "remark": null,
-        "id": "5d7c595466094e369c6ed9fdcab6ba50",
-        "modelId": "416a0c3361a9409495623eff5c19fb41",
-        "deviceName": "璁惧2",
-        "deviceType": null,
-        "longitude": 124.98495711631958,
-        "latitude": 46.60913669289758,
-        "altitude": -0.010649270561847658,
-        "belongingRoute": "绾胯矾2",
-        "face": 30,
-        "label": "璁惧2",
-        "children": [
-            {
-                "id": "197f2157b83d1d1e",
-                "label": "鍦伴潰鐐�0",
-                "longitude": 124.98495046473204,
-                "latitude": 46.60913764437918,
-                "height": 5.517192953851729,
-                "children": [
-                    {
-                        "id": "197f2157b833e7e6",
-                        "label": "绌轰腑鐐�0",
-                        "longitude": 124.98487290823232,
-                        "latitude": 46.609159110536,
-                        "height": 8.492315413669576
-                    }
-                ]
-            },
-            {
-                "id": "197f2157b83cb37c",
-                "label": "鍦伴潰鐐�1",
-                "longitude": 124.98495132002881,
-                "latitude": 46.609137518901555,
-                "height": 7.424720940488529,
-                "children": [
-                    {
-                        "id": "197f2157b83dbf31",
-                        "label": "绌轰腑鐐�1",
-                        "longitude": 124.984847808066,
-                        "latitude": 46.60911367086078,
-                        "height": 8.37839897370324
-                    }
-                ]
-            },
-            {
-                "id": "197f2157b831259d",
-                "label": "鍦伴潰鐐�2",
-                "longitude": 124.98496295996078,
-                "latitude": 46.60913752946039,
-                "height": 7.424330357264399,
-                "children": [
-                    {
-                        "id": "197f2157b837245b",
-                        "label": "绌轰腑鐐�2",
-                        "longitude": 124.98502199892675,
-                        "latitude": 46.60913926099941,
-                        "height": 12.416325107963392
-                    }
-                ]
-            },
-            {
-                "id": "197f2157b83112ee",
-                "label": "鍦伴潰鐐�3",
-                "longitude": 124.9849638899571,
-                "latitude": 46.60913769557282,
-                "height": 5.51721178277007,
-                "children": [
-                    {
-                        "id": "197f2157b8349c7d",
-                        "label": "绌轰腑鐐�3",
-                        "longitude": 124.98502033157477,
-                        "latitude": 46.609152323278046,
-                        "height": 4.804689162058357
-                    }
-                ]
-            }
-        ]
-    },
-    {
-        "createBy": null,
-        "createTime": null,
-        "updateBy": null,
-        "updateTime": null,
-        "remark": null,
-        "id": "f796896ac1c445c183456c500502bef0",
-        "modelId": "1bd29eedeaaf4a3da83212fbb1793fd5",
-        "deviceName": "璁惧1",
-        "deviceType": null,
-        "longitude": 125.14336018333184,
-        "latitude": 46.558980802047344,
-        "altitude": -0.0019061848373990704,
-        "belongingRoute": "绾胯矾1",
-        "face": 60,
-        "label": "璁惧1",
-        "children": [
-    {
-        "id": "197f21d1d1a28cf6",
-        "label": "鍦伴潰鐐�0",
-        "longitude": 125.14335344922452,
-        "latitude": 46.558982037049276,
-        "height": 5.556334669315725,
-        "children": [
-            {
-                "id": "197f21d1d1adcbe6",
-                "label": "绌轰腑鐐�0",
-                "longitude": 125.14330233595797,
-                "latitude": 46.55904743869546,
-                "height": 6.468726016875199
-            }
-        ]
-    },
-    {
-        "id": "197f21d1d1a4aa12",
-        "label": "鍦伴潰鐐�1",
-        "longitude": 125.14335458905991,
-        "latitude": 46.558981268478746,
-        "height": 7.384477227891685,
-        "children": [
-            {
-                "id": "197f21d1d1a846ae",
-                "label": "绌轰腑鐐�1",
-                "longitude": 125.14298096389273,
-                "latitude": 46.558969173376134,
-                "height": 22.10867400719622
-            }
-        ]
-    },
-    {
-        "id": "197f21d1d1a52190",
-        "label": "鍦伴潰鐐�2",
-        "longitude": 125.14336589537841,
-        "latitude": 46.558981709304724,
-        "height": 7.424676991507425,
-        "children": [
-            {
-                "id": "197f21d1d1a6a4fe",
-                "label": "绌轰腑鐐�2",
-                "longitude": 125.14339720378332,
-                "latitude": 46.5590446327473,
-                "height": 16.720685909327106
-            }
-        ]
-    },
-    {
-        "id": "197f21d1d1a272b1",
-        "label": "鍦伴潰鐐�3",
-        "longitude": 125.14336689453488,
-        "latitude": 46.558981604123645,
-        "height": 5.516875737104807,
-        "children": [
-            {
-                "id": "197f21d1d1af7638",
-                "label": "绌轰腑鐐�3",
-                "longitude": 125.14397230855407,
-                "latitude": 46.55882377669704,
-                "height": 45.87173852318548
-            }
-        ]
-    }
-]
-    }
-],
+        treeData:[],
         defaultProps: {
           children: 'children',
           label: 'label'
@@ -343,21 +165,24 @@
         showDevice:false,
         multipleSelection: [],
         showModel:false,
-        deviceId:null
+        deviceId:null,
+        drawer:false,
+        ruleForm:{
+          speed:14,
+          flySpeed:15
+        },
+        
     }
   },
   methods:{
     handleClose(){
-      console.log("close")
       this.dialogVisible = false
       this.$emit('close')
     },
     flyToLocal(row){
-      console.log(row)
-      console.log(viewer)
-      //  const position = Cesium.Cartesian3.fromDegrees(row.longitude,row.latitude, row.altitude);
-       const position = Cesium.Cartesian3.fromDegrees(0,0,0);
-
+       const position = Cesium.Cartesian3.fromDegrees(row.longitude,row.latitude, row.deviceHeight);
+      // rotationAngle  = Cesium.Math.toRadians(row.face)  ||  Cesium.Math.toRadians(0)
+      rotationAngle  = Cesium.Math.toRadians(row.face)  ||  Cesium.Math.toRadians(0)
       // 璁剧疆妯″瀷鏂瑰悜锛堝彲閫夛級
       const heading = Cesium.Math.toRadians(row.face); // 鏈濅笢鍗楁柟鍚�
       const pitch = 0;
@@ -373,7 +198,7 @@
         position: position,
         orientation: orientation,
         model: {
-          uri: "http://192.168.1.5:9000/tower/2025/07/11/閾佸_20250711093701A001.glb", // 鏇挎崲鎴愪綘鐨勬ā鍨嬭矾寰�
+          uri: row?.ardTowerModel.modelRoute, // 鏇挎崲鎴愪綘鐨勬ā鍨嬭矾寰�
           scale: 1,
         },
         label: {
@@ -421,29 +246,73 @@
             type: 'warning'
           })
         }
-        this.tableData = this.tableData.concat(arr)
+        this.tableData = this.treeData.concat(arr)
       }
       const dealTreeData =this.dealTee()
-      // this.treeData = dealTreeData
-      console.log(this.treeData)
+      this.treeData = dealTreeData
     },
     dealTee(){
+      console.log(this.tableData)
      return  this.tableData.map(item => ({
         ...item,
         label: item.deviceName,
-        children: []
       }));
     },
     deleteData(row){
+      console.log(row)
       // 鎵惧埌 id 涓� "1" 鐨勫厓绱犵储寮�
       const index = this.tableData.findIndex(item => item.id === row.id);
-
       // 濡傛灉鎵惧埌浜嗭紝鍒犻櫎璇ュ厓绱�
       if (index !== -1) {
         this.tableData.splice(index, 1);
       }
-      const dealTreeData = this.dealTee()
+      const indexTree = this.treeData.findIndex(item => item.id === row.id);
+      // 濡傛灉鎵惧埌浜嗭紝鍒犻櫎璇ュ厓绱�
+      if (index !== -1) {
+        this.treeData.splice(indexTree, 1);
+      }
+      if(this.treeData?.length >=2 && this.treeData[0]?.children?.length > 0 && this.treeData[1]?.children?.length > 0 ) {
+          this.dealAddHeight()
+      } else if(this.treeData?.length ==1) {
+        this.treeData.map((device,index) => {
+          // 纭繚璁惧鏈塩hildren鏁扮粍
+          if(index == 0) {
+            //绗竴涓暟鎹�
+            if (device.children && Array.isArray(device.children) && device.children.length > 0) {
+                // 鑾峰彇鏈�鍚庝竴涓┖涓偣
+                const lastChild = device.children[device.children.length - 1];
+                const firstChild = device.children[0];
+                // 娣辨嫹璐濇渶鍚庝竴涓厓绱狅紙鍖呮嫭宓屽鐨刢hildren锛�
+                const newChildJson = JSON.parse(JSON.stringify(lastChild));
+                // 娣辨嫹璐濇渶涓�涓�涓厓绱狅紙鍖呮嫭宓屽鐨刢hildren锛�
+                const firstChildJson = JSON.parse(JSON.stringify(firstChild));
+
+                if(newChildJson && newChildJson.label.includes('鍔犻珮')){
+                  device.children?.pop(newChild);
+                }else if(firstChildJson && firstChildJson.label.includes('鍔犻珮')) {
+                    device.children?.shift(firstChildJson);
+                }
+                // 娣诲姞鍒癱hildren鏁扮粍鏈熬
+            }
+          }
+        })
+      }
+      const entitiesToRemove = [];
+      viewer.entities.values.forEach(entity => {
+        if (entity.id && entity.id.includes(row.id)) {
+          entitiesToRemove.push(entity.id);
+        }
+      });
+      entitiesToRemove.forEach(id => {
+        viewer.entities.removeById(id);
+      });
+      this.drawConnectionsWithLabels(this.treeData)
+      // console.log(this.tableData)
+      console.log(this.treeData)
+      // const dealTreeData = this.dealTee()
+      // console.log(dealTreeData)
       // this.treeData = dealTreeData
+      // this.drawConnectionsWithLabels(this.treeData)
     },
     chooseModel(row){
       this.deviceId = row.id
@@ -454,125 +323,165 @@
     },
     receiveModel(obj){
       //deal閫昏緫
-      console.log(obj)
+      let flightTemplateId =obj.modelObj.id
+      let deviceId = obj.deviceId
       this.dealTableTemplate(obj)
+      // let 
+      obtainRealData(flightTemplateId,deviceId).then(res=>{
+        console.log(res)
+        let treeDealData = this.transformFlightData(res.data?.coordinateSystemVoS || [])
+        console.log(treeDealData)
+        this.dealTreeMerge(obj,treeDealData)
+        
+        this.rotateAllPoints(this.treeData || [],res.data.longitude,res.data.latitude,res.data.height)
+        console.log(this.treeData)
+        if(this.treeData?.length >=2 && this.treeData[0]?.children?.length > 0 && this.treeData[1]?.children?.length > 0 ) {
+            this.dealAddHeight()
+        }
+        console.log(this.treeData)
+        this.drawConnectionsWithLabels(this.treeData)
+      })
       // this.dealTreeMerge(obj)
     },
+    dealAddHeight(){
+      let currentLength = this.treeData.filter(item=>item.children)?.length || 0
+      console.log(this.treeData)
+      console.log(currentLength)
+      this.treeData.map((device,index) => {
+          // 纭繚璁惧鏈塩hildren鏁扮粍
+          if(index == 0) {
+            //绗竴涓暟鎹�
+            if (device.children && Array.isArray(device.children) && device.children.length > 0) {
+                // 鑾峰彇鏈�鍚庝竴涓┖涓偣
+                const lastChild = device.children[device.children.length - 1];
+                // 娣辨嫹璐濇渶鍚庝竴涓厓绱狅紙鍖呮嫭宓屽鐨刢hildren锛�
+                const newChild = JSON.parse(JSON.stringify(lastChild));
+                if(newChild.label.includes('鍔犻珮')) {
+
+                }else {
+                  newChild.label = newChild.label + '-鍔犻珮'
+                  // 楂樺害澧炲姞20
+                  // newChild.height += 20;
+                  //濉旈珮 - 楂樺害  + 寰�涓婇澶氬皯绫�
+                  newChild.height += (device.ardTowerModel?.modelHeight  - newChild.height +  20) ;
+                  console.log('push11111111111111')
+                  // 娣诲姞鍒癱hildren鏁扮粍鏈熬
+                  device.children.push(newChild);
+                }
+            }
+          }
+          else if(index == currentLength -1) {
+            if (device.children && Array.isArray(device.children) && device.children.length > 0) {
+                // 鑾峰彇鏈�鍚庝竴涓┖涓偣
+                const lastChild = device.children[0];
+                // 娣辨嫹璐濇渶涓�涓�涓厓绱狅紙鍖呮嫭宓屽鐨刢hildren锛�
+                const newChild = JSON.parse(JSON.stringify(lastChild));
+                if(newChild.label.includes('鍔犻珮')) {
+                }else {
+                  newChild.label = newChild.label + '-鍔犻珮绗竴涓偣'
+                  newChild.height += (device.ardTowerModel?.modelHeight  - newChild.height +  20) ;
+                  // 娣诲姞鍒癱hildren鏁扮粍鏈熬
+                  device.children.unshift(newChild);
+                }
+                
+            }
+          } else {
+            if (device.children && Array.isArray(device.children) && device.children.length > 0) {
+                // 鑾峰彇鏈�鍚庝竴涓┖涓偣
+                const firstChild = device.children[0];
+                const lastChild = device.children[device.children.length - 1];
+                // 娣辨嫹璐濇渶涓�涓�涓厓绱狅紙鍖呮嫭宓屽鐨刢hildren锛�
+                const newFirstChild = JSON.parse(JSON.stringify(firstChild));
+                const newLastChildChild = JSON.parse(JSON.stringify(lastChild));
+                //楂樺害澧炲姞20
+                if(newFirstChild.label.includes('鍔犻珮')) {
+                }else {
+                    newFirstChild.label = newFirstChild.label + '-鍔犻珮'
+                    newFirstChild.height += (device.ardTowerModel?.modelHeight  - newFirstChild.height +  20) ;
+                    device.children.unshift(firstChild);
+                }
+                if(newLastChildChild.label.includes('鍔犻珮')) {
+                }else {
+                    newLastChildChild.label = newLastChildChild.label + '-鍔犻珮'
+                    newLastChildChild.height += (device.ardTowerModel?.modelHeight  - newLastChildChild.height +  20) ;
+                    device.children.push(newLastChildChild);
+                }
+            }
+          }
+      })
+    },
+    //杩斿洖鏁版嵁杞崲鏍戠粨鏋�
+    transformFlightData(data) {
+      console.log(data)
+      const result = [];
+
+      data.forEach(item => {
+        // 鎵惧埌绗竴涓� groundPoint锛屼綔涓轰唬琛�
+        const groundPoint = item.groundPointVo?.[0];
+
+        // 鐢熸垚 children 鑺傜偣
+        const children = groundPoint ? [{
+          id: groundPoint.id,
+          label: groundPoint.targetName,
+          longitude: groundPoint.longitude,
+          latitude: groundPoint.latitude,
+          height: groundPoint.height
+        }] : [];
+
+        // 鐢熸垚绌轰腑鐐�
+        result.push({
+          id: item.id,
+          label: item.targetName,
+          longitude: item.longitude,
+          latitude: item.latitude,
+          height: item.altitude,
+          children
+        });
+      });
+
+      return result;
+    },
     dealTableTemplate(obj){
-      const target = this.tableData.find(item => item.id === obj.deviceId)
-      if (target) {
-        this.$set(target, 'mode', obj.modelObj.name) // 鉁� Vue2 闇�瑕佷娇鐢� $set 浠ョ‘淇濆搷搴斿紡
+      const targetTableData = this.tableData.find(item => item.id === obj.deviceId)
+      const targetTreeData = this.treeData.find(item => item.id === obj.deviceId)
+      if (targetTableData) {
+        this.$set(targetTableData, 'mode', obj.modelObj.templateName) // 鉁� Vue2 闇�瑕佷娇鐢� $set 浠ョ‘淇濆搷搴斿紡
+      }
+      if (targetTreeData) {
+        this.$set(targetTreeData, 'mode', obj.modelObj.templateName) // 鉁� Vue2 闇�瑕佷娇鐢� $set 浠ョ‘淇濆搷搴斿紡
       }
     },
-    dealTreeMerge(obj){
-      let newChildrenData= [
-        { id: 100, label: '鏂板瓙鑺傜偣A',children:[{id: 1001,label: '鏂板瓙鑺傜偣A-1'}]},
-        { id: 101, label: '鏂板瓙鑺傜偣B' }
-      ]
+    dealTreeMerge(obj,data){
       this.treeData.forEach(item => {
         if(item.id == obj.deviceId) {
           // 鏇挎崲绗竴灞傛瘡涓妭鐐圭殑 children
-          this.$set(item, 'children', JSON.parse(JSON.stringify(newChildrenData)));
+          this.$set(item, 'children', JSON.parse(JSON.stringify(data)));
         }
       });
     },
-    drawConnectionsWithLabels1111(devices) {
-      const airPoints = [];
-
-      devices.forEach(device => {
-        if (!Array.isArray(device.children)) return;
-
-        device.children.forEach(groundPoint => {
-          console.log(groundPoint)
-          const groundPos = Cesium.Cartesian3.fromDegrees(
-            groundPoint.longitude,
-            groundPoint.latitude,
-            groundPoint.height
-          );
-
-          // 鉁� 鍦伴潰鐐癸細娣诲姞瀹炰綋 + label
-          viewer.entities.add({
-            position: groundPos,
-            point: {
-              pixelSize: 6,
-              color: Cesium.Color.BLUE
-            },
-            label: {
-              text: groundPoint.label || '',
-              font: '14px sans-serif',
-              fillColor: Cesium.Color.WHITE,
-              style: Cesium.LabelStyle.FILL_AND_OUTLINE,
-              outlineWidth: 2,
-              outlineColor: Cesium.Color.BLACK,
-              verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
-              pixelOffset: new Cesium.Cartesian2(0, -12)
-            }
-          });
-
-          // 閬嶅巻绌轰腑鐐�
-          if (Array.isArray(groundPoint.children)) {
-            groundPoint.children.forEach(airPoint => {
-              console.log(airPos)
-              const airPos = Cesium.Cartesian3.fromDegrees(
-                airPoint.longitude,
-                airPoint.latitude,
-                airPoint.height
-              );
-
-              // 鉁� 绌轰腑鐐癸細娣诲姞瀹炰綋 + label
-              viewer.entities.add({
-                position: airPos,
-                point: {
-                  pixelSize: 6,
-                  color: Cesium.Color.YELLOW
-                },
-                label: {
-                  text: airPoint.label || '',
-                  font: '14px sans-serif',
-                  fillColor: Cesium.Color.YELLOW,
-                  style: Cesium.LabelStyle.FILL_AND_OUTLINE,
-                  outlineWidth: 2,
-                  outlineColor: Cesium.Color.BLACK,
-                  verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
-                  pixelOffset: new Cesium.Cartesian2(0, -12)
-                }
-              });
-
-              // 鉁� 鍦伴潰鐐� 鉃� 绌轰腑鐐� 钃濊壊铏氱嚎
-              viewer.entities.add({
-                polyline: {
-                  positions: [groundPos, airPos],
-                  width: 2,
-                  material: new Cesium.PolylineDashMaterialProperty({
-                    color: Cesium.Color.BLUE,
-                    dashLength: 8
-                  })
-                }
-              });
-
-              airPoints.push(airPos);
-            });
-          }
-        });
-      });
-
-      // 鉁� 鎵�鏈夌┖涓偣 鉃� 榛勮壊瀹炵嚎杩炴帴
-      if (airPoints.length > 1) {
-        viewer.entities.add({
-          polyline: {
-            positions: airPoints,
-            width: 3,
-            material: Cesium.Color.YELLOW
-          }
-        });
-      }
+    generateId() {
+      return 'id_' + Math.random().toString(36).substring(2, 10);
     },
     drawConnectionsWithLabels(devices) {
-      const airPoints = [];
+      if(lastConnectPolyline) {
+        viewer.entities.remove(lastConnectPolyline)
+        lastConnectPolyline = null
+      }
+        // 鐩存帴鎿嶄綔EntityCollection锛堟帹鑽愶級
+      const entitiesToRemove = [];
+      viewer.entities.values.forEach(entity => {
+        if (entity.id && entity.id.includes(this.deviceId)) {
+          entitiesToRemove.push(entity.id);
+        }
+      });
 
+      entitiesToRemove.forEach(id => {
+        viewer.entities.removeById(id);
+      });
+      const airPoints = [];
+      console.log(devices)
       devices.forEach(device => {
         if (!Array.isArray(device.children)) return;
-
         device.children.forEach(airPoint => {
           // 绌轰腑鐐逛綅缃�
           const airPos = Cesium.Cartesian3.fromDegrees(
@@ -584,6 +493,7 @@
           // 鉁� 娣诲姞绌轰腑鐐瑰疄浣撳拰 label
           viewer.entities.add({
             position: airPos,
+            id:device.id +'airpoint' + this.generateId(),
             point: {
               pixelSize: 6,
               color: Cesium.Color.YELLOW
@@ -613,6 +523,7 @@
 
               // 鉁� 娣诲姞鍦伴潰鐐瑰疄浣撳拰 label
               viewer.entities.add({
+                id:device.id +'groundpoint' + this.generateId(),
                 position: groundPos,
                 point: {
                   pixelSize: 6,
@@ -632,6 +543,7 @@
 
               // 鉁� 钃濊壊铏氱嚎杩炴帴锛氱┖涓偣 鉃� 鍦伴潰鐐�
               viewer.entities.add({
+                id:device.id +'polyline' + this.generateId(),
                 polyline: {
                   positions: [airPos, groundPos],
                   width: 2,
@@ -645,10 +557,10 @@
           }
         });
       });
-
+      console.log(airPoints)
       // 鉁� 榛勮壊瀹炵嚎杩炴帴鎵�鏈夌┖涓偣
       if (airPoints.length > 1) {
-        viewer.entities.add({
+        lastConnectPolyline = viewer.entities.add({
           polyline: {
             positions: airPoints,
             width: 3,
@@ -657,183 +569,107 @@
         });
       }
     },
-    draw(){
-      this.drawConnectionsWithLabels(this.treeData)
-    },
-    test(){
-        this.treeData = this.swapGroundAir(this.treeData);        
-    },
-    swapGroundAir(data) {
-      
-      return data.map(device => {
-        const newChildren = [];
-
-        device.children.forEach(ground => {
-          const air = ground.children && ground.children[0];
-          if (air) {
-            newChildren.push({
-              ...air,
-              children: [
-                {
-                  ...ground,
-                  children: undefined
-                }
-              ]
+    rotateAllPoints(dataList,towerLongitude,towerLatitude,towerhHight) {
+      return dataList.map(item => {
+        if(!item.isDeal) {
+          const towerPoint = Cesium.Cartesian3.fromDegrees(towerLongitude, towerLatitude, towerhHight);
+          const newGround = {
+            ...item,
+          };
+          if(item.id == this.deviceId ){
+            item.isDeal = true
+          } 
+          // 澶勭悊瀛愮┖涓偣
+          newGround.children = item.children?.map(child => {
+            const airPoint = Cesium.Cartesian3.fromDegrees(child.longitude, child.latitude, child.height);
+            const rotatedAirPoint = this.rotateAroundPoint( airPoint,towerPoint, rotationAngle);
+            const rotatedAirCarto = Cesium.Cartographic.fromCartesian(rotatedAirPoint);
+            child.longitude = Cesium.Math.toDegrees(rotatedAirCarto.longitude)
+            child.latitude = Cesium.Math.toDegrees(rotatedAirCarto.latitude)
+            child.height = rotatedAirCarto.height
+            child.children = child.children?.map(sonChild => {
+              const groundPoint = Cesium.Cartesian3.fromDegrees(sonChild.longitude, sonChild.latitude, sonChild.height);
+              const newGroundPoint = this.rotateAroundPoint( groundPoint,towerPoint, rotationAngle);
+              const newGroundCarto = Cesium.Cartographic.fromCartesian(newGroundPoint);
+              return {
+                ...sonChild,
+                longitude: Cesium.Math.toDegrees(newGroundCarto.longitude),
+                latitude: Cesium.Math.toDegrees(newGroundCarto.latitude),
+                height: newGroundCarto.height
+              };
             });
-          }
-        });
-
-        return {
-          ...device,
-          children: newChildren
-        };
-      });
-    },
-    huixian(){
-      let data=[
-    {
-        "altitude": 35.09683139439875,
-        "ardGroundPoint": [
-            {
-                "height": 35.0960134603141,
-                "latitude": 0.000032899894086000126,
-                "longitude": 3.2789183307897707e-7,
-                "pointNumber": 1,
-                "targetName": "鍦伴潰鐐�0"
-            }
-        ],
-        "latitude": 0.0009372188427979371,
-        "longitude": 0.000009340650264268872,
-        "pointNumber": 1,
-        "targetName": "绌轰腑鐐�0"
-    },
-    {
-        "altitude": 40.057437157900914,
-        "ardGroundPoint": [
-            {
-                "height": 40.05662385374772,
-                "latitude": 0.00002759265968150938,
-                "longitude": 7.877836487599675e-7,
-                "pointNumber": 1,
-                "targetName": "鍦伴潰鐐�1"
-            }
-        ],
-        "latitude": 0.0009315830781716235,
-        "longitude": 0.000026597143043885405,
-        "pointNumber": 2,
-        "targetName": "绌轰腑鐐�1"
-    },
-    {
-        "altitude": 90.05743715790092,
-        "ardGroundPoint": [
-            {
-                "height": 40.05662385374772,
-                "latitude": 0.00002759265968150938,
-                "longitude": 7.877836487599675e-7,
-                "pointNumber": 1,
-                "targetName": "鍦伴潰鐐�1-鍔犻珮"
-            }
-        ],
-        "latitude": 0.0009315830781716235,
-        "longitude": 0.000026597143043885405,
-        "pointNumber": 3,
-        "targetName": "绌轰腑鐐�1-鍔犻珮"
-    },
-    {
-        "altitude": 85.4017386642163,
-        "ardGroundPoint": [
-            {
-                "height": 35.09000336658791,
-                "latitude": -0.0000329911085806409,
-                "longitude": 4.656954257439534e-7,
-                "pointNumber": 1,
-                "targetName": "鍦伴潰鐐�2"
-            }
-        ],
-        "latitude": -0.0009372610742669285,
-        "longitude": 0.000013144727598247196,
-        "pointNumber": 4,
-        "targetName": "绌轰腑鐐�2-鍔犻珮"
-    },
-    {
-        "altitude": 35.401738664216296,
-        "ardGroundPoint": [
-            {
-                "height": 35.09000336658791,
-                "latitude": -0.0000329911085806409,
-                "longitude": 4.656954257439534e-7,
-                "pointNumber": 1,
-                "targetName": "鍦伴潰鐐�2"
-            }
-        ],
-        "latitude": -0.0009372610742669285,
-        "longitude": 0.000013144727598247196,
-        "pointNumber": 5,
-        "targetName": "绌轰腑鐐�2"
-    }
-]
-      let aaa = this.convertToTree(data)
-      console.log(aaa)
-      this.drawLines(aaa)
-    },
-    convertToTree(data) {
-      return data.map((item, index) => {
-        const parentId = 'air_' + index;
-        return {
-          id: parentId,
-          label: item.targetName,
-          longitude: item.longitude,
-          latitude: item.latitude,
-          height: item.altitude,
-          children: (item.ardGroundPoint || []).map((g, i) => {
-            return {
-              id: parentId + '_ground_' + i,
-              label: g.targetName,
-              longitude: g.longitude,
-              latitude: g.latitude,
-              height: g.height
-            }
-          })
+          });
+          console.log(newGround.children)
+          return newGround;
         }
+         
       });
     },
-    drawLines(treeData) {
-      console.log(treeData)
-      // 鏀堕泦绌轰腑鐐逛綅缃�
-      const airPositions = treeData.map(point => {
-        return Cesium.Cartesian3.fromDegrees(
-          point.longitude,
-          point.latitude,
-          point.height
-        );
-      });
+    //聽璁$畻鐐笰缁曠偣B閫嗘椂閽堟棆杞寚瀹氳搴﹀悗鐨勬柊浣嶇疆
+    //  绌轰腑鐐规垨鑰呭湴闈㈢偣绗涘崱灏斿潗鏍� 濉旂殑绗涘崱灏斿潗鏍�    濉旂殑鏈濆悜鍊�
+    rotateAroundPoint(startPoint,pivotPoint,rotationAngle) {
+      console.log(rotationAngle)
+      //聽鍒涘缓涓�涓粠B鐐瑰埌鏈湴鍧愭爣绯荤殑杞崲鐭╅樀锛堜笢鏂瑰悜涓篨杞达紝鍖楁柟鍚戜负Y杞达紝鍨傜洿鏂瑰悜涓篫杞达級
+     const transformationMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(pivotPoint);
+      //聽鑾峰彇涓栫晫鍧愭爣绯诲埌鏈湴鍧愭爣绯荤殑杞崲鐭╅樀
+     const inverseTransformationMatrix = Cesium.Matrix4.inverse(transformationMatrix,new Cesium.Matrix4());
+      //聽灏咥鐐硅浆鎹㈠埌灞�閮ㄥ潗鏍囩郴涓�
+     const localStartPoint = Cesium.Matrix4.multiplyByPoint(inverseTransformationMatrix, startPoint,new Cesium.Cartesian3());
+      //聽璁$畻A鐐瑰湪灞�閮ㄥ潗鏍囩郴涓�嗘椂閽堟棆杞寚瀹氳搴﹀悗鐨勬柊浣嶇疆
+     const rotatedX = localStartPoint.x * Math.cos(rotationAngle) + localStartPoint.y * Math.sin(rotationAngle);
+     const rotatedY = localStartPoint.y * Math.cos(rotationAngle) - localStartPoint.x * Math.sin(rotationAngle);
+     const rotatedZ = localStartPoint.z; //聽Z杞村潗鏍囦繚鎸佷笉鍙�
+      //聽灏嗘棆杞悗鐨勫眬閮ㄥ潗鏍囪浆鎹㈠洖涓栫晫鍧愭爣绯�
+     return Cesium.Matrix4.multiplyByPoint(transformationMatrix,聽new聽Cesium.Cartesian3(rotatedX,聽rotatedY,聽rotatedZ),聽new聽Cesium.Cartesian3());
+    },
+    getRowKeys(row){
+      console.log(row)
+      return row.id +this.generateId()
+    },
+    submit(){
+      console.log(this.treeData)
 
-      // 1. 绌轰腑鐐逛箣闂寸敤榛勮壊瀹炵嚎杩炴帴
-      viewer.entities.add({
-        polyline: {
-          positions: airPositions,
-          width: 2,
-          material: Cesium.Color.YELLOW
-        }
-      });
+      const routePointList = [];
 
-      // 2. 姣忎釜绌轰腑鐐逛笌鍦伴潰鐐圭敤钃濊壊铏氱嚎杩炴帴
-      treeData.forEach(point => {
-        const airPos = Cesium.Cartesian3.fromDegrees(point.longitude, point.latitude, point.height);
-        point.children.forEach(child => {
-          const groundPos = Cesium.Cartesian3.fromDegrees(child.longitude, child.latitude, child.height);
-          viewer.entities.add({
-            polyline: {
-              positions: [airPos, groundPos],
-              width: 1,
-              material: new Cesium.PolylineDashMaterialProperty({
-                color: Cesium.Color.BLUE,
-                dashLength: 8
-              })
-            }
+      this.treeData.forEach(device => {
+        device.children.forEach((airPoint, index) => {
+          routePointList.push({
+            routePointIndex: routePointList.length,
+            longitude: airPoint.longitude,
+            latitude: airPoint.latitude,
+            height: airPoint.height,
+            isStartAndEndPoint: false,
+            coordinatePointReq: {
+                height: airPoint.children[0].height,
+                latitude:airPoint.children[0].latitude,
+                longitude: airPoint.children[0].longitude
+              }
           });
         });
       });
+
+      // 鏍囪棣栧熬涓� true
+      if (routePointList.length > 0) {
+        routePointList[0].isStartAndEndPoint = true;
+        routePointList[routePointList.length - 1].isStartAndEndPoint = true;
+      }
+
+      console.log(routePointList);
+      let params  = {
+        routePointList:routePointList
+      }
+      console.log('鐢熸垚鑸嚎')
+      buildKmz(params).then(res=>{
+        if(res.code == 200) {
+           this.$message({
+              message: '鐢熸垚鑸嚎鎴愬姛',
+              type: 'success'
+            })
+        }
+      })
+    },
+    lineSet(){
+      this.drawer =true
     }
   }
 }

--
Gitblit v1.9.3