Bläddra i källkod

风机绩效帮功能;
样本库过滤条件查询修改;

chenminghua 1 år sedan
förälder
incheckning
158ba411ef
42 ändrade filer med 661 tillägg och 228 borttagningar
  1. 0 2
      gyee-sample-impala/src/main/java/com/gyee/impala/common/base/ExcludeQueryWrapper.java
  2. 3 2
      gyee-sample-impala/src/main/java/com/gyee/impala/service/impl/master/CasefaultServiceImpl.java
  3. 4 2
      gyee-sample-impala/src/main/java/com/gyee/impala/service/impl/master/CasefaultalgServiceImpl.java
  4. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/MapperGenerator.java
  5. 3 119
      power-fitting/src/main/java/com/gyee/power/fitting/common/alg/PowerFittingALG.java
  6. 6 6
      power-fitting/src/main/java/com/gyee/power/fitting/common/alg/PowerProcessALG.java
  7. 0 6
      power-fitting/src/main/java/com/gyee/power/fitting/common/alg/PowerTemperatureAlg.java
  8. 128 2
      power-fitting/src/main/java/com/gyee/power/fitting/common/alg/WindDirectionALG.java
  9. 10 4
      power-fitting/src/main/java/com/gyee/power/fitting/common/config/GyeeConfig.java
  10. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/common/result/ResultCode.java
  11. 13 1
      power-fitting/src/main/java/com/gyee/power/fitting/common/spring/InitialRunner.java
  12. 14 0
      power-fitting/src/main/java/com/gyee/power/fitting/common/util/DateUtil.java
  13. 6 6
      power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/AgcDeviateController.java
  14. 8 9
      power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/DataFittingController.java
  15. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/DataPrepareController.java
  16. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/DataProcessController.java
  17. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/DateOptionController.java
  18. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/ElectricQuantityController.java
  19. 23 3
      power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/FiveLossInfoController.java
  20. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/PowerTemperatureController.java
  21. 2 2
      power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/WindDirectionController.java
  22. 16 0
      power-fitting/src/main/java/com/gyee/power/fitting/mapper/PowermodelMapper.java
  23. 4 1
      power-fitting/src/main/java/com/gyee/power/fitting/model/Powerfittinganalysis.java
  24. 47 0
      power-fitting/src/main/java/com/gyee/power/fitting/model/Powermodel.java
  25. 60 0
      power-fitting/src/main/java/com/gyee/power/fitting/schedule/DeviateAnalysisTask.java
  26. 34 0
      power-fitting/src/main/java/com/gyee/power/fitting/schedule/FiveLossScheduleTask.java
  27. 2 1
      power-fitting/src/main/java/com/gyee/power/fitting/service/PowerfittinganalysisService.java
  28. 23 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/PowermodelService.java
  29. 4 1
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/AgcDeviateService.java
  30. 1 1
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/FileService.java
  31. 37 5
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/DataFittingService.java
  32. 3 1
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/DataPrepareService.java
  33. 5 3
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/DataProcessService.java
  34. 109 22
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/fiveloss/FiveLossService.java
  35. 5 4
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/windresource/RatioService.java
  36. 2 2
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/windresource/WindDirectionService.java
  37. 5 9
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PowerfittinganalysisServiceImpl.java
  38. 3 3
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PowerlossinfoServiceImpl.java
  39. 66 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PowermodelServiceImpl.java
  40. 6 3
      power-fitting/src/main/resources/application.yaml
  41. BIN
      power-fitting/src/main/resources/gdnx.db
  42. 2 1
      power-fitting/src/main/resources/mapper/PowerfittinganalysisMapper.xml

+ 0 - 2
gyee-sample-impala/src/main/java/com/gyee/impala/common/base/ExcludeQueryWrapper.java

@@ -97,6 +97,4 @@ public class ExcludeQueryWrapper<T> extends QueryWrapper<T> {
         }
         return super.notBetween(condition, column, val1, val2);
     }
-
-
 }

+ 3 - 2
gyee-sample-impala/src/main/java/com/gyee/impala/service/impl/master/CasefaultServiceImpl.java

