From 1190b6e0bea6f91b85b8e1b574300b18aac3e562 Mon Sep 17 00:00:00 2001
From: wangjuncheng <1>
Date: 星期三, 25 六月 2025 14:43:29 +0800
Subject: [PATCH] 11111111

---
 src/components/menu/TimeLine.vue |  109 ++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 84 insertions(+), 25 deletions(-)

diff --git a/src/components/menu/TimeLine.vue b/src/components/menu/TimeLine.vue
index 91d7acb..177f159 100644
--- a/src/components/menu/TimeLine.vue
+++ b/src/components/menu/TimeLine.vue
@@ -201,6 +201,7 @@
 });
 let minFlowRate = ref();
 let maxFlowRate = ref();
+let maxStage = null;
 // 璁$畻灞炴��
 const progressPercentage = computed(
   () => (currentTime.value / duration.value) * 100
@@ -463,36 +464,94 @@
 
 function updateWaterColorByTime() {
   if (!rainTotalInfo.value || rainTotalInfo.value.length === 0) return;
+
+  // 杈呭姪鍑芥暟锛氬皢 "YYYY-MM-DD HH:mm:ss" 杞崲涓� JavaScript Date 瀵硅薄
+  const timeToTimestamp = (timeStr) => new Date(timeStr).getTime();
+
+  // 鑾峰彇鍒濆鏃堕棿鎴筹紙绗竴涓暟鎹偣鐨勬椂闂达級
+  const initialTimestamp = timeToTimestamp(rainTotalInfo.value[0].time);
+
+  // 璁$畻褰撳墠杩涘害
   const progress = currentTime.value / duration.value;
   const floatIndex = progress * (rainTotalInfo.value.length - 1);
   const index = Math.floor(floatIndex);
   const nextIndex = Math.min(index + 1, rainTotalInfo.value.length - 1);
   const currentData = rainTotalInfo.value[index];
   const nextData = rainTotalInfo.value[nextIndex];
+  const currentTimestamp = timeToTimestamp(currentData.time);
+
+  // 宸茶繃鍘荤殑鏃堕棿锛堝皬鏃讹級
+  const elapsedTimeInHours = parseFloat((currentTimestamp - initialTimestamp) / (1000 * 60 * 60));
+
+  console.log(`鎸佺画浜� ${elapsedTimeInHours} 灏忔椂`);
+
   // 鍚敤鎻掑�硷紙alpha 骞虫粦杩囨浮锛�
   const alpha = floatIndex - index;
-  const currentTotal = currentData.total;
-  const nextTotal = nextData.total;
-  const total = currentTotal + (nextTotal - currentTotal) * alpha;
-  console.log(`璁$畻寰楀埌鐨勬椂闂存闀夸负: ${timeStepInfo} 灏忔椂`);
-  // 鏍规嵁 total 璁剧疆棰滆壊
-  let color = "#D4F2E7"; // 榛樿钃濊壊
+  const currentIntensity = currentData.intensity;
+  const nextIntensity = nextData.intensity;
+  const intensity = currentIntensity + (nextIntensity - currentIntensity);
+  // 璁$畻 IR(t)
+  const D = elapsedTimeInHours + 0.0001; // 鍔犱竴涓瀬灏忛噺闃叉闄ら浂
+  const IR = 56.9 * Math.pow(D, -0.746); // 鍗曚綅 mm/h
 
-  if (total >= 150) {
-    color = '#663300'; 
-  } else if (total >= 125) {
-    color = '#B26633'; 
-  } else if (total >= 100) {
-    color = '#CC9966';
-  } else if (total >= 75) {
-    color = '#CCE5FF'; 
-  } else if (total >= 50) {
-    color = '#99CCFF';
-  } else if (total >= 25) {
-    color = '#66B3FF'; 
+  // 鍒ゆ柇褰撳墠闃舵
+  let stage = 0;
+  if (intensity >= 1.0 * IR) {
+    stage = 6;
+  } else if (intensity >= 0.8 * IR) {
+    stage = 5;
+  } else if (intensity >= 0.6 * IR) {
+    stage = 4;
+  } else if (intensity >= 0.4 * IR) {
+    stage = 3;
+  } else if (intensity >= 0.2 * IR) {
+    stage = 2;
+  } else if (intensity > 0) {
+    stage = 1;
   }
-  // console.log(`褰撳墠 total: ${total.toFixed(2)}, 棰滆壊: ${color}`);
-  // updateWaterColor(color)
+
+  // 鏇存柊鍏ㄥ眬鏈�澶ч樁娈碉紙涓嶄細鍥為��锛�
+  if (!maxStage) maxStage = 0;
+  maxStage = Math.max(maxStage, stage);
+
+  // 杈撳嚭鍏抽敭淇℃伅
+  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 ? '鏄�' : '鍚�'
+  });
+
+  // 鏍规嵁鏈�澶ч樁娈佃缃鑹�
+  let color = "#D4F2E7";
+  switch (maxStage) {
+    case 0:
+      color = "#D4F2E7";
+      break;
+    case 1:
+      color = "#66B3FF";
+      break;
+    case 2:
+      color = "#99CCFF";
+      break;
+    case 3:
+      color = "#CCE5FF";
+      break;
+    case 4:
+      color = "#CC9966";
+      break;
+    case 5:
+      color = "#B26633";
+      break;
+    case 6:
+      color = "#663300";
+      break;
+  }
+
+  updateWaterColor(color);
 }
 
 function updateWeatherByProgress() {
@@ -509,11 +568,11 @@
   // const rainValue = currentRain + (nextRain - currentRain) * alpha;
   const rainValue = currentRain + (nextRain - currentRain);
   // 鎵撳嵃褰撳墠澶勭悊鐨勯洦閲忔暟鎹�
-  console.log(
-    `姝e湪澶勭悊鐨勯洦閲忔暟鎹偣: 褰撳墠=${currentRain}, 涓嬩竴涓�=${nextRain}, 鎻掑�煎悗=${rainValue.toFixed(
-      2
-    )}, 绱㈠紩=${index}`
-  );
+  // console.log(
+  //   `姝e湪澶勭悊鐨勯洦閲忔暟鎹偣: 褰撳墠=${currentRain}, 涓嬩竴涓�=${nextRain}, 鎻掑�煎悗=${rainValue.toFixed(
+  //     2
+  //   )}, 绱㈠紩=${index}`
+  // );
   // 濡傛灉褰撳墠绱㈠紩鏈彉鍖栦笖鎻掑�煎樊寮備笉澶э紝璺宠繃閲嶅鏇存柊
   if (index === lastUsedIndex && Math.abs(rainValue - lastRainValue) < 0.1) {
     // console.log('鐢变簬鏁版嵁鏃犳樉钁楀彉鍖栵紝璺宠繃鏈鏇存柊');

--
Gitblit v1.9.3