Browse Source

一厂泵功图计算修改

gxt 1 year ago
parent
commit
47dacc42a3
1 changed files with 13 additions and 30 deletions
  1. 13 30
      src/main/java/com/gct/aoid/algorithm/CalPumpCard.java

+ 13 - 30
src/main/java/com/gct/aoid/algorithm/CalPumpCard.java

@@ -1,6 +1,5 @@
1 1
 package com.gct.aoid.algorithm;
2 2
 
3
-import com.alibaba.fastjson.JSONObject;
4 3
 import com.gct.aoid.entity.DiagramCardBaseParam;
5 4
 import com.gct.aoid.entity.SingleDiagramDiagnoseResult;
6 5
 import com.gct.common.util.SGTUtil;
@@ -201,42 +200,26 @@ public class CalPumpCard {
201 200
         //ProcessParam2 pp2 = new ProcessParam2(); //Commented by lloyd 2021.1.30
202 201
         double tmpDownLevel = 0.001;
203 202
         double tmpUpLevel = 0, downLoadingLevel = 0, upLoadingLevel = 0;
204
-        int tmpANNNum = 0;
205 203
         if (isLegal != 1) return null;//功图不合法不能计算
206 204
 
207 205
         Double[][] cardArray = SGTUtil.diagramReverse(sgt);
208
-
209
-        while (tmpANNNum == 0) {
210
-            boolean flag = false;
211
-            for (int i = 0; i < sgt.length / 2; i++) {
212
-                if (cardArray[0][i] <= S * tmpDownLevel) {
213
-                    tmpANNNum++;
214
-                    downLoadingLevel += cardArray[1][i];
215
-                    flag = true;
216
-                    break;
217
-                }
206
+        double minS = 999999, maxS = -999999;
207
+        for (Double[] point : sgt) {
208
+            if (point[0] > maxS) maxS = point[0];
209
+            if (point[0] < minS) minS = point[0];
210
+        }
211
+        int downNum = 0, upNum = 0;
212
+        for (Double[] point : sgt) {
213
+            if (point[0] <= minS * 1.001) {
214
+                downLoadingLevel = (downLoadingLevel * downNum + point[1]) / (downNum + 1);
215
+                downNum++;
218 216
             }
219
-            if (tmpANNNum == 0 && !flag) {
220
-                log.error("泵功图无法计算::==>params:sgt={},S={},isLegal={},N={},result2={}", JSONObject.toJSONString(sgt),
221
-                        S,isLegal,N,result2);
222
-                return null;
217
+            if (point[0] >= maxS * 0.98) {
218
+                upLoadingLevel = (upLoadingLevel * upNum + point[1]) / (upNum + 1);
219
+                upNum++;
223 220
             }
224
-            tmpDownLevel += 0.001;
225 221
         }
226 222
 
227
-        downLoadingLevel = downLoadingLevel / tmpANNNum;
228
-        tmpANNNum = 0;
229
-        tmpUpLevel = 0.98;
230
-        while (tmpANNNum == 0) {
231
-            for (int i = 0; i < sgt.length; i++) {
232
-                if (cardArray[0][i] >= S * tmpUpLevel) {
233
-                    tmpANNNum++;
234
-                    upLoadingLevel = upLoadingLevel + cardArray[1][i];
235
-                }
236
-            }
237
-            tmpUpLevel = tmpUpLevel - 0.001;
238
-        }
239
-        upLoadingLevel /= tmpANNNum;
240 223
         double[] tmpdDMWY = new double[sgt.length];
241 224
         double[] tmpdDMYeZH = new double[sgt.length];
242 225
         Double[][] DBU;