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

---
 src/utils/water.js                         |   35 ++++++-----
 src/components/monifangzhen/echartInfo.vue |    1 
 src/components/menu/TimeLine.vue           |  109 ++++++++++++++++++++++++++++--------
 3 files changed, 102 insertions(+), 43 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('鐢变簬鏁版嵁鏃犳樉钁楀彉鍖栵紝璺宠繃鏈鏇存柊');
diff --git a/src/components/monifangzhen/echartInfo.vue b/src/components/monifangzhen/echartInfo.vue
index 9231c23..3f73aaa 100644
--- a/src/components/monifangzhen/echartInfo.vue
+++ b/src/components/monifangzhen/echartInfo.vue
@@ -309,7 +309,6 @@
   if (nowTime.value) {
     const timeParts = nowTime.value.split(" ");
     const timeOnly = timeParts[1]; // 鑾峰彇 "mm:ss" 閮ㄥ垎
-    console.log(nowTime.value, "nowTime.valuenowTime.value");
     return timeOnly;
   }
 };
diff --git a/src/utils/water.js b/src/utils/water.js
index 59a2f68..dff0df4 100644
--- a/src/utils/water.js
+++ b/src/utils/water.js
@@ -12,7 +12,7 @@
     enableWaterArrowFlow(false);
     water.destroy();
     water = null;
-    console.log("Water simulation destroyed.");
+    // console.log("Water simulation destroyed.");
   }
 }
 
@@ -78,25 +78,26 @@
   }
 
   waterLegendData.value = waterHeightLevels;
-  console.log(waterLegendData.value, "鍥句緥鏁版嵁");
+  // console.log(waterLegendData.value, "鍥句緥鏁版嵁");
 
-  
+
   water = await earthCtrl.simulate.createWaterSimulateLayer({
     baseUrl,
     interval,
     color: SmartEarth.Cesium.Color.fromCssColorString("#D4F2E7"),
     loop: false,
     callback: timeCallback,
-    alphaByDepth: -0.3,
+    // alphaByDepth: -0.3,
+    alphaByDepth: -0.8,
     waterHeightLevels,
     colorRender,
     sizeIndex: 0,
   });
-  enableWaterArrowFlow(false);
+  // enableWaterArrowFlow(false);
   toggleWaterShadow(false);
-  console.log(
-    `浠跨湡妯℃嫙鍙傛暟锛氳姹傝矾寰� ${baseUrl}, 甯ч棿闂撮殧 ${interval}ms, 鏄惁寮�鍚笓棰樻覆鏌� ${colorRender}`
-  );
+  // console.log(
+  //   `浠跨湡妯℃嫙鍙傛暟锛氳姹傝矾寰� ${baseUrl}, 甯ч棿闂撮殧 ${interval}ms, 鏄惁寮�鍚笓棰樻覆鏌� ${colorRender}`
+  // );
 }
 /**
  * 鍒濆鍖栨按浣撴ā鎷熻鍥�
@@ -123,7 +124,7 @@
 export function updateWaterColor(color) {
   if (water) {
     water.color = Cesium.Color.fromCssColorString(color);
-    console.log("鍒囨崲棰滆壊涓猴細",color);
+    // console.log("鍒囨崲棰滆壊涓猴細",color);
   } else {
     console.warn("No water simulation to pause.");
   }
@@ -134,7 +135,7 @@
 export function pauseWaterSimulation() {
   if (water) {
     water.pause();
-    console.log("鏆傚仠浠跨湡");
+    // console.log("鏆傚仠浠跨湡");
   } else {
     console.warn("No water simulation to pause.");
   }
@@ -146,7 +147,7 @@
 export function resumeWaterSimulation() {
   if (water) {
     water.resume();
-    console.log("缁х画浠跨湡");
+    // console.log("缁х画浠跨湡");
   } else {
     console.warn("No water simulation to resume.");
   }
@@ -165,9 +166,9 @@
       return;
     }
     // const idx = Math.floor(Math.random() * imageList.length); //闅忔満绱㈠紩璺宠浆锛屽疄闄呬腑鐢ㄤ笉鍒帮紝鍙敤浣滄紨绀�
-    console.log(
-      `Jumping to timestamp: count:[${imageList.length}], index:[${closestIndex}]`
-    );
+    // console.log(
+    //   `Jumping to timestamp: count:[${imageList.length}], index:[${closestIndex}]`
+    // );
     water.setTime(imageList[closestIndex]);
   } else {
     console.warn("No water simulation to set time for.");
@@ -181,7 +182,7 @@
 export function toggleWaterColorRender(enabled) {
   if (water) {
     water.colorRender = enabled;
-    console.log(`鏄惁寮�鍚笓棰樻覆鏌� ${enabled}`);
+    // console.log(`鏄惁寮�鍚笓棰樻覆鏌� ${enabled}`);
   } else {
     console.warn("No water simulation to toggle color rendering.");
   }
@@ -196,7 +197,7 @@
   if (water) {
     // 榛樿鍏抽棴鐘舵��
     water.flowEnabled = enabled; // 鍋囪 SDK 鏀寔姝ゅ睘鎬�
-    console.log(`绠ご娴佸悜鍔ㄧ敾宸�${enabled ? "寮�鍚�" : "鍏抽棴"}`);
+    // console.log(`绠ご娴佸悜鍔ㄧ敾宸�${enabled ? "寮�鍚�" : "鍏抽棴"}`);
   } else {
     console.warn("鏈壘鍒版按浣撴ā鎷熷浘灞傦紝璇峰厛鍚姩娲按妯℃嫙");
   }
@@ -218,7 +219,7 @@
       earthCtrl.shadowMap.maximumDistance = 10000.0; //鏈�澶ц窛绂�
       earthCtrl.shadowMap.pointLightRadius = 50.0; //鐐瑰厜婧愬崐寰�
     }
-    console.log(`闃村奖鏁堟灉宸�${enabled ? "寮�鍚�" : "鍏抽棴"}`);
+    // console.log(`闃村奖鏁堟灉宸�${enabled ? "寮�鍚�" : "鍏抽棴"}`);
   } catch (error) {
     console.error("璁剧疆闃村奖澶辫触:", error);
   }

--
Gitblit v1.9.3