|
@@ -1,5 +1,6 @@
|
|
package com.cpp.web.service.datafactory;
|
|
package com.cpp.web.service.datafactory;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.cpp.common.utils.StringUtils;
|
|
import com.cpp.common.utils.StringUtils;
|
|
import com.cpp.web.domain.BaseForecastCloudEntity;
|
|
import com.cpp.web.domain.BaseForecastCloudEntity;
|
|
import com.cpp.web.domain.BaseForecastEntity;
|
|
import com.cpp.web.domain.BaseForecastEntity;
|
|
@@ -102,7 +103,7 @@ public class CloudFileParsing {
|
|
if (!fileName.contains(dayStr)) {
|
|
if (!fileName.contains(dayStr)) {
|
|
file.delete();
|
|
file.delete();
|
|
log.warn(fileName + "不是当天的文件,删除!");
|
|
log.warn(fileName + "不是当天的文件,删除!");
|
|
- break;
|
|
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
// 如果文件名长度符合规则
|
|
// 如果文件名长度符合规则
|
|
if (fileName.length() < 31) {
|
|
if (fileName.length() < 31) {
|
|
@@ -116,10 +117,16 @@ public class CloudFileParsing {
|
|
parsingLog.setFileType(FileTypeEnum.dq);
|
|
parsingLog.setFileType(FileTypeEnum.dq);
|
|
// 解析短期文件
|
|
// 解析短期文件
|
|
List<BaseForecastCloudEntity> listDq = new ArrayList<>();
|
|
List<BaseForecastCloudEntity> listDq = new ArrayList<>();
|
|
- listDq.addAll(fileAnalysisShortTerm(file, new Date(currentDate)));
|
|
|
|
|
|
+ listDq.addAll(fileAnalysisShortTerm(file, new Date(currentDate),stationCode));
|
|
if (!listDq.isEmpty()) {
|
|
if (!listDq.isEmpty()) {
|
|
try {
|
|
try {
|
|
parsingLog.setStationCode(stationCode);
|
|
parsingLog.setStationCode(stationCode);
|
|
|
|
+ BaseForecastCloudEntity base = listDq.get(0);
|
|
|
|
+ Date createTime = base.getCreateTime();
|
|
|
|
+ String forecastModel = base.getForecastModel();
|
|
|
|
+
|
|
|
|
+ QueryWrapper queryWrapper = new QueryWrapper<ForecastPowerShortTermCloud>().between("create_time",DateTimeUtil.getDayStartTime(createTime.getTime()),DateTimeUtil.getDayLastTime(createTime.getTime())).eq("station_code",stationCode).eq("forecast_model",forecastModel);
|
|
|
|
+ forecastPowerShortTermCloudService.remove(queryWrapper);
|
|
forecastPowerShortTermCloudService.saveBatch(overhaulPlanService.getCorrectionData(listDq, FileTypeEnum.dq.name(), fileName, stationCode));
|
|
forecastPowerShortTermCloudService.saveBatch(overhaulPlanService.getCorrectionData(listDq, FileTypeEnum.dq.name(), fileName, stationCode));
|
|
flag = true;
|
|
flag = true;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -149,10 +156,18 @@ public class CloudFileParsing {
|
|
|
|
|
|
try {
|
|
try {
|
|
parsingLog.setFileType(FileTypeEnum.nwp);
|
|
parsingLog.setFileType(FileTypeEnum.nwp);
|
|
- List<NwpCloud> listNwp = fileAnalysisNwp(file, new Date(currentDate));
|
|
|
|
|
|
+ List<NwpCloud> listNwp = fileAnalysisNwp(file, new Date(currentDate), stationCode);
|
|
if (!listNwp.isEmpty()) {
|
|
if (!listNwp.isEmpty()) {
|
|
try {
|
|
try {
|
|
- parsingLog.setStationCode(listNwp.get(0).getStationCode());
|
|
|
|
|
|
+ parsingLog.setStationCode(stationCode);
|
|
|
|
+ NwpCloud nwpCloud = listNwp.get(0);
|
|
|
|
+ Date createTime = nwpCloud.getCreateTime();
|
|
|
|
+ String forecastModel = nwpCloud.getForecastModel();
|
|
|
|
+
|
|
|
|
+ QueryWrapper queryWrapper = new QueryWrapper<NwpCloud>().between("create_time",DateTimeUtil.getDayStartTime(createTime.getTime()),DateTimeUtil.getDayLastTime(createTime.getTime())).eq("station_code",stationCode).eq("forecast_model",forecastModel);
|
|
|
|
+
|
|
|
|
+ nwpCloudService.remove(queryWrapper);
|
|
|
|
+
|
|
nwpCloudService.saveBatch(listNwp);
|
|
nwpCloudService.saveBatch(listNwp);
|
|
flag = true;
|
|
flag = true;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -206,7 +221,7 @@ public class CloudFileParsing {
|
|
* @param file 文件路径
|
|
* @param file 文件路径
|
|
* @return 样例集合
|
|
* @return 样例集合
|
|
*/
|
|
*/
|
|
- private List<NwpCloud> fileAnalysisNwp(File file, Date currentDate) {
|
|
|
|
|
|
+ private List<NwpCloud> fileAnalysisNwp(File file, Date currentDate,String stationCode) {
|
|
List<NwpCloud> listNwp = new ArrayList<>();
|
|
List<NwpCloud> listNwp = new ArrayList<>();
|
|
if (file.renameTo(file)) {
|
|
if (file.renameTo(file)) {
|
|
InputStreamReader readNwp = null;
|
|
InputStreamReader readNwp = null;
|
|
@@ -219,8 +234,6 @@ public class CloudFileParsing {
|
|
BigDecimal nwpDirectRadiation = new BigDecimal("0.7"); //直接辐射
|
|
BigDecimal nwpDirectRadiation = new BigDecimal("0.7"); //直接辐射
|
|
BigDecimal nwpDiffuseRadiation = new BigDecimal("0.3"); //散接辐射
|
|
BigDecimal nwpDiffuseRadiation = new BigDecimal("0.3"); //散接辐射
|
|
|
|
|
|
-
|
|
|
|
- String stationCode = "";
|
|
|
|
String forecastModel = "";
|
|
String forecastModel = "";
|
|
|
|
|
|
|
|
|
|
@@ -229,7 +242,6 @@ public class CloudFileParsing {
|
|
String[] datas = lineTxt.split("\t");
|
|
String[] datas = lineTxt.split("\t");
|
|
|
|
|
|
if (datas[0].startsWith("<集中")) {
|
|
if (datas[0].startsWith("<集中")) {
|
|
- stationCode = ParsingUtil.splitLineWithSpace(datas[0])[1].split("'")[1];
|
|
|
|
// 使用单引号分割字符串
|
|
// 使用单引号分割字符串
|
|
forecastModel = ParsingUtil.splitLineWithSpace(datas[0])[2].split("'")[1];
|
|
forecastModel = ParsingUtil.splitLineWithSpace(datas[0])[2].split("'")[1];
|
|
}
|
|
}
|
|
@@ -367,7 +379,8 @@ public class CloudFileParsing {
|
|
*/
|
|
*/
|
|
private List<ForecastPowerShortTermCloud> fileAnalysisShortTerm(
|
|
private List<ForecastPowerShortTermCloud> fileAnalysisShortTerm(
|
|
File file,
|
|
File file,
|
|
- Date currentDate
|
|
|
|
|
|
+ Date currentDate,
|
|
|
|
+ String stationCode
|
|
) {
|
|
) {
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
List<ForecastPowerShortTermCloud> forecastPowerShortTerm = new ArrayList<>();
|
|
List<ForecastPowerShortTermCloud> forecastPowerShortTerm = new ArrayList<>();
|
|
@@ -381,7 +394,6 @@ public class CloudFileParsing {
|
|
read = new InputStreamReader(Files.newInputStream(file.toPath()), StandardCharsets.UTF_8);
|
|
read = new InputStreamReader(Files.newInputStream(file.toPath()), StandardCharsets.UTF_8);
|
|
bufferedReader = new BufferedReader(read);
|
|
bufferedReader = new BufferedReader(read);
|
|
|
|
|
|
- String stationCode = "";
|
|
|
|
String forecastModel = "";
|
|
String forecastModel = "";
|
|
|
|
|
|
// 循环解析文件
|
|
// 循环解析文件
|
|
@@ -389,8 +401,6 @@ public class CloudFileParsing {
|
|
|
|
|
|
String[] string_arr = stringLine.split("\t");
|
|
String[] string_arr = stringLine.split("\t");
|
|
if (string_arr[0].startsWith("<集中")) {
|
|
if (string_arr[0].startsWith("<集中")) {
|
|
- stationCode = ParsingUtil.splitLineWithSpace(string_arr[0])[1].split("'")[1];
|
|
|
|
- // 使用单引号分割字符串
|
|
|
|
forecastModel = ParsingUtil.splitLineWithSpace(string_arr[0])[2].split("'")[1];
|
|
forecastModel = ParsingUtil.splitLineWithSpace(string_arr[0])[2].split("'")[1];
|
|
}
|
|
}
|
|
|
|
|