public/CimSDK/Workers/Model/ModelLibrary.html | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
public/json/rainfall.json | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/api/trApi.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/components/menu/TimeLine.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/components/monifangzhen/schemeCard.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/store/simulation.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/left/CitySim.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/left/KGSimOption/RealTimeSimulation.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
vue.config.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
public/CimSDK/Workers/Model/ModelLibrary.html
@@ -148,7 +148,7 @@ var Viewer = parent.earthCtrl.viewer; var sgworld = parent.earthCtrl; var Cesium = parent.Cesium; var ModelLibraryURL = 'http://192.168.56.107:8088/ModelLibrary/' var ModelLibraryURL = 'http://192.168.37.60:8088/ModelLibrary/' var imgRootURL = ModelLibraryURL + 'image/'; //è·åæ°æ® public/json/rainfall.json
ÎļþÒÑɾ³ý src/api/trApi.js
@@ -81,6 +81,28 @@ throw error; } } // 宿¶æ¨¡æçç»æ export async function getSimresult(ids) { try { const res = await instance.get(`/simu/results?id=${ids}`); return res.data; } catch (error) { console.error("Error deleting simulation data:", error); throw error; } } // ç»æå®æ¶æ¨¡æ export async function stopSim(ids) { try { const res = await instance.get(`/simu/stop?id=${ids}`); return res.data; } catch (error) { console.error("Error deleting simulation data:", error); throw error; } } // ************************************************************************************************************** // è§£æjsonè·åæ³¥ç³æµåæ° export function parseWaterSimulationData(jsonData) { 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> @@ -107,9 +146,9 @@ updateWaterColor, } from "@/utils/water"; import mapUtils from "@/utils/tools.js"; import { fetchWaterSimulationData } from "@/api/trApi.js"; import { fetchWaterSimulationData, stopSim } from "@/api/trApi.js"; import { EventBus } from "@/eventBus"; import { ElMessage } from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus"; // ç¶æç®¡çå¨ import { useSimStore } from "@/store/simulation"; import { storeToRefs } from "pinia"; @@ -278,7 +317,8 @@ const startPlayback = () => { clearInterval(playInterval); if (selectedScheme.value.type === 2) { // æ°å»ºæ¹æ¡ä¸ç宿¶æ¨¡æä¸è½åé if (selectedScheme.value.type === 2 && simStore.rePlayList.length == 0) { // ç±»å为 2ï¼æ¯ 5 ç§è·³å¨ä¸æ¬¡ playInterval = setInterval(() => { const fiveSeconds = 5; @@ -541,9 +581,9 @@ // å ¨å±ç¶æè®°å½ const colorState = { currentColor: "#F5F0E6", // å½åé¢è² currentAlpha: -0.3, // å½åéæåº¦ colorStages: null, // é¢è®¡ç®çé¢è²é¶æ®µæ¶é´ç¹ maxColorTime: null // è®°å½è¾¾å°ææ·±é¢è²æ¶çæ¶é´ç¹ currentAlpha: -0.3, // å½åéæåº¦ colorStages: null, // é¢è®¡ç®çé¢è²é¶æ®µæ¶é´ç¹ maxColorTime: null, // è®°å½è¾¾å°ææ·±é¢è²æ¶çæ¶é´ç¹ }; // é¢è®¡ç®é¢è²é¶æ®µæ¶é´ç¹ @@ -556,17 +596,17 @@ { hex: "#D4B483", luminance: 184.0 }, // stage 2 { hex: "#B78B6A", luminance: 148.4 }, // stage 3 { hex: "#8B5A3A", luminance: 101.0 }, // stage 4 { hex: "#744C33", luminance: 84.5 }, // stage 5 { hex: "#5D3D2C", luminance: 68.1 } // stage 6 { hex: "#744C33", luminance: 84.5 }, // stage 5 { hex: "#5D3D2C", luminance: 68.1 }, // stage 6 ]; const alphaStops = [ -0.2, // stage 0 -0.3, // stage 1 -0.4, // stage 2 -0.5, // stage 3 -0.6, // stage 4 -0.7, // stage 5 -0.8 // stage 6 -0.2, // stage 0 -0.3, // stage 1 -0.4, // stage 2 -0.5, // stage 3 -0.6, // stage 4 -0.7, // stage 5 -0.8, // stage 6 ]; // 累计éé¨ééå¼ï¼mmï¼ const R_THRESHOLDS = [0, 200, 240, 280, 310, 350]; // å ±6ä¸ªé¶æ®µå¯¹åº6个éå¼ @@ -579,7 +619,7 @@ const total = rainTotalInfo.value[i].total; // ä½¿ç¨ total æ¿ä»£ intensity timeTotals.push({ time, total total, }); } @@ -594,7 +634,7 @@ startTime: time, color: COLOR_STOPS[stage].hex, alpha: alphaStops[stage], threshold threshold, }; break; } @@ -606,7 +646,7 @@ startTime: 0, color: COLOR_STOPS[0].hex, alpha: alphaStops[0], threshold: 0 threshold: 0, }; colorState.colorStages = stages; @@ -623,7 +663,10 @@ // æ¥æ¾å½åæ¶é´ç¹æå±çé¶æ®µ let currentStage = 0; for (let i = colorState.colorStages.length - 1; i >= 0; i--) { if (colorState.colorStages[i] && currentTime.value >= colorState.colorStages[i].startTime) { if ( colorState.colorStages[i] && currentTime.value >= colorState.colorStages[i].startTime ) { currentStage = i; break; } @@ -631,15 +674,21 @@ // è®°å½è¾¾å°ææ·±é¢è²çæ¶é´ç¹ if (currentStage >= colorState.colorStages.length - 1) { if (colorState.maxColorTime === null || currentTime.value > colorState.maxColorTime) { if ( colorState.maxColorTime === null || currentTime.value > colorState.maxColorTime ) { colorState.maxColorTime = currentTime.value; } } // 夿æ¯å¦éè¦å¼ºå¶æ´æ°é¢è² const isTimeGoingBackward = currentTime.value < colorState.lastTime; const isBeforeMaxColorTime = colorState.maxColorTime !== null && currentTime.value <= colorState.maxColorTime; const shouldForceUpdate = isForceUpdate && (isTimeGoingBackward || isBeforeMaxColorTime); const isBeforeMaxColorTime = colorState.maxColorTime !== null && currentTime.value <= colorState.maxColorTime; const shouldForceUpdate = isForceUpdate && (isTimeGoingBackward || isBeforeMaxColorTime); // æ´æ°é¢è²é»è¾ if (shouldForceUpdate || isTimeGoingBackward) { @@ -652,7 +701,9 @@ const newAlpha = colorState.colorStages[currentStage].alpha; // åªåºç¨æ´æçé¢è²åæ´ä½çéæåº¦ if (calculateLuminance(newColor) < calculateLuminance(colorState.currentColor)) { if ( calculateLuminance(newColor) < calculateLuminance(colorState.currentColor) ) { colorState.currentColor = newColor; } if (newAlpha < colorState.currentAlpha) { @@ -717,7 +768,8 @@ // 夿æ¯å¦éè¦å¼ºå¶æ´æ°é¢è² const isGoingBackward = newTime < currentTime.value; const isBeforeMaxColor = colorState.maxColorTime !== null && newTime <= colorState.maxColorTime; const isBeforeMaxColor = colorState.maxColorTime !== null && newTime <= colorState.maxColorTime; const shouldForceUpdate = isGoingBackward || isBeforeMaxColor; currentTime.value = newTime; @@ -910,16 +962,25 @@ ); const jsonFetch = ref(null); const currentReplayIndex = ref(0); // å½åææ¾çrePlayListç´¢å¼ // æå为ç¬ç«å½æ° async function initializeSimulationData(force = false) { async function initializeSimulationData(replayItem = null) { try { const schemeInfo = selectedScheme.value; serviceInfo = schemeInfo.serviceName; if (schemeInfo.type == 2) { speedShow.value = false; jsonFetch.value = layerDate.value; if ( replayItem || (simStore.rePlayList && simStore.rePlayList.length != 0) ) { jsonFetch.value = replayItem || simStore.rePlayList[currentReplayIndex.value]; speedShow.value = true; } else { jsonFetch.value = layerDate.value; speedShow.value = false; } } else { getRainfallData(); speedShow.value = true; @@ -962,11 +1023,36 @@ } } // æè½½æ¶è°ç¨ onMounted(async () => { // å 为è¿ä¸ªå½æ°å®æ¶æ¨¡æçå¬ä¹éè¦ä½¿ç¨ï¼æä»¥å°è£ äºä¸ä¸ªå½æ° await initializeSimulationData(); }); // ææ¾å®æåçåè° function handlePlayFinished() { if (selectedScheme.value.type !== 2) return; finishPlay.value = false; currentReplayIndex.value++; if (currentReplayIndex.value < simStore.rePlayList.length) { console.log(currentReplayIndex.value); // èªå¨ææ¾ä¸ä¸ä¸ª initializeSimulationData(simStore.rePlayList[currentReplayIndex.value]); togglePlay(); shouldAutoPlay.value = false; } else { // ææé¡¹ç®ææ¾å®æ currentReplayIndex.value = 0; // éç½®ç´¢å¼ isPlaying.value = false; // åæ¢ææ¾ } } // ç嬿æ¾å®æäºä»¶ watch( () => finishPlay.value, (newVal) => { if (newVal && selectedScheme.value.type === 2) { handlePlayFinished(); } } ); const shouldAutoPlay = ref(false); // çå¬ layerDate åååæ è®°åå¤ææ¾ watch( @@ -986,6 +1072,13 @@ shouldAutoPlay.value = false; } }); // æè½½æ¶è°ç¨ onMounted(async () => { // å 为è¿ä¸ªå½æ°å®æ¶æ¨¡æçå¬ä¹éè¦ä½¿ç¨ï¼æä»¥å°è£ äºä¸ä¸ªå½æ° await initializeSimulationData(); }); // æ ¹æ®è¿åæ°æ®ç个æ°å»æ¸²ææ¶é´è½´ function updateTimelineRange() { if (waterTimestamps.value.length > 0) { @@ -1002,28 +1095,63 @@ }); const { endSimulate } = inject("simulateActions"); function handleBack() { endSimulate(); // 忢宿¶æ¨¡æå®æ¶å¨ EventBus.emit("close-time"); async function handleBack() { // 宿¶æ¨¡æå¼¹çªç¡®è®¤æ¯è¿åæ¹æ¡åè¡¨è¿æ¯åæ¢æ¨¡æ if (selectedScheme.value.type === 2) { try { await ElMessageBox.confirm("æ¹æ¡æªåæ¢æ¶ç»ææ¨¡æåï¼åå°å°åæ¢è®¡ç®", { confirmButtonText: "è¿åå表", cancelButtonText: "ç»ææ¨¡æ", type: "warning", }); // ç¨æ·ç¹å»äºç¡®è®¤ï¼è¿é䏿§è¡ä»»ä½æä½ï¼ä» å ³éå¯¹è¯æ¡ } catch (error) { stopSim(selectedScheme.value.id).then((res) => { if (res.code == 404) { ElMessage.warning("该æå¡å·²åæ¢"); } else { ElMessage.success("æå¡æ£å¨åæ¢ä¸"); } }); // return; } } // ä¸ç®¡typeæ¯ä¸æ¯2ï¼æç»é½æ§è¡ç»ææ¨¡æçæä½ endSimulation(); } async function endSimulation() { EventBus.emit("close-time"); endSimulate(); isWaterPrimitiveCreated.value = false; // ç»æè®¡ç®å忢æ¾å if (ratelevelRef.value) { ratelevelRef.value.endCalculation(); ratelevelRef.value.stopPicking(); } // æ¸ é¤ç¹ if (crossRef.value) { crossRef.value.clearPoints(); console.log("æ§è¡å é¤ç¹åè½"); } emit("isColorRender", false); // å»¶è¿å é¤é¨éå¾å± setTimeout(() => { mapUtils.delRain(); }, 3000); destoryWaterPrimitive(); // åéäºä»¶éèç¸å ³ä¿¡æ¯ EventBus.emit("hide-schemeInfo"); EventBus.emit("clear-water-depth"); EventBus.emit("clear-water-velocity"); ElMessage({ message: "模æè¿ç¨æ£å¨å ³éä¸...", type: "success" }); } </script> src/components/monifangzhen/schemeCard.vue
@@ -29,6 +29,9 @@ @click="startPlay(item)" >è¿å ¥æ¨¡æ</el-button > <el-button size="small" v-show="item.type == 2" @click="rePlay(item)" >åå²åæ¾</el-button > <!-- :disabled="item.status !== 2" --> </div> </div> @@ -50,7 +53,15 @@ <script setup> import { EventBus } from "@/eventBus"; // å¼å ¥äºä»¶æ»çº¿ import { onMounted, ref, watch, defineEmits, onUnmounted } from "vue"; import { nextTick, onMounted, ref, watch, defineEmits, onUnmounted, inject, } from "vue"; import dayjs from "dayjs"; import { initeWaterPrimitiveView } from "@/utils/water"; import Message from "@/components/tools/Message.vue"; @@ -61,11 +72,11 @@ import { ElMessage, ElMessageBox } from "element-plus"; const emit = defineEmits(["start", "end", "reset", "closeBtn"]); import { getRegionData, getSimData, deleteSimData, getSimStart, getSimDataById, getSimresult, } from "@/api/trApi.js"; const simStore = useSimStore(); @@ -101,8 +112,9 @@ // 宿¶æ¨¡æäºåé请æ±ä¸æ¬¡ç宿¶å¨ const realTimeSimInterval = ref(null); const { startSimulate, endSimulate } = inject("simulateActions"); async function startPlay(item) { console.log(item, "item"); if (item.status === 2) { ElMessage.warning("å½åæ¹æ¡æ£å¨åæä¸,æ æ³è¿å ¥æ¨¡æï¼"); return; @@ -131,7 +143,7 @@ currentScheme.value = item; schemeInfoShow.value = true; emit("closeBtn", false); emit("start"); startSimulate(); return; } @@ -151,47 +163,35 @@ return; } // å¤ç type == 2 çæ åµï¼å®æ¶æ¨¡æï¼ if (item.type === 2) { // æ¸ é¤å·²æå®æ¶å¨ï¼é²æ¢éå¤å¯å¨ if (realTimeSimInterval.value) { clearInterval(realTimeSimInterval.value); } // å³å»æ§è¡ä¸æ¬¡ await executeRealTimeSimulation(item); // æ¯é 5 åéæ§è¡ä¸æ¬¡ realTimeSimInterval.value = setInterval(() => { executeRealTimeSimulation(item); }, 5 * 60 * 1000); // 5åé return; } // é»è®¤æ åµï¼ææå¡åç§° simStore.setSelectedScheme(item); } // å°è£ 宿¶æ¨¡æç弿¥æä½ async function executeRealTimeSimulation(item) { try { const ress = await getSimStart(item.id); const res = await getSimDataById(item.id); item.serviceName = res.data[0]?.serviceName || null; simStore.setSelectedScheme(item); getScheme(); if (ress.code === 200) { simStore.layerDate = ress.data; initeWaterPrimitiveView(); emit("start"); } } catch (e) { console.error("宿¶æ¨¡æè·åæ¨¡ææ°æ®å¤±è´¥ï¼", e); } // 宿¶æ¨¡æåå²åæ¾ function rePlay(item) { // å½åéä¸çæ¹æ¡ simStore.setSelectedScheme(item); // æ¿idå»è¯·æ±resultsæ¥å£ï¼å¦æé¿åº¦ä¸ä¸º0ï¼åå¯ä»¥è¿è¡åå²åæ¾ getSimresult(item.id) .then((res) => { if (res.code == 500) { // 妿é¿åº¦ä¸º0ï¼æç¤ºç¨æ·å¹¶ä¸ä¸è¿è¡åç»æä½ ElMessage.warning("æç¤ºï¼æ²¡æå¯åæ¾çæ°æ®ï¼"); return; // 黿¢åç»æä½ } else { simStore.rePlayList = res.data; console.log(simStore.rePlayList, "lisi"); } // ä½¿ç¨ nextTick ç¡®ä¿ DOM æ´æ°ååæ§è¡åç»æä½ nextTick(() => { initeWaterPrimitiveView(); startSimulate(); }); }) .catch((error) => { console.log("请æ±å¤±è´¥ï¼", error); // é误å¤ç }); } function handleBack(value) { @@ -221,10 +221,10 @@ item.result == "å建仿ç" || item.result == "宿" || item.result == "-1" || item.result == null item.result == "忢" || item.result == "è¿è¡ä¸" ); simAPIStore.shouldPoll = !shouldStop; // ä¿®æ¹ Pinia ç¶æ console.log(shouldStop, "aaaaaaaaaaaaaaaa"); // 3. 妿éè¦åæ¢ if (shouldStop) { if (intervalId) { src/store/simulation.js
@@ -2,6 +2,8 @@ import { defineStore } from 'pinia' import { ref } from 'vue' export const useSimStore = defineStore('simulation', () => { // åå²åæ¾å表 const rePlayList = ref([]) // åäº¬å¸æææçcode const townCodeAll = ref([]) // 宿¶æ¨¡æææ°çlayer @@ -47,10 +49,22 @@ // éé¨åä½ const intensityUnit = ref() const setSelectedScheme = (scheme) => { selectedScheme.value = scheme rainFalls.value = JSON.parse(scheme.data).rainfalls intensityUnit.value = JSON.parse(scheme.data).intensityUnit } selectedScheme.value = scheme; try { const parsedData = JSON.parse(scheme.data); // åªæå½ rainfalls å intensityUnit åå¨ä¸éç©ºæ¶æèµå¼ if (parsedData.rainfalls && parsedData.intensityUnit) { rainFalls.value = parsedData.rainfalls; intensityUnit.value = parsedData.intensityUnit; } else { console.warn("缺å°å¿ è¦ç rainfalls æ intensityUnit åæ®µ"); } } catch (error) { console.error("è§£æ scheme.data åºé", error); } }; const clearSelectedScheme = () => { selectedScheme.value = null } @@ -200,6 +214,7 @@ devices, frameNum, layerDate, rePlayList, // æ¹æ¡ç¸å ³æ¹æ³ setSchemCard, src/views/left/CitySim.vue
@@ -186,7 +186,7 @@ const intensityOptions = ref([ { value: "mm/h", label: "mm/h" }, { value: "mm/5min", label: "mm/5min" }, { value: "mm/1min", label: "mm/1min" }, { value: "mm/min", label: "mm/min" }, ]); // å®ä¹ä¸ä¸ªæ¹æ³ï¼ç¨äºæ ¹æ® type è·ååºåæ°æ® @@ -495,7 +495,9 @@ : undefined, })); console.log(rawRainFallList, "åå§é鍿°æ®"); // æ´æ° forms.rainFallListï¼å¯ç¨äºå¾è¡¨æ¾ç¤ºçç¨é forms.rainFallList = rawRainFallList; // 夿æ¯å¦ä¸ºæ´å°æ¶æ°æ®ï¼å³ç¸é»æ¶é´é´éæ¯å¦ä¸ºæ´å°æ¶ï¼ const isHourlyData = checkIfHourlyData(rawRainFallList); @@ -513,9 +515,6 @@ intensity: item.intensity, })); } // æ´æ° forms.rainFallListï¼å¯ç¨äºå¾è¡¨æ¾ç¤ºçç¨é forms.rainFallList = rawRainFallList; // 计ç®èµ·å§æ¶é´åç»ææ¶é´ï¼æ¯«ç§æ°ï¼ const firstTime = parseDateTime(hourlyRainfallList[0]?.time); src/views/left/KGSimOption/RealTimeSimulation.vue
@@ -81,7 +81,8 @@ import { useSimStore } from "@/store/simulation.js"; import { EventBus } from "@/eventBus"; // å¼å ¥äºä»¶æ»çº¿ import { getDeviceInfoSHG, getYLJData } from "@/api/hpApi"; import { getSimStart, getSimDataById } from "@/api/trApi"; import { getSimStart, getSimDataById, getSimresult } from "@/api/trApi"; import { ControlSchemeType } from "@/assets/js/lib-pixelstreamingfrontend.esm"; // è·å Store å®ä¾ const simAPIStore = SimAPIStore(); @@ -219,14 +220,15 @@ // 宿¶æ¨¡æå®æ¶å¨ let pollingInterval = null; // ç¨äºè®°å½ä¸æ¬¡æ°æ®æ¡æ° let lastDataLength = 0; let pollingTimer = null; // ç¨äºä¿å宿¶å¨å¼ç¨ async function startPlay() { // å¼å§æ¨¡æåéè¦å ä¿åæ¹æ¡ updateSelectedGauges(); formData.geom = props.selectedArea; // ä¿åæ¹æ¡ const resApi = await simAPIStore.addSimCheme(formData); const schemeId = resApi.data?.data?.id; @@ -237,7 +239,6 @@ EventBus.emit("close-selectArea"); // æ¾ç¤ºå è½½ä¸æç¤º const loadingMessage = ElMessage({ type: "info", message: "æ£å¨å¯å¨æ¨¡æ...", @@ -246,58 +247,130 @@ }); try { // è°ç¨æ±è§£å¨å¹¶åå§å模æ const resStart = await getSimStart(schemeId); await getSimStart(schemeId); // 请æ±å®æåå ³éå è½½æç¤º loadingMessage.close(); if (resStart.code === 200) { const res = await getSimDataById(schemeId); simStore.setSelectedScheme(res.data[0]); simStore.layerDate = resStart.data; initeWaterPrimitiveView(); // å®ä¹ä¸ä¸ªå½æ°ç¨äºè½®è¯¢è·åæ°æ® const pollForResult = async () => { try { startSimulate(); // è¿éå¯è½ä¼æ¥é } catch (error) { console.error("è°ç¨ startSimulate åºéï¼", error); } const res = await getSimresult(schemeId); console.log(res.data, "宿¶æ¨¡æ - è½®è¯¢ç»æ"); // å¼å§è½®è¯¢ä»»å¡ï¼æ¯ 5 åéè°ç¨ä¸æ¬¡ getSimStart å¹¶æ´æ°æ¹æ¡æ°æ® startPolling(schemeId); } else { ElMessage.error(resStart.message || "è°ç¨æ±è§£å¨å¤±è´¥"); } if (res.code === 200 && res.data.length > 0) { // æåæ¿å°æ°æ® loadingMessage.close(); handleNewData(res.data, schemeId); startPolling(schemeId); // â æ¸ é¤å®æ¶å¨ if (pollingTimer) { clearTimeout(pollingTimer); pollingTimer = null; } } else { // æ°æ®æ æï¼ç»§ç»è½®è¯¢ pollingTimer = setTimeout(pollForResult, 10 * 1000); } } catch (error) { console.error("è¯·æ±æ¨¡æç»æå¤±è´¥", error); pollingTimer = setTimeout(pollForResult, 10 * 1000); // 请æ±åºéä¹ç»§ç»è½®è¯¢ } }; // 馿¬¡å»¶è¿ 2 åéå¼å§è½®è¯¢ pollingTimer = setTimeout(async () => { await pollForResult(); // å¼å§ç¬¬ä¸æ¬¡è½®è¯¢ }, 3 * 60 * 1000); // 3åéåç¬¬ä¸æ¬¡è¯·æ± } catch (error) { loadingMessage.close(); ElMessage.error("请æ±å¤±è´¥ï¼" + (error.message || "æªç¥é误")); console.error("è°ç¨ getSimStart åºéï¼", error); if (pollingTimer) { clearTimeout(pollingTimer); pollingTimer = null; } } } // å¯å¨è½®è¯¢å½æ° // 宿¶äºåéè¯·æ± function startPolling(schemeId) { stopPolling(); // é¿å éå¤å¯å¨ stopPolling(); // ç¡®ä¿ä¸ä¼éå¤å¯å¨ pollingInterval = setInterval(async () => { try { const resStart = await getSimStart(schemeId); const res = await getSimresult(schemeId); if (resStart.code === 200) { const res = await getSimDataById(schemeId); simStore.setSelectedScheme(res.data[0]); // æ´æ°æ¹æ¡æ°æ® simStore.layerDate = resStart.data; // æ´æ° layer æ°æ® if (res.data && res.data.length > 0) { if (res.data.length === lastDataLength) { console.log("ä¸»è½®è¯¢ï¼æ æ°æ°æ®ï¼åæ¢ä¸º 10 ç§é«é¢è½®è¯¢"); console.log("轮询è·åææ°æ°æ®æå"); } else { console.warn("轮询请æ±å¤±è´¥ï¼", resStart.message); clearInterval(pollingInterval); pollingInterval = null; startFastPolling(schemeId); // å¯å¨é«é¢è½®è¯¢ } else { handleNewData(res.data, schemeId); } } } catch (error) { console.error("轮询请æ±å¼å¸¸ï¼", error); console.error("轮询è·å模æç»æå¤±è´¥", error); } }, 5 * 60 * 1000); // æ¯ 5 åéæ§è¡ä¸æ¬¡ }, 5.6 * 60 * 1000); // æ¯ 5.5 åéæ§è¡ä¸æ¬¡ } let fastPollingInterval = null; // 妿äºåéæ²¡æ¿å°ææ°çæ°æ®ï¼åå¼å¯åç§éè°ç¨ä¸æ¬¡ï¼æ¿å°ææ°çæ°æ®å°±åæ¢ function startFastPolling(schemeId) { fastPollingInterval = setInterval(async () => { try { const res = await getSimresult(schemeId); if (res.data && res.data.length > 0) { if (res.data.length !== lastDataLength) { console.log("é«é¢è½®è¯¢ï¼æ£æµå°æ°æ°æ®ï¼æ¢å¤ä¸»è½®è¯¢"); clearInterval(fastPollingInterval); fastPollingInterval = null; handleNewData(res.data, schemeId); startPolling(schemeId); // éæ°å¯å¨ä¸»è½®è¯¢ } } } catch (error) { console.error("é«é¢è½®è¯¢è·å模æç»æå¤±è´¥", error); } }, 10 * 1000); // æ¯ 10 ç§æ§è¡ä¸æ¬¡ } // æ¿åææ°çlayer.jsonåå¨å°piniaä¸ async function handleNewData(dataArray, schemeId) { // æ¿æå¡åç§° const res = await getSimDataById(schemeId); simStore.setSelectedScheme(res.data[0]); // æ´æ°æ¹æ¡æ°æ® const latestItem = dataArray[dataArray.length - 1]; const currentLength = dataArray.length; if (currentLength <= lastDataLength) { console.log("æ¬è½®æ æ°æ°æ®ï¼é¿åº¦æªååï¼"); return; } // æ´æ°æ è¯ lastDataLength = currentLength; // æ§è¡æ´æ°é»è¾ console.log("æ£æµå°æ°æ°æ®ï¼æ´æ°ä¸..."); console.log(latestItem, "last"); simStore.layerDate = latestItem; initeWaterPrimitiveView(); try { startSimulate(); } catch (error) { console.error("è°ç¨ startSimulate åºéï¼", error); } } // åæ¢è½®è¯¢å½æ° @@ -305,8 +378,14 @@ if (pollingInterval) { clearInterval(pollingInterval); pollingInterval = null; console.log("è½®è¯¢å·²åæ¢"); } if (fastPollingInterval) { clearInterval(fastPollingInterval); fastPollingInterval = null; } console.log("è½®è¯¢å·²åæ¢"); } EventBus.on("close-time", () => { vue.config.js
@@ -21,7 +21,7 @@ hot: true, proxy: { '/api': { target: 'http://192.168.56.107:8088', target: 'http://192.168.37.60:8088', // target: 'http://192.168.1.104:8078', changeOrigin: true, // pathRewrite: { @@ -38,7 +38,7 @@ secure: false }, '/simu': { target: 'http://192.168.56.107:8088', target: 'http://192.168.37.60:8088', changeOrigin: true, secure: false }