Commit 771b4c4c authored by 高建强's avatar 高建强

item:稳压泵指标统计业务优化

parent bdfee22a
...@@ -21,6 +21,7 @@ public enum PressurePumpRelateEnum { ...@@ -21,6 +21,7 @@ public enum PressurePumpRelateEnum {
PIPE_PRESSURE_ABNORMAL_STATUS("异常", "稳压泵管网压力异常状态"), PIPE_PRESSURE_ABNORMAL_STATUS("异常", "稳压泵管网压力异常状态"),
START("1", "稳压泵启动"), START("1", "稳压泵启动"),
STOP("0", "稳压泵停止"), STOP("0", "稳压泵停止"),
CREATED_TIME("createdTime", "物联采集信号创建时间属性"),
UN_CLEAN_TIME("false", "未消除"); UN_CLEAN_TIME("false", "未消除");
private final String value; private final String value;
......
...@@ -590,7 +590,7 @@ public class EmergencyController extends AbstractBaseController { ...@@ -590,7 +590,7 @@ public class EmergencyController extends AbstractBaseController {
} }
} }
} }
return CommonResponseUtil.success(iEmergencyService.getPressurePumpStatusChart(equipmentCode, startTime, endTime, bizOrgCode, getAppKey(), getProduct(), getToken())); return CommonResponseUtil.success(iEmergencyService.getPressurePumpStatusChart(startTime, endTime, bizOrgCode, getAppKey(), getProduct(), getToken()));
} }
@PersonIdentify @PersonIdentify
...@@ -609,7 +609,7 @@ public class EmergencyController extends AbstractBaseController { ...@@ -609,7 +609,7 @@ public class EmergencyController extends AbstractBaseController {
} }
} }
} }
return CommonResponseUtil.success(iEmergencyService.getPressurePumpDiagnosticAnalysis(equipmentCode, nameKeys, fieldKey, bizOrgCode, getAppKey(), getProduct(), getToken())); return CommonResponseUtil.success(iEmergencyService.getPressurePumpDiagnosticAnalysis(nameKeys, fieldKey, bizOrgCode, getAppKey(), getProduct(), getToken()));
} }
@PersonIdentify @PersonIdentify
......
...@@ -54,9 +54,9 @@ public interface IEmergencyService { ...@@ -54,9 +54,9 @@ public interface IEmergencyService {
Map<String, Integer> getStockEquipStatistics(); Map<String, Integer> getStockEquipStatistics();
Map<String, Object> getPressurePumpStatusChart(String equipmentCode, String startTime, String endTime, String bizOrgCode, String appKey, String product, String token); Map<String, Object> getPressurePumpStatusChart(String startTime, String endTime, String bizOrgCode, String appKey, String product, String token);
List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String equipmentCode, String nameKeys, String fieldKey, String bizOrgCode, String appKey, String product, String token); List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String nameKeys, String fieldKey, String bizOrgCode, String appKey, String product, String token);
double getPressurePumpIntervalTime(String prefix, String appKey, String product, String token); double getPressurePumpIntervalTime(String prefix, String appKey, String product, String token);
......
...@@ -228,7 +228,7 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -228,7 +228,7 @@ public class EmergencyServiceImpl implements IEmergencyService {
} }
@Override @Override
public List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String equipmentCode1, String nameKeys, String fieldKey, String bizOrgCode, String appKey, String product, String token) { public List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String nameKeys, String fieldKey, String bizOrgCode, String appKey, String product, String token) {
PressurePumpAnalysisEnum[] values = PressurePumpAnalysisEnum.values(); PressurePumpAnalysisEnum[] values = PressurePumpAnalysisEnum.values();
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
for (PressurePumpAnalysisEnum value : values) { for (PressurePumpAnalysisEnum value : values) {
...@@ -302,25 +302,28 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -302,25 +302,28 @@ public class EmergencyServiceImpl implements IEmergencyService {
} }
@Override @Override
public Map<String, Object> getPressurePumpStatusChart(String equipmentCode, String startTime, String endTime, String bizOrgCode, String appKey, String product, String token) { public Map<String, Object> getPressurePumpStatusChart(String startTime, String endTime, String bizOrgCode, String appKey, String product, String token) {
Map<String, Object> map = new LinkedHashMap<>(); Map<String, Object> map = new LinkedHashMap<>();
try { try {
// 获取稳压泵 // 从 json 配置文件获取配置信息
List<Map<String, Object>> list = equipmentSpecificSerivce.getListByEquipmentCode(equipmentCode, bizOrgCode); List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue());
// 获取各稳压泵数据,及时间戳 if (!CollectionUtils.isEmpty(infoList)) {
if (!CollectionUtils.isEmpty(list)) { Map infoMap = infoList.get(0);
// 获取查询时间范围内的时间戳 String equipmentCode = infoMap.get("equipmentCode").toString();
List<String> timeHourList = DateUtils.getTimeStrListByStartAndEnd(startTime, endTime, DateUtils.MONTH_DAY_HOUR_MINUTE_PATTERN); // 获取稳压泵
Set<String> timeSet = new LinkedHashSet<>(); List<Map<String, Object>> list = equipmentSpecificSerivce.getListByEquipmentCode(equipmentCode, bizOrgCode);
List<Map<String, Object>> yData = new ArrayList<>(); // 获取各稳压泵数据,及时间戳
LinkedHashMap<String, List<Map<String, String>>> dataListMap = new LinkedHashMap<>(); if (!CollectionUtils.isEmpty(list)) {
for (Map<String, Object> x : list) { // 获取查询时间范围内的时间戳
Object iotCode = x.get("iotCode"); List<String> timeHourList = DateUtils.getTimeStrListByStartAndEnd(startTime, endTime, DateUtils.MONTH_DAY_HOUR_MINUTE_PATTERN);
if (iotCode != null) { Set<String> timeSet = new LinkedHashSet<>();
// 判断开始时间,是否在redis缓存有效期之内,是,redis获取数据,否则,iot获取数据 List<Map<String, Object>> yData = new ArrayList<>();
List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue()); LinkedHashMap<String, List<Map<String, String>>> dataListMap = new LinkedHashMap<>();
if (!CollectionUtils.isEmpty(infoList)) { for (Map<String, Object> x : list) {
int expire = Integer.parseInt(infoList.get(0).get("expire").toString()) * -1; Object iotCode = x.get("iotCode");
if (iotCode != null) {
// 判断开始时间,是否在redis缓存有效期之内,是,redis获取数据,否则,iot获取数据
int expire = Integer.parseInt(infoMap.get("expire").toString()) * -1;
Date dateNow = DateUtils.getDateNow(); Date dateNow = DateUtils.getDateNow();
Date beforeDate = DateUtils.dateAddSeconds(dateNow, expire); Date beforeDate = DateUtils.dateAddSeconds(dateNow, expire);
Date startDate = DateUtils.convertStrToDate(startTime, DateUtils.DATE_TIME_PATTERN); Date startDate = DateUtils.convertStrToDate(startTime, DateUtils.DATE_TIME_PATTERN);
...@@ -334,7 +337,7 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -334,7 +337,7 @@ public class EmergencyServiceImpl implements IEmergencyService {
timeSet.add(y.getCreatedTime()); timeSet.add(y.getCreatedTime());
Map<String, String> xMap = new HashMap<>(); Map<String, String> xMap = new HashMap<>();
xMap.put(pressurePumpStart, y.getValue().toString()); xMap.put(pressurePumpStart, y.getValue().toString());
xMap.put("createdTime", y.getCreatedTime()); xMap.put(PressurePumpRelateEnum.CREATED_TIME.getValue(), y.getCreatedTime());
dataList.add(xMap); dataList.add(xMap);
}); });
dataListMap.put(iotCode.toString(), dataList); dataListMap.put(iotCode.toString(), dataList);
...@@ -344,65 +347,65 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -344,65 +347,65 @@ public class EmergencyServiceImpl implements IEmergencyService {
String prefix = iotCode.toString().substring(0, 8); String prefix = iotCode.toString().substring(0, 8);
String suffix = iotCode.toString().substring(8); String suffix = iotCode.toString().substring(8);
List<Map<String, String>> dataList = pressurePumpService.getIotCommonListData(startTime, endTime, prefix, suffix, null, pressurePumpStart); List<Map<String, String>> dataList = pressurePumpService.getIotCommonListData(startTime, endTime, prefix, suffix, null, pressurePumpStart);
dataList.forEach(z -> timeSet.add(z.get("createdTime"))); dataList.forEach(z -> timeSet.add(z.get(PressurePumpRelateEnum.CREATED_TIME.getValue())));
dataListMap.put(iotCode.toString(), dataList); dataListMap.put(iotCode.toString(), dataList);
} }
} }
} }
} // 数据时间排序
// 数据时间排序 List<String> sortTimeList = new ArrayList<>(timeSet);
List<String> sortTimeList = new ArrayList<>(timeSet); Collections.sort(sortTimeList);
Collections.sort(sortTimeList); // 数据时间截取,MM-dd HH:mm
// 数据时间截取,MM-dd HH:mm // List<String> sortTimeCollectList = sortTimeList.stream().map(x -> DateUtils.dateFormat(DateUtils.convertStrToDate(x, DateUtils.DATE_TIME_PATTERN),DateUtils.MONTH_DAY_HOUR_MINUTE_PATTERN)).collect(Collectors.toList());
// List<String> sortTimeCollectList = sortTimeList.stream().map(x -> DateUtils.dateFormat(DateUtils.convertStrToDate(x, DateUtils.DATE_TIME_PATTERN),DateUtils.MONTH_DAY_HOUR_MINUTE_PATTERN)).collect(Collectors.toList()); List<String> sortTimeCollectList = sortTimeList.stream().map(x -> x.substring(5, x.length() - 3)).collect(Collectors.toList());
List<String> sortTimeCollectList = sortTimeList.stream().map(x -> x.substring(5, x.length() - 3)).collect(Collectors.toList()); // 数据时间截取,MM-dd HH
// 数据时间截取,MM-dd HH List<String> sortTimeTmpCollectList = sortTimeList.stream().map(x -> x.substring(5, x.length() - 6)).collect(Collectors.toList());
List<String> sortTimeTmpCollectList = sortTimeList.stream().map(x -> x.substring(5, x.length() - 6)).collect(Collectors.toList()); // 组装x时间轴数据
// 组装x时间轴数据 List<String> timeList = new ArrayList<>();
List<String> timeList = new ArrayList<>(); timeHourList.forEach(t -> {
timeHourList.forEach(t -> { String strTime = t.substring(0, t.length() - 3);
String strTime = t.substring(0, t.length() - 3); if (sortTimeCollectList.contains(t)) {
if (sortTimeCollectList.contains(t)) { timeList.add(t);
timeList.add(t); } else if (!sortTimeTmpCollectList.contains(strTime)) {
} else if (!sortTimeTmpCollectList.contains(strTime)) { timeList.add(strTime + ":00");
timeList.add(strTime + ":00"); sortTimeTmpCollectList.add(strTime);
sortTimeTmpCollectList.add(strTime); }
} });
}); // 遍历稳压泵,dataListMap获取各稳压泵数据,没有数据的进行补0
// 遍历稳压泵,dataListMap获取各稳压泵数据,没有数据的进行补0 list.forEach(x -> {
list.forEach(x -> { Map<String, Object> yMap = new HashMap<>();
Map<String, Object> yMap = new HashMap<>(); List<Integer> yList = new ArrayList<>();
List<Integer> yList = new ArrayList<>(); String name = x.get("name").toString();
String name = x.get("name").toString(); yMap.put("name", name);
yMap.put("name", name); Object iotCode = x.get("iotCode");
Object iotCode = x.get("iotCode"); if (x.get("iotCode") != null) {
if (x.get("iotCode") != null) { List<Map<String, String>> dataList = dataListMap.get(iotCode.toString());
List<Map<String, String>> dataList = dataListMap.get(iotCode.toString()); if (!CollectionUtils.isEmpty(dataList)) {
if (!CollectionUtils.isEmpty(dataList)) { Collections.reverse(dataList);
Collections.reverse(dataList); Map<String, List<Map<String, String>>> dataMap = dataList.stream().filter(y -> y.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue())).collect(Collectors.groupingBy(e -> e.get("createdTime").substring(5, 16)));
Map<String, List<Map<String, String>>> dataMap = dataList.stream().filter(y -> y.containsKey("createdTime")).collect(Collectors.groupingBy(e -> e.get("createdTime").substring(5, 16))); List<Map<String, String>> yDataList = null;
List<Map<String, String>> yDataList = null; for (String t : timeList) {
for (String t : timeList) { List<Map<String, String>> data = dataMap.get(t);
List<Map<String, String>> data = dataMap.get(t); if (!CollectionUtils.isEmpty(data)) {
if (!CollectionUtils.isEmpty(data)) { yDataList = data.stream().filter(o -> PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(o.get(pressurePumpStart))).collect(Collectors.toList());
yDataList = data.stream().filter(o -> PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(o.get(pressurePumpStart))).collect(Collectors.toList()); String flag = data.get(data.size() - 1).get(pressurePumpStart);
String flag = data.get(data.size() - 1).get(pressurePumpStart); yList.add(!CollectionUtils.isEmpty(yDataList) ? Integer.parseInt(PressurePumpRelateEnum.START.getValue()) : PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(flag) ? Integer.parseInt(PressurePumpRelateEnum.START.getValue()): Integer.parseInt(PressurePumpRelateEnum.STOP.getValue()));
yList.add(!CollectionUtils.isEmpty(yDataList) ? Integer.parseInt(PressurePumpRelateEnum.START.getValue()) : PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(flag) ? Integer.parseInt(PressurePumpRelateEnum.START.getValue()): Integer.parseInt(PressurePumpRelateEnum.STOP.getValue())); } else {
} else { yList.add(Integer.parseInt(PressurePumpRelateEnum.STOP.getValue()));
yList.add(Integer.parseInt(PressurePumpRelateEnum.STOP.getValue())); }
} }
} else {
timeList.forEach(t -> {
yList.add(Integer.parseInt(PressurePumpRelateEnum.STOP.getValue()));
});
} }
} else { yMap.put("data", yList);
timeList.forEach(t -> { yData.add(yMap);
yList.add(Integer.parseInt(PressurePumpRelateEnum.STOP.getValue()));
});
} }
yMap.put("data", yList); });
yData.add(yMap); map.put("xData", timeList);
} map.put("yData", yData);
}); }
map.put("xData", timeList);
map.put("yData", yData);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("getPressurePumpStatusChart-->获取稳压泵启停状态图失败:{}", e.getMessage()); log.error("getPressurePumpStatusChart-->获取稳压泵启停状态图失败:{}", e.getMessage());
......
...@@ -129,12 +129,18 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -129,12 +129,18 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
IotDataVO iotDataVO = redisDataList.get(0); IotDataVO iotDataVO = redisDataList.get(0);
String value = iotDataVO.getValue().toString(); String value = iotDataVO.getValue().toString();
String createdTime = iotDataVO.getCreatedTime(); String createdTime = iotDataVO.getCreatedTime();
List<IotDataVO> falseDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
if (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(value)) { if (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(value)) {
intervalTime1 = createdTime; intervalTime1 = createdTime;
if (CollectionUtils.isNotEmpty(falseDataList)) {
// 获取最新的停止时间
intervalTime2 = falseDataList.get(0).getCreatedTime();
}
} else { } else {
List<IotDataVO> falseDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
List<IotDataVO> trueDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue()); List<IotDataVO> trueDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue());
if (CollectionUtils.isNotEmpty(falseDataList) && CollectionUtils.isNotEmpty(trueDataList)) { if (CollectionUtils.isNotEmpty(falseDataList) && CollectionUtils.isNotEmpty(trueDataList)) {
// 获取最新的启动时间
intervalTime1 = trueDataList.get(0).getCreatedTime();
// 获取大于启动信号,且最近停止信号的时间 // 获取大于启动信号,且最近停止信号的时间
String finalIntervalTime = intervalTime1; String finalIntervalTime = intervalTime1;
List<IotDataVO> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSeconds(finalIntervalTime, x.getCreatedTime(), DateUtils.DATE_TIME_PATTERN) >= 0).collect(Collectors.toList()); List<IotDataVO> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSeconds(finalIntervalTime, x.getCreatedTime(), DateUtils.DATE_TIME_PATTERN) >= 0).collect(Collectors.toList());
...@@ -157,22 +163,23 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -157,22 +163,23 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
String intervalTime2 = nowStrLong; String intervalTime2 = nowStrLong;
if (CollectionUtils.isNotEmpty(iotDataList)) { if (CollectionUtils.isNotEmpty(iotDataList)) {
String value = iotDataList.get(0).get(pressurePumpStart); String value = iotDataList.get(0).get(pressurePumpStart);
List<Map<String, String>> falseDataList = iotDataList.stream().filter(x -> x.containsKey("createdTime") && "false".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList()); String createdTime = iotDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
List<Map<String, String>> trueDataList = iotDataList.stream().filter(x -> x.containsKey("createdTime") && "true".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList()); List<Map<String, String>> falseDataList = iotDataList.stream().filter(x -> x.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && "false".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(trueDataList)) { List<Map<String, String>> trueDataList = iotDataList.stream().filter(x -> x.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && "true".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
intervalTime1 = trueDataList.get(0).get("createdTime");
}
if (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(value)) { if (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(value)) {
intervalTime1 = createdTime;
if (CollectionUtils.isNotEmpty(falseDataList)) { if (CollectionUtils.isNotEmpty(falseDataList)) {
intervalTime2 = falseDataList.get(0).get("createdTime"); intervalTime2 = falseDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
} }
} else { } else {
if (CollectionUtils.isNotEmpty(falseDataList) && CollectionUtils.isNotEmpty(trueDataList)) { if (CollectionUtils.isNotEmpty(falseDataList) && CollectionUtils.isNotEmpty(trueDataList)) {
// 获取最新的启动时间
intervalTime1 = trueDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
// 获取最接近最新启动信号,且时间大于启动信号的停止信号时间值 // 获取最接近最新启动信号,且时间大于启动信号的停止信号时间值
String finalIntervalTime = intervalTime2; String finalIntervalTime = intervalTime1;
List<Map<String, String>> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSeconds(finalIntervalTime, x.get("createdTime"), "yyyy-MM-dd HH:mm:ss") >= 0).collect(Collectors.toList()); List<Map<String, String>> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSeconds(finalIntervalTime, x.get(PressurePumpRelateEnum.CREATED_TIME.getValue()), DateUtils.DATE_TIME_PATTERN) >= 0).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(timeList)) { if (CollectionUtils.isNotEmpty(timeList)) {
intervalTime1 = timeList.get(timeList.size() - 1).get("createdTime"); intervalTime2 = timeList.get(timeList.size() - 1).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
} }
} }
} }
...@@ -199,7 +206,7 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -199,7 +206,7 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
private List<Map<String, String>> getIotDataFilterList(List<Map<String, String>> iotDataList, String value, Date beforeDate) { private List<Map<String, String>> getIotDataFilterList(List<Map<String, String>> iotDataList, String value, Date beforeDate) {
if (beforeDate != null) { if (beforeDate != null) {
return iotDataList.stream().filter(x -> DateUtils.dateCompare(DateUtils.longStr2Date(x.get("createdTime")), beforeDate) >= 0 && value.equalsIgnoreCase(x.get(pressurePumpPipePressure))).collect(Collectors.toList()); return iotDataList.stream().filter(x -> DateUtils.dateCompare(DateUtils.longStr2Date(x.get(PressurePumpRelateEnum.CREATED_TIME.getValue())), beforeDate) >= 0 && value.equalsIgnoreCase(x.get(pressurePumpPipePressure))).collect(Collectors.toList());
} }
return iotDataList.stream().filter(x -> value.equalsIgnoreCase(x.get(pressurePumpPipePressure))).collect(Collectors.toList()); return iotDataList.stream().filter(x -> value.equalsIgnoreCase(x.get(pressurePumpPipePressure))).collect(Collectors.toList());
} }
...@@ -228,10 +235,11 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -228,10 +235,11 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
List<IotDataVO> falseDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue()); List<IotDataVO> falseDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
List<IotDataVO> trueDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue()); List<IotDataVO> trueDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue());
if (CollectionUtils.isNotEmpty(falseDataList) && CollectionUtils.isNotEmpty(trueDataList)) { if (CollectionUtils.isNotEmpty(falseDataList) && CollectionUtils.isNotEmpty(trueDataList)) {
// 获取最新启动时间
durationTime = trueDataList.get(0).getCreatedTime(); durationTime = trueDataList.get(0).getCreatedTime();
// 获取大于启动信号,且最近停止信号的时间 // 获取大于启动信号,且最近停止信号的时间
String finalNowStrLong = nowStrLong; String finalDurationTime = durationTime;
List<IotDataVO> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSeconds(finalNowStrLong, x.getCreatedTime(), DateUtils.DATE_TIME_PATTERN) >= 0).collect(Collectors.toList()); List<IotDataVO> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSeconds(finalDurationTime, x.getCreatedTime(), DateUtils.DATE_TIME_PATTERN) >= 0).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(timeList)) { if (CollectionUtils.isNotEmpty(timeList)) {
nowStrLong = timeList.get(timeList.size() - 1).getCreatedTime(); nowStrLong = timeList.get(timeList.size() - 1).getCreatedTime();
} }
...@@ -249,18 +257,19 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -249,18 +257,19 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
String durationTime = nowStrLong; String durationTime = nowStrLong;
if (CollectionUtils.isNotEmpty(iotDataList)) { if (CollectionUtils.isNotEmpty(iotDataList)) {
String value = iotDataList.get(0).get(pressurePumpStart); String value = iotDataList.get(0).get(pressurePumpStart);
List<Map<String, String>> falseDataList = iotDataList.stream().filter(x -> x.containsKey("createdTime") && "false".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList()); List<Map<String, String>> falseDataList = iotDataList.stream().filter(x -> x.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && "false".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
List<Map<String, String>> trueDataList = iotDataList.stream().filter(x -> x.containsKey("createdTime") && "true".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList()); List<Map<String, String>> trueDataList = iotDataList.stream().filter(x -> x.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && "true".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
if ("true".equalsIgnoreCase(value)) { if (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(value)) {
durationTime = iotDataList.get(0).get("createdTime"); durationTime = iotDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
} else { } else {
if (CollectionUtils.isNotEmpty(falseDataList) && CollectionUtils.isNotEmpty(trueDataList)) { if (CollectionUtils.isNotEmpty(falseDataList) && CollectionUtils.isNotEmpty(trueDataList)) {
durationTime = trueDataList.get(0).get("createdTime"); // 获取最新启动时间
durationTime = trueDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
// 获取最接近最新启动信号,且时间大于启动信号的停止信号时间值 // 获取最接近最新启动信号,且时间大于启动信号的停止信号时间值
String finalDurationTime = durationTime; String finalDurationTime = durationTime;
List<Map<String, String>> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSeconds(finalDurationTime, x.get("createdTime"), "yyyy-MM-dd HH:mm:ss") >= 0).collect(Collectors.toList()); List<Map<String, String>> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSeconds(finalDurationTime, x.get(PressurePumpRelateEnum.CREATED_TIME.getValue()), DateUtils.DATE_TIME_PATTERN) >= 0).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(timeList)) { if (CollectionUtils.isNotEmpty(timeList)) {
nowStrLong = timeList.get(timeList.size() - 1).get("createdTime"); nowStrLong = timeList.get(timeList.size() - 1).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
} }
} }
} }
...@@ -303,7 +312,7 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -303,7 +312,7 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
if ("true".equalsIgnoreCase(value)) { if ("true".equalsIgnoreCase(value)) {
List<Map<String, String>> falseDataList = getIotDataFilterList(iotDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue()); List<Map<String, String>> falseDataList = getIotDataFilterList(iotDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
if (CollectionUtils.isNotEmpty(falseDataList)) { if (CollectionUtils.isNotEmpty(falseDataList)) {
String createdTime = falseDataList.get(0).get("createdTime"); String createdTime = falseDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
try { try {
Date stop5BeforeDate = DateUtils.dateAddMinutes(DateUtils.convertStrToDate(createdTime, DateUtils.DATE_TIME_PATTERN), Integer.parseInt(PressurePumpRelateEnum.PRESSURE_PUMP_START_BEFORE_MINUTE.getValue())); Date stop5BeforeDate = DateUtils.dateAddMinutes(DateUtils.convertStrToDate(createdTime, DateUtils.DATE_TIME_PATTERN), Integer.parseInt(PressurePumpRelateEnum.PRESSURE_PUMP_START_BEFORE_MINUTE.getValue()));
// 获取指定之前时间,指定值数据 // 获取指定之前时间,指定值数据
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment