Browse Source

航站统计数据修改

zhongxiaoyu 2 years ago
parent
commit
05a6df9d09
2 changed files with 32 additions and 82 deletions
  1. 4 4
      public/config.js
  2. 28 78
      src/views/realTime/components/AirportView/index.vue

+ 4 - 4
public/config.js

@@ -183,10 +183,10 @@ var DATACONTENT_ID = {
   internationalDepartureAirport: 1803525, // 国际离港航站
   arrivalAirport: 1803522, // 国内进港航站
   internationalArrivalAirport: 1803523, // 国际进港航站
-  departureAirportWeightCount: 1803614, // 国内离港重量统计
-  internationalDepartureAirportWeightCount: 1803613, // 国际离港重量统计
-  arrivalAirportWeightCount: 1803616, // 国内进港重量统计
-  internationalArrivalAirportWeightCount: 1803615, // 国际进港重量统计
+  departureAirportAirportCount: 1803537, // 国内离港统计
+  internationalDepartureAirportAirportCount: 1803542, // 国际离港统计
+  arrivalAirportAirportCount: 1803547, // 国内进港统计
+  internationalArrivalAirportAirportCount: 1803552, // 国际进港统计
   warningRules: 18040, // 报警预警策略
   // 航班
   departureFlightInfo: 1803511, // 国内离港航班基础信息

+ 28 - 78
src/views/realTime/components/AirportView/index.vue

@@ -4,19 +4,17 @@
       <AirportForm :name="name" @form-data-change="formDataChangeHandler" />
       <div class="airport-count">
         <CountBox
-          :count-number="tableDataCount.flightCount"
+          :count-number="airportCount.flightNum"
           :length="4"
           label="今日计划航班数"
         />
         <CountBox
-          :count-number="
-            isDeparture ? finishedCount : tableDataCount.tallyCount
-          "
+          :count-number="airportCount.finishFlightNum"
           :length="4"
           label="已完成航班数"
         />
         <CountBox
-          :count-number="weightCount"
+          :count-number="airportCount.weight"
           label="已转载重量KG"
           :length="8"
         />
@@ -57,20 +55,6 @@
         @cell-click="cellClickHandler"
       />
     </div>
-    <!-- <div class="table-footer">
-      <span class="table-footer-count"
-        >货运航班总数:{{ tableDataCount.freightFlightCount }}</span
-      >
-      <span class="table-footer-count"
-        >货站交接总数:{{ tableDataCount.depotFlightCount }}</span
-      >
-      <span v-if="isDeparture" class="table-footer-count"
-        >已装机总数:{{ tableDataCount.loadCount }}</span
-      >
-      <span v-else class="table-footer-count"
-        >已卸机总数:{{ tableDataCount.unloadCount }}</span
-      >
-    </div> -->
   </div>
 </template>
 <script lang="tsx" setup>
@@ -105,18 +89,18 @@ const formDataChangeHandler = (data: CommonData) => {
   Object.assign(formData, data)
 }
 
-const { tableColumns, tableData, getTableData } = useAirportTable(
-  props.name,
-  formData
-)
-
-const finishedCount = ref(0)
-
-const weightCount = ref(0)
-const getWeightCount = async () => {
+const airportCount = reactive({
+  flightNum: 0,
+  finishFlightNum: 0,
+  weight: 0,
+})
+const getAirportCount = async () => {
   try {
     const { startDate, endDate } = formData
-    const dataContent = [startDate, endDate]
+    if (typeof startDate !== 'string' || typeof endDate !== 'string') {
+      throw new Error('Type Error: date must be string')
+    }
+    const dataContent = [startDate.slice(0, 10), endDate.slice(0, 10)]
     const {
       code,
       returnData: { listValues },
@@ -126,7 +110,7 @@ const getWeightCount = async () => {
         DATACONTENT_ID[
           `${
             props.name.slice(0, 1).toLowerCase() + props.name.slice(1)
-          }WeightCount`
+          }AirportCount`
         ],
       dataContent,
     })
@@ -134,21 +118,31 @@ const getWeightCount = async () => {
       throw new Error(message || '失败')
     }
     if (!listValues.length) {
-      ElMessage.info('未查询到重量信息')
-      weightCount.value = 0
+      ElMessage.info('未查询到统计信息')
+      airportCount.flightNum = airportCount.finishFlightNum = airportCount.weight = 0
       return
     }
-    weightCount.value = listValues[0].weight
+    const { flightNum, finishFlightNum, weight } = listValues[0]
+    airportCount.flightNum = flightNum ?? 0
+    airportCount.finishFlightNum = finishFlightNum ?? 0
+    airportCount.weight = weight ?? 0
   } catch (error) {
     console.error(error)
   }
 }
 
+const { tableColumns, tableData, getTableData } = useAirportTable(
+  props.name,
+  formData
+)
+
+const finishedCount = ref(0)
+
 const { getWarningRules } = useFlightState(props.name, tableData, finishedCount)
 
 useLoop(
   [
-    getWeightCount,
+    getAirportCount,
     getTableData,
     // getWarningRules,
   ],
@@ -247,50 +241,6 @@ const rowClassName = params => {
   return `${rowClass(params)} ${classes.join(' ')}`
 }
 
-const tableDataCount = computed(() =>
-  tableData.value.reduce(
-    (counts: { [x: string]: number }, current) => {
-      // const preCount = current[isDeparture ? 'preLoad' : 'preUnload']
-      // if (preCount) {
-      //   counts.waybillCount += Number(String(preCount).split('/')[0])
-      //   counts.goodsCount += Number(String(preCount).split('/')[1])
-      // }
-      if (typeof current['allNumber'] === 'number') {
-        counts.flightCount = current['allNumber']
-      }
-      if (current['depotJoinTime'] || current['depotJoinTime_IN']) {
-        counts.depotFlightCount++
-      }
-      const isFreight = tableColumns.value.some(
-        column => column.groupName === '地服相关' && current[column.columnName]
-      )
-      if (isFreight) {
-        counts.freightFlightCount++
-      }
-      if (current['loadPlaneSureTime']) {
-        counts.loadCount++
-      }
-      if (current['unLoadTime']) {
-        counts.unloadCount++
-      }
-      if (current['tallyTime_in']) {
-        counts.tallyCount++
-      }
-      return counts
-    },
-    {
-      // waybillCount: 0,
-      // goodsCount: 0,
-      flightCount: 0,
-      depotFlightCount: 0,
-      freightFlightCount: 0,
-      loadCount: 0,
-      unloadCount: 0,
-      tallyCount: 0,
-    }
-  )
-)
-
 const { cellClickHandler } = useTableCellClick(props.name)
 
 const route = useRoute()