|
@@ -58,6 +58,10 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
private IStationInfoMinService stationInfoMinService;
|
|
|
@Resource
|
|
|
private IProBasicProjectPlanService proBasicProjectPlanService;
|
|
|
+ @Resource
|
|
|
+ private IHistoryPredictService historyPredictService;
|
|
|
+ @Resource
|
|
|
+ private IPredictExaminService predictExaminService;
|
|
|
|
|
|
@Override
|
|
|
public void execute() throws Exception {
|
|
@@ -281,10 +285,10 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
String tbId = piZt.getTurbineId();
|
|
|
// Map<Double, Long> collect = piZt.getPointDatas().stream().collect(Collectors.groupingBy(PointData::getValue, Collectors.counting()));
|
|
|
double sumfs = fsList.stream().mapToDouble(PointData::getValue).sum();
|
|
|
-// double xs = 1;
|
|
|
-// if (rfdl > 0 && sum1 > 0) {
|
|
|
-// xs = rfdl / (sum1 / 240);
|
|
|
-// }
|
|
|
+ // double xs = 1;
|
|
|
+ // if (rfdl > 0 && sum1 > 0) {
|
|
|
+ // xs = rfdl / (sum1 / 240);
|
|
|
+ // }
|
|
|
// double sum2 = fsList.stream().mapToDouble(pd -> {
|
|
|
// Double v = CalcCache.fitcoef.get(tbId).get(pd.getValue());
|
|
|
// if (v == null) v = 0.0;
|
|
@@ -1406,18 +1410,18 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
cxInfo.setPointDatas(cxc);
|
|
|
|
|
|
//风机风速、功率->场站风速、功率
|
|
|
-// List<PointData> firstFs = new ArrayList<>();
|
|
|
-// List<PointData> firstGl = new ArrayList<>();
|
|
|
+ // List<PointData> firstFs = new ArrayList<>();
|
|
|
+ // List<PointData> firstGl = new ArrayList<>();
|
|
|
List<PointData> firstZsgl = new ArrayList<>();
|
|
|
double v1, v2, v3;
|
|
|
for (int i = 0; i < agcInfo.getPointDatas().size(); i++) {
|
|
|
int finalI = i;
|
|
|
long ts = start.getTime() + i * 15000L;
|
|
|
-// v1 = fsMap.values().stream().mapToDouble(pds -> pds.getPointDatas().get(finalI).getValue()).average().orElse(0.0);
|
|
|
-// v2 = glMap.values().stream().mapToDouble(pds -> pds.getPointDatas().get(finalI).getValue()).sum();
|
|
|
+ // v1 = fsMap.values().stream().mapToDouble(pds -> pds.getPointDatas().get(finalI).getValue()).average().orElse(0.0);
|
|
|
+ // v2 = glMap.values().stream().mapToDouble(pds -> pds.getPointDatas().get(finalI).getValue()).sum();
|
|
|
v3 = pdsZsglMap.values().stream().mapToDouble(pds -> pds.get(finalI).getValue()).sum();
|
|
|
-// firstFs.add(new PointData(ts, v1));
|
|
|
-// firstGl.add(new PointData(ts, v2));
|
|
|
+ // firstFs.add(new PointData(ts, v1));
|
|
|
+ // firstGl.add(new PointData(ts, v2));
|
|
|
firstZsgl.add(new PointData(ts, v3));
|
|
|
}
|
|
|
|
|
@@ -1802,7 +1806,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
Map<String, Map<Integer, Integer>> collectAi = list.stream().collect(Collectors.groupingBy(StateAi::getModel, Collectors.toMap(StateAi::getOriginalState, StateAi::getMappingState)));
|
|
|
|
|
|
// Map<String, Map<Double,Double>> fitMap = new HashMap<>();
|
|
|
-// entityFs = entityFs.stream().filter(ef -> !CalcCache.keys.contains(ef.getTurbineId())).collect(Collectors.toList());
|
|
|
+ // entityFs = entityFs.stream().filter(ef -> !CalcCache.keys.contains(ef.getTurbineId())).collect(Collectors.toList());
|
|
|
for (PointInfo ef : entityFs) {
|
|
|
String wtId = ef.getTurbineId();
|
|
|
PointInfo glInfo = glMap.get(wtId);
|
|
@@ -3988,7 +3992,7 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
if (pdCx.getTs() + 10 * 60 * 1000 > end.getTime()) {
|
|
|
if (llgl < sjgl) llgl = sjgl * 1.0005;
|
|
|
if (llgl > sjgl * 1.5) llgl = sjgl * 1.5;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
System.out.println("实际功率测点离线");
|
|
|
}
|
|
|
PointData data = new PointData();
|
|
@@ -4052,6 +4056,137 @@ public class JavaFunctionJobHandler extends IJobHandler {
|
|
|
}
|
|
|
stationInfoMinService.saveOrUpdateBatch(byDate);
|
|
|
}
|
|
|
+
|
|
|
+ public void calcPredictExamin(Date date) {
|
|
|
+ DateTime end = DateUtil.beginOfDay(date);
|
|
|
+ DateTime begin = DateUtil.offsetDay(end, -1);
|
|
|
+ List<PointInfo> entity = getEntity("MX000", "state");
|
|
|
+ List<PointInfo> entity1 = getEntity("AI422", "state");
|
|
|
+ entity.addAll(entity1);
|
|
|
+ Map<String, EquipmentModel> map = equipmentModelService.map();
|
|
|
+
|
|
|
+ Map<String, Double> tbPowerMap = entity.stream().collect(Collectors.toMap(pi -> pi.getTurbineId(), pi -> map.get(pi.getTurbineId()).getPowerProduction()));
|
|
|
+ List<PointInfo> entityGl = getEntity("AI114", "turbine");
|
|
|
+ getSnapDataByEntity(entityGl, begin, end, 15 * 60);
|
|
|
+ Map<String, PointInfo> glpisMap = entityGl.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
|
|
|
+ QueryWrapper<HistoryPredict> predictWrapper = new QueryWrapper<>();
|
|
|
+ predictWrapper.lambda().eq(HistoryPredict::getPredictType, "CDQ").eq(HistoryPredict::getDataTime, begin)
|
|
|
+ .orderByAsc(HistoryPredict::getDataTime);
|
|
|
+ List<HistoryPredict> predictList = historyPredictService.list(predictWrapper);
|
|
|
+ Map<String, List<HistoryPredict>> predictsMap = predictList.stream().collect(Collectors.groupingBy(HistoryPredict::getTurbineId));
|
|
|
+ //超短期
|
|
|
+ List<HistoryPredict> cdqPredicts = new ArrayList<>();
|
|
|
+ predictsMap.forEach((stId, hps) -> {
|
|
|
+ cdqPredicts.addAll(hps.subList(0, 16));
|
|
|
+ });
|
|
|
+ for (int i = 1; i < 6; i++) {
|
|
|
+ DateTime hour = DateUtil.offsetHour(begin, 4 * i);
|
|
|
+ DateTime hour2 = DateUtil.offsetHour(hour, 4);
|
|
|
+ QueryWrapper<HistoryPredict> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.lambda().eq(HistoryPredict::getPredictType, "CDQ").eq(HistoryPredict::getDataTime, hour)
|
|
|
+ .between(HistoryPredict::getPredictTime, hour, hour2).orderByAsc(HistoryPredict::getDataTime);
|
|
|
+ List<HistoryPredict> predicts = historyPredictService.list(predictWrapper);
|
|
|
+ cdqPredicts.addAll(predicts);
|
|
|
+ }
|
|
|
+ Map<String, List<HistoryPredict>> cdqPredictsMap = cdqPredicts.stream().collect(Collectors.groupingBy(HistoryPredict::getTurbineId));
|
|
|
+
|
|
|
+ List<PredictExamin> peList = new ArrayList<>();
|
|
|
+ predictsMap.forEach((stId, hps) -> {
|
|
|
+ List<Double> predictPower = hps.stream().map(HistoryPredict::getPredictPower).collect(Collectors.toList());
|
|
|
+ List<Double> actualPower = glpisMap.get(stId).getPointDatas().stream().map(PointData::getValue).collect(Collectors.toList());
|
|
|
+ Double installCapacity = tbPowerMap.get(stId);
|
|
|
+ HistoryPredict predict = hps.get(0);
|
|
|
+ PredictExamin examin = new PredictExamin();
|
|
|
+ examin.setModelId(predict.getModelId());
|
|
|
+ examin.setPredictType("DQ");
|
|
|
+ examin.setDeviceType(predict.getDeviceType());
|
|
|
+ examin.setTime(begin);
|
|
|
+ examin.setSiteId(predict.getSiteId());
|
|
|
+ examin.setPeriodId(predict.getPeriodId());
|
|
|
+ examin.setLineId(predict.getLineId());
|
|
|
+ examin.setTurbineId(predict.getTurbineId());
|
|
|
+ examin.setExaminScore(calcExaminScore(predictPower, actualPower, installCapacity));
|
|
|
+ examin.setAccuracyRate(calcAccuracyRate(predictPower, actualPower, installCapacity));
|
|
|
+ peList.add(examin);
|
|
|
+ //超短期
|
|
|
+ List<Double> predictPowerCdq = cdqPredictsMap.get(stId).stream().map(HistoryPredict::getPredictPower).collect(Collectors.toList());
|
|
|
+ PredictExamin e = new PredictExamin();
|
|
|
+ e.setModelId(predict.getModelId());
|
|
|
+ e.setPredictType("CDQ");
|
|
|
+ e.setDeviceType(predict.getDeviceType());
|
|
|
+ e.setTime(begin);
|
|
|
+ e.setSiteId(predict.getSiteId());
|
|
|
+ e.setPeriodId(predict.getPeriodId());
|
|
|
+ e.setLineId(predict.getLineId());
|
|
|
+ e.setTurbineId(predict.getTurbineId());
|
|
|
+ e.setExaminScore(calcExaminScore(predictPowerCdq, actualPower, installCapacity));
|
|
|
+ e.setAccuracyRate(calcAccuracyRate(predictPowerCdq, actualPower, installCapacity));
|
|
|
+ peList.add(e);
|
|
|
+ });
|
|
|
+ predictExaminService.saveBatch(peList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算功率日预测曲线最大误差值
|
|
|
+ *
|
|
|
+ * @param predictPower 96个点的预测功率值
|
|
|
+ * @param actualPower 96个点的实际功率值
|
|
|
+ * @param installCapacity 装机容量
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ public double calcExaminScore(List<Double> predictPower, List<Double> actualPower, Double installCapacity) {
|
|
|
+ if (CollUtil.isEmpty(predictPower) || CollUtil.isEmpty(actualPower) || installCapacity == null) return 0;
|
|
|
+ int n = predictPower.size();
|
|
|
+ if (n != actualPower.size()) return 0;
|
|
|
+ double maxErrorPercentage = 0.0;
|
|
|
+ for (int i = 0; i < n; i++) {
|
|
|
+ double errorPercentage = 0.0;
|
|
|
+ if (predictPower.get(i) == 0) {
|
|
|
+ if (Math.abs(actualPower.get(i)) <= 0.03 * installCapacity) {
|
|
|
+ continue; // 不考核
|
|
|
+ } else {
|
|
|
+ errorPercentage = 100.0;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ errorPercentage = Math.abs(predictPower.get(i) - actualPower.get(i)) / predictPower.get(i) * 100;
|
|
|
+ }
|
|
|
+ if (errorPercentage > maxErrorPercentage) {
|
|
|
+ maxErrorPercentage = errorPercentage;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return maxErrorPercentage;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算功率超短期预测曲线准确率
|
|
|
+ *
|
|
|
+ * @param predictPower 96个点的预测功率值
|
|
|
+ * @param actualPower 96个点的实际功率值
|
|
|
+ * @param installCapacity 装机容量
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ public double calcAccuracyRate(List<Double> predictPower, List<Double> actualPower, Double installCapacity) {
|
|
|
+ if (CollUtil.isEmpty(predictPower) || CollUtil.isEmpty(actualPower) || installCapacity == null) return 0;
|
|
|
+ int n = predictPower.size();
|
|
|
+ if (n != actualPower.size()) return 0;
|
|
|
+ double totalError = 0.0;
|
|
|
+ int validPoints = 0;
|
|
|
+ for (int i = 0; i < n; i++) {
|
|
|
+ double errorPercentage = 0.0;
|
|
|
+ if (Math.abs(predictPower.get(i) - actualPower.get(i)) <= 0.03 * installCapacity) {
|
|
|
+ // 该点不计入误差计算
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ errorPercentage = Math.abs(predictPower.get(i) - actualPower.get(i)) / installCapacity * 100;
|
|
|
+ totalError += errorPercentage;
|
|
|
+ validPoints++;
|
|
|
+ }
|
|
|
+ if (validPoints == 0) {
|
|
|
+ return 100.0; // 所有点均在3%以内,准确率为100%
|
|
|
+ } else {
|
|
|
+ return 100 - totalError / validPoints;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|