Browse Source

增加各个段的曲线偏差率,运行时间统计

chenminghua 2 years ago
parent
commit
40cb91d054

+ 5 - 4
power-fitting/src/main/java/com/gyee/power/fitting/common/alg/PowerFittingALG.java

@@ -8,6 +8,7 @@ import java.text.DecimalFormat;
 import java.util.ArrayList;
 import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 /**
@@ -320,11 +321,11 @@ public class PowerFittingALG {
             double count = 0;
             double sum = 0;
             for (Point point : points1){
-                List<Point> list = points2.stream().filter(it -> it.getX() == point.getX()).collect(Collectors.toList());
-                if (list.size() > 0 && list.get(0).getX() >= minSpeed && list.get(0).getX() < maxSpeed){
-                    sum += Math.pow(point.getY() - list.get(0).getY(), 2);
+                Optional<Point> p = points2.stream().filter(it -> it.getX() == point.getX()).findFirst();
+                if (p.isPresent() && p.get().getX() >= minSpeed && p.get().getX() < maxSpeed){
+                    sum += Math.pow(point.getY() - p.get().getY(), 2);
                     count ++;
-                    pc += point.getY() - list.get(0).getY();
+                    pc += point.getY() - p.get().getY();
                 }
             }
             sum = Math.sqrt(sum);

+ 6 - 1
power-fitting/src/main/java/com/gyee/power/fitting/common/config/GyeeConfig.java

@@ -6,6 +6,7 @@ import org.springframework.boot.system.ApplicationHome;
 import org.springframework.stereotype.Component;
 
 import java.io.File;
+import java.util.Arrays;
 import java.util.List;
 
 @Data
@@ -30,10 +31,14 @@ public class GyeeConfig {
     /** 数据压缩下载 **/
     private String filePathDownload;
     /** 功率曲线拟合测点 **/
-    private List<String> points;
+    private String points;
     /** 适配器读取数据等间隔时间 **/
     private Integer interval;
 
+    public List<String> getPoints() {
+        return Arrays.asList(this.points.split(","));
+    }
+
     public String getFilePathPrepare() {
         return jarF.getParentFile().getAbsolutePath() + "\\" + filePathPrepare;
     }

+ 16 - 5
power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/DataFittingController.java

@@ -107,11 +107,11 @@ public class DataFittingController {
      * @param id 曲线拟合的id
      * @return
      */
-    @GetMapping("curve/ratio")
-    public JSONObject dataCurveRatio(String id){
-        Map<String, Double> map = fittingService.dataCurveRatio(id);
-        return JsonResult.successData(ResultCode.SUCCESS, map);
-    }
+//    @GetMapping("curve/ratio")
+//    public JSONObject dataCurveRatio(String id){
+//        Map<String, Double> map = fittingService.dataCurveRatio(id);
+//        return JsonResult.successData(ResultCode.SUCCESS, map);
+//    }
 
 
     /**
@@ -124,4 +124,15 @@ public class DataFittingController {
         Object o = fittingService.dataFittingLine(ids);
         return JsonResult.successData(ResultCode.SUCCESS, o);
     }
+
+    /**
+     * 获取多风机的运行时间 统计并网时间  3-5m   5-10m   10-12m   12-25m
+     * @param ids  拟合好的数据ID
+     * @return
+     */
+    @GetMapping("time")
+    public JSONObject dataFittingYXTime(String ids){
+        Object o = fittingService.dataFittingTime(ids);
+        return JsonResult.successData(ResultCode.SUCCESS, o);
+    }
 }

+ 12 - 0
power-fitting/src/main/java/com/gyee/power/fitting/model/Powerfittinganalysis.java

