|
@@ -27,9 +27,7 @@ import java.nio.charset.Charset;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
import java.util.stream.Collectors;
|
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* 采集数据解析实现类
|
|
@@ -1022,29 +1020,27 @@ public class AnalysisDataImpl {
|
|
|
for (File file1 : files) {
|
|
|
if (file1.isDirectory()) {
|
|
|
File[] files1 = file1.listFiles();
|
|
|
- Stream<File> fileStream= Arrays.asList(files1).stream();
|
|
|
//筛选包含.log后缀的文件
|
|
|
- List<File> fileNameList = fileStream.filter(f -> !f.isDirectory() && f.getName().substring(f.getName().lastIndexOf(".")).contains(".log")).collect(Collectors.toList());
|
|
|
+ List<File> fileNameList = Arrays.asList(files1).stream().filter(f -> !f.isDirectory() && f.getName().substring(f.getName().lastIndexOf(".")).contains(".log")).collect(Collectors.toList());
|
|
|
//循环文件名
|
|
|
for (File fileNameForELog : fileNameList) {
|
|
|
- log.info("找到eol-fileNameForELog文件:{}",fileNameForELog);
|
|
|
+ log.info("找到eol-fileNameForELog文件:{}", fileNameForELog);
|
|
|
try {
|
|
|
String fileName = fileNameForELog.getName().substring(0, fileNameForELog.getName().indexOf(".log"));
|
|
|
//找出wnd文件
|
|
|
- List<File> wndFile = fileStream.filter(f -> f.getName().contains(".wnd") && f.getName().contains(fileName)).collect(Collectors.toList());
|
|
|
- log.info("找到eol文件的wnd格式文件:{}",JSONUtil.parse(wndFile));
|
|
|
+ List<File> wndFile = Arrays.asList(files1).stream().filter(f -> f.getName().contains(".wnd") && f.getName().contains(fileName)).collect(Collectors.toList());
|
|
|
+ log.info("找到eol文件的wnd格式文件:{}", JSONUtil.parse(wndFile));
|
|
|
if (wndFile.size() > 0) {
|
|
|
HashMap<String, String> stringStringHashMap = this.parseWnd(wndFile.get(0));
|
|
|
String eqNo = stringStringHashMap.get("SiteNumber");
|
|
|
//找出csv文件
|
|
|
- List<File> csvFile = fileStream.filter(f -> f.getName().contains(".csv") && f.getName().contains(fileName)).collect(Collectors.toList());
|
|
|
-
|
|
|
- //移动原文件备份
|
|
|
- File orgFile = new File(fileNameForELog.getParent() + File.separator + "Email" + File.separator);
|
|
|
- List<File> orgElogFile = Arrays.asList(orgFile.listFiles()).stream().filter(f -> f.getName().endsWith(".elog") && f.getName().contains(fileName)).collect(Collectors.toList());
|
|
|
- log.info("找到eol-orgElogFile:{}",JSONUtil.parse(orgElogFile));
|
|
|
+ List<File> csvFile = Arrays.asList(file1.listFiles()).stream().filter(f -> f.getName().contains(".csv") && f.getName().contains(fileName)).collect(Collectors.toList());
|
|
|
|
|
|
if (csvFile.size() > 0) {
|
|
|
+ //移动原文件备份
|
|
|
+ File orgFile = new File(fileNameForELog.getParent() + File.separator + "Email" + File.separator);
|
|
|
+ List<File> orgElogFile = Arrays.asList(orgFile.listFiles()).stream().filter(f -> f.getName().endsWith(".elog") && f.getName().contains(fileName)).collect(Collectors.toList());
|
|
|
+ log.info("找到eol-orgElogFile:{}", JSONUtil.parse(orgElogFile));
|
|
|
parseEol(csvFile.get(0), stringStringHashMap, eqNo, fileNameForELog, orgElogFile);
|
|
|
}
|
|
|
}
|
|
@@ -1063,8 +1059,9 @@ public class AnalysisDataImpl {
|
|
|
|
|
|
//解析eol文件
|
|
|
public void parseEol(File fileCsv, HashMap<String, String> stringStringHashMap, String eqNo, File fileNameForELog, List<File> orgElogFile) throws Exception {
|
|
|
-
|
|
|
- CsvReader reader = CsvUtil.getReader();
|
|
|
+ CsvReadConfig config = new CsvReadConfig();
|
|
|
+ config.setFieldSeparator(' ');
|
|
|
+ CsvReader reader = CsvUtil.getReader(config);
|
|
|
CsvData data = reader.read(fileCsv);
|
|
|
List<CsvRow> rows = data.getRows();
|
|
|
|
|
@@ -1074,7 +1071,7 @@ public class AnalysisDataImpl {
|
|
|
//遍历行
|
|
|
List<Map<String, Object>> dataList = new ArrayList<>();
|
|
|
|
|
|
- List< String> headerMap = new ArrayList<>();
|
|
|
+ List<String> headerMap = new ArrayList<>();
|
|
|
|
|
|
if (rows.get(3).getRawList().contains("DateTime")) {
|
|
|
List<String> strArr = rows.get(3).getRawList();
|
|
@@ -1090,11 +1087,11 @@ public class AnalysisDataImpl {
|
|
|
|
|
|
HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
List<String> strArr = rows.get(i).getRawList();
|
|
|
- for (int j=0;j<strArr.size(); j ++ ) {
|
|
|
- if("-".equals(strArr.get(j))){
|
|
|
+ for (int j = 0; j < strArr.size(); j++) {
|
|
|
+ if ("-".equals(strArr.get(j))) {
|
|
|
hashMap.put(headerMap.get(j), "-0.99");
|
|
|
- }else{
|
|
|
- hashMap.put(headerMap.get(j), strArr.get(j));
|
|
|
+ } else {
|
|
|
+ hashMap.put(headerMap.get(j), strArr.get(j).replace(",", ""));
|
|
|
}
|
|
|
}
|
|
|
if (hashMap.size() > 3) {
|
|
@@ -1203,7 +1200,7 @@ public class AnalysisDataImpl {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static String assembleWind(String s, HashSet<String> wsHeight, HashSet<String> wdHeight) {
|
|
|
+ public static String assembleWind(String s, HashSet<String> wsHeight, HashSet<String> wdHeight) {
|
|
|
String str = s;
|
|
|
if (s.contains("WS")) {
|
|
|
|
|
@@ -1222,7 +1219,7 @@ public class AnalysisDataImpl {
|
|
|
wsHeight.add(height);
|
|
|
}
|
|
|
//ave/min/max/sta
|
|
|
- String type = assembleProperty(wsAndType,false);
|
|
|
+ String type = assembleProperty(wsAndType, false);
|
|
|
str = "ws" + type + "_" + height;
|
|
|
|
|
|
} else if (s.contains("WD")) {
|
|
@@ -1235,30 +1232,30 @@ public class AnalysisDataImpl {
|
|
|
}
|
|
|
wdHeight.add(height);
|
|
|
//ave/min/max/sta
|
|
|
- String type = assembleProperty(wdAndType,false);
|
|
|
+ String type = assembleProperty(wdAndType, false);
|
|
|
str = "wd" + type + "_" + height;
|
|
|
|
|
|
} else if (s.contains("DateTime")) {
|
|
|
str = "time";
|
|
|
} else if (s.contains("PR")) {
|
|
|
- String type = assembleProperty(s,false);
|
|
|
+ String type = assembleProperty(s, false);
|
|
|
str = "pa" + type;
|
|
|
} else if (s.contains("TEM")) {
|
|
|
- String type = assembleProperty(s,true);
|
|
|
+ String type = assembleProperty(s, true);
|
|
|
str = "t" + type;
|
|
|
} else if (s.contains("RH")) {
|
|
|
- String type = assembleProperty(s,true);
|
|
|
+ String type = assembleProperty(s, true);
|
|
|
str = "rh" + type;
|
|
|
}
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static String assembleProperty(String property,boolean heightFlag) {
|
|
|
+ public static String assembleProperty(String property, boolean heightFlag) {
|
|
|
//有塔有多个层高得温度
|
|
|
String height = "";
|
|
|
if (heightFlag && property.split("_").length > 3 && !"10".equals(property.split("_")[2])) {
|
|
|
- height = "_"+property.split("_")[2];
|
|
|
+ height = "_" + property.split("_")[2];
|
|
|
}
|
|
|
String s = "Ave";
|
|
|
if (property.contains("-")) {
|
|
@@ -1272,8 +1269,8 @@ public class AnalysisDataImpl {
|
|
|
} else {
|
|
|
s = "Ave";
|
|
|
}
|
|
|
- if(StrUtil.isNotBlank(height)){
|
|
|
- s=s+height;
|
|
|
+ if (StrUtil.isNotBlank(height)) {
|
|
|
+ s = s + height;
|
|
|
}
|
|
|
return s;
|
|
|
|
|
@@ -1292,14 +1289,14 @@ public class AnalysisDataImpl {
|
|
|
|
|
|
//遍历行
|
|
|
List<Map<String, Object>> dataList = new ArrayList<>();
|
|
|
- List< String> headerMap = new ArrayList<>();
|
|
|
+ List<String> headerMap = new ArrayList<>();
|
|
|
|
|
|
if (rows.get(3).getRawList().contains("DateTime")) {
|
|
|
- List<String> strArr = rows.get(3).getRawList();
|
|
|
- for (String str : strArr) {
|
|
|
- String s1 = assembleWind(str, wsHeight, wdHeight);
|
|
|
- //修改表头
|
|
|
- headerMap.add( s1);
|
|
|
+ List<String> strArr = rows.get(3).getRawList();
|
|
|
+ for (String str : strArr) {
|
|
|
+ String s1 = assembleWind(str, wsHeight, wdHeight);
|
|
|
+ //修改表头
|
|
|
+ headerMap.add(s1);
|
|
|
|
|
|
}
|
|
|
} else {
|
|
@@ -1309,8 +1306,8 @@ public class AnalysisDataImpl {
|
|
|
|
|
|
HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
List<String> strArr = rows.get(i).getRawList();
|
|
|
- for (int j=0;j<strArr.size(); j ++ ) {
|
|
|
- System.out.println("第"+j+"个 headerMap.get(j): 【"+ headerMap.get(j) + "】 strArr.get(j):"+strArr.get(j));
|
|
|
+ for (int j = 0; j < strArr.size(); j++) {
|
|
|
+ System.out.println("第" + j + "个 headerMap.get(j): 【" + headerMap.get(j) + "】 strArr.get(j):" + strArr.get(j));
|
|
|
hashMap.put(headerMap.get(j), strArr.get(j));
|
|
|
}
|
|
|
if (hashMap.size() > 3 && !hashMap.get("time").equals("DateTime")) {
|