|
@@ -37,6 +37,7 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
+ private final String format = "yyyy-MM-dd HH:mm:ss";
|
|
|
@Autowired
|
|
|
ElectricFieldService electricFieldService;
|
|
|
@Autowired
|
|
@@ -53,7 +54,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
ForecastPowerShortTermService forecastPowerShortTermService;
|
|
|
@Autowired
|
|
|
PowerStationStatusDataService powerStationStatusDataService;
|
|
|
- private final String format = "yyyy-MM-dd HH:mm:ss";
|
|
|
+
|
|
|
/**
|
|
|
* 获取超短期预测功率,当数据库中超短期预测记录不足查询所需时,进行本地化计算,用于上报专用
|
|
|
*
|
|
@@ -70,7 +71,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
// 查询预测时间点对应的开机容量
|
|
|
Map<Long, BigDecimal> openCapacityMap = null;
|
|
|
try {
|
|
|
- openCapacityMap = super.queryOpenCapacity(startTime, endTime, electricFieldInfo.getCapacity(), stationCode);
|
|
|
+ openCapacityMap = super.queryOpenCapacity(startTime, endTime, electricFieldInfo.getCapacity(), stationCode);
|
|
|
} catch (BusinessException e) {
|
|
|
log.error(stationCode + "超短期数据生成获取开机容量出错:" + CommonUtil.printStackTraceToString(e));
|
|
|
}
|
|
@@ -176,7 +177,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
PowerStationStatusData realPower = realPowerList.get(0);
|
|
|
// 将实际功率替换到对应的超短期点位上
|
|
|
ForecastPowerUltraShortTermHis d = forecastPowerUltraShortTermHiss.get(replacePoint - 1);
|
|
|
- if (realPower.getRealValue().compareTo(new BigDecimal(0)) >=0) {
|
|
|
+ if (realPower.getRealValue().compareTo(new BigDecimal(0)) >= 0) {
|
|
|
d.setAbleValue(realPower.getRealValue());
|
|
|
}
|
|
|
}
|
|
@@ -219,22 +220,22 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
// 根据场站类型执行相应超短期预测
|
|
|
try {
|
|
|
// 获取查询时间,从当前时间所处时间点标记时间开始查询,截至到96个时间点对应的标记时间
|
|
|
- String cdqUpMin = super.getSysParameter("CDQ_UP_MIN", "0",stationCode);
|
|
|
+ String cdqUpMin = super.getSysParameter("CDQ_UP_MIN", "0", stationCode);
|
|
|
Long calTime = DateMomentUtil.getMomentTime(System.currentTimeMillis() + Integer.parseInt(cdqUpMin) * 1000 * 60, 1, 15 * 60 * 1000L);
|
|
|
Long startTime = calTime + 15 * 1000 * 60L;
|
|
|
- String llcdq_point = sysParameterService.getSysParameter("FILE_LLCDQ_POINT", "16",stationCode);
|
|
|
+ String llcdq_point = sysParameterService.getSysParameter("FILE_LLCDQ_POINT", "16", stationCode);
|
|
|
Integer forecastPoints = Integer.parseInt(llcdq_point);
|
|
|
Integer forecastMinutes = forecastPoints * 15;
|
|
|
// 结束时间增加15分钟为了防止文件先生成,实时表中最后一个时间点没有点位的问题
|
|
|
Long endTime = DateUtils.addMinutes(new Date(startTime), forecastMinutes).getTime() + 1000 * 60 * 15L;
|
|
|
|
|
|
// 查询该时间段内的短期预测功率
|
|
|
- List<ForecastPowerShortTerm> forecastPowerShortTermList = this.forecastPowerShortTermRepository.findByForecastTimeBetweenAndStationCode(startTime, endTime,stationCode);
|
|
|
+ List<ForecastPowerShortTerm> forecastPowerShortTermList = this.forecastPowerShortTermRepository.findByForecastTimeBetweenAndStationCode(startTime, endTime, stationCode);
|
|
|
Map<Long, List<ForecastPowerShortTerm>> forecastPowerShortTermsMap =
|
|
|
forecastPowerShortTermList.stream().collect(Collectors.groupingBy(ForecastPowerShortTerm::getForecastTime));
|
|
|
Map<Long, BigDecimal> openCapacityMap = null;
|
|
|
try {
|
|
|
- openCapacityMap = super.queryOpenCapacity(startTime, endTime, electricField.getCapacity(),stationCode);
|
|
|
+ openCapacityMap = super.queryOpenCapacity(startTime, endTime, electricField.getCapacity(), stationCode);
|
|
|
} catch (BusinessException e) {
|
|
|
log.error("预测数据生成获取开机容量出错:" + CommonUtil.printStackTraceToString(e));
|
|
|
}
|
|
@@ -247,7 +248,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
if (ElectricFieldTypeEnum.E1.compareTo(electricField.getElectricFieldTypeEnum()) == 0) {
|
|
|
forecastPowerShortTerms = forecastPowerShortTermService.generateSolarPowerShortTerm(tempTime, openCapacityMap.get(tempTime), electricField);
|
|
|
} else {
|
|
|
- forecastPowerShortTerms = forecastPowerShortTermService.generateWindPowerShortTerm(tempTime, openCapacityMap.get(tempTime),stationCode);
|
|
|
+ forecastPowerShortTerms = forecastPowerShortTermService.generateWindPowerShortTerm(tempTime, openCapacityMap.get(tempTime), stationCode);
|
|
|
}
|
|
|
addForecastPowerShortTermList.add(forecastPowerShortTerms);
|
|
|
}
|
|
@@ -262,10 +263,10 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
|
|
|
if (ElectricFieldTypeEnum.E1.compareTo(electricField.getElectricFieldTypeEnum()) == 0) {
|
|
|
// 光伏电站
|
|
|
- this.executeForecastForlight(forecastPowerShortTermList, electricField.getCapacity(),stationCode);
|
|
|
+ this.executeForecastForlight(forecastPowerShortTermList, electricField.getCapacity(), stationCode);
|
|
|
} else if (ElectricFieldTypeEnum.E2.compareTo(electricField.getElectricFieldTypeEnum()) == 0) {
|
|
|
// 风力电场
|
|
|
- this.executeForecastForWind(forecastPowerShortTermList, electricField.getCapacity(),stationCode);
|
|
|
+ this.executeForecastForWind(forecastPowerShortTermList, electricField.getCapacity(), stationCode);
|
|
|
} else {
|
|
|
log.error("场站类型非法!");
|
|
|
}
|
|
@@ -295,7 +296,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
Date currentTime = new Date(System.currentTimeMillis());
|
|
|
Date startTime = DateUtils.addMinutes(currentTime, -10);
|
|
|
Date endTime = DateUtils.addMinutes(currentTime, 1);
|
|
|
- List<PowerStationStatusData> powerStationStatusDataList = this.powerStationStatusDataRepository.findByTimeBetweenAndStationCode(startTime, endTime,stationCode);
|
|
|
+ List<PowerStationStatusData> powerStationStatusDataList = this.powerStationStatusDataRepository.findByTimeBetweenAndStationCode(startTime, endTime, stationCode);
|
|
|
List<PowerStationStatusData> filterList = powerStationStatusDataList.stream().filter(t -> t.getAbleValue().compareTo(new BigDecimal("-1")) > 0).collect(Collectors.toList());
|
|
|
String coe = super.getSysParameter("CDQ_COE", "1.05", stationCode);
|
|
|
|
|
@@ -305,7 +306,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
} catch (Exception e) {
|
|
|
log.error("获取当前时刻错误", e);
|
|
|
}
|
|
|
- String llcdq_point = sysParameterService.getSysParameter("FILE_LLCDQ_POINT", "16",stationCode);
|
|
|
+ String llcdq_point = sysParameterService.getSysParameter("FILE_LLCDQ_POINT", "16", stationCode);
|
|
|
Integer forecastPoints = Integer.parseInt(llcdq_point);
|
|
|
if (filterList.size() > 0) {
|
|
|
// 获取当前时刻对应的短期
|
|
@@ -313,11 +314,10 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
BigDecimal currentForecastPowerValue = BigDecimal.ZERO;
|
|
|
try {
|
|
|
Long currentMoment = DateMomentUtil.getMomentTime(currentTime.getTime(), 1, 15 * 60 * 1000L);
|
|
|
- currentForecastPowerShortTermList = this.forecastPowerShortTermRepository.findByForecastTimeBetweenAndStationCode(currentMoment, currentMoment,stationCode);
|
|
|
- if (currentForecastPowerShortTermList.size()<=0){
|
|
|
+ currentForecastPowerShortTermList = this.forecastPowerShortTermRepository.findByForecastTimeBetweenAndStationCode(currentMoment, currentMoment, stationCode);
|
|
|
+ if (currentForecastPowerShortTermList.size() <= 0) {
|
|
|
currentForecastPowerValue = currentForecastPowerShortTermList.get(0).getFpValue();
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
// 当前时间没有对应的短期,用实际功率最近的一个替换
|
|
|
filterList.sort(Comparator.comparing(PowerStationStatusData::getTime).reversed());
|
|
|
currentForecastPowerValue = filterList.get(0).getAbleValue();
|
|
@@ -373,7 +373,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
forecastPowerUltraShortTermList.add(forecastPowerUltraShortTerm);
|
|
|
}
|
|
|
} else {
|
|
|
- log.info(stationCode+"库中没有可用,本次可用计算数据采用短期*系数的方式生成数据");
|
|
|
+ log.info(stationCode + "库中没有可用,本次可用计算数据采用短期*系数的方式生成数据");
|
|
|
|
|
|
// 短期乘以系数
|
|
|
for (int i = 0; i < forecastPoints; i++) {
|
|
@@ -422,7 +422,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
if (startTime % timeStep != 0) {
|
|
|
startTime = startTime - (startTime % timeStep) + timeStep;
|
|
|
}
|
|
|
- if ( list.size() > 0) {
|
|
|
+ if (list.size() > 0) {
|
|
|
for (long i = startTime; i < endTime; i = i + timeStep) {
|
|
|
long finalI = i;
|
|
|
List<ForecastPowerUltraShortTermHis> filterList = list.stream().filter(t -> t.getForecastTime() == finalI).collect(Collectors.toList());
|
|
@@ -483,7 +483,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
realPowerMap.put("value" + p, ableDatas);
|
|
|
}
|
|
|
|
|
|
- Map<String, Object> map = powerStationStatusDataService.findByTimeBetweenForContrast(new Date(startTime), new Date(endTime), 900000l);
|
|
|
+ Map<String, Object> map = powerStationStatusDataService.findByTimeBetweenForContrast(new Date(startTime), new Date(endTime), 900000l, stationCode);
|
|
|
|
|
|
ElectricField electricField = electricFieldService.getSingleStation(stationCode);
|
|
|
map.put("value", realPowerMap);
|