Эх сурвалжийг харах

WMS历史轨迹-增加按探头分组查询数据的接口;改变查询逻辑;改变页面表格样式。

DongZ 1 жил өмнө
parent
commit
e70db1b608

+ 10 - 1
src/api/WMS/historical-route.js

@@ -10,7 +10,16 @@ const queryAddress = (data) => {
   });
 }
 
+// 查询地址
+const getMerge = (data) => {
+  return request({
+    url: `/geocode/merge`,
+    method: "post",
+    data,
+  });
+}
+
 export default {
   queryAddress,
-
+  getMerge,
 }

+ 207 - 73
src/views/WMS/historical-route/index.vue

@@ -3,35 +3,61 @@
     <el-tabs v-model="activeName" type="border-card" stretch @tab-click="handleClick">
       <el-tab-pane label="温湿度信息" name="first">
         <div id="body" :style="{width: width - 300 + 'px'}">
-          <!-- 单据信息 -->
+          <!--导出按钮-->
+          <el-button class="OutCss" v-print="'#print'" type="primary">导出</el-button>
           <el-timeline>
-            <el-timeline>
+            <!-- 数据表 -->
+            <h2>车辆温湿度列表</h2>
+            <div v-for="(item, index) in dataCar">
+              <h2>
+                ============================================================================================================================
+              </h2>
               <el-descriptions>
-                <el-descriptions-item label="订单编号">{{this.basicData.billCode}}</el-descriptions-item>
-                <el-descriptions-item label="车牌号">{{this.basicData.plateNumber}}</el-descriptions-item>
+                <el-descriptions-item label="订单编号">{{item[0].billCode}}</el-descriptions-item>
+                <el-descriptions-item label="车牌号">{{item[0].measuringPointName}}</el-descriptions-item>
+                <el-descriptions-item label="探头">{{item[0].measuringPointAddr}}</el-descriptions-item>
+                <el-descriptions-item label="开始时间">{{item[0].hisDate}}</el-descriptions-item>
+                <el-descriptions-item label="结束时间">{{item[item.length - 1].end}}</el-descriptions-item>
               </el-descriptions>
+              <el-table :data="item" stripe border style="width: 97%">
+                <el-table-column prop="temperature" label="温度" align="center" min-width="80" />
+                <el-table-column prop="hisDate" label="时间点" align="center" min-width="200" />
+                <el-table-column prop="temperature1" label="温度" align="center" min-width="80" />
+                <el-table-column prop="hisDate1" label="时间点" align="center" min-width="200" />
+                <el-table-column prop="temperature2" label="温度" align="center" min-width="80" />
+                <el-table-column prop="hisDate2" label="时间点" align="center" min-width="200" />
+                <el-table-column prop="temperature3" label="温度" align="center" min-width="80" />
+                <el-table-column prop="hisDate3" label="时间点" align="center" min-width="200" />
+                <el-table-column prop="temperature4" label="温度" align="center" min-width="80" />
+                <el-table-column prop="hisDate4" label="时间点" align="center" min-width="200" />
+              </el-table>
+              <template></template>
+            </div>
+            <h2>保温箱温湿度列表</h2>
+            <div v-for="(item, index) in dataBox">
+              <h2>
+                ============================================================================================================================
+              </h2>
               <el-descriptions>
-                <el-descriptions-item label="开始时间">{{this.basicData.startTime}}</el-descriptions-item>
-                <el-descriptions-item label="结束时间">{{this.basicData.endTime}}</el-descriptions-item>
+                <el-descriptions-item label="订单编号">{{item[0].billCode}}</el-descriptions-item>
+                <el-descriptions-item label="保温箱号">{{item[0].measuringPointName}}</el-descriptions-item>
+                <el-descriptions-item label="探头">{{item[0].measuringPointAddr}}</el-descriptions-item>
+                <el-descriptions-item label="开始时间">{{item[0].hisDate}}</el-descriptions-item>
+                <el-descriptions-item label="结束时间">{{item[item.length - 1].end}}</el-descriptions-item>
               </el-descriptions>
