瀏覽代碼

恶劣天气修改

songhaodong 2 年之前
父節點
當前提交
c83227e192

+ 250 - 52
ipfcst/ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/job/UploadFileMatoushanJob.java

@@ -83,7 +83,7 @@ public class UploadFileMatoushanJob extends BaseService {
   //@Scheduled(fixedRate = 1000*60)
   //  30 30 5 * * ? 0/1 * * * * ?
   //  30 10,25,30 5,17 * * ?
-  @Scheduled(cron = "0/1 */1 * * * ?")
+  @Scheduled(cron = "0/1 */2 * * * ?")
   public void createDqFile()  {
     log.info("时间 【" + DateTimeUtil.dateToStrLong(new Date()) + "】 马头山短期文件生成开始");
     //1.读取配置
@@ -143,17 +143,17 @@ public class UploadFileMatoushanJob extends BaseService {
    */
   private List<ForecastPowerShortTerm> caculateDqs(List<Nwp> listTemperature) {
     // 是否开启了解冻开机 1开启
-    String yesorno_start_thaw_boot = super.getSysParameter("YESORNO_START_THAW_BOOT", "1");
+    // String yesorno_start_thaw_boot = super.getSysParameter("YESORNO_START_THAW_BOOT", "1");
     // 层高
     String windHeight = super.getSysParameter("WIND_HEIGHT", "30");
     List<ForecastPowerShortTerm> forecastPowerShortTermList = new ArrayList<>();
 
-    List<IcingShutdown> icingShutdowns = new ArrayList<>();
-    List<IcingShutdown> icingShutdownList = new ArrayList<>();
-    // 是否开启了解冻开机
-    if(yesorno_start_thaw_boot.equals("1")){
-      icingShutdownList = thawBoot();
-    }
+    // List<IcingShutdown> icingShutdowns = new ArrayList<>();
+    // List<IcingShutdown> icingShutdownList = new ArrayList<>();
+    // // 是否开启了解冻开机
+    // if(yesorno_start_thaw_boot.equals("1")){
+    //   icingShutdownList = thawBoot();
+    // }
 
     for (Nwp nwp: listTemperature) {
       Float speed = Convert.toFloat(getHeightWs(nwp,windHeight).setScale(1, RoundingMode.HALF_UP));
@@ -223,12 +223,12 @@ public class UploadFileMatoushanJob extends BaseService {
       forecastPowerShortTerm.setGenDate(new Date());
       forecastPowerShortTerm.setPredictionModelEnum(PredictionModelEnum.E1);
 
-      // 解冻开机
-      for(IcingShutdown icingShutdown:icingShutdownList){
-        if(icingShutdown.getStartTime() < nwp.getPreTime() && nwp.getPreTime() < icingShutdown.getEndTime()){
-          forecastPowerShortTerm.setFpValue(NumberUtil.round(totalPower/1000 + 2 * icingShutdown.getShutDownNumber(),2).setScale(2,RoundingMode.HALF_UP));
-        }
-      }
+      // // 解冻开机
+      // for(IcingShutdown icingShutdown:icingShutdownList){
+      //   if(icingShutdown.getStartTime() < nwp.getPreTime() && nwp.getPreTime() < icingShutdown.getEndTime()){
+      //     forecastPowerShortTerm.setFpValue(NumberUtil.round(totalPower/1000 + 2 * icingShutdown.getShutDownNumber(),2).setScale(2,RoundingMode.HALF_UP));
+      //   }
+      // }
 
       // 计算超装机容量设置为92.7
       if(forecastPowerShortTerm.getFpValue().compareTo(new BigDecimal(93))> 0 ){
@@ -493,7 +493,11 @@ public class UploadFileMatoushanJob extends BaseService {
     return forecastPowerShortTermList;
   }
 
-  //  随机数80-90
+
+  /**
+   * 随机数80-90
+   * @return
+   */
   public Float random(){
     Random r = new Random();
     DecimalFormat df= new DecimalFormat( "0.00");
@@ -517,6 +521,7 @@ public class UploadFileMatoushanJob extends BaseService {
     if(yesorno_start_icing_shotdown.equals("1")){
       // 停机数据
       List<IcingShutdown> icingShutdowns = parkedWindTurbine();
+      long endTime = icingShutdowns.get(icingShutdowns.size() - 1).getEndTime();
 
       // 短期数据
       List<ForecastPowerShortTerm> byForecastTimeBetween = forecastPowerShortTermRepository.findByForecastTimeBetween(startTimes, endTimes);
@@ -534,8 +539,41 @@ public class UploadFileMatoushanJob extends BaseService {
           }
         }
       }
+
+
+      int shut_down_number = Integer.parseInt(super.getSysParameter("SHUT_DOWN_NUMBER", "0"));
+
+      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);
+
     }
   }
 
@@ -625,6 +663,14 @@ public class UploadFileMatoushanJob extends BaseService {
     }
 
     shutDownNumber = icingShutdowns.size();
+
+   try {
+     SysParameter shut_down_number = sysParameterService.getParameterBySysKey("SHUT_DOWN_NUMBER");
+     shut_down_number.setSysValue(String.valueOf(icingShutdowns.size()));
+     sysParameterService.update(shut_down_number);
+   } catch (BusinessException e) {
+     log.info("获取参数错误:" + e);
+   }
     log.info("执行结冰停机方法结束,系统时间:"+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
     return icingShutdowns;
   }
@@ -634,23 +680,27 @@ public class UploadFileMatoushanJob extends BaseService {
    *
    * @return
    */
-  public List<IcingShutdown> thawBoot(){
+  public List<IcingShutdown> thawBoot(Long startTime, Long endTime){
     // 解冻间隔时间 马头山
     Integer thawing_interval_m = Integer.parseInt(super.getSysParameter("THAWING_INTERVAL_M", "60"));
     // 解冻间隔时间 将军山
     Integer thawing_interval_j = Integer.parseInt(super.getSysParameter("THAWING_INTERVAL_J", "80"));
     // 开机温度
     String thawing_interval_temperature = super.getSysParameter("THAWING_INTERVAL_TEMPERATURE", "-1");
+    // 停机数量
+    int shut_down_number = Integer.parseInt(super.getSysParameter("SHUT_DOWN_NUMBER", "-1"));
     // 系统时间
     Date systemDate = new Date();
     long tomrrow = DateUtil.endOfDay(DateUtil.offsetDay(systemDate,1)).getTime() + 1;
     // 获取两天nwp数据
-    List<Nwp> nwpData = nwpService.getNwpData(DateUtil.beginOfDay(systemDate).getTime(), tomrrow);
-    // 临时对象
-    IcingShutdown icingShutdown = new IcingShutdown();
-    IcingShutdown icingShutdownM = new IcingShutdown();
+    List<Nwp> nwpData = nwpService.getNwpData(startTime, endTime);
+    // // 临时对象
+    // IcingShutdown icingShutdown = new IcingShutdown();
+    // IcingShutdown icingShutdownM = new IcingShutdown();
     // 返回集合
     List<IcingShutdown> icingShutdowns = new ArrayList<>();
+    List<IcingShutdown> icingShutdownsM = new ArrayList<>();
+    List<IcingShutdown> icingShutdownsJ = new ArrayList<>();
 
     Integer ifOfCount = 0;
     Integer ifOfCountM = 0;
@@ -681,35 +731,183 @@ public class UploadFileMatoushanJob extends BaseService {
       forJ = 8;
     }
     log.info("执行解冻开机方法开始,系统时间:"+ DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
+
+    // 下一个解冰点
+    int nextJ = 0;
+    int nextM = 0;
     // 停机台数大于0
-    if(shutDownNumber > 0) {
+    if(shut_down_number > 0) {
       for (int i = 0; i < nwpData.size(); i++) {
-        if (shutDownNumber > 0) {
-          // 当前点温度是否高于解冻温度  并判断下一小时内四个点的温度
-          for (int j = i; j <= forJ; j++){
-            if(nwpData.get(i).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0) {
-              ifOfCount = ifOfCount + 1;
-              Long preTime = nwpData.get(j).getPreTime();
-              Long preTimeJ =DateUtil.offsetMinute(new Date(preTime), thawing_interval_j).getTime();
-              icingShutdown.setStartTime(preTime);
-              icingShutdown.setEndTime(preTimeJ);
-              icingShutdown.setShutDownNumber(ifOfCount);
+        // 临时对象
+        IcingShutdown icingShutdown = new IcingShutdown();
+        IcingShutdown icingShutdownM = new IcingShutdown();
+
+        int count = 0;
+
+        // 停机数量是否大于0
+        if (shut_down_number > 0) {
+
+          // 当前温度高于解冻温度
+          if(nwpData.get(i).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0) {
+            // 高于解冻温度的nwp数据时间点
+            icingShutdown.setStartTime(nwpData.get(i).getPreTime());
+
+            // 解冰集合有值
+            if(icingShutdownsJ.size() > 0){
+              // 当前循环等于下一个解冰点
+              if(nextJ == i){
+                // 将军山
+                for (int j = i; j <= i + forJ; j++) {
+                  if (nwpData.get(j).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0) {
+
+                    // 当是最后一次循环 记录时间点 则代表当前数据点之后的几个点位温度都满足解冰条件
+                    if (j == i + forJ) {
+                      ifOfCount = ifOfCount + 1;
+                      icingShutdown.setEndTime(nwpData.get(j).getPreTime());
+                      icingShutdown.setShutDownNumber(ifOfCount);
+                      icingShutdownsJ.add(icingShutdown);
+                      // 下一个解冻时间点
+                      nextJ = i + forJ + 1;
+
+                      count++;
+                    }
+                  }
+                }
+              }
+            }else {
+
+              // 将军山
+              for (int j = i; j <= i + forJ; j++) {
+                if (nwpData.get(j).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0) {
+
+                  // 当是最后一次循环 记录时间点 则代表当前数据点之后的几个点位温度都满足解冰条件
+                  if (j == i + forJ) {
+                    ifOfCount = ifOfCount + 1;
+                    icingShutdown.setEndTime(nwpData.get(j).getPreTime());
+                    icingShutdown.setShutDownNumber(ifOfCount);
+                    icingShutdownsJ.add(icingShutdown);
+                    // 下一个解冻时间点
+                    nextJ = i + forJ;
+                    count++;
+                  }
+                }
+              }
             }
-          }
-          for (int k = i; k <= forM; k++) {
-            if (nwpData.get(i).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0) {
-              ifOfCountM = ifOfCountM + 1;
-              Long preTime = nwpData.get(k).getPreTime();
-              Long preTimeM = DateUtil.offsetMinute(new Date(preTime), thawing_interval_m).getTime();
-              icingShutdownM.setStartTime(preTime);
-              icingShutdownM.setEndTime(preTimeM);
-              icingShutdownM.setShutDownNumber(ifOfCountM);
+
+            // 马头山
+            icingShutdownM.setStartTime(nwpData.get(i).getPreTime());
+            if(icingShutdownsM.size()> 0){
+              if(nextM == i){
+                for (int k = i; k <= i + forM; k++) {
+                  if (nwpData.get(k).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0) {
+                    if(k == i + forM){
+                      ifOfCountM = ifOfCountM + 1;
+                      icingShutdownM.setEndTime(nwpData.get(k).getPreTime());
+                      icingShutdownM.setShutDownNumber(ifOfCount);
+                      icingShutdownsM.add(icingShutdownM);
+                      nextM = i + forM + 1;
+                      count++;
+                    }
+                  }
+                }
+              }
+            }else{
+              for (int k = i; k <= i + forM; k++) {
+                if (nwpData.get(k).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0) {
+                  if(k == i + forM){
+                    ifOfCountM = ifOfCountM + 1;
+                    icingShutdownM.setEndTime(nwpData.get(k).getPreTime());
+                    icingShutdownM.setShutDownNumber(ifOfCount);
+                    icingShutdownsM.add(icingShutdownM);
+                    nextM = i + forM + 1;
+                    count++;
+                  }
+                }
+              }
             }
+
+
+
+
+
           }
-          shutDownNumber -= 2;
+
+        //
+        //
+        //
+        //
+        //
+        //
+        //
+        //
+        //
+        //
+        //
+        //
+        //
+        //
+        //
+        //   for (int j = i; j <= i + forJ; j++){
+        //     if(nwpData.get(j).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0) {
+        //
+        //       Long preTime = nwpData.get(j).getPreTime();
+        //       icingShutdown.setStartTime(preTime);
+        //       if(j == forJ + i){
+        //         Long preTimeJ =DateUtil.offsetMinute(new Date(preTime), thawing_interval_j).getTime();
+        //         icingShutdown.setEndTime(preTimeJ);
+        //       }else {
+        //         preTime = nwpData.get(j).getPreTime();
+        //         icingShutdown.setStartTime(preTime);
+        //       }
+        //     }
+        //   }
+        //
+        //
+        //
+        //   ifOfCount = ifOfCount + 1;
+        //   for (int j = i; j <= i + forJ; j++){
+        //     if(nwpData.get(j).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0) {
+        //
+        //       Long preTime = nwpData.get(j).getPreTime();
+        //       Long preTimeJ =DateUtil.offsetMinute(new Date(preTime), thawing_interval_j).getTime();
+        //       icingShutdown.setStartTime(preTime);
+        //       icingShutdown.setEndTime(preTimeJ);
+        //       icingShutdown.setShutDownNumber(ifOfCount);
+        //       shutDownNumber -= 1;
+        //     }
+        //   }
+        //   count++;
+        //   ifOfCountM = ifOfCountM + 1;
+        //   for (int k = i; k <= i + forM; k++) {
+        //     if (nwpData.get(i).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0) {
+        //
+        //       Long preTime = nwpData.get(k).getPreTime();
+        //       Long preTimeM = DateUtil.offsetMinute(new Date(preTime), thawing_interval_m).getTime();
+        //       icingShutdownM.setStartTime(preTime);
+        //       icingShutdownM.setEndTime(preTimeM);
+        //       icingShutdownM.setShutDownNumber(ifOfCountM);
+        //       shutDownNumber -= 1;
+        //
+        //     }
+        //   }
+        //   count++;
         }
+
+        if(count > 0){
+          try {
+            SysParameter shutdownnumber = sysParameterService.getParameterBySysKey("SHUT_DOWN_NUMBER");
+            shutdownnumber.setSysValue(String.valueOf(Integer.parseInt(shutdownnumber.getSysValue()) - count));
+            sysParameterService.update(shutdownnumber);
+          } catch (BusinessException e) {
+            log.info("获取参数错误:" + e);
+          }
+        }
+        shut_down_number = Integer.parseInt(super.getSysParameter("SHUT_DOWN_NUMBER", "-1"));
       }
     }
+
+    icingShutdowns.addAll(icingShutdownsJ);
+    icingShutdowns.addAll(icingShutdownsM);
     log.info("执行解冻开机方法结束,系统时间:"+ DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
 
     return icingShutdowns;
@@ -805,22 +1003,22 @@ public class UploadFileMatoushanJob extends BaseService {
     List<Nwp> listTemperature = getNwpDatas();
     List<Nwp> nwpList = new ArrayList<>();
     for (Nwp nwp : listTemperature) {
-      //层高
+      // 层高
       String windHeight = super.getSysParameter("WIND_HEIGHT", "30");
-      //风速
+      // 风速
       BigDecimal heightWs = getHeightWs(nwp, windHeight);
-      //查询增加的系数 默认1.2
+      // 查询增加的系数 默认1.2
       String wd_change_coefficient = super.getSysParameter("WD_CHANGE_COEFFICIENT", "1.2");
       BigDecimal coefficient = new BigDecimal(wd_change_coefficient);
-      //最低风速阈值
+      // 最低风速阈值
       String minimum_ws = super.getSysParameter("MINIMUM_WS", "1");
       BigDecimal minimumWs = new BigDecimal(minimum_ws);
-      //判断当前点比前15分钟的风向是否有改变
+      // 判断当前点比前15分钟的风向是否有改变
       Boolean eq = wdChange(nwp,windHeight);
       if (eq == false) {
-        //判断风速的值是否在最小区间
+        // 判断风速的值是否在最小区间
         if (heightWs.compareTo(BigDecimal.ZERO) == 0 || heightWs.compareTo(minimumWs) == -1) {
-          //设置修改之后的nwp风速数据
+          // 设置修改之后的nwp风速数据
           setHeightWs(nwp, windHeight, coefficient);
           nwpList.add(nwp);
         }
@@ -839,18 +1037,18 @@ public class UploadFileMatoushanJob extends BaseService {
    * @return
    */
   public Boolean wdChange(Nwp nwp,String fieldName) {
-    //获取当前nwp数据的时间
+    // 获取当前nwp数据的时间
     Long preEndTime = nwp.getPreTime() ;
-    //获取上15分钟的nwp数据的时间
+    // 获取上15分钟的nwp数据的时间
     Long preStartTime = preEndTime - 60000 * 15;
 
     List<Nwp> nwpData = nwpRepository.findByPreTimeBetween(preStartTime, preEndTime);
     List<BigDecimal> heightWd = getHeightWd(nwpData, fieldName);
 
-    //获取上15分钟风向数据
+    // 获取上15分钟风向数据
     BigDecimal wdFirst = heightWd.get(0);
     String firstWd = decideWind(wdFirst);
-    //获取当前nwp数据的风向
+    // 获取当前nwp数据的风向
     BigDecimal wdLast = heightWd.get(nwpData.size() - 1);
     String lastWd = decideWind(wdLast);