|
@@ -0,0 +1,459 @@
|
|
|
+package com.gyee.power.fitting.service.custom.curve;
|
|
|
+
|
|
|
+import com.gyee.power.fitting.common.alg.DBSCANPointALG;
|
|
|
+import com.gyee.power.fitting.common.config.GyeeConfig;
|
|
|
+import com.gyee.power.fitting.common.constants.Constants;
|
|
|
+import com.gyee.power.fitting.common.spring.InitialRunner;
|
|
|
+import com.gyee.power.fitting.common.util.FileUtil;
|
|
|
+import com.gyee.power.fitting.common.alg.PowerFittingALG;
|
|
|
+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.custom.*;
|
|
|
+import com.gyee.power.fitting.service.PowerfittinganalysisService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class DataFittingService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private GyeeConfig config;
|
|
|
+ @Resource
|
|
|
+ private DataScanService dataScanService;
|
|
|
+ @Resource
|
|
|
+ private PowerfittinganalysisService powerService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 曲线拟合
|
|
|
+ * @param ids
|
|
|
+ * @param maxs
|
|
|
+ * @param mins
|
|
|
+ * @param maxp
|
|
|
+ * @param minp
|
|
|
+ * @param dimension
|
|
|
+ * @param mode 拟合方式 0:单台拟合 1:合并拟合 2:同名拟合
|
|
|
+ */
|
|
|
+ public Powerfittinganalysis dataFitting(String ids, Double maxs, Double mins, Double maxp, Double minp, Integer dimension, Integer mode){
|
|
|
+ AtomicReference<Powerfittinganalysis> object = new AtomicReference<>();
|
|
|
+
|
|
|
+ if (mode == 0){ //单台拟合
|
|
|
+ String[] splitId = ids.split(",");
|
|
|
+ for (String id : splitId) {
|
|
|
+ List<Powerfittinganalysis> list = powerService.selectListByIds(id);
|
|
|
+ List<Double> arraySpeed = new ArrayList<>();
|
|
|
+ List<Double> arrayPower = new ArrayList<>();
|
|
|
+ List<String> line = FileUtil.readFile(list.get(0).getPath(), true);
|
|
|
+ csvParse(line, arraySpeed, arrayPower, mins, maxs, minp, maxp);
|
|
|
+ List<Modelpowerdetails> mp = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(list.get(0).getWindturbine()).getModelid());
|
|
|
+ Double maxP = mp.stream().map(Modelpowerdetails::getEnsurepower).max(Comparator.comparing(Double::doubleValue)).get();
|
|
|
+ object.set(fittingMode(list, maxP, arraySpeed, arrayPower, dimension, mode));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (mode == 1){ //合并拟合
|
|
|
+ List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
|
|
|
+ AtomicReference<Double> maxP = new AtomicReference<>(0.0);
|
|
|
+ List<Double> arraySpeed = new ArrayList<>();
|
|
|
+ List<Double> arrayPower = new ArrayList<>();
|
|
|
+ for (Powerfittinganalysis obj : list){
|
|
|
+ List<String> line = FileUtil.readFile(obj.getPath(), true);
|
|
|
+ csvParse(line, arraySpeed, arrayPower, mins, maxs, minp, maxp);
|
|
|
+ List<Modelpowerdetails> mp = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid());
|
|
|
+ Double maxPower = mp.stream().map(Modelpowerdetails::getEnsurepower).max(Comparator.comparing(Double::doubleValue)).get();
|
|
|
+ if (maxPower > maxP.get()) maxP.set(maxPower);
|
|
|
+ }
|
|
|
+ object.set(fittingMode(list, maxP.get(), arraySpeed, arrayPower, dimension, mode));
|
|
|
+ }
|
|
|
+ if (mode == 2){ //同名拟合
|
|
|
+ List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
|
|
|
+ Map<String, List<Powerfittinganalysis>> map = list.stream().collect(Collectors.groupingBy(d -> d.getWindturbine()));
|
|
|
+ map.forEach((k, ls) -> {
|
|
|
+ if (ls.size() > 1){
|
|
|
+ double maxP = 0;
|
|
|
+ List<Modelpowerdetails> mp = null;
|
|
|
+ List<Double> arraySpeed = new ArrayList<>();
|
|
|
+ List<Double> arrayPower = new ArrayList<>();
|
|
|
+ for (Powerfittinganalysis obj : ls){
|
|
|
+ List<String> line = FileUtil.readFile(obj.getPath(), true);
|
|
|
+ csvParse(line, arraySpeed, arrayPower, mins, maxs, minp, maxp);
|
|
|
+ mp = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid());
|
|
|
+ maxP = mp.stream().map(Modelpowerdetails::getEnsurepower).max(Comparator.comparing(Double::doubleValue)).get();
|
|
|
+ }
|
|
|
+ object.set(fittingMode(ls, maxP, arraySpeed, arrayPower, dimension, mode));
|
|
|
+ }else {
|
|
|
+ for (Powerfittinganalysis obj : ls) {
|
|
|
+ List<Powerfittinganalysis> collect = new ArrayList<>();
|
|
|
+ collect.add(obj);
|
|
|
+ List<Double> arraySpeed = new ArrayList<>();
|
|
|
+ List<Double> arrayPower = new ArrayList<>();
|
|
|
+ List<String> line = FileUtil.readFile(collect.get(0).getPath(), true);
|
|
|
+ csvParse(line, arraySpeed, arrayPower, mins, maxs, minp, maxp);
|
|
|
+ List<Modelpowerdetails> mp = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(list.get(0).getWindturbine()).getModelid());
|
|
|
+ Double maxP = mp.stream().map(Modelpowerdetails::getEnsurepower).max(Comparator.comparing(Double::doubleValue)).get();
|
|
|
+ object.set(fittingMode(collect, maxP, arraySpeed, arrayPower, dimension, mode));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return object.get();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 拟合模块展示 tree
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<Object> dataFittingTree(){
|
|
|
+ List<Powerfittinganalysis> list = powerService.selectList(Constants.DATA_FITTING);
|
|
|
+ List<Object> ls = PowerFittingUtil.powerDataTree(list, Constants.DATA_FITTING);
|
|
|
+ return ls;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 组装表格数据
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Object> dataFittingShow(String id){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+
|
|
|
+ /** 添加标题 **/
|
|
|
+ List<TableTitle> lt = new ArrayList<>();
|
|
|
+ StringBuilder sb = setTitle();
|
|
|
+ String[] str = sb.toString().split(",");
|
|
|
+ for (String s : str){
|
|
|
+ lt.add(new TableTitle(s));
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 添加内容 **/
|
|
|
+ List<PowerFittingPoint> list = new ArrayList<>();
|
|
|
+ Powerfittinganalysis obj = powerService.selectItemById(id);
|
|
|
+ List<String> ls = FileUtil.readFile(obj.getPath(), false);
|
|
|
+ for (int i = 1; i < ls.size(); i++){
|
|
|
+ PowerFittingPoint data = new PowerFittingPoint(ls.get(i).split(","));
|
|
|
+ list.add(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("title", lt);
|
|
|
+ map.put("data", list);
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 曲线,散点等数据
|
|
|
+ * 风速 eg:[1,2,3,4。。。。]
|
|
|
+ * 曲线 eg:[1,2,3,4。。。。]
|
|
|
+ * 散点 eg:[[1,2],[3,2],[3,5]。。。。。]
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Object> dataFittingCurve(String id){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ Powerfittinganalysis obj = powerService.selectItemById(id);
|
|
|
+
|
|
|
+ //实际功率、风速、Cp值
|
|
|
+ List<Object> sjglList = new ArrayList<>();
|
|
|
+ List<Object> cpzList = new ArrayList<>();
|
|
|
+ List<String> ls = FileUtil.readFile(obj.getPath(), true);
|
|
|
+ for (int i = 1; i < ls.size(); i++){
|
|
|
+ String[] split = ls.get(i).split(",");
|
|
|
+ sjglList.add(new double[]{Double.valueOf(split[0]), Double.valueOf(split[1])});
|
|
|
+ cpzList.add(new double[]{Double.valueOf(split[0]), Double.valueOf(split[2])});
|
|
|
+ }
|
|
|
+
|
|
|
+ //保证功率
|
|
|
+ List<Modelpowerdetails> modelPower = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid());
|
|
|
+ List<Object> bzglList = modelPower.stream().sorted(Comparator.comparing(Modelpowerdetails::getSpeed)).map(m -> new double[]{m.getSpeed(), m.getEnsurepower()}).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //散点
|
|
|
+ String[] ids = obj.getPrepareid().split(",");
|
|
|
+ List<PowerPointData> yyd = new ArrayList<>(); //有用点
|
|
|
+ List<PowerPointData> wyd = new ArrayList<>(); //无用点
|
|
|
+ for (String pid : ids){
|
|
|
+ Powerfittinganalysis pf = powerService.selectItemById(pid);
|
|
|
+ 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);
|
|
|
+ if (pd.getSpeed() < 0 || pd.getPower() < 0)
|
|
|
+ continue;
|
|
|
+ pd.setWtId(pf.getWindturbine());
|
|
|
+ pd.setFilter(Integer.parseInt(split[9]));
|
|
|
+ if (0 == pd.getFilter())
|
|
|
+ yyd.add(pd); //没有过滤
|
|
|
+ if (1 == pd.getFilter())
|
|
|
+ wyd.add(pd); //已过滤
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dataScanService.setMapYY(DBSCANPointALG.dbscan(yyd, 10));
|
|
|
+ dataScanService.setMapWY(DBSCANPointALG.dbscan(wyd, 10));
|
|
|
+
|
|
|
+ List<PointVo> listYY = new ArrayList<>();
|
|
|
+ List<PointVo> listWY = new ArrayList<>();
|
|
|
+ dataScanService.getMapYY().forEach((k, v) -> {
|
|
|
+ listYY.add(new PointVo(v.get(0).getSpeed(), v.get(0).getPower(), dataScanService.getMapYY().get(k).size() + 3, k));
|
|
|
+ });
|
|
|
+ dataScanService.getMapWY().forEach((k, v) -> {
|
|
|
+ listWY.add(new PointVo(v.get(0).getSpeed(), v.get(0).getPower(), dataScanService.getMapWY().get(k).size() + 3, k));
|
|
|
+ });
|
|
|
+
|
|
|
+ map.put("sjgl", sjglList); //实际功率
|
|
|
+ map.put("llgl", bzglList); //保证功率
|
|
|
+ map.put("cpz", cpzList); //Cp值
|
|
|
+ map.put("obj", obj); //对象
|
|
|
+ map.put("yyd", listYY); //有用散点
|
|
|
+ map.put("wyd", listWY); //无用散点
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String assemble(LineCurveFitting lf){
|
|
|
+ StringBuilder sb = setTitle();
|
|
|
+ for (int i = 0; i < lf.getYLines().size(); i++){
|
|
|
+ Point cp = lf.getCpValue().get(i);
|
|
|
+ Point gl = lf.getYLines().get(i);
|
|
|
+
|
|
|
+ String stx = String.format("%.2f", gl.getX());
|
|
|
+ double x = Double.parseDouble(stx);
|
|
|
+ String sty = String.format("%.2f", gl.getY());
|
|
|
+ double y = Double.parseDouble(sty);
|
|
|
+ String stcp = String.format("%.4f", cp.getY());
|
|
|
+ double z = Double.parseDouble(stcp);
|
|
|
+ sb.append(x).append(",").append(y).append(",").append(z).append("\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private StringBuilder setTitle(){
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ String columnName = String.join(",", Constants.FITTING_TITLE);
|
|
|
+ sb.append(columnName).append("\n");
|
|
|
+ return sb;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /** 读取csv数据 转换成对象数组 **/
|
|
|
+ private void csvParse(List<String> line, List<Double> arrayS, List<Double> arrayP, double mins, double maxs, double minp, double maxp){
|
|
|
+ for (int i = 1; i < line.size(); i++) {
|
|
|
+ String[] split = line.get(i).split(",");
|
|
|
+ int filter = Integer.valueOf(split[9]); //是否过滤 0:没过滤 1:过滤
|
|
|
+ double x = Double.valueOf(split[2]); //风速
|
|
|
+ double y = Double.valueOf(split[1]); //功率
|
|
|
+ if (filter == 0 && (x >= mins && x <= maxs && y >= minp && y <= maxp)) {
|
|
|
+ arrayS.add(x);
|
|
|
+ arrayP.add(y);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Powerfittinganalysis fittingMode(List<Powerfittinganalysis> list, Double powerMax, List<Double> arraySpeed, List<Double> arrayPower, Integer dimension, int mode){
|
|
|
+ if (list == null || list.size() == 0)
|
|
|
+ return null;
|
|
|
+
|
|
|
+ Powerfittinganalysis obj = list.get(0);
|
|
|
+ //风速0-25,数据不全拟合的则不全,需要补一下
|
|
|
+ arraySpeed.add(0.0);
|
|
|
+ arraySpeed.add(25.01);
|
|
|
+ arrayPower.add(0.0);
|
|
|
+ arrayPower.add(powerMax);
|
|
|
+ double[] arrX = arraySpeed.stream().sorted().mapToDouble(i->i).toArray();
|
|
|
+ double[] arrY = arrayPower.stream().sorted().mapToDouble(i->i).toArray();
|
|
|
+
|
|
|
+ //功率曲线拟合
|
|
|
+ List<Point> temp = PowerFittingALG.buildLine(arrX, arrY, arraySpeed.size(), dimension, 0.01);
|
|
|
+
|
|
|
+ //推力系数 CP值
|
|
|
+ LineCurveFitting lf = new LineCurveFitting();
|
|
|
+ lf.setYLines(temp);
|
|
|
+ lf = PowerFittingALG.buildCp(InitialRunner.equipmentMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid()).getSweptarea(), lf);
|
|
|
+
|
|
|
+ //曲线偏差率
|
|
|
+ List<Point> pointsAll = new ArrayList<>();
|
|
|
+ List<Modelpowerdetails> mp = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid());
|
|
|
+ for (int i = 0; i < mp.size(); i++){
|
|
|
+ Modelpowerdetails power = mp.get(i);
|
|
|
+ pointsAll.add(new Point(power.getSpeed(), power.getEnsurepower()));
|
|
|
+ }
|
|
|
+ double maxp = mp.stream().max(Comparator.comparing(d -> d.getEnsurepower())).get().getEnsurepower();
|
|
|
+ double pcl = PowerFittingALG.curveDeviationRatio(temp, pointsAll, maxp);
|
|
|
+
|
|
|
+ String content = assemble(lf);
|
|
|
+ String prepareId = "";
|
|
|
+ String fileName = null;
|
|
|
+ if (mode == 0){
|
|
|
+ prepareId = obj.getId();
|
|
|
+ fileName = config.getFilePathFitting() + obj.getStation() + "_" + obj.getCode() + "_" + SnowFlakeUtil.generateIdL() / 100000 + ".csv";
|
|
|
+ }
|
|
|
+ if (mode == 1){
|
|
|
+ prepareId = list.stream().map(d -> d.getId()).collect(Collectors.joining(","));
|
|
|
+ fileName = config.getFilePathFitting() + obj.getStation() + "_merge" + "_" + SnowFlakeUtil.generateIdL() / 100000 + ".csv";
|
|
|
+ }
|
|
|
+ if (mode == 2){
|
|
|
+ prepareId = list.stream().map(d -> d.getId()).collect(Collectors.joining(","));
|
|
|
+ fileName = config.getFilePathFitting() + obj.getStation() + "_same" + "_" + SnowFlakeUtil.generateIdL() / 100000 + ".csv";
|
|
|
+ }
|
|
|
+ boolean flag = FileUtil.writeFile(fileName, content);
|
|
|
+ if (flag) { // TODO 保存数据库
|
|
|
+ obj.setPath(fileName);
|
|
|
+ obj.setPrepareid(prepareId);
|
|
|
+ obj.setCpavg(lf.getCpAvg());
|
|
|
+ obj.setPcratio(pcl);
|
|
|
+ obj.setType(Constants.DATA_FITTING);
|
|
|
+ powerService.insertItem(obj);
|
|
|
+ }
|
|
|
+ System.out.println("功率曲线拟合完成:" + obj.getWindturbine());
|
|
|
+
|
|
|
+ return obj;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过大点的key获取小散点
|
|
|
+ * @param yk
|
|
|
+ * @param wk
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<PowerPointData> dataOrigin(String yk, String wk) {
|
|
|
+ List<PowerPointData> list = new ArrayList<>();
|
|
|
+
|
|
|
+ if (!StringUtils.isEmpty(yk)){
|
|
|
+ String[] key = yk.split(",");
|
|
|
+ for (String k : key){
|
|
|
+ list.addAll(dataScanService.getMapYY().get(k));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(wk)){
|
|
|
+ String[] kew = wk.split(",");
|
|
|
+ for (String k : kew){
|
|
|
+ list.addAll(dataScanService.getMapWY().get(k));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 曲线偏差率 分段的+全部的
|
|
|
+ * @param id
|
|
|
+ * 3-5 5-10 10-12 12-25
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Double> dataCurveRatio(String id) {
|
|
|
+ Map<String, Double> map = new HashMap<>();
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
+ Powerfittinganalysis obj = powerService.selectItemById(id);
|
|
|
+ try{
|
|
|
+ //风速、实际功率
|
|
|
+ List<Point> point5 = new ArrayList<>(); //分段
|
|
|
+ List<Point> point10 = new ArrayList<>(); //分段
|
|
|
+ List<Point> point12= new ArrayList<>(); //分段
|
|
|
+ List<Point> point25 = new ArrayList<>(); //分段
|
|
|
+ List<String> ls = FileUtil.readFile(obj.getPath(), true);
|
|
|
+ for (int i = 1; i < ls.size(); i++){
|
|
|
+ String[] split = ls.get(i).split(",");
|
|
|
+ double speed = Double.valueOf(split[0]);
|
|
|
+ if (speed >= 3 && speed < 5)
|
|
|
+ point5.add(new Point(speed, Double.valueOf(split[1])));
|
|
|
+ if (speed >= 5 && speed < 10)
|
|
|
+ point10.add(new Point(speed, Double.valueOf(split[1])));
|
|
|
+ if (speed >= 10 && speed < 12)
|
|
|
+ point12.add(new Point(speed, Double.valueOf(split[1])));
|
|
|
+ if (speed >= 12 && speed <= 25)
|
|
|
+ point25.add(new Point(speed, Double.valueOf(split[1])));
|
|
|
+ }
|
|
|
+
|
|
|
+ //保证功率
|
|
|
+ List<Point> points5 = new ArrayList<>(); //分段
|
|
|
+ List<Point> points10 = new ArrayList<>(); //分段
|
|
|
+ List<Point> points12 = new ArrayList<>(); //分段
|
|
|
+ List<Point> points25 = new ArrayList<>(); //分段
|
|
|
+ List<Modelpowerdetails> list = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(obj.getWindturbine()).getModelid());
|
|
|
+ for (int i = 0; i < list.size(); i++){
|
|
|
+ Modelpowerdetails power = list.get(i);
|
|
|
+ if (power.getSpeed() >= 3 && power.getSpeed() < 5)
|
|
|
+ points5.add(new Point(power.getSpeed(), power.getEnsurepower()));
|
|
|
+ if (power.getSpeed() >= 5 && power.getSpeed() < 10)
|
|
|
+ points10.add(new Point(power.getSpeed(), power.getEnsurepower()));
|
|
|
+ if (power.getSpeed() >= 10 && power.getSpeed() <= 12)
|
|
|
+ points12.add(new Point(power.getSpeed(), power.getEnsurepower()));
|
|
|
+ if (power.getSpeed() >= 12 && power.getSpeed() <= 25)
|
|
|
+ points25.add(new Point(power.getSpeed(), power.getEnsurepower()));
|
|
|
+ }
|
|
|
+
|
|
|
+ double maxp5 = list.stream().filter(f -> 5.0 == f.getSpeed()).collect(Collectors.toList()).get(0).getEnsurepower();
|
|
|
+ double maxp10 = list.stream().filter(f -> 10.0 == f.getSpeed()).collect(Collectors.toList()).get(0).getEnsurepower();
|
|
|
+ double maxp12 = list.stream().filter(f -> 12.0 == f.getSpeed()).collect(Collectors.toList()).get(0).getEnsurepower();
|
|
|
+ double maxp25 = list.stream().filter(f -> 25.0 == f.getSpeed()).collect(Collectors.toList()).get(0).getEnsurepower();
|
|
|
+
|
|
|
+
|
|
|
+ //曲线偏差率
|
|
|
+ double pcl5 = PowerFittingALG.curveDeviationRatio2(point5, points5, maxp5, 3);
|
|
|
+ double pcl10 = PowerFittingALG.curveDeviationRatio2(point10, points10, maxp10, 5);
|
|
|
+ double pcl12 = PowerFittingALG.curveDeviationRatio2(point12, points12, maxp12, 10);
|
|
|
+ double pcl25 = PowerFittingALG.curveDeviationRatio2(point25, points25, maxp25, 12);
|
|
|
+
|
|
|
+ map.put("pcl5", Double.valueOf(df.format(pcl5)));
|
|
|
+ map.put("pcl10", Double.valueOf(df.format(pcl10)));
|
|
|
+ map.put("pcl12", Double.valueOf(df.format(pcl12)));
|
|
|
+ map.put("pcl25", Double.valueOf(df.format(pcl25)));
|
|
|
+
|
|
|
+ } catch (Exception e){
|
|
|
+ log.error("DataFittingService--dataCurveRatio",e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 多风机功率曲线展示
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Object dataFittingLine(String ids) {
|
|
|
+ List<Object> result = new ArrayList<>();
|
|
|
+ List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
|
|
|
+ if (list.size() == 0)
|
|
|
+ return result;
|
|
|
+
|
|
|
+ list.forEach(item -> {
|
|
|
+ //实际功率、风速
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ List<Object> sjgl = new ArrayList<>();
|
|
|
+ List<String> ls = FileUtil.readFile(item.getPath(), true);
|
|
|
+ for (int i = 1; i < ls.size(); i++){
|
|
|
+ String[] split = ls.get(i).split(",");
|
|
|
+ sjgl.add(new double[]{Double.valueOf(split[0]), Double.valueOf(split[1])});
|
|
|
+ }
|
|
|
+ map.put("wtId", item.getWindturbine());
|
|
|
+ map.put("sjgl", sjgl);
|
|
|
+ result.add(map);
|
|
|
+ });
|
|
|
+
|
|
|
+ //保证功率
|
|
|
+ List<Modelpowerdetails> modelPower = InitialRunner.modelPowerDetailMap.get(InitialRunner.wtMap.get(list.get(0).getWindturbine()).getModelid());
|
|
|
+ List<Object> bzgl = modelPower.stream().sorted(Comparator.comparing(Modelpowerdetails::getSpeed)).map(m -> new double[]{m.getSpeed(), m.getEnsurepower()}).collect(Collectors.toList());
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("sjgl", result);
|
|
|
+ map.put("bzgl", bzgl);
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+}
|