Browse Source

UploadFileMatoushanJob内容修改

songhaodong 2 năm trước cách đây
mục cha
commit
b76652a7b4

+ 32 - 22
ipfcst/ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/job/UploadFileMatoushanJob.java

@@ -11,6 +11,7 @@ import com.jiayue.ipfcst.common.data.service.BaseService;
 import com.jiayue.ipfcst.console.service.NwpService;
 import com.jiayue.ipfcst.console.service.SysParameterService;
 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.scheduling.annotation.Scheduled;
@@ -136,17 +137,27 @@ public class UploadFileMatoushanJob extends BaseService {
    * @param listTemperature
    */
   private List<ForecastPowerShortTerm> caculateDqs(List<Nwp> listTemperature) {
-
     // 是否开启了结冰停机 1开启
     String yesorno_start_icing_shotdown = super.getSysParameter("YESORNO_START_ICING_SHOTDOWN", "0");
     // 是否开启了解冻开机 1开启
     String yesorno_start_thaw_boot = super.getSysParameter("YESORNO_START_THAW_BOOT", "0");
-
-
+    // 层高
+    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_icing_shotdown.equals("1")){
+      icingShutdowns = parkedWindTurbine();
+    }
+    // 是否开启了解冻开机
+    if(yesorno_start_thaw_boot.equals("1")){
+      icingShutdownList = parkedWindTurbine();
+    }
     for (Nwp nwp: listTemperature) {
 
-      Float speed = Convert.toFloat(nwp.getWs70().setScale(1, RoundingMode.HALF_UP));
+      Float speed = Convert.toFloat(getHeightWs(nwp,windHeight).setScale(1, RoundingMode.HALF_UP));
 
       //风速小于3米每秒不发电
       if(speed<3f) {
@@ -209,25 +220,20 @@ public class UploadFileMatoushanJob extends BaseService {
       forecastPowerShortTerm.setForecastTime(nwp.getPreTime());
       forecastPowerShortTerm.setFpValue(NumberUtil.round(totalPower/1000,2));
 
-      // 是否开启了结冰停机
-      if(yesorno_start_icing_shotdown.equals("1")){
-        List<IcingShutdown> icingShutdowns = parkedWindTurbine();
-        for(IcingShutdown icingShutdown:icingShutdowns){
-          if(icingShutdown.getStartTime() < nwp.getPreTime() && nwp.getPreTime() < icingShutdown.getEndTime()){
-            forecastPowerShortTerm.setFpValue(NumberUtil.round(totalPower/1000 - 2 * icingShutdown.getShutDownNumber(),2));
-          }
+      // 结冰停机
+      for(IcingShutdown icingShutdown:icingShutdowns){
+        if(icingShutdown.getStartTime() < nwp.getPreTime() && nwp.getPreTime() < icingShutdown.getEndTime()){
+          forecastPowerShortTerm.setFpValue(NumberUtil.round(totalPower/1000 - 2 * icingShutdown.getShutDownNumber(),2));
         }
       }
-      // 是否开启了解冻开机
-      if(yesorno_start_thaw_boot.equals("1")){
-        List<IcingShutdown> icingShutdowns = parkedWindTurbine();
-        for(IcingShutdown icingShutdown:icingShutdowns){
-          if(icingShutdown.getStartTime() < nwp.getPreTime() && nwp.getPreTime() < icingShutdown.getEndTime()){
-            forecastPowerShortTerm.setFpValue(NumberUtil.round(totalPower/1000 + 2 * icingShutdown.getShutDownNumber(),2));
-          }
+      // 解冻开机
+      for(IcingShutdown icingShutdown:icingShutdownList){
+        if(icingShutdown.getStartTime() < nwp.getPreTime() && nwp.getPreTime() < icingShutdown.getEndTime()){
+          forecastPowerShortTerm.setFpValue(NumberUtil.round(totalPower/1000 + 2 * icingShutdown.getShutDownNumber(),2));
         }
       }
 
+
       // 计算超装机容量设置为92.7
       if(forecastPowerShortTerm.getFpValue().compareTo(new BigDecimal(93))> 0 ){
         forecastPowerShortTerm.setFpValue(BigDecimal.valueOf(random()));
@@ -420,7 +426,7 @@ public class UploadFileMatoushanJob extends BaseService {
   public List<ForecastPowerShortTerm> modifyShorterData(List<ForecastPowerShortTerm> forecastPowerShortTermList){
     List<ModifyShorterData> modifyShorterDataList = modifyShorterDataRepository.findByStartTimeAfter(new Date());
     DecimalFormat decimalFormat=new DecimalFormat(".00");
-    log.info("执行修改短期系数方法开始,系统时间:"+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+    log.info("执行修改短期系数方法开始,系统时间:"+ DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
     for(ModifyShorterData m: modifyShorterDataList){
       Date startTime = m.getStartTime();
       Date endTime = m.getEndTime();
@@ -435,7 +441,7 @@ public class UploadFileMatoushanJob extends BaseService {
         }
       }
     }
-    log.info("执行修改短期系数方法结束,系统时间:"+ new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+    log.info("执行修改短期系数方法结束,系统时间:"+ DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
     return modifyMinPower(forecastPowerShortTermList);
   }
 
@@ -752,7 +758,7 @@ public class UploadFileMatoushanJob extends BaseService {
    * 修改nwp风速
    */
   public void moldRepair(){
-    log.info("执行修改nwp风速:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+    log.info("执行修改nwp风速:" + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
     List<Nwp> listTemperature = getNwpDatas();
     List<Nwp> nwpList = new ArrayList<>();
     for (Nwp nwp : listTemperature) {
@@ -778,12 +784,16 @@ public class UploadFileMatoushanJob extends BaseService {
       }
     }
     nwpService.saveAll(nwpList);
-    log.info("执行修改nwp风速结束 系统时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+    log.info("执行修改nwp风速结束 系统时间:" + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
   }
 
 
   /**
    * 判断风向是否发生改变
+   *
+   * @param nwp
+   * @param fieldName
+   * @return
    */
   public Boolean wdChange(Nwp nwp,String fieldName) {
     //获取当前nwp数据的时间