|
@@ -4,19 +4,26 @@ import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
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.AlarmTypeEnum;
|
|
|
import com.jiayue.ipfcst.common.data.constant.enums.PredictionModelEnum;
|
|
|
import com.jiayue.ipfcst.common.data.entity.*;
|
|
|
import com.jiayue.ipfcst.common.data.repository.*;
|
|
|
import com.jiayue.ipfcst.common.data.service.BaseService;
|
|
|
import com.jiayue.ipfcst.console.service.NwpService;
|
|
|
import com.jiayue.ipfcst.console.service.SysParameterService;
|
|
|
+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.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
@@ -62,6 +69,8 @@ public class ForecastPowerShortTermGeneratorService extends BaseService {
|
|
|
ModifyShorterDataRepository modifyShorterDataRepository;
|
|
|
@Autowired
|
|
|
NwpSpeedModifiedRespository nwpSpeedModifiedRespository;
|
|
|
+ @Autowired
|
|
|
+ NwpHisRepository nwpHisRepository;
|
|
|
|
|
|
//模板风机为key,其它风机id及风速为value
|
|
|
public static Map<String,List<String>> moduleFanMaps = new HashMap<>();
|
|
@@ -82,7 +91,7 @@ public class ForecastPowerShortTermGeneratorService extends BaseService {
|
|
|
//@Scheduled(fixedRate = 1000*60)
|
|
|
// 30 30 5 * * ? 0/1 * * * * ?
|
|
|
// 30 10,25,30 5,17 * * ? 0/1 */2 * * * ?
|
|
|
- // @Scheduled(cron = "0/1 */1 * * * ?")
|
|
|
+ @Scheduled(cron = "0/1 */1 * * * ?")
|
|
|
public void createDqFile() {
|
|
|
log.info("时间 【" + DateTimeUtil.dateToStrLong(new Date()) + "】 马头山短期数据生成开始");
|
|
|
// 用户主目录
|
|
@@ -101,6 +110,8 @@ public class ForecastPowerShortTermGeneratorService extends BaseService {
|
|
|
// forecastPowerShortTermRepository.saveAll(forecastPowerShortTerms);
|
|
|
//6.恶劣天气
|
|
|
yesOrNoStartIcingShutdown(forecastPowerShortTerms, nwpDatas);
|
|
|
+ // 7.短期数据范围
|
|
|
+ yesOrNoDataRange();
|
|
|
log.info("时间 【" + DateTimeUtil.dateToStrLong(new Date()) + "】 马头山短期数据生成完成");
|
|
|
}
|
|
|
/**
|
|
@@ -135,7 +146,9 @@ public class ForecastPowerShortTermGeneratorService extends BaseService {
|
|
|
private List<Nwp> getNwpDatas() {
|
|
|
long startTimes = getMillisecondsSubDay();
|
|
|
long endTimes = startTimes + dayNum * 24 * 60 * 60 * 1000 - 15 * 60 * 1000;
|
|
|
- List<Nwp> nwpData = nwpService.getNwpData(startTimes, endTimes);
|
|
|
+ // long endTimes = DateUtil.beginOfDay(DateUtil.tomorrow()).getTime();
|
|
|
+ // List<Nwp> nwpData = nwpService.getNwpData(startTimes, endTimes);
|
|
|
+ List<Nwp> nwpData = nwpRepository.findByPreTimeBetween(startTimes, endTimes);
|
|
|
List<NwpSpeedModified> nwpSpeedModifieds = nwpSpeedModifiedRespository.findByPreTimeBetween(startTimes, endTimes);
|
|
|
// 用修改后的风速值替换原值
|
|
|
if(nwpSpeedModifieds.size() > 0){
|
|
@@ -191,55 +204,65 @@ public class ForecastPowerShortTermGeneratorService extends BaseService {
|
|
|
//根据风向+风机模板id配置+风速 获取当前风速对应的其它风机应该有的风速list
|
|
|
List<String> fanKeys = removeOverhaulFansMaps.get(fengxiangId + "-" + modleFanId + "-" + speed);
|
|
|
if(null == fanKeys){
|
|
|
- System.out.println(modleFanId);
|
|
|
- }
|
|
|
- for (String fanKey : fanKeys) {
|
|
|
- //切出风机ID查询风机具体配置信息
|
|
|
- FanUnitInfo fanInfo = fanInfoMap.get(fanKey.split("-")[0]);
|
|
|
- //小于满发风速
|
|
|
- if (speed < fanInfo.getFullWindSpeed()) {
|
|
|
- //根据风机曲线点表获取功率值
|
|
|
- totalPower += windTurbinePowerCurveMaps.get(fanInfo.getFanId() + "").get(Convert.toFloat(fanKey.split("-")[1]));
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (speed >= fanInfo.getCutOutSpeed()) {
|
|
|
- //风速大于切出,发电为0
|
|
|
- totalPower += 0;
|
|
|
- continue;
|
|
|
- }
|
|
|
- //大于满发风速
|
|
|
- if (speed >= fanInfo.getFullWindSpeed()) {
|
|
|
- //满发和切出之间的功率值
|
|
|
- Float totalPowerTemp = 0f;
|
|
|
- //在满发和切出之间,看具体机组信息和风速
|
|
|
- for (CutOutSpeedSpecifyInfo cutOutSpeedSpecifyInfo : fanInfo.getCutOutSpeedSpecifyInfos()
|
|
|
- ) {
|
|
|
- //
|
|
|
- if (speed >= cutOutSpeedSpecifyInfo.getLowerWindSpeedLimit()
|
|
|
- && speed < cutOutSpeedSpecifyInfo.getHighWindSpeedLimit()) {
|
|
|
- //当前风速的发电功率
|
|
|
- totalPowerTemp += cutOutSpeedSpecifyInfo.getPowerGeneration();
|
|
|
- }
|
|
|
+ System.out.println(fengxiangId + "-" + modleFanId + "-" + speed);
|
|
|
+ }else {
|
|
|
+ for (String fanKey : fanKeys) {
|
|
|
+ //切出风机ID查询风机具体配置信息
|
|
|
+ FanUnitInfo fanInfo = fanInfoMap.get(fanKey.split("-")[0]);
|
|
|
+ //小于满发风速
|
|
|
+ if (speed < fanInfo.getFullWindSpeed()) {
|
|
|
+ //根据风机曲线点表获取功率值
|
|
|
+ totalPower += windTurbinePowerCurveMaps.get(fanInfo.getFanId() + "").get(Convert.toFloat(fanKey.split("-")[1]));
|
|
|
+ continue;
|
|
|
}
|
|
|
- //满发风速和切出 之间无发电则是在满发状态
|
|
|
- if(totalPowerTemp == 0){
|
|
|
- totalPower += fanInfo.getFanUnitCapacity();
|
|
|
- }else{
|
|
|
- totalPower += totalPowerTemp;
|
|
|
+ if (speed >= fanInfo.getCutOutSpeed()) {
|
|
|
+ //风速大于切出,发电为0
|
|
|
+ totalPower += 0;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //大于满发风速
|
|
|
+ if (speed >= fanInfo.getFullWindSpeed()) {
|
|
|
+ //满发和切出之间的功率值
|
|
|
+ Float totalPowerTemp = 0f;
|
|
|
+ //在满发和切出之间,看具体机组信息和风速
|
|
|
+ for (CutOutSpeedSpecifyInfo cutOutSpeedSpecifyInfo : fanInfo.getCutOutSpeedSpecifyInfos()
|
|
|
+ ) {
|
|
|
+ //
|
|
|
+ if (speed >= cutOutSpeedSpecifyInfo.getLowerWindSpeedLimit()
|
|
|
+ && speed < cutOutSpeedSpecifyInfo.getHighWindSpeedLimit()) {
|
|
|
+ //当前风速的发电功率
|
|
|
+ totalPowerTemp += cutOutSpeedSpecifyInfo.getPowerGeneration();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //满发风速和切出 之间无发电则是在满发状态
|
|
|
+ if(totalPowerTemp == 0){
|
|
|
+ totalPower += fanInfo.getFanUnitCapacity();
|
|
|
+ }else{
|
|
|
+ totalPower += totalPowerTemp;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ ForecastPowerShortTerm forecastPowerShortTerm = new ForecastPowerShortTerm();
|
|
|
+ forecastPowerShortTerm.setForecastTime(nwp.getPreTime());
|
|
|
+ forecastPowerShortTerm.setFpValue(NumberUtil.round(totalPower/1000,2).setScale(2,RoundingMode.HALF_UP));
|
|
|
+ forecastPowerShortTerm.setGenDate(new Date());
|
|
|
+ forecastPowerShortTerm.setPredictionModelEnum(PredictionModelEnum.E1);
|
|
|
+
|
|
|
+ // 计算超装机容量
|
|
|
+ if(forecastPowerShortTerm.getFpValue().compareTo(new BigDecimal(60))> 0 ){
|
|
|
+ forecastPowerShortTerm.setFpValue(BigDecimal.valueOf(random(50, 60)).setScale(2,RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ // // 计算低于15
|
|
|
+ // if(forecastPowerShortTerm.getFpValue().compareTo(new BigDecimal(15)) < 0 ){
|
|
|
+ // forecastPowerShortTerm.setFpValue(BigDecimal.valueOf(random(15, 25)).setScale(2,RoundingMode.HALF_UP));
|
|
|
+ // }
|
|
|
+
|
|
|
+ // dataRange(forecastPowerShortTerm);
|
|
|
+
|
|
|
+ forecastPowerShortTermList.add(forecastPowerShortTerm);
|
|
|
+
|
|
|
}
|
|
|
- ForecastPowerShortTerm forecastPowerShortTerm = new ForecastPowerShortTerm();
|
|
|
- forecastPowerShortTerm.setForecastTime(nwp.getPreTime());
|
|
|
- forecastPowerShortTerm.setFpValue(NumberUtil.round(totalPower/1000,2).setScale(2,RoundingMode.HALF_UP));
|
|
|
- forecastPowerShortTerm.setGenDate(new Date());
|
|
|
- forecastPowerShortTerm.setPredictionModelEnum(PredictionModelEnum.E1);
|
|
|
-
|
|
|
- // 计算超装机容量
|
|
|
- if(forecastPowerShortTerm.getFpValue().compareTo(new BigDecimal(93))> 0 ){
|
|
|
- forecastPowerShortTerm.setFpValue(BigDecimal.valueOf(random()).setScale(2,RoundingMode.HALF_UP));
|
|
|
- }
|
|
|
- forecastPowerShortTermList.add(forecastPowerShortTerm);
|
|
|
+
|
|
|
}
|
|
|
List<ForecastPowerShortTerm> forecastPowerShortTerms = modifyShorterData(forecastPowerShortTermList);
|
|
|
|
|
@@ -426,7 +449,7 @@ public class ForecastPowerShortTermGeneratorService extends BaseService {
|
|
|
* @return
|
|
|
*/
|
|
|
public List<ForecastPowerShortTerm> modifyShorterData(List<ForecastPowerShortTerm> forecastPowerShortTermList){
|
|
|
- List<ModifyShorterData> modifyShorterDataList = modifyShorterDataRepository.findByStartTimeAfter(new Date());
|
|
|
+ List<ModifyShorterData> modifyShorterDataList = modifyShorterDataRepository.findByEndTimeBefore(new Date());
|
|
|
DecimalFormat decimalFormat=new DecimalFormat(".00");
|
|
|
log.info("执行修改短期系数方法开始,系统时间:"+ DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
for(ModifyShorterData m: modifyShorterDataList){
|
|
@@ -437,10 +460,15 @@ public class ForecastPowerShortTermGeneratorService extends BaseService {
|
|
|
if(new Date(f.getForecastTime()).after(startTime) && new Date(f.getForecastTime()).before(endTime)){
|
|
|
f.setFpValue(f.getFpValue().multiply(new BigDecimal(m.getModulus())).setScale(2,RoundingMode.HALF_UP));
|
|
|
}
|
|
|
- // 计算超装机容量设置为92.7
|
|
|
- if(f.getFpValue().compareTo(new BigDecimal(93)) > 0){
|
|
|
- f.setFpValue(new BigDecimal(random()).setScale(2,RoundingMode.HALF_UP));
|
|
|
+ // 计算超装机容量 60
|
|
|
+ if(f.getFpValue().compareTo(new BigDecimal(60)) > 0){
|
|
|
+ f.setFpValue(new BigDecimal(random(50, 60)).setScale(2,RoundingMode.HALF_UP));
|
|
|
}
|
|
|
+ // // 计算小于15
|
|
|
+ // if(f.getFpValue().compareTo(new BigDecimal(15)) < 0){
|
|
|
+ // f.setFpValue(new BigDecimal(random(15, 25)).setScale(2,RoundingMode.HALF_UP));
|
|
|
+ // }
|
|
|
+ // dataRange(f);
|
|
|
}
|
|
|
}
|
|
|
log.info("执行修改短期系数方法结束,系统时间:"+ DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
@@ -504,12 +532,13 @@ public class ForecastPowerShortTermGeneratorService extends BaseService {
|
|
|
* 随机数15到60
|
|
|
* @return
|
|
|
*/
|
|
|
- public Float random(){
|
|
|
+ public Float random(int min, int max){
|
|
|
+ // long random = CommonUtil.getRandom(15, 60);
|
|
|
Random r = new Random();
|
|
|
DecimalFormat df= new DecimalFormat( "0.00");
|
|
|
- float randomFloat = r.nextFloat() * (60 - 15) + 15;
|
|
|
+ float randomFloat = r.nextFloat() * (max - min) + min;
|
|
|
String format = df.format(randomFloat);
|
|
|
- return Float.parseFloat(format);
|
|
|
+ return Float.parseFloat(String.valueOf(format));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -529,68 +558,66 @@ public class ForecastPowerShortTermGeneratorService extends BaseService {
|
|
|
// 停机数据
|
|
|
List<IcingShutdown> icingShutdowns = parkedWindTurbine(nwpDatas);
|
|
|
|
|
|
- for(IcingShutdown icingShutdown: icingShutdowns){
|
|
|
+ if(icingShutdowns.size() > 0 ){
|
|
|
+ for(IcingShutdown icingShutdown: icingShutdowns){
|
|
|
+
|
|
|
+ for(ForecastPowerShortTerm forecastPowerShortTerm: byForecastTimeBetween){
|
|
|
+ // 短期数据在停机数据时间内
|
|
|
+ if(icingShutdown.getStartTime() <= forecastPowerShortTerm.getForecastTime() && forecastPowerShortTerm.getForecastTime() < icingShutdown.getEndTime()){
|
|
|
+ forecastPowerShortTerm.setFpValue(forecastPowerShortTerm.getFpValue().subtract(new BigDecimal(2 * icingShutdown.getShutDownNumber())));
|
|
|
+ }
|
|
|
+ // 如果小于0 则等于0
|
|
|
+ if(forecastPowerShortTerm.getFpValue().compareTo(BigDecimal.ZERO) < 0){
|
|
|
+ forecastPowerShortTerm.setFpValue(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 解冰开机
|
|
|
+ long startTime = icingShutdowns.get(0).getStartTime();
|
|
|
+ List<IcingShutdown> icingShutdowns1 = thawBoot(startTime, endTimes);
|
|
|
+
|
|
|
+ for(IcingShutdown icingShutdown: icingShutdowns1){
|
|
|
+ for(ForecastPowerShortTerm forecastPowerShortTerm: byForecastTimeBetween){
|
|
|
+ // 短期数据在停机数据时间内
|
|
|
+ if(icingShutdown.getStartTime() <= forecastPowerShortTerm.getForecastTime() && forecastPowerShortTerm.getForecastTime() < icingShutdown.getEndTime()){
|
|
|
+ forecastPowerShortTerm.setFpValue(forecastPowerShortTerm.getFpValue().add(new BigDecimal(2 * icingShutdown.getShutDownNumber())));
|
|
|
+ }
|
|
|
+ // 计算超装机容量 60
|
|
|
+ if(forecastPowerShortTerm.getFpValue().compareTo(new BigDecimal(60))> 0 ){
|
|
|
+ forecastPowerShortTerm.setFpValue(BigDecimal.valueOf(random(50,60)).setScale(2,RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ // 读取停机数量
|
|
|
+ int shut_down_number = Integer.parseInt(super.getSysParameter("SHUT_DOWN_NUMBER", "0"));
|
|
|
+
|
|
|
+ long endTime = icingShutdowns.get(icingShutdowns.size() - 1).getEndTime();
|
|
|
+ long startTime1 = icingShutdowns1.get(0).getStartTime();
|
|
|
for(ForecastPowerShortTerm forecastPowerShortTerm: byForecastTimeBetween){
|
|
|
- // 短期数据在停机数据时间内
|
|
|
- if(icingShutdown.getStartTime() <= forecastPowerShortTerm.getForecastTime() && forecastPowerShortTerm.getForecastTime() < icingShutdown.getEndTime()){
|
|
|
- forecastPowerShortTerm.setFpValue(forecastPowerShortTerm.getFpValue().subtract(new BigDecimal(2 * icingShutdown.getShutDownNumber())));
|
|
|
+ if(forecastPowerShortTerm.getForecastTime() >= endTime && forecastPowerShortTerm.getForecastTime() < startTime1){
|
|
|
+ forecastPowerShortTerm.setFpValue(forecastPowerShortTerm.getFpValue().subtract( new BigDecimal(2 * shut_down_number)));
|
|
|
}
|
|
|
// 如果小于0 则等于0
|
|
|
if(forecastPowerShortTerm.getFpValue().compareTo(BigDecimal.ZERO) < 0){
|
|
|
forecastPowerShortTerm.setFpValue(BigDecimal.ZERO);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 读取停机数量
|
|
|
- int shut_down_number = Integer.parseInt(super.getSysParameter("SHUT_DOWN_NUMBER", "0"));
|
|
|
+ // 保存修改后短期数据
|
|
|
+ forecastPowerShortTermRepository.saveAll(byForecastTimeBetween);
|
|
|
|
|
|
- long endTime = icingShutdowns.get(icingShutdowns.size() - 1).getEndTime();
|
|
|
- for(ForecastPowerShortTerm forecastPowerShortTerm: byForecastTimeBetween){
|
|
|
- if(forecastPowerShortTerm.getForecastTime() >= endTime){
|
|
|
- forecastPowerShortTerm.setFpValue(forecastPowerShortTerm.getFpValue().subtract( new BigDecimal(2 * shut_down_number)));
|
|
|
- }
|
|
|
- // 如果小于0 则等于0
|
|
|
- if(forecastPowerShortTerm.getFpValue().compareTo(BigDecimal.ZERO) < 0){
|
|
|
- forecastPowerShortTerm.setFpValue(BigDecimal.ZERO);
|
|
|
- }
|
|
|
}
|
|
|
-
|
|
|
- // 解冰开机
|
|
|
- // long startTime = icingShutdowns.get(0).getStartTime();
|
|
|
- // List<IcingShutdown> icingShutdowns1 = thawBoot(startTime, endTimes);
|
|
|
- //
|
|
|
- // for(IcingShutdown icingShutdown: icingShutdowns1){
|
|
|
- // for(ForecastPowerShortTerm forecastPowerShortTerm: byForecastTimeBetween){
|
|
|
- // // 短期数据在停机数据时间内
|
|
|
- // if(icingShutdown.getStartTime() <= forecastPowerShortTerm.getForecastTime() && forecastPowerShortTerm.getForecastTime() < icingShutdown.getEndTime()){
|
|
|
- // forecastPowerShortTerm.setFpValue(forecastPowerShortTerm.getFpValue().add(new BigDecimal(2 * icingShutdown.getShutDownNumber())));
|
|
|
- // }
|
|
|
- // // 计算超装机容量设置为92.7
|
|
|
- // if(forecastPowerShortTerm.getFpValue().compareTo(new BigDecimal(93))> 0 ){
|
|
|
- // forecastPowerShortTerm.setFpValue(BigDecimal.valueOf(random()).setScale(2,RoundingMode.HALF_UP));
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // 保存修改后短期数据
|
|
|
- forecastPowerShortTermRepository.saveAll(byForecastTimeBetween);
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 结冰停机
|
|
|
*
|
|
|
- * 遍历nwp数据 判断当前nwp是否满足结冰条件,满足则下雪时长加一, 不满足则下雪中断加1 如果中断次数大于一小时 则重新计算下雪时长
|
|
|
- *
|
|
|
- * 到达马头山结冰时间 则把当前nwp时间当作开始时间 加上间隔停机时间当作结束时间 并记录停机数量
|
|
|
- *
|
|
|
- * 将军山同
|
|
|
- *
|
|
|
- *
|
|
|
- * 结冰需要满足的条件是温度低于 和 降水强度大于
|
|
|
+ *判断所有nwp数据
|
|
|
+ * 当前点位nwp满足解冰条件 则记录下来 , 判断当前点位后的nwp是否也满足,直到不满足解冰条件的点位出现,把当前不满足的nwp记录下来 , 一个开始时间结束时间为一个对象 ,
|
|
|
+ * 继续判断之后的nwp ,直到所有nwp判断结束, 把所有对象存成一个集合
|
|
|
*
|
|
|
*
|
|
|
* @param nwpDatas
|
|
@@ -602,76 +629,172 @@ public class ForecastPowerShortTermGeneratorService extends BaseService {
|
|
|
// 结冰降水量阈值
|
|
|
BigDecimal tpr_threshold = new BigDecimal(super.getSysParameter("TPR_THRESHOLD", "1.00"));
|
|
|
// 持续降雪多长时间开始结冰 马头山
|
|
|
- String duration_of_snow_m = super.getSysParameter("DURATION_OF_SNOW_M", "30");
|
|
|
+ Integer duration_of_snow_m = Integer.parseInt(super.getSysParameter("DURATION_OF_SNOW_M", "30"));
|
|
|
// 持续降雪多长时间开始结冰 将军山
|
|
|
- String duration_of_snow_j = super.getSysParameter("DURATION_OF_SNOW_J", "18");
|
|
|
+ Integer duration_of_snow_j = Integer.parseInt(super.getSysParameter("DURATION_OF_SNOW_J", "18"));
|
|
|
// 停机间隔时间 马头山
|
|
|
- String shut_down_number_time_interval_m = super.getSysParameter("SHUT_DOWN_NUMBER_TIME_INTERVAL_M", "60");
|
|
|
+ int shut_down_number_time_interval_m = Integer.parseInt(super.getSysParameter("SHUT_DOWN_NUMBER_TIME_INTERVAL_M", "60"));
|
|
|
// 停机间隔时间 将军山
|
|
|
- String shut_down_number_time_interval_j = super.getSysParameter("SHUT_DOWN_NUMBER_TIME_INTERVAL_J", "60");
|
|
|
+ int shut_down_number_time_interval_j = Integer.parseInt(super.getSysParameter("SHUT_DOWN_NUMBER_TIME_INTERVAL_J", "60"));
|
|
|
// 降雪持续时长
|
|
|
Integer snowHowLong = 0;
|
|
|
- // 降雪中断次数
|
|
|
- Integer snowHowLongCut = 0;
|
|
|
// 返回集合
|
|
|
List<IcingShutdown> icingShutdowns = new ArrayList<>();
|
|
|
|
|
|
- // 停机数量
|
|
|
- int iShutDownNumber = 0;
|
|
|
-
|
|
|
- // 临时对象
|
|
|
- IcingShutdown tempIS = new IcingShutdown();
|
|
|
- IcingShutdown tempISM = new IcingShutdown();
|
|
|
-
|
|
|
log.info("执行结冰停机方法开始,系统时间:"+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
|
|
|
- for(Nwp nwp: nwpDatas){
|
|
|
- // 判断是否结冰
|
|
|
- if(nwp.getT().compareTo(down_the_temperature) < 1 && nwp.getTpr().compareTo(tpr_threshold) > 0){
|
|
|
+ Long cutTime = 0l;
|
|
|
+ int cutCounts = 0;
|
|
|
+ long startTime = 0l;
|
|
|
+ long endTime = 0l;
|
|
|
+ List<IcingShutdown> icingShutdowns1 = new ArrayList<>();
|
|
|
+ for(int i = 0; i < nwpDatas.size(); i++){
|
|
|
+ if(nwpDatas.get(i).getT().compareTo(down_the_temperature) < 1 && nwpDatas.get(i).getTpr().compareTo(tpr_threshold) > 0){
|
|
|
+ if(snowHowLong == 0 ){
|
|
|
+ startTime = nwpDatas.get(i).getPreTime();
|
|
|
+ }
|
|
|
snowHowLong += 1;
|
|
|
- }else{
|
|
|
- snowHowLongCut += 1;
|
|
|
- if(snowHowLongCut > 4){
|
|
|
+ cutCounts = 0;
|
|
|
+ }else {
|
|
|
+ cutTime = nwpDatas.get(i).getPreTime();
|
|
|
+ cutCounts += 1;
|
|
|
+ if(cutCounts == 4){
|
|
|
snowHowLong = 0;
|
|
|
+ endTime = DateUtil.offsetHour(new Date(cutTime),-1).getTime();
|
|
|
+ cutCounts = 0;
|
|
|
}
|
|
|
}
|
|
|
- // 临时对象
|
|
|
- IcingShutdown icingShutdown = new IcingShutdown();
|
|
|
- IcingShutdown icingShutdownM = new IcingShutdown();
|
|
|
- // 到达将军山停机时间
|
|
|
- if(snowHowLong == Integer.parseInt(duration_of_snow_j) * 4){
|
|
|
- iShutDownNumber += 1;
|
|
|
- icingShutdown.setStartTime(nwp.getPreTime());
|
|
|
- icingShutdown.setEndTime(DateUtil.offsetMinute(new Date(nwp.getPreTime()), Integer.parseInt(shut_down_number_time_interval_j)).getTime());
|
|
|
- icingShutdown.setShutDownNumber(1);
|
|
|
- icingShutdowns.add(icingShutdown);
|
|
|
- }
|
|
|
|
|
|
- if(snowHowLong > Integer.parseInt(duration_of_snow_j) * 4){
|
|
|
- iShutDownNumber += 1;
|
|
|
- icingShutdown.setStartTime(tempIS.getEndTime());
|
|
|
- icingShutdown.setEndTime(DateUtil.offsetMinute(new Date(tempIS.getEndTime()), Integer.parseInt(shut_down_number_time_interval_j)).getTime());
|
|
|
- icingShutdown.setShutDownNumber(iShutDownNumber);
|
|
|
- icingShutdowns.add(icingShutdown);
|
|
|
+ if(endTime != 0 && startTime != 0){
|
|
|
+ IcingShutdown icingShutdown = new IcingShutdown();
|
|
|
+ icingShutdown.setStartTime(startTime);
|
|
|
+ icingShutdown.setEndTime(endTime);
|
|
|
+ icingShutdowns1.add(icingShutdown);
|
|
|
+ startTime = 0;
|
|
|
+ endTime = 0;
|
|
|
}
|
|
|
|
|
|
- // 到达马头山停机时间
|
|
|
- if(snowHowLong == Integer.parseInt(duration_of_snow_m) * 4){
|
|
|
- iShutDownNumber += 1;
|
|
|
- icingShutdownM.setStartTime(nwp.getPreTime());
|
|
|
- icingShutdownM.setEndTime(DateUtil.offsetMinute(new Date(nwp.getPreTime()), Integer.parseInt(shut_down_number_time_interval_m)).getTime());
|
|
|
- icingShutdownM.setShutDownNumber(iShutDownNumber);
|
|
|
- icingShutdowns.add(icingShutdownM);
|
|
|
+ }
|
|
|
+
|
|
|
+ int dj = 4;
|
|
|
+ int dm = 4;
|
|
|
+
|
|
|
+ if(shut_down_number_time_interval_j > 0 && shut_down_number_time_interval_j <= 30){
|
|
|
+ dj = 2;
|
|
|
+ }else if(shut_down_number_time_interval_j > 30 && shut_down_number_time_interval_j <= 45){
|
|
|
+ dj = 3;
|
|
|
+ }else if(shut_down_number_time_interval_j > 45 && shut_down_number_time_interval_j <= 60){
|
|
|
+ dj = 4;
|
|
|
+ }else if(shut_down_number_time_interval_j > 60 && shut_down_number_time_interval_j <= 75){
|
|
|
+ dj = 5;
|
|
|
+ }else if(shut_down_number_time_interval_j > 75 && shut_down_number_time_interval_j <= 90){
|
|
|
+ dj = 6;
|
|
|
+ }else if(shut_down_number_time_interval_j > 90 && shut_down_number_time_interval_j <= 105){
|
|
|
+ dj = 7;
|
|
|
+ }else if(shut_down_number_time_interval_j > 105 && shut_down_number_time_interval_j <= 120){
|
|
|
+ dj = 8;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(shut_down_number_time_interval_m > 0 && shut_down_number_time_interval_m <= 30){
|
|
|
+ dj = 2;
|
|
|
+ }else if(shut_down_number_time_interval_m > 30 && shut_down_number_time_interval_m <= 45){
|
|
|
+ dj = 3;
|
|
|
+ }else if(shut_down_number_time_interval_m > 0 && shut_down_number_time_interval_m <= 60){
|
|
|
+ dm = 4;
|
|
|
+ }else if(shut_down_number_time_interval_m > 60 && shut_down_number_time_interval_m <= 75){
|
|
|
+ dm = 5;
|
|
|
+ }else if(shut_down_number_time_interval_m > 75 && shut_down_number_time_interval_m <= 90){
|
|
|
+ dm = 6;
|
|
|
+ }else if(shut_down_number_time_interval_m > 90 && shut_down_number_time_interval_m <= 105){
|
|
|
+ dm = 7;
|
|
|
+ }else if(shut_down_number_time_interval_m > 105 && shut_down_number_time_interval_m <= 120){
|
|
|
+ dm = 8;
|
|
|
+ }
|
|
|
+ duration_of_snow_j *= dj;
|
|
|
+ duration_of_snow_m *= dm;
|
|
|
+ int shutDownJ = 0;
|
|
|
+ int shutDownM = 0;
|
|
|
+ for(IcingShutdown icingShutdown:icingShutdowns1){
|
|
|
+ long l = (icingShutdown.getEndTime() - icingShutdown.getStartTime()) / 1000 / 60 / 15 + 1;
|
|
|
+
|
|
|
+
|
|
|
+ if(l / 4 > 2){
|
|
|
+ long kkk = l / dj;
|
|
|
+ long l11 = l % 4;
|
|
|
+ if(l11 > 0 ){
|
|
|
+ kkk += 1;
|
|
|
+ }
|
|
|
+ kkk -= duration_of_snow_j / dj;
|
|
|
+ if(l11 == 0 && kkk < 0){
|
|
|
+ kkk = 1;
|
|
|
+ }
|
|
|
+ // 推移时间
|
|
|
+ long l22 = icingShutdowns1.get(0).getStartTime() + 1000l * 60 * 15 * duration_of_snow_j;
|
|
|
+ // 开始停机时间
|
|
|
+ icingShutdown.setStartTime(l22);
|
|
|
+ for(int i = 0; i < kkk; i++){
|
|
|
+ shutDownJ += 1;
|
|
|
+ IcingShutdown icingShutdown1 = new IcingShutdown();
|
|
|
+ icingShutdown1.setStartTime(DateUtil.offsetMinute(new Date(icingShutdown.getStartTime()),i * shut_down_number_time_interval_j).getTime());
|
|
|
+ long endTimes = DateUtil.offsetMinute(new Date(icingShutdown.getStartTime()),(i + 1) * shut_down_number_time_interval_j ).getTime();
|
|
|
+ if(endTimes > icingShutdown.getEndTime())endTimes = icingShutdown.getEndTime() + 1000l;
|
|
|
+ icingShutdown1.setEndTime(endTimes);
|
|
|
+ icingShutdown1.setShutDownNumber(shutDownJ);
|
|
|
+ icingShutdowns.add(icingShutdown1);
|
|
|
+ }
|
|
|
}
|
|
|
- if(snowHowLong > Integer.parseInt(duration_of_snow_m) * 4){
|
|
|
- iShutDownNumber += 1;
|
|
|
- icingShutdownM.setStartTime(nwp.getPreTime());
|
|
|
- icingShutdownM.setEndTime(DateUtil.offsetMinute(new Date(tempISM.getEndTime()), Integer.parseInt(shut_down_number_time_interval_m)).getTime());
|
|
|
- icingShutdownM.setShutDownNumber(iShutDownNumber);
|
|
|
- icingShutdowns.add(icingShutdownM);
|
|
|
+
|
|
|
+
|
|
|
+ // 将军山
|
|
|
+ // if(l > duration_of_snow_j){
|
|
|
+ // long kkk = l / dj;
|
|
|
+ // long l11 = l % 4;
|
|
|
+ // if(l11 > 0 ){
|
|
|
+ // kkk += 1;
|
|
|
+ // }
|
|
|
+ // kkk -= duration_of_snow_j / dj;
|
|
|
+ // // 推移时间
|
|
|
+ // long l22 = icingShutdowns1.get(0).getStartTime() + 1000l * 60 * 15 * duration_of_snow_j;
|
|
|
+ // // 开始停机时间
|
|
|
+ // icingShutdown.setStartTime(l22);
|
|
|
+ // for(int i = 0; i < kkk; i++){
|
|
|
+ // shutDownJ += 1;
|
|
|
+ // IcingShutdown icingShutdown1 = new IcingShutdown();
|
|
|
+ // icingShutdown1.setStartTime(DateUtil.offsetMinute(new Date(icingShutdown.getStartTime()),i * shut_down_number_time_interval_j).getTime());
|
|
|
+ // long endTimes = DateUtil.offsetMinute(new Date(icingShutdown.getStartTime()),(i + 1) * shut_down_number_time_interval_j ).getTime();
|
|
|
+ // if(endTimes > icingShutdown.getEndTime())endTimes = icingShutdown.getEndTime() + 1000l;
|
|
|
+ // icingShutdown1.setEndTime(endTimes);
|
|
|
+ // icingShutdown1.setShutDownNumber(shutDownJ);
|
|
|
+ // icingShutdowns.add(icingShutdown1);
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+ // }
|
|
|
+
|
|
|
+ // 马头山
|
|
|
+ if(l > duration_of_snow_m){
|
|
|
+ long kk = l / dm;
|
|
|
+ long l1 = l % 4;
|
|
|
+ if(l1 > 0 ){
|
|
|
+ kk += 1;
|
|
|
+ }
|
|
|
+ kk -= duration_of_snow_m / dm;
|
|
|
+ // 推移时间
|
|
|
+ long l2 = icingShutdowns1.get(0).getStartTime() + 1000l * 60 * 15 * duration_of_snow_m;
|
|
|
+ // 开始停机时间
|
|
|
+ icingShutdown.setStartTime(l2);
|
|
|
+ for(int i = 0; i < kk; i++){
|
|
|
+ shutDownM += 1;
|
|
|
+ IcingShutdown icingShutdown1 = new IcingShutdown();
|
|
|
+ icingShutdown1.setStartTime(DateUtil.offsetMinute(new Date(icingShutdown.getStartTime()),i * shut_down_number_time_interval_m).getTime());
|
|
|
+ long endTimes = DateUtil.offsetMinute(new Date(icingShutdown.getStartTime()),(i + 1) * shut_down_number_time_interval_m ).getTime();
|
|
|
+ if(endTimes > icingShutdown.getEndTime())endTimes = icingShutdown.getEndTime() + 1000l;
|
|
|
+ icingShutdown1.setEndTime(endTimes);
|
|
|
+ icingShutdown1.setShutDownNumber(shutDownM);
|
|
|
+ icingShutdowns.add(icingShutdown1);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- tempIS = icingShutdown;
|
|
|
- tempISM = icingShutdownM;
|
|
|
}
|
|
|
|
|
|
shutDownNumber = icingShutdowns.size();
|
|
@@ -1251,21 +1374,22 @@ public class ForecastPowerShortTermGeneratorService extends BaseService {
|
|
|
public Boolean westWindUp(List<Nwp> nwpList, Nwp nwp, Integer update_how_long_west_wind,String windHeight){
|
|
|
Boolean b = false;
|
|
|
// 西南风增强系数
|
|
|
- // Integer west_wind_up_modulus = Integer.parseInt();
|
|
|
BigDecimal west_wind_up_modulus = new BigDecimal(super.getSysParameter("WEST_WIND_UP_MODULUS", "1.6"));
|
|
|
- // 层高
|
|
|
- // String windHeight = super.getSysParameter("WIND_HEIGHT", "30");
|
|
|
long endTime = 60 * 1000 * 60 * update_how_long_west_wind;
|
|
|
// 需要修改的时间区间nwp
|
|
|
List<Nwp> collect = nwpList.stream().filter(n -> n.getPreTime().compareTo(nwp.getPreTime()) > -1 && n.getPreTime().compareTo(nwp.getPreTime() + endTime) < 1).collect(Collectors.toList());
|
|
|
|
|
|
List<Nwp> tempNwp = new ArrayList<>();
|
|
|
for (Nwp nwp1 : collect) {
|
|
|
- // 判断80风速是否小于10米
|
|
|
- if(getHeightWs(nwp1, windHeight).compareTo(new BigDecimal(10)) < 0){
|
|
|
- // nwp1.setWs80(nwp.getWs80().multiply(new BigDecimal(west_wind_up_modulus)));
|
|
|
- setHeightWs(nwp1, windHeight, getHeightWs(nwp1, windHeight).multiply(west_wind_up_modulus).setScale(2,RoundingMode.HALF_UP));
|
|
|
+ if(getHeightWs(nwp1, windHeight).compareTo(BigDecimal.ZERO) == 0){
|
|
|
+ setHeightWs(nwp1, windHeight, new BigDecimal(10.1).setScale(2,RoundingMode.HALF_UP));
|
|
|
+ }else {
|
|
|
+ // 判断80风速是否小于10米
|
|
|
+ if(getHeightWs(nwp1, windHeight).compareTo(new BigDecimal(10)) < 0){
|
|
|
+ setHeightWs(nwp1, windHeight, getHeightWs(nwp1, windHeight).multiply(west_wind_up_modulus).setScale(2,RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
tempNwp.add(nwp1);
|
|
|
}
|
|
|
List<Nwp> nwps = nwpRepository.saveAll(tempNwp);
|
|
@@ -1287,4 +1411,37 @@ public class ForecastPowerShortTermGeneratorService extends BaseService {
|
|
|
return c.getTimeInMillis() - DateUtils.getFragmentInMilliseconds(c, Calendar.DAY_OF_MONTH);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ // 处理小于15 大于60的数据
|
|
|
+
|
|
|
+ public ForecastPowerShortTerm dataRange( ForecastPowerShortTerm forecastPowerShortTerm){
|
|
|
+
|
|
|
+ // 计算超装机容量 60
|
|
|
+ if(forecastPowerShortTerm.getFpValue().compareTo(new BigDecimal(60)) > 0){
|
|
|
+ forecastPowerShortTerm.setFpValue(new BigDecimal(random(50, 60)).setScale(2,RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ // 计算小于15
|
|
|
+ if(forecastPowerShortTerm.getFpValue().compareTo(new BigDecimal(15)) < 0){
|
|
|
+ forecastPowerShortTerm.setFpValue(new BigDecimal(random(50, 60)).setScale(2,RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ return forecastPowerShortTerm;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 预测功率取值范围
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private void yesOrNoDataRange(){
|
|
|
+ String power_range = super.getSysParameter("POWER_RANGE", "1");
|
|
|
+ if(power_range.equals("1")){
|
|
|
+ // List<ForecastPowerShortTerm> byForecastTimeBetween = forecastPowerShortTermRepository.findByForecastTimeBetween(DateUtil.beginOfDay(DateUtil.tomorrow()).getTime(), DateUtil.endOfDay(DateUtil.tomorrow()).getTime());
|
|
|
+ List<ForecastPowerShortTerm> forecastPowerShortTermRepositoryAll = forecastPowerShortTermRepository.findAll();
|
|
|
+ for(ForecastPowerShortTerm forecastPowerShortTerm:forecastPowerShortTermRepositoryAll){
|
|
|
+ dataRange(forecastPowerShortTerm);
|
|
|
+ }
|
|
|
+ forecastPowerShortTermRepository.saveAll(forecastPowerShortTermRepositoryAll);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|