From cf4ed06dea0076e518319de24c5120bb3fe0dae9 Mon Sep 17 00:00:00 2001
From: guonan <guonan201020@163.com>
Date: 星期五, 06 六月 2025 14:41:25 +0800
Subject: [PATCH] 提交

---
 src/components/tools/LayerTree.vue                |    4 
 src/views/GisView.vue                             |  475 ++++++++++++++++++++++++++++++------------
 src/api/hpApi.js                                  |   85 +++++++
 src/components/menu/Device.vue                    |   42 +++
 src/store/simulation.js                           |    2 
 src/api/requestHT.js                              |    2 
 src/components/menu/Location.vue                  |   22 +
 src/views/left/KGSimOption/RealTimeSimulation.vue |    4 
 8 files changed, 481 insertions(+), 155 deletions(-)

diff --git a/src/api/hpApi.js b/src/api/hpApi.js
index 2cba069..d1f77ab 100644
--- a/src/api/hpApi.js
+++ b/src/api/hpApi.js
@@ -69,8 +69,8 @@
   return response.data;
 }
 
-// 鑾峰彇鐩戞祴璁惧淇℃伅
-export async function getDeviceInfo(data) {
+// 鑾峰彇鐞夌拑搴欓晣鐩戞祴璁惧淇℃伅
+export async function getDeviceInfoShg(data) {
   const response = await axios.post("/hp/deviceInfo/getData", {
     filterObject: {
       "dictDeviceType": data,
@@ -81,18 +81,97 @@
   return response.data;
 }
 
+// 鑾峰彇鍖椾含甯傜洃娴嬭澶囦俊鎭�
+export async function getDeviceInfo(data) {
+  const response = await axios.post("/hp/deviceInfo/getData", {
+
+    "currentPage": 1,
+    "pageSize": 10000,
+    "filterObject": {
+      "belongObjList": [
+        "1797461961110261762"
+      ]
+      // "id": "",
+      // "deviceName": "",
+      // "deviceCode": "",
+      // "deviceClientId": "",
+      // "dictDeviceType": "",
+      // "hdName": "",
+      // "installUnit": "",
+      // "rtuUnit": "",
+      // "dictDisasterType": "",
+      // "dictCommunicationType": "",
+      // "dictDeviceStatus": "",
+      // "divisionDistrict": "",
+      // "townCode": ""
+    },
+    "sortedList": [
+      {
+        "sorted": "createTime",
+        "type": "desc"
+      }
+    ]
+  })
+
+  return response.data;
+}
+
+
 // 鑾峰彇闅愭偅鐐逛俊鎭�
 export async function getDangerPoint(data) {
   const response = await axios.post("/hp/sinoDzHiddenDangerPoint/getData", {
     filterObject: {
       "divisionCounty": "110116000000",
-      "divisionTown": "110116110000"
+      "divisionTown": "110116110000",
+      // "divisionCounty": null,
+      // "divisionTown": null,
+      "year": 2025
     },
     "pageSize": 10000
   });
   return response.data;
 }
 
+export async function fetchAndLoadDangerPoints(loadCallback) {
+  let currentPage = 1;
+  const pageSize = 100; // 姣忔璇锋眰鐨勬暟鎹噺
+
+  while (true) {
+    try {
+      const response = await axios.post("/hp/sinoDzHiddenDangerPoint/getData", {
+        filterObject: {
+          divisionCounty: "110111000000",
+          divisionTown: null,
+          year: 2025
+        },
+        pageSize: pageSize,
+        currentPage: currentPage // 娣诲姞褰撳墠椤电爜鍙傛暟
+      });
+
+      const pageData = response.data?.data?.pageData;
+
+      if (!Array.isArray(pageData)) {
+        console.error("Expected an array in 'pageData', but got:", typeof pageData, pageData);
+        break;
+      }
+
+      if (pageData.length === 0) break; // 娌℃湁鏇村鏁版嵁浜�
+
+      // 璋冪敤浼犲叆鐨勫洖璋冨嚱鏁帮紝鐢ㄤ簬鏇存柊椤甸潰鍐呭
+      loadCallback(pageData);
+
+      if (pageData.length < pageSize) break; // 濡傛灉鏈杩斿洖鐨勬暟鎹皯浜巔ageSize锛岃鏄庡凡鑾峰彇瀹屾墍鏈夋暟鎹�
+
+      currentPage++; // 鏇存柊涓嬩竴椤电殑椤电爜
+    } catch (error) {
+      console.error("Error fetching danger points:", error);
+      break;
+    }
+  }
+}
+
+
+
 // 鏍规嵁骞翠唤鑾峰彇闆ㄩ噺鏁版嵁
 export async function getRainfallDataYears(data) {
   const response = await axios.post("/hp/rainfallCountyCity/getData", {
diff --git a/src/api/requestHT.js b/src/api/requestHT.js
index bf8ac9a..7cc0f4a 100644
--- a/src/api/requestHT.js
+++ b/src/api/requestHT.js
@@ -3,7 +3,7 @@
 // 鍒涘缓 Axios 瀹炰緥
 const instance = axios.create({
   baseURL: "/", // 浣跨敤浣犻厤缃殑 /auth 浠g悊
-  timeout: 1000 * 60, // 璇锋眰瓒呮椂鏃堕棿锛堝崟浣嶏細姣锛�
+  // timeout: 1000 * 60, // 璇锋眰瓒呮椂鏃堕棿锛堝崟浣嶏細姣锛�
   headers: {
     "Content-Type": "application/json", // 榛樿璇锋眰澶�
   },
diff --git a/src/components/menu/Device.vue b/src/components/menu/Device.vue
index a566a28..3b69b4d 100644
--- a/src/components/menu/Device.vue
+++ b/src/components/menu/Device.vue
@@ -74,7 +74,7 @@
 import { useRoute, onBeforeRouteUpdate } from "vue-router";
 import { createPoint, removeEntities } from "@/utils/map";
 import { deviceDictList, getDictName } from "@/constant/dict.js";
-import { getDeviceInfo } from "@/api/hpApi";
+import { getDeviceInfoShg, getDeviceInfo } from "@/api/hpApi";
 import { initeWaterPrimitiveView } from "@/utils/water"; //鐩告満flyTo鍑芥暟锛屽悗缁璷ptions鍒楄〃涓湁瀵瑰簲缁忕含搴﹀悗寮冪敤
 import { useSimStore } from "@/store/simulation";
 import { Loading } from "@element-plus/icons-vue";
@@ -87,7 +87,7 @@
   try {
     await getData();
     await loadDeviceList(selectValue.value);
-    initeWaterPrimitiveView();
+    // initeWaterPrimitiveView();
   } finally {
     isLoading.value = false;
   }
@@ -124,9 +124,9 @@
     removeEntities(item.deviceId);
   });
 };
-const initializeDevicePoints = () => {
+const initializeDevicePoints = (val) => {
   const list = [];
-  deviceListAll.value.forEach((item, index) => {
+  val.forEach((item, index) => {
     // 鏍规嵁闇�姹傚彲澧炲垹
     item.type = getDictName(deviceDictList, item.dictDeviceType);
     item.name = item.deviceName.split(selectValue.value)[1] || item.deviceName;
@@ -141,7 +141,7 @@
 };
 const allDevices = ref([]);
 const getData = async () => {
-  const res = await getDeviceInfo();
+  const res = await getDeviceInfoShg();
   allDevices.value = res.data.pageData;
 };
 // 鏍规嵁鍖哄煙鍚嶇О鍔犺浇璁惧鍒楄〃
@@ -149,14 +149,38 @@
   try {
     isLoading.value = true;
     handleCleanup();
-    // const res = await getDeviceInfo();
+    // const res = await getDeviceInfoShg();
     // const allDevices = res.data.pageData;
     const devicesInArea = allDevices.value.filter((item) =>
       item.deviceName?.includes(areaName)
     );
-    deviceListAll.value = devicesInArea;
-    deviceListAll.length = 0;
-    initializeDevicePoints();
+    // deviceListAll.value = devicesInArea;
+    getDeviceInfo().then((res) => {
+      const list = res.data.pageData;
+      deviceListAll.value = [];
+
+      let index = 0;
+      const batchSize = 50; // 姣忔澶勭悊鐨勬暟閲�
+      const delay = 100; // 姣忛殧澶氬皯姣澶勭悊涓�娆�
+
+      const intervalId = setInterval(() => {
+        // 鍙栧嚭褰撳墠鎵规鐨勬暟鎹�
+        const batch = list.slice(index, index + batchSize);
+
+        if (batch.length === 0) {
+          clearInterval(intervalId); // 鏁版嵁澶勭悊瀹屼簡锛屽仠姝㈠畾鏃跺櫒
+          return;
+        }
+
+        // 鎶婂綋鍓嶆壒娆$殑鏁版嵁 push 鍒� deviceListAll
+        deviceListAll.value = [...deviceListAll.value, ...batch];
+
+        // 瀵瑰綋鍓嶆壒娆℃墽琛屽垵濮嬪寲鏂规硶
+        initializeDevicePoints(batch);
+
+        index += batchSize;
+      }, delay);
+    });
   } catch (error) {
     console.error("鍔犺浇璁惧淇℃伅澶辫触", error);
   } finally {
diff --git a/src/components/menu/Location.vue b/src/components/menu/Location.vue
index 1830e67..64e6460 100644
--- a/src/components/menu/Location.vue
+++ b/src/components/menu/Location.vue
@@ -71,6 +71,22 @@
 import { initeWaterPrimitiveView } from "@/utils/water"; //鐩告満flyTo鍑芥暟锛屽悗缁璷ptions鍒楄〃涓湁瀵瑰簲缁忕含搴﹀悗寮冪敤
 import { useRoute, onBeforeRouteUpdate } from "vue-router";
 import { Loading } from "@element-plus/icons-vue";
+import { fetchAndLoadDangerPoints } from "@/api/hpApi.js";
+
+const districtList = ref([]);
+
+const displayData = ref([]);
+
+const loadCallback = async (newData) => {
+  districtList.value = [...newData];
+  console.log(districtList.value, "aaaaaaaaaaaaaaaaaaaaaaaaa");
+
+  await initializeDevicePoints();
+};
+
+onMounted(() => {
+  fetchAndLoadDangerPoints(loadCallback);
+});
 
 const simStore = useSimStore();
 // onBeforeRouteUpdate((to, from, next) => {
@@ -115,7 +131,6 @@
   },
 ]);
 
-const districtList = ref([]);
 const loading = ref(true); // 鎺у埗鍔犺浇鐘舵��
 
 function handleClick(district) {
@@ -152,7 +167,7 @@
     })
   );
 };
-// 鏍规嵁鍖哄煙鍚嶇О杩囨护鏁版嵁
+
 const filterDataByArea = async (areaName) => {
   handleCleanup();
   if (!areaName || !simStore.DangerPoint || simStore.DangerPoint.length === 0) {
@@ -164,7 +179,8 @@
   );
 
   if (JSON.stringify(districtList.value) !== JSON.stringify(filteredData)) {
-    districtList.value = filteredData;
+    // districtList.value = filteredData;
+
     await initializeDevicePoints();
   }
 };
diff --git a/src/components/tools/LayerTree.vue b/src/components/tools/LayerTree.vue
index f572dd8..5e4e75f 100644
--- a/src/components/tools/LayerTree.vue
+++ b/src/components/tools/LayerTree.vue
@@ -28,7 +28,7 @@
 import { loadAreaPolygon, clearAreaPolygon } from "@/utils/area";
 import { checkedKeys } from "@/store/index";
 import { getDuanMainData, getDistrictListData } from "@/api/index.js";
-import { getDeviceInfo, getDangerPoint } from "@/api/hpApi";
+import { getDeviceInfoShg, getDangerPoint } from "@/api/hpApi";
 
 import { useSimStore } from "@/store/simulation";
 
@@ -254,7 +254,7 @@
 
 // 鐩戞祴璁惧鍒楄〃
 const getDevicetList = async () => {
-  const res = await getDeviceInfo(); // 璋冩暣getDeviceInfo浠ユ帴鍙楀姩鎬佸弬鏁帮紝濡傛灉闇�瑕佺殑璇�
+  const res = await getDeviceInfoShg(); // 璋冩暣getDeviceInfoShg浠ユ帴鍙楀姩鎬佸弬鏁帮紝濡傛灉闇�瑕佺殑璇�
   devicetList.value = res.data.pageData.filter((item) =>
     item.deviceName?.includes("瀛欒儭娌�")
   );
diff --git a/src/store/simulation.js b/src/store/simulation.js
index 4bfc089..e1cea0d 100644
--- a/src/store/simulation.js
+++ b/src/store/simulation.js
@@ -106,6 +106,7 @@
 
     const startZHJC = () => {
         init()
+        flyToHomeView()
         functionShow.value = true
         deviceShow.value = true
         isShowEarth.value = true
@@ -114,6 +115,7 @@
 
     const startMNFZ = () => {
         init()
+        flyToHomeView()
         leftShow.value = true
         isShowEarth.value = false
 
diff --git a/src/views/GisView.vue b/src/views/GisView.vue
index 5640040..9ea1a4f 100644
--- a/src/views/GisView.vue
+++ b/src/views/GisView.vue
@@ -44,7 +44,7 @@
 import { EventBus } from "@/eventBus"; // 寮曞叆浜嬩欢鎬荤嚎
 import { useSimStore } from "@/store/simulation";
 const simStore = useSimStore();
-
+/////////////////////////鍦板浘褰卞儚閫夋嫨/////////////////////////
 const views = [
   { label: "鍦板浘", value: "map", icon: "鍦板浘.png" },
   { label: "褰卞儚", value: "image", icon: "褰卞儚.png" },
@@ -105,8 +105,11 @@
     });
   }
 };
+/////////////////////////鍦板浘褰卞儚閫夋嫨/////////////////////////
+
 const route = useRoute();
 let handler = null;
+/////////////////////////鍒濆鍖栧湴鍥�/////////////////////////
 function initMap() {
   window.Cesium = SmartEarth.Cesium;
   window.earthCtrl = new SmartEarth.EarthCtrl("gis-view");
@@ -114,24 +117,19 @@
 
   // 1. 璁剧疆鍒濆鏃堕棿
   const date = new Date(2025, 3, 11, 12, 0, 0, 0);
-  // const date = new Date(2024, 6, 13, 5, 5, 50);
   const julianDate = SmartEarth.Cesium.JulianDate.fromDate(date);
-  // earthCtrl.viewer.clock.currentTime = julianDate;
 
-  // // 2. 閰嶇疆鏃堕挓閫夐」锛岀姝㈣嚜鍔ㄦ帹杩涙椂闂�
-  earthCtrl.viewer.clockViewModel.shouldAnimate = false; // 绂佺敤鍔ㄧ敾
+  // 2. 閰嶇疆鏃堕挓閫夐」
+  earthCtrl.viewer.clockViewModel.shouldAnimate = false;
   earthCtrl.viewer.clockViewModel.clockRange =
-    SmartEarth.Cesium.ClockRange.CLAMPED; // 闄愬埗鏃堕棿鑼冨洿
-  earthCtrl.viewer.clockViewModel.multiplier = 0; // 璁剧疆鏃堕棿鎺ㄨ繘閫熷害涓�0
-  // 寮�鍚ぇ姘旀暎灏勬晥鏋�
-  earthCtrl.atmosphere.enable();
-  // 3. 璁剧疆褰撳墠鏃堕棿骞堕攣瀹�
+    SmartEarth.Cesium.ClockRange.CLAMPED;
+  earthCtrl.viewer.clockViewModel.multiplier = 0;
   earthCtrl.viewer.clock.currentTime = julianDate;
 
-  //鏄剧ずfps
+  // 鏄剧ずfps
   earthCtrl.showFPS = true;
 
-  // 绯荤粺鐩墠榛樿浣跨敤鐨�
+  // 鍏堟坊鍔犲簳鍥�
   earthCtrl.factory.createImageryLayer({
     sourceType: "mapworld",
     url: "http://t0.tianditu.com/img_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=img&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=7eb11c0c503429878691ac917238f87f",
@@ -139,13 +137,10 @@
     style: "default",
     format: "image/jpeg",
     maximumLevel: 18,
-    layer: "",
-    tileMatrixSetID: "",
   });
-  // 鍏抽棴鍦板舰娣卞害妫�娴�
-  // viewer.scene.globe.depthTestAgainstTerrain = false;
 }
 
+/////////////////////////鏂板缓鏂规鍖哄煙閫夋嫨/////////////////////////
 const MULTIPOLYGON_COORDS = ref([]);
 let previousEntities = []; // 鐢ㄤ簬瀛樺偍涔嬪墠鍒涘缓鐨勫疄浣�
 const flyToHeight = ref(null);
@@ -262,6 +257,7 @@
   clearPreviousEntities();
   flyToHomeView();
 });
+/////////////////////////鏂板缓鏂规鍖哄煙閫夋嫨/////////////////////////
 
 function addCityPolygon() {
   const url = `/json/110000.geo.json`;
@@ -283,8 +279,6 @@
       50000000
     );
     polygonEntity.forEach((entity) => {
-      // console.log("entity", entity)
-
       entity.polygon.material = new Cesium.ColorMaterialProperty(
         Cesium.Color.LIGHTSTEELBLUE.withAlpha(0)
         // new Cesium.Color.fromCssColorString("#0f2636b3")
@@ -388,136 +382,257 @@
   viewer.scene.camera.flyTo(view);
 }
 
-let htmlEntityList = [];
-function initDistrictCount() {
-  getDistrictCount().then((res) => {
-    res.data.forEach((item) => {
-      const { districtName, count, lat, lon } = item;
-      item.name = `${item.districtName}\n${item.count}`;
-      item.longitude = item.lon;
-      item.latitude = item.lat;
-      item.showBillboard = false;
-      item.showLabel = true;
-      item.label = {
-        text: item.name,
-        backgroundColor: SmartEarth.Cesium.Color.SKYBLUE.withAlpha(0.8),
-        font: "14pt Source Han Sans CN",
-        fillColor: SmartEarth.Cesium.Color.WHITE,
-        showBackground: true,
-      };
-      // createPoint(item)
-      const html = earthCtrl.view.createScreenDialog({
-        html: `
-						<div class="district-count">
-							<div class="name">${districtName}</div>
-							<div class="value">${count}</div>
-					</div>
-					`,
-        lon: item.lon,
-        lat: item.lat,
-        height: 0,
-      });
-      html.maxVisibleDistance = 69000;
-      html.minVisibleDistance = 20000;
-      html.element.addEventListener("click", () => {
-        viewer.camera.flyTo({
-          destination: Cesium.Cartesian3.fromDegrees(
-            item.longitude,
-            item.latitude,
-            12000
-          ),
-          orientation: {
-            pitch: Cesium.Math.toRadians(-90),
-            heading: Cesium.Math.toRadians(0),
-            roll: 0,
-          },
-          duration: 2,
-        });
-      });
+///////////////////////// 鍖哄煙鏍囪鐐圭鐞嗙郴缁� /////////////////////////
+// 瀛樺偍鎵�鏈夊垱寤虹殑HTML瀹炰綋锛堝湴鍥句笂鐨勬爣璁扮偣锛�
+const htmlEntityList = [];
+const wmsLayers = []; // 瀛樺偍鍒涘缓鐨刉MS鍥惧眰
 
-      htmlEntityList.push(html);
-    });
-  });
+// 璺敱瀵瑰簲鐨� WMS 鍥惧眰閰嶇疆
+const WMS_LAYER_MAP = {
+  "/zhjc": {
+    url: "http://192.168.56.106:8191/iserver/services/map-ywsj_view_jc_zkr_device_all_kb/wms130/ywsj_device_kb",
+  },
+  "/yhgl": {
+    url: "http://192.168.56.106:8191/iserver/services/map-ywsj_view_dz_zkr_point_kb/wms130/ywsj_yhd_kb",
+  },
+};
+
+// 缁熶竴绠$悊鎵�鏈夊尯鍩熸爣璁扮殑鏍峰紡閰嶇疆
+const ENTITY_CONFIG = {
+  label: {
+    backgroundColor: SmartEarth.Cesium.Color.SKYBLUE.withAlpha(0.8),
+    font: "14pt Source Han Sans CN",
+    fillColor: SmartEarth.Cesium.Color.WHITE,
+    showBackground: true,
+  },
+  showBillboard: false,
+  showLabel: true,
+};
+
+// 鍖哄煙绾у埆閰嶇疆
+const LEVEL_CONFIG = {
+  // 浜岀骇鍖哄煙
+  secondary: {
+    maxVisibleDistance: 69000,
+    minVisibleDistance: 20000,
+    flyToHeight: 12000,
+    wmsOptions: {
+      sourceType: "wms",
+      url: "", // 鍔ㄦ�佽缃�
+      layers: "0.1",
+      parameters: {
+        format: "image/png",
+        transparent: true,
+        version: "1.1.1",
+        srs: "EPSG:4326",
+        query_layers: "0.2",
+        info_format: "application/json",
+      },
+    },
+  },
+  // 涓�绾у尯鍩�
+  primary: {
+    maxVisibleDistance: 50000000,
+    minVisibleDistance: 70000,
+    flyToHeight: 45000,
+  },
+};
+
+// 鏇存柊 WMS 閰嶇疆鍑芥暟锛堟牴鎹綋鍓嶈矾鐢憋級
+function updateWmsLayerByRoute(currentPath) {
+  const config = WMS_LAYER_MAP[currentPath];
+  if (!config) return;
+
+  LEVEL_CONFIG.secondary.wmsOptions.url = config.url;
 }
-function initDistrictCountByCity() {
-  getDistrictCountByCity().then((res) => {
-    res.data.forEach((item) => {
-      const { districtName, count, lat, lon } = item;
-      item.name = `${item.districtName}\n${item.count}`;
-      item.longitude = item.lon;
-      item.latitude = item.lat;
-      item.showBillboard = false;
-      item.showLabel = true;
-      item.label = {
-        text: item.name,
-        backgroundColor: SmartEarth.Cesium.Color.SKYBLUE.withAlpha(0.8),
-        font: "14pt Source Han Sans CN",
-        fillColor: SmartEarth.Cesium.Color.WHITE,
-        showBackground: true,
-      };
-      // createPoint(item)
-      const html = earthCtrl.view.createScreenDialog({
-        html: `
-						<div class="district-count">
-							<div class="name">${districtName}</div>
-							<div class="value">${count}</div>
-					</div>
-					`,
-        lon: item.lon,
-        lat: item.lat,
-        height: 0,
-      });
-      html.maxVisibleDistance = 50000000;
-      html.minVisibleDistance = 70000;
-      html.element.addEventListener("click", () => {
-        viewer.camera.flyTo({
-          destination: Cesium.Cartesian3.fromDegrees(
-            item.longitude,
-            item.latitude,
-            45000
-          ),
-          orientation: {
-            pitch: Cesium.Math.toRadians(-90),
-            heading: Cesium.Math.toRadians(0),
-            roll: 0,
-          },
-          duration: 2,
-        });
-      });
 
-      htmlEntityList.push(html);
+// 鍒濆鍖栧尯鍩熺粺璁�
+function initDistrictCount(level = "secondary") {
+  const getPoint =
+    level === "secondary" ? getDistrictCount : getDistrictCountByCity;
+  const config = LEVEL_CONFIG[level];
+
+  getPoint()
+    .then((res) => {
+      res.data.forEach((item) => {
+        processDistrictItem(item, config, level); // 娣诲姞level鍙傛暟
+      });
+    })
+    .catch((error) => {
+      console.error(`鍒濆鍖�${level}绾у尯鍩熺粺璁″け璐�:`, error);
     });
+}
+
+// 澶勭悊鍗曚釜鍖哄煙椤�
+function processDistrictItem(item, config, level = "secondary") {
+  // 娣诲姞榛樿鍊�
+  normalizeItemData(item);
+  const html = createDistrictHtmlMarker(item, config);
+
+  if (level === "secondary") {
+    secondaryHandler(html, item, config);
+  } else {
+    primaryHandler(html, item, config);
+  }
+
+  htmlEntityList.push(html);
+}
+
+// 璁剧疆浜岀骇鍖哄煙鐐瑰嚮澶勭悊锛堝寘鍚玏MS鍥惧眰锛�
+function secondaryHandler(html, item, config) {
+  html.element.addEventListener("click", async () => {
+    try {
+      // 鍏堥鍚戠洰鏍囦綅缃�
+      await flyToDistrict(item.longitude, item.latitude, config.flyToHeight);
+
+      // 绉婚櫎鏃у浘灞�
+      removeAllWmsLayers();
+      // 寤舵椂1绉掑悗娣诲姞鏂板浘灞�
+      setTimeout(() => {
+        // 濡傛灉婊¤冻鍙鑼冨洿锛屽皾璇曢噸鏂板姞杞� WMS 鍥惧眰
+        const cameraHeight = viewer.camera.positionCartographic.height;
+        // loadWmsImg(cameraHeight);
+      }, 1000); // 1000姣 = 1绉�
+
+      // 璁剧疆WMS瑕佺礌鏌ヨ
+      setupWmsFeatureQuery();
+
+      // 娣诲姞鏂扮殑鐐瑰嚮浜嬩欢
+    } catch (error) {
+      console.error("鍖哄煙鐐瑰嚮澶勭悊澶辫触:", error);
+    }
   });
 }
 
-const validPaths = ["/", "/yhgl"];
+// 璁剧疆涓�绾у尯鍩熺偣鍑诲鐞�
+function primaryHandler(html, item, config) {
+  html.element.addEventListener("click", () => {
+    flyToDistrict(item.longitude, item.latitude, config.flyToHeight);
+    console.log(item.districtCode, "itemitemitemitem");
+  });
+}
+
+// 缁熶竴鏁版嵁鏍煎紡鍜屾坊鍔犻粯璁ら厤缃�
+function normalizeItemData(item) {
+  item.name = `${item.districtName}\n${item.count}`;
+  item.longitude = item.lon;
+  item.latitude = item.lat;
+  Object.assign(item, ENTITY_CONFIG);
+}
+
+// 鍒涘缓HTML鏍囪
+function createDistrictHtmlMarker(item, config) {
+  const html = earthCtrl.view.createScreenDialog({
+    html: `
+      <div class="district-count">
+        <div class="name">${item.districtName}</div>
+        <div class="value">${item.count}</div>
+      </div>
+    `,
+    lon: item.lon,
+    lat: item.lat,
+    height: 0,
+  });
+
+  html.maxVisibleDistance = config.maxVisibleDistance;
+  html.minVisibleDistance = config.minVisibleDistance;
+
+  return html;
+}
+
+// 椋炲悜鎸囧畾鍖哄煙
+function flyToDistrict(longitude, latitude, height) {
+  viewer.camera.flyTo({
+    destination: Cesium.Cartesian3.fromDegrees(longitude, latitude, height),
+    orientation: {
+      pitch: Cesium.Math.toRadians(-90),
+      heading: Cesium.Math.toRadians(0),
+      roll: 0,
+    },
+    duration: 2,
+  });
+}
+
+// 璺敱鐩戝惉
+const validPaths = ["/", "/yhgl", "/zhjc"];
 watch(
   () => route.fullPath,
   (val) => {
-    if (!validPaths.includes(val)) {
-      // clusterLayer.dataSource.show = false
-      htmlEntityList.forEach((item) => {
-        item.show = false;
-      });
-      removeCameraChange();
-    } else {
+    const isValidPath = validPaths.includes(val);
+
+    // 鏇存柊 WMS 鍥惧眰閰嶇疆
+    updateWmsLayerByRoute(val);
+
+    // 鎺у埗HTML瀹炰綋鏄剧ず
+    htmlEntityList.forEach((item) => {
+      item.show = isValidPath
+        ? isVisibleDistance(item.minVisibleDistance, item.maxVisibleDistance)
+        : false;
+    });
+
+    // 鎺у埗鐩告満鍙樺寲鐩戝惉
+    if (isValidPath) {
       handleCameraChange();
-      // clusterLayer.dataSource.show = true
-      htmlEntityList.forEach((item) => {
-        item.show = isVisibleDistance(
-          item.minVisibleDistance,
-          item.maxVisibleDistance
-        );
-      });
+
+      // 濡傛灉婊¤冻鍙鑼冨洿锛屽皾璇曢噸鏂板姞杞� WMS 鍥惧眰
+      const cameraHeight = viewer.camera.positionCartographic.height;
+      // loadWmsImg(cameraHeight);
+    } else {
+      removeCameraChange();
+      removeAllWmsLayers();
     }
   }
 );
-function handleCameraChange() {
-  viewer.camera.changed.addEventListener(toggleHtmlLayerByVisibleDistance);
+
+// 鑷姩鍔犺浇 WMS 鍥惧眰
+async function loadWmsImg(cameraHeight) {
+  const config = LEVEL_CONFIG.secondary;
+
+  // 鍒ゆ柇鏄惁澶勪簬浜岀骇鍙鑼冨洿鍐�
+  if (cameraHeight <= config.minVisibleDistance) {
+    // 濡傛灉褰撳墠娌℃湁WMS鍥惧眰锛屽垯鑷姩鍔犺浇绗竴涓簩绾х偣鐨刉MS鍥惧眰
+    if (wmsLayers.length === 0 && htmlEntityList.length > 0) {
+      const firstItem = htmlEntityList[0]; // 鍙互閫変换鎰忎竴涓簩绾х偣
+      removeAllWmsLayers(); // 娓呴櫎鍙兘瀛樺湪鐨勬畫鐣欏浘灞�
+
+      earthCtrl.factory
+        .createImageryLayer(config.wmsOptions)
+        .then((wmsLayer) => {
+          wmsLayers.push(wmsLayer);
+        });
+    } else {
+      // 宸叉湁鍥惧眰浣哢RL鍙樹簡锛岄渶瑕佹洿鏂�
+      const currentUrl = wmsLayers[0]?.imageryProvider?.url;
+      if (currentUrl !== config.wmsOptions.url) {
+        removeAllWmsLayers();
+        earthCtrl.factory
+          .createImageryLayer(config.wmsOptions)
+          .then((wmsLayer) => {
+            wmsLayers.push(wmsLayer);
+          });
+      }
+    }
+  } else if (cameraHeight > config.maxVisibleDistance && wmsLayers.length > 0) {
+    // 濡傛灉瓒呭嚭鍙鑼冨洿涓斿凡鏈塛MS鍥惧眰锛屽垯娓呴櫎
+    removeAllWmsLayers();
+    // 鍙互鍦ㄨ繖閲岀Щ闄や簨浠剁洃鍚櫒
+    if (clickHandler) {
+      clickHandler.destroy();
+      clickHandler = null;
+    }
+  }
 }
-function removeCameraChange() {
-  viewer.camera.changed.removeEventListener(toggleHtmlLayerByVisibleDistance);
+
+let clickHandler = null;
+
+// 绉婚櫎鎵�鏈塛MS鍥惧眰
+function removeAllWmsLayers() {
+  wmsLayers.forEach((layer) => {
+    layer.removeFromMap();
+  });
+  wmsLayers.length = 0; // 娓呯┖鏁扮粍
 }
+
 let cameraChangeTimer = null;
 
 function toggleHtmlLayerByVisibleDistance() {
@@ -526,27 +641,117 @@
     cameraChangeTimer = null;
     return;
   }
+
   cameraChangeTimer = setTimeout(() => {
+    const cameraHeight = viewer.camera.positionCartographic.height;
+
+    // 鏇存柊HTML瀹炰綋鏄剧ず鐘舵��
     htmlEntityList.forEach((item) => {
       item.show = isVisibleDistance(
         item.minVisibleDistance,
         item.maxVisibleDistance
       );
     });
+
+    // 妫�鏌ユ槸鍚﹂渶瑕佽嚜鍔ㄥ姞杞芥垨娓呴櫎WMS鍥惧眰
+    // loadWmsImg(cameraHeight);
   }, 100);
 }
 
+function handleCameraChange() {
+  viewer.camera.changed.addEventListener(toggleHtmlLayerByVisibleDistance);
+}
+
+function removeCameraChange() {
+  viewer.camera.changed.removeEventListener(toggleHtmlLayerByVisibleDistance);
+}
+
+// 鍒濆鍖栧嚱鏁�
+function initAllDistrictCounts() {
+  initDistrictCount("secondary"); // 浜岀骇鍖哄煙
+  initDistrictCount("primary"); // 涓�绾у尯鍩�
+}
+
+// 璁剧疆WMS瑕佺礌鏌ヨ
+function setupWmsFeatureQuery() {
+  // // 鍏堢Щ闄ゅ凡鏈夌殑浜嬩欢鐩戝惉锛堜笉鑳借锛岃浜嗕箣鍚庨殣鎮g偣灏变笉浼氳姹備簡锛�
+  // earthCtrl.viewer.screenSpaceEventHandler.removeInputAction(
+  //   Cesium.ScreenSpaceEventType.LEFT_CLICK
+  // );
+
+  // 娣诲姞鏂扮殑鐐瑰嚮浜嬩欢
+  earthCtrl.viewer.screenSpaceEventHandler.setInputAction(
+    handleMapClick,
+    Cesium.ScreenSpaceEventType.LEFT_CLICK
+  );
+}
+
+// 澶勭悊鍦板浘鐐瑰嚮鏌ヨ
+function handleMapClick(click) {
+  console.log("鐐瑰嚮灞忓箷浣嶇疆:", click.position);
+
+  // 1. 鑾峰彇鐐瑰嚮浣嶇疆鐨勫湴鐞嗗潗鏍�
+  const ray = viewer.camera.getPickRay(click.position);
+  if (!ray) {
+    console.log("鏃犳硶鑾峰彇鎷惧彇灏勭嚎");
+    return;
+  }
+
+  const cartesian = viewer.scene.globe.pick(ray, viewer.scene);
+  if (!cartesian) {
+    console.log("鏃犳硶鑾峰彇鍦扮悊鍧愭爣");
+    return;
+  }
+
+  // console.log("cartesian:", cartesian);
+
+  const cartographic = Cesium.Cartographic.fromCartesian(cartesian);
+  const longitude = Cesium.Math.toDegrees(cartographic.longitude);
+  const latitude = Cesium.Math.toDegrees(cartographic.latitude);
+  console.log("鐐瑰嚮浣嶇疆鍧愭爣:", longitude, latitude);
+
+  queryWmsFeatures(longitude, latitude, click.position);
+}
+
+// 鏌ヨWMS瑕佺礌
+function queryWmsFeatures(longitude, latitude, clickPosition) {
+  const wmsUrl = LEVEL_CONFIG.secondary.wmsOptions.url;
+  const params = new URLSearchParams({
+    SERVICE: "WMS",
+    VERSION: "1.1.1",
+    REQUEST: "GetFeatureInfo",
+    LAYERS: "0.1", // 鏌ヨ淇℃伅鎵�鍦ㄧ殑鍥惧眰
+    QUERY_LAYERS: "0.2",
+    INFO_FORMAT: "text/xml",
+    FEATURE_COUNT: "10", // 杩斿洖鏈�澶�10涓绱�
+    X: Math.floor(clickPosition.x),
+    Y: Math.floor(clickPosition.y),
+    SRS: "EPSG:4326",
+    WIDTH: viewer.canvas.width,
+    HEIGHT: viewer.canvas.height,
+    BBOX: [longitude - 1, latitude - 1, longitude + 1, latitude + 1].join(","),
+  });
+
+  const featureInfoUrl = wmsUrl + "?" + params.toString();
+  // console.log("璇锋眰URL:", featureInfoUrl);
+
+  // 3. 鍙戦�丟etFeatureInfo璇锋眰
+  fetch(featureInfoUrl)
+    .then((res) => res.text()) // 鍏堣幏鍙栨枃鏈�
+    .then((text) => {
+      // console.log(text);
+    });
+}
 onMounted(() => {
   initMap();
-  // 鍦ㄤ綘鐨勫垵濮嬪寲浠g爜涓皟鐢ㄨ繖涓嚱鏁�
   addCityPolygon();
   initHandler();
   // initView()
   loadAreaPolygon("/json/nsl_area.geojson");
   loadAreaPolygonAll("/json/geometry.json", true);
   flyToHomeView();
-  initDistrictCount();
-  initDistrictCountByCity();
+  // 椤甸潰鍔犺浇鏃跺垵濮嬪寲
+  initAllDistrictCounts();
   handleCameraChange();
   // 璁剧疆 billboard 鐐瑰嚮浜嬩欢
 });
diff --git a/src/views/left/KGSimOption/RealTimeSimulation.vue b/src/views/left/KGSimOption/RealTimeSimulation.vue
index d3192ae..29ca253 100644
--- a/src/views/left/KGSimOption/RealTimeSimulation.vue
+++ b/src/views/left/KGSimOption/RealTimeSimulation.vue
@@ -78,7 +78,7 @@
 import { initeWaterPrimitiveView } from "@/utils/water";
 import { SimAPIStore } from "@/store/simAPI";
 import { EventBus } from "@/eventBus"; // 寮曞叆浜嬩欢鎬荤嚎
-import { getDeviceInfo } from "@/api/hpApi";
+import { getDeviceInfoShg } from "@/api/hpApi";
 
 // 鑾峰彇 Store 瀹炰緥
 const simStore = SimAPIStore();
@@ -117,7 +117,7 @@
 const getRainListAll = () => {
   // 闆ㄩ噺璁$被鍨媔d
   const ids = "1874719366287368194";
-  getDeviceInfo(ids).then((res) => {
+  getDeviceInfoShg(ids).then((res) => {
     rainListNoFilter.value = res.data.pageData;
     // 鏍规嵁褰撳墠閫夋嫨鐨勫尯鍩熻嚜鍔ㄨ繃婊�
     updateShgListByArea();

--
Gitblit v1.9.3