|
@@ -1,10 +1,8 @@
|
|
|
package com.jiayue.biz.service.impl;
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
-import cn.hutool.core.text.csv.CsvData;
|
|
|
-import cn.hutool.core.text.csv.CsvReader;
|
|
|
-import cn.hutool.core.text.csv.CsvRow;
|
|
|
-import cn.hutool.core.text.csv.CsvUtil;
|
|
|
+import cn.hutool.core.text.csv.*;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.core.util.ZipUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import cn.hutool.poi.excel.ExcelReader;
|
|
@@ -29,6 +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;
|
|
|
|
|
@@ -1063,45 +1062,46 @@ public class AnalysisDataImpl {
|
|
|
|
|
|
|
|
|
//解析eol文件
|
|
|
- public void parseEol(File fileCsv, HashMap<String, String> stringStringHashMap, String eqNo, File fileNameForELog, List<File> orgElogFile) {
|
|
|
+ public void parseEol(File fileCsv, HashMap<String, String> stringStringHashMap, String eqNo, File fileNameForELog, List<File> orgElogFile) throws Exception {
|
|
|
|
|
|
CsvReader reader = CsvUtil.getReader();
|
|
|
CsvData data = reader.read(fileCsv);
|
|
|
List<CsvRow> rows = data.getRows();
|
|
|
- //todo 不严谨但是能用
|
|
|
- CsvRow row = data.getRow(2);
|
|
|
|
|
|
HashSet<String> wsHeight = new HashSet<>();
|
|
|
HashSet<String> wdHeight = new HashSet<>();
|
|
|
|
|
|
- boolean state = true;
|
|
|
//遍历行
|
|
|
List<Map<String, Object>> dataList = new ArrayList<>();
|
|
|
|
|
|
- for (CsvRow csvRow : rows) {
|
|
|
- //getRawList返回一个List列表,列表的每一项为CSV中的一个单元格(既逗号分隔部分)
|
|
|
- HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
- for (int i = 0; i < csvRow.size(); i++) {
|
|
|
- String str = csvRow.get(i);
|
|
|
- if (str.contains("DateTime")) {
|
|
|
- if (state) {
|
|
|
- state = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- String s1 = this.assembleWind(str, wsHeight, wdHeight);
|
|
|
+ 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);
|
|
|
//修改表头
|
|
|
- csvRow.set(i, s1);
|
|
|
- if (str.equals("-")) {
|
|
|
- str = "-0.99";
|
|
|
+ headerMap.add(s1);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new Exception("EOL文件解析到数据异常");
|
|
|
+ }
|
|
|
+ for (int i = 4; i < rows.size(); i++) {
|
|
|
+
|
|
|
+ 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))){
|
|
|
+ hashMap.put(headerMap.get(j), "-0.99");
|
|
|
+ }else{
|
|
|
+ hashMap.put(headerMap.get(j), strArr.get(j));
|
|
|
}
|
|
|
- hashMap.put(row.get(i), str);
|
|
|
}
|
|
|
- //过滤数据
|
|
|
- if (hashMap.size() > 3 && !hashMap.get("time").equals("DateTime")) {
|
|
|
+ if (hashMap.size() > 3) {
|
|
|
dataList.add(hashMap);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
this.emailWindTowerInfoSave(eqNo);
|
|
|
List<WindTowerInfo> list = windTowerInfoService.list();
|
|
|
List<WindTowerInfo> windTowerInfos = list.stream().filter(w -> w.getEquipmentNo().equals(eqNo)).collect(Collectors.toList());
|
|
@@ -1203,7 +1203,7 @@ public class AnalysisDataImpl {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public 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 +1222,7 @@ public class AnalysisDataImpl {
|
|
|
wsHeight.add(height);
|
|
|
}
|
|
|
//ave/min/max/sta
|
|
|
- String type = this.assembleProperty(wsAndType);
|
|
|
+ String type = assembleProperty(wsAndType,false);
|
|
|
str = "ws" + type + "_" + height;
|
|
|
|
|
|
} else if (s.contains("WD")) {
|
|
@@ -1235,42 +1235,88 @@ public class AnalysisDataImpl {
|
|
|
}
|
|
|
wdHeight.add(height);
|
|
|
//ave/min/max/sta
|
|
|
- String type = this.assembleProperty(wdAndType);
|
|
|
+ String type = assembleProperty(wdAndType,false);
|
|
|
str = "wd" + type + "_" + height;
|
|
|
|
|
|
} else if (s.contains("DateTime")) {
|
|
|
str = "time";
|
|
|
} else if (s.contains("PR")) {
|
|
|
- String type = this.assembleProperty(s);
|
|
|
+ String type = assembleProperty(s,false);
|
|
|
str = "pa" + type;
|
|
|
} else if (s.contains("TEM")) {
|
|
|
- String type = this.assembleProperty(s);
|
|
|
+ String type = assembleProperty(s,true);
|
|
|
str = "t" + type;
|
|
|
} else if (s.contains("RH")) {
|
|
|
- String type = this.assembleProperty(s);
|
|
|
+ String type = assembleProperty(s,true);
|
|
|
str = "rh" + type;
|
|
|
}
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
|
|
|
- public String assembleProperty(String property) {
|
|
|
+ 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];
|
|
|
+ }
|
|
|
String s = "Ave";
|
|
|
if (property.contains("-")) {
|
|
|
if (property.contains("STDev")) {
|
|
|
s = "Sta";
|
|
|
} else if (property.contains("Max")) {
|
|
|
s = "Max";
|
|
|
-
|
|
|
} else if (property.contains("Min")) {
|
|
|
s = "Min";
|
|
|
}
|
|
|
} else {
|
|
|
s = "Ave";
|
|
|
}
|
|
|
+ if(StrUtil.isNotBlank(height)){
|
|
|
+ s=s+height;
|
|
|
+ }
|
|
|
return s;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public static void main(String[] args) throws Exception {
|
|
|
+ CsvReadConfig config = new CsvReadConfig();
|
|
|
+ config.setFieldSeparator(' ');
|
|
|
+ CsvReader reader = CsvUtil.getReader(config);
|
|
|
+ CsvData data = reader.read(new File("E:\\迅雷下载\\1\\ID006183_20240124_081336.elog_20240125_065638.log_20240125_070222.csv"));
|
|
|
+ List<CsvRow> rows = data.getRows();
|
|
|
+
|
|
|
+ HashSet<String> wsHeight = new HashSet<>();
|
|
|
+ HashSet<String> wdHeight = new HashSet<>();
|
|
|
+
|
|
|
+ //遍历行
|
|
|
+ List<Map<String, Object>> dataList = 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);
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new Exception("数据异常");
|
|
|
+ }
|
|
|
+ for (int i = 4; i < rows.size(); i++) {
|
|
|
+
|
|
|
+ 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));
|
|
|
+ hashMap.put(headerMap.get(j), strArr.get(j));
|
|
|
+ }
|
|
|
+ if (hashMap.size() > 3 && !hashMap.get("time").equals("DateTime")) {
|
|
|
+ dataList.add(hashMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|