-              <!--导出按钮-->
-              <el-button class="OutCss" v-print="'#print'" type="primary">导出</el-button>
-            </el-timeline>
-          </el-timeline>
-          <el-timeline>
-            <!-- 数据表 -->
-            <h2>订单温湿度列表</h2>
-            <el-table :data="tableData2" stripe border style="width: 97%">
-              <el-table-column prop="measuringPointName" label="车牌号或保温箱" align="center" min-width="150" />
-              <el-table-column prop="measuringPointAddr" label="探头" align="center" min-width="90" />
-              <el-table-column prop="temperature" label="温度" align="center" min-width="80" />
-              <el-table-column prop="hisDate" label="时间点" align="center" min-width="200" />
-              <el-table-column prop="measuringPointName1" label="车牌号或保温箱" align="center" min-width="150" />
-              <el-table-column prop="measuringPointAddr1" label="探头" align="center" min-width="90" />
-              <el-table-column prop="temperature1" label="温度" align="center" min-width="80" />
-              <el-table-column prop="hisDate1" label="时间点" align="center" min-width="200" />
-              <!-- <el-table-column prop="address" label="地址" width="400" /> -->
-            </el-table>
+              <el-table :data="item" stripe border style="width: 97%">
+                <el-table-column prop="temperature" label="温度" align="center" min-width="80" />
+                <el-table-column prop="hisDate" label="时间点" align="center" min-width="200" />
+                <el-table-column prop="temperature1" label="温度" align="center" min-width="80" />
+                <el-table-column prop="hisDate1" label="时间点" align="center" min-width="200" />
+                <el-table-column prop="temperature2" label="温度" align="center" min-width="80" />
+                <el-table-column prop="hisDate2" label="时间点" align="center" min-width="200" />
+                <el-table-column prop="temperature3" label="温度" align="center" min-width="80" />
+                <el-table-column prop="hisDate3" label="时间点" align="center" min-width="200" />
+                <el-table-column prop="temperature4" label="温度" align="center" min-width="80" />
+                <el-table-column prop="hisDate4" label="时间点" align="center" min-width="200" />
+              </el-table>
+            </div>
           </el-timeline>
         </div>
         <br>
@@ -148,7 +174,10 @@
         aggT: 0,
         aggH: 0,
         avgT: 0,
-        avgH: 0
+        avgH: 0,
+        dataCar: [],
+        dataBox: [],
+        dataMerge: [],
       };
     },
     mounted() {
@@ -161,11 +190,9 @@
       if (this.carMessage.boxCode != null) {
         this.carMessage.boxCode = this.$route.query.boxCode.split(',');
       }
-      //当结束时间为空时,默认为当前时间
-      if (this.carMessage.endTime == '' || this.carMessage.endTime == null) {
-        this.carMessage.endTime = this.formatDateTime(this.getCurrentTime(), 'yyyy-MM-dd HH:mm:ss');
-      }
       console.log(this.carMessage, 'this.carMessage')
+      // 所有数据的总集合
+      this.merge(this.carMessage);
       this.handleGeocodeRepo(this.carMessage);
     },
     methods: {
@@ -174,14 +201,17 @@
         historyApi.queryAddress(data).then(res => {
           console.log(res, 'res-----------------');
           if (res.code == 200) {
+            // 表格中分列展示数据
+            this.listSplitting(res.data.car, res.data.box);
+            console.log(this.dataCar, 'this.dataCar');
             //定义路线数组
             let path = [];
             //筛选含经纬度的数组
             let latitudeLongitude = [];
             let count = 0;
-            for (let i = 0; i < res.data.length; i++) {
-              if (res.data[i].gpsLatitude != 0 && res.data[i].gpsLongitude != 0) {
-                latitudeLongitude[count++] = res.data[i];
+            for (let i = 0; i < this.dataMerge.length; i++) {
+              if (this.dataMerge[i].gpsLatitude != 0 && this.dataMerge[i].gpsLongitude != 0) {
+                latitudeLongitude[count++] = this.dataMerge[i];
               }
             }
             //定义整数递增值,并且绘制初始路径
@@ -196,9 +226,9 @@
               }
             }
             //计算各值
-            this.calculate(res.data);
+            this.calculate(this.dataMerge);
             //对订单温湿度列表进行赋值
-            this.assignmentTable1(res.data);
+            this.assignmentTable1(this.dataMerge);
             //提取探头种类数量
             let probeSum = [];
             let probe = [];
@@ -332,10 +362,10 @@
                   }
                 }
                 // count = 0;
-                for (let j = 0; j < res.data.length; j++) {
-                  if (boxForm.name == res.data[j].measuringPointName) {
-                    e = res.data[j].hisDate;
-                    f = res.data[j].temperature;
+                for (let j = 0; j < this.dataMerge.length; j++) {
+                  if (boxForm.name == this.dataMerge[j].measuringPointName) {
+                    e = this.dataMerge[j].hisDate;
+                    f = this.dataMerge[j].temperature;
                     boxForm.data.push([e, f]);
                   }
                 }
@@ -555,46 +585,150 @@
         this.modelData1[0].startTime = array[0].hisDate;
         this.modelData1[0].endTime = array[array.length - 1].hisDate;
         this.tableData1 = this.modelData1;
-        let median = (array.length / 2).toFixed(0);
-        let table = []
-        for (let i = 0; i < median; i++) {
-          table[i] = {
-            measuringPointName: '',
-            measuringPointAddr: '',
-            temperature: '',
-            hisDate: '',
-            measuringPointName1: '',
-            measuringPointAddr1: '',
-            temperature1: '',
-            hisDate1: ''
+        //   let median = (array.length / 2).toFixed(0);
+        //   let table = []
+        //   for (let i = 0; i < median; i++) {
+        //     table[i] = {
+        //       measuringPointName: '',
+        //       measuringPointAddr: '',
+        //       temperature: '',
+        //       hisDate: '',
+        //       measuringPointName1: '',
+        //       measuringPointAddr1: '',
+        //       temperature1: '',
+        //       hisDate1: ''
+        //     }
+        //   }
+        //   if (array.length % 2 == 0) {
+        //     for (let i = 0, j = 0, z = 1; i < median; i++, j = j + 2, z = z + 2) {
+        //       table[i].measuringPointName = array[j].measuringPointName;
+        //       table[i].measuringPointAddr = array[j].measuringPointAddr;
+        //       table[i].temperature = array[j].temperature;
+        //       table[i].hisDate = array[j].hisDate;
+        //       table[i].measuringPointName1 = array[z].measuringPointName;
+        //       table[i].measuringPointAddr1 = array[z].measuringPointAddr;
+        //       table[i].temperature1 = array[z].temperature;
+        //       table[i].hisDate1 = array[z].hisDate;
+        //     }
+        //   } else {
+        //     for (let i = 0, j = 0, z = 1; i < median; i++, j = j + 2, z = z + 2) {
+        //       table[i].measuringPointName = array[j].measuringPointName;
+        //       table[i].measuringPointAddr = array[j].measuringPointAddr;
+        //       table[i].temperature = array[j].temperature;
+        //       table[i].hisDate = array[j].hisDate;
+        //       if (i != median - 1) {
+        //         table[i].measuringPointName1 = array[z].measuringPointName;
+        //         table[i].measuringPointAddr1 = array[z].measuringPointAddr;
+        //         table[i].temperature1 = array[z].temperature;
+        //         table[i].hisDate1 = array[z].hisDate;
+        //       }
+        //     }
+        //   }
+        //   this.tableData2 = table;
+      },
+      merge(data) {
+        historyApi.getMerge(data).then(res => {
+          if (res.code == 200) {
+            this.dataMerge = res.data;
+            console.log(this.dataMerge, 'dataMerge')
           }
-        }
-        if (array.length % 2 == 0) {
-          for (let i = 0, j = 0, z = 1; i < median; i++, j = j + 2, z = z + 2) {
-            table[i].measuringPointName = array[j].measuringPointName;
-            table[i].measuringPointAddr = array[j].measuringPointAddr;
-            table[i].temperature = array[j].temperature;
-            table[i].hisDate = array[j].hisDate;
-            table[i].measuringPointName1 = array[z].measuringPointName;
-            table[i].measuringPointAddr1 = array[z].measuringPointAddr;
-            table[i].temperature1 = array[z].temperature;
-            table[i].hisDate1 = array[z].hisDate;
+        })
+      },
+      // 表格数据分列展示
+      listSplitting(dataCar, dataBox) {
+        let differenceValueCar;
+        let arr2 = [];
+        for (let i = 0; i < dataCar.length; i++) {
+          let arr3 = [];
+          // 向上取整差值
+          differenceValueCar = Math.ceil(dataCar[i].length / 5);
+          for (let j = 0; j < dataCar[i].length; j++) {
+            if (j == differenceValueCar) {
+              for (let z = 0; z < differenceValueCar; z++) {
+                dataCar[i][z].temperature1 = dataCar[i][j + z].temperature;
+                dataCar[i][z].hisDate1 = dataCar[i][j + z].hisDate;
+              }
+            }
+            if (j == differenceValueCar * 2) {
+              for (let z = 0; z < differenceValueCar; z++) {
+                dataCar[i][z].temperature2 = dataCar[i][j + z].temperature;
+                dataCar[i][z].hisDate2 = dataCar[i][j + z].hisDate;
+              }
+            }
+            if (j == differenceValueCar * 3) {
+              for (let z = 0; z < differenceValueCar; z++) {
+                dataCar[i][z].temperature3 = dataCar[i][j + z].temperature;
+                dataCar[i][z].hisDate3 = dataCar[i][j + z].hisDate;
+              }
+            }
+            if (j == differenceValueCar * 4) {
+              for (let z = 0; z < differenceValueCar; z++) {
+                if (j + z < dataCar[i].length) {
+                  dataCar[i][z].temperature4 = dataCar[i][j + z].temperature;
+                  dataCar[i][z].hisDate4 = dataCar[i][j + z].hisDate;
+                }
+              }
+            }
+            if (j < differenceValueCar) {
+              arr3.push(dataCar[i][j]);
+              console.log(arr3, 'arr3')
+            }
           }
-        } else {
-          for (let i = 0, j = 0, z = 1; i < median; i++, j = j + 2, z = z + 2) {
-            table[i].measuringPointName = array[j].measuringPointName;
-            table[i].measuringPointAddr = array[j].measuringPointAddr;
-            table[i].temperature = array[j].temperature;
-            table[i].hisDate = array[j].hisDate;
-            if (i != median - 1) {
-              table[i].measuringPointName1 = array[z].measuringPointName;
-              table[i].measuringPointAddr1 = array[z].measuringPointAddr;
-              table[i].temperature1 = array[z].temperature;
-              table[i].hisDate1 = array[z].hisDate;
+          arr2.push(arr3);
+          this.queryEnd(arr2[i], differenceValueCar);
+        }
+        this.dataCar = arr2;
+        let differenceValueBox;
+        let arr = [];
+        for (let i = 0; i < dataBox.length; i++) {
+          let arr1 = [];
+          // 向上取整差值
+          differenceValueBox = Math.ceil(dataBox[i].length / 5);
+          for (let j = 0; j < dataBox[i].length; j++) {
+            if (j == differenceValueBox) {
+              for (let z = 0; z < differenceValueBox; z++) {
+                dataBox[i][z].temperature1 = dataBox[i][j + z].temperature;
+                dataBox[i][z].hisDate1 = dataBox[i][j + z].hisDate;
+              }
             }
+            if (j == differenceValueBox * 2) {
+              for (let z = 0; z < differenceValueBox; z++) {
+                dataBox[i][z].temperature2 = dataBox[i][j + z].temperature;
+                dataBox[i][z].hisDate2 = dataBox[i][j + z].hisDate;
+              }
+            }
+            if (j == differenceValueBox * 3) {
+              for (let z = 0; z < differenceValueBox; z++) {
+                dataBox[i][z].temperature3 = dataBox[i][j + z].temperature;
+                dataBox[i][z].hisDate3 = dataBox[i][j + z].hisDate;
+              }
+            }
+            if (j == differenceValueBox * 4) {
+              for (let z = 0; z < differenceValueBox; z++) {
+                if (j + z < dataBox[i].length) {
+                  dataBox[i][z].temperature4 = dataBox[i][j + z].temperature;
+                  dataBox[i][z].hisDate4 = dataBox[i][j + z].hisDate;
+                }
+              }
+            }
+            if (j < differenceValueBox) {
+              arr1.push(dataBox[i][j]);
+            }
+          }
+          arr.push(arr1);
+          console.log(arr, 'arr')
+          this.queryEnd(arr[i], differenceValueBox);
+        }
+        this.dataBox = arr;
+      },
+      // 查找结束时间
+      queryEnd(arr, differenceValue) {
+        for (let j = differenceValue - 1; j >= 0; j--) {
+          if (arr[j].hisDate4 != null && arr[j].hisDate4 != '' && arr[j].hisDate4 != undefined) {
+            arr[differenceValue - 1].end = arr[j].hisDate4;
+            return;
           }
         }
-        this.tableData2 = table;
       },
       //获取当前时间
       getCurrentTime() {