@@ -35,13 +35,14 @@ public class CasefaultServiceImpl extends ServiceImpl<CasefaultMapper, Casefault
     @Override
     public List<Casefault> getAll(String station, String[] model, String[] widget, String st, String et,String category, Long[] ids) {
         ExcludeQueryWrapper<Casefault> wrapper = new ExcludeQueryWrapper<>();
-        wrapper.eq("stationen", station)
-                .eq("category", category)
+        wrapper.eq("category", category)
                 .in("model", model)
                 .in("faultcode", widget)
                 .in("faultid", ids)
                 .ge("starttime", st)
                 .le("starttime", et);
+        if (!StringUtils.isEmpty(station))
+            wrapper.eq("stationen", station);
 
         try {
             return baseMapper.selectList(wrapper);

+ 4 - 2
gyee-sample-impala/src/main/java/com/gyee/impala/service/impl/master/CasefaultalgServiceImpl.java

@@ -20,6 +20,7 @@ import com.gyee.impala.model.slave.Temperatureinfo;
 import com.gyee.impala.model.slave.Windturbinetestingpointai2;
 import com.gyee.impala.service.master.CasefaultService;
 import com.gyee.impala.service.master.CasefaultalgService;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.kudu.client.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.Cacheable;
@@ -129,8 +130,7 @@ public class CasefaultalgServiceImpl extends ServiceImpl<CasefaultalgMapper, Cas
                                      String st, String et, String algcode, Boolean confirm, Double minSpeed, Double maxSpeed,
                                      Double minFaultTime, Double maxFaultTime, Double minTemperature, Double maxTemperature) {
         ExcludeQueryWrapper<Casefaultalg> wrapper = new ExcludeQueryWrapper<>();
-        wrapper.eq("stationen", station)
-                .eq("windturbineid", wtId)
+        wrapper.eq("windturbineid", wtId)
                 .in("id", id)
                 .in("faultid", faultid)
                 .in("model", model)
@@ -146,6 +146,8 @@ public class CasefaultalgServiceImpl extends ServiceImpl<CasefaultalgMapper, Cas
                 .ge("temperature", minTemperature)
                 .le("temperature", maxTemperature)
                 .orderByDesc("starttime");
+        if (!StringUtils.isEmpty(station))
+            wrapper.eq("stationen", station);
         try {
             return baseMapper.selectList(wrapper);
         } catch (Exception e) {

+ 1 - 1
power-fitting/src/main/java/com/gyee/power/fitting/MapperGenerator.java

@@ -27,7 +27,7 @@ public class MapperGenerator {
     //作者
     private static String authorName = "chenmh";
     //要生成的表名
-    private static String[] tables = {"XXX","XXX","XXX"};
+    private static String[] tables = {"POWERMODEL"};
     //table前缀
     private static String prefix = "";
 

+ 3 - 119
power-fitting/src/main/java/com/gyee/power/fitting/common/alg/PowerFittingALG.java

@@ -5,6 +5,7 @@ import com.gyee.power.fitting.model.custom.Point;
 import com.gyee.power.fitting.model.custom.PointVo;
 import com.gyee.power.fitting.model.custom.PowerPointData;
 
+import java.math.BigDecimal;
 import java.text.DecimalFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -245,27 +246,13 @@ public class PowerFittingALG {
             cpAvg /= sum1;
 
         line.setCpValue(cpValue);
-        line.setCpAvg(cpAvg);
+        line.setCpAvg(new BigDecimal(cpAvg).setScale(2, BigDecimal.ROUND_CEILING).doubleValue());
 
         return line;
     }
 
 
-    /**
-     * 静风频率计算
-     * @param list  风速数组
-     * @param speed 切入风速
-     * @return
-     */
-    public static double frequency(List<Double> list, double speed){
-        DecimalFormat df = new DecimalFormat("0.00");
-        int count = 0;
-        for (Double fs : list){
-            if (fs < speed)
-                count ++;
-        }
-        return list.size() > 0 ? Double.valueOf(df.format(((double)count / list.size() * 100 ))) : 0.0;
-    }
+
 
 
     /**
@@ -336,108 +323,5 @@ public class PowerFittingALG {
         return result;
     }
 
-
-    /**
-     * 对风偏差散点过滤  统计-50 到 50的
-     * 频次
-     * @param list
-     *
-     *
-     * @return
-     */
-    public static List<Point> windDeviationScatter(List<PowerPointData> list){
-        //正负偏差 [-50,-49,....,0,1,2,.....50]
-        List<Point> ls = new ArrayList<>();
-        LinkedHashSet<Double> keys = new LinkedHashSet<>();  //散点太多去重
-        //次数统计
-        for (int i = 0; i < list.size(); i++){
-            PowerPointData item = list.get(i);
-            int ele = (int)Math.round((item.getFx() + Math.abs(item.getDfwc())));
-            int index = ele - 180;
-            if (index >= -50 && index <= 50) {
-                double key = Math.abs(index) + item.getSpeed();
-                if (!keys.contains(key))
-                    ls.add(new Point(index, item.getSpeed()));
-                keys.add(key);
-            }
-        }
-
-        return ls;
-    }
-
-
-    /**
-     * 静态偏航对风分析
-     * 对风偏差散点过滤  统计-15 到 15的  正负偏差 [-15,-14,....,0,1,2,.....15]
-     * 数据为二维数组 内层数组为3项. 第一项表示Y轴索引(风速),  第二项代表X轴的索引(正负偏差) 第三项代表value值.
-     * @param points
-     * @return
-     */
-    public static List<Object> windDeviationPoint(List<PowerPointData> points){
-        List<PowerPointData> list = new ArrayList<>();
-        List<Object> result = new ArrayList<>();
-        Map<Integer, double[]> map = new LinkedHashMap<>();
-
-        //过滤对风偏差
-        for (int i = 0; i < points.size(); i++){
-            PowerPointData item = points.get(i);
-            if (item.getSpeed() < 4.5 || item.getSpeed() >= 10.5 && item.getMxzt() != 2)
-                continue;
-
-            list.add(item);
-            Integer speed = Math.toIntExact(Math.round(item.getSpeed()));
-            if (!map.containsKey(speed))
-                map.put(speed, new double[2]);  //[0]最小值 [1]最大值
-
-            double[] value = map.get(speed);
-            double power = item.getPower() < 0 ? 0 : item.getPower();
-            value[0] = power < value[0] ? power : value[0]; //最小值
-            value[1] = power > value[1] ? power : value[1]; //最大值
-        }
-
-        DecimalFormat sf = new DecimalFormat("0.00");
-        for (int i = 0; i < list.size(); i++){
-            PowerPointData item = list.get(i);
-            Integer speed = Math.toIntExact(Math.round(item.getSpeed()));
-            int ele = (int) (Math.abs(item.getFx()) + Math.abs(item.getAngle()));
-            int index = ele - 180;
-            if (index >= -30 && index <= 30 && item.getPower() > 0) {
-                double[] value = map.get(speed);
-                double v = (item.getPower() - value[0]) / (value[1] - value[0]);
-                double s[] = {speed, index, Double.valueOf(sf.format(v)).doubleValue()};
-                result.add(s);
-            }
-        }
-
-        return result;
-    }
-
-
-    /**
-     * 对风偏差频次统计  统计-50 到 50
-     * @param list
-     * @return
-     */
-    public static int[] windDeviationRatio(List<PowerPointData> list){
-        int[] pc = new int[101];  //正负偏差 [-50,-49,....,0,1,2,.....50]
-        //次数统计
-        for (int i = 0; i < list.size(); i++){
-            PowerPointData item = list.get(i);
-            int ele = (int) (Math.abs(item.getFx()) + Math.abs(item.getDfwc()));
-            int index = ele - 180;
-            if (index >= -50 && index <= 50)
-                pc[50-(index > 0 ? -index : Math.abs(index))]++;
-        }
-
-        return pc;
-    }
-
-
-    public static void main(String[] args){
-        double s =  4.53;
-        Integer speed = Math.toIntExact(Math.round(s));
-        System.out.println(speed);
-    }
-
 }
 

+ 6 - 6
power-fitting/src/main/java/com/gyee/power/fitting/common/alg/PowerProcessALG.java

@@ -124,12 +124,12 @@ public class PowerProcessALG {
                         if (k < 0.9 && item.getSpeed() <= 4 && item.getSpeed() > 3.5) {
                             item.setFilter(1);
                         }
-                        if (k < 0.85 && item.getSpeed() <= 3.5 && item.getSpeed() > 3) {
-                            item.setFilter(1);
-                        }
-                        if (k < 0.4 && item.getSpeed() <= 3 && item.getSpeed() > 0) {
-                            item.setFilter(1);
-                        }
+//                        if (k < 0.85 && item.getSpeed() <= 3.5 && item.getSpeed() > 3) {
+//                            item.setFilter(1);
+//                        }
+//                        if (k < 0.4 && item.getSpeed() <= 3 && item.getSpeed() > 0) {
+//                            item.setFilter(1);
+//                        }
                     }
                 }
             }

+ 0 - 6
power-fitting/src/main/java/com/gyee/power/fitting/common/alg/PowerTemperatureAlg.java

@@ -69,10 +69,4 @@ public class PowerTemperatureAlg {
                 });
         return list;
     }
-
-
-    public static void main(String[] args){
-        for (int i = -4; i <= 28; i+=5)
-            System.out.println(i);
-    }
 }

+ 128 - 2
power-fitting/src/main/java/com/gyee/power/fitting/common/alg/WindDirectionALG.java

@@ -1,11 +1,11 @@
 package com.gyee.power.fitting.common.alg;
 
-
+import com.gyee.power.fitting.model.custom.Point;
 import com.gyee.power.fitting.model.custom.PowerPointData;
 
+import java.text.DecimalFormat;
 import java.util.*;
 
