|
@@ -0,0 +1,397 @@
|
|
|
+package com.jiayue.ipfcst.console.service;
|
|
|
+
|
|
|
+import com.jiayue.ipfcst.common.core.exception.BusinessException;
|
|
|
+import com.jiayue.ipfcst.common.core.util.CommonUtil;
|
|
|
+import com.jiayue.ipfcst.common.core.util.DateMomentUtil;
|
|
|
+import com.jiayue.ipfcst.common.core.util.DateTimeUtil;
|
|
|
+import com.jiayue.ipfcst.common.data.constant.enums.ElectricFieldTypeEnum;
|
|
|
+import com.jiayue.ipfcst.common.data.constant.enums.PredictionModelEnum;
|
|
|
+import com.jiayue.ipfcst.common.data.entity.*;
|
|
|
+import com.jiayue.ipfcst.common.data.repository.ForecastPowerShortTermRepository;
|
|
|
+import com.jiayue.ipfcst.common.data.repository.ForecastPowerUltraShortTermHisRepository;
|
|
|
+import com.jiayue.ipfcst.common.data.repository.ForecastPowerUltraShortTermRepository;
|
|
|
+import com.jiayue.ipfcst.common.data.repository.PowerStationStatusDataRepository;
|
|
|
+import com.jiayue.ipfcst.common.data.service.BaseService;
|
|
|
+import com.sun.istack.internal.NotNull;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.time.DateFormatUtils;
|
|
|
+import org.apache.commons.lang.time.DateUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 超短期功率预测业务
|
|
|
+ *
|
|
|
+ * @author xsl
|
|
|
+ * @version 3.0
|
|
|
+ * @since 2020/4/22 18:24
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class ForecastPowerUltraShortTermService extends BaseService {
|
|
|
+ @Autowired
|
|
|
+ ElectricFieldService electricFieldService;
|
|
|
+ @Autowired
|
|
|
+ ForecastPowerShortTermRepository forecastPowerShortTermRepository;
|
|
|
+ @Autowired
|
|
|
+ SysParameterService sysParameterService;
|
|
|
+ @Autowired
|
|
|
+ PowerStationStatusDataRepository powerStationStatusDataRepository;
|
|
|
+ @Autowired
|
|
|
+ ForecastPowerUltraShortTermRepository forecastPowerUltraShortTermRepository;
|
|
|
+ @Autowired
|
|
|
+ ForecastPowerUltraShortTermHisRepository forecastPowerUltraShortTermHisRepository;
|
|
|
+ @Autowired
|
|
|
+ ForecastPowerShortTermService forecastPowerShortTermService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成超短期预测功率,自动更新覆盖预测功率
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ */
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED)
|
|
|
+ public void buildForecastPowerUltraShortTerm(@NotNull final Long startTime, @NotNull final Long endTime,String stationCode) {
|
|
|
+ this.getForecastPowerUltraShortTerm(startTime, endTime,stationCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取超短期预测功率,当数据库中超短期预测记录不足查询所需时,进行本地化计算,用于上报专用
|
|
|
+ *
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @return 预测功率结果集
|
|
|
+ */
|
|
|
+ @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"));
|
|
|
+ // 查询场站信息
|
|
|
+ ElectricField electricFieldInfo = electricFieldService.getSingleStation(stationCode);
|
|
|
+ // 查询预测时间点对应的开机容量
|
|
|
+ Map<Long, BigDecimal> openCapacityMap = null;
|
|
|
+ try {
|
|
|
+ openCapacityMap = super.queryOpenCapacity(startTime, endTime, electricFieldInfo.getCapacity(),stationCode);
|
|
|
+ } catch (BusinessException 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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){
|
|
|
+ forecastPowerUltraShortTermList.add(f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Long momentTime = 15 * 60 * 1000L; // 15分钟一个时刻
|
|
|
+ Integer moments = Math.toIntExact((endTime - startTime) / momentTime + 1);
|
|
|
+ log.info(stationCode+"获取所需记录数:" + moments);
|
|
|
+
|
|
|
+ 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());
|
|
|
+ BigDecimal tempValue;
|
|
|
+ if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
+ if (DateTimeUtil.checkInSunriseAndSunset(startTime, electricFieldInfo.getLongitude().doubleValue(), electricFieldInfo.getLatitude().doubleValue())) {
|
|
|
+ tempValue = new BigDecimal(CommonUtil.getRandom(1, 70) / 100.0d);
|
|
|
+ } else {
|
|
|
+ // 日升日落
|
|
|
+ tempValue = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tempValue = new BigDecimal(CommonUtil.getRandom(1, 70) / 100.0d);
|
|
|
+ }
|
|
|
+ tempValue = tempValue.multiply(electricFieldInfo.getCapacity()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ ForecastPowerUltraShortTerm forecastPowerUltraShortTerm = new ForecastPowerUltraShortTerm();
|
|
|
+ forecastPowerUltraShortTerm.setGenDate(new Date(monentTime));
|
|
|
+ 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.setStationCode(stationCode);
|
|
|
+ // 保存超短期实时预测记录
|
|
|
+ this.forecastPowerUltraShortTermRepository.save(forecastPowerUltraShortTerm);
|
|
|
+ forecastPowerUltraShortTermList.add(forecastPowerUltraShortTerm);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info(stationCode+"生成超短期实时预测功率记录数:" + forecastPowerUltraShortTermList.size());
|
|
|
+ // 按预测时刻升序
|
|
|
+ forecastPowerUltraShortTermList.sort(Comparator.comparing(ForecastPowerUltraShortTerm::getForecastTime));
|
|
|
+
|
|
|
+ // 处理超短期历史记录
|
|
|
+ List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermHiss = new ArrayList<>();
|
|
|
+ ForecastPowerUltraShortTermHis forecastPowerUltraShortTermHis;
|
|
|
+ int n = 1;
|
|
|
+ // 生成超短期历史数据
|
|
|
+ BigDecimal openCapacity;
|
|
|
+ //生成数据
|
|
|
+ for (ForecastPowerUltraShortTerm forecastPowerUltraShortTerm : forecastPowerUltraShortTermList) {
|
|
|
+ forecastPowerUltraShortTermHis = new ForecastPowerUltraShortTermHis();
|
|
|
+ openCapacity = openCapacityMap.get(forecastPowerUltraShortTerm.getForecastTime());
|
|
|
+ forecastPowerUltraShortTermHis.setForecastTime(forecastPowerUltraShortTerm.getForecastTime());
|
|
|
+ forecastPowerUltraShortTermHis.setSuCapacity(openCapacity);
|
|
|
+ forecastPowerUltraShortTermHis.setCapacity(electricFieldInfo.getCapacity());
|
|
|
+ forecastPowerUltraShortTermHis.setForecastHowLongAgo(n++);
|
|
|
+ forecastPowerUltraShortTermHis.setTheoryValue(forecastPowerUltraShortTerm.getFpValue());
|
|
|
+ // 预测可用功率=预测*(开机容量/装机容量)
|
|
|
+ BigDecimal fpValue = forecastPowerUltraShortTerm.getFpValue().multiply(openCapacity)
|
|
|
+ .divide(electricFieldInfo.getCapacity(), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ forecastPowerUltraShortTermHis.setAbleValue(fpValue);
|
|
|
+ forecastPowerUltraShortTermHis.setPredictionModelEnum(forecastPowerUltraShortTerm.getPredictionModelEnum());
|
|
|
+ forecastPowerUltraShortTermHis.setDifferenceValue(forecastPowerUltraShortTerm.getDifferenceValue());
|
|
|
+ forecastPowerUltraShortTermHis.setCoefficientValue(forecastPowerUltraShortTerm.getCoefficientValue());
|
|
|
+ forecastPowerUltraShortTermHis.setGenDate(new Date(monentTime));
|
|
|
+ forecastPowerUltraShortTermHis.setStationCode(stationCode);
|
|
|
+ forecastPowerUltraShortTermHiss.add(forecastPowerUltraShortTermHis);
|
|
|
+ }
|
|
|
+// 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);
|
|
|
+ replacePoint = Integer.valueOf(realpower_replace_cdq);
|
|
|
+ if (replacePoint <= forecastPowerUltraShortTermHiss.size() && replacePoint > 0) {
|
|
|
+ Long pre5Time = 0l;
|
|
|
+ Date systemDate = new Date();
|
|
|
+ try {
|
|
|
+ // 获取前5分钟时刻
|
|
|
+ pre5Time = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
+ } catch (Exception 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);
|
|
|
+ if (realPowerList.size() > 0) {
|
|
|
+ // 按时间降序排列
|
|
|
+ realPowerList.sort(Comparator.comparing(PowerStationStatusData::getTime).reversed());
|
|
|
+ // 获取最后一条最新的实际功率
|
|
|
+ PowerStationStatusData realPower = realPowerList.get(0);
|
|
|
+ // 将实际功率替换到对应的超短期点位上
|
|
|
+ ForecastPowerUltraShortTermHis d = forecastPowerUltraShortTermHiss.get(replacePoint - 1);
|
|
|
+ if (realPower.getRealValue().compareTo(new BigDecimal(0)) != -1) {
|
|
|
+ d.setAbleValue(realPower.getRealValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String lowerPredictionLimit = super.getSysParameter("LowerPredictionLimit", "0",stationCode);
|
|
|
+ BigDecimal lpl = new BigDecimal(lowerPredictionLimit);
|
|
|
+
|
|
|
+ forecastPowerUltraShortTermHiss.forEach(s->{
|
|
|
+ if(s.getAbleValue().compareTo(lpl)==-1){
|
|
|
+ s.setAbleValue(lpl);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 删除当前时刻标记时间生成的超短期历史记录
|
|
|
+ this.forecastPowerUltraShortTermHisRepository.deleteNowMoment(startTime, endTime, new Date(monentTime),stationCode);
|
|
|
+ // 保存超短期历史记录
|
|
|
+ this.forecastPowerUltraShortTermHisRepository.saveAll(forecastPowerUltraShortTermHiss);
|
|
|
+ return forecastPowerUltraShortTermHiss;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 执行超短期预测
|
|
|
+ */
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
|
|
|
+ public void executeForecast() {
|
|
|
+ // 获取多场站
|
|
|
+ List<ElectricField> electricFieldList = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ electricFieldList = super.getMultipleStation();
|
|
|
+ } catch (BusinessException e) {
|
|
|
+ log.error("生成超短期实时获取多场站失败",e);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (electricFieldList.isEmpty()){
|
|
|
+ log.error("没有找到场站,不能执行超短期实时数据生成");
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ 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;
|
|
|
+ // 查询该时间段内的短期预测功率
|
|
|
+ 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);
|
|
|
+ } catch (BusinessException e) {
|
|
|
+ log.error("预测数据生成获取开机容量出错:" + CommonUtil.printStackTraceToString(e));
|
|
|
+ }
|
|
|
+ List<ForecastPowerShortTerm> addForecastPowerShortTermList = new ArrayList<>();
|
|
|
+ // 判断短期数据是否缺点
|
|
|
+ for (Long tempTime = startTime; tempTime <= endTime; tempTime = tempTime + 15 * 60 * 1000L) {
|
|
|
+ if (forecastPowerShortTermsMap.get(tempTime) == null) {
|
|
|
+ // 缺失时间点
|
|
|
+ ForecastPowerShortTerm forecastPowerShortTerms = null;
|
|
|
+ if (ElectricFieldTypeEnum.E1.compareTo(electricField.getElectricFieldTypeEnum()) == 0) {
|
|
|
+ forecastPowerShortTerms = forecastPowerShortTermService.generateSolarPowerShortTerm(tempTime, openCapacityMap.get(tempTime), electricField);
|
|
|
+ } else {
|
|
|
+ forecastPowerShortTerms = forecastPowerShortTermService.generateWindPowerShortTerm(tempTime, openCapacityMap.get(tempTime),stationCode);
|
|
|
+ }
|
|
|
+ addForecastPowerShortTermList.add(forecastPowerShortTerms);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!addForecastPowerShortTermList.isEmpty()) {
|
|
|
+ // 保存短期预测
|
|
|
+ this.forecastPowerShortTermRepository.saveAll(addForecastPowerShortTermList);
|
|
|
+ // 将补齐的预测功率追加到查询预测功率结果集中
|
|
|
+ forecastPowerShortTermList.addAll(addForecastPowerShortTermList);
|
|
|
+ }
|
|
|
+ forecastPowerShortTermList.sort(Comparator.comparing(ForecastPowerShortTerm::getForecastTime));
|
|
|
+
|
|
|
+ if (ElectricFieldTypeEnum.E1.compareTo(electricField.getElectricFieldTypeEnum()) == 0) {
|
|
|
+ // 光伏电站
|
|
|
+ this.executeForecastForlight(forecastPowerShortTermList, electricField.getCapacity(),stationCode);
|
|
|
+ } else if (ElectricFieldTypeEnum.E2.compareTo(electricField.getElectricFieldTypeEnum()) == 0) {
|
|
|
+ // 风力电场
|
|
|
+ this.executeForecastForWind(forecastPowerShortTermList, electricField.getCapacity(),stationCode);
|
|
|
+ } else {
|
|
|
+ log.error("场站类型非法!");
|
|
|
+ }
|
|
|
+ } catch (BusinessException e) {
|
|
|
+ log.error("获取场站信息出错!", e);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("系统运行错误!", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 执行风电场超短期预测
|
|
|
+ *
|
|
|
+ * @param forecastPowerShortTermList 短期预测结果集
|
|
|
+ * @param capacity 装机容量
|
|
|
+ */
|
|
|
+ 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);
|
|
|
+ log.info("参数cdqjsfs值为:" + cdqjsfs + ",超短期计算方式,0为默认乘系数的方式,1为根据可用功率计算的方式。");
|
|
|
+ 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> filterList = powerStationStatusDataList.stream().filter(t -> t.getAbleValue().compareTo(new BigDecimal("-1")) == 1).collect(Collectors.toList());
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ if (filterList.size() > 0) {
|
|
|
+ BigDecimal sumAbleValue = filterList.stream().map(PowerStationStatusData::getAbleValue)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal averageAbleValue = sumAbleValue.divide(new BigDecimal(filterList.size()), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //可用-短期差值
|
|
|
+ BigDecimal deviationValue = averageAbleValue.subtract(currentForecastPowerShortTerm.getFpValue());
|
|
|
+ for (int i = 1; i < forecastPowerShortTermList.size(); i++) {
|
|
|
+ forecastPowerUltraShortTerm = new ForecastPowerUltraShortTerm();
|
|
|
+ forecastPowerUltraShortTerm.setForecastTime(forecastPowerShortTermList.get(i).getForecastTime());
|
|
|
+ forecastPowerUltraShortTerm.setGenDate(new Date(monentTime));
|
|
|
+ //短期
|
|
|
+ stPower = forecastPowerShortTermList.get(i).getFpValue();
|
|
|
+ //短期*系数
|
|
|
+ ustPowers = stPower.multiply(new BigDecimal(coe)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ // 如果短期预测小于等于0,则超短期为0
|
|
|
+ if (stPower.doubleValue() <= 0) {
|
|
|
+ forecastPowerUltraShortTerm.setFpValue(BigDecimal.ZERO);
|
|
|
+ forecastPowerUltraShortTerm.setDifferenceValue(BigDecimal.ZERO);
|
|
|
+ forecastPowerUltraShortTerm.setCoefficientValue(BigDecimal.ZERO);
|
|
|
+ forecastPowerUltraShortTerm.setPredictionModelEnum(PredictionModelEnum.E4);
|
|
|
+ } else {
|
|
|
+ BigDecimal xzjdq = deviationValue.add(stPower).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ String cdqjsfsZbxz = electricFieldService.getSysParameter("cdqjsfsZbxz", "0.4",stationCode);
|
|
|
+ log.debug("参数cdqjsfsZbxz值为:" + cdqjsfsZbxz + ",超短期计算方式,可用和短期的差值加短期占比。");
|
|
|
+ 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()) {
|
|
|
+ // 如果超短期结果超出装机容量,则超短期结果为装机容量
|
|
|
+ forecastPowerUltraShortTerm.setFpValue(capacity);
|
|
|
+ } else if (ustPower.doubleValue() < 0) {
|
|
|
+ // 如果超短期结果小于0,则超短期结果为0
|
|
|
+ forecastPowerUltraShortTerm.setFpValue(BigDecimal.ZERO);
|
|
|
+ }else{
|
|
|
+ if(cdqjsfs.equals("1")){
|
|
|
+ forecastPowerUltraShortTerm.setFpValue(ustPower);
|
|
|
+ forecastPowerUltraShortTerm.setPredictionModelEnum(PredictionModelEnum.E5);
|
|
|
+ }else{
|
|
|
+ forecastPowerUltraShortTerm.setFpValue(ustPowers);
|
|
|
+ forecastPowerUltraShortTerm.setPredictionModelEnum(PredictionModelEnum.E9);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ forecastPowerUltraShortTerm.setDifferenceValue(ustPower);
|
|
|
+ forecastPowerUltraShortTerm.setCoefficientValue(ustPowers);
|
|
|
+ }
|
|
|
+ forecastPowerUltraShortTerm.setStationCode(stationCode);
|
|
|
+ forecastPowerUltraShortTermList.add(forecastPowerUltraShortTerm);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.info("库中没有可用,本次可用计算数据采用短期*系数的方式生成数据");
|
|
|
+
|
|
|
+ // 短期乘以系数
|
|
|
+ for (int i = 1; i < forecastPowerShortTermList.size(); i++) {
|
|
|
+ stPower = forecastPowerShortTermList.get(i).getFpValue();
|
|
|
+ ustPower = stPower.multiply(new BigDecimal(coe)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ forecastPowerUltraShortTerm = new ForecastPowerUltraShortTerm();
|
|
|
+ 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.setFpValue(ustPower);
|
|
|
+ forecastPowerUltraShortTerm.setGenDate(new Date(monentTime));
|
|
|
+ forecastPowerUltraShortTerm.setStationCode(stationCode);
|
|
|
+ forecastPowerUltraShortTermList.add(forecastPowerUltraShortTerm);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 保存超短期预测结果
|
|
|
+ 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) {
|
|
|
+ // 暂时光超短期预测方法=风超短期预测方法
|
|
|
+ this.executeForecastForWind(forecastPowerShortTermList, capacity,stationCode);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|