Bladeren bron

发电能力分析数据调整

chenminghua 1 jaar geleden
bovenliggende
commit
5c0dfccf1a
21 gewijzigde bestanden met toevoegingen van 298 en 110 verwijderingen
  1. 4 0
      benchmarking-impala/src/main/java/com/gyee/benchmarkingimpala/service/BenchmarkingService.java
  2. 2 1
      power-fitting/src/main/java/com/gyee/power/fitting/PowerBootApplication.java
  3. 9 0
      power-fitting/src/main/java/com/gyee/power/fitting/common/config/GyeeConfig.java
  4. 25 5
      power-fitting/src/main/java/com/gyee/power/fitting/common/spring/InitialRunner.java
  5. 10 8
      power-fitting/src/main/java/com/gyee/power/fitting/common/util/DateUtil.java
  6. 36 2
      power-fitting/src/main/java/com/gyee/power/fitting/common/util/FileUtil.java
  7. 64 0
      power-fitting/src/main/java/com/gyee/power/fitting/controller/agc/PowerPredictionController.java
  8. 2 2
      power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/BladeController.java
  9. 2 2
      power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/PowerTemperatureController.java
  10. 5 31
      power-fitting/src/main/java/com/gyee/power/fitting/model/agc/AgcDeviateConfig.java
  11. 10 0
      power-fitting/src/main/java/com/gyee/power/fitting/model/agc/AiPoints.java
  12. 10 5
      power-fitting/src/main/java/com/gyee/power/fitting/schedule/DeviateAnalysisTask.java
  13. 0 2
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/agc/AgcDeviateService.java
  14. 59 0
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/agc/PowerPredictionService.java
  15. 7 4
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/blade/BladeService.java
  16. 8 8
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/curve/DataFittingService.java
  17. 10 7
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/ratedpower/RatedPowerService.java
  18. 25 18
      power-fitting/src/main/java/com/gyee/power/fitting/service/custom/temperature/PowerTemperatureService.java
  19. 9 15
      power-fitting/src/main/resources/application.yaml
  20. BIN
      power-fitting/src/main/resources/gdnx.db
  21. 1 0
      power-fitting/src/main/resources/readme.md

+ 4 - 0
benchmarking-impala/src/main/java/com/gyee/benchmarkingimpala/service/BenchmarkingService.java

