From 2f387619c1cf834c058ac77a3fd4cabc42e5d4de Mon Sep 17 00:00:00 2001 From: guonan <guonan201020@163.com> Date: 星期三, 25 六月 2025 15:09:30 +0800 Subject: [PATCH] 提交初版实时模拟 --- src/components/menu/TimeLine.vue | 42 +++++++++++++++++++++++++----------------- 1 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/components/menu/TimeLine.vue b/src/components/menu/TimeLine.vue index 177f159..b3f87e6 100644 --- a/src/components/menu/TimeLine.vue +++ b/src/components/menu/TimeLine.vue @@ -152,7 +152,7 @@ import { useSimStore } from "@/store/simulation"; import { storeToRefs } from "pinia"; const simStore = useSimStore(); -const { selectedScheme, frameNum } = storeToRefs(simStore); +const { selectedScheme, frameNum, layerDate } = storeToRefs(simStore); const emit = defineEmits([ "timeUpdate", @@ -191,7 +191,7 @@ const isWaterPrimitiveCreated = ref(false); let playInterval = null; let timeStepInfo = null; -let rainTotalInfo = ([]); +let rainTotalInfo = []; const isRainEnabled = ref(false); const rainParams = reactive({ rainSize: 0.5, @@ -349,10 +349,10 @@ const rainfallList = data.rainfalls; console.log("鏈�缁堢殑 rainfallList:", rainfallList); - rainTotalInfo.value = rainfallList - calculateTimeStep(rainTotalInfo.value) + rainTotalInfo.value = rainfallList; + calculateTimeStep(rainTotalInfo.value); // 浣跨敤绀轰緥 - timeStepInfo = calculateTimeStep(rainTotalInfo.value); + timeStepInfo = calculateTimeStep(rainTotalInfo.value); // 鎻愬彇 intensity 鍊� rainFallValues.value = rainfallList.map((r) => r.intensity); @@ -431,13 +431,13 @@ function calculateTimeStep(dataArray) { if (!dataArray || dataArray.length < 2) { - console.warn('鏁版嵁涓嶈冻锛屾棤娉曡绠楁椂闂存闀�'); + console.warn("鏁版嵁涓嶈冻锛屾棤娉曡绠楁椂闂存闀�"); return null; } // 瑙f瀽鏃堕棿瀛楃涓蹭负 Date 瀵硅薄 function parseTime(timeStr) { - return new Date(timeStr.replace(' ', 'T')); // 鍏煎 ISO 鏍煎紡 + return new Date(timeStr.replace(" ", "T")); // 鍏煎 ISO 鏍煎紡 } const firstTime = parseTime(dataArray[0].time); @@ -455,7 +455,9 @@ const next = parseTime(dataArray[i + 1].time); const step = Math.abs(next - current) / (1000 * 60 * 60); // 姣 -> 灏忔椂 if (Math.abs(step - timeStepHours) > 0.01) { - console.warn(`鍦ㄧ储寮� ${i} 澶勫彂鐜颁簡涓嶅悓鐨勬椂闂存闀�: ${step.toFixed(2)} 灏忔椂`); + console.warn( + `鍦ㄧ储寮� ${i} 澶勫彂鐜颁簡涓嶅悓鐨勬椂闂存闀�: ${step.toFixed(2)} 灏忔椂` + ); } } @@ -481,7 +483,9 @@ const currentTimestamp = timeToTimestamp(currentData.time); // 宸茶繃鍘荤殑鏃堕棿锛堝皬鏃讹級 - const elapsedTimeInHours = parseFloat((currentTimestamp - initialTimestamp) / (1000 * 60 * 60)); + const elapsedTimeInHours = parseFloat( + (currentTimestamp - initialTimestamp) / (1000 * 60 * 60) + ); console.log(`鎸佺画浜� ${elapsedTimeInHours} 灏忔椂`); @@ -516,13 +520,13 @@ // 杈撳嚭鍏抽敭淇℃伅 console.table({ - '褰撳墠鏃堕棿': currentData.time, - '绱鏃堕暱 D(t) (h)': D.toFixed(2), - '闆ㄥ己闃堝�� IR(t) (mm/h)': IR.toFixed(2), - '褰撳墠闄嶉洦寮哄害 I(t) (mm/h)': intensity.toFixed(2), - '褰撳墠闃舵缂栧彿': stage, - '鏈�澶ч樁娈电紪鍙�': maxStage, - '鏄惁瑙﹀彂娉ョ煶娴�': stage >= 5 ? '鏄�' : '鍚�' + 褰撳墠鏃堕棿: currentData.time, + "绱鏃堕暱 D(t) (h)": D.toFixed(2), + "闆ㄥ己闃堝�� IR(t) (mm/h)": IR.toFixed(2), + "褰撳墠闄嶉洦寮哄害 I(t) (mm/h)": intensity.toFixed(2), + 褰撳墠闃舵缂栧彿: stage, + 鏈�澶ч樁娈电紪鍙�: maxStage, + 鏄惁瑙﹀彂娉ョ煶娴�: stage >= 5 ? "鏄�" : "鍚�", }); // 鏍规嵁鏈�澶ч樁娈佃缃鑹� @@ -757,12 +761,16 @@ try { // 褰撳墠鏂规鐨勬墍鏈変俊鎭� const schemeInfo = selectedScheme.value; + const jsonFetch = ref(null); serviceInfo = schemeInfo.serviceName; if (selectedScheme.value.type == 2) { speedShow.value = false; + jsonFetch.value = layerDate.value; + // serviceInfo = layerDate.value; } else { getRainfallData(); speedShow.value = true; + jsonFetch.value = null; } // console.log('鑾峰彇鍒扮殑 serviceName:', serviceInfo); @@ -772,7 +780,7 @@ waterTimestamps: timestamps, watersMaxHeight, watersMinHeight, - } = await fetchWaterSimulationData(serviceInfo); + } = await fetchWaterSimulationData(serviceInfo, jsonFetch.value); console.log( "褰撳墠鏂规涓嬬殑鏈�澶ф按浣嶆繁搴﹀拰鏈�灏忔按浣嶆繁搴�", watersMaxHeight, -- Gitblit v1.9.3