Commit 647894ad authored by 高建强's avatar 高建强

item:调整稳压泵近3日统计数据,兼容柱状图数据存储结构

parent c2c21787
...@@ -912,7 +912,7 @@ public class DateUtils { ...@@ -912,7 +912,7 @@ public class DateUtils {
while (true) { while (true) {
if (MONTH_DAY_HOUR_PATTERN.equals(pattern)) { if (MONTH_DAY_HOUR_PATTERN.equals(pattern)) {
date = dateAddMinutes(date, 60); date = dateAddMinutes(date, 60);
} else if (MONTH_DAY_PATTERN.equals(pattern)) { } else if (DATE_PATTERN.equals(pattern) || MONTH_DAY_PATTERN.equals(pattern)) {
date = dateAddDays(date, 1); date = dateAddDays(date, 1);
} else { } else {
date = dateAddMinutes(date, 1); date = dateAddMinutes(date, 1);
......
...@@ -134,9 +134,33 @@ public interface IPressurePumpService { ...@@ -134,9 +134,33 @@ public interface IPressurePumpService {
*/ */
Object mapToObject(Map<String,String> map,Class<?> aClass, String indexKey) throws IllegalAccessException, InstantiationException; Object mapToObject(Map<String,String> map,Class<?> aClass, String indexKey) throws IllegalAccessException, InstantiationException;
List<PressurePumpCountVo> getDayAvgDataList(List<Map<String, Object>> pumpInfoList, String infoCode, String countRedisKey, String equipmentCode, String nameKey, String bizOrgCode, long countExpire); /**
* 获取iot指标统计数据
* @param startTime
* @param endTime
* @param infoCode
* @param countRedisKey
* @param prefix
* @param suffix
* @param key
* @param fieldKey
* @param expire
* @return
*/
List<PressurePumpCountVo> getIotCountData(String startTime, String endTime, String infoCode, String countRedisKey, String prefix, String suffix, String key, String fieldKey, long expire); List<PressurePumpCountVo> getIotCountData(String startTime, String endTime, String infoCode, String countRedisKey, String prefix, String suffix, String key, String fieldKey, long expire);
/**
* 获取稳压泵时间范围统计数据
* @param pumpInfoList
* @param startTime
* @param endTime
* @param infoCode
* @param countRedisKey
* @param equipmentCode
* @param nameKey
* @param countExpire
* @param bizOrgCode
* @return
*/
Map<String, List<PressurePumpCountVo>> getDateRangeCountList(List<Map<String, Object>> pumpInfoList, String startTime, String endTime, String infoCode, String countRedisKey, String equipmentCode, String nameKey, long countExpire, String bizOrgCode); Map<String, List<PressurePumpCountVo>> getDateRangeCountList(List<Map<String, Object>> pumpInfoList, String startTime, String endTime, String infoCode, String countRedisKey, String equipmentCode, String nameKey, long countExpire, String bizOrgCode);
} }
...@@ -232,50 +232,61 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -232,50 +232,61 @@ public class EmergencyServiceImpl implements IEmergencyService {
@Override @Override
public List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String bizOrgCode) { public List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String bizOrgCode) {
// 从 json 配置文件获取配置信息 try {
List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue()); // 从 json 配置文件获取配置信息
if (!CollectionUtils.isEmpty(infoList)) { List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue());
Map map = infoList.get(0); if (!CollectionUtils.isEmpty(infoList)) {
String equipmentCode = map.get("equipmentCode").toString(); Map map = infoList.get(0);
String pipePressureEquipmentCode = map.get("pipePressureEquipmentCode").toString(); String equipmentCode = map.get("equipmentCode").toString();
String faultNameKey = map.get("faultNameKey").toString(); String pipePressureEquipmentCode = map.get("pipePressureEquipmentCode").toString();
String top = map.get("top").toString(); String faultNameKey = map.get("faultNameKey").toString();
String countRedisKey = map.get("countRedisKey").toString(); String top = map.get("top").toString();
long countExpire = Long.parseLong(map.get("countExpire").toString()); String countRedisKey = map.get("countRedisKey").toString();
// 1. 判断稳压泵整体是否故障 long countExpire = Long.parseLong(map.get("countExpire").toString());
List<EquipmentSpecificAlarmLog> alarmLogList = equipmentSpecificAlarmLogService.getAlarmLogInfoList(equipmentCode, faultNameKey, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), PressurePumpRelateEnum.UN_CLEAN_TIME.getValue(), bizOrgCode); // 1. 判断稳压泵整体是否故障
PressurePumpAnalysisEnum.PRESSURE_PUMP_FAULT.setValue(CollectionUtils.isEmpty(alarmLogList) ? PressurePumpRelateEnum.NOT_FAULT.getValue() : PressurePumpRelateEnum.FAULT.getValue()); List<EquipmentSpecificAlarmLog> alarmLogList = equipmentSpecificAlarmLogService.getAlarmLogInfoList(equipmentCode, faultNameKey, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), PressurePumpRelateEnum.UN_CLEAN_TIME.getValue(), bizOrgCode);
// 获取稳压泵数据,redis没有,从iot取 PressurePumpAnalysisEnum.PRESSURE_PUMP_FAULT.setValue(CollectionUtils.isEmpty(alarmLogList) ? PressurePumpRelateEnum.NOT_FAULT.getValue() : PressurePumpRelateEnum.FAULT.getValue());
List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, bizOrgCode); // 获取稳压泵数据,redis没有,从iot取
Map<String, List<IotDataVO>> dataMap = pressurePumpService.getDataList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), equipmentCode, top, pressurePumpStart, bizOrgCode, null); List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, bizOrgCode);
List<IotDataVO> dataList = dataMap.get("dataList"); Map<String, List<IotDataVO>> dataMap = pressurePumpService.getDataList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), equipmentCode, top, pressurePumpStart, bizOrgCode, null);
List<IotDataVO> dataListFilterTrue = dataMap.get("dataListFilterTrue"); List<IotDataVO> dataList = dataMap.get("dataList");
List<IotDataVO> dataListFilterFalse = dataMap.get("dataListFilterFalse"); List<IotDataVO> dataListFilterTrue = dataMap.get("dataListFilterTrue");
Map<String, List<IotDataVO>> dataPipMap = pressurePumpService.getDataList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), pipePressureEquipmentCode, top, pressurePumpPipePressure, bizOrgCode, null); List<IotDataVO> dataListFilterFalse = dataMap.get("dataListFilterFalse");
List<IotDataVO> dataPipeList = dataPipMap.get("dataList"); Map<String, List<IotDataVO>> dataPipMap = pressurePumpService.getDataList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), pipePressureEquipmentCode, top, pressurePumpPipePressure, bizOrgCode, null);
List<IotDataVO> dataPipeList = dataPipMap.get("dataList");
String nowStrLong = DateUtils.getDateNowString();
Date dateNow = DateUtils.getDateNow(); String nowStrLong = DateUtils.getDateNowString();
// 2. 最近一次启停间隔 Date dateNow = DateUtils.getDateNow();
long interval = pressurePumpService.getAllPressurePumpStartStopInterval(dataList, dataListFilterTrue, dataListFilterFalse, nowStrLong); // 2. 最近一次启停间隔
PressurePumpAnalysisEnum.PRESSURE_PUMP_INTERVAL.setValue(interval); long interval = pressurePumpService.getAllPressurePumpStartStopInterval(dataList, dataListFilterTrue, dataListFilterFalse, nowStrLong);
// 3. 最近一次启动时长 PressurePumpAnalysisEnum.PRESSURE_PUMP_INTERVAL.setValue(interval);
long duration = pressurePumpService.getAllPressurePumpStartStopDuration(dataList, dataListFilterTrue, dataListFilterFalse, nowStrLong); // 3. 最近一次启动时长
PressurePumpAnalysisEnum.PRESSURE_PUMP_DURATION.setValue(duration); long duration = pressurePumpService.getAllPressurePumpStartStopDuration(dataList, dataListFilterTrue, dataListFilterFalse, nowStrLong);
// 4. 半小时启动 PressurePumpAnalysisEnum.PRESSURE_PUMP_DURATION.setValue(duration);
int halfFrequency = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.HALF_HOUR.getValue()), dataListFilterTrue, dateNow); // 4. 半小时启动
PressurePumpAnalysisEnum.PRESSURE_PUMP_HALF.setValue(halfFrequency); int halfFrequency = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.HALF_HOUR.getValue()), dataListFilterTrue, dateNow);
// 5. 今日启动次数,前3天启动次数的均值 PressurePumpAnalysisEnum.PRESSURE_PUMP_HALF.setValue(halfFrequency);
// 获取稳压泵数据,redis没有,从iot取 // 5. 今日启动次数,前3天启动次数的均值
List<PressurePumpCountVo> dayAvgDataList = pressurePumpService.getDayAvgDataList(pumpInfoList, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, equipmentCode, pressurePumpStart, bizOrgCode, countExpire); // 获取稳压泵数据,redis没有,从iot取
AtomicInteger dayAvgFrequency = new AtomicInteger(); Date startDate = DateUtils.dateAddDays(dateNow, Integer.parseInt(PressurePumpRelateEnum.DAY_AVG.getValue()));
if (!CollectionUtils.isEmpty(dayAvgDataList)) { String startTime = String.join(" ", DateUtils.dateFormat(startDate, DateUtils.DATE_PATTERN), "00:00:00");
dayAvgDataList.forEach(x -> dayAvgFrequency.addAndGet(x.getValue())); String endTime = String.join(" ", DateUtils.dateFormat(dateNow, DateUtils.DATE_PATTERN), "00:00:00");
Map<String, List<PressurePumpCountVo>> dayAvgDataMap = pressurePumpService.getDateRangeCountList(pumpInfoList, startTime,endTime, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, equipmentCode, pressurePumpStart, countExpire, bizOrgCode);
AtomicInteger dayAvgFrequency = new AtomicInteger();
if (!CollectionUtils.isEmpty(dayAvgDataMap)) {
for (List<PressurePumpCountVo> voList : dayAvgDataMap.values()) {
if (!CollectionUtils.isEmpty(voList)) {
voList.forEach(x -> dayAvgFrequency.addAndGet(x.getValue()));
}
}
}
PressurePumpAnalysisEnum.PRESSURE_PUMP_DAY_AVG.setValue(Math.round(dayAvgFrequency.get() / Math.abs(Integer.parseInt(PressurePumpRelateEnum.DAY_AVG.getValue()))));
// 6. 管网压力状态
double pressureDiff = pressurePumpService.getAllPressurePumpPipePressureDiff(dataList, dataPipeList, PressurePumpRelateEnum.PRESSURE_PUMP_START_BEFORE_MINUTE.getValue());
PressurePumpAnalysisEnum.PRESSURE_PUMP_PIPE.setValue(pressureDiff > Double.parseDouble(PressurePumpRelateEnum.PIPE_PRESSURE_DIFF.getValue()) ? PressurePumpRelateEnum.PIPE_PRESSURE_ABNORMAL_STATUS.getValue() : PressurePumpRelateEnum.PIPE_PRESSURE_NORMAL_STATUS.getValue());
} }
PressurePumpAnalysisEnum.PRESSURE_PUMP_DAY_AVG.setValue(Math.round(dayAvgFrequency.get() / Math.abs(Integer.parseInt(PressurePumpRelateEnum.DAY_AVG.getValue())))); } catch (ParseException e) {
// 6. 管网压力状态 log.error("getPressurePumpDiagnosticAnalysis-->获取稳压泵诊断与分析失败:{}", e.getMessage());
double pressureDiff = pressurePumpService.getAllPressurePumpPipePressureDiff(dataList, dataPipeList, PressurePumpRelateEnum.PRESSURE_PUMP_START_BEFORE_MINUTE.getValue());
PressurePumpAnalysisEnum.PRESSURE_PUMP_PIPE.setValue(pressureDiff > Double.parseDouble(PressurePumpRelateEnum.PIPE_PRESSURE_DIFF.getValue()) ? PressurePumpRelateEnum.PIPE_PRESSURE_ABNORMAL_STATUS.getValue() : PressurePumpRelateEnum.PIPE_PRESSURE_NORMAL_STATUS.getValue());
} }
return PressurePumpAnalysisEnum.getList(); return PressurePumpAnalysisEnum.getList();
} }
...@@ -296,7 +307,7 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -296,7 +307,7 @@ public class EmergencyServiceImpl implements IEmergencyService {
// 从redis获取日期范围数据,没有从iot获取。redis存储数据并返回 // 从redis获取日期范围数据,没有从iot获取。redis存储数据并返回
Map<String, List<PressurePumpCountVo>> dateRangeCountMap = pressurePumpService.getDateRangeCountList(pumpInfoList, startTime, endTime, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, equipmentCode, pressurePumpStart, countExpire, bizOrgCode); Map<String, List<PressurePumpCountVo>> dateRangeCountMap = pressurePumpService.getDateRangeCountList(pumpInfoList, startTime, endTime, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, equipmentCode, pressurePumpStart, countExpire, bizOrgCode);
if (!CollectionUtils.isEmpty(pumpInfoList)) { if (!CollectionUtils.isEmpty(pumpInfoList)) {
List<String> timeList = DateUtils.getTimeStrListByStartAndEnd(startTime, endTime, DateUtils.MONTH_DAY_PATTERN); List<String> timeList = DateUtils.getTimeStrListByStartAndEnd(startTime, endTime, DateUtils.DATE_PATTERN);
List<Map<String, Object>> yDataList = new ArrayList<>(); List<Map<String, Object>> yDataList = new ArrayList<>();
for (Map<String, Object> pumpMap : pumpInfoList) { for (Map<String, Object> pumpMap : pumpInfoList) {
Object iotCode = pumpMap.get("iotCode"); Object iotCode = pumpMap.get("iotCode");
...@@ -307,7 +318,7 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -307,7 +318,7 @@ public class EmergencyServiceImpl implements IEmergencyService {
String iotCodeStr = iotCode.toString(); String iotCodeStr = iotCode.toString();
List<PressurePumpCountVo> countVoList = dateRangeCountMap.get(iotCodeStr); List<PressurePumpCountVo> countVoList = dateRangeCountMap.get(iotCodeStr);
Map<String, List<PressurePumpCountVo>> collect = countVoList.stream().collect(Collectors.groupingBy(PressurePumpCountVo::getTime)); Map<String, List<PressurePumpCountVo>> collect = countVoList.stream().collect(Collectors.groupingBy(PressurePumpCountVo::getTime));
List<PressurePumpCountVo> data = collect.get("2023-" + time); List<PressurePumpCountVo> data = collect.get(time);
dataList.add(CollectionUtils.isEmpty(data) ? 0 : data.get(0).getValue()); dataList.add(CollectionUtils.isEmpty(data) ? 0 : data.get(0).getValue());
} else { } else {
dataList.add(0); dataList.add(0);
...@@ -317,7 +328,8 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -317,7 +328,8 @@ public class EmergencyServiceImpl implements IEmergencyService {
dataMap.put("data", dataList); dataMap.put("data", dataList);
yDataList.add(dataMap); yDataList.add(dataMap);
} }
map.put("xData", timeList); List<String> collect = timeList.stream().map(x -> x.substring(4)).collect(Collectors.toList());
map.put("xData", collect);
map.put("yData", yDataList); map.put("yData", yDataList);
} }
} }
...@@ -380,7 +392,6 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -380,7 +392,6 @@ public class EmergencyServiceImpl implements IEmergencyService {
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 -> 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());
......
...@@ -274,24 +274,32 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -274,24 +274,32 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
} }
@Override @Override
public List<PressurePumpCountVo> getDayAvgDataList(List<Map<String, Object>> pumpInfoList, String infoCode, String countRedisKey, String equipmentCode, String nameKey, String bizOrgCode, long countExpire) { public Map<String, List<PressurePumpCountVo>> getDateRangeCountList(List<Map<String, Object>> pumpInfoList, String startTime, String endTime, String infoCode, String countRedisKey, String equipmentCode, String nameKey, long countExpire, String bizOrgCode) {
Map<String, List<PressurePumpCountVo>> dataMap = new HashMap<>();
try { try {
Date dateNow = DateUtils.convertStrToDate(DateUtils.getDateNowString(), DateUtils.DATE_PATTERN); if (CollectionUtils.isNotEmpty(pumpInfoList)) {
Date beforeDate = DateUtils.dateAddDays(dateNow, Integer.parseInt(PressurePumpRelateEnum.DAY_AVG.getValue())); for (Map<String, Object> map : pumpInfoList) {
List<PressurePumpCountVo> dataList = getCountDataToRedisByDateBetween(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, nameKey, null, beforeDate, dateNow); // iot获取数据,返回并存储redis
if (CollectionUtils.isNotEmpty(pumpInfoList) && (CollectionUtils.isEmpty(dataList) || dataList.size() < Math.abs(Integer.parseInt(PressurePumpRelateEnum.DAY_AVG.getValue())))) { Object iotCode = map.get("iotCode");
// iot获取数据,返回并存储redis if (!ObjectUtils.isEmpty(iotCode)) {
String startTime = DateUtils.convertDateToString(beforeDate, DateUtils.DATE_TIME_PATTERN); String iotCodeStr = iotCode.toString();
String endTime = DateUtils.convertDateToString(dateNow, DateUtils.DATE_TIME_PATTERN); Date startDate = DateUtils.convertStrToDate(startTime, DateUtils.DATE_PATTERN);
Object iotCode = pumpInfoList.get(0).get("iotCode"); Date endDate = DateUtils.convertStrToDate(endTime, DateUtils.DATE_PATTERN);
String prefix = ObjectUtils.isEmpty(iotCode) ? "" : iotCode.toString().substring(0, 8); List<PressurePumpCountVo> dataList = getCountDataToRedisByDateBetween(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, nameKey, iotCodeStr, startDate, endDate);
dataList = getIotCountData(startTime, endTime, infoCode, countRedisKey, prefix, null, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), nameKey, countExpire); Long days = DateUtils.getDurationDays(startTime, endTime, DateUtils.DATE_TIME_PATTERN);
if (CollectionUtils.isEmpty(dataList) || (CollectionUtils.isNotEmpty(dataList) && dataList.size() < days)) {
String prefix = ObjectUtils.isEmpty(iotCode) ? "" : iotCodeStr.substring(0, 8);
String suffix = ObjectUtils.isEmpty(iotCode) ? "" : iotCodeStr.substring(8);
dataList = getIotCountData(startTime, endTime, infoCode, countRedisKey, prefix, suffix, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), nameKey, countExpire);
}
dataMap.put(iotCodeStr, dataList);
}
}
} }
return dataList;
} catch (ParseException e) { } catch (ParseException e) {
log.error("获取稳压泵天启动次数失败:{}", e.getMessage()); log.error("获取稳压泵范围启动统计失败:{}", e.getMessage());
} }
return Collections.emptyList(); return dataMap;
} }
@Override @Override
...@@ -318,35 +326,6 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -318,35 +326,6 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
return Collections.emptyList(); return Collections.emptyList();
} }
@Override
public Map<String, List<PressurePumpCountVo>> getDateRangeCountList(List<Map<String, Object>> pumpInfoList, String startTime, String endTime, String infoCode, String countRedisKey, String equipmentCode, String nameKey, long countExpire, String bizOrgCode) {
Map<String, List<PressurePumpCountVo>> dataMap = new HashMap<>();
try {
if (CollectionUtils.isNotEmpty(pumpInfoList)) {
for (Map<String, Object> map : pumpInfoList) {
// iot获取数据,返回并存储redis
Object iotCode = map.get("iotCode");
if (!ObjectUtils.isEmpty(iotCode)) {
String iotCodeStr = iotCode.toString();
Date startDate = DateUtils.convertStrToDate(startTime, DateUtils.DATE_PATTERN);
Date endDate = DateUtils.convertStrToDate(endTime, DateUtils.DATE_PATTERN);
List<PressurePumpCountVo> dataList = getCountDataToRedisByDateBetween(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, nameKey, iotCodeStr, startDate, endDate);
Long days = DateUtils.getDurationDays(startTime, endTime, DateUtils.DATE_TIME_PATTERN);
if (CollectionUtils.isEmpty(dataList) || (CollectionUtils.isNotEmpty(dataList) && dataList.size() < days)) {
String prefix = ObjectUtils.isEmpty(iotCode) ? "" : iotCodeStr.substring(0, 8);
String suffix = ObjectUtils.isEmpty(iotCode) ? "" : iotCodeStr.substring(8);
dataList = getIotCountData(startTime, endTime, infoCode, countRedisKey, prefix, suffix, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), nameKey, countExpire);
dataMap.put(iotCodeStr, dataList);
}
}
}
}
} catch (ParseException e) {
log.error("获取稳压泵范围启动统计失败:{}", e.getMessage());
}
return dataMap;
}
// private List<Map<String, String>> getIotDataFilterList(List<Map<String, String>> iotDataList, String value) { // private List<Map<String, String>> getIotDataFilterList(List<Map<String, String>> iotDataList, String value) {
// return iotDataList.stream().filter(x -> x.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && value.equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList()); // return iotDataList.stream().filter(x -> x.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && value.equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
// } // }
...@@ -365,12 +344,12 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -365,12 +344,12 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
return dataList; return dataList;
} }
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 -> x.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && 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 -> x.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && 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 -> x.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && value.equalsIgnoreCase(x.get(pressurePumpPipePressure))).collect(Collectors.toList()); // return iotDataList.stream().filter(x -> x.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && value.equalsIgnoreCase(x.get(pressurePumpPipePressure))).collect(Collectors.toList());
} // }
@Override @Override
public int getAllPressurePumpStartFrequency(double hour, List<IotDataVO> dataList, Date dateNow) { public int getAllPressurePumpStartFrequency(double hour, List<IotDataVO> dataList, Date dateNow) {
......
...@@ -112,10 +112,21 @@ public class SupervisionVideoServiceImpl extends ServiceImpl<SupervisionVideoMap ...@@ -112,10 +112,21 @@ public class SupervisionVideoServiceImpl extends ServiceImpl<SupervisionVideoMap
int twoHourStartNum = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.TWO_HOUR.getValue()), dataListFilterTrue, dateNow); int twoHourStartNum = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.TWO_HOUR.getValue()), dataListFilterTrue, dateNow);
int fourHourStartNum = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.FOUR_HOUR.getValue()), dataListFilterTrue, dateNow); int fourHourStartNum = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.FOUR_HOUR.getValue()), dataListFilterTrue, dateNow);
// 近3天启动平均值,四合五入 // 近3天启动平均值,四合五入
List<PressurePumpCountVo> dayAvgDataList = pressurePumpService.getDayAvgDataList(pumpInfoList, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, equipmentCode, pressurePumpStart, bizOrgCode, countExpire);
AtomicInteger dayAvgFrequency = new AtomicInteger(); AtomicInteger dayAvgFrequency = new AtomicInteger();
if (!CollectionUtils.isEmpty(dayAvgDataList)) { try {
dayAvgDataList.forEach(x -> dayAvgFrequency.addAndGet(x.getValue())); Date startDate = com.yeejoin.amos.boot.biz.common.utils.DateUtils.dateAddDays(dateNow, Integer.parseInt(PressurePumpRelateEnum.DAY_AVG.getValue()));
String startTime = String.join(" ", com.yeejoin.amos.boot.biz.common.utils.DateUtils.dateFormat(startDate, com.yeejoin.amos.boot.biz.common.utils.DateUtils.DATE_PATTERN), "00:00:00");
String endTime = String.join(" ", com.yeejoin.amos.boot.biz.common.utils.DateUtils.dateFormat(dateNow, com.yeejoin.amos.boot.biz.common.utils.DateUtils.DATE_PATTERN), "00:00:00");
Map<String, List<PressurePumpCountVo>> dayAvgDataMap = pressurePumpService.getDateRangeCountList(pumpInfoList, startTime,endTime, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, equipmentCode, pressurePumpStart, countExpire, bizOrgCode);
if (!CollectionUtils.isEmpty(dayAvgDataMap)) {
for (List<PressurePumpCountVo> voList : dayAvgDataMap.values()) {
if (!CollectionUtils.isEmpty(voList)) {
voList.forEach(x -> dayAvgFrequency.addAndGet(x.getValue()));
}
}
}
} catch (ParseException e) {
log.error("近3天平均启动次数获取失败-->dayAvgFrequency:{}", e.getMessage());
} }
int dayAvgStartNum = Math.round(dayAvgFrequency.get() / Math.abs(Integer.parseInt(PressurePumpRelateEnum.DAY_AVG.getValue()))); int dayAvgStartNum = Math.round(dayAvgFrequency.get() / Math.abs(Integer.parseInt(PressurePumpRelateEnum.DAY_AVG.getValue())));
pressurePumpInfo = fireFightingSystemMapper.getPressurePumpInfo(page, bizOrgCode, null); pressurePumpInfo = fireFightingSystemMapper.getPressurePumpInfo(page, bizOrgCode, null);
......
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