Przeglądaj źródła

添加实时数据最新时间方法

linqilong 6 miesięcy temu
rodzic
commit
ae29aea6a3
4 zmienionych plików z 30 dodań i 16 usunięć
  1. 1 1
      src/api/gx.ts
  2. 1 1
      src/layout/index.vue
  3. 20 0
      src/utils/date.ts
  4. 8 14
      src/views/Situational.vue

+ 1 - 1
src/api/gx.ts

@@ -855,7 +855,7 @@ export function getWaterLevelAndFlowLatest(data: any) {
     url: '/gx_api/gx/sq/waterLevelAndFlow/latest',
     method: 'get',
     params: data,
-    timeout: 1000 * 60
+    timeout: 1000 * 60 * 6
   })
 }
 

+ 1 - 1
src/layout/index.vue

@@ -34,7 +34,7 @@ onMounted(() => {
 <template>
   <div :style="{ '--current-color': theme }" class="app-wrapper">
 
-    <antv-map v-show="appStore.floorType === 'map'" class="floor-container"></antv-map>
+    <antv-map v-if="appStore.floorType === 'map'" class="floor-container"></antv-map>
     <ue-player v-show="appStore.floorType === 'ue'" class="floor-container"></ue-player>
 
     <!-- 顶部阴影 -->

+ 20 - 0
src/utils/date.ts

@@ -0,0 +1,20 @@
+// 日期
+export function getLatestTimeWithMinuteMultipleOfFive(date = new Date(), minutesNumber = 10) {
+  // 获取当前分钟数
+  let minutes = date.getMinutes();
+
+  // 计算最近的5的倍数
+  let remainder = minutes % 5;
+  if (remainder !== 0) {
+    minutes = minutes - remainder;
+  }
+  minutes = minutes - minutesNumber;
+
+  // 设置调整后的分钟数和秒数为0
+  date.setMinutes(minutes);
+  date.setSeconds(0);
+  date.setMilliseconds(0);
+
+  // 返回调整后的时间
+  return date;
+}

+ 8 - 14
src/views/Situational.vue

@@ -17,6 +17,7 @@ import {
 import {formatd} from "@/utils/ruoyi";
 import {filterWaterQualitys} from "@/utils/unit";
 import {Setting, View} from "@/utils/tdInstruction";
+import {getLatestTimeWithMinuteMultipleOfFive} from "@/utils/date";
 
 const route = useRoute()
 const dibaImage = (new URL('@/assets/images/dike.png', import.meta.url).href)
@@ -122,7 +123,11 @@ async function reloadLeft2() {
 
 async function reloadLeft3() {
   const stcds = stationList.map(s => s.stcd).join(',')
-  const waterData = await getWaterLevelAndFlowLatest({stcds}).then(res => res.data)
+  const tm = formatd(getLatestTimeWithMinuteMultipleOfFive(new Date(), 15), 'yyyy-MM-dd hh:mm:ss')
+  const waterData = await getWaterLevelAndFlowLatest({stcds, tm}).then(res => res.data)
+  const currentStationData = waterData.find(d => d.stcd === route.params.stcd)
+  wlData.ss = currentStationData.z + ''
+
   const seriesData = stationList.map(s => {
     const data = waterData.find(d => d.stcd === s.stcd)
     return data ? data.z : 0
@@ -184,7 +189,8 @@ async function reloadLeft3() {
       barWidth: 18,
       label: {
         show: true,
-        position: 'top'
+        position: 'top',
+        color: '#fff'
       },
       data: seriesData
     }]
@@ -349,16 +355,6 @@ async function reloadRight3() {
   right3Ref.value.carousel(1000, true)
 }
 
-/**
- * 获取实时水位数据
- */
-function getCharacteristicLevel() {
-  getWaterLevelAndFlowLatest({stcds: route.params.stcd}).then(res => {
-    const data = res.data[0]
-    wlData.ss = data.z + ''
-  })
-}
-
 /**
  * 获取最新水质数据
  */
@@ -384,8 +380,6 @@ onMounted(() => {
   reloadLeft2()
   reloadLeft3()
 
-  // 获取实时水位
-  getCharacteristicLevel()
   // 获取最新水质数据
   getLatestWaterQuality()
 })