-
 /**
  * 风向玫瑰图
  * 风向频次玫瑰图
@@ -68,6 +68,132 @@ public class WindDirectionALG {
 
 
     /**
+     * 静风频率计算 、平均风速计算
+     * @param list  风速数组
+     * @param cutInSpeed 切入风速
+     * @return
+     */
+    public static List<Double> frequency(List<Double> list, double cutInSpeed){
+        List<Double> result = new ArrayList<>();
+        DecimalFormat df = new DecimalFormat("0.00");
+        int count = 0;
+        double speed = 0.0;
+        for (Double fs : list){
+            speed += fs;
+            if (fs < cutInSpeed)
+                count ++;
+        }
+        double frequency = list.size() > 0 ? Double.valueOf(df.format(((double)count / list.size() * 100 ))) : 0;
+        double speedAVG = list.size() > 0 ? Double.valueOf(df.format(speed/list.size())) : 0;
+        result.add(frequency);
+        result.add(speedAVG);
+        return result;
+    }
+
+
+
+    /**
+     * 对风偏差散点过滤  统计-50 到 50的
+     * 频次
+     * @param list
+     *
+     *
+     * @return
+     */
+    public static List<Point> windDeviationScatter(List<PowerPointData> list){
+        //正负偏差 [-50,-49,....,0,1,2,.....50]
+        List<Point> ls = new ArrayList<>();
+        LinkedHashSet<Double> keys = new LinkedHashSet<>();  //散点太多去重
+        //次数统计
+        for (int i = 0; i < list.size(); i++){
+            PowerPointData item = list.get(i);
+            int ele = (int)Math.round((item.getFx() + Math.abs(item.getDfwc())));
+            int index = ele - 180;
+            if (index >= -50 && index <= 50) {
+                double key = Math.abs(index) + item.getSpeed();
+                if (!keys.contains(key))
+                    ls.add(new Point(index, item.getSpeed()));
+                keys.add(key);
+            }
+        }
+
+        return ls;
+    }
+
+
+    /**
+     * 静态偏航对风分析
+     * 对风偏差散点过滤  统计-15 到 15的  正负偏差 [-15,-14,....,0,1,2,.....15]
+     * 数据为二维数组 内层数组为3项. 第一项表示Y轴索引(风速),  第二项代表X轴的索引(正负偏差) 第三项代表value值.
+     * @param points
+     * @return
+     */
+    public static Map<String, Object> windDeviationPoint(List<PowerPointData> points){
+        List<PowerPointData> list = new ArrayList<>();
+        List<Object> temp = new ArrayList<>();
+        Map<String, Object> result = new HashMap<>();
+        Map<Integer, double[]> map = new LinkedHashMap<>();
+
+        //过滤对风偏差
+        for (int i = 0; i < points.size(); i++){
+            PowerPointData item = points.get(i);
+            if ((item.getSpeed() < 4.5 || item.getSpeed() >= 10.5) && item.getMxzt() != 2)
+                continue;
+
+            list.add(item);
+            Integer speed = Math.toIntExact(Math.round(item.getSpeed()));
+            if (!map.containsKey(speed))
+                map.put(speed, new double[2]);  //[0]最小值 [1]最大值
+
+            double[] value = map.get(speed);
+            double power = item.getPower() < 0 ? 0 : item.getPower();
+            value[0] = power < value[0] ? power : value[0]; //最小值
+            value[1] = power > value[1] ? power : value[1]; //最大值
+        }
+
+        int avg = 0;
+        DecimalFormat sf = new DecimalFormat("0.00");
+        for (int i = 0; i < list.size(); i++){
+            PowerPointData item = list.get(i);
+            Integer speed = Math.toIntExact(Math.round(item.getSpeed()));
+            int ele = (int) (Math.abs(item.getFx()) + Math.abs(item.getAngle()));
+            int index = ele - 180;
+            if (index >= -30 && index <= 30 && item.getPower() > 0) {
+                avg += index;
+                double[] value = map.get(speed);
+                double v = (item.getPower() - value[0]) / (value[1] - value[0]);
+                double s[] = {speed, index, Double.valueOf(sf.format(v)).doubleValue()};
+                temp.add(s);
+            }
+        }
+        result.put("data", temp);
+        result.put("avg", temp.size() > 0 ? avg/temp.size() : 0);
+
+        return result;
+    }
+
+
+    /**
+     * 对风偏差频次统计  统计-50 到 50
+     * @param list
+     * @return
+     */
+    public static int[] windDeviationRatio(List<PowerPointData> list){
+        int[] pc = new int[101];  //正负偏差 [-50,-49,....,0,1,2,.....50]
+        //次数统计
+        for (int i = 0; i < list.size(); i++){
+            PowerPointData item = list.get(i);
+            int ele = (int) (Math.abs(item.getFx()) + Math.abs(item.getDfwc()));
+            int index = ele - 180;
+            if (index >= -50 && index <= 50)
+                pc[50-(index > 0 ? -index : Math.abs(index))]++;
+        }
+
+        return pc;
+    }
+
+
+    /**
      * 风向划分
      * 0:0-22.5
      * 1:22.5-45

+ 10 - 4
power-fitting/src/main/java/com/gyee/power/fitting/common/config/GyeeConfig.java

@@ -8,6 +8,7 @@ import lombok.Data;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.boot.system.ApplicationHome;
+import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Component;
 
 import java.io.File;
@@ -16,6 +17,7 @@ import java.util.List;
 import java.util.stream.Collectors;
 
 @Data
+@Order(0)
 @Component
 @ConfigurationProperties(prefix = "gyee")
 public class GyeeConfig {
@@ -40,13 +42,17 @@ public class GyeeConfig {
     private String points;
     /** 适配器读取数据等间隔时间 **/
     private Integer interval;
