|
@@ -88,8 +88,11 @@ public class PushCommon {
|
|
String todayStr = today.format(formatter);
|
|
String todayStr = today.format(formatter);
|
|
|
|
|
|
// 获取已经下载的预测文件内容
|
|
// 获取已经下载的预测文件内容
|
|
- List<String> originalContents = getInitFileLines(todayStr,filePath,record,"DQ");
|
|
|
|
-
|
|
|
|
|
|
+ List<String> originalContents = getInitFileLines(stationCode ,todayStr,filePath,record,"DQ");
|
|
|
|
+ if (originalContents == null || originalContents.size() == 0) {
|
|
|
|
+ log.error("场站{}下载的文件为空",stationCode);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
List<Map<String, Object>> vList = new ArrayList<>();
|
|
List<Map<String, Object>> vList = new ArrayList<>();
|
|
String dataTime[];
|
|
String dataTime[];
|
|
// 循环解析原始短期文件
|
|
// 循环解析原始短期文件
|
|
@@ -120,6 +123,14 @@ public class PushCommon {
|
|
// 将预测时间和预测功率放入list中
|
|
// 将预测时间和预测功率放入list中
|
|
map.put("forecastTime", dataTime[0] + "_" + dataTime[1]);
|
|
map.put("forecastTime", dataTime[0] + "_" + dataTime[1]);
|
|
map.put("fpValue", originalContentArr[3]);
|
|
map.put("fpValue", originalContentArr[3]);
|
|
|
|
+ String valueString = originalContentArr[3];
|
|
|
|
+ try {
|
|
|
|
+ BigDecimal decimal = new BigDecimal(valueString);
|
|
|
|
+ map.put("upper", decimal.multiply(new BigDecimal("1.1")));
|
|
|
|
+ map.put("lower", decimal.multiply(new BigDecimal("0.9")));
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
+ System.err.println("输入字符串格式错误");
|
|
|
|
+ }
|
|
vList.add(map);
|
|
vList.add(map);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -156,7 +167,11 @@ public class PushCommon {
|
|
String todayStr = today.toString("yyyyMMdd");
|
|
String todayStr = today.toString("yyyyMMdd");
|
|
|
|
|
|
// 获取已经下载的预测文件内容
|
|
// 获取已经下载的预测文件内容
|
|
- List<String> originalContents = getInitFileLines(todayStr,filePath,record,"NWP");
|
|
|
|
|
|
+ List<String> originalContents = getInitFileLines(stationCode,todayStr,filePath,record,"NWP");
|
|
|
|
+ if (originalContents == null || originalContents.size() == 0) {
|
|
|
|
+ log.error("场站{}下载的文件为空",stationCode);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
|
|
List<Map<String, Object>> vList = new ArrayList<>();
|
|
List<Map<String, Object>> vList = new ArrayList<>();
|
|
for (String originalContent : originalContents) {
|
|
for (String originalContent : originalContents) {
|
|
@@ -224,7 +239,6 @@ public class PushCommon {
|
|
velocityContext.put("stationCode", station.getStationCode());
|
|
velocityContext.put("stationCode", station.getStationCode());
|
|
velocityContext.put("stationName", station.getName());
|
|
velocityContext.put("stationName", station.getName());
|
|
|
|
|
|
- log.info("******templateName:{}",templateName);
|
|
|
|
File newFile;
|
|
File newFile;
|
|
// 生成新文件
|
|
// 生成新文件
|
|
try {
|
|
try {
|
|
@@ -282,34 +296,34 @@ public class PushCommon {
|
|
* 获取已经下载的预测原始文件内容
|
|
* 获取已经下载的预测原始文件内容
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public List<String> getInitFileLines(String todayStr,String filePath ,Record record ,String fileType){
|
|
|
|
|
|
+ public List<String> getInitFileLines(String stationCode,String todayStr,String filePath ,Record record ,String fileType){
|
|
List<String> originalContents = new ArrayList<>();
|
|
List<String> originalContents = new ArrayList<>();
|
|
// 获取指定目录下的短期原始数据(/jiayue/insu/file/init/J00269/)
|
|
// 获取指定目录下的短期原始数据(/jiayue/insu/file/init/J00269/)
|
|
File files = new File(filePath);
|
|
File files = new File(filePath);
|
|
String[] fileNames = files.list();
|
|
String[] fileNames = files.list();
|
|
// 如果文件名列表为空
|
|
// 如果文件名列表为空
|
|
if (fileNames == null || fileNames.length == 0) {
|
|
if (fileNames == null || fileNames.length == 0) {
|
|
- log.info("指定目录下无文件");
|
|
|
|
|
|
+ log.info("场站:{},指定目录:{} 下无文件",stationCode,filePath);
|
|
record.setState(StatusEnum.FILE_NULL.getSign());
|
|
record.setState(StatusEnum.FILE_NULL.getSign());
|
|
record.setStateContent(StatusEnum.FILE_NULL.getMsg());
|
|
record.setStateContent(StatusEnum.FILE_NULL.getMsg());
|
|
recordService.save(record);
|
|
recordService.save(record);
|
|
return originalContents;
|
|
return originalContents;
|
|
}
|
|
}
|
|
- // 获取当天日期
|
|
|
|
|
|
|
|
// 转为list并根据日期筛选排序
|
|
// 转为list并根据日期筛选排序
|
|
List<String> fileList = Arrays.stream(fileNames).collect(Collectors.toList());
|
|
List<String> fileList = Arrays.stream(fileNames).collect(Collectors.toList());
|
|
List<String> filterFileList = fileList.stream().filter(s -> s.contains(todayStr)).filter(s -> s.contains(fileType)).collect(Collectors.toList());
|
|
List<String> filterFileList = fileList.stream().filter(s -> s.contains(todayStr)).filter(s -> s.contains(fileType)).collect(Collectors.toList());
|
|
// 如果筛选后无文件
|
|
// 如果筛选后无文件
|
|
if (filterFileList.size() == 0) {
|
|
if (filterFileList.size() == 0) {
|
|
- log.info("无当日文件");
|
|
|
|
|
|
+ log.info("场站:{},无当日文件",stationCode);
|
|
record.setState(StatusEnum.FILE_NULL.getSign());
|
|
record.setState(StatusEnum.FILE_NULL.getSign());
|
|
record.setStateContent(StatusEnum.FILE_NULL.getMsg());
|
|
record.setStateContent(StatusEnum.FILE_NULL.getMsg());
|
|
recordService.save(record);
|
|
recordService.save(record);
|
|
return originalContents;
|
|
return originalContents;
|
|
}
|
|
}
|
|
- filterFileList.sort(Collections.reverseOrder());
|
|
|
|
|
|
|
|
|
|
+ // 根据时间倒序,选择最新的文件
|
|
|
|
+ filterFileList.sort(Collections.reverseOrder());
|
|
// 获取原始文件
|
|
// 获取原始文件
|
|
File originalFile = new File(filterFileList.get(0));
|
|
File originalFile = new File(filterFileList.get(0));
|
|
// 读取文件
|
|
// 读取文件
|