Explorar el Código

添加获取今日凌晨毫秒方法

songhaodong hace 2 años
padre
commit
6a1154dbf7

+ 24 - 40
ipfcst/ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/job/UploadFileMatoushanJob.java

@@ -3,10 +3,6 @@ package com.jiayue.ipfcst.fileupload.job;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.NumberUtil;
-import cn.hutool.core.util.RandomUtil;
-import cn.hutool.http.HttpUtil;
-import cn.hutool.json.JSONObject;
-import cn.hutool.json.JSONUtil;
 import com.jiayue.ipfcst.common.core.exception.BusinessException;
 import com.jiayue.ipfcst.common.core.util.DateTimeUtil;
 import com.jiayue.ipfcst.common.data.entity.*;
@@ -16,17 +12,11 @@ import com.jiayue.ipfcst.console.service.NwpService;
 import com.jiayue.ipfcst.console.service.SysParameterService;
 import com.jiayue.ipfcst.fileupload.util.UtilTools;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang.StringUtils;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+import org.apache.commons.lang.time.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
-import java.io.File;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.text.DateFormat;
@@ -137,7 +127,7 @@ public class UploadFileMatoushanJob extends BaseService {
    * @return
    */
   private List<Nwp>  getNwpDatas() {
-    long startTimes = UtilTools.getMillisecondsSubDay();
+    long startTimes = getMillisecondsSubDay();
     long endTimes = startTimes + dayNum * 24 * 60 * 60 * 1000 - 15 * 60 * 1000;
     List<Nwp> listTemperature = nwpRepository.findByPreTimeBetween(startTimes, endTimes);
     //排序后根据预测时间过滤
@@ -625,9 +615,9 @@ public class UploadFileMatoushanJob extends BaseService {
     // 解冻间隔时间 马头山
     String thawing_interval_m = super.getSysParameter("THAWING_INTERVAL_M", "1");
     // 解冻间隔时间 将军山
-    String thawing_interval_j = super.getSysParameter("THAWING_INTERVAL_J", "1");
+    String thawing_interval_j = super.getSysParameter("THAWING_INTERVAL_J", "1.2");
     // 开机温度
-    String thawing_interval_temperature = super.getSysParameter("THAWING_INTERVAL_TEMPERATURE", "1");
+    String thawing_interval_temperature = super.getSysParameter("THAWING_INTERVAL_TEMPERATURE", "-1");
     // 系统时间
     Date systemDate = new Date();
     long tomrrow = DateUtil.endOfDay(DateUtil.offsetDay(systemDate,1)).getTime() + 1;
@@ -643,35 +633,12 @@ public class UploadFileMatoushanJob extends BaseService {
 
     Integer ifOfCount = 0;
     Integer ifOfCountM = 0;
-//
-//    if(Integer.parseInt(shut_down_number) > 0){
-//      for(Nwp nwp:nwpData){
-//        if(Integer.parseInt(shut_down_number) > 0){
-//          if(nwp.getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0){
-//            ifOfCount = ifOfCount + 1;
-//            icingShutdown.setStartTime(nwp.getPreTime());
-//            icingShutdown.setEndTime(DateUtil.offsetHour(new Date(nwp.getPreTime()),Integer.parseInt(thawing_interval_j)).getTime());
-//            icingShutdown.setShutDownNumber(ifOfCount);
-//            icingShutdowns.add(icingShutdown);
-//            ifOfCountM = ifOfCountM + 1;
-//            icingShutdownM.setStartTime(nwp.getPreTime());
-//            icingShutdownM.setEndTime(DateUtil.offsetHour(new Date(nwp.getPreTime()),Integer.parseInt(thawing_interval_m)).getTime());
-//            icingShutdown.setShutDownNumber(ifOfCountM);
-//            icingShutdowns.add(icingShutdownM);
-//
-//          }
-//        }
-//      }
-//    }
-//
-//    for (long i = nwpData.get(0).getPreTime(); i <= nwpData.get(nwpData.size() - 1).getPreTime(); i+=1000 * 60 * 15) {
-//
-//
-//
-//    }
+
+    // 停机台数大于0
     if(Integer.parseInt(shut_down_number) > 0) {
       for (int i = 0; i < nwpData.size(); i++) {
         if (Integer.parseInt(shut_down_number) > 0) {
+          // 当前点温度是否高于解冻温度  并判断下一小时内四个点的温度
           if(nwpData.get(i).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0){
             if(nwpData.get(i+1).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0){
               if(nwpData.get(i+2).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0){
@@ -708,6 +675,11 @@ public class UploadFileMatoushanJob extends BaseService {
         }
       }
     }
+
+    if(Integer.parseInt(shut_down_number) > 0){
+
+    }
+
     return icingShutdowns;
   }
 
@@ -771,4 +743,16 @@ public class UploadFileMatoushanJob extends BaseService {
 
 
 
+  /**
+   * 今日凌晨 毫秒
+   *
+   * @return
+   */
+  public long getMillisecondsSubDay() {
+
+    Calendar c = Calendar.getInstance();
+
+    return c.getTimeInMillis() - DateUtils.getFragmentInMilliseconds(c, Calendar.DAY_OF_MONTH);
+  }
+
 }