From b040d81c856a77f280b38037e78a8b6a8bdb31ab Mon Sep 17 00:00:00 2001 From: guonan <guonan201020@163.com> Date: 星期二, 08 七月 2025 15:51:15 +0800 Subject: [PATCH] 泥位计 --- src/components/tools/LayerTree.vue | 1 src/utils/map.js | 22 ++++- src/api/hpApi.js | 15 +++ src/components/menu/Device.vue | 3 src/store/simulation.js | 5 + src/components/menu/TimeLine.vue | 100 ++++++++++++++++++------ src/components/monifangzhen/schemeCard.vue | 86 +++++++++++++++++++++ 7 files changed, 200 insertions(+), 32 deletions(-) diff --git a/src/api/hpApi.js b/src/api/hpApi.js index 2d609df..e3df69f 100644 --- a/src/api/hpApi.js +++ b/src/api/hpApi.js @@ -146,7 +146,20 @@ return response.data; } -// 鏌ヨ瀛欒儭娌熺洃娴嬭澶� +// 鎺ュ彛澶氬啓鍑犱釜搴旇鏃犲Θ鍚� +export async function getDeviceNWJ(data, townCode) { + const response = await axios.post("/hp/deviceInfo/getData", { + filterObject: { + "dictDeviceTypeList": [data], + "townCodeList": [townCode], + "year": 2025, + }, + "pageSize": 10000 + }); + return response.data; +} + +// 鏌ヨ瀛欒儭娌熺洃娴嬭澶囷紝dictCommunicationType涓烘煡璇㈠瓩鑳℃矡鐨勯洦閲忚 export async function getDeviceInfoSHG(data) { const response = await axios.post("/hp/deviceInfo/getData", { filterObject: { diff --git a/src/components/menu/Device.vue b/src/components/menu/Device.vue index daf8ff3..a055fb9 100644 --- a/src/components/menu/Device.vue +++ b/src/components/menu/Device.vue @@ -106,7 +106,7 @@ <script setup> import { ref, computed, onMounted, watch, onBeforeUnmount } from "vue"; import { useRoute, onBeforeRouteUpdate } from "vue-router"; -import { createPoint, removeEntities, clearAllPoints } from "@/utils/map"; +import { createPoint, clearAllPoints } from "@/utils/map"; import { deviceDictList, getDictName } from "@/constant/dict.js"; import { initeWaterPrimitiveView } from "@/utils/water"; //鐩告満flyTo鍑芥暟锛屽悗缁璷ptions鍒楄〃涓湁瀵瑰簲缁忕含搴﹀悗寮冪敤 import { useSimStore } from "@/store/simulation"; @@ -177,6 +177,7 @@ }); }; +// 鍗曚釜鐐规覆鏌� const DevicePoints = async (item) => { // 鏍规嵁闇�姹傚彲澧炲垹 item.type = getDictName(deviceDictList, item.dictDeviceType); diff --git a/src/components/menu/TimeLine.vue b/src/components/menu/TimeLine.vue index 0337415..649f970 100644 --- a/src/components/menu/TimeLine.vue +++ b/src/components/menu/TimeLine.vue @@ -2,20 +2,30 @@ <div class="timeline-container"> <div class="controls"> <div class="control-btn" @click="skipBackward"> - <img src="@/assets/img/timeline/left.png" class="fas fa-step-backward" /> + <img + src="@/assets/img/timeline/left.png" + class="fas fa-step-backward" + /> </div> <div class="control-btn play-btn" @click="togglePlay"> <img v-show="isPlaying" src="@/assets/img/timeline/stop.png" /> <img v-show="!isPlaying" src="@/assets/img/timeline/start.png" /> </div> <div class="control-btn" @click="skipForward"> - <img src="@/assets/img/timeline/right.png" class="fas fa-step-forward" /> + <img + src="@/assets/img/timeline/right.png" + class="fas fa-step-forward" + /> </div> <div class="speed-control" v-show="speedShow"> <div @click="toggleSpeedMenu">{{ playbackRate }}X</div> <div class="speed-menu" v-show="showSpeedMenu"> - <div v-for="rate in playbackRates" :key="rate" @click.capture="setPlaybackRate(rate)" - :class="{ active: playbackRate === rate }"> + <div + v-for="rate in playbackRates" + :key="rate" + @click.capture="setPlaybackRate(rate)" + :class="{ active: playbackRate === rate }" + > {{ rate }}X </div> </div> @@ -25,19 +35,33 @@ <div class="timeline"> <div class="dates"> <div class="current-date">褰撳墠鎾斁鏃堕棿锛歿{ currentPlayingTime }}</div> - <div v-for="(date, index) in visibleDates" :key="index" class="date-label"> + <div + v-for="(date, index) in visibleDates" + :key="index" + class="date-label" + > <!-- {{ formatDate(date) }} --> </div> <div> 涓撻娓叉煋: - <el-switch v-model="isColorRenderEnabled" @change="handleColorRenderChange" style="margin-top: -3px" - :disabled="!isPlaying || !isWaterPrimitiveCreated" /> + <el-switch + v-model="isColorRenderEnabled" + @change="handleColorRenderChange" + style="margin-top: -3px" + :disabled="!isPlaying || !isWaterPrimitiveCreated" + /> <!-- active-text="寮�" inactive-text="鍏�" --> </div> </div> <div class="timeline-track" ref="timelineTrack" @click="seekToPosition"> - <div class="timeline-progress" :style="{ width: progressPercentage + '%' }"></div> - <div class="timeline-cursor" :style="{ left: progressPercentage + '%' }"></div> + <div + class="timeline-progress" + :style="{ width: progressPercentage + '%' }" + ></div> + <div + class="timeline-cursor" + :style="{ left: progressPercentage + '%' }" + ></div> <div class="scale-markers"> <div class="scale-marker" style="left: 0%"></div> <div class="scale-marker" style="left: 25%"></div> @@ -46,8 +70,12 @@ <div class="scale-marker" style="left: 100%"></div> </div> <div class="time-markers"> - <div v-for="(time, index) in timeMarkers" :key="index" class="time-marker" - :style="{ left: `${index * 25}%`, transform: 'translateX(-50%)' }"> + <div + v-for="(time, index) in timeMarkers" + :key="index" + class="time-marker" + :style="{ left: `${index * 25}%`, transform: 'translateX(-50%)' }" + > <div class="date-part">{{ time.split(" ")[0] }}</div> <div class="time-part">{{ time.split(" ")[1] }}</div> </div> @@ -56,27 +84,38 @@ </div> <div> <div style="display: flex"> - <ratelevel ref="ratelevelRef" :playing-time="sendCurrentPlayingTime" - @finish-calculation="handleFinishCalculation" style=" + <ratelevel + ref="ratelevelRef" + :playing-time="sendCurrentPlayingTime" + @finish-calculation="handleFinishCalculation" + style=" margin-top: 12px; margin-left: 28px; margin-right: 10px; justify-content: flex-end; - " /> - <crossanalysis ref="crossRef" style=" + " + /> + <crossanalysis + ref="crossRef" + style=" margin-top: 12px; margin-left: 16px; margin-right: 20px; justify-content: flex-end; - " /> + " + /> </div> - <el-button @click="handleBack" style=" + <el-button + @click="handleBack" + style=" margin-top: 3px; margin-left: 28px; margin-right: 10px; width: 75%; height: 30%; - ">缁撴潫妯℃嫙</el-button> + " + >缁撴潫妯℃嫙</el-button + > </div> </div> </template> @@ -114,7 +153,9 @@ import { useSimStore } from "@/store/simulation"; import { storeToRefs } from "pinia"; const simStore = useSimStore(); -const { selectedScheme, frameNum, layerDate, schemWaterInfo } = storeToRefs(simStore); +const { selectedScheme, frameNum, layerDate, schemWaterInfo } = + storeToRefs(simStore); +import { clearAllPoints } from "@/utils/map"; const emit = defineEmits([ "timeUpdate", @@ -352,7 +393,7 @@ // 闄嶉洦鏁版嵁鐩稿叧鍙橀噺 let rainFallValues = ref([]); // 瀛樺偍鍘熷闄嶉洦閲忔暟鎹� let minRainValue = ref(Infinity); -let averageRainIntensity = ref() +let averageRainIntensity = ref(); let maxRainValue = ref(-Infinity); // 鑾峰彇闄嶉洦鏁版嵁 function getRainfallData() { @@ -435,7 +476,10 @@ rainFallValues.value = hourlyRainfallList.map((r) => r.intensity); // 璁$畻骞冲潎闆ㄥ己 if (rainFallValues.value.length > 0) { - const sumIntensity = rainFallValues.value.reduce((sum, val) => sum + val, 0); + const sumIntensity = rainFallValues.value.reduce( + (sum, val) => sum + val, + 0 + ); averageRainIntensity.value = sumIntensity / rainFallValues.value.length; } else { averageRainIntensity.value = 0; // 鎴栬�� null 琛ㄧず鏃犳暟鎹� @@ -451,7 +495,6 @@ minRainValue.value, maxRainValue.value ); - } // 瀹氫箟闄嶉洦绛夌骇鍙婂叾瀵瑰簲鐨勮瑙夊弬鏁� const rainLevels = [ @@ -709,7 +752,8 @@ // console.log("========================================"); // console.log(`銆愭椂闂存埑銆�: ${new Date(currentTimeMs).toLocaleString()}`); console.log( - `銆愮疮璁¢檷闆ㄩ噺 R銆�: ${currentTotal !== null ? currentTotal.toFixed(2) : "鏈煡" + `銆愮疮璁¢檷闆ㄩ噺 R銆�: ${ + currentTotal !== null ? currentTotal.toFixed(2) : "鏈煡" } mm` ); // console.log(`銆愬綋鍓嶉樁娈点��: 绗� ${currentStage} 闃舵`); @@ -982,8 +1026,12 @@ watersMaxHeight, watersMinHeight ); - const waterInfoArr = [watersMaxHeight, maxRainValue.value,averageRainIntensity.value] - schemWaterInfo.value = waterInfoArr + const waterInfoArr = [ + watersMaxHeight, + maxRainValue.value, + averageRainIntensity.value, + ]; + schemWaterInfo.value = waterInfoArr; // 鏇存柊鏃堕棿杞寸浉鍏虫暟鎹� if (timestamps) { frameNum.value = timestamps.length; @@ -1103,6 +1151,8 @@ } async function endSimulation() { + clearAllPoints(); + simStore.openDia = true; // 缁撴潫妯℃嫙涔嬪悗娓呴櫎layer鍒楄〃 simStore.rePlayList = []; console.log(simStore.rePlayList, "缁撴潫妯℃嫙娓呴櫎rePlayListrePlayList鍒楄〃"); diff --git a/src/components/monifangzhen/schemeCard.vue b/src/components/monifangzhen/schemeCard.vue index a3c6507..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; diff --git a/src/components/tools/LayerTree.vue b/src/components/tools/LayerTree.vue index d2cf58a..cbe28aa 100644 --- a/src/components/tools/LayerTree.vue +++ b/src/components/tools/LayerTree.vue @@ -323,7 +323,6 @@ */ function addTetrahedron() { getSafePoint().then((res) => { - console.log(res,'resresresres') const geoJsonData = convertToGeoJson(res.data); // 杞崲涓� GeoJSON // 鍔犺浇 GeoJSON 鏁版嵁鍒板湴鍥� loadAreaPolygon(geoJsonData, true).then((entities) => { diff --git a/src/store/simulation.js b/src/store/simulation.js index d090634..f4b9f57 100644 --- a/src/store/simulation.js +++ b/src/store/simulation.js @@ -2,6 +2,7 @@ import { defineStore } from 'pinia' import { ref } from 'vue' export const useSimStore = defineStore('simulation', () => { + const openDia = ref(true) // 鍘嗗彶鍥炴斁鍒楄〃 const rePlayList = ref([]) // 鍖椾含甯傛墍鏈夋潙鐨刢ode @@ -16,6 +17,8 @@ const DeviceShowSwitch = ref(false) const DangerShowSwitch = ref(false) const DangerPoint = ref([]) + // 娉ヤ綅璁� + const selectNWJ = ref() // 鐩戞祴璁惧鍒楄〃 const devices = ref([]) const navigationShow = ref(true) @@ -218,6 +221,8 @@ schemWaterInfo, layerDate, rePlayList, + selectNWJ, + openDia, // 鏂规鐩稿叧鏂规硶 setSchemCard, diff --git a/src/utils/map.js b/src/utils/map.js index 75dc1d0..25a7ef8 100644 --- a/src/utils/map.js +++ b/src/utils/map.js @@ -1,5 +1,8 @@ import { showDeviceDetail, deviceDetail, className, dialogPositon } from "@/store"; -import { componentToSlot } from "element-plus/es/components/table-v2/src/utils.mjs"; + +import { useSimStore } from '@/store/simulation' + + export function addTerrain(url) { // console.log("鍔犺浇鍦板舰"); var terrainProvider = new Cesium.CesiumTerrainProvider({ @@ -84,7 +87,7 @@ // 濡傛灉宸茬粡瀛樺湪璇� id 鐨� entity锛屽垯璺宠繃鍒涘缓 if (pointEntityMap.has(id)) { clearAllPoints() - console.log(`鐐� ${id} 宸插瓨鍦紝璺宠繃鍒涘缓`); + console.log(`鐐� ${id} 宸插瓨鍦紝宸叉竻闄ら噸寤篳); } let position = Cesium.Cartesian3.fromDegrees(longitude, latitude, height || 50); @@ -196,8 +199,19 @@ if (Cesium.defined(picked) && id) { const entity = picked?.id; - console.log(entity.attrs, 'attrsattrsattrs') - if (entity && entity.className) { + const simStore = useSimStore() + + if (entity && !simStore.openDia) { + let obj = { + deviceName: entity.attrs.deviceName, + latitude: entity.attrs.latitude, + longitude: entity.attrs.longitude + } + simStore.selectNWJ = obj + showDeviceDetail.value = false; + console.log(simStore.selectNWJ, 'map.js鐐瑰嚮娉ヤ綅璁�') + } + if (entity && entity.className && simStore.openDia) { showDeviceDetail.value = true; deviceDetail.value = entity.attrs; className.value = entity.className; -- Gitblit v1.9.3