|
@@ -22,6 +22,7 @@ import com.gyee.power.fitting.service.IWindpowerstationtestingpoint2Service;
|
|
|
import com.gyee.power.fitting.service.Windturbinetestingpointai2Service;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.math3.fitting.WeightedObservedPoints;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -48,6 +49,12 @@ public class IvPvCurveFittingService {
|
|
|
@Resource
|
|
|
private AnnotationTool annotationTool;
|
|
|
|
|
|
+ private List<FixedVo> fixedVos;
|
|
|
+ private Map<String, String> uniforcodes;
|
|
|
+
|
|
|
+ @Value("${gf3xjscz}")
|
|
|
+ private String gf3xjscz;
|
|
|
+
|
|
|
|
|
|
public void getDatas2File(String stationid, long start, long end) {
|
|
|
|
|
@@ -66,13 +73,12 @@ public class IvPvCurveFittingService {
|
|
|
private void infos2File(List<List<PhotovoltaicInfo>> datas) {
|
|
|
|
|
|
//文件第一行
|
|
|
- List<FixedVo> fixedVos = annotationTool.getFixedVoList(PhotovoltaicInfo.class);
|
|
|
- String columnName = fixedVos.stream().map(FixedVo::getDes).collect(Collectors.joining(","));
|
|
|
+ String columnName = getFixedVos().stream().map(FixedVo::getDes).collect(Collectors.joining(","));
|
|
|
//遍历逆变器
|
|
|
for (List<PhotovoltaicInfo> data : datas) {
|
|
|
PhotovoltaicInfo info = data.get(0);
|
|
|
String station = info.getStation();
|
|
|
- String fileName = config.getFilePathPrepare() + "gf\\" + station + "-" + info.getInverter() + "-" + DateUtils.date2StringS(new Date(info.getTime())) + ".csv";
|
|
|
+ String fileName = config.getGfDataPath() + station + "-" + info.getInverter() + "-" + DateUtils.date2StringS(new Date(info.getTime())) + ".csv";
|
|
|
File file = new File(fileName);
|
|
|
if (file.exists()) continue;
|
|
|
StringBuilder sb = new StringBuilder();
|
|
@@ -115,10 +121,9 @@ public class IvPvCurveFittingService {
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getTable(String s) {
|
|
|
- List<FixedVo> fixedVos = annotationTool.getFixedVoList(PhotovoltaicInfo.class);
|
|
|
- List<TableTitle> collect = fixedVos.stream().map(d -> new TableTitle(d.getName(), d.getDes())).collect(Collectors.toList());
|
|
|
+ List<TableTitle> collect = getFixedVos().stream().map(d -> new TableTitle(d.getName(), d.getDes())).collect(Collectors.toList());
|
|
|
Map<String, Object> tableMap = new HashMap<>();
|
|
|
- String fs = config.getFilePathPrepare() + "gf\\" + s;
|
|
|
+ String fs = config.getGfDataPath() + s;
|
|
|
List<PhotovoltaicInfo> infos = file2Info(fs, false);
|
|
|
tableMap.put("data", infos);
|
|
|
tableMap.put("title", collect);
|
|
@@ -169,17 +174,24 @@ public class IvPvCurveFittingService {
|
|
|
List<PhotovoltaicInfo> bzclds = file2Info(bzcldPath, true);
|
|
|
Map<String, PhotovoltaicInfo> bzcldMap = bzclds.stream().collect(Collectors.toMap(PhotovoltaicInfo::getInverter, Function.identity()));
|
|
|
|
|
|
- String fs = config.getFilePathPrepare() + "gf\\";
|
|
|
+ String fs = config.getGfDataPath();
|
|
|
Map<String, List<PhotovoltaicInfo>> stringListMap = new HashMap<>();
|
|
|
for (String s : fileList) {
|
|
|
//读取一个文件
|
|
|
List<PhotovoltaicInfo> infos = file2Info(fs + s, true);
|
|
|
List<PhotovoltaicInfo> theoryInfos;
|
|
|
- if (s.contains("HZJ_GDC") || s.contains("AK_GDC")) {
|
|
|
+
|
|
|
+ boolean b = false;
|
|
|
+ String[] split = gf3xjscz.split(",");
|
|
|
+ for (String s1 : split) {
|
|
|
+ if (s.contains(s1)) b = true;
|
|
|
+ }
|
|
|
+ if (b) {
|
|
|
theoryInfos = CurrentVoltageCalc.CalcTheoryPowerHZJ(infos, bzcldMap);
|
|
|
} else {
|
|
|
theoryInfos = CurrentVoltageCalc.CalcTheoryPower(infos, bzcldMap);
|
|
|
}
|
|
|
+
|
|
|
//按逆变器聚合数据
|
|
|
if (stringListMap.containsKey(theoryInfos.get(0).getInverter())) {
|
|
|
stringListMap.get(theoryInfos.get(0).getInverter()).addAll(theoryInfos);
|
|
@@ -198,7 +210,7 @@ public class IvPvCurveFittingService {
|
|
|
*/
|
|
|
public Map<String, List<PhotovoltaicInfo>> mergeCalculat(List<String> fileList) {
|
|
|
|
|
|
- String fs = config.getFilePathPrepare() + "gf\\";
|
|
|
+ String fs = config.getGfDataPath();
|
|
|
Map<String, List<PhotovoltaicInfo>> stringListMap = new HashMap<>();
|
|
|
for (String s : fileList) {
|
|
|
//读取一个文件
|
|
@@ -260,9 +272,8 @@ public class IvPvCurveFittingService {
|
|
|
}
|
|
|
|
|
|
//文件第一行
|
|
|
- List<FixedVo> fixedVos = annotationTool.getFixedVoList(PhotovoltaicInfo.class);
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
- String columnName = fixedVos.stream().map(FixedVo::getDes).collect(Collectors.joining(","));
|
|
|
+ String columnName = getFixedVos().stream().map(FixedVo::getDes).collect(Collectors.joining(","));
|
|
|
sb.append(columnName).append("\n");
|
|
|
for (PhotovoltaicInfo ptInfo : ptInfos) {
|
|
|
sb.append(ptInfo.getStation()).append(",").append(ptInfo.getInverter()).append(",")
|
|
@@ -275,7 +286,7 @@ public class IvPvCurveFittingService {
|
|
|
.append(",").append(ptInfo.getCI()).append(",").append(ptInfo.getCV())
|
|
|
.append("\n");
|
|
|
}
|
|
|
- String fileName = config.getFilePathPrepare() + "bzd\\标准点.csv";
|
|
|
+ String fileName = config.getFilePathPrepare() + "bzd" + File.separator + "标准点.csv";
|
|
|
File file = new File(fileName);
|
|
|
file.delete();
|
|
|
FileUtil.writeFile(fileName, sb.toString());
|
|
@@ -284,10 +295,9 @@ public class IvPvCurveFittingService {
|
|
|
|
|
|
public List<TableTitle> getTheoryTitel() {
|
|
|
|
|
|
- List<FixedVo> fixedVos = annotationTool.getFixedVoList(PhotovoltaicInfo.class);
|
|
|
String[] ss = {"station", "datetime", "T", "S", "actualP"};
|
|
|
List<String> strings = Arrays.asList(ss);
|
|
|
- List<TableTitle> collect = fixedVos.stream().map(d -> new TableTitle(d.getName(), d.getDes())).collect(Collectors.toList());
|
|
|
+ List<TableTitle> collect = getFixedVos().stream().map(d -> new TableTitle(d.getName(), d.getDes())).collect(Collectors.toList());
|
|
|
collect = collect.stream().filter(c -> strings.contains(c.getKey())).collect(Collectors.toList());
|
|
|
TableTitle title = new TableTitle();
|
|
|
title.setKey("ideaP");
|
|
@@ -305,7 +315,7 @@ public class IvPvCurveFittingService {
|
|
|
*/
|
|
|
public List<PhotovoltaicInfo> calculatFitting(List<String> fileList) {
|
|
|
|
|
|
- String fs = config.getFilePathPrepare() + "gf\\";
|
|
|
+ String fs = config.getGfDataPath();
|
|
|
List<PhotovoltaicInfo> infoList = new ArrayList<>();
|
|
|
for (String s : fileList) {
|
|
|
List<PhotovoltaicInfo> infos = file2Info(fs + s, true);
|
|
@@ -351,7 +361,7 @@ public class IvPvCurveFittingService {
|
|
|
public List<FjjxbVo> getPhotovoltaicPerformanceList(long startdate, long enddate) {
|
|
|
int oneday = 24 * 60 * 60;
|
|
|
|
|
|
- String bzcldPath = config.getFilePathPrepare() + "bzd\\标准点.csv";
|
|
|
+ String bzcldPath = config.getFilePathPrepare() + "bzd" + File.separator + "标准点.csv";
|
|
|
List<PhotovoltaicInfo> bzclds = file2Info(bzcldPath, true);
|
|
|
Map<String, PhotovoltaicInfo> bzcldMap = bzclds.stream().collect(Collectors.toMap(PhotovoltaicInfo::getInverter, Function.identity()));
|
|
|
|
|
@@ -383,7 +393,7 @@ public class IvPvCurveFittingService {
|
|
|
//遍历逆变器
|
|
|
for (List<PhotovoltaicInfo> data : datas) {
|
|
|
|
|
|
- if ("HZJ_GDC".equals(stationid) || "AK_GDC".equals(stationid)) {
|
|
|
+ if (gf3xjscz.contains(stationid)) {
|
|
|
CurrentVoltageCalc.CalcTheoryPowerHZJ(data, bzcldMap);
|
|
|
} else {
|
|
|
CurrentVoltageCalc.CalcTheoryPower(data, bzcldMap);
|
|
@@ -443,7 +453,7 @@ public class IvPvCurveFittingService {
|
|
|
List<PhotovoltaicInfo> infos = new ArrayList<>();
|
|
|
|
|
|
List<TsDoubleData> bdyDatas = null, cdyDatas = null, bdlDatas = null, cdlDatas = null;
|
|
|
- if ("HZJ_GDC".equals(stationid) || "AK_GDC".equals(stationid)) {
|
|
|
+ if (gf3xjscz.contains(stationid)) {
|
|
|
//电网B相电压
|
|
|
bdyDatas = adpClient.getHistorySnap(bdypoints.get(wtid), start, end, interval);
|
|
|
//电网C相电压
|
|
@@ -464,7 +474,7 @@ public class IvPvCurveFittingService {
|
|
|
|
|
|
info.setT(double3Decimal(zjwdDatas.get(j).getDoubleValue()));
|
|
|
info.setS(double3Decimal(zfsDatas.get(j).getDoubleValue(), false));
|
|
|
- if ("HZJ_GDC".equals(stationid) || "AK_GDC".equals(stationid)) {
|
|
|
+ if (gf3xjscz.contains(stationid)) {
|
|
|
info.setAI(double3Decimal(adlDatas.get(j).getDoubleValue(), false));
|
|
|
info.setBI(double3Decimal(bdlDatas.get(j).getDoubleValue(), false));
|
|
|
info.setCI(double3Decimal(cdlDatas.get(j).getDoubleValue(), false));
|
|
@@ -502,7 +512,8 @@ public class IvPvCurveFittingService {
|
|
|
* 逆变器,测点
|
|
|
*/
|
|
|
private Map<String, String> getPoints(String stationid, String key) {
|
|
|
-
|
|
|
+ //获取unifromcode
|
|
|
+ getFixedVos();
|
|
|
switch (key) {
|
|
|
case "zgl":
|
|
|
//总功率
|
|
@@ -514,30 +525,30 @@ public class IvPvCurveFittingService {
|
|
|
adyPoints = windPointService.getPoints(stationid, null, "AIG063");
|
|
|
} else {
|
|
|
//电网A相电压
|
|
|
- adyPoints = windPointService.getPoints(stationid, null, "AIG061");
|
|
|
+ adyPoints = windPointService.getPoints(stationid, null, uniforcodes.get("A相电压"));
|
|
|
}
|
|
|
return adyPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
|
|
|
case "bdy":
|
|
|
- List<Windturbinetestingpointai2> bdyPoints = windPointService.getPoints(stationid, null, "AIG061A");
|
|
|
+ List<Windturbinetestingpointai2> bdyPoints = windPointService.getPoints(stationid, null, uniforcodes.get("B相电压"));
|
|
|
return bdyPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
|
|
|
case "cdy":
|
|
|
- List<Windturbinetestingpointai2> cdyPoints = windPointService.getPoints(stationid, null, "AIG065");
|
|
|
+ List<Windturbinetestingpointai2> cdyPoints = windPointService.getPoints(stationid, null, uniforcodes.get("C相电压"));
|
|
|
return cdyPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
|
|
|
case "adl":
|
|
|
- List<Windturbinetestingpointai2> adlPoints = windPointService.getPoints(stationid, null, "AIG060");
|
|
|
+ List<Windturbinetestingpointai2> adlPoints = windPointService.getPoints(stationid, null, uniforcodes.get("A相电流"));
|
|
|
return adlPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
|
|
|
case "bdl":
|
|
|
- List<Windturbinetestingpointai2> bdlPoints = windPointService.getPoints(stationid, null, "AIG062");
|
|
|
+ List<Windturbinetestingpointai2> bdlPoints = windPointService.getPoints(stationid, null, uniforcodes.get("B相电流"));
|
|
|
return bdlPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
|
|
|
case "cdl":
|
|
|
- List<Windturbinetestingpointai2> cdlPoints = windPointService.getPoints(stationid, null, "AIG064");
|
|
|
+ List<Windturbinetestingpointai2> cdlPoints = windPointService.getPoints(stationid, null, uniforcodes.get("C相电流"));
|
|
|
return cdlPoints.stream().collect(Collectors.toMap(Windturbinetestingpointai2::getWindturbineid, Windturbinetestingpointai2::getCode));
|
|
|
}
|
|
|
return new HashMap<>();
|
|
|
}
|
|
|
|
|
|
public int deleteFiles(List<String> fileList) {
|
|
|
- String fs = config.getFilePathPrepare() + "gf\\";
|
|
|
+ String fs = config.getGfDataPath();
|
|
|
List<PhotovoltaicInfo> infoList = new ArrayList<>();
|
|
|
int count = 0;
|
|
|
for (String s : fileList) {
|
|
@@ -549,7 +560,7 @@ public class IvPvCurveFittingService {
|
|
|
|
|
|
public void downFiles(List<String> strings, HttpServletResponse response) {
|
|
|
List<File> files = path2File(strings);
|
|
|
- String path = config.getFilePathPrepare() + "zip\\" + System.currentTimeMillis() + ".zip";
|
|
|
+ String path = config.getFilePathPrepare() + "zip" + File.separator + System.currentTimeMillis() + ".zip";
|
|
|
String s = FileUtil.zipFiles(files, new File(path));
|
|
|
FileUtil.download(s, response);
|
|
|
}
|
|
@@ -557,8 +568,21 @@ public class IvPvCurveFittingService {
|
|
|
private List<File> path2File(List<String> strings) {
|
|
|
List<File> files = new ArrayList<>();
|
|
|
for (String string : strings) {
|
|
|
- files.add(new File(config.getFilePathPrepare() + "gf\\" + string));
|
|
|
+ files.add(new File(config.getGfDataPath() + string));
|
|
|
}
|
|
|
return files;
|
|
|
}
|
|
|
+
|
|
|
+ public List<FixedVo> getFixedVos() {
|
|
|
+ if (fixedVos == null) {
|
|
|
+ fixedVos = annotationTool.getFixedVoList(PhotovoltaicInfo.class);
|
|
|
+ uniforcodes = fixedVos.stream().filter(fv -> fv.getUniformCode() != null).collect(Collectors.toMap(FixedVo::getDes, FixedVo::getUniformCode));
|
|
|
+ }
|
|
|
+ return fixedVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, String> getUniforcodes() {
|
|
|
+ getFixedVos();
|
|
|
+ return uniforcodes;
|
|
|
+ }
|
|
|
}
|