|
@@ -11,9 +11,12 @@ 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.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 lombok.extern.slf4j.Slf4j;
|
|
|
+import lombok.val;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -131,19 +134,16 @@ public class DataFittingService {
|
|
|
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<FixedVo> fxList = AnnotationTool.getFixedVoList(PowerFittingData.class);
|
|
|
+ List<TableTitle> lt = fxList.stream().filter(f -> f.getRemark().equals("1"))
|
|
|
+ .map(d -> new TableTitle(d.getName(), d.getValue())).collect(Collectors.toList());
|
|
|
|
|
|
/** 添加内容 **/
|
|
|
- List<PowerFittingPoint> list = new ArrayList<>();
|
|
|
+ List<PowerFittingData> 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(","));
|
|
|
+ PowerFittingData data = new PowerFittingData(ls.get(i).split(","));
|
|
|
list.add(data);
|
|
|
}
|
|
|
|
|
@@ -171,9 +171,9 @@ public class DataFittingService {
|
|
|
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])});
|
|
|
+ PowerFittingData data = new PowerFittingData(ls.get(i).split(","));
|
|
|
+ sjglList.add(new double[]{Double.valueOf(data.getSpeed()), data.getNhdata()});
|
|
|
+ cpzList.add(new double[]{Double.valueOf(data.getSpeed()), data.getCpdata()});
|
|
|
}
|
|
|
|
|
|
//保证功率
|
|
@@ -181,7 +181,7 @@ public class DataFittingService {
|
|
|
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(",");
|
|
|
+ String[] ids = obj.getProcessid().split(",");
|
|
|
List<PowerPointData> yyd = new ArrayList<>(); //有用点
|
|
|
List<PowerPointData> wyd = new ArrayList<>(); //无用点
|
|
|
for (String pid : ids){
|
|
@@ -189,11 +189,10 @@ public class DataFittingService {
|
|
|
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);
|
|
|
+ PowerPointData pd = new PowerPointData(split, true);
|
|
|
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())
|
|
@@ -207,9 +206,11 @@ public class DataFittingService {
|
|
|
List<PointVo> listYY = new ArrayList<>();
|
|
|
List<PointVo> listWY = new ArrayList<>();
|
|
|
dataScanService.getMapYY().forEach((k, v) -> {
|
|
|
+ // k: 前端画圈时的散点数据标记
|
|
|
listYY.add(new PointVo(v.get(0).getSpeed(), v.get(0).getPower(), dataScanService.getMapYY().get(k).size() + 3, k));
|
|
|
});
|
|
|
dataScanService.getMapWY().forEach((k, v) -> {
|
|
|
+ // k: 前端画圈时的散点数据标记
|
|
|
listWY.add(new PointVo(v.get(0).getSpeed(), v.get(0).getPower(), dataScanService.getMapWY().get(k).size() + 3, k));
|
|
|
});
|
|
|
|
|
@@ -243,8 +244,9 @@ public class DataFittingService {
|
|
|
|
|
|
|
|
|
private StringBuilder setTitle(){
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
- String columnName = String.join(",", Constants.FITTING_TITLE);
|
|
|
+ val sb = new StringBuilder();
|
|
|
+ val list = AnnotationTool.getFixedVoList(PowerFittingData.class);
|
|
|
+ String columnName = list.stream().filter(f -> f.getRemark().equals("1")).map(FixedVo::getValue).collect(Collectors.joining(","));
|
|
|
sb.append(columnName).append("\n");
|
|
|
return sb;
|
|
|
}
|
|
@@ -254,9 +256,10 @@ public class DataFittingService {
|
|
|
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]); //功率
|
|
|
+ PowerPointData data = new PowerPointData(split, true);//是否过滤 0:没过滤 1:过滤
|
|
|
+ double x = data.getSpeed(); //风速
|
|
|
+ double y = data.getPower(); //功率
|
|
|
+ int filter = data.getFilter();
|
|
|
if (filter == 0 && (x >= mins && x <= maxs && y >= minp && y <= maxp)) {
|
|
|
arrayS.add(x);
|
|
|
arrayP.add(y);
|
|
@@ -290,24 +293,25 @@ public class DataFittingService {
|
|
|
dataCurveRatio(lf, obj);
|
|
|
|
|
|
String content = assemble(lf);
|
|
|
- String prepareId = "";
|
|
|
+
|
|
|
+ String processId = "";
|
|
|
String fileName = null;
|
|
|
if (mode == 0){
|
|
|
- prepareId = obj.getId();
|
|
|
+ processId = 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(","));
|
|
|
+ processId = 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(","));
|
|
|
+ processId = 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.setProcessid(processId);
|
|
|
obj.setCpavg(lf.getCpAvg());
|
|
|
obj.setType(Constants.DATA_FITTING);
|
|
|
powerService.insertItem(obj);
|
|
@@ -385,7 +389,7 @@ public class DataFittingService {
|
|
|
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)
|
|
|
+ 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()));
|
|
@@ -399,11 +403,11 @@ public class DataFittingService {
|
|
|
double maxp25 = list.stream().filter(f -> 25.0 == f.getSpeed()).collect(Collectors.toList()).get(0).getEnsurepower();
|
|
|
|
|
|
//曲线偏差率
|
|
|
- double pcl = PowerFittingALG.curveDeviationRatio2(point, points, maxp25, 11);
|
|
|
- double pcl5 = PowerFittingALG.curveDeviationRatio2(point5, points5, maxp5, 3);
|
|
|
- double pcl10 = PowerFittingALG.curveDeviationRatio2(point10, points10, maxp10, 5);
|
|
|
- double pcl12 = PowerFittingALG.curveDeviationRatio2(point12, points12, maxp12, 10);
|
|
|
- double pcl25 = PowerFittingALG.curveDeviationRatio2(point25, points25, maxp25, 12);
|
|
|
+ double pcl = PowerFittingALG.curveDeviationRatio2(point, points, maxp25, 3, 25);
|
|
|
+ double pcl5 = PowerFittingALG.curveDeviationRatio2(point5, points5, maxp5, 3, 5);
|
|
|
+ double pcl10 = PowerFittingALG.curveDeviationRatio2(point10, points10, maxp10, 5, 10);
|
|
|
+ double pcl12 = PowerFittingALG.curveDeviationRatio2(point12, points12, maxp12, 10, 12);
|
|
|
+ double pcl25 = PowerFittingALG.curveDeviationRatio2(point25, points25, maxp25, 12, 25);
|
|
|
|
|
|
obj.setPcratio(Double.valueOf(df.format(pcl)));
|
|
|
obj.setPc5ratio(Double.valueOf(df.format(pcl5)));
|
|
@@ -455,20 +459,21 @@ public class DataFittingService {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 统计并网时间 3-5m 5-10m 10-12m 12-25m 不运行
|
|
|
+ * 统计并网时间 3-5m 5-10m 10-12m 12-25m(全功率) 不运行
|
|
|
* @param ids
|
|
|
* @return
|
|
|
*/
|
|
|
public Object dataFittingTime(String ids) {
|
|
|
List<Object> result = new ArrayList<>();
|
|
|
List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
|
|
|
+
|
|
|
if (list.size() == 0)
|
|
|
return result;
|
|
|
|
|
|
list.forEach(item -> {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
int[] time = new int[5];
|
|
|
- String[] split = item.getPrepareid().split(",");//数据准备ID,获取文件
|
|
|
+ String[] split = item.getProcessid().split(",");//数据准备ID,获取文件
|
|
|
for (String id : split){
|
|
|
List<String> line = FileUtil.readFile(powerService.getById(id).getPath(), true);
|
|
|
timeTotal(time, line);
|
|
@@ -485,7 +490,7 @@ public class DataFittingService {
|
|
|
List<PowerPointData> list = new ArrayList<>();
|
|
|
double interval = DateUtil.getTimeDiff(line.get(1).split(",")[0], line.get(2).split(",")[0]); //两条数据的间隔时间
|
|
|
for (int i = 1; i < line.size(); i++){
|
|
|
- list.add(new PowerPointData(line.get(i).split(",")));
|
|
|
+ list.add(new PowerPointData(line.get(i).split(","), true));
|
|
|
}
|
|
|
for (PowerPointData item : list){
|
|
|
if (item.getSpeed() >= 3.0 && item.getSpeed() < 5.0 && item.getMxzt() == 2)
|