|
@@ -649,7 +649,7 @@ public class AnalysisDataImpl {
|
|
|
List<Map<String, Object>> filterData = new CheckDataRecode().checkValue(allData, type);
|
|
|
String equipmentId = file.getName().substring(0, 4);
|
|
|
String eTime = file.getName().substring(4, 12);
|
|
|
- windTowerDataParentTableService.packageData(filterData, equipmentId, eTime, type, "");
|
|
|
+ windTowerDataParentTableService.packageData(filterData, equipmentId, type, "");
|
|
|
reader.close();
|
|
|
|
|
|
}
|
|
@@ -698,7 +698,7 @@ public class AnalysisDataImpl {
|
|
|
List<Map<String, Object>> filterData = new CheckDataRecode().checkValue(allData, type);
|
|
|
String eqId = file.getName().split("_")[0];
|
|
|
String eTime = file.getName().split("_")[1];
|
|
|
- windTowerDataParentTableService.packageData(filterData, eqId, eTime, type, "");
|
|
|
+ windTowerDataParentTableService.packageData(filterData, eqId, type, "");
|
|
|
reader.close();
|
|
|
}
|
|
|
|
|
@@ -780,49 +780,6 @@ public class AnalysisDataImpl {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 解析声雷达文件入库
|
|
|
- */
|
|
|
- public void AnalysisSldFile() {
|
|
|
- File file = new File("D:\\AcousticRadar\\new\\");
|
|
|
- if (!file.exists()) {
|
|
|
- file.mkdirs();
|
|
|
- }
|
|
|
- //获取目录下的所有文件夹
|
|
|
- File[] files = file.listFiles();
|
|
|
- try {
|
|
|
- for (File file1 : files) {
|
|
|
- //获取新数据文件夹的文件名
|
|
|
- String fileName = file1.getName();
|
|
|
- //新老文件夹名字一致
|
|
|
- File oldFile = new File("D:\\AcousticRadar\\old\\" + fileName);
|
|
|
- //获取文件夹下的所有文件
|
|
|
- File[] fileList = file1.listFiles();
|
|
|
- for (File file2 : fileList) {
|
|
|
- //如果有zip文件就解压到当前文件夹
|
|
|
- if (isArchiveFile(file2)) {
|
|
|
- String zipPath = file2.getPath();
|
|
|
- //解压文件
|
|
|
- ZipUtil.unzip(file2.getPath(), file1.getPath() + "\\");
|
|
|
- //删除压缩包
|
|
|
- FileUtils.deleteFile(zipPath);
|
|
|
- }
|
|
|
- if (file2.getName().contains(".csv")) {
|
|
|
- //解析csv文件
|
|
|
- acousticRadar(file2, file1.getName());
|
|
|
- //将解析过的文件转移到备用目录
|
|
|
- com.jiayue.biz.util.FileUtil.move(file2.getPath(), oldFile.getPath() + "\\");
|
|
|
- log.info("声雷达文件入库成功");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("声雷达文件入库错误");
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* @param file csv文件
|
|
|
* @param eqId 设备Id
|
|
|
*/
|
|
@@ -835,7 +792,7 @@ public class AnalysisDataImpl {
|
|
|
//获取到csv文件
|
|
|
List<CsvRow> rows = data.getRows();
|
|
|
//获取层高
|
|
|
- List<WindTowerInfo> equipmentNo = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo,eqId).list();
|
|
|
+ List<WindTowerInfo> equipmentNo = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, eqId).list();
|
|
|
String height = "";
|
|
|
if (equipmentNo.size() == 0) {
|
|
|
CsvRow csvRow = rows.get(0);
|
|
@@ -972,7 +929,8 @@ public class AnalysisDataImpl {
|
|
|
|
|
|
//过滤数据
|
|
|
List<Map<String, Object>> mapList1 = new CheckDataRecode().checkValue(mapList, "sld");
|
|
|
- windTowerDataParentTableService.packageData(mapList1, eqId, time1, "sld", "");
|
|
|
+ windTowerDataParentTableService.packageData(mapList1, eqId, "sld", "");
|
|
|
+ com.jiayue.biz.util.FileUtil.move(file.getPath(), eolFilePath + File.separator + eqId);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -1159,7 +1117,7 @@ public class AnalysisDataImpl {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
- windTowerDataParentTableService.packageData(dataList, eqNo, "", "eol", "");
|
|
|
+ windTowerDataParentTableService.packageData(dataList, eqNo, "eol", "");
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -1278,5 +1236,136 @@ public class AnalysisDataImpl {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * dat文件解析
|
|
|
+ */
|
|
|
+ public void parseByDat(File file) {
|
|
|
+ String dec = "D:\\in" + File.separator;
|
|
|
+ String fileName = file.getName();
|
|
|
+ File newFile = new File(file.getPath());
|
|
|
+ //修改后缀名 方便解析
|
|
|
+ if (fileName.contains(".dat")) {
|
|
|
+ String newFileName = fileName.substring(0, fileName.lastIndexOf(".")) + ".csv";
|
|
|
+ newFile = new File(dec + newFileName);
|
|
|
+ file.renameTo(newFile);
|
|
|
+ }
|
|
|
+ CsvReader reader = CsvUtil.getReader();
|
|
|
+ CsvData csvRows = reader.read(newFile);
|
|
|
+ List<CsvRow> rows = csvRows.getRows();
|
|
|
+ CsvRow rowsOne = rows.get(1);
|
|
|
+ CsvRow rowsF = rows.get(5);
|
|
|
+
|
|
|
+ StringBuilder height = new StringBuilder();
|
|
|
+ StringBuilder wdHeight = new StringBuilder();
|
|
|
+ WindTowerInfo windTowerInfo = new WindTowerInfo();
|
|
|
+ for (int i = rowsOne.size() - 1; i >= 0; i--) {
|
|
|
+ String wsOrWdOrTOrRhOrPa = getWsOrWdOrTOrRhOrPa(rowsOne.get(i), height, wdHeight, i, rowsF, windTowerInfo);
|
|
|
+ rowsOne.set(i, wsOrWdOrTOrRhOrPa);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<WindTowerInfo> equipmentNo = windTowerInfoService.getByEquipmentNo(windTowerInfo.getEquipmentNo());
|
|
|
+
|
|
|
+ if (equipmentNo.size() == 0) {
|
|
|
+ windTowerInfo.setHeights(height.toString());
|
|
|
+ windTowerInfo.setWdHeights(height.toString());
|
|
|
+ windTowerInfoService.saveOrUpdate(windTowerInfo);
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> mapList = parseByHead(rows, rowsOne);
|
|
|
+ List<Map<String, Object>> mapList1 = new CheckDataRecode().checkValue(mapList, "dat");
|
|
|
+ windTowerDataParentTableService.packageData(mapList1, windTowerInfo.getEquipmentNo(), "dat", "");
|
|
|
+ //将后缀名修改回来
|
|
|
+ String newFileName = fileName.substring(0, fileName.lastIndexOf(".")) + ".dat";
|
|
|
+ File file1 = new File(dec + newFileName);
|
|
|
+ newFile.renameTo(file1);
|
|
|
+ try {
|
|
|
+ com.jiayue.biz.util.FileUtil.move(file1.getPath(), eolFilePath + File.separator + windTowerInfo.getEquipmentNo());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("dat文件转移失败");
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Map<String, Object>> parseByHead(List<CsvRow> rows, CsvRow rowsOne) {
|
|
|
+ List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
+ for (int i = 4; i < rows.size(); i++) {
|
|
|
+ HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
+ for (int j = 0; j < rows.get(i).size(); j++) {
|
|
|
+ if (StrUtil.isNotBlank(rowsOne.get(j))) {
|
|
|
+ if (rowsOne.get(j).equals("time")) {
|
|
|
+ hashMap.put(rowsOne.get(j), rows.get(i).get(j));
|
|
|
+ } else {
|
|
|
+ hashMap.put(rowsOne.get(j), new BigDecimal(rows.get(i).get(j)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mapList.add(hashMap);
|
|
|
+ }
|
|
|
+ return mapList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public String getWsOrWdOrTOrRhOrPa(String attribute, StringBuilder wsHeight, StringBuilder wdHeight, int i, CsvRow rowsF, WindTowerInfo windTowerInfo) {
|
|
|
+ String str = "";
|
|
|
+ String height = "";
|
|
|
+ String avgOrStaOrMaxOrMin = getAvgOrStaOrMaxOrMin(attribute);
|
|
|
+ if (attribute.contains("TIMESTAMP")) {
|
|
|
+ str = "time";
|
|
|
+ } else if (attribute.contains("WS")) {
|
|
|
+ height = CalculationUtil.getNumberFromString(attribute);
|
|
|
+ if (wsHeight.toString().equals("")) {
|
|
|
+ wsHeight.append(height);
|
|
|
+ } else {
|
|
|
+ if (!wsHeight.toString().contains(height)) {
|
|
|
+ wsHeight.append(",").append(height);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "ws" + avgOrStaOrMaxOrMin + "_" + height;
|
|
|
+ } else if (attribute.contains("WD")) {
|
|
|
+ height = CalculationUtil.getNumberFromString(attribute);
|
|
|
+ if (wdHeight.toString().equals("")) {
|
|
|
+ wdHeight.append(height);
|
|
|
+ } else {
|
|
|
+ if (!wdHeight.toString().contains(height)) {
|
|
|
+ wdHeight.append(",").append(height);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "wd" + avgOrStaOrMaxOrMin + "_" + height;
|
|
|
+ } else if (attribute.contains("Ta")) {
|
|
|
+ str = "t";
|
|
|
+ } else if (attribute.contains("RH")) {
|
|
|
+ str = "rh";
|
|
|
+ } else if (attribute.contains("pa")) {
|
|
|
+ str = "pa";
|
|
|
+ } else if (attribute.contains("Station")) {
|
|
|
+ windTowerInfo.setEquipmentNo(rowsF.get(i));
|
|
|
+ } else if (attribute.equals("N")) {
|
|
|
+ windTowerInfo.setLatitude(new BigDecimal(rowsF.get(i)));
|
|
|
+ } else if (attribute.equals("E")) {
|
|
|
+ windTowerInfo.setLongitude(new BigDecimal(rowsF.get(i)));
|
|
|
+ } else {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ return str + avgOrStaOrMaxOrMin;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getAvgOrStaOrMaxOrMin(String attribute) {
|
|
|
+ String str = "";
|
|
|
+ if (attribute.contains("Batt") || attribute.contains("Minute")) {
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+ if (attribute.contains("Avg")) {
|
|
|
+ str = "Avg";
|
|
|
+ } else if (attribute.contains("Std")) {
|
|
|
+ str = "Sta";
|
|
|
+ } else if (attribute.contains("Max")) {
|
|
|
+ str = "Max";
|
|
|
+ } else if (attribute.contains("Min")) {
|
|
|
+ str = "Min";
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|