|
@@ -30,10 +30,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
-import java.time.LocalDate;
|
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
|
|
-import java.time.Month;
|
|
|
|
|
-import java.time.ZoneId;
|
|
|
|
|
|
|
+import java.time.*;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.format.TextStyle;
|
|
import java.time.format.TextStyle;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -55,7 +52,7 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
// 定义时间格式
|
|
// 定义时间格式
|
|
|
private final String dateTimeFormatter = "yyyy-MM-dd";
|
|
private final String dateTimeFormatter = "yyyy-MM-dd";
|
|
|
|
|
|
|
|
- private final String dateFormatter = "MM-dd";
|
|
|
|
|
|
|
+ private final String dateFormatter = "MMdd";
|
|
|
|
|
|
|
|
@Value("${skf.data.url}")
|
|
@Value("${skf.data.url}")
|
|
|
private String dynamicMeasurementsUrl;
|
|
private String dynamicMeasurementsUrl;
|
|
@@ -73,7 +70,6 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
@Value("${skf.data.condition}")
|
|
@Value("${skf.data.condition}")
|
|
|
private String condition;
|
|
private String condition;
|
|
|
|
|
|
|
|
- private List<String> abcd = Lists.newArrayList();
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 通过skf接口获取树结构(带部件)
|
|
* 通过skf接口获取树结构(带部件)
|
|
@@ -147,6 +143,8 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
List<HierarchyListVo> hierarchyListVoList = getHierarchyLists();
|
|
List<HierarchyListVo> hierarchyListVoList = getHierarchyLists();
|
|
|
log.info("获取SKF数据组织结构树 >>> " + JSON.toJSONString(hierarchyListVoList));
|
|
log.info("获取SKF数据组织结构树 >>> " + JSON.toJSONString(hierarchyListVoList));
|
|
|
|
|
|
|
|
|
|
+ // 获取当前小时数
|
|
|
|
|
+// int hour = ZonedDateTime.now(ZoneId.of("Asia/Shanghai")).minusHours(1).getHour();
|
|
|
// 企业
|
|
// 企业
|
|
|
company:
|
|
company:
|
|
|
for (HierarchyListVo companyHierarchyListVo : hierarchyListVoList) {
|
|
for (HierarchyListVo companyHierarchyListVo : hierarchyListVoList) {
|
|
@@ -180,12 +178,18 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
// 频谱相位包络
|
|
// 频谱相位包络
|
|
|
List<DynamicMeasurementsVo> envelopeList = getDynamicMeasurementsList(pointId, 4);
|
|
List<DynamicMeasurementsVo> envelopeList = getDynamicMeasurementsList(pointId, 4);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
// 拼接服务器地址
|
|
// 拼接服务器地址
|
|
|
- String dataPath = skfDataPath + "/" + companyHierarchyListVo.getName() + "/" + fieldHierarchyListVo.getName()
|
|
|
|
|
- + "/" + getCurrentYearByTimeZone(this.shanghaiZone) + "/" + yesterdayTimeNew + "/" + engineHierarchyListVo.getName();
|
|
|
|
|
- log.info(" dataPath 路径 ====> " + dataPath);
|
|
|
|
|
|
|
+ String dataPath = null;
|
|
|
|
|
+
|
|
|
|
|
+ dataPath = skfDataPath + "/" + companyHierarchyListVo.getName() + "/" + fieldHierarchyListVo.getName()
|
|
|
|
|
+ + "/" + getCurrentYearByTimeZone(this.shanghaiZone) + "/" + yesterdayTimeNew + "/"
|
|
|
|
|
+ + engineHierarchyListVo.getName();
|
|
|
|
|
|
|
|
|
|
+// dataPath = skfDataPath + "/" + companyHierarchyListVo.getName() + "/" + fieldHierarchyListVo.getName()
|
|
|
|
|
+// + "/" + getCurrentYearByTimeZone(this.shanghaiZone) + "/" + yesterdayTimeNew + "/" + hour
|
|
|
|
|
+// + "/"+ engineHierarchyListVo.getName();
|
|
|
|
|
+
|
|
|
|
|
+ log.info(" dataPath 路径 ====> " + dataPath);
|
|
|
|
|
|
|
|
String fileName = null;
|
|
String fileName = null;
|
|
|
if (!CollectionUtil.isEmpty(shiftList)) {
|
|
if (!CollectionUtil.isEmpty(shiftList)) {
|
|
@@ -227,9 +231,8 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
FileUtil.writeString(json, new File(fileName), StandardCharsets.UTF_8);
|
|
FileUtil.writeString(json, new File(fileName), StandardCharsets.UTF_8);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
// 获取具体数据并生成csv
|
|
// 获取具体数据并生成csv
|
|
|
-// dynamicMeasurementsConvertData(shiftList, dataPath, fileNamePrefix);
|
|
|
|
|
|
|
+ // dynamicMeasurementsConvertData(shiftList, dataPath, fileNamePrefix);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -239,6 +242,7 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
StringBuffer keyBuffer = new StringBuffer(ManagerRedisKeyConstant.SKF_SHAKE_KEY);
|
|
StringBuffer keyBuffer = new StringBuffer(ManagerRedisKeyConstant.SKF_SHAKE_KEY);
|
|
|
keyBuffer.append(ManagerRedisKeyConstant.PLACEHOLDER);
|
|
keyBuffer.append(ManagerRedisKeyConstant.PLACEHOLDER);
|
|
|
keyBuffer.append(yesterdayDate);
|
|
keyBuffer.append(yesterdayDate);
|
|
|
|
|
+// keyBuffer.append(hour);
|
|
|
cacheService.add(keyBuffer.toString(), "1");
|
|
cacheService.add(keyBuffer.toString(), "1");
|
|
|
|
|
|
|
|
log.info(" >>> skf接口处理完毕 <<<");
|
|
log.info(" >>> skf接口处理完毕 <<<");
|
|
@@ -350,7 +354,6 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
break dynamic;
|
|
break dynamic;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
// 风场名称@风机名称@测点id@测点名称@转速@采样频率@测点工程单位@频谱的工程单位@频谱开始时间@频谱结束时间@普线数@震动类型时间_cms.csv
|
|
// 风场名称@风机名称@测点id@测点名称@转速@采样频率@测点工程单位@频谱的工程单位@频谱开始时间@频谱结束时间@普线数@震动类型时间_cms.csv
|
|
|
StringBuffer fileName = new StringBuffer();
|
|
StringBuffer fileName = new StringBuffer();
|
|
|
fileName.append(fileNamePrefix).append("@")
|
|
fileName.append(fileNamePrefix).append("@")
|
|
@@ -377,9 +380,25 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
*/
|
|
*/
|
|
|
private List<DynamicMeasurementsVo> getDynamicMeasurementsList(Integer pointId, Integer includeMeasurements) {
|
|
private List<DynamicMeasurementsVo> getDynamicMeasurementsList(Integer pointId, Integer includeMeasurements) {
|
|
|
// 获取开始的时间
|
|
// 获取开始的时间
|
|
|
- String fromDateUTC = LocalDate.now().minusDays(1).format(DateTimeFormatter.ofPattern(dateTimeFormatter));
|
|
|
|
|
|
|
+ String fromDateUTC = null;
|
|
|
// 获取结束的时间,当前时间
|
|
// 获取结束的时间,当前时间
|
|
|
- String toDateUTC = LocalDate.now().format(DateTimeFormatter.ofPattern(dateTimeFormatter));
|
|
|
|
|
|
|
+ String toDateUTC = null;
|
|
|
|
|
+
|
|
|
|
|
+ // 获取结束的时间,当前时间 now(ZoneId.of("UTC"))
|
|
|
|
|
+ fromDateUTC = "2026-04-15"; //LocalDate.now().minusDays(1).format(DateTimeFormatter.ofPattern(dateTimeFormatter));
|
|
|
|
|
+ toDateUTC = "2026-04-16"; //LocalDate.now().format(DateTimeFormatter.ofPattern(dateTimeFormatter));
|
|
|
|
|
+
|
|
|
|
|
+// // 带时区(中国时区)
|
|
|
|
|
+// LocalDate now = LocalDate.now();
|
|
|
|
|
+// // 获取上一个小时数
|
|
|
|
|
+// int lastHour = ZonedDateTime.now(ZoneId.of("Asia/Shanghai")).minusHours(1).getHour();
|
|
|
|
|
+// // 定义格式化规则:年-月-日
|
|
|
|
|
+// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
+// // 格式化日期
|
|
|
|
|
+// String currentDate = now.format(formatter);
|
|
|
|
|
+//
|
|
|
|
|
+// fromDateUTC = currentDate + " " + lastHour+":00:00";
|
|
|
|
|
+// toDateUTC = currentDate + " " + lastHour+":59:59";
|
|
|
|
|
|
|
|
String skfToken = getSkfAutoToken();
|
|
String skfToken = getSkfAutoToken();
|
|
|
if (StringUtils.isEmpty(skfToken)) {
|
|
if (StringUtils.isEmpty(skfToken)) {
|
|
@@ -586,4 +605,6 @@ public class VibrationServiceImpl implements VibrationService {
|
|
|
return dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
return dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|