Browse Source

额定风速2

malijun 8 months ago
parent
commit
b9ee40bb5b
1 changed files with 27 additions and 2 deletions
  1. 27 2
      ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

+ 27 - 2
ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

@@ -1126,14 +1126,15 @@ public class JavaFunctionJobHandler extends IJobHandler {
             PointInfo turbineZt = calcTurbineDizt2(wtUcPis.get(wtId), latest, start, end, 60);
             PointInfo turbineAizt = calcTurbineAizt2(aiztMap.get(wtId), collectAi, start, end, 60);
             Map<Double, Double> fit = new TreeMap<>();
+            double capacity = 2000;
             if (turbineZt != null) {
-                double capacity = map.get(turbineZt.getSpare()).getPowerProduction();
+                capacity = map.get(turbineZt.getSpare()).getPowerProduction();
                 fit = dataProcessAndFit(ef, glInfo, turbineZt, CalcCache.bzgl.get(turbineZt.getSpare()), capacity);
 //                fitMap.put(wtId, fit);
                 turbineZt.setPointDatas(null);
             }
             if (turbineAizt != null) {
-                double capacity = map.get(turbineAizt.getSpare()).getPowerProduction();
+                capacity = map.get(turbineAizt.getSpare()).getPowerProduction();
                 fit = dataProcessAndFit(ef, glInfo, turbineAizt, CalcCache.bzgl.get(turbineAizt.getSpare()), capacity);
 //                fitMap.put(wtId, fit);
                 turbineAizt.setPointDatas(null);
@@ -1144,6 +1145,30 @@ public class JavaFunctionJobHandler extends IJobHandler {
             //存redis
 //            stringRedisTemplate.opsForValue().set("glqxnh:" + end.getMonth() + ":" + wtId, JSON.toJSONString(fit));
 
+
+            //符合条件的风速和
+            List<Double> listDouble = new ArrayList<>();
+            //遍历fit集合,取出值与capacity相等的key
+            if (!fit.isEmpty()) {
+                for (double key : fit.keySet()) {
+                    Double v = fit.get(key);
+                    //如果v-capacity的值小于10大于-10,则把key加入listDouble
+                    if ((Math.abs(v - capacity) <= 10) && Math.abs(v - capacity) >= -10) {
+                        listDouble.add(key);
+                    }
+                }
+            }
+            //取出listDouble的值求平均值
+            double agValue = 0;
+            if (!listDouble.isEmpty()) {
+                for (Double aDouble : listDouble) {
+                    agValue += aDouble;
+                }
+                agValue = agValue / listDouble.size();
+            }
+
+            System.out.println("wtId:" + wtId + "agValue平均额定风速:"+agValue );
+
         }
 
 //        stringRedisTemplate.opsForValue().set("glqxnh", JSON.toJSONString(fitMap));