From f373e0c0797e1800bf066fdfbb748bb9242230f6 Mon Sep 17 00:00:00 2001
From: wangjuncheng <1>
Date: 星期二, 08 七月 2025 17:46:02 +0800
Subject: [PATCH] 泥位计

---
 src/components/monifangzhen/schemeCard.vue |   88 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 87 insertions(+), 1 deletions(-)

diff --git a/src/components/monifangzhen/schemeCard.vue b/src/components/monifangzhen/schemeCard.vue
index c8c6c6e..0447eeb 100644
--- a/src/components/monifangzhen/schemeCard.vue
+++ b/src/components/monifangzhen/schemeCard.vue
@@ -79,6 +79,10 @@
   getSimresult,
 } from "@/api/trApi.js";
 
+import { getAeraTownCode, getDeviceNWJ } from "@/api/hpApi";
+import { createPoint, removeEntities, clearAllPoints } from "@/utils/map";
+import { deviceDictList, getDictName } from "@/constant/dict.js";
+
 const simStore = useSimStore();
 const simAPIStore = SimAPIStore();
 // 閫変腑鐨勬柟妗� ID
@@ -114,7 +118,89 @@
 
 const { startSimulate, endSimulate } = inject("simulateActions");
 
+const BJCode = ref([
+  { label: "瀵嗕簯鍖�", value: "110118000000" },
+  { label: "鎴垮北鍖�", value: "110111000000" },
+  { label: "闂ㄥご娌熷尯", value: "110109000000" },
+  { label: "寤跺簡鍖�", value: "110119000000" },
+  { label: "鎬�鏌斿尯", value: "110116000000" },
+  { label: "鏄屽钩鍖�", value: "110114000000" },
+  { label: "骞宠胺鍖�", value: "110117000000" },
+  { label: "娴锋穩鍖�", value: "110108000000" },
+  { label: "鐭虫櫙灞卞尯", value: "110107000000" },
+  { label: "涓板彴鍖�", value: "110106000000" },
+]);
+
 async function startPlay(item) {
+  simStore.openDia = false;
+  clearAllPoints();
+  const areaName = item.areaName;
+
+  let districtCode;
+
+  // 1. 鍒ゆ柇鏄惁鍖呭惈 鈥滃尯鈥�
+  if (!areaName.includes("鍖�")) {
+    console.log(
+      `鏂规涓ā鎷熴��${areaName}銆戜笉鍖呭惈鈥滃尯鈥濓紝浣跨敤榛樿缂栫爜锛氭��鏌斿尯(110116000000)`
+    );
+    districtCode = "110116000000"; // 鎵嬪姩鎸囧畾涓烘��鏌斿尯缂栫爜
+  } else {
+    // 2. 鍦� BJCode 涓煡鎵惧尮閰嶇殑鍖哄煙 value
+    const matchedArea = BJCode.value.find((area) => area.label === areaName);
+
+    if (!matchedArea) {
+      console.warn(`鏈壘鍒� ${areaName} 瀵瑰簲鐨勫尯鍩熺紪鐮乣);
+      return;
+    }
+
+    districtCode = matchedArea.value;
+  }
+
+  // 1. 鑾峰彇涔¢晣鍖哄煙缂栫爜
+  const areaRes = await getAeraTownCode(districtCode);
+  const districtCodes = areaRes.data.map((item) => item.districtCode);
+
+  // 2. 娉ヤ綅璁$被鍨婭D
+  const ids = "1437295811";
+
+  // 3. 骞惰璇锋眰鎵�鏈夎澶囨暟鎹�
+  const requests = districtCodes.map((code) =>
+    getDeviceNWJ(ids, code)
+      .then((res) => res.data?.pageData || []) // 瀹夊叏鎻愬彇 pageData
+      .catch((err) => {
+        console.error(`璇锋眰澶辫触 (code: ${code})`, err);
+        return []; // 鍑洪敊鏃朵篃杩斿洖绌烘暟缁勶紝閬垮厤 Promise.all 涓柇
+      })
+  );
+
+  // 4. 绛夊緟鎵�鏈夎姹傚畬鎴�
+  const allPageDataArrays = await Promise.all(requests);
+
+  // 5. 鍚堝苟浜岀淮鏁扮粍涓轰竴缁存暟缁�
+  const mergedPageData = allPageDataArrays.flat();
+
+  // 6. 濡傛灉涓嶆槸鈥滃尯鈥濓紝鍒欒繃婊ゅ嚭 deviceName 鍖呭惈 "瀛欒儭娌�" 鐨勮澶�
+  const filteredPageData = areaName.includes("鍖�")
+    ? mergedPageData
+    : mergedPageData.filter((device) => device.deviceName.includes("瀛欒儭娌�"));
+
+  console.log(
+    filteredPageData,
+    areaName.includes("鍖�") ? "鍏ㄩ儴娉ヤ綅璁¤澶囧垪琛�" : "瀛欒儭娌熸偿浣嶈璁惧鍒楄〃"
+  );
+
+  // 7. 鍒涘缓鐐�
+  filteredPageData.forEach((item) => {
+    // 鏍规嵁闇�姹傚彲澧炲垹
+    item.type = getDictName(deviceDictList, item.dictDeviceType);
+    item.name = item.deviceName;
+    item.id = item.deviceId;
+    item.className = "device";
+    item.showLabel = true;
+
+    createPoint(item);
+  });
+
   if (item.status === 2) {
     ElMessage.warning("褰撳墠鏂规姝e湪鍒嗘瀽涓�,鏃犳硶杩涘叆妯℃嫙锛�");
     return;
@@ -221,7 +307,7 @@
         item.result == "鍒涘缓浠跨湡" ||
         item.result == "瀹屾垚" ||
         item.result == "-1" ||
-        item.result == "鍋滄" ||
+        item.result == "宸插仠姝�" ||
         item.result == "杩愯涓�"
     );
     simAPIStore.shouldPoll = !shouldStop; // 淇敼 Pinia 鐘舵��

--
Gitblit v1.9.3