|
@@ -30,7 +30,7 @@ public class CalculateForecastPowerShortTermStationImpl implements CalculateInte
|
|
|
private final ForecastPowerShortTermStationService forecastPowerShortTermStationService;
|
|
|
|
|
|
@Override
|
|
|
- public List<AccuracyPassRate> calc(Date startTime,Date endTime,List<PowerStationStatusData> powerStationStatusDataList, List<ElectricField> electricFieldList, List<String> formulaTypes, String province){
|
|
|
+ public List<AccuracyPassRate> calc(Date startTime, Date endTime, List<PowerStationStatusData> powerStationStatusDataList, List<ElectricField> electricFieldList, List<String> formulaTypes, String province) {
|
|
|
|
|
|
List<AccuracyPassRate> accuracyPassRates = new ArrayList<>();
|
|
|
|
|
@@ -56,7 +56,6 @@ public class CalculateForecastPowerShortTermStationImpl implements CalculateInte
|
|
|
accuracyPassRate.setForecastType(ForecastTypeEnum.dq);
|
|
|
accuracyPassRate.setStationCode(stationCode);
|
|
|
accuracyPassRate.setForecastHowLongAgo(ago);
|
|
|
- List<CalculationInfo> calculationInfoList = new ArrayList<>();
|
|
|
|
|
|
// 短期预测功率
|
|
|
Map<Date, List<ForecastPowerShortTermStation>> dateForecastListMap = agoListMap.get(ago).stream().filter(p -> p.getStationCode().equals(stationCode)).collect(Collectors.groupingBy(ForecastPowerShortTermStation::getTime, Collectors.toList()));
|
|
@@ -66,6 +65,7 @@ public class CalculateForecastPowerShortTermStationImpl implements CalculateInte
|
|
|
BigDecimal cap = electricField.getCapacity();
|
|
|
|
|
|
if (formulaTypes.contains("DAY_SHORT_ACCURACY")) {//准确率计算
|
|
|
+ List<CalculationInfo> calculationInfoList = new ArrayList<>();
|
|
|
// 从开始时间,每隔15分钟,一直循环到当前时间
|
|
|
for (long stepTime = startTime.getTime(); stepTime <= endTime.getTime(); stepTime += 900000L) {
|
|
|
Date finalTime = new Date(stepTime);
|
|
@@ -73,21 +73,27 @@ public class CalculateForecastPowerShortTermStationImpl implements CalculateInte
|
|
|
CalculationInfo calculationInfo = new CalculationInfo();
|
|
|
// 如果短期预测功率不为空且站场功率不为空
|
|
|
if (dateForecastListMap.containsKey(finalTime) && datePowerListMap.containsKey(finalTime)) {
|
|
|
- ForecastPowerShortTermStation forecastPowerShortTermStation = dateForecastListMap.get(finalTime).get(0);
|
|
|
- // 短期预测功率
|
|
|
- calculationInfo.setTime(stepTime);
|
|
|
- calculationInfo.setForecastAbleValue(forecastPowerShortTermStation.getFpValue());
|
|
|
- calculationInfo.setForecastTheoryValue(forecastPowerShortTermStation.getFpValue());
|
|
|
- calculationInfo.setForecastCapacity(cap);
|
|
|
- calculationInfo.setForecastSuCapacity(cap);
|
|
|
|
|
|
PowerStationStatusData powerStationStatusData = datePowerListMap.get(finalTime).get(0);
|
|
|
- //实际
|
|
|
- calculationInfo.setCapacity(cap);
|
|
|
- calculationInfo.setOpenCapacity(cap);
|
|
|
- calculationInfo.setAbleValue(powerStationStatusData.getAbleValue());
|
|
|
- calculationInfo.setRealValue(powerStationStatusData.getRealValue());
|
|
|
- calculationInfo.setTheoryValue(powerStationStatusData.getTheoryValue());
|
|
|
+ //限电时不参与考核,抛去
|
|
|
+ if (!powerStationStatusData.getPowerRationing().equals(1)) {
|
|
|
+
|
|
|
+ ForecastPowerShortTermStation forecastPowerShortTermStation = dateForecastListMap.get(finalTime).get(0);
|
|
|
+ // 短期预测功率
|
|
|
+ calculationInfo.setTime(stepTime);
|
|
|
+ calculationInfo.setForecastAbleValue(forecastPowerShortTermStation.getFpValue());
|
|
|
+ calculationInfo.setForecastTheoryValue(forecastPowerShortTermStation.getFpValue());
|
|
|
+ calculationInfo.setForecastCapacity(cap);
|
|
|
+ calculationInfo.setForecastSuCapacity(cap);
|
|
|
+
|
|
|
+
|
|
|
+ //实际
|
|
|
+ calculationInfo.setCapacity(cap);
|
|
|
+ calculationInfo.setOpenCapacity(cap);
|
|
|
+ calculationInfo.setAbleValue(powerStationStatusData.getAbleValue());
|
|
|
+ calculationInfo.setRealValue(powerStationStatusData.getRealValue());
|
|
|
+ calculationInfo.setTheoryValue(powerStationStatusData.getTheoryValue());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 预测功率或实际功率为空的时候,不放入result中
|
|
@@ -99,7 +105,7 @@ public class CalculateForecastPowerShortTermStationImpl implements CalculateInte
|
|
|
|
|
|
if (calculationInfoList == null || calculationInfoList.size() == 0) {
|
|
|
accuracyPassRate.setAccuracy("无可用数据计算");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
// 获取计算基础数据
|
|
|
CalculateRequest calculateRequest = new CalculateRequest();
|
|
|
calculateRequest.setCalculationInfoList(calculationInfoList);
|
|
@@ -123,69 +129,78 @@ public class CalculateForecastPowerShortTermStationImpl implements CalculateInte
|
|
|
}
|
|
|
}
|
|
|
if (formulaTypes.contains("POINT_SHORT_ACCURACY")) {//单点偏差计算
|
|
|
- List<String> results = new ArrayList<>();
|
|
|
+
|
|
|
+ BigDecimal sum = BigDecimal.ZERO;
|
|
|
+ Boolean b = false;
|
|
|
|
|
|
for (long stepTime = startTime.getTime(); stepTime <= endTime.getTime(); stepTime += 900000L) {
|
|
|
Date finalTime = new Date(stepTime);
|
|
|
- // 组装数据
|
|
|
- CalculationInfo calculationInfo = new CalculationInfo();
|
|
|
- // 如果短期预测功率不为空且站场功率不为空
|
|
|
+
|
|
|
if (dateForecastListMap.containsKey(finalTime) && datePowerListMap.containsKey(finalTime)) {
|
|
|
- ForecastPowerShortTermStation forecastPowerShortTermStation = dateForecastListMap.get(finalTime).get(0);
|
|
|
- // 短期预测功率
|
|
|
- calculationInfo.setTime(stepTime);
|
|
|
- calculationInfo.setForecastAbleValue(forecastPowerShortTermStation.getFpValue());
|
|
|
- calculationInfo.setForecastTheoryValue(forecastPowerShortTermStation.getFpValue());
|
|
|
- calculationInfo.setForecastCapacity(cap);
|
|
|
- calculationInfo.setForecastSuCapacity(cap);
|
|
|
|
|
|
+ ForecastPowerShortTermStation forecastPowerShortTermStation = dateForecastListMap.get(finalTime).get(0);
|
|
|
PowerStationStatusData powerStationStatusData = datePowerListMap.get(finalTime).get(0);
|
|
|
- //实际
|
|
|
- calculationInfo.setCapacity(cap);
|
|
|
- calculationInfo.setOpenCapacity(cap);
|
|
|
- calculationInfo.setAbleValue(powerStationStatusData.getAbleValue());
|
|
|
- calculationInfo.setRealValue(powerStationStatusData.getRealValue());
|
|
|
- calculationInfo.setTheoryValue(powerStationStatusData.getTheoryValue());
|
|
|
- }
|
|
|
|
|
|
- // 预测功率或实际功率为空的时候,不放入result中
|
|
|
- if (calculationInfo.getRealValue() != null && calculationInfo.getAbleValue() != null && calculationInfo.getForecastAbleValue() != null) {
|
|
|
- // 获取计算基础数据
|
|
|
- CalculateRequest calculateRequest = new CalculateRequest();
|
|
|
- calculateRequest.setCalculationInfoList(Arrays.asList(calculationInfo));
|
|
|
- calculateRequest.setElectricCapacity(capacity);
|
|
|
- calculateRequest.setProvince(province);
|
|
|
- calculateRequest.setStationCode(stationCode);
|
|
|
- calculateRequest.setFormulaType("POINT_SHORT_ACCURACY");
|
|
|
- calculateRequest.setElectricType(electricType);
|
|
|
- calculateRequest.setSign(electricField.getStationCode());
|
|
|
- calculateRequest.setStationStatus("无");
|
|
|
- calculateRequest.setStationCode(electricField.getStationCode());
|
|
|
- CalculateResult resultMap = SpringUtils.getBean(AccuracyPassRateCalculateService.class).calculate(calculateRequest);
|
|
|
- // 如果计算成功,从结果中获取value
|
|
|
- if (String.valueOf(resultMap.get(CalculateResult.CODE_TAG)).
|
|
|
- equals(CalculateResult.Type.SUCCESS.value())) {
|
|
|
- results.add(String.valueOf(resultMap.get(CalculateResult.DATA_TAG)));
|
|
|
- } else {
|
|
|
- results.add(String.valueOf(resultMap.get(CalculateResult.MSG_TAG)));
|
|
|
- }
|
|
|
|
|
|
+ BigDecimal subtractAbs = powerStationStatusData.getRealValue().subtract(forecastPowerShortTermStation.getFpValue()).abs();
|
|
|
+ BigDecimal value = subtractAbs.divide(electricField.getCapacity(), 4, BigDecimal.ROUND_DOWN);
|
|
|
+ sum = sum.add(value);
|
|
|
+ b = true;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- if (results.isEmpty()) {
|
|
|
- accuracyPassRate.setDeviationSum("无可用数据计算");
|
|
|
+
|
|
|
+ if (b) {
|
|
|
+ accuracyPassRate.setDeviationSum(sum.doubleValue()*100 + "%");
|
|
|
} else {
|
|
|
- double sum = 0d;
|
|
|
- for (String result : results) {
|
|
|
- if (result.indexOf("%") > -1 && result.length() < 7) {
|
|
|
- sum += Double.parseDouble(result.replace("%", ""));
|
|
|
- }
|
|
|
- }
|
|
|
- if (accuracyPassRate.getDeviationSum() == null) {
|
|
|
- accuracyPassRate.setDeviationSum(BigDecimal.valueOf(sum / 100).setScale(2, BigDecimal.ROUND_HALF_UP) + "");
|
|
|
- }
|
|
|
+ accuracyPassRate.setDeviationSum("无可用数据计算");
|
|
|
}
|
|
|
|
|
|
+// Boolean b = false;
|
|
|
+// BigDecimal yibai = BigDecimal.valueOf(100);
|
|
|
+// BigDecimal mkh = electricField.getCapacity().multiply(new BigDecimal(0.03));
|
|
|
+// for (long stepTime = startTime.getTime(); stepTime <= endTime.getTime(); stepTime += 900000L) {
|
|
|
+//
|
|
|
+// Date finalTime = new Date(stepTime);
|
|
|
+//
|
|
|
+// if (dateForecastListMap.containsKey(finalTime) && datePowerListMap.containsKey(finalTime)) {
|
|
|
+// PowerStationStatusData powerStationStatusData = datePowerListMap.get(finalTime).get(0);
|
|
|
+//
|
|
|
+// //限电时不参与考核,抛去
|
|
|
+// if (!powerStationStatusData.getPowerRationing().equals(1)) {
|
|
|
+//
|
|
|
+// ForecastPowerShortTermStation forecastPowerShortTermStation = dateForecastListMap.get(finalTime).get(0);
|
|
|
+//
|
|
|
+// BigDecimal pr = powerStationStatusData.getRealValue();
|
|
|
+// BigDecimal pn = forecastPowerShortTermStation.getFpValue();
|
|
|
+//
|
|
|
+// //预测功率0,实际功率<=容量的3% 不予考核 反之误差为100%
|
|
|
+// if (pn.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+// if (pr.compareTo(mkh) >= 0) {
|
|
|
+// sum.add(yibai);
|
|
|
+// }
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// //实际功率为0,预测功率<=容量的3% 不予考核 反之误差为100%
|
|
|
+// if (pr.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+// if (pn.compareTo(mkh) >= 0) {
|
|
|
+// sum.add(yibai);
|
|
|
+// }
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// BigDecimal subtract = pr.subtract(pn);
|
|
|
+// sum = sum.add(subtract.divide(pn,2,BigDecimal.ROUND_DOWN));
|
|
|
+//
|
|
|
+// b = true;
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
accuracyPassRates.add(accuracyPassRate);
|
|
|
}
|