|
|
|
|
@ -524,14 +524,15 @@ public class RecordIotenvInstantServiceImpl implements IRecordIotenvInstantServi
|
|
|
|
|
*
|
|
|
|
|
* @param recordIotenvInstant 物联网数据
|
|
|
|
|
* @param monitorTypes 设备类型集合
|
|
|
|
|
* @param vibrationParam 振动参数(振动设备可选择单个参数导出)
|
|
|
|
|
* @return 过滤后的物联网数据集合
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<RecordIotenvInstant> selectRecordIotenvInstantListForExportWithFilter(RecordIotenvInstant recordIotenvInstant, Set<Integer> monitorTypes) throws ParseException {
|
|
|
|
|
public List<RecordIotenvInstant> selectRecordIotenvInstantListForExportWithFilter(RecordIotenvInstant recordIotenvInstant, Set<Integer> monitorTypes, String vibrationParam) throws ParseException {
|
|
|
|
|
// 先查询原始数据
|
|
|
|
|
List<RecordIotenvInstant> list = selectRecordIotenvInstantListForExport(recordIotenvInstant);
|
|
|
|
|
// 根据设备类型过滤无效数据
|
|
|
|
|
return filterInvalidData(list, monitorTypes);
|
|
|
|
|
return filterInvalidData(list, monitorTypes, vibrationParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -540,11 +541,14 @@ public class RecordIotenvInstantServiceImpl implements IRecordIotenvInstantServi
|
|
|
|
|
* type=5: 温度设备 -> 设备编号、设备名称、温度、记录时间
|
|
|
|
|
* type=6: 温湿度设备 -> 设备编号、设备名称、温度、湿度、记录时间
|
|
|
|
|
* type=7: 噪声设备 -> 设备编号、设备名称、噪声、记录时间
|
|
|
|
|
* type=10: 振动设备 -> 设备编号、设备名称、振动速度、振动位移、振动加速度、振动温度、记录时间
|
|
|
|
|
* type=10: 振动设备 -> 若指定vibrationParam则只导出该参数,否则导出全部振动参数
|
|
|
|
|
* 混合类型: 导出所有列
|
|
|
|
|
*
|
|
|
|
|
* @param monitorTypes 设备类型集合
|
|
|
|
|
* @param vibrationParam 振动参数(振动设备可选择单个参数导出:vibrationSpeed/vibrationDisplacement/vibrationAcceleration/vibrationTemp)
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String[] getExportColumnsByType(Set<Integer> monitorTypes) {
|
|
|
|
|
public String[] getExportColumnsByType(Set<Integer> monitorTypes, String vibrationParam) {
|
|
|
|
|
List<String> columns = new ArrayList<>();
|
|
|
|
|
// 固定列:设备编号、设备名称
|
|
|
|
|
columns.add("monitorCode");
|
|
|
|
|
@ -573,11 +577,15 @@ public class RecordIotenvInstantServiceImpl implements IRecordIotenvInstantServi
|
|
|
|
|
case 7: // 噪声设备
|
|
|
|
|
columns.add("noise");
|
|
|
|
|
break;
|
|
|
|
|
case 10: // 振动设备
|
|
|
|
|
columns.add("vibrationSpeed");
|
|
|
|
|
columns.add("vibrationDisplacement");
|
|
|
|
|
columns.add("vibrationAcceleration");
|
|
|
|
|
columns.add("vibrationTemp");
|
|
|
|
|
case 10: // 振动设备:若指定vibrationParam则只导出该参数
|
|
|
|
|
if (vibrationParam != null && !vibrationParam.isEmpty()) {
|
|
|
|
|
columns.add(vibrationParam);
|
|
|
|
|
} else {
|
|
|
|
|
columns.add("vibrationSpeed");
|
|
|
|
|
columns.add("vibrationDisplacement");
|
|
|
|
|
columns.add("vibrationAcceleration");
|
|
|
|
|
columns.add("vibrationTemp");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
// 其他类型:导出所有列
|
|
|
|
|
@ -600,12 +608,14 @@ public class RecordIotenvInstantServiceImpl implements IRecordIotenvInstantServi
|
|
|
|
|
/**
|
|
|
|
|
* 根据设备类型过滤无效数据
|
|
|
|
|
* 过滤规则(使用OR关系,满足任一类型的有效性即保留):
|
|
|
|
|
* 1. 温度设备(type=5):温度>0且<=79
|
|
|
|
|
* 2. 温湿度设备(type=6):温度或湿度任一>0且<=79
|
|
|
|
|
* 3. 噪声设备(type=7):噪声>0且<=79
|
|
|
|
|
* 4. 振动设备(type=10):振动相关字段任一>0
|
|
|
|
|
* 1. 温度设备(type=5):温度>0且<80
|
|
|
|
|
* 2. 温湿度设备(type=6):温度或湿度任一>0且<80
|
|
|
|
|
* 3. 噪声设备(type=7):噪声>0且<80
|
|
|
|
|
* 4. 振动设备(type=10):若指定vibrationParam则只过滤该参数,否则振动相关字段任一>0且<80
|
|
|
|
|
*
|
|
|
|
|
* @param vibrationParam 振动参数(振动设备可选择单个参数过滤)
|
|
|
|
|
*/
|
|
|
|
|
private List<RecordIotenvInstant> filterInvalidData(List<RecordIotenvInstant> list, Set<Integer> monitorTypes) {
|
|
|
|
|
private List<RecordIotenvInstant> filterInvalidData(List<RecordIotenvInstant> list, Set<Integer> monitorTypes, String vibrationParam) {
|
|
|
|
|
if (monitorTypes.isEmpty()) {
|
|
|
|
|
// 未指定类型时,保留有任何有效数据的记录
|
|
|
|
|
return list.stream().filter(this::hasValidData).collect(Collectors.toList());
|
|
|
|
|
@ -614,6 +624,10 @@ public class RecordIotenvInstantServiceImpl implements IRecordIotenvInstantServi
|
|
|
|
|
// 单一类型:严格按该类型过滤
|
|
|
|
|
if (monitorTypes.size() == 1) {
|
|
|
|
|
Integer type = monitorTypes.iterator().next();
|
|
|
|
|
// 振动设备且指定了单个参数时,只过滤该参数
|
|
|
|
|
if (type == 10 && vibrationParam != null && !vibrationParam.isEmpty()) {
|
|
|
|
|
return list.stream().filter(record -> isValidVibrationParam(record, vibrationParam)).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
return list.stream().filter(record -> isValidForType(record, type)).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -628,6 +642,28 @@ public class RecordIotenvInstantServiceImpl implements IRecordIotenvInstantServi
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 判断指定振动参数是否有效:>0且<80 */
|
|
|
|
|
private boolean isValidVibrationParam(RecordIotenvInstant record, String vibrationParam) {
|
|
|
|
|
BigDecimal value = null;
|
|
|
|
|
switch (vibrationParam) {
|
|
|
|
|
case "vibrationSpeed":
|
|
|
|
|
value = record.getVibrationSpeed();
|
|
|
|
|
break;
|
|
|
|
|
case "vibrationDisplacement":
|
|
|
|
|
value = record.getVibrationDisplacement();
|
|
|
|
|
break;
|
|
|
|
|
case "vibrationAcceleration":
|
|
|
|
|
value = record.getVibrationAcceleration();
|
|
|
|
|
break;
|
|
|
|
|
case "vibrationTemp":
|
|
|
|
|
value = record.getVibrationTemp();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return value != null && value.compareTo(BigDecimal.ZERO) > 0 && value.compareTo(new BigDecimal("80")) < 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 判断记录对于指定类型是否有效 */
|
|
|
|
|
private boolean isValidForType(RecordIotenvInstant record, Integer type) {
|
|
|
|
|
switch (type) {
|
|
|
|
|
@ -659,12 +695,18 @@ public class RecordIotenvInstantServiceImpl implements IRecordIotenvInstantServi
|
|
|
|
|
return noise != null && noise.compareTo(BigDecimal.ZERO) > 0 && noise.compareTo(new BigDecimal("79")) <= 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 判断是否有有效的振动数据 */
|
|
|
|
|
/** 判断是否有有效的振动数据:>0且<80 */
|
|
|
|
|
private boolean hasValidVibrationData(RecordIotenvInstant record) {
|
|
|
|
|
return (record.getVibrationSpeed() != null && record.getVibrationSpeed().compareTo(BigDecimal.ZERO) > 0) ||
|
|
|
|
|
(record.getVibrationDisplacement() != null && record.getVibrationDisplacement().compareTo(BigDecimal.ZERO) > 0) ||
|
|
|
|
|
(record.getVibrationAcceleration() != null && record.getVibrationAcceleration().compareTo(BigDecimal.ZERO) > 0) ||
|
|
|
|
|
(record.getVibrationTemp() != null && record.getVibrationTemp().compareTo(BigDecimal.ZERO) > 0);
|
|
|
|
|
BigDecimal upperLimit = new BigDecimal("80");
|
|
|
|
|
return isValidVibrationValue(record.getVibrationSpeed(), upperLimit) ||
|
|
|
|
|
isValidVibrationValue(record.getVibrationDisplacement(), upperLimit) ||
|
|
|
|
|
isValidVibrationValue(record.getVibrationAcceleration(), upperLimit) ||
|
|
|
|
|
isValidVibrationValue(record.getVibrationTemp(), upperLimit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 判断振动值是否有效:>0且<80 */
|
|
|
|
|
private boolean isValidVibrationValue(BigDecimal value, BigDecimal upperLimit) {
|
|
|
|
|
return value != null && value.compareTo(BigDecimal.ZERO) > 0 && value.compareTo(upperLimit) < 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 判断记录是否有任何有效数据 */
|
|
|
|
|
|