@@ -449,6 +449,10 @@ public class BenchmarkingService  {
        AtomicReference<Double> sl = new AtomicReference<>((double) 0);
         list.stream().forEach(i->{
            FjjxbVo vo = new FjjxbVo();
+           //由于部分风机的发电量数据采集不到,所以将理论发电量也去掉
+            if (i.getGenecapacity() <= 0){
+                i.setTherogenecapacity(0.0);
+            }
             if (type.equals("1")){
                 vo.setId(i.getWindpowerstationid());
                 vo.setName(CacheContext.wpmap.get(i.getWindpowerstationid().trim()).getName());

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

@@ -38,8 +38,9 @@ public class PowerBootApplication {
         String[] fileName = {bean.getFilePathPrepare(), bean.getFilePathProcess(), bean.getFilePathFitting(), bean.getFilePathDownload()};
         for (String path : fileName){
             File file = new File(path);
-            if (!file.exists())
+            if (!file.exists()) {
                 file.mkdirs();
+            }
         }
     }
 

+ 9 - 0
power-fitting/src/main/java/com/gyee/power/fitting/common/config/GyeeConfig.java

@@ -39,6 +39,8 @@ public class GyeeConfig {
     private String filePathProcess;
     /** 数据拟合保存路径(拟合后的数据) **/
     private String filePathFitting;
+    /** 配置文件路径 **/
+    private String filePathPower;
     /** 数据压缩下载 **/
     private String filePathDownload;
     /** 功率曲线拟合测点 **/
@@ -86,6 +88,13 @@ public class GyeeConfig {
         this.filePathDownload = filePathDownload;
     }
 
+    public String getFilePathPower() {
+        return jarF.getParentFile().getAbsolutePath() + File.separator + filePathPower;
+    }
+
+    public void setFilePathPower(String filePathPower) {
+        this.filePathPower = filePathPower;
+    }
 
     private List<String> getUniformCodes(){
         List<FixedVo> fxList = annotationTool.getFixedVoList(PowerPointData.class);

+ 25 - 5
power-fitting/src/main/java/com/gyee/power/fitting/common/spring/InitialRunner.java

@@ -1,7 +1,10 @@
 package com.gyee.power.fitting.common.spring;
 
+import com.alibaba.fastjson.JSON;
 import com.gyee.power.fitting.common.config.GyeeConfig;
+import com.gyee.power.fitting.common.util.FileUtil;
 import com.gyee.power.fitting.model.*;
+import com.gyee.power.fitting.model.agc.AgcDeviateConfig;
 import com.gyee.power.fitting.service.*;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -27,7 +30,7 @@ import java.util.stream.Collectors;
 public class InitialRunner implements CommandLineRunner {
 
     @Resource
-    GyeeConfig config;
+    private GyeeConfig config;
     @Resource
     private WindturbineService windturbineService;
     @Resource
@@ -115,6 +118,7 @@ public class InitialRunner implements CommandLineRunner {
     public static Map<String, List<Modelpowerdetails>> modelPowerDetailMap = new HashMap<>();
     /** key: NG01_01, speed, power**/
     public static Map<String, Map<Double, Double>> zsllglMap = new HashMap<>();
+    public static Map<String, AgcDeviateConfig> powerPreMap = new HashMap<>();
 
     @Override
     public void run(String... args) {
@@ -126,6 +130,7 @@ public class InitialRunner implements CommandLineRunner {
         cacheProject();
         cacheLine();
         cachePhotovoltaicInfo();
+        cacheFGL();
 
         // 耗时缓存
         new Thread(() -> {
@@ -180,8 +185,9 @@ public class InitialRunner implements CommandLineRunner {
         wpList.stream().forEach(d -> list.addAll(pointService.selectList(d.getId(), config.getPoints())));
         pointMap.putAll(list.stream().collect(Collectors.groupingBy(u -> u.getWindturbineid())));
         log.info("cachePoints: " + pointMap.size());
-        if (pointMap.size() == 0)
+        if (pointMap.size() == 0) {
             log.error("cachePoints", "测点数据缓存失败");
+        }
     }
 
     /**
@@ -189,8 +195,9 @@ public class InitialRunner implements CommandLineRunner {
      */
     private void cacheEquipment() {
         equipmentList.addAll(equipmentmodelService.selectList());
-        for (Equipmentmodel eq : equipmentList)
+        for (Equipmentmodel eq : equipmentList) {
             equipmentMap.put(eq.getId(), eq);
+        }
         log.info("设备型号数据缓存完成");
     }
 
@@ -223,12 +230,25 @@ public class InitialRunner implements CommandLineRunner {
         }else{
             List<Powermodel> list = powermodelService.selectByWtId(wtId);
             Map<Double, Double> collect = list.stream().collect(Collectors.toMap(Powermodel::getSpeed, Powermodel::getPower));
-            if (zsllglMap.containsKey(wtId))
+            if (zsllglMap.containsKey(wtId)) {
                 zsllglMap.replace(wtId, collect);
-            else
+            } else {
                 zsllglMap.put(wtId, collect);
+            }
         }
         log.info("自算功率数据缓存完成");
     }
 
+    /**
+     * 功率预测相关测点
+     */
+    private void cacheFGL(){
+        String str = FileUtil.getStringFromFile(config.getFilePathPower() + "fgl_info.json");
+        AgcDeviateConfig[] object = JSON.parseObject(str, AgcDeviateConfig[].class);
+        for (AgcDeviateConfig conf : object){
+            powerPreMap.put(conf.getId(), conf);
+        }
+        log.info("自功率预测相关测点数据缓存完成");
+    }
+
 }

+ 10 - 8
power-fitting/src/main/java/com/gyee/power/fitting/common/util/DateUtil.java

@@ -16,6 +16,16 @@ import java.util.TimeZone;
 public class DateUtil extends DateUtils {
 
     /**
+     * 时间格式(yyyy-MM-dd)
+     */
+    public final static String DATE_PATTERN = "yyyy-MM-dd";
+    public final static String DATE_SECOND_PATTERN = "yyyy-MM-dd HH:mm";
+    /**
+     * 时间格式(yyyy-MM-dd HH:mm:ss)
+     */
+    public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
+
+    /**
      * 获取当前时间
      *
      * @return
@@ -85,14 +95,6 @@ public class DateUtil extends DateUtils {
         return stamp;
     }
 
-    /**
-     * 时间格式(yyyy-MM-dd)
-     */
-    public final static String DATE_PATTERN = "yyyy-MM-dd";
-    /**
-     * 时间格式(yyyy-MM-dd HH:mm:ss)
-     */
-    public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
 
     public static String format(Date date) {
         return format(date, DATE_PATTERN);

+ 36 - 2
power-fitting/src/main/java/com/gyee/power/fitting/common/util/FileUtil.java

@@ -26,7 +26,7 @@ public class FileUtil {
         try {
             File file = new File(fileName);
             if (!file.exists()) {
-                fileName = fileName.substring(0, fileName.lastIndexOf("\\"));
+                fileName = fileName.substring(0, fileName.lastIndexOf(File.separator));
                 File file1 = new File(fileName);
                 file1.mkdirs();
                 file.createNewFile();
@@ -44,7 +44,7 @@ public class FileUtil {
             }
             bw.flush();
         } catch (Exception e) {
-            log.error("writePowerData", e);
+            log.error("FileUtil-----writePowerData", e);
             return false;
         } finally {
             try {
@@ -253,4 +253,38 @@ public class FileUtil {
         return zipFile.getAbsolutePath();
     }
 
+
+    /**
+     * 从文件中获取字符串
+     *
+     * @param path 路径
+     * @return 字符串
+     */
+    public static String getStringFromFile(String path) {
+        BufferedReader bufferedReader = null;
+        File file = new File(path);
+        if (!file.exists()) {
+            return "";
+        }
+        try {
+            bufferedReader = new BufferedReader(new FileReader(file));
+            StringBuilder sb = new StringBuilder();
+            String s = null;
+            while ((s = bufferedReader.readLine()) != null) {
+                sb.append(s);
+            }
+            return sb.toString();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                assert bufferedReader != null;
+                bufferedReader.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return "";
+    }
+
 }

+ 64 - 0
power-fitting/src/main/java/com/gyee/power/fitting/controller/agc/PowerPredictionController.java

@@ -0,0 +1,64 @@
+package com.gyee.power.fitting.controller.agc;
+
+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.spring.InitialRunner;
+import com.gyee.power.fitting.common.util.DateUtil;
+import com.gyee.power.fitting.service.custom.agc.PowerPredictionService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author gyee
+ * 功率预测接口
+ */
+@RestController
+@RequestMapping("/power/prediction")
+public class PowerPredictionController {
+
+    @Resource
+    private PowerPredictionService predictionService;
+
+    /**
+     * 查询调度名称
+     * @returnv
+     */
+    @GetMapping("config")
+    public JSONObject getConfig(){
+        List<Object> list = new ArrayList<>();
+        InitialRunner.powerPreMap.forEach((k, v) -> {
+            Map<String, String> map = new HashMap<>();
+            map.put("id", k);
+            map.put("name", v.getTitle());
+            list.add(map);
+        });
+        return JsonResult.successData(ResultCode.SUCCESS, list);
+    }
+
+
+    /**
+     * 查询功率预测数据及实际功率
+     * @param id   调度id,场站
+     * @param st
+     * @param et
+     * @param interval  功率预测数据默认15分钟一条数据  900s
+     * @return
+     */
+    @GetMapping("data")
+    public JSONObject getPredictionData(String id, String st, String et,
+                                             @RequestParam(value = "interval", defaultValue = "900", required = false) int interval){
+        long startTime = DateUtil.parseStrtoDate(st, DateUtil.DATE_PATTERN).getTime();
+        long endTime = DateUtil.addDays(DateUtil.parseStrtoDate(et, DateUtil.DATE_PATTERN), 1).getTime();
+        Map<String, Object> map = predictionService.getPredictionData(id, startTime, endTime, interval);
+        return JsonResult.successData(ResultCode.SUCCESS, map);
+    }
+}

+ 2 - 2
power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/BladeController.java

@@ -21,8 +21,8 @@ public class BladeController {
 
     /**
      * 叶片角度
-     * @param ids
-     * @return
+     * @param 数据准备 ids
+     * @returnv
      */
     @GetMapping("angle")
     public JSONObject bladeAngle(String ids){

+ 2 - 2
power-fitting/src/main/java/com/gyee/power/fitting/controller/fj/PowerTemperatureController.java

@@ -24,7 +24,7 @@ public class PowerTemperatureController {
 
     /***
      * 与温度有关的额定功率
-     * @param ids  预处理数据的id
+     * @param ids  拟合数据的id
      * @return
      */
     @GetMapping("rated/power")
@@ -36,7 +36,7 @@ public class PowerTemperatureController {
 
     /***
      * 温度曲线分析
-     * @param id  预处理数据的id
+     * @param id  拟合数据的id
      * @return
      */
     @GetMapping("curve/analysis")

+ 5 - 31
power-fitting/src/main/java/com/gyee/power/fitting/model/agc/AgcDeviateConfig.java

@@ -1,5 +1,8 @@
 package com.gyee.power.fitting.model.agc;
 
+import lombok.Data;
+
+@Data
 public class AgcDeviateConfig {
 
     private String id;
@@ -12,37 +15,8 @@ public class AgcDeviateConfig {
      */
     private String title;
 
-    private AiPoints[] aiPoints;
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public float getInstalledCapacity() {
-        return installedCapacity;
-    }
+    private AiPoints power;
 
-    public void setInstalledCapacity(float installedCapacity) {
-        this.installedCapacity = installedCapacity;
-    }
-
-    public String getTitle() {
-        return title;
-    }
-
-    public void setTitle(String title) {
-        this.title = title;
-    }
-
-    public AiPoints[] getAiPoints() {
-        return aiPoints;
-    }
+    private AiPoints[] aiPoints;
 
-    public void setAiPoints(AiPoints[] aiPoints) {
-        this.aiPoints = aiPoints;
-    }
 }

+ 10 - 0
power-fitting/src/main/java/com/gyee/power/fitting/model/agc/AiPoints.java

@@ -19,6 +19,8 @@ public class AiPoints {
      */
     private String unit;
 
+    private int type;
+
     public String getName() {
         return name;
     }
@@ -53,4 +55,12 @@ public class AiPoints {
     public void setUnit(String unit) {
         this.unit = unit;
     }
+
+    public int getType() {
+        return type;
+    }
+
+    public void setType(int type) {
+        this.type = type;
+    }
 }

+ 10 - 5
power-fitting/src/main/java/com/gyee/power/fitting/schedule/DeviateAnalysisTask.java

@@ -30,12 +30,15 @@ public class DeviateAnalysisTask {
 
     /**
      * 元数据缓存
+     * 每月1号凌晨1点执行
      */
-    @Scheduled(cron = "0 0 1 1 * ?")  //每月1号凌晨1点执行
+    @Scheduled(cron = "0 0 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点值
+        //上月1号0点值
+        Date st = DateUtil.dateZeroFormat(month);
+        //当月1号0点值
+        Date et = DateUtil.dateZeroFormat(new Date());
         Map<String, List<Windturbine>> wpMap = InitialRunner.wpMap;
         wpMap.forEach((k, v) -> {
             List<String> wtIds = v.stream().map(m -> m.getId()).collect(Collectors.toList());
@@ -46,12 +49,14 @@ public class DeviateAnalysisTask {
 
     /**
      * 根据缓存的文件进行数据预处理
+     * 每月1号22点执行
      */
-    @Scheduled(cron = "0 0 22 1 * ?")  //每月1号22点执行
+    @Scheduled(cron = "0 0 22 1 * ?")
     public void dataProcess(){
         List<Powerfittinganalysis> list = powerService.selectListByIsCal(Constants.DATA_PROCESS, 0);
-        if (list == null || list.size() == 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);

+ 0 - 2
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/agc/AgcDeviateService.java

@@ -52,8 +52,6 @@ public class AgcDeviateService {
 
     @Resource
     private IDataAdapter iDataAdapter;
-    @Resource
-    private GyeeConfig gyeeConfig;
 
 
     public AgcDeviateService(AgcDeviateMapper agcDeviateMapper, FileService fs, Environment env) {

+ 59 - 0
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/agc/PowerPredictionService.java

@@ -0,0 +1,59 @@
+package com.gyee.power.fitting.service.custom.agc;
+
+import com.alibaba.fastjson.JSONObject;
+import com.gyee.power.fitting.common.feign.RemoteServiceBuilder;
+import com.gyee.power.fitting.common.spring.InitialRunner;
+import com.gyee.power.fitting.common.util.DateUtil;
+import com.gyee.power.fitting.model.agc.AiPoints;
+import com.gyee.power.fitting.model.custom.TsDoubleData;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @author gyee
+ */
+@Service
+public class PowerPredictionService {
+
+    @Resource
+    private RemoteServiceBuilder remoteService;
+
+
+    public Map<String, Object> getPredictionData(String id, long st, long et, int interval) {
+        Map<String, Object> result = new HashMap<>();
+
+        //时间
+        List<String> time = new ArrayList<>();
+        //实际功率,等间隔
+        List<Double> sjgl = new ArrayList<>();
+        String sjglPoint = InitialRunner.powerPreMap.get(id).getPower().getTag();
+        List<TsDoubleData> data = remoteService.adapter().getHistorySnap(sjglPoint, st, et, interval);
+        for (TsDoubleData ts : data){
+            time.add(DateUtil.format(ts.getTs(), DateUtil.DATE_TIME_PATTERN));
+            sjgl.add(new BigDecimal(ts.getDoubleValue()).setScale(2, BigDecimal.ROUND_FLOOR).doubleValue());
+        }
+
+        //短期功率
+//        List<Double> dqgl = new ArrayList<>();
+//        AiPoints[] aiPoints = InitialRunner.powerPreMap.get(id).getAiPoints();
+//        List<String> fglPoint = Arrays.stream(aiPoints).filter(f -> f.getType() == 1).map(m -> m.getTag()).collect(Collectors.toList());
+//        for (long s = st; s <= et; s += (interval * 1000)){
+//            JSONObject json = remoteService.adapter().getHistorySection(tagNames, s);
+//            for (String point : fglPoint){
+//                double value = json.getJSONObject(point).getDoubleValue("doubleValue");
+//                dqgl.add(new BigDecimal(value).setScale(2, BigDecimal.ROUND_FLOOR).doubleValue());
+//            }
+//        }
+//
+//        result.put("time", time);
+//        result.put("sjgl", sjgl);
+//        result.put("dqyugl", dqgl);
+
+        return result;
+    }
+}

+ 7 - 4
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/blade/BladeService.java

@@ -1,5 +1,6 @@
 package com.gyee.power.fitting.service.custom.blade;
 
+import com.gyee.power.fitting.common.util.DateUtil;
 import com.gyee.power.fitting.common.util.FileUtil;
 import com.gyee.power.fitting.model.Powerfittinganalysis;
 import com.gyee.power.fitting.model.custom.PowerPointData;
@@ -27,8 +28,9 @@ public class BladeService {
     public Object bladeAngle(String ids){
         Map<String, Object> result = new HashMap<>();
         List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
-        if (list.size() == 0)
+        if (list.size() == 0) {
             return result;
+        }
 
         List<String> time = new ArrayList<>();
         List<Object> temp = new ArrayList<>();
@@ -51,8 +53,9 @@ public class BladeService {
             mp.put("c13", curveDeviation(p1, p3));
             mp.put("c23", curveDeviation(p2, p3));
             mp.put("wt", obj.getWindturbine());
-            if (time.size() == 0)
-                time.addAll(ls.stream().map(m -> m.getTime()).collect(Collectors.toList()));
+            if (time.size() == 0) {
+                time.addAll(ls.stream().map(m -> DateUtil.format(m.getTime(), DateUtil.DATE_SECOND_PATTERN)).collect(Collectors.toList()));
+            }
             temp.add(mp);
         }
         result.put("time", time);
@@ -110,7 +113,7 @@ public class BladeService {
         double count = 0;
         for (int i = 0; i < ls1.size(); i++){
             double diff = ls1.get(i) - ls2.get(i);
-            double v = ls2.get(i) != 0 ? diff / ls2.get(i) * 100 : diff;
+            double v = ls2.get(i) != 0 ? diff / ls2.get(i) * 100 : 0;
             count += v;
         }
         result = new BigDecimal(count / ls1.size()).setScale(2, RoundingMode.FLOOR).doubleValue();

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

@@ -11,10 +11,7 @@ import com.gyee.power.fitting.common.util.DateUtil;
 import com.gyee.power.fitting.common.util.FileUtil;
 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.Windturbine;
+import com.gyee.power.fitting.model.*;
 import com.gyee.power.fitting.model.anno.AnnotationTool;
 import com.gyee.power.fitting.model.anno.FixedVo;
 import com.gyee.power.fitting.model.custom.*;
@@ -440,15 +437,18 @@ public class DataFittingService {
     public Object dataFittingLine(String ids) {
         List<Object> result = new ArrayList<>();
         Map<String, Windturbine> wtMap = InitialRunner.wtMap;
+        Map<String, Equipmentmodel> eqMap = InitialRunner.equipmentMap;
         List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
-        if (list.size() == 0)
+        if (list.size() == 0) {
             return result;
+        }
 
-        String model = wtMap.get(list.get(0).getWindturbine()).getModelid();
+        double power = eqMap.get(wtMap.get(list.get(0).getWindturbine()).getModelid()).getPowerproduction();
         list.forEach(item -> {
             //机型不一致,额定功率计算不准确
-            if (!model.equals(wtMap.get(item.getWindturbine()).getModelid()))
-                throw new CustomException(4010, item.getWindturbine() + "机型不一致,请重新选择");
+            if (power != eqMap.get(wtMap.get(item.getWindturbine()).getModelid()).getPowerproduction()) {
+                throw new CustomException(4010, item.getWindturbine() + "机型额定功率不一致,请重新选择");
+            }
 
             //实际功率、风速
             Map<String, Object> map = new HashMap<>();

+ 10 - 7
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/ratedpower/RatedPowerService.java

@@ -9,6 +9,7 @@ import com.gyee.power.fitting.model.Windturbine;
 import com.gyee.power.fitting.model.custom.PowerPointData;
 import com.gyee.power.fitting.service.PowerfittinganalysisService;
 import lombok.val;
+import org.apache.commons.collections4.list.TreeList;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -32,29 +33,31 @@ public class RatedPowerService {
         Map<String, Equipmentmodel> eqMap = InitialRunner.equipmentMap;
         Map<String, Windturbine> wtMap = InitialRunner.wtMap;
         List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
-        if (list.size() == 0)
+        if (list.size() == 0) {
             return result;
+        }
 
         List<PowerPointData> all = new ArrayList<>();
-        TreeMap<String, Object> map = new TreeMap<>();
+        TreeList<Object> lst = new TreeList<>();
         for (Powerfittinganalysis obj : list){
             String[] spid = obj.getProcessid().split(",");
             for (String id : spid){
+                TreeMap<String, Object> mp = new TreeMap<>();
                 Powerfittinganalysis item = powerService.selectItemById(id);
                 List<PowerPointData> ls = csvParse(item);
                 all.addAll(ls);
                 double avg = ls.size() > 0 ? ls.stream().mapToDouble(PowerPointData::getPower).average().getAsDouble() : 0;
-                map.put(item.getWindturbine(), new BigDecimal(avg).setScale(0, RoundingMode.CEILING).doubleValue());
-                Map<String, Integer> mp = new HashMap<>();
-                ls.stream().collect(Collectors.groupingBy(PowerPointData::getTime)).forEach((k, v) -> mp.put(k, v.size()));
-                map.put("count", mp);
+                mp.put("wt", item.getWindturbine());
+                mp.put("avg", new BigDecimal(avg).setScale(0, RoundingMode.CEILING).doubleValue());
+                mp.put("count", ls.size());
+                lst.add(mp);
             }
         }
         double avg = all.size() > 0 ? all.stream().mapToDouble(PowerPointData::getPower).average().getAsDouble() : 0;
         double avgData = new BigDecimal(avg).setScale(0, RoundingMode.CEILING).doubleValue();
 
         result.put("avg", avgData);
-        result.put("data", map);
+        result.put("data", lst);
         result.put("power", eqMap.get(wtMap.get(list.get(0).getWindturbine()).getModelid()).getPowerproduction());
 
         return result;

+ 25 - 18
power-fitting/src/main/java/com/gyee/power/fitting/service/custom/temperature/PowerTemperatureService.java

@@ -31,24 +31,28 @@ public class PowerTemperatureService {
     public Object ratedPower(String ids) {
         List<Object> result = new ArrayList<>();
         List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
-        if (list == null || list.size() == 0)
+        if (list == null || list.size() == 0) {
             return result;
+        }
 
         for (Powerfittinganalysis obj : list){
-            Powerfittinganalysis pf = powerService.selectItemById(obj.getId());
-            List<Modelpowerdetails> ls = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid());
-            Double theoryPower = ls.get(ls.size() - 1).getTheorypower(); //理论功率
-            Map<String, Object> map = csvParse(pf);//数据解析
-            List<PowerPointData> data = (List<PowerPointData>) map.get("data");
-            Object res = PowerTemperatureAlg.temperatureRatedPower(data, theoryPower, (Double) map.get("minT"), (Double) map.get("maxT"));
-            List<int[]> rp = PowerTemperatureAlg.temperatureRatedPower(data);
-
-            Map<String, Object> mp = new HashMap<>();
-            mp.put("wt", pf.getWindturbine());
-            mp.put("power", InitialRunner.equipmentMap.get(InitialRunner.wtMap.get(pf.getWindturbine()).getModelid()));
-            mp.put("res1", res); //额定功率vs.温度分析
-            mp.put("res2", rp);  //额定功率vs.温度分析
-            result.add(mp);
+            String[] split = obj.getProcessid().split(",");
+            for (String id : split){
+                Powerfittinganalysis pf = powerService.selectItemById(id);
+                List<Modelpowerdetails> ls = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid());
+                Double theoryPower = ls.get(ls.size() - 1).getTheorypower(); //理论功率
+                Map<String, Object> map = csvParse(pf);//数据解析
+                List<PowerPointData> data = (List<PowerPointData>) map.get("data");
+                Object res = PowerTemperatureAlg.temperatureRatedPower(data, theoryPower, (Double) map.get("minT"), (Double) map.get("maxT"));
+                List<int[]> rp = PowerTemperatureAlg.temperatureRatedPower(data);
+
+                Map<String, Object> mp = new HashMap<>();
+                mp.put("wt", pf.getWindturbine());
+                mp.put("power", InitialRunner.equipmentMap.get(InitialRunner.wtMap.get(pf.getWindturbine()).getModelid()));
+                mp.put("res1", res); //额定功率vs.温度分析
+                mp.put("res2", rp);  //额定功率vs.温度分析
+                result.add(mp);
+            }
         }
 
         return result;
@@ -58,8 +62,9 @@ public class PowerTemperatureService {
     public Object curveAnalysis(String id) {
         Map<String, Object> map = new HashMap<>();
         Powerfittinganalysis obj = powerService.selectItemById(id);
-        if (obj == null)
+        if (obj == null) {
             return map;
+        }
 
         //实际功率
         List<Object> sjglList = new ArrayList<>();
@@ -79,12 +84,14 @@ public class PowerTemperatureService {
         String[] ids = obj.getProcessid().split(",");
         for (String pid : ids) {
             Powerfittinganalysis pf = powerService.selectItemById(pid);
-            List<String> lp = FileUtil.readFile(pf.getPath(), true);   //数据解析
+            //数据解析
+            List<String> lp = FileUtil.readFile(pf.getPath(), true);
             for (int i = 1; i < lp.size(); i++){
                 String[] split = lp.get(i).split(",");
                 PowerPointData pd = new PowerPointData(split, true);
-                if (pd.getSpeed() < 0 || pd.getPower() < 0)
+                if (pd.getSpeed() < 0 || pd.getPower() < 0) {
                     continue;
+                }
 
                 Object[] temp = new Object[3];
                 temp[0] = pd.getSpeed();

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

@@ -9,7 +9,7 @@ gyee:
   file-path-fitting: data/fitting/
   # 数据压缩下载
   file-path-download: data/zip/
-  # 功率曲线离线数据保存路径
+  # 配置文件保存路径
   file-path-power: data/power/
   # 数据准备时由于数据量太大,初始一个默认间隔,用于适配器取数
   interval: 20
@@ -38,22 +38,16 @@ spring:
   datasource:
     type: com.alibaba.druid.pool.DruidDataSource
     # 宁夏三区oracle
-#    driver-class-name: oracle.jdbc.OracleDriver
-#    url: jdbc:oracle:thin:@192.168.1.105:1521:gdnxfd
-#    username: nxfdprod
-#    password: gdnxfd123
-
-    # 华为云oracle(功率预测的环境)
     driver-class-name: oracle.jdbc.OracleDriver
-    url: jdbc:oracle:thin:@120.46.129.85:1521:ORCL
-    username: gyee
-    password: FRWIND
+    url: jdbc:oracle:thin:@192.168.1.105:1521:gdnxfd
+    username: nxfdprod
+    password: gdnxfd123
 
-    # 本地sql-lite
-#    driver-class-name: org.sqlite.JDBC
-#    url: jdbc:sqlite::resource:gdnx.db
-#    username:
-#    password:
+    # 华为云oracle(功率预测的环境)
+#    driver-class-name: oracle.jdbc.OracleDriver
+#    url: jdbc:oracle:thin:@120.46.129.85:1521:ORCL
+#    username: gyee
+#    password: FRWIND
 
     druid:
       # 初始化大小,最小,最大

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


+ 1 - 0
power-fitting/src/main/resources/readme.md

@@ -35,3 +35,4 @@
 
   ![img_2.png](image/img_2.png)
 
+