@@ -64,6 +64,18 @@ public class Powerfittinganalysis extends Model<Powerfittinganalysis> {
     @TableField("PCRATIO")
     private Double pcratio;
 
+    @TableField("PC5RATIO")
+    private Double pc5ratio;
+
+    @TableField("PC10RATIO")
+    private Double pc10ratio;
+
+    @TableField("PC12RATIO")
+    private Double pc12ratio;
+
+    @TableField("PC25RATIO")
+    private Double pc25ratio;
+
 
 
     @Override

+ 73 - 29
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/DataFittingService.java

@@ -4,6 +4,7 @@ import com.gyee.power.fitting.common.alg.DBSCANPointALG;
 import com.gyee.power.fitting.common.config.GyeeConfig;
 import com.gyee.power.fitting.common.constants.Constants;
 import com.gyee.power.fitting.common.spring.InitialRunner;
+import com.gyee.power.fitting.common.util.DateUtil;
 import com.gyee.power.fitting.common.util.FileUtil;
 import com.gyee.power.fitting.common.alg.PowerFittingALG;
 import com.gyee.power.fitting.common.util.PowerFittingUtil;
@@ -278,6 +279,7 @@ public class DataFittingService {
 
         //功率曲线拟合
         List<Point> temp = PowerFittingALG.buildLine(arrX, arrY, arraySpeed.size(), dimension, 0.01);
+        temp.forEach(f -> { if (f.getX() < 2.5 && f.getY() > 0) f.setY(0); });
 
         //推力系数 CP值
         LineCurveFitting lf = new LineCurveFitting();
@@ -285,14 +287,7 @@ public class DataFittingService {
         lf = PowerFittingALG.buildCp(InitialRunner.equipmentMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid()).getSweptarea(), lf);
 
         //曲线偏差率
-        List<Point> pointsAll = new ArrayList<>();
-        List<Modelpowerdetails> mp = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid());
-        for (int i = 0; i < mp.size(); i++){
-            Modelpowerdetails power = mp.get(i);
-            pointsAll.add(new Point(power.getSpeed(), power.getEnsurepower()));
-        }
-        double maxp = mp.stream().max(Comparator.comparing(d -> d.getEnsurepower())).get().getEnsurepower();
-        double pcl = PowerFittingALG.curveDeviationRatio(temp, pointsAll, maxp);
+        dataCurveRatio(lf, obj);
 
         String content = assemble(lf);
         String prepareId = "";
@@ -314,7 +309,6 @@ public class DataFittingService {
             obj.setPath(fileName);
             obj.setPrepareid(prepareId);
             obj.setCpavg(lf.getCpAvg());
-            obj.setPcratio(pcl);
             obj.setType(Constants.DATA_FITTING);
             powerService.insertItem(obj);
         }
@@ -350,35 +344,36 @@ public class DataFittingService {
 
     /**
      * 曲线偏差率  分段的+全部的
-     * @param id
      *  3-5  5-10  10-12  12-25
      * @return
      */
-    public Map<String, Double> dataCurveRatio(String id) {
-        Map<String, Double> map = new HashMap<>();
+    private void dataCurveRatio(LineCurveFitting lf, Powerfittinganalysis obj) {
         DecimalFormat df = new DecimalFormat("0.00");
-        Powerfittinganalysis obj = powerService.selectItemById(id);
         try{
             //风速、实际功率
+            List<Point> point = new ArrayList<>();  //3-25m
             List<Point> point5 = new ArrayList<>();  //分段
             List<Point> point10 = new ArrayList<>();  //分段
             List<Point> point12= new ArrayList<>();  //分段
             List<Point> point25 = new ArrayList<>();  //分段
-            List<String> ls = FileUtil.readFile(obj.getPath(), true);
-            for (int i = 1; i < ls.size(); i++){
-                String[] split = ls.get(i).split(",");
-                double speed = Double.valueOf(split[0]);
+            List<Point> line = lf.getYLines();
+            for (int i = 1; i < line.size(); i++){
+                double speed = Double.valueOf(df.format(line.get(i).getX()));
                 if (speed >= 3 && speed < 5)
-                    point5.add(new Point(speed, Double.valueOf(split[1])));
+                    point5.add(new Point(speed, line.get(i).getY()));
                 if (speed >= 5 && speed < 10)
-                    point10.add(new Point(speed, Double.valueOf(split[1])));
+                    point10.add(new Point(speed, line.get(i).getY()));
                 if (speed >= 10 && speed < 12)
-                    point12.add(new Point(speed, Double.valueOf(split[1])));
+                    point12.add(new Point(speed, line.get(i).getY()));
                 if (speed >= 12 && speed <= 25)
-                    point25.add(new Point(speed, Double.valueOf(split[1])));
+                    point25.add(new Point(speed, line.get(i).getY()));
+                if (speed >= 3 && speed <= 25){
+                    point.add(new Point(speed, line.get(i).getY()));
+                }
             }
 
             //保证功率
+            List<Point> points = new ArrayList<>();  //3-25m
             List<Point> points5 = new ArrayList<>();  //分段
             List<Point> points10 = new ArrayList<>();  //分段
             List<Point> points12 = new ArrayList<>();  //分段
@@ -394,6 +389,8 @@ public class DataFittingService {
                     points12.add(new Point(power.getSpeed(), power.getEnsurepower()));
                 if (power.getSpeed() >= 12 && power.getSpeed() <= 25)
                     points25.add(new Point(power.getSpeed(), power.getEnsurepower()));
+                if (power.getSpeed() >= 3 && power.getSpeed() <= 25)
+                    points.add(new Point(power.getSpeed(), power.getEnsurepower()));
             }
 
             double maxp5 = list.stream().filter(f -> 5.0 == f.getSpeed()).collect(Collectors.toList()).get(0).getEnsurepower();
@@ -401,23 +398,22 @@ public class DataFittingService {
             double maxp12 = list.stream().filter(f -> 12.0 == f.getSpeed()).collect(Collectors.toList()).get(0).getEnsurepower();
             double maxp25 = list.stream().filter(f -> 25.0 == f.getSpeed()).collect(Collectors.toList()).get(0).getEnsurepower();
 
-
             //曲线偏差率
+            double pcl = PowerFittingALG.curveDeviationRatio2(point, points, maxp25, 11);
             double pcl5 = PowerFittingALG.curveDeviationRatio2(point5, points5, maxp5, 3);
             double pcl10 = PowerFittingALG.curveDeviationRatio2(point10, points10, maxp10, 5);
             double pcl12 = PowerFittingALG.curveDeviationRatio2(point12, points12, maxp12, 10);
             double pcl25 = PowerFittingALG.curveDeviationRatio2(point25, points25, maxp25, 12);
 
-            map.put("pcl5", Double.valueOf(df.format(pcl5)));
-            map.put("pcl10", Double.valueOf(df.format(pcl10)));
-            map.put("pcl12", Double.valueOf(df.format(pcl12)));
-            map.put("pcl25", Double.valueOf(df.format(pcl25)));
+            obj.setPcratio(Double.valueOf(df.format(pcl)));
+            obj.setPc5ratio(Double.valueOf(df.format(pcl5)));
+            obj.setPc10ratio(Double.valueOf(df.format(pcl10)));
+            obj.setPc12ratio(Double.valueOf(df.format(pcl12)));
+            obj.setPc25ratio(Double.valueOf(df.format(pcl25)));
 
         } catch (Exception e){
             log.error("DataFittingService--dataCurveRatio",e);
         }
-
-        return map;
     }
 
 
@@ -441,7 +437,7 @@ public class DataFittingService {
                 String[] split = ls.get(i).split(",");
                 sjgl.add(new double[]{Double.valueOf(split[0]), Double.valueOf(split[1])});
             }
-            map.put("wtId", item.getWindturbine());
+            map.put("obj", item);
             map.put("sjgl", sjgl);
             result.add(map);
         });
@@ -456,4 +452,52 @@ public class DataFittingService {
 
         return map;
     }
+
+
+    /**
+     * 统计并网时间  3-5m   5-10m   10-12m   12-25m  不运行
+     * @param ids
+     * @return
+     */
+    public Object dataFittingTime(String ids) {
+        List<Object> result = new ArrayList<>();
+        List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
+        if (list.size() == 0)
+            return result;
+
+        list.forEach(item -> {
+            Map<String, Object> map = new HashMap<>();
+            int[] time = new int[5];
+            String[] split = item.getPrepareid().split(",");//数据准备ID,获取文件
+            for (String id : split){
+                List<String> line = FileUtil.readFile(powerService.getById(id).getPath(), true);
+                timeTotal(time, line);
+            }
+            map.put("wtId", item.getWindturbine());
+            map.put("time", time);
+            result.add(map);
+        });
+
+        return result;
+    }
+
+    private void timeTotal(int[] time, List<String> line){
+        List<PowerPointData> list = new ArrayList<>();
+        double interval = DateUtil.getTimeDiff(line.get(1).split(",")[0], line.get(2).split(",")[0]); //两条数据的间隔时间
+        for (int i = 1; i < line.size(); i++){
+            list.add(new PowerPointData(line.get(i).split(",")));
+        }
+        for (PowerPointData item : list){
+            if (item.getSpeed() >= 3.0 && item.getSpeed() < 5.0 && item.getMxzt() == 2)
+                time[0] += interval;
+            if (item.getSpeed() >= 5.0 && item.getSpeed() < 10.0 && item.getMxzt() == 2)
+                time[1] += interval;
+            if (item.getSpeed() >= 10.0 && item.getSpeed() < 12.0 && item.getMxzt() == 2)
+                time[2] += interval;
+            if (item.getSpeed() >= 12.0 && item.getSpeed() <= 25.0 && item.getMxzt() == 2)
+                time[3] += interval;
+            if (item.getMxzt() != 2)
+                time[4] += interval;
+        }
+    }
 }

+ 9 - 17
power-fitting/src/main/resources/application.yaml

@@ -10,15 +10,7 @@ gyee:
   # 数据压缩下载
   file-path-download: data\zip\
   # 风机实发功率\风机风速\发电机转速\明细状态\风机日发电量\实时欠发状态\风向\对风角度(对风误差)  顺序不能乱
-  points:
-    - AI130
-    - AI022
-    - AI128
-    - ZTMX
-    - RFDL
-    - RSSQFZT
-    - AI008
-    - AI036
+  points: AI130,AI022,AI128,ZTMX,RFDL,RSSQFZT,AI008,AI036
   # 数据准备时由于数据量太大,初始一个默认间隔,用于适配器取数
   interval: 20
 
@@ -40,14 +32,14 @@ spring:
     allow-bean-definition-overriding: false #当遇到同样名字的时候,是否允许覆盖注册
   datasource:
     type: com.alibaba.druid.pool.DruidDataSource
-#    url: jdbc:oracle:thin:@192.168.1.105:1521:gdnxfd
-#    username: nxfdprod
-#    password: gdnxfd123
-#    driver-class-name: oracle.jdbc.OracleDriver
-    driver-class-name: org.sqlite.JDBC
-    url: jdbc:sqlite::resource:gdnx.db
-    username:
-    password:
+    url: jdbc:oracle:thin:@192.168.1.105:1521:gdnxfd
+    username: nxfdprod
+    password: gdnxfd123
+    driver-class-name: oracle.jdbc.OracleDriver
+#    driver-class-name: org.sqlite.JDBC
+#    url: jdbc:sqlite::resource:gdnx.db
+#    username:
+#    password:
 
     druid:
       # 初始化大小,最小,最大

BIN
power-fitting/src/main/resources/gdnx.db


+ 5 - 1
power-fitting/src/main/resources/mapper/PowerfittinganalysisMapper.xml

@@ -18,11 +18,15 @@
         <result column="SPEEDAVG" property="speedavg" />
         <result column="FREQUENCY" property="frequency" />
         <result column="PCRATIO" property="pcratio" />
+        <result column="PC5RATIO" property="pc5ratio" />
+        <result column="PC10RATIO" property="pc10ratio" />
+        <result column="PC12RATIO" property="pc12ratio" />
+        <result column="PC25RATIO" property="pc25ratio" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        ID, STATION, STATIONCN, WINDTURBINE, code, interval, TIME, PATH, TYPE, PREPAREID, CPAVG, SPEEDAVG, FREQUENCY, PCRATIO
+        ID, STATION, STATIONCN, WINDTURBINE, code, interval, TIME, PATH, TYPE, PREPAREID, CPAVG, SPEEDAVG, FREQUENCY, PCRATIO, PC5RATIO, PC10RATIO, PC12RATIO, PC25RATIO
     </sql>
 
 </mapper>