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