|
@@ -1,4 +1,4 @@
|
|
|
-package com.jiayue.ipfcst.fileupload.job;
|
|
|
+package com.jiayue.ipfcst.console.service.mts;
|
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
@@ -39,7 +39,7 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
-public class ForecastPowerShortTermGeneratorJob extends BaseService {
|
|
|
+public class ForecastPowerShortTermGeneratorService extends BaseService {
|
|
|
@Autowired
|
|
|
NwpRepository nwpRepository;
|
|
|
@Autowired
|
|
@@ -82,19 +82,23 @@ public class ForecastPowerShortTermGeneratorJob extends BaseService {
|
|
|
//@Scheduled(fixedRate = 1000*60)
|
|
|
// 30 30 5 * * ? 0/1 * * * * ?
|
|
|
// 30 10,25,30 5,17 * * ? 0/1 */2 * * * ?
|
|
|
- @Scheduled(cron = "30 10,25,30 5,17 * * ?")
|
|
|
+ // @Scheduled(cron = "0/1 */1 * * * ?")
|
|
|
public void createDqFile() {
|
|
|
log.info("时间 【" + DateTimeUtil.dateToStrLong(new Date()) + "】 马头山短期数据生成开始");
|
|
|
- //1.读取配置
|
|
|
+ // 用户主目录
|
|
|
+ String userHome = System.getProperties().getProperty("user.home");
|
|
|
+ System.out.println("用户主目录:"+userHome);
|
|
|
+ // 1.读取配置
|
|
|
readDataForParams();
|
|
|
//2.修改nwp数据
|
|
|
List<Nwp> nwpDatas = moldRepair();
|
|
|
//3.持续强北风
|
|
|
beginWestWindUp();
|
|
|
//4.查询nwp数据
|
|
|
- getNwpDatas();
|
|
|
+ // getNwpDatas();
|
|
|
//5.计算短期预测
|
|
|
List<ForecastPowerShortTerm> forecastPowerShortTerms = caculateDqs(nwpDatas);
|
|
|
+ // forecastPowerShortTermRepository.saveAll(forecastPowerShortTerms);
|
|
|
//6.恶劣天气
|
|
|
yesOrNoStartIcingShutdown(forecastPowerShortTerms, nwpDatas);
|
|
|
log.info("时间 【" + DateTimeUtil.dateToStrLong(new Date()) + "】 马头山短期数据生成完成");
|
|
@@ -158,6 +162,7 @@ public class ForecastPowerShortTermGeneratorJob extends BaseService {
|
|
|
* @param listTemperature
|
|
|
*/
|
|
|
private List<ForecastPowerShortTerm> caculateDqs(List<Nwp> listTemperature) {
|
|
|
+ log.info("计算短期预测:" + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
// 层高
|
|
|
String windHeight = super.getSysParameter("WIND_HEIGHT", "30");
|
|
|
List<ForecastPowerShortTerm> forecastPowerShortTermList = new ArrayList<>();
|
|
@@ -239,6 +244,7 @@ public class ForecastPowerShortTermGeneratorJob extends BaseService {
|
|
|
List<ForecastPowerShortTerm> forecastPowerShortTerms = modifyShorterData(forecastPowerShortTermList);
|
|
|
|
|
|
forecastPowerShortTermRepository.saveAll(forecastPowerShortTerms);
|
|
|
+ log.info("计算短期预测结束:" + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
return forecastPowerShortTerms;
|
|
|
}
|
|
|
|
|
@@ -552,21 +558,21 @@ public class ForecastPowerShortTermGeneratorJob extends BaseService {
|
|
|
}
|
|
|
|
|
|
// 解冰开机
|
|
|
- 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));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // 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);
|
|
@@ -594,7 +600,7 @@ public class ForecastPowerShortTermGeneratorJob extends BaseService {
|
|
|
// 停机温度
|
|
|
BigDecimal down_the_temperature = new BigDecimal(super.getSysParameter("DOWN_THE_TEMPERATURE", "-4"));
|
|
|
// 结冰降水量阈值
|
|
|
- BigDecimal tpr_threshold = new BigDecimal(super.getSysParameter("TPR_THRESHOLD", "1.0000"));
|
|
|
+ BigDecimal tpr_threshold = new BigDecimal(super.getSysParameter("TPR_THRESHOLD", "1.00"));
|
|
|
// 持续降雪多长时间开始结冰 马头山
|
|
|
String duration_of_snow_m = super.getSysParameter("DURATION_OF_SNOW_M", "30");
|
|
|
// 持续降雪多长时间开始结冰 将军山
|
|
@@ -965,7 +971,7 @@ public class ForecastPowerShortTermGeneratorJob extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
nwpService.saveAll(nwpList);
|
|
|
- if(nwpList.size() < 0){
|
|
|
+ if(nwpList.size() <= 0){
|
|
|
nwpList = listTemperature;
|
|
|
}
|
|
|
log.info("执行修改nwp风速结束 系统时间:" + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
@@ -1108,27 +1114,64 @@ public class ForecastPowerShortTermGeneratorJob extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public BigDecimal getWd(Nwp nwp, String fieldName) {
|
|
|
+ BigDecimal wd = BigDecimal.ZERO;
|
|
|
+ switch (fieldName) {
|
|
|
+ case "10":
|
|
|
+ wd = nwp.getWd10();
|
|
|
+ break;
|
|
|
+ case "30":
|
|
|
+ wd = nwp.getWd30();
|
|
|
+ break;
|
|
|
+ case "50":
|
|
|
+ wd = nwp.getWd50();
|
|
|
+ break;
|
|
|
+ case "70":
|
|
|
+ wd = nwp.getWd70();
|
|
|
+ break;
|
|
|
+ case "80":
|
|
|
+ wd = nwp.getWd80();
|
|
|
+ break;
|
|
|
+ case "90":
|
|
|
+ wd = nwp.getWd90();
|
|
|
+ break;
|
|
|
+ case "100":
|
|
|
+ wd = nwp.getWd100();
|
|
|
+ break;
|
|
|
+ case "170":
|
|
|
+ wd = nwp.getWd170();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return wd;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 持续强北风后 修改西南风风速值
|
|
|
*/
|
|
|
public void beginWestWindUp(){
|
|
|
// 系统日期
|
|
|
Date systemTime = new Date();
|
|
|
+ // 层高
|
|
|
+ String windHeight = super.getSysParameter("WIND_HEIGHT", "30");
|
|
|
+
|
|
|
+ // 修改多长时间的西南风风速
|
|
|
+ Integer update_how_long_west_wind = Integer.parseInt(super.getSysParameter("UPDATE_HOW_LONG_WEST_WIND", "6"));
|
|
|
|
|
|
// 今天开始
|
|
|
long beginOfDay = DateUtil.beginOfDay(systemTime).getTime();
|
|
|
// 今天结束
|
|
|
long endOfDay = DateUtil.endOfDay(systemTime).getTime() + 1;
|
|
|
- // 获取今天nwp
|
|
|
- List<Nwp> todayNwp = nwpRepository.findByPreTimeBetween(beginOfDay, endOfDay);
|
|
|
- // 80米风向是西南风的点位预测时间
|
|
|
- long preTime = 0l;
|
|
|
|
|
|
- // 修改多长时间的西南风风速
|
|
|
- Integer update_how_long_west_wind = Integer.parseInt(super.getSysParameter("UPDATE_HOW_LONG_WEST_WIND", "6"));
|
|
|
+ long startTimes = getMillisecondsSubDay();
|
|
|
+ long endTimes = startTimes + dayNum * 24 * 60 * 60 * 1000 - 15 * 60 * 1000;
|
|
|
+ log.info("执行西南风增强开始:" + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ // 获取今天nwp
|
|
|
+ List<Nwp> todayNwp = nwpRepository.findByPreTimeBetween(startTimes, endTimes);
|
|
|
|
|
|
// 西南风list
|
|
|
- List<Nwp> xnNwp = todayNwp.stream().filter(nwp -> nwp.getWd80().compareTo(new BigDecimal(202.5)) > -1 && nwp.getWd80().compareTo(new BigDecimal(247.5)) < -1).collect(Collectors.toList());
|
|
|
+ List<Nwp> xnNwp = todayNwp.stream().filter(nwp -> getWd(nwp, windHeight).compareTo(new BigDecimal(202.5)) > -1 && getWd(nwp, windHeight).compareTo(new BigDecimal(247.5)) < 1).collect(Collectors.toList());
|
|
|
|
|
|
// 格式化日志时间
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
|
|
@@ -1142,12 +1185,13 @@ public class ForecastPowerShortTermGeneratorJob extends BaseService {
|
|
|
// 是连续强北风
|
|
|
if(isNorth){
|
|
|
// 执行西南风增强
|
|
|
- Boolean aBoolean = westWindUp(xnNwp, nwp, update_how_long_west_wind);
|
|
|
+ Boolean aBoolean = westWindUp(xnNwp, nwp, update_how_long_west_wind,windHeight);
|
|
|
log.info("时间:"+simpleDateFormat.format(new Date())+"->"+"西南风是否增强成功:" + aBoolean);
|
|
|
}
|
|
|
// 从计算结束的nwp开始
|
|
|
i= i + update_how_long_west_wind * 4;
|
|
|
}
|
|
|
+ log.info("执行西南风增强结束:" + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1165,18 +1209,21 @@ public class ForecastPowerShortTermGeneratorJob extends BaseService {
|
|
|
// 允许不是北风的差值
|
|
|
Integer long_north_always = Integer.parseInt(super.getSysParameter("LONG_NORTH_ALWAYS", "5"));
|
|
|
// 强北风持续时间区间
|
|
|
- Integer long_north_wing_start = Integer.parseInt(super.getSysParameter("LONG_NORTH_WING_START", "10"));
|
|
|
+ Integer long_north_wing_start = Integer.parseInt(super.getSysParameter("LONG_NORTH_WIND_START", "10"));
|
|
|
// 获取西南风时间 的前 long_north_wing_start 小时的nwp
|
|
|
List<Nwp> lastNHourList = nwpRepository.findByPreTimeBetween(DateUtil.offsetHour(DateUtil.date(preTime), -long_north_wing_start).getTime(), preTime);
|
|
|
|
|
|
+ // 层高
|
|
|
+ String windHeight = super.getSysParameter("WIND_HEIGHT", "30");
|
|
|
+
|
|
|
for(Nwp nwp: lastNHourList){
|
|
|
// 如果是北风
|
|
|
- if(nwp.getWd80().compareTo(BigDecimal.ZERO) > -1 && nwp.getWd80().compareTo(new BigDecimal(45)) < -1 || nwp.getWd80().compareTo(new BigDecimal(315)) > -1 && nwp.getWd80().compareTo(new BigDecimal(360)) < -1 ){
|
|
|
- //如果风速大于10 则是强北风
|
|
|
- if(nwp.getWs80().compareTo(new BigDecimal(10)) > -1){
|
|
|
+ if(getWd(nwp, windHeight).compareTo(BigDecimal.ZERO) > -1 && getWd(nwp, windHeight).compareTo(new BigDecimal(45)) < 1 || getWd(nwp, windHeight).compareTo(new BigDecimal(315)) > -1 && getWd(nwp, windHeight).compareTo(new BigDecimal(360)) < 1 ){
|
|
|
+ // //如果风速大于10 则是强北风
|
|
|
+ // if(nwp.getWs80().compareTo(new BigDecimal(10)) > -1){
|
|
|
// 统计强北风出现次数
|
|
|
strongNorthWind += 1;
|
|
|
- }
|
|
|
+ // }
|
|
|
}else {
|
|
|
// 统计强北风中断次数
|
|
|
strongNorthWindCut += 1;
|
|
@@ -1201,20 +1248,23 @@ public class ForecastPowerShortTermGeneratorJob extends BaseService {
|
|
|
* @param nwpList
|
|
|
* @param nwp 当前nwp
|
|
|
*/
|
|
|
- public Boolean westWindUp(List<Nwp> nwpList, Nwp nwp, Integer update_how_long_west_wind){
|
|
|
+ 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(super.getSysParameter("WEST_WIND_UP_MODULUS", "1.6"));
|
|
|
-
|
|
|
+ // 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> 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(nwp1.getWs80().compareTo(new BigDecimal(10)) > -1){
|
|
|
- nwp1.setWs80(nwp.getWs80().multiply(new BigDecimal(west_wind_up_modulus)));
|
|
|
+ // 判断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));
|
|
|
}
|
|
|
tempNwp.add(nwp1);
|
|
|
}
|