فهرست منبع

林洋上下午短期请求功能

fanxiaoyu 4 روز پیش
والد
کامیت
28c283bfad

+ 2 - 2
in-client-qn/src/main/java/com/jiayue/insu/inclientqn/service/client/BackDataGenBodyService.java

@@ -86,7 +86,7 @@ public class BackDataGenBodyService {
     public StringBuilder genStateAccuracyRate(List<BackStatData> backStatDatas) {
         StringBuilder content = new StringBuilder();
         // 如果统计数据中实际功率不为空
-        if (backStatDatas.get(0).getTheoryPower() != null && backStatDatas.get(0).getAvailablePower() != null){
+        if (backStatDatas.get(0).getAccuracy() != null){
             // 获取开始、结束、title标签
             String labelStart = TemplateStant.GEN_LABELSTART(QNHLEnum.DATA_STAT_TYPE_AccuracyRate.getCode());
             String labelEnd = TemplateStant.GEN_LABELEND(QNHLEnum.DATA_STAT_TYPE_AccuracyRate.getCode());
@@ -111,7 +111,7 @@ public class BackDataGenBodyService {
     public StringBuilder genStateLimitPowerFlag(List<BackStatData> backStatDatas) {
         StringBuilder content = new StringBuilder();
         // 如果统计数据中实际功率不为空
-        if (backStatDatas.get(0).getTheoryPower() != null && backStatDatas.get(0).getAvailablePower() != null){
+        if (backStatDatas.get(0).getPowerLimitSign() != null){
             // 获取开始、结束、title标签
             String labelStart = TemplateStant.GEN_LABELSTART(QNHLEnum.DATA_STAT_TYPE_LimitPowerFlag.getCode());
             String labelEnd = TemplateStant.GEN_LABELEND(QNHLEnum.DATA_STAT_TYPE_LimitPowerFlag.getCode());

+ 24 - 9
in-cloud/src/main/java/com/jiayue/insu/incloud/job/data/pull/LxPullCorrectDataJob.java

@@ -14,7 +14,10 @@ import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.List;
 
 /**
  * 飔合科技 拉取修正数据定时任务
@@ -40,17 +43,29 @@ public class LxPullCorrectDataJob implements Job {
         Station station = stationService.checkAndFindStation(code,CommonStant.RECORD_TYPE_PULL_CORRECT);
         //没有成功记录进行业务
         if (station != null) {
-            //查询是否有今天成功记录 (为提高稳定性,该定时任务采取在规定时间段内 重复循环执行的定时策略,故:需要查询是否存在成功记录)
-            Record successRecord = recordService.findTimeAndTypeAndStateAndStation(
-                    LocalDateTimeUtil.beginOfDay(LocalDateTime.now()),
-                    CommonStant.RECORD_TYPE_PULL_CORRECT,
-                    StatusEnum.SUCCESS.getSign(), station.getStationCode());
+            LocalTime noon = LocalTime.NOON;
+            LocalDateTime noonToday = LocalDateTime.of(LocalDate.now(),noon);
+            // 判断当前时间是否在中午12点之前  =》 12点之前请求一次修正短期,12点之后请求一次修正短期 一天共两次,根据时间来判断
+            if (LocalDateTime.now().isBefore(noonToday)){
+                //查询是否有今天成功记录 (为提高稳定性,该定时任务采取在规定时间段内 重复循环执行的定时策略,故:需要查询是否存在成功记录)
+                Record successRecord = recordService.findTimeAndTypeAndStateAndStation(
+                        LocalDateTimeUtil.beginOfDay(LocalDateTime.now()),
+                        CommonStant.RECORD_TYPE_PULL_CORRECT,
+                        StatusEnum.SUCCESS.getSign(), station.getStationCode());
+                // 没有成功记录进行请求业务
+                if (successRecord == null){
+                    pullCorrectDataForLx.pullDQData(station);
+                }
+            }else {
+                // 12点之后 请求记录应该是2条,小于2条记录继续请求修正数据
+                List<Record> recordList = recordService.findTypeAndStateAndStationAndCreatTime(
+                        CommonStant.RECORD_TYPE_PULL_CORRECT,
+                        StatusEnum.SUCCESS.getSign(), station.getStationCode(),LocalDateTimeUtil.beginOfDay(LocalDateTime.now()));
 
-            // 没有成功记录进行请求业务
-            if (successRecord == null){
-                pullCorrectDataForLx.pullDQData(station);
+                if (recordList.size() <= 1) {
+                    pullCorrectDataForLx.pullDQData(station);
+                }
             }
-
         }else{
             log.error("========== 一体化定时任务异常:  场站信息为空  {}==========",code);
         }

+ 25 - 22
in-cloud/src/main/java/com/jiayue/insu/incloud/pulldata/PullCorrectDataForLx.java

@@ -33,6 +33,7 @@ import org.springframework.stereotype.Component;
 import java.io.*;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.util.*;
@@ -79,7 +80,7 @@ public class PullCorrectDataForLx implements IPullInitCorrectDataForSH {
 //    private String cloudFileCreateLog;
 
     /**
-     * 拉取修正预测数据并生成文件上送minio服务器
+     * 拉取修正预测数据并生成文件上送minio服务器(林洋请求上下午修正短期数据)
      *
      * @param station 场站信息
      * @return 是否成功
@@ -87,19 +88,19 @@ public class PullCorrectDataForLx implements IPullInitCorrectDataForSH {
     @Override
     public Boolean pullDQData(Station station) {
 
-        Record record = new Record();
-        record.setStationCode(station.getStationCode());
-        record.setInCode(station.getInCode());
-        record.setType(CommonStant.RECORD_TYPE_PULL_CORRECT);
-        LocalDateTime localDateTime = LocalDateTimeUtil.beginOfDay(LocalDateTime.now());
-        record.setTime(localDateTime);
-        record.setCreateTime(LocalDateTime.now());
-
-        Station st = stationService.findByStationCode(station.getStationCode());
+        Record record = null;
+        LocalTime noon = LocalTime.NOON;
+        LocalDateTime noonToday = LocalDateTime.of(LocalDate.now(), noon);
+        // 判断当前时间是否在中午12点之前
+        if (LocalDateTime.now().isBefore(noonToday)) {
+            record = new Record(CommonStant.RECORD_TYPE_PULL_CORRECT, CompanyConstant.COMPANY_LX, station.getStationCode(), null, LocalDateTimeUtil.beginOfDay(LocalDateTime.now()), LocalDateTime.now(), null, null);
+        } else {
+            record = new Record(CommonStant.RECORD_TYPE_PULL_CORRECT, CompanyConstant.COMPANY_LX, station.getStationCode(), null, noonToday, LocalDateTime.now(), null, null);
+        }
 
         IntegrationCompany integrationCompany = integrationCompanyService.findByCode(CompanyConstant.COMPANY_LX);
 //        String dataPullUrl = integrationCompany.getPullUrl();
-        String dataPullUrl = "http://112.2.27.84:4220/changeData";
+//        String dataPullUrl = "http://112.2.27.84:4220/changeData";
 
         boolean result = false;
         boolean isUpload = false;
@@ -140,7 +141,7 @@ public class PullCorrectDataForLx implements IPullInitCorrectDataForSH {
 //                            if (false) {
                                 record.setState(StatusEnum.DATA_DEFICIENCY.getCode());
                                 record.setStateContent(StatusEnum.DATA_DEFICIENCY.getMsg());
-                                log.warn("========== {}:{} ==> 请求短期修正数据缺数: {}", integrationCompany.getName(), st.getStationCode(), list.size());
+                                log.warn("========== {}:{} ==> 请求短期修正数据缺数: {}", integrationCompany.getName(), station.getStationCode(), list.size());
                             } else {
                                 result = true;
                                 for (ForecastData a : aList) {
@@ -152,7 +153,7 @@ public class PullCorrectDataForLx implements IPullInitCorrectDataForSH {
                                     } else {
                                         record.setState(StatusEnum.DATA_DEFICIENCY.getCode());
                                         record.setStateContent(StatusEnum.DATA_DEFICIENCY.getMsg());
-                                        log.warn("========== {}:{} ==> 请求短期修正数据缺数: {}", integrationCompany.getName(), st.getStationCode(), list.size());
+                                        log.warn("========== {}:{} ==> 请求短期修正数据缺数: {}", integrationCompany.getName(), station.getStationCode(), list.size());
                                         break;
                                     }
                                 }
@@ -161,11 +162,11 @@ public class PullCorrectDataForLx implements IPullInitCorrectDataForSH {
                         } catch (Exception e) {
                             record.setState(StatusEnum.CONNECT_RESPONSE_FORMAT_ERROR.getSign());
                             record.setStateContent("解析短期修正数据失败");
-                            log.error("=========={}:{} ==> 解析短期修正数据失败 ", integrationCompany.getName(), st.getStationCode());
+                            log.error("=========={}:{} ==> 解析短期修正数据失败 ", integrationCompany.getName(), station.getStationCode());
                         }
 
                         if (result) {
-                            log.info("=========={}:{} ==> 拉取短期修正数据成功! ==========", integrationCompany.getName(), st.getStationCode());
+                            log.info("=========={}:{} ==> 拉取短期修正数据成功! ==========", integrationCompany.getName(), station.getStationCode());
                             record.setState(StatusEnum.SUCCESS.getSign());
                             record.setStateContent(String.valueOf(list.size()));
                             boolean b = forecastDataService.saveOrUpdateBatch(aList);
@@ -189,23 +190,23 @@ public class PullCorrectDataForLx implements IPullInitCorrectDataForSH {
                     } else {
                         record.setState(StatusEnum.RESPONSE_FAIL.getSign());
                         record.setStateContent(StatusEnum.RESPONSE_FAIL.getMsg());
-                        log.error("=========={}:{} ==>拉取短期修正数据失败 响应码异常 ", integrationCompany.getName(), st.getStationCode());
+                        log.error("=========={}:{} ==>拉取短期修正数据失败 响应码异常 ", integrationCompany.getName(), station.getStationCode());
                     }
                 } else {
                     record.setState(StatusEnum.CONNECT_RESPONSE_FORMAT_ERROR.getSign());
                     record.setStateContent(StatusEnum.CONNECT_RESPONSE_FORMAT_ERROR.getMsg());
-                    log.error("=========={}:{} ==>拉取短期修正数据失败 接收响应字符串非json格式 ", integrationCompany.getName(), st.getStationCode());
+                    log.error("=========={}:{} ==>拉取短期修正数据失败 接收响应字符串非json格式 ", integrationCompany.getName(), station.getStationCode());
                 }
             } else {
                 record.setState(StatusEnum.CONNECT_RESPONSE_CONTENT_NULL.getSign());
                 record.setStateContent(StatusEnum.CONNECT_RESPONSE_CONTENT_NULL.getMsg());
-                log.error("=========={}:{} ==> 拉取短期修正数据失败  返回响应内容为空 ==========", integrationCompany.getName(), st.getStationCode());
+                log.error("=========={}:{} ==> 拉取短期修正数据失败  返回响应内容为空 ==========", integrationCompany.getName(), station.getStationCode());
             }
 
         } catch (Exception e) {
             record.setState(StatusEnum.CONNECT_ERROR.getSign());
             record.setStateContent(StatusEnum.CONNECT_ERROR.getMsg());
-            log.error("=========={}:{} ==>请求短期修正数据失败 连接断开或请求超时 ==========", integrationCompany.getName(), st.getStationCode());
+            log.error("=========={}:{} ==>请求短期修正数据失败 连接断开或请求超时 ==========", integrationCompany.getName(), station.getStationCode());
             e.printStackTrace();
 
         }
@@ -331,12 +332,14 @@ public class PullCorrectDataForLx implements IPullInitCorrectDataForSH {
             }
             String fileName = "";
 
+            //根据时间区分上送minio文件名
+            LocalTime noon = LocalTime.NOON;
+            LocalDateTime noonToday = LocalDateTime.of(LocalDate.now(), noon);
             // 文件名区分(上午、下午)
-            LocalTime now = LocalTime.now();
-            if (now.getHour() <= 12) {
+            if (LocalDateTime.now().isBefore(noonToday)) {
                 fileName = "DQ_" + DateUtil.format(DateUtil.beginOfDay(new Date()), "yyyyMMddHHmmss") + "0.RB";
             } else {
-                fileName = "DQ_" + new SimpleDateFormat("yyyy-MM-dd").format(new Date())+"1200000.RB";
+                fileName = "DQ_" + new SimpleDateFormat("yyyyMMdd").format(new Date())+"1200000.RB";
             }
 
             file = new File(fUrl + File.separatorChar + fileName);