Browse Source

优化额定风速计算

malijun 5 months ago
parent
commit
2a1b586d88
1 changed files with 60 additions and 59 deletions
  1. 60 59
      ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

+ 60 - 59
ruoyi-admin/src/test/java/com/ruoyi/JavaFunctionJobHandler.java

@@ -1083,7 +1083,6 @@ public class JavaFunctionJobHandler extends IJobHandler {
     }
 
 
-
     public Map<Double, Double> dataProcessAndFit(PointInfo fsPI, PointInfo glPI, PointInfo ztPI, Map<Double, Double> modelPowerMap, double capacity) {
         List<PointData> fsPds = fsPI.getPointDatas();
         List<PointData> glPds = glPI.getPointDatas();
@@ -1233,7 +1232,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
         QueryWrapper<PointInfo> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("uniform_code", "AI066");
 
-        List<PointInfo>pointInfos = getEntity("AI066", "turbine");
+        List<PointInfo> pointInfos = getEntity("AI066", "turbine");
 //        List<PointInfo> pointInfos = pointInfo.selectList(queryWrapper);
 
         //定义切入风速map集合
@@ -1432,84 +1431,86 @@ public class JavaFunctionJobHandler extends IJobHandler {
                     NumberUtil.round(pd.getValue(), 2).doubleValue())).collect(Collectors.toList());
             ef.setPointDatas(peek);
 
-            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) {
-                capacity = map.get(turbineZt.getSpare()).getPowerProduction();
-                fit = dataProcessAndFit(ef, glInfo, turbineZt, CalcCache.bzgl.get(turbineZt.getSpare()), capacity);
+            try {
+                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) {
+                    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) {
-                capacity = map.get(turbineAizt.getSpare()).getPowerProduction();
-                fit = dataProcessAndFit(ef, glInfo, turbineAizt, CalcCache.bzgl.get(turbineAizt.getSpare()), capacity);
+                    turbineZt.setPointDatas(null);
+                }
+                if (turbineAizt != null) {
+                    capacity = map.get(turbineAizt.getSpare()).getPowerProduction();
+                    fit = dataProcessAndFit(ef, glInfo, turbineAizt, CalcCache.bzgl.get(turbineAizt.getSpare()), capacity);
 //                fitMap.put(wtId, fit);
-                turbineAizt.setPointDatas(null);
-            }
-            ef.setPointDatas(null);
-            glInfo.setPointDatas(null);
+                    turbineAizt.setPointDatas(null);
+                }
+                ef.setPointDatas(null);
+                glInfo.setPointDatas(null);
 
-            //存redis
+                //存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);
+                //符合条件的风速和
+                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;
+                //取出listDouble的值求平均值
+                double agValue = 0;
+                if (!listDouble.isEmpty()) {
+                    for (Double aDouble : listDouble) {
+                        agValue += aDouble;
+                    }
+                    agValue = agValue / listDouble.size();
                 }
-                agValue = agValue / listDouble.size();
-            }
-            System.out.println("wtId:" + wtId + "agValue平均额定风速:" + agValue);
+                System.out.println("wtId:" + wtId + "agValue平均额定风速:" + agValue);
 
 
-            //存入数据库
-            System.out.println(wtId + " " + start);
-            QueryWrapper<TurbineInfoDay> turbineInfoDayQueryWrapper = new QueryWrapper<>();
-            turbineInfoDayQueryWrapper.eq("turbine_id", wtId);
-            turbineInfoDayQueryWrapper.eq("record_date", start);
-            TurbineInfoDay one = turbineInfoDayService.getOne(turbineInfoDayQueryWrapper);
-            System.out.println(one);
-            if (one == null) {
-                TurbineInfoDay turbineInfoDay = new TurbineInfoDay();
-                turbineInfoDay.setTurbineId(wtId);
-                turbineInfoDay.setRecordDate(start);
-                turbineInfoDay.setEdfs(agValue);
-                System.out.println(turbineInfoDay);
-                turbineInfoDayService.save(turbineInfoDay);
-            } else {
-                one.setEdfs(agValue);
+                //存入数据库
+                System.out.println(wtId + " " + start);
+                QueryWrapper<TurbineInfoDay> turbineInfoDayQueryWrapper = new QueryWrapper<>();
+                turbineInfoDayQueryWrapper.eq("turbine_id", wtId);
+                turbineInfoDayQueryWrapper.eq("record_date", start);
+                TurbineInfoDay one = turbineInfoDayService.getOne(turbineInfoDayQueryWrapper);
                 System.out.println(one);
-                turbineInfoDayService.updateById(one);
+                if (one == null) {
+                    TurbineInfoDay turbineInfoDay = new TurbineInfoDay();
+                    turbineInfoDay.setTurbineId(wtId);
+                    turbineInfoDay.setRecordDate(start);
+                    turbineInfoDay.setEdfs(agValue);
+                    System.out.println(turbineInfoDay);
+                    turbineInfoDayService.save(turbineInfoDay);
+                } else {
+                    one.setEdfs(agValue);
+                    System.out.println(one);
+                    turbineInfoDayService.updateById(one);
+                }
+
+            }catch (Exception e) {
+                System.out.println(wtId + " " + start);
             }
 
 
+
         }
 
 //        stringRedisTemplate.opsForValue().set("glqxnh", JSON.toJSONString(fitMap));
     }
 
 
+}
 
 
 
-    }
-
-
-
-}