+    /** 数据是否离线执行 **/
+    private boolean offLine;
+    /** 是否实时计算 **/
+    private boolean realTimeCal;
 
     public List<String> getPoints() {
         return getUniformCodes();
     }
 
     public String getFilePathPrepare() {
-        return jarF.getParentFile().getAbsolutePath() + "\\" + filePathPrepare;
+        return jarF.getParentFile().getAbsolutePath() + File.separator + filePathPrepare;
     }
 
     public void setFilePathPrepare(String filePathPrepare) {
@@ -54,7 +60,7 @@ public class GyeeConfig {
     }
 
     public String getFilePathProcess() {
-        return jarF.getParentFile().getAbsolutePath() + "\\" + filePathProcess;
+        return jarF.getParentFile().getAbsolutePath() + File.separator + filePathProcess;
     }
 
     public void setFilePathProcess(String filePathProcess) {
@@ -62,7 +68,7 @@ public class GyeeConfig {
     }
 
     public String getFilePathFitting() {
-        return jarF.getParentFile().getAbsolutePath() + "\\" + filePathFitting;
+        return jarF.getParentFile().getAbsolutePath() + File.separator + filePathFitting;
     }
 
     public void setFilePathFitting(String filePathFitting) {
@@ -70,7 +76,7 @@ public class GyeeConfig {
     }
 
     public String getFilePathDownload() {
-        return jarF.getParentFile().getAbsolutePath() + "\\" + filePathDownload;
+        return jarF.getParentFile().getAbsolutePath() + File.separator + filePathDownload;
     }
 
     public void setFilePathDownload(String filePathDownload) {

+ 1 - 1
power-fitting/src/main/java/com/gyee/power/fitting/common/result/ResultCode.java

@@ -21,7 +21,7 @@ public enum ResultCode {
     ERROR_DATA(4006, "数据库操作失败"),
     ERROR_DATA_REPEAT(4007, "数据已存在"),
     ERROR_SQL(4008, "sql语法不正确"),
-    ERROR_MODEL(4006, "同场站不同机型至少启用一个模型"),
+    ERROR_MODEL(4009, "同场站不同机型至少启用一个模型"),
 
 
     /* 参数错误:1000~1999 */

+ 13 - 1
power-fitting/src/main/java/com/gyee/power/fitting/common/spring/InitialRunner.java

@@ -42,6 +42,8 @@ public class InitialRunner implements CommandLineRunner {
     private ProjectService projectService;
     @Resource
     private LineService lineService;
+    @Resource
+    private PowermodelService powermodelService;
 
 
     /**场站所有信息**/
@@ -53,7 +55,7 @@ public class InitialRunner implements CommandLineRunner {
     public static List<Windturbine> wtList = new ArrayList<>();
     /** key:wtId NG01_01 **/
     public static Map<String, Windturbine> wtMap = new HashMap<>();
-    /**场站的风机**/
+    /**场站的风机  key:NSS_FDC**/
     public static Map<String, List<Windturbine>> wpMap = new HashMap<>();
 
     /**期次**/
@@ -75,6 +77,8 @@ public class InitialRunner implements CommandLineRunner {
     public static Map<String, List<Modelpower>> modelPowerMap = new HashMap<>();
     /** key: model  UP82 **/
     public static Map<String, List<Modelpowerdetails>> modelPowerDetailMap = new HashMap<>();
+    /** key: NG01_01 **/
+    public static Map<String, List<Powermodel>> zsllglMap = new HashMap<>();
 
 
     @Override
@@ -146,4 +150,12 @@ public class InitialRunner implements CommandLineRunner {
         lineList.forEach(f -> lineMap.put(f.getId(), f));
     }
 
+    /**
+     * 自算理论功率
+     */
+    public void cacheZSLLGL(String wtId){
+        List<Powermodel> list = powermodelService.selectByWtId(wtId);
+        zsllglMap.replace(wtId, list);
+    }
+
 }

+ 14 - 0
power-fitting/src/main/java/com/gyee/power/fitting/common/util/DateUtil.java

@@ -212,6 +212,20 @@ public class DateUtil extends DateUtils {
     }
 
     /**
+     * 获取0点0分0秒值
+     * @param date
+     * @return
+     */
+    public static final Date dateZeroFormat(Date date){
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH),
+                0, 0, 0);
+        Date time = cal.getTime();
+        return time;
+    }
+
+    /**
      * 日期路径 即年/月/日 如2018/08/08
      */
     public static final String datePath() {

+ 6 - 6
power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/AgcDeviateController.java

@@ -1,8 +1,8 @@
-package com.gyee.power.fitting.controller.analyse;
+package com.gyee.power.fitting.controller.agc;
 
+import com.gyee.power.fitting.common.config.GyeeConfig;
 import com.gyee.power.fitting.model.agc.AgcDeviateTag;
-import com.gyee.power.fitting.service.custom.curve.AgcDeviateService;
-import org.springframework.beans.factory.annotation.Value;
+import com.gyee.power.fitting.service.custom.agc.AgcDeviateService;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -22,8 +22,8 @@ import java.util.stream.Collectors;
 public class AgcDeviateController {
     @Resource
     private AgcDeviateService agcDeviateService;
-    @Value("${gyee.offline:fasle}")
-    private boolean isOffline;
+    @Resource
+    private GyeeConfig gyeeConfig;
 
     /**
      * 获取偏差信息
@@ -40,7 +40,7 @@ public class AgcDeviateController {
                                               @RequestParam(value = "id") String id,
                                               @RequestParam(value = "interval", defaultValue = "60", required = false) int interval) {
         List<AgcDeviateTag> ls = new ArrayList<>();
-        if (isOffline) {
+        if (gyeeConfig.isOffLine()) {
             ls = agcDeviateService.getAgcDeviateTagsOffline(id, startTs, endTs, interval);
         } else {
             ls = agcDeviateService.getAgcDeviateTags(id, startTs, endTs, interval);

+ 8 - 9
power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/DataFittingController.java

@@ -1,4 +1,4 @@
-package com.gyee.power.fitting.controller.analyse;
+package com.gyee.power.fitting.controller.fj;
 
 
 import com.alibaba.fastjson.JSONObject;
@@ -10,7 +10,6 @@ import com.gyee.power.fitting.service.custom.curve.DataFittingService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
@@ -103,15 +102,15 @@ public class DataFittingController {
 
 
     /**
-     * 计算曲线偏差率
-     * @param id 曲线拟合的id
+     * 保存拟合的功率曲线数据
+     * @param ids 曲线拟合的ids
      * @return
      */
-//    @GetMapping("curve/ratio")
-//    public JSONObject dataCurveRatio(String id){
-//        Map<String, Double> map = fittingService.dataCurveRatio(id);
-//        return JsonResult.successData(ResultCode.SUCCESS, map);
-//    }
+    @GetMapping("curve/save")
+    public JSONObject dataCurveSave(String ids){
+        fittingService.curveSave(ids);
+        return JsonResult.success(ResultCode.SUCCESS);
+    }
 
 
     /**

+ 1 - 1
power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/DataPrepareController.java

@@ -1,4 +1,4 @@
-package com.gyee.power.fitting.controller.analyse;
+package com.gyee.power.fitting.controller.fj;
 
 import com.alibaba.fastjson.JSONObject;
 import com.gyee.power.fitting.common.result.JsonResult;

+ 1 - 1
power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/DataProcessController.java

@@ -1,4 +1,4 @@
-package com.gyee.power.fitting.controller.analyse;
+package com.gyee.power.fitting.controller.fj;
 
 import com.alibaba.fastjson.JSONObject;
 import com.gyee.power.fitting.common.result.JsonResult;

+ 1 - 1
power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/DateOptionController.java

@@ -1,4 +1,4 @@
-package com.gyee.power.fitting.controller.analyse;
+package com.gyee.power.fitting.controller.fj;
 
 import com.alibaba.fastjson.JSONObject;
 import com.gyee.power.fitting.common.config.GyeeConfig;

+ 1 - 1
power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/ElectricQuantityController.java

@@ -1,4 +1,4 @@
-package com.gyee.power.fitting.controller.analyse;
+package com.gyee.power.fitting.controller.fj;
 
 
 import org.springframework.web.bind.annotation.CrossOrigin;

+ 23 - 3
power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/FiveLossInfoController.java

@@ -1,11 +1,10 @@
-package com.gyee.power.fitting.controller.analyse;
+package com.gyee.power.fitting.controller.fj;
 
 
 import com.alibaba.fastjson.JSONObject;
 import com.gyee.power.fitting.common.result.JsonResult;
 import com.gyee.power.fitting.common.result.ResultCode;
 import com.gyee.power.fitting.common.util.DateUtil;
-import com.gyee.power.fitting.model.custom.FjjxbVo;
 import com.gyee.power.fitting.service.custom.fiveloss.FiveLossService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.CrossOrigin;
@@ -27,6 +26,23 @@ public class FiveLossInfoController {
     @Resource
     private FiveLossService fiveLossService;
 
+    @GetMapping("five/loss/cal")
+    public JSONObject fiveLossCal(String ids){
+        Map<String, Object> map = fiveLossService.fiveLossCal(ids);
+        return JsonResult.successData(ResultCode.SUCCESS, map);
+    }
+
+
+    /**
+     * 五损数据查询
+     * @param station
+     * @param project
+     * @param line
+     * @param st
+     * @param et
+     * @param type  1:场站  2:期次  3:线路
+     * @return
+     */
     @GetMapping("index")
     public JSONObject fiveLoss(String station, String project, String line, String st, String et, String type){
         Date begin = DateUtil.parseStrtoDate(st, DateUtil.DATE_PATTERN);
@@ -39,8 +55,12 @@ public class FiveLossInfoController {
     }
 
 
+    /**
+     * 五损数据计算
+     * @return
+     */
     @GetMapping("cal")
-    public JSONObject test(){
+    public JSONObject fiveCal(){
         fiveLossService.fiveLossCal();
         return JsonResult.success(ResultCode.SUCCESS);
     }

+ 1 - 1
power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/PowerTemperatureController.java

@@ -1,4 +1,4 @@
-package com.gyee.power.fitting.controller.analyse;
+package com.gyee.power.fitting.controller.fj;
 
 
 import com.alibaba.fastjson.JSONObject;

+ 2 - 2
power-fitting/src/main/java/com/gyee/power/fitting/controller/analyse/WindDirectionController.java

@@ -1,4 +1,4 @@
-package com.gyee.power.fitting.controller.analyse;
+package com.gyee.power.fitting.controller.fj;
 
 
 import com.alibaba.fastjson.JSONObject;
@@ -25,7 +25,7 @@ public class WindDirectionController {
     private WindDirectionService windDirectionService;
 
     /***
-     * 风向玫瑰图
+     * 风速风向玫瑰图
      * @param ids  预处理数据的id
      * @param mode 统计方式   0:单台统计   1:合并统计
      * @return

+ 16 - 0
power-fitting/src/main/java/com/gyee/power/fitting/mapper/PowermodelMapper.java

@@ -0,0 +1,16 @@
+package com.gyee.power.fitting.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.power.fitting.model.Powermodel;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author chenmh
+ * @since 2023-02-21
+ */
+public interface PowermodelMapper extends BaseMapper<Powermodel> {
+
+}

+ 4 - 1
power-fitting/src/main/java/com/gyee/power/fitting/model/Powerfittinganalysis.java

@@ -80,7 +80,10 @@ public class Powerfittinganalysis extends Model<Powerfittinganalysis> {
     private Integer interp; //等间隔时间,单位:秒
 
     @TableField("ISCAL")
-    private Integer iscal;  //0-没有计算  1-已计算
+    private Integer iscal = 0;  //0-没有计算  1-已计算
+//
+//    @TableField("ISPROCESS")
+//    private Integer isprocess = 0;  //0-没有计算  1-已计算
 
     @Override
     protected Serializable pkVal() {

+ 47 - 0
power-fitting/src/main/java/com/gyee/power/fitting/model/Powermodel.java

@@ -0,0 +1,47 @@
+package com.gyee.power.fitting.model;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 自算---------拟合功率
+ * </p>
+ *
+ * @author chenmh
+ * @since 2023-02-21
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("POWERMODEL")
+public class Powermodel extends Model<Powermodel> {
+
+    private static final long serialVersionUID=1L;
+
+    @TableField("ID")
+    private String id;
+
+    @TableField("WINDTURBINEID")
+    private String windturbineid;
+
+    @TableField("SPEED")
+    private double speed;
+
+    @TableField("POWER")
+    private double power;
+
+    @TableField("MODEL")
+    private String model;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return null;
+    }
+
+}

+ 60 - 0
power-fitting/src/main/java/com/gyee/power/fitting/schedule/DeviateAnalysisTask.java

@@ -0,0 +1,60 @@
+package com.gyee.power.fitting.schedule;
+
+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.model.Powerfittinganalysis;
+import com.gyee.power.fitting.model.Windturbine;
+import com.gyee.power.fitting.service.PowerfittinganalysisService;
+import com.gyee.power.fitting.service.custom.curve.DataPrepareService;
+import com.gyee.power.fitting.service.custom.curve.DataProcessService;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Component
+public class DeviateAnalysisTask {
+
+    @Resource
+    private DataPrepareService prepareService;
+    @Resource
+    private DataProcessService processService;
+    @Resource
+    private PowerfittinganalysisService powerService;
+
+
+    /**
+     * 元数据缓存
+     */
+    @Scheduled(cron = "0 0 1 1 * ?")  //每月1号凌晨1点执行
+    public void dataPrepare(){
+        Date month = DateUtil.addMonths(new Date(), -1);
+        Date st = DateUtil.dateZeroFormat(month);  //上月1号0点值
+        Date et = DateUtil.dateZeroFormat(new Date());  //当月1号0点值
+        Map<String, List<Windturbine>> wpMap = InitialRunner.wpMap;
+        wpMap.forEach((k, v) -> {
+            List<String> wtIds = v.stream().map(m -> m.getId()).collect(Collectors.toList());
+            prepareService.dataPrepare(k, wtIds, st.getTime(), et.getTime(), 10 * 60);
+        });
+    }
+
+
+    /**
+     * 根据缓存的文件进行数据预处理
+     */
+    @Scheduled(cron = "0 0 22 1 * ?")  //每月1号22点执行
+    public void dataProcess(){
+        List<Powerfittinganalysis> list = powerService.selectListByIsCal(Constants.DATA_PROCESS, 0);
+        if (list == null || list.size() == 0)
+            return;
+
+        List<String> ids = list.stream().map(m -> m.getId()).collect(Collectors.toList());
+        processService.dataProcess(ids, 25.0, 0.0, 2500.0, 0.0, true, true, true, true, true, true, 3);
+    }
+
+}

+ 34 - 0
power-fitting/src/main/java/com/gyee/power/fitting/schedule/FiveLossScheduleTask.java

@@ -1,8 +1,42 @@
 package com.gyee.power.fitting.schedule;
 
 
+import com.gyee.power.fitting.common.config.GyeeConfig;
+import com.gyee.power.fitting.common.util.DateUtil;
+import com.gyee.power.fitting.service.custom.fiveloss.FiveLossService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
+import java.util.Date;
+
 @Component
 public class FiveLossScheduleTask {
+
+    @Autowired
+    private GyeeConfig gyeeConfig;
+    @Autowired
+    private FiveLossService fiveLossService;
+
+    /**
+     * 五损数据离线计算,使用已经缓存的文件
+     */
+    @Scheduled(cron = "0 0 23 1 * ?")  //每月1号23点执行
+    public void fiveLossCal(){
+        fiveLossService.fiveLossCal();
+    }
+
+    /**
+     * 每月2号凌晨三点执行
+     */
+    @Scheduled(cron = "0 0 3 * * ?")  //每天凌晨三点执行
+    public void fiveLossLineCal(){
+        // 是否实时计算五损数据
+        if (gyeeConfig.isRealTimeCal()){
+            Date date = DateUtil.addDays(new Date(), -1);
+            Date st = DateUtil.dateZeroFormat(date);
+            Date et = DateUtil.dateZeroFormat(new Date());
+            fiveLossService.fiveLossCalByLine(st.getTime(), et.getTime(), 60);
+        }
+    }
 }

+ 2 - 1
power-fitting/src/main/java/com/gyee/power/fitting/service/PowerfittinganalysisService.java

@@ -33,9 +33,10 @@ public interface PowerfittinganalysisService extends IService<Powerfittinganalys
 
     /**
      * 查询准备的数据
-     * @param type  Constants.DATA_PREPARE
+     * @param type  Constants.DATA_PREPARE  Constants.DATA_PROCESS
      * @param isCal
      * @return
      */
     List<Powerfittinganalysis> selectListByIsCal(String type, int isCal);
+
 }

+ 23 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/PowermodelService.java

@@ -0,0 +1,23 @@
+package com.gyee.power.fitting.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.power.fitting.model.Powermodel;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author chenmh
+ * @since 2023-02-21
+ */
+public interface PowermodelService extends IService<Powermodel> {
+
+    void insertBatch(List<Powermodel> list);
+
+    boolean deleteItem(String wtId);
+
+    List<Powermodel> selectByWtId(String wtId);
+}

+ 4 - 1
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/AgcDeviateService.java

@@ -1,7 +1,8 @@
-package com.gyee.power.fitting.service.custom.curve;
+package com.gyee.power.fitting.service.custom.agc;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.TypeReference;
+import com.gyee.power.fitting.common.config.GyeeConfig;
 import com.gyee.power.fitting.common.feign.IDataAdapter;
 import com.gyee.power.fitting.model.agc.AgcDeviateConfig;
 import com.gyee.power.fitting.model.agc.AgcDeviateTag;
@@ -51,6 +52,8 @@ public class AgcDeviateService {
 
     @Resource
     private IDataAdapter iDataAdapter;
+    @Resource
+    private GyeeConfig gyeeConfig;
 
 
     public AgcDeviateService(AgcDeviateMapper agcDeviateMapper, FileService fs, Environment env) {

+ 1 - 1
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/FileService.java

@@ -1,4 +1,4 @@
-package com.gyee.power.fitting.service.custom.curve;
+package com.gyee.power.fitting.service.custom.agc;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.TypeReference;

+ 37 - 5
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/DataFittingService.java

@@ -11,16 +11,20 @@ import com.gyee.power.fitting.common.util.PowerFittingUtil;
 import com.gyee.power.fitting.common.util.SnowFlakeUtil;
 import com.gyee.power.fitting.model.Modelpowerdetails;
 import com.gyee.power.fitting.model.Powerfittinganalysis;
+import com.gyee.power.fitting.model.Powermodel;
 import com.gyee.power.fitting.model.anno.AnnotationTool;
 import com.gyee.power.fitting.model.anno.FixedVo;
 import com.gyee.power.fitting.model.custom.*;
 import com.gyee.power.fitting.service.PowerfittinganalysisService;
+import com.gyee.power.fitting.service.PowermodelService;
 import lombok.extern.slf4j.Slf4j;
 import lombok.val;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
@@ -34,6 +38,8 @@ public class DataFittingService {
     @Resource
     private GyeeConfig config;
     @Resource
+    private PowermodelService modelService;
+    @Resource
     private DataScanService dataScanService;
     @Resource
     private PowerfittinganalysisService powerService;
@@ -282,18 +288,15 @@ 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();
         lf.setYLines(temp);
         lf = PowerFittingALG.buildCp(InitialRunner.equipmentMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid()).getSweptarea(), lf);
-
+        lf.getCpValue().forEach(f -> {if(f.getX() <= 2.5) f.setY(0);});
         //曲线偏差率
         dataCurveRatio(lf, obj);
 
         String content = assemble(lf);
-
         String processId = "";
         String fileName = null;
         if (mode == 0){
@@ -466,7 +469,6 @@ public class DataFittingService {
     public Object dataFittingTime(String ids) {
         List<Object> result = new ArrayList<>();
         List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
-
         if (list.size() == 0)
             return result;
 
@@ -505,4 +507,34 @@ public class DataFittingService {
                 time[4] += interval;
         }
     }
+
+    /**
+     * 通过拟合的id保存理论功率
+     * @param ids
+     */
+    public void curveSave(String ids) {
+        List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
+        if (list.size() == 0)
+            return;
+
+        list.forEach(f -> {
+            try {
+                List<Powermodel> result = new ArrayList<>();
+                List<String> ls = FileUtil.readFile(f.getPath(), true);
+                for (int i = 1; i < ls.size(); i++){
+                    String[] split = ls.get(i).split(",");
+                    Powermodel obj = new Powermodel();
+                    obj.setWindturbineid(f.getWindturbine());
+                    obj.setModel(InitialRunner.wtMap.get(f.getWindturbine()).getModelid());
+                    obj.setSpeed(new BigDecimal(split[0]).setScale(2, RoundingMode.CEILING).doubleValue());
+                    obj.setPower(new BigDecimal(split[1]).setScale(2, RoundingMode.CEILING).doubleValue());
+                    result.add(obj);
+                }
+                modelService.deleteItem(f.getWindturbine());
+                modelService.insertBatch(result);
+            }catch (Exception e){
+                log.error(e.getMessage());
+            }
+        });
+    }
 }

+ 3 - 1
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/DataPrepareService.java

@@ -30,6 +30,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -65,11 +66,12 @@ public class DataPrepareService {
 
                 for (int i = 0; i < points.size(); i++){
                     Windturbinetestingpointai2 point = collect.get(points.get(i)).get(0);
+                    log.info("测点:" + point.getId() + "----" + point.getName());
                     List<TsDoubleData> data = remoteService.adapter().getHistorySnap(point.getId(), st, et, interval);
                     if (data == null || data.size() < 0)
                         break;
                     result.add(data);
-                    Thread.sleep(200);
+                    TimeUnit.MILLISECONDS.sleep(200);
                 }
                 if (result.size() != points.size())
                     continue;

+ 5 - 3
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/DataProcessService.java

@@ -2,6 +2,7 @@ package com.gyee.power.fitting.service.custom.curve;
 
 import com.gyee.power.fitting.common.alg.PowerFittingALG;
 import com.gyee.power.fitting.common.alg.PowerProcessALG;
+import com.gyee.power.fitting.common.alg.WindDirectionALG;
 import com.gyee.power.fitting.common.config.GyeeConfig;
 import com.gyee.power.fitting.common.constants.Constants;
 import com.gyee.power.fitting.common.spring.InitialRunner;
@@ -67,12 +68,12 @@ public class DataProcessService {
             /** 风速  ->  保证功率  来自数据库 **/
             List<Modelpowerdetails> modelPowerList = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid());
             Map<Double, Double> modelPowerMap = modelPowerList.stream().collect(Collectors.toMap(Modelpowerdetails::getSpeed, Modelpowerdetails::getEnsurepower));
-
             /** 数据预处理 **/
             List<PowerPointData> data = PowerProcessALG.dataProcess(eis, modelPowerMap, maxs, mins, maxp, minp, isfbw, isfhl, isbw, istj, isglpc, isqfh, qfhdj);
-
             /** 静风频率 **/
-            double frequency = PowerFittingALG.frequency(data.stream().map(PowerPointData::getSpeed).collect(Collectors.toList()), 3);
+            List<Double> ls = WindDirectionALG.frequency(data.stream().map(PowerPointData::getSpeed).collect(Collectors.toList()), 3);
+            double frequency = ls.get(0);
+            double speed = ls.get(1);
 
             String content = assemble(data);
             String fileName = config.getFilePathProcess() + obj.getStation() + "_" + obj.getCode() + "_" + SnowFlakeUtil.generateIdL() / 100000 + ".csv";
@@ -80,6 +81,7 @@ public class DataProcessService {
             if (flag) {  // TODO  保存数据库
                 obj.setPath(fileName);
                 obj.setFrequency(frequency);
+                obj.setSpeedavg(speed);
                 obj.setType(Constants.DATA_PROCESS);
                 powerService.insertItem(obj);
             }

+ 109 - 22
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/fiveloss/FiveLossService.java

@@ -2,7 +2,9 @@ package com.gyee.power.fitting.service.custom.fiveloss;
 
 import com.alibaba.fastjson.JSONObject;
 import com.gyee.power.fitting.common.constants.Constants;
+import com.gyee.power.fitting.common.exception.CustomException;
 import com.gyee.power.fitting.common.feign.RemoteServiceBuilder;
+import com.gyee.power.fitting.common.result.ResultCode;
 import com.gyee.power.fitting.common.spring.InitialRunner;
 import com.gyee.power.fitting.common.util.CollectUtil;
 import com.gyee.power.fitting.common.util.DateUtil;
@@ -16,7 +18,6 @@ import com.gyee.power.fitting.model.custom.TableTitle;
 import com.gyee.power.fitting.model.custom.TsDoubleData;
 import com.gyee.power.fitting.service.PowerfittinganalysisService;
 import com.gyee.power.fitting.service.PowerlossinfoService;
-import com.gyee.power.fitting.service.Windturbinetestingpointai2Service;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
@@ -26,7 +27,6 @@ import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
-import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
 
@@ -42,7 +42,7 @@ public class FiveLossService {
     private RemoteServiceBuilder remoteService;
 
     /**
-     * 五项损失
+     * 五项损失查询
      *
      * @param station 场站
      * @param project 期次
@@ -118,18 +118,22 @@ public class FiveLossService {
     public void fiveLossCal() {
         log.info("======风机绩效榜计算开始.............");
         Map<String, Windturbine> wtmap = InitialRunner.wtMap;
-        Map<String, List<Modelpowerdetails>> modelmap = InitialRunner.modelPowerDetailMap;
+        Map<String, List<Powermodel>> modelmap = InitialRunner.zsllglMap;
 
         List<Powerfittinganalysis> analyses = analysisService.selectListByIsCal(Constants.DATA_PREPARE, 0);
-        if (analyses.size() == 0)
+        if (analyses.size() == 0){
+            log.info("======风机榜效帮计算结束,Powerfittinganalysis数据为空.............");
             return;
+        }
 
         for (Powerfittinganalysis p : analyses) {
             List<Powerlossinfo> result = new ArrayList<>();
             Windturbine wt = wtmap.get(p.getWindturbine());
             List<String> content = FileUtil.readFile(p.getPath(), true);
-            if (content.size() == 0)
+            if (content.size() == 0){
+                log.info("======风机榜效帮计算结束,文件内容为空.............");
                 continue;
+            }
 
             log.info("======风机绩效榜计算:" + p.getWindturbine());
             content.remove(0); //去掉标题栏
@@ -145,17 +149,17 @@ public class FiveLossService {
                 double xnssdl = 0;//性能损失电量
 
                 List<PowerPointData> pdl = ls.stream().map(mp -> new PowerPointData(mp.split(","), false)).collect(Collectors.toList());
-                double zcfd = generalLoss(pdl, modelmap.get(wt.getModelid()), p.getInterp(), 2); //正常发电
-                xdssdl = generalLoss(pdl, modelmap.get(wt.getModelid()), p.getInterp(), 5);  //限电损失电量
-                double qxjcl = generalLoss(pdl, modelmap.get(wt.getModelid()), p.getInterp(), 3); //缺陷降出力损失电量
-                double xdjcl = generalLoss(pdl, modelmap.get(wt.getModelid()), p.getInterp(), 4); //限电降出力损失电量
-                double cnsltj = generalLoss(pdl, modelmap.get(wt.getModelid()), p.getInterp(), 7); //场内受累停机损失电量
-                double cnsljx = generalLoss(pdl, modelmap.get(wt.getModelid()), p.getInterp(), 9); //场内受累检修损失电量
-                double dwsl = generalLoss(pdl, modelmap.get(wt.getModelid()), p.getInterp(), 10); //电网受累损失电量
-                double hjsl = generalLoss(pdl, modelmap.get(wt.getModelid()), p.getInterp(), 11); //环境受累损失电量
-
-                gzssdl = generalLoss(pdl, modelmap.get(wt.getModelid()), p.getInterp(), 6);
-                jhjxssdl = generalLoss(pdl, modelmap.get(wt.getModelid()), p.getInterp(), 8);
+                double zcfd = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 2); //正常发电
+                xdssdl = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 5);  //限电损失电量
+                double qxjcl = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 3); //缺陷降出力损失电量
+                double xdjcl = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 4); //限电降出力损失电量
+                double cnsltj = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 7); //场内受累停机损失电量
+                double cnsljx = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 9); //场内受累检修损失电量
+                double dwsl = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 10); //电网受累损失电量
+                double hjsl = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 11); //环境受累损失电量
+
+                gzssdl = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 6);
+                jhjxssdl = generalLoss(pdl, modelmap.get(p.getWindturbine()), p.getInterp(), 8);
                 fjhjxssdl = gzssdl;
                 xdssdl = xdssdl + xdjcl;
                 slssdl = cnsltj + dwsl + hjsl + cnsljx + cnsljx;
@@ -201,15 +205,15 @@ public class FiveLossService {
      * @param status   风机当前状态
      * @return
      */
-    private double generalLoss(List<PowerPointData> ztmxData, List<Modelpowerdetails> zsglData, int interval, double status) {
+    private double generalLoss(List<PowerPointData> ztmxData, List<Powermodel> zsglData, int interval, double status) {
         double ssdl = 0.0;
         List<PowerPointData> pointData = ztmxData.stream().filter(zt -> zt.getMxzt() == status).collect(Collectors.toList());
-        List<Modelpowerdetails> theoryData = zsglData.stream().filter(f -> f.getTheorypower() > 0).collect(Collectors.toList());
-        if (status == 2.0 || status == 3.0 || status == 4.0 || status == 9.0 || status == 10.0 || status == 11.0) {
+        List<Powermodel> theoryData = zsglData.stream().filter(f -> f.getPower() > 0.0).collect(Collectors.toList());
+        if (status == 0.0 || status == 2.0 || status == 3.0 || status == 4.0 || status == 9.0 || status == 11.0) {
             for (PowerPointData obj : pointData) {
                 for (int i = 0; i < theoryData.size(); i++) {
                     if (String.format("%.2f", obj.getSpeed()).equals(String.format("%.2f", theoryData.get(i).getSpeed()))) {
-                        double zsgl = theoryData.get(i).getTheorypower();
+                        double zsgl = theoryData.get(i).getPower();
                         double power = obj.getPower();
                         double temp = (zsgl - power) > 0 ? zsgl - power : 0;
                         ssdl = ssdl + (temp / 60) * (interval / 60);
@@ -221,7 +225,7 @@ public class FiveLossService {
             for (PowerPointData obj : pointData) {
                 for (int i = 0; i < theoryData.size(); i++) {
                     if (String.format("%.2f", obj.getSpeed()).equals(String.format("%.2f", theoryData.get(i).getSpeed()))) {
-                        double zsgl = theoryData.get(i).getTheorypower();
+                        double zsgl = theoryData.get(i).getPower();
                         ssdl = ssdl + (zsgl / 60) * (interval / 60);
                         break;
                     }
@@ -342,4 +346,87 @@ public class FiveLossService {
 
         return ssdl > 0 ? ssdl : 0;
     }
+
+    /**
+     * 使用文件计算五损数据
+     * @param ids  准备的数据ID
+     */
+    public Map<String, Object> fiveLossCal(String ids) {
+        log.info("======风机绩效榜计算开始.............");
+        Map<String, Object> promise = new HashMap<>();
+        List<FjjxbVo> result = new ArrayList<>();
+        Map<String, List<Powermodel>> zsglmap = InitialRunner.zsllglMap;
+
+        List<Powerfittinganalysis> analyses = analysisService.selectListByIds(ids);
+        if (analyses.size() == 0 || zsglmap.size() == 0){
+            log.info("======风机榜效帮计算结束,自算理论功率数据为空.............");
+            throw new CustomException(ResultCode.ERROR);
+        }
+
+        for (Powerfittinganalysis p : analyses) {
+            List<String> content = FileUtil.readFile(p.getPath(), true);
+            if (content.size() == 0){
+                log.info("======风机榜效帮计算结束,文件内容为空.............");
+                continue;
+            }
+            log.info("======风机绩效榜计算:" + p.getWindturbine());
+            double llfdl = 0.0; //理论发电量
+            double rfdl = 0.0; //日发电量
+            double jhjxssdl = 0.0;//计划检修损失电量
+            double fjhjxssdl =0.0;//非计划检修电量
+            double xdssdl = 0.0;//限电损失电量
+            double slssdl = 0.0;//受累损失电量
+            double xnssdl = 0.0;//性能损失电量
+            double speed = 0.0;//风速
+            content.remove(0); //去掉标题栏
+            int count = 86400 / p.getInterp(); //一天86400s  一天的条数
+            List<List<String>> coll = CollectUtil.groupListByQty(content, count);
+            for (List<String> ls : coll) {
+                List<PowerPointData> pdl = ls.stream().map(mp -> new PowerPointData(mp.split(","), false)).collect(Collectors.toList());
+                double lldl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), -1); //理论发电量
+                double dj = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 0); //待机
+                double sdtj = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 1); //手动停机
+                double zcfd = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 2); //正常发电
+                double xdss = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 5);  //限电损失电量
+                double qxjcl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 3); //缺陷降出力损失电量
+                double xdjcl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 4); //限电降出力损失电量
+                double cnsltj = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 7); //场内受累停机损失电量
+                double cnsljx = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 9); //场内受累检修损失电量
+                double dwsl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 10); //电网受累损失电量
+                double hjsl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 11); //环境受累损失电量
+                double gzss = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 6); //故障损失电量
+                double tjjx = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 8); //停机检修
+
+                llfdl += lldl;
+                jhjxssdl += (tjjx + cnsljx);
+                fjhjxssdl += (gzss + cnsltj);
+                xdssdl += (xdjcl + xdss);
+                slssdl += (dwsl + hjsl);
+                xnssdl += (dj + sdtj + zcfd + qxjcl);
+                rfdl += pdl.get(pdl.size() - 1).getDl();
+                speed += pdl.stream().mapToDouble(PowerPointData::getSpeed).sum();
+            }
+            FjjxbVo vo = new FjjxbVo();
+            vo.setId(p.getWindturbine());
+            vo.setName(p.getWindturbine());
+            vo.setLlfdl(llfdl);
+            vo.setSjfdl(rfdl);
+            vo.setJhjx(jhjxssdl);
+            vo.setFjhjx(fjhjxssdl);
+            vo.setXd(xdssdl);
+            vo.setXn(xnssdl);
+            vo.setSl(slssdl);
+            vo.setSpeed(new BigDecimal(speed/content.size()).setScale(2, RoundingMode.CEILING).doubleValue());
+            vo.setFnlly(llfdl > 0 ? new BigDecimal(rfdl / llfdl).setScale(2, RoundingMode.CEILING).doubleValue() : 0);
+            result.add(vo);
+        }
+        log.info("======风机榜效帮计算结束.............");
+        /** 添加标题 **/
+        List<FixedVo> fxList = AnnotationTool.getFixedVoList(FjjxbVo.class);
+        List<TableTitle> lt = fxList.stream().map(d -> new TableTitle(d.getName(), d.getDes())).collect(Collectors.toList());
+        promise.put("title", lt);
+        promise.put("data", result);
+
+        return promise;
+    }
 }

+ 5 - 4
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/windresource/RatioService.java

@@ -2,6 +2,7 @@ package com.gyee.power.fitting.service.custom.windresource;
 
 
 import com.gyee.power.fitting.common.alg.PowerFittingALG;
+import com.gyee.power.fitting.common.alg.WindDirectionALG;
 import com.gyee.power.fitting.common.util.FileUtil;
 import com.gyee.power.fitting.model.Powerfittinganalysis;
 import com.gyee.power.fitting.model.custom.Point;
@@ -34,8 +35,8 @@ public class RatioService {
         if (mode == 0){
             listObj.forEach(obj -> {
                 List<PowerPointData> points = csvParse(obj);
-                int[] count = PowerFittingALG.windDeviationRatio(points);
-                List<Point> scatter = PowerFittingALG.windDeviationScatter(points);
+                int[] count = WindDirectionALG.windDeviationRatio(points);
+                List<Point> scatter = WindDirectionALG.windDeviationScatter(points);
                 Map<String, Object> map = new HashMap<>();
                 map.put("wtId", obj.getWindturbine());
                 map.put("count", count);
@@ -49,8 +50,8 @@ public class RatioService {
                 List<PowerPointData> points = csvParse(obj);
                 ls.addAll(points);
             });
-            int[] count = PowerFittingALG.windDeviationRatio(ls);
-            List<Point> scatter = PowerFittingALG.windDeviationScatter(ls);
+            int[] count = WindDirectionALG.windDeviationRatio(ls);
+            List<Point> scatter = WindDirectionALG.windDeviationScatter(ls);
             Map<String, Object> map = new HashMap<>();
             map.put("wtId", "merge");
             map.put("count", count);

+ 2 - 2
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/windresource/WindDirectionService.java

@@ -42,7 +42,7 @@ public class WindDirectionService {
                 map.put("roses", WindDirectionALG.fxRoses(ls));
                 map.put("count", WindDirectionALG.fxCountRoses(ls));
                 map.put("radar", WindDirectionALG.fxRadarRoses(ls));
-                map.put("frequency", PowerFittingALG.windDeviationPoint(ls));
+                map.put("frequency", WindDirectionALG.windDeviationPoint(ls));
                 result.add(map);
             }
         }
@@ -55,7 +55,7 @@ public class WindDirectionService {
             map.put("roses", WindDirectionALG.fxRoses(ls));
             map.put("count", WindDirectionALG.fxCountRoses(ls));
             map.put("radar", WindDirectionALG.fxRadarRoses(ls));
-            map.put("frequency", PowerFittingALG.windDeviationPoint(ls));
+            map.put("frequency", WindDirectionALG.windDeviationPoint(ls));
             result.add(map);
         }
 

+ 5 - 9
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PowerfittinganalysisServiceImpl.java

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -70,15 +71,13 @@ public class PowerfittinganalysisServiceImpl extends ServiceImpl<Powerfittingana
 
     @Override
     public List<Powerfittinganalysis> selectListByIds(String ids) {
-        List<Powerfittinganalysis> list = new ArrayList();
-
         try{
-            list = baseMapper.selectBatchIds(Arrays.asList(ids.split(",")));
+            return baseMapper.selectBatchIds(Arrays.asList(ids.split(",")));
         }catch (Exception e){
             log.error("PowerfittinganalysisServiceImpl--selectListByIds", e);
         }
 
-        return list;
+        return Collections.EMPTY_LIST;
     }
 
     @Override
@@ -92,18 +91,15 @@ public class PowerfittinganalysisServiceImpl extends ServiceImpl<Powerfittingana
 
     @Override
     public List<Powerfittinganalysis> selectListByIsCal(String type, int isCal) {
-        List<Powerfittinganalysis> list = new ArrayList();
-
         ExcludeQueryWrapper wrapper = new ExcludeQueryWrapper();
         wrapper.eq("type", type);
         wrapper.eq("iscal", isCal);
-
         try{
-            list = baseMapper.selectList(wrapper);
+            return baseMapper.selectList(wrapper);
         }catch (Exception e){
             log.error("PowerfittinganalysisServiceImpl--selectListByIsCal", e);
         }
 
-        return list;
+        return Collections.EMPTY_LIST;
     }
 }

+ 3 - 3
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PowerlossinfoServiceImpl.java

@@ -10,6 +10,7 @@ import com.gyee.power.fitting.model.Powerlossinfo;
 import com.gyee.power.fitting.service.PowerlossinfoService;
 import org.springframework.stereotype.Service;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
@@ -82,7 +83,6 @@ public class PowerlossinfoServiceImpl extends ServiceImpl<PowerlossinfoMapper, P
 
     @Override
     public List<Powerlossinfo> selectList(String station, List<String> project, List<String> line, Date st, Date et) {
-        List<Powerlossinfo> list = new ArrayList<>();
         ExcludeQueryWrapper<Powerlossinfo> wrapper = new ExcludeQueryWrapper<>();
         wrapper.eq("stationid", station)
                 .in("projectid", project)
@@ -90,10 +90,10 @@ public class PowerlossinfoServiceImpl extends ServiceImpl<PowerlossinfoMapper, P
                 .ge("recorddate", st)
                 .le("recorddate", et);
         try{
-            list = baseMapper.selectList(wrapper);
+            return baseMapper.selectList(wrapper);
         }catch (Exception e){
             log.error("FiveLossService--fiveLoss", e);
         }
-        return list;
+        return Collections.EMPTY_LIST;
     }
 }

+ 66 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/impl/PowermodelServiceImpl.java

@@ -0,0 +1,66 @@
+package com.gyee.power.fitting.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.power.fitting.common.base.ExcludeQueryWrapper;
+import com.gyee.power.fitting.common.util.CollectUtil;
+import com.gyee.power.fitting.common.util.SnowFlakeUtil;
+import com.gyee.power.fitting.mapper.PowermodelMapper;
+import com.gyee.power.fitting.model.Powermodel;
+import com.gyee.power.fitting.service.PowermodelService;
+import org.springframework.stereotype.Service;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author chenmh
+ * @since 2023-02-21
+ */
+@Service
+public class PowermodelServiceImpl extends ServiceImpl<PowermodelMapper, Powermodel> implements PowermodelService {
+
+    @Override
+    public void insertBatch(List<Powermodel> list) {
+        list.forEach(item -> item.setId(SnowFlakeUtil.generateId()));
+        try{
+            if (list.size() > 1000){
+                List<List<Powermodel>> coll = CollectUtil.groupListByQty(list, 1000);
+                coll.forEach(ls -> saveBatch(ls));
+            } else {
+                saveBatch(list);
+            }
+        }catch (Exception e){
+            log.error("PowermodelServiceImpl--insertBatch", e);
+        }
+    }
+
+    @Override
+    public boolean deleteItem(String wtId) {
+        ExcludeQueryWrapper<Powermodel> wrapper = new ExcludeQueryWrapper<>();
+        wrapper.eq("windturbineid", wtId);
+        int count = 0;
+        try{
+            count = baseMapper.delete(wrapper);
+        } catch (Exception e){
+            log.error("PowermodelServiceImpl--deleteItem", e);
+            return false;
+        }
+        return count > 0 ? true : false;
+    }
+
+    @Override
+    public List<Powermodel> selectByWtId(String wtId) {
+        ExcludeQueryWrapper<Powermodel> wrapper = new ExcludeQueryWrapper<>();
+        wrapper.eq("windturbineid", wtId);
+        try{
+            return baseMapper.selectList(wrapper);
+        }catch (Exception e){
+            log.error("PowermodelServiceImpl--selectByWtId", e);
+        }
+        return Collections.EMPTY_LIST;
+    }
+}

+ 6 - 3
power-fitting/src/main/resources/application.yaml

@@ -9,12 +9,15 @@ gyee:
   file-path-fitting: data\fitting\
   # 数据压缩下载
   file-path-download: data\zip\
+  # 功率曲线离线数据保存路径
+  file-path-power: data\power\
   # 数据准备时由于数据量太大,初始一个默认间隔,用于适配器取数
   interval: 20
   # 当前是否是离线环境
-  offline: true
-  # 功率曲线离线数据保存路径
-  file-path-power: data\power\
+  off-line: true
+  # 是否实时计算五损数据   true:连接实时数据库按天计算   false:使用离线数据按月计算
+  real-time-cal: false
+
 
 server:
   port: 9002

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


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

@@ -23,12 +23,13 @@
         <result column="PC12RATIO" property="pc12ratio" />
         <result column="PC25RATIO" property="pc25ratio" />
         <result column="INTERP" property="interp" />
+        <result column="ISPROCESS" property="isprocess" />
         <result column="ISCAL" property="iscal" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        ID, STATION, STATIONCN, WINDTURBINE, code, interval, TIME, PATH, TYPE, PROCESSID, CPAVG, SPEEDAVG, FREQUENCY, PCRATIO, PC5RATIO, PC10RATIO, PC12RATIO, PC25RATIO, INTERP, ISCAL
+        ID, STATION, STATIONCN, WINDTURBINE, code, interval, TIME, PATH, TYPE, PROCESSID, CPAVG, SPEEDAVG, FREQUENCY, PCRATIO, PC5RATIO, PC10RATIO, PC12RATIO, PC25RATIO, INTERP, ISCAL, ISPROCESS
     </sql>
 
 </mapper>