Sfoglia il codice sorgente

智能报表优化排序

kukuasir@vip.qq.com 1 anno fa
parent
commit
db7a7e57fd
2 ha cambiato i file con 24 aggiunte e 18 eliminazioni
  1. 0 1
      src/js/merge.js
  2. 24 17
      src/js/sort.js

+ 0 - 1
src/js/merge.js

@@ -32,7 +32,6 @@ export function expandAllNodes(boxList) {
       });
     }
   });
-	console.log(">>> 合并之后: ", tableData)
 	// 合并单机
 	return _getStandaloneSpanRows(tableData)
 }

+ 24 - 17
src/js/sort.js

@@ -5,17 +5,15 @@ export function sortBoxListByHost(data, sort) {
   for (let i = 0; i < data.length; i++) {
     const box = data[i];
     const hostCtrl = box.hostCtrl || [];
-    let maxVal = 0;
+    let maxVal = -1;
     for (let j = 0; j < hostCtrl.length; j++) {
       const hp = hostCtrl[j];
-      // if (_isFloat(sort.prop)) {
-      //   if (hp[sort.prop] > maxVal && box.runStatus == 1) {
-      //     maxVal = hp[sort.prop];
-      //   }
-      // } else {
-      //   // TODO:
-      // }
-      if (hp[sort.prop] > maxVal && box.runStatus == 1) {
+      if (
+        hp[sort.prop] > maxVal &&
+        box.runStatus == 1 &&
+        hp.host_su_temp &&
+        hp.host_re_temp
+      ) {
         maxVal = hp[sort.prop];
       }
     }
@@ -30,7 +28,7 @@ export function sortBoxListByNewTrend(data, sort) {
   for (let i = 0; i < data.length; i++) {
     const box = data[i];
     const newTrendCtrl = box.newTrendCtrl || [];
-    let maxVal = 0;
+    let maxVal = -1;
     for (let j = 0; j < newTrendCtrl.length; j++) {
       const dh = newTrendCtrl[j];
       if (dh[sort.prop] > maxVal && box.runStatus == 1) {
@@ -48,7 +46,7 @@ export function sortBoxListByHeatExchange(data, sort) {
   for (let i = 0; i < data.length; i++) {
     const box = data[i];
     const heatExchangeCtrl = box.hex || [];
-    let maxVal = 0;
+    let maxVal = -1;
     for (let j = 0; j < heatExchangeCtrl.length; j++) {
       const hex = heatExchangeCtrl[j];
       if (hex[sort.prop] > maxVal && box.runStatus == 1) {
@@ -65,14 +63,23 @@ export function sortBoxListByEnd(data, sort) {
   for (let i = 0; i < data.length; i++) {
     const box = data[i];
     const endCtrl = box.end || [];
-    let maxVal = 0;
-    for (let j = 0; j < endCtrl.length; j++) {
-      const end = endCtrl[j];
-      if (end[sort.prop] > maxVal && box.runStatus == 1) {
-        maxVal = end[sort.prop];
+    // 末端的通讯异常数量比较特殊,需要累加起来计算
+    if (sort.prop === "end_exception_num" && box.runStatus == 1) {
+      let total_end_exception_num = 0;
+      for (let j = 0; j < endCtrl.length; j++) {
+        total_end_exception_num += endCtrl[j].end_exception_num;
       }
+      box.max_end_exception_num = total_end_exception_num;
+    } else {
+      let maxVal = -1;
+      for (let j = 0; j < endCtrl.length; j++) {
+        const end = endCtrl[j];
+        if (end[sort.prop] > maxVal && box.runStatus == 1) {
+          maxVal = end[sort.prop];
+        }
+      }
+      box["max_" + sort.prop] = maxVal;
     }
-    box["max_" + sort.prop] = maxVal;
   }
   return _sortData(data, sort);
 }