|
|
@@ -115,7 +115,7 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
Integer pointId = pointHierarchyListVo.getId();
|
|
|
log.info("测点id >>> " + pointId);
|
|
|
|
|
|
- List<DynamicMeasurementsVo> dynamicMeasurementsList = getDynamicMeasurementsList(pointId);
|
|
|
+ List<DynamicMeasurementsVo> dynamicMeasurementsList = getDynamicMeasurementsList(pointId, null);
|
|
|
if (CollectionUtil.isEmpty(dynamicMeasurementsList)) {
|
|
|
continue;
|
|
|
}
|
|
|
@@ -141,6 +141,8 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
*/
|
|
|
@Override
|
|
|
public void extracTwindGeneratorSkfPointData(String yesterdayDate) {
|
|
|
+
|
|
|
+ String yesterdayTimeNew = LocalDate.now().minusDays(1).format(DateTimeFormatter.ofPattern(dateFormatter));
|
|
|
// 获取组织结构
|
|
|
List<HierarchyListVo> hierarchyListVoList = getHierarchyLists();
|
|
|
log.info("获取SKF数据组织结构树 >>> " + JSON.toJSONString(hierarchyListVoList));
|
|
|
@@ -169,19 +171,65 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
Integer pointId = pointHierarchyListVo.getId();
|
|
|
log.info("测点id >>> " + pointId);
|
|
|
|
|
|
- List<DynamicMeasurementsVo> dynamicMeasurementsList = getDynamicMeasurementsList(pointId);
|
|
|
- if (CollectionUtil.isEmpty(dynamicMeasurementsList)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ // 时域幅值
|
|
|
+ List<DynamicMeasurementsVo> shiftList = getDynamicMeasurementsList(pointId, 1);
|
|
|
+
|
|
|
+ // 频谱幅值
|
|
|
+ List<DynamicMeasurementsVo> frequencyList = getDynamicMeasurementsList(pointId, 2);
|
|
|
+
|
|
|
+ // 频谱相位包络
|
|
|
+ List<DynamicMeasurementsVo> envelopeList = getDynamicMeasurementsList(pointId, 4);
|
|
|
+
|
|
|
+
|
|
|
// 拼接服务器地址
|
|
|
- String dataPath = skfDataPath + "/" + companyHierarchyListVo.getName() + "/" + fieldHierarchyListVo.getName() + "/"
|
|
|
- + engineHierarchyListVo.getName() + "/" + getCurrentYearByTimeZone(this.shanghaiZone) + "/"
|
|
|
- + yesterdayTime;
|
|
|
+ String dataPath = skfDataPath + "/" + companyHierarchyListVo.getName() + "/" + fieldHierarchyListVo.getName()
|
|
|
+ + "/" + getCurrentYearByTimeZone(this.shanghaiZone) + "/" + yesterdayTimeNew + "/" + engineHierarchyListVo.getName();
|
|
|
+ log.info(" dataPath 路径 ====> " + dataPath);
|
|
|
+
|
|
|
+
|
|
|
+ String fileName = null;
|
|
|
+ if (!CollectionUtil.isEmpty(shiftList)) {
|
|
|
+ fileName = dataPath + "/" + fieldHierarchyListVo.getName() + "@"
|
|
|
+ + engineHierarchyListVo.getName() + "@"
|
|
|
+ + pointId + "@"
|
|
|
+ + pointHierarchyListVo.getName() + "@1.json";
|
|
|
+ for (DynamicMeasurementsVo dynamicMeasurementsVo : shiftList) {
|
|
|
+// dynamicMeasurementsVo.setIncludeMeasurements(1);
|
|
|
+ dynamicMeasurementsVo.setPointName(pointHierarchyListVo.getName());
|
|
|
+ }
|
|
|
+ String json = JSON.toJSONString(shiftList);
|
|
|
+ FileUtil.writeString(json, new File(fileName), StandardCharsets.UTF_8);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!CollectionUtil.isEmpty(frequencyList)) {
|
|
|
+ fileName = dataPath + "/" + fieldHierarchyListVo.getName() + "@"
|
|
|
+ + engineHierarchyListVo.getName() + "@"
|
|
|
+ + pointId + "@"
|
|
|
+ + pointHierarchyListVo.getName() + "@2.json";
|
|
|
+ for (DynamicMeasurementsVo dynamicMeasurementsVo : frequencyList) {
|
|
|
+// dynamicMeasurementsVo.setIncludeMeasurements(2);
|
|
|
+ dynamicMeasurementsVo.setPointName(pointHierarchyListVo.getName());
|
|
|
+ }
|
|
|
+ String json = JSON.toJSONString(frequencyList);
|
|
|
+ FileUtil.writeString(json, new File(fileName), StandardCharsets.UTF_8);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!CollectionUtil.isEmpty(envelopeList)) {
|
|
|
+ fileName = dataPath + "/" + fieldHierarchyListVo.getName() + "@"
|
|
|
+ + engineHierarchyListVo.getName() + "@"
|
|
|
+ + pointId + "@"
|
|
|
+ + pointHierarchyListVo.getName() + "@4.json";
|
|
|
+ for (DynamicMeasurementsVo dynamicMeasurementsVo : envelopeList) {
|
|
|
+// dynamicMeasurementsVo.setIncludeMeasurements(4);
|
|
|
+ dynamicMeasurementsVo.setPointName(pointHierarchyListVo.getName());
|
|
|
+ }
|
|
|
+ String json = JSON.toJSONString(envelopeList);
|
|
|
+ FileUtil.writeString(json, new File(fileName), StandardCharsets.UTF_8);
|
|
|
+ }
|
|
|
|
|
|
- String fileNamePrefix = fieldHierarchyListVo.getName() + "@" + engineHierarchyListVo.getName() + "@" + pointId + "@" + pointHierarchyListVo.getName();
|
|
|
|
|
|
// 获取具体数据并生成csv
|
|
|
- dynamicMeasurementsConvertData(dynamicMeasurementsList, dataPath, fileNamePrefix);
|
|
|
+// dynamicMeasurementsConvertData(shiftList, dataPath, fileNamePrefix);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -266,7 +314,7 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
Integer pointId = pointHierarchyListVo.getId();
|
|
|
log.info("测点id >>> " + pointId);
|
|
|
|
|
|
- List<DynamicMeasurementsVo> dynamicMeasurementsList = getDynamicMeasurementsList(pointId);
|
|
|
+ List<DynamicMeasurementsVo> dynamicMeasurementsList = getDynamicMeasurementsList(pointId, null);
|
|
|
if (CollectionUtil.isEmpty(dynamicMeasurementsList)) {
|
|
|
continue;
|
|
|
}
|
|
|
@@ -301,13 +349,22 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
if (CollectionUtils.isEmpty(doubleList)) {
|
|
|
break dynamic;
|
|
|
}
|
|
|
- // 风场名称@风机名称@测点id@测点名称@转速@采样频率@震动类型时间_cms.csv
|
|
|
- String fileName = fileNamePrefix + "@" + dynamicMeasurementsVo.getSpeed() + "@" + dynamicMeasurementsVo.getSampleRate() + "@" + dynamicMeasurementsVo.getEUType() + "@" + utctolocal(dynamicMeasurementsVo.getReadingTimeUTC()) + "_cms.csv";
|
|
|
|
|
|
- // abcd.add("震动类型:" + dynamicMeasurementsVo.getEUType() + " 类型值: " + dynamicMeasurementsVo.getEu());
|
|
|
+
|
|
|
+ // 风场名称@风机名称@测点id@测点名称@转速@采样频率@测点工程单位@频谱的工程单位@频谱开始时间@频谱结束时间@普线数@震动类型时间_cms.csv
|
|
|
+ StringBuffer fileName = new StringBuffer();
|
|
|
+ fileName.append(fileNamePrefix).append("@")
|
|
|
+ .append(dynamicMeasurementsVo.getSpeed()).append("@")
|
|
|
+ .append(dynamicMeasurementsVo.getSampleRate()).append("@")
|
|
|
+ .append(dynamicMeasurementsVo.getEUType()).append("@")
|
|
|
+ .append(dynamicMeasurementsVo.getEUSpectrum()).append("@")
|
|
|
+ .append(dynamicMeasurementsVo.getStartFrequency()).append("@")
|
|
|
+ .append(dynamicMeasurementsVo.getEndFrequency()).append("@")
|
|
|
+ .append(dynamicMeasurementsVo.getSamples()).append("@")
|
|
|
+ .append(utctolocal(dynamicMeasurementsVo.getReadingTimeUTC())).append("@").append("_cms.csv");
|
|
|
|
|
|
//生成csv文件
|
|
|
- createCsvFile(doubleList, dataPath, fileName);
|
|
|
+ createCsvFile(doubleList, dataPath, fileName.toString());
|
|
|
log.info("抽取skf数据并生成csv文件 >>>> " + fileName);
|
|
|
}
|
|
|
}
|
|
|
@@ -318,7 +375,7 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
* @param pointId
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<DynamicMeasurementsVo> getDynamicMeasurementsList(Integer pointId) {
|
|
|
+ private List<DynamicMeasurementsVo> getDynamicMeasurementsList(Integer pointId, Integer includeMeasurements) {
|
|
|
// 获取开始的时间
|
|
|
String fromDateUTC = LocalDate.now().minusDays(1).format(DateTimeFormatter.ofPattern(dateTimeFormatter));
|
|
|
// 获取结束的时间,当前时间
|
|
|
@@ -336,6 +393,11 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("fromDateUTC", fromDateUTC);
|
|
|
params.put("toDateUTC", toDateUTC);
|
|
|
+ if (includeMeasurements != null) {
|
|
|
+ params.put("includeMeasurements", includeMeasurements);
|
|
|
+ }
|
|
|
+ params.put("includeMeasurements", includeMeasurements);
|
|
|
+ params.put("descending", true);
|
|
|
|
|
|
//发送请求
|
|
|
HttpResult result = HttpGetClient.sendWithAuthAndParams(url, skfToken, params);
|
|
|
@@ -343,7 +405,7 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
// 处理响应结果
|
|
|
if (result.isSuccess()) {
|
|
|
log.info("请求成功,状态码: " + result.getStatusCode());
|
|
|
- result.getData().ifPresent(data -> System.out.println("响应内容: " + data));
|
|
|
+ result.getData().ifPresent(data -> log.info("测点振动数据响应内容: " + data));
|
|
|
lists = JSONArray.parseArray(result.getData().get(), DynamicMeasurementsVo.class);
|
|
|
return lists;
|
|
|
} else {
|
|
|
@@ -434,6 +496,9 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
}
|
|
|
//构造文件
|
|
|
String fullPath = path + "/" + fileName;
|
|
|
+
|
|
|
+ log.info("fullPath 路径 ====>" + fullPath);
|
|
|
+
|
|
|
File csvFile = new File(fullPath);
|
|
|
//导入HuTool中CSV工具包的CsvWriter类,设置导出字符类型, CHARSET_UTF_8
|
|
|
CsvWriter writer = CsvUtil.getWriter(csvFile, CharsetUtil.CHARSET_UTF_8);
|