|
@@ -22,6 +22,7 @@ import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -57,8 +58,8 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
* @param endTime 结束时间
|
|
|
*/
|
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
|
|
- public void buildForecastPowerUltraShortTerm(@NotNull final Long startTime, @NotNull final Long endTime,String stationCode) {
|
|
|
- this.getForecastPowerUltraShortTerm(startTime, endTime,stationCode);
|
|
|
+ public void buildForecastPowerUltraShortTerm(@NotNull final Long startTime, @NotNull final Long endTime, String stationCode) {
|
|
|
+ this.getForecastPowerUltraShortTerm(startTime, endTime, stationCode);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -71,40 +72,40 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
@SuppressWarnings("WeakerAccess")
|
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
|
|
public List<ForecastPowerUltraShortTermHis> getForecastPowerUltraShortTerm(@NotNull final Long startTime, @NotNull final Long endTime, @NotNull final String stationCode) {
|
|
|
- log.info(stationCode+"开始获取超短期实时预测功率" + DateFormatUtils.format(startTime, "yyyy-MM-dd HH:mm:ss") + " 至 " + DateFormatUtils.format(endTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ log.info(stationCode + "开始获取超短期实时预测功率" + DateFormatUtils.format(startTime, "yyyy-MM-dd HH:mm:ss") + " 至 " + DateFormatUtils.format(endTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
// 查询场站信息
|
|
|
ElectricField electricFieldInfo = electricFieldService.getSingleStation(stationCode);
|
|
|
// 查询预测时间点对应的开机容量
|
|
|
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));
|
|
|
+ log.error(stationCode + "超短期数据生成获取开机容量出错:" + CommonUtil.printStackTraceToString(e));
|
|
|
}
|
|
|
Long monentTime = 0L;
|
|
|
try {
|
|
|
monentTime = DateMomentUtil.getMomentTime(new Date().getTime(), 1, 15 * 60 * 1000L);
|
|
|
} catch (Exception e) {
|
|
|
- log.error(stationCode+"获取当前时刻错误",e);
|
|
|
+ log.error(stationCode + "获取当前时刻错误", e);
|
|
|
}
|
|
|
|
|
|
List<ForecastPowerUltraShortTerm> forecastPowerUltraShortTermList = new ArrayList<>();
|
|
|
- List<ForecastPowerUltraShortTerm> tempList = this.forecastPowerUltraShortTermRepository.findByForecastTimeBetweenAndStationCode(startTime, endTime,stationCode);
|
|
|
- for (ForecastPowerUltraShortTerm f:tempList){
|
|
|
- if (Integer.parseInt(DateFormatUtils.format(f.getForecastTime(),"mm"))%15==0){
|
|
|
+ List<ForecastPowerUltraShortTerm> tempList = this.forecastPowerUltraShortTermRepository.findByForecastTimeBetweenAndStationCode(startTime, endTime, stationCode);
|
|
|
+ for (ForecastPowerUltraShortTerm f : tempList) {
|
|
|
+ if (Integer.parseInt(DateFormatUtils.format(f.getForecastTime(), "mm")) % 15 == 0) {
|
|
|
forecastPowerUltraShortTermList.add(f);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Long momentTime = 15 * 60 * 1000L; // 15分钟一个时刻
|
|
|
Integer moments = Math.toIntExact((endTime - startTime) / momentTime + 1);
|
|
|
- log.info(stationCode+"所需时间moments个数:"+moments);
|
|
|
- log.info(stationCode+"获取所需记录数:" + forecastPowerUltraShortTermList.size());
|
|
|
+ log.info(stationCode + "所需时间moments个数:" + moments);
|
|
|
+ log.info(stationCode + "获取所需记录数:" + forecastPowerUltraShortTermList.size());
|
|
|
if (moments > forecastPowerUltraShortTermList.size()) {
|
|
|
Map<Long, List<ForecastPowerUltraShortTerm>> forecastPowerShortTermsMap = forecastPowerUltraShortTermList.stream().collect(Collectors.groupingBy(ForecastPowerUltraShortTerm::getForecastTime));
|
|
|
for (Long tempTime = startTime; tempTime <= endTime; tempTime = tempTime + momentTime) {
|
|
|
if (forecastPowerShortTermsMap.get(tempTime) == null) {
|
|
|
- log.info(stationCode+"文件超短期缺点:"+tempTime+" forecastPowerShortTermsMap里个数:"+forecastPowerShortTermsMap.size());
|
|
|
+ log.info(stationCode + "文件超短期缺点:" + tempTime + " forecastPowerShortTermsMap里个数:" + forecastPowerShortTermsMap.size());
|
|
|
BigDecimal tempValue;
|
|
|
if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
if (DateTimeUtil.checkInSunriseAndSunset(startTime, electricFieldInfo.getLongitude().doubleValue(), electricFieldInfo.getLatitude().doubleValue())) {
|
|
@@ -122,8 +123,8 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
forecastPowerUltraShortTerm.setForecastTime(tempTime);
|
|
|
forecastPowerUltraShortTerm.setFpValue(tempValue);
|
|
|
forecastPowerUltraShortTerm.setPredictionModelEnum(PredictionModelEnum.E4);
|
|
|
- forecastPowerUltraShortTerm.setCoefficientValue(new BigDecimal(-0.99).setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
- forecastPowerUltraShortTerm.setDifferenceValue(new BigDecimal(-0.99).setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
+ forecastPowerUltraShortTerm.setCoefficientValue(new BigDecimal(-0.99).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ forecastPowerUltraShortTerm.setDifferenceValue(new BigDecimal(-0.99).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
forecastPowerUltraShortTerm.setStationCode(stationCode);
|
|
|
// 保存超短期实时预测记录
|
|
|
this.forecastPowerUltraShortTermRepository.save(forecastPowerUltraShortTerm);
|
|
@@ -131,7 +132,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- log.info(stationCode+"生成超短期实时预测功率记录数:" + forecastPowerUltraShortTermList.size());
|
|
|
+ log.info(stationCode + "生成超短期实时预测功率记录数:" + forecastPowerUltraShortTermList.size());
|
|
|
// 按预测时刻升序
|
|
|
forecastPowerUltraShortTermList.sort(Comparator.comparing(ForecastPowerUltraShortTerm::getForecastTime));
|
|
|
|
|
@@ -164,7 +165,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
// List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermHiss = forecastPowerUltraShortTermHiss1.stream().filter(t -> t.getForecastHowLongAgo() <=16).collect(Collectors.toList());
|
|
|
// 获取实际功率替换超短期点位参数
|
|
|
Integer replacePoint = 0;
|
|
|
- String realpower_replace_cdq = sysParameterService.getSysParameter("realpower_replace_cdq", "0",stationCode);
|
|
|
+ String realpower_replace_cdq = sysParameterService.getSysParameter("realpower_replace_cdq", "0", stationCode);
|
|
|
replacePoint = Integer.valueOf(realpower_replace_cdq);
|
|
|
if (replacePoint <= forecastPowerUltraShortTermHiss.size() && replacePoint > 0) {
|
|
|
Long pre5Time = 0l;
|
|
@@ -173,10 +174,10 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
// 获取前5分钟时刻
|
|
|
pre5Time = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
} catch (Exception e) {
|
|
|
- log.error(stationCode+"超短期数据用实际功率替换生成时刻步长错误", e);
|
|
|
+ log.error(stationCode + "超短期数据用实际功率替换生成时刻步长错误", e);
|
|
|
pre5Time = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
}
|
|
|
- List<PowerStationStatusData> realPowerList = powerStationStatusDataRepository.findByTimeBetweenAndStationCode(new Date(pre5Time), new Date(pre5Time + 5 * 60 * 1000 - 1000),stationCode);
|
|
|
+ List<PowerStationStatusData> realPowerList = powerStationStatusDataRepository.findByTimeBetweenAndStationCode(new Date(pre5Time), new Date(pre5Time + 5 * 60 * 1000 - 1000), stationCode);
|
|
|
if (realPowerList.size() > 0) {
|
|
|
// 按时间降序排列
|
|
|
realPowerList.sort(Comparator.comparing(PowerStationStatusData::getTime).reversed());
|
|
@@ -190,17 +191,17 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- String lowerPredictionLimit = super.getSysParameter("LowerPredictionLimit", "0",stationCode);
|
|
|
+ String lowerPredictionLimit = super.getSysParameter("LowerPredictionLimit", "0", stationCode);
|
|
|
BigDecimal lpl = new BigDecimal(lowerPredictionLimit);
|
|
|
|
|
|
- forecastPowerUltraShortTermHiss.forEach(s->{
|
|
|
- if(s.getAbleValue().compareTo(lpl)==-1){
|
|
|
+ forecastPowerUltraShortTermHiss.forEach(s -> {
|
|
|
+ if (s.getAbleValue().compareTo(lpl) == -1) {
|
|
|
s.setAbleValue(lpl);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 删除当前时刻标记时间生成的超短期历史记录
|
|
|
- this.forecastPowerUltraShortTermHisRepository.deleteNowMoment(startTime, endTime, new Date(monentTime),stationCode);
|
|
|
+ this.forecastPowerUltraShortTermHisRepository.deleteNowMoment(startTime, endTime, new Date(monentTime), stationCode);
|
|
|
// 保存超短期历史记录
|
|
|
this.forecastPowerUltraShortTermHisRepository.saveAll(forecastPowerUltraShortTermHiss);
|
|
|
return forecastPowerUltraShortTermHiss;
|
|
@@ -216,34 +217,33 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
try {
|
|
|
electricFieldList = super.getMultipleStation();
|
|
|
} catch (BusinessException e) {
|
|
|
- log.error("生成超短期实时获取多场站失败",e);
|
|
|
+ log.error("生成超短期实时获取多场站失败", e);
|
|
|
}
|
|
|
|
|
|
- if (electricFieldList.isEmpty()){
|
|
|
+ if (electricFieldList.isEmpty()) {
|
|
|
log.error("没有找到场站,不能执行超短期实时数据生成");
|
|
|
- }
|
|
|
- else{
|
|
|
- for (ElectricField electricField:electricFieldList){
|
|
|
+ } else {
|
|
|
+ for (ElectricField electricField : electricFieldList) {
|
|
|
String stationCode = electricField.getStationCode();
|
|
|
// 根据场站类型执行相应超短期预测
|
|
|
try {
|
|
|
- String cdqUpMin = super.getSysParameter("CDQ_UP_MIN", "0",stationCode);
|
|
|
- Long currentTime = System.currentTimeMillis()+ Integer.parseInt(cdqUpMin) * 1000 * 60;
|
|
|
- String llcdq_point = sysParameterService.getSysParameter("FILE_LLCDQ_POINT", "16",stationCode);
|
|
|
+ String cdqUpMin = super.getSysParameter("CDQ_UP_MIN", "0", stationCode);
|
|
|
+ Long currentTime = System.currentTimeMillis() + Integer.parseInt(cdqUpMin) * 1000 * 60;
|
|
|
+ String llcdq_point = sysParameterService.getSysParameter("FILE_LLCDQ_POINT", "16", stationCode);
|
|
|
Integer forecastPoints = Integer.parseInt(llcdq_point);
|
|
|
Integer forecastMinutes = forecastPoints * 15;
|
|
|
|
|
|
// 超短期提前N分钟生成文件
|
|
|
Long startTime = DateMomentUtil.getMomentTime(currentTime, 1, 15 * 60 * 1000L);
|
|
|
// 结束时间增加15分钟为了防止文件先生成,实时表中最后一个时间点没有点位的问题
|
|
|
- Long endTime = DateUtils.addMinutes(new Date(startTime), forecastMinutes).getTime()+1000 * 60 * 15L;
|
|
|
+ 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));
|
|
|
}
|
|
@@ -256,7 +256,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);
|
|
|
}
|
|
@@ -271,10 +271,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("场站类型非法!");
|
|
|
}
|
|
@@ -293,28 +293,28 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
* @param forecastPowerShortTermList 短期预测结果集
|
|
|
* @param capacity 装机容量
|
|
|
*/
|
|
|
- private List<ForecastPowerUltraShortTerm> executeForecastForWind(final List<ForecastPowerShortTerm> forecastPowerShortTermList, final BigDecimal capacity,String stationCode) {
|
|
|
+ private List<ForecastPowerUltraShortTerm> executeForecastForWind(final List<ForecastPowerShortTerm> forecastPowerShortTermList, final BigDecimal capacity, String stationCode) {
|
|
|
List<ForecastPowerUltraShortTerm> forecastPowerUltraShortTermList = new ArrayList<>();
|
|
|
ForecastPowerUltraShortTerm forecastPowerUltraShortTerm;
|
|
|
//获取系统参数cdqjsfs,超短期计算方式,0为默认乘系数的方式,1为根据可用功率计算的方式
|
|
|
- String cdqjsfs = electricFieldService.getSysParameter("cdqjsfs", "1",stationCode);
|
|
|
+ String cdqjsfs = electricFieldService.getSysParameter("cdqjsfs", "1", stationCode);
|
|
|
log.info("参数cdqjsfs值为:" + cdqjsfs + ",超短期计算方式,0为默认乘系数的方式,1为根据可用功率计算的方式。");
|
|
|
- BigDecimal stPower, ustPower,ustPowers;
|
|
|
+ BigDecimal stPower, ustPower, ustPowers;
|
|
|
// 判断查询可用功率结果是否为空,如果不为空根据平均可用功率与短期预测结果的偏差值进行计算超短期结果,否则超短期=短期*随机系数
|
|
|
// 查询当前时间点标记时间前10分钟的可用功率
|
|
|
ForecastPowerShortTerm currentForecastPowerShortTerm = forecastPowerShortTermList.get(0);
|
|
|
Date currentTime = new Date(currentForecastPowerShortTerm.getForecastTime());
|
|
|
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")) == 1).collect(Collectors.toList());
|
|
|
- String coe = super.getSysParameter("CDQ_COE", "1.05",stationCode);
|
|
|
+ String coe = super.getSysParameter("CDQ_COE", "1.05", stationCode);
|
|
|
|
|
|
Long monentTime = 0L;
|
|
|
try {
|
|
|
monentTime = DateMomentUtil.getMomentTime(new Date().getTime(), 1, 15 * 60 * 1000L);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("获取当前时刻错误",e);
|
|
|
+ log.error("获取当前时刻错误", e);
|
|
|
}
|
|
|
if (filterList.size() > 0) {
|
|
|
BigDecimal sumAbleValue = filterList.stream().map(PowerStationStatusData::getAbleValue)
|
|
@@ -338,9 +338,9 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
forecastPowerUltraShortTerm.setPredictionModelEnum(PredictionModelEnum.E4);
|
|
|
} else {
|
|
|
BigDecimal xzjdq = deviationValue.add(stPower).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- String cdqjsfsZbxz = electricFieldService.getSysParameter("cdqjsfsZbxz", "0.4",stationCode);
|
|
|
+ String cdqjsfsZbxz = electricFieldService.getSysParameter("cdqjsfsZbxz", "0.4", stationCode);
|
|
|
log.debug("参数cdqjsfsZbxz值为:" + cdqjsfsZbxz + ",超短期计算方式,可用和短期的差值加短期占比。");
|
|
|
- String cdqjsfsZbdq = electricFieldService.getSysParameter("cdqjsfsZbdq", "0.6",stationCode);
|
|
|
+ String cdqjsfsZbdq = electricFieldService.getSysParameter("cdqjsfsZbdq", "0.6", stationCode);
|
|
|
log.debug("参数cdqjsfsZbdq值为:" + cdqjsfsZbdq + ",超短期计算方式,短期占比。");
|
|
|
ustPower = xzjdq.multiply(new BigDecimal(cdqjsfsZbxz)).setScale(2, BigDecimal.ROUND_HALF_UP).add(stPower.multiply(new BigDecimal(cdqjsfsZbdq)).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
if (ustPower.doubleValue() > capacity.doubleValue()) {
|
|
@@ -349,11 +349,11 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
} else if (ustPower.doubleValue() < 0) {
|
|
|
// 如果超短期结果小于0,则超短期结果为0
|
|
|
forecastPowerUltraShortTerm.setFpValue(BigDecimal.ZERO);
|
|
|
- }else{
|
|
|
- if(cdqjsfs.equals("1")){
|
|
|
+ } else {
|
|
|
+ if (cdqjsfs.equals("1")) {
|
|
|
forecastPowerUltraShortTerm.setFpValue(ustPower);
|
|
|
forecastPowerUltraShortTerm.setPredictionModelEnum(PredictionModelEnum.E5);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
forecastPowerUltraShortTerm.setFpValue(ustPowers);
|
|
|
forecastPowerUltraShortTerm.setPredictionModelEnum(PredictionModelEnum.E9);
|
|
|
}
|
|
@@ -375,7 +375,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
forecastPowerUltraShortTerm.setForecastTime(forecastPowerShortTermList.get(i).getForecastTime());
|
|
|
forecastPowerUltraShortTerm.setPredictionModelEnum(PredictionModelEnum.E9);
|
|
|
forecastPowerUltraShortTerm.setCoefficientValue(ustPower);
|
|
|
- forecastPowerUltraShortTerm.setDifferenceValue(new BigDecimal(-0.99).setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
+ forecastPowerUltraShortTerm.setDifferenceValue(new BigDecimal(-0.99).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
forecastPowerUltraShortTerm.setFpValue(ustPower);
|
|
|
forecastPowerUltraShortTerm.setGenDate(new Date(monentTime));
|
|
|
forecastPowerUltraShortTerm.setStationCode(stationCode);
|
|
@@ -383,15 +383,107 @@ public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
// 保存超短期预测结果
|
|
|
- this.forecastPowerUltraShortTermRepository.deleteByForecastTimeBetweenAndStationCode(forecastPowerShortTermList.get(1).getForecastTime(), forecastPowerShortTermList.get(forecastPowerShortTermList.size() - 1).getForecastTime(),stationCode);
|
|
|
+ this.forecastPowerUltraShortTermRepository.deleteByForecastTimeBetweenAndStationCode(forecastPowerShortTermList.get(1).getForecastTime(), forecastPowerShortTermList.get(forecastPowerShortTermList.size() - 1).getForecastTime(), stationCode);
|
|
|
this.forecastPowerUltraShortTermRepository.saveAll(forecastPowerUltraShortTermList);
|
|
|
|
|
|
return forecastPowerUltraShortTermList;
|
|
|
}
|
|
|
|
|
|
- private void executeForecastForlight(final List<ForecastPowerShortTerm> forecastPowerShortTermList, final BigDecimal capacity,String stationCode) {
|
|
|
+ private void executeForecastForlight(final List<ForecastPowerShortTerm> forecastPowerShortTermList, final BigDecimal capacity, String stationCode) {
|
|
|
// 暂时光超短期预测方法=风超短期预测方法
|
|
|
- this.executeForecastForWind(forecastPowerShortTermList, capacity,stationCode);
|
|
|
+ this.executeForecastForWind(forecastPowerShortTermList, capacity, stationCode);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据提前多久,开始结束时间查询历史超短期 yh
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @param ago 提前多久预测
|
|
|
+ * @return 结果集
|
|
|
+ */
|
|
|
+ @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
|
|
|
+ public Map<String, Object> findByForecastTimeBetweenAndForecastHowLongAgoOrderByForecastTime(Long startTime, Long endTime, Integer ago) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ List<ForecastPowerUltraShortTermHis> list = forecastPowerUltraShortTermHisRepository.findByForecastTimeBetweenAndForecastHowLongAgo(startTime, endTime, ago);
|
|
|
+ list.sort(Comparator.comparing(ForecastPowerUltraShortTermHis::getForecastTime));
|
|
|
+ long timeStep = 900000L;
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ List<String> times = new ArrayList<>();
|
|
|
+ List<Float> datas = new ArrayList<>();
|
|
|
+ if (startTime % timeStep != 0) {
|
|
|
+ startTime = startTime - (startTime % timeStep) + timeStep;
|
|
|
+ }
|
|
|
+ if (list != null && 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());
|
|
|
+ if (filterList != null && filterList.size() > 0) {
|
|
|
+ datas.add(filterList.get(0).getAbleValue().floatValue());
|
|
|
+ } else {
|
|
|
+ datas.add(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ times.add(sdf.format(new Date(finalI)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("times", times);
|
|
|
+ map.put("datas", datas);
|
|
|
+
|
|
|
+ return map;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 超短期查询16个点数据 tl
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @return 结果集
|
|
|
+ */
|
|
|
+ @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
|
|
|
+ public Map<String, Object> findByForecastRealTimeUltraShortTerm16(Long startTime, String stationCode) {
|
|
|
+ Long endTime = startTime + 60 * 60 * 1000 * 24;
|
|
|
+// List<Map<String,Object>> valueList16 = new ArrayList<>();
|
|
|
+ //取出16点数据存入集合中
|
|
|
+ Map<String, Object> realPowerMap = new HashMap<>();
|
|
|
+ List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermHisList = forecastPowerUltraShortTermHisRepository.findByForecastTimeBetweenAndStationCode(startTime, endTime, stationCode);
|
|
|
+ for (int p = 1; p <= 16; p++) {
|
|
|
+
|
|
|
+ int finalP = p;
|
|
|
+ List<ForecastPowerUltraShortTermHis> filterList = forecastPowerUltraShortTermHisList.stream().filter(t -> t.getForecastHowLongAgo() == finalP).collect(Collectors.toList());
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ long timeStep = 900000L;
|
|
|
+ if (startTime % timeStep != 0) {
|
|
|
+ startTime = startTime - (startTime % timeStep);
|
|
|
+ }
|
|
|
+ List<Float> ableDatas = new ArrayList<>();
|
|
|
+ List<String> times = new ArrayList<>();
|
|
|
+
|
|
|
+ for (long i = startTime; i < endTime; i = i + 900000L) {
|
|
|
+ long finalI = i;
|
|
|
+ List<ForecastPowerUltraShortTermHis> p1 = filterList.stream().filter(t -> t.getForecastTime() == finalI).collect(Collectors.toList());
|
|
|
+ if (p1 != null && p1.size() > 0) {
|
|
|
+
|
|
|
+ if (p1.get(0).getAbleValue().compareTo(new BigDecimal(-99)) == 0) {
|
|
|
+ ableDatas.add(0f);
|
|
|
+ } else {
|
|
|
+ ableDatas.add(p1.get(0).getAbleValue().floatValue());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ableDatas.add(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ realPowerMap.put("value" + p, ableDatas);
|
|
|
+ }
|
|
|
+
|
|
|
+ //Map<String, Object> map = powerStationStatusDataService.findByTimeBetweenForContrast(new Date(startTime), new Date(endTime), 900000l);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ ElectricField electricField = electricFieldService.getSingleStation(stationCode);
|
|
|
+ map.put("value", realPowerMap);
|
|
|
+ map.put("capacity", electricField.getCapacity());
|
|
|
+ return map;
|
|
|
+
|
|
|
+ }
|
|
|
}
|