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

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

parent bdfee22a
......@@ -21,6 +21,7 @@ public enum PressurePumpRelateEnum {
PIPE_PRESSURE_ABNORMAL_STATUS("异常", "稳压泵管网压力异常状态"),
START("1", "稳压泵启动"),
STOP("0", "稳压泵停止"),
CREATED_TIME("createdTime", "物联采集信号创建时间属性"),
UN_CLEAN_TIME("false", "未消除");
private final String value;
......
......@@ -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
......@@ -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
......
......@@ -54,9 +54,9 @@ public interface IEmergencyService {
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);
......
......@@ -228,7 +228,7 @@ public class EmergencyServiceImpl implements IEmergencyService {
}
@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();
List<Map<String, Object>> list = new ArrayList<>();
for (PressurePumpAnalysisEnum value : values) {
......@@ -302,9 +302,14 @@ public class EmergencyServiceImpl implements IEmergencyService {
}
@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<>();
try {
// 从 json 配置文件获取配置信息
List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue());
if (!CollectionUtils.isEmpty(infoList)) {
Map infoMap = infoList.get(0);
String equipmentCode = infoMap.get("equipmentCode").toString();
// 获取稳压泵
List<Map<String, Object>> list = equipmentSpecificSerivce.getListByEquipmentCode(equipmentCode, bizOrgCode);
// 获取各稳压泵数据,及时间戳
......@@ -318,9 +323,7 @@ public class EmergencyServiceImpl implements IEmergencyService {
Object iotCode = x.get("iotCode");
if (iotCode != null) {
// 判断开始时间,是否在redis缓存有效期之内,是,redis获取数据,否则,iot获取数据
List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue());
if (!CollectionUtils.isEmpty(infoList)) {
int expire = Integer.parseInt(infoList.get(0).get("expire").toString()) * -1;
int expire = Integer.parseInt(infoMap.get("expire").toString()) * -1;
Date dateNow = DateUtils.getDateNow();
Date beforeDate = DateUtils.dateAddSeconds(dateNow, expire);
Date startDate = DateUtils.convertStrToDate(startTime, DateUtils.DATE_TIME_PATTERN);
......@@ -334,7 +337,7 @@ public class EmergencyServiceImpl implements IEmergencyService {
timeSet.add(y.getCreatedTime());
Map<String, String> xMap = new HashMap<>();
xMap.put(pressurePumpStart, y.getValue().toString());
xMap.put("createdTime", y.getCreatedTime());
xMap.put(PressurePumpRelateEnum.CREATED_TIME.getValue(), y.getCreatedTime());
dataList.add(xMap);
});
dataListMap.put(iotCode.toString(), dataList);
......@@ -344,17 +347,16 @@ public class EmergencyServiceImpl implements IEmergencyService {
String prefix = iotCode.toString().substring(0, 8);
String suffix = iotCode.toString().substring(8);
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);
}
}
}
}
// 数据时间排序
List<String> sortTimeList = new ArrayList<>(timeSet);
Collections.sort(sortTimeList);
// 数据时间截取,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());
// 数据时间截取,MM-dd HH
List<String> sortTimeTmpCollectList = sortTimeList.stream().map(x -> x.substring(5, x.length() - 6)).collect(Collectors.toList());
......@@ -380,7 +382,7 @@ public class EmergencyServiceImpl implements IEmergencyService {
List<Map<String, String>> dataList = dataListMap.get(iotCode.toString());
if (!CollectionUtils.isEmpty(dataList)) {
Collections.reverse(dataList);
Map<String, List<Map<String, String>>> dataMap = dataList.stream().filter(y -> y.containsKey("createdTime")).collect(Collectors.groupingBy(e -> e.get("createdTime").substring(5, 16)));
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)));
List<Map<String, String>> yDataList = null;
for (String t : timeList) {
List<Map<String, String>> data = dataMap.get(t);
......@@ -404,6 +406,7 @@ public class EmergencyServiceImpl implements IEmergencyService {
map.put("xData", timeList);
map.put("yData", yData);
}
}
} catch (Exception e) {
log.error("getPressurePumpStatusChart-->获取稳压泵启停状态图失败:{}", e.getMessage());
}
......
......@@ -129,12 +129,18 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
IotDataVO iotDataVO = redisDataList.get(0);
String value = iotDataVO.getValue().toString();
String createdTime = iotDataVO.getCreatedTime();
List<IotDataVO> falseDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
if (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(value)) {
intervalTime1 = createdTime;
if (CollectionUtils.isNotEmpty(falseDataList)) {
// 获取最新的停止时间
intervalTime2 = falseDataList.get(0).getCreatedTime();
}
} else {
List<IotDataVO> falseDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
List<IotDataVO> trueDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue());
if (CollectionUtils.isNotEmpty(falseDataList) && CollectionUtils.isNotEmpty(trueDataList)) {
// 获取最新的启动时间
intervalTime1 = trueDataList.get(0).getCreatedTime();
// 获取大于启动信号,且最近停止信号的时间
String finalIntervalTime = intervalTime1;
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 {
String intervalTime2 = nowStrLong;
if (CollectionUtils.isNotEmpty(iotDataList)) {
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>> trueDataList = iotDataList.stream().filter(x -> x.containsKey("createdTime") && "true".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(trueDataList)) {
intervalTime1 = trueDataList.get(0).get("createdTime");
}
String createdTime = iotDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
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(PressurePumpRelateEnum.CREATED_TIME.getValue()) && "true".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
if (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(value)) {
intervalTime1 = createdTime;
if (CollectionUtils.isNotEmpty(falseDataList)) {
intervalTime2 = falseDataList.get(0).get("createdTime");
intervalTime2 = falseDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
}
} else {
if (CollectionUtils.isNotEmpty(falseDataList) && CollectionUtils.isNotEmpty(trueDataList)) {
// 获取最新的启动时间
intervalTime1 = trueDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
// 获取最接近最新启动信号,且时间大于启动信号的停止信号时间值
String finalIntervalTime = intervalTime2;
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());
String finalIntervalTime = intervalTime1;
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)) {
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 {
private List<Map<String, String>> getIotDataFilterList(List<Map<String, String>> iotDataList, String value, Date beforeDate) {
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());
}
......@@ -228,10 +235,11 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
List<IotDataVO> falseDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
List<IotDataVO> trueDataList = getRedisDataFilterList(redisDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue());
if (CollectionUtils.isNotEmpty(falseDataList) && CollectionUtils.isNotEmpty(trueDataList)) {
// 获取最新启动时间
durationTime = trueDataList.get(0).getCreatedTime();
// 获取大于启动信号,且最近停止信号的时间
String finalNowStrLong = nowStrLong;
List<IotDataVO> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSeconds(finalNowStrLong, x.getCreatedTime(), DateUtils.DATE_TIME_PATTERN) >= 0).collect(Collectors.toList());
String finalDurationTime = durationTime;
List<IotDataVO> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSeconds(finalDurationTime, x.getCreatedTime(), DateUtils.DATE_TIME_PATTERN) >= 0).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(timeList)) {
nowStrLong = timeList.get(timeList.size() - 1).getCreatedTime();
}
......@@ -249,18 +257,19 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
String durationTime = nowStrLong;
if (CollectionUtils.isNotEmpty(iotDataList)) {
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>> trueDataList = iotDataList.stream().filter(x -> x.containsKey("createdTime") && "true".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
if ("true".equalsIgnoreCase(value)) {
durationTime = iotDataList.get(0).get("createdTime");
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(PressurePumpRelateEnum.CREATED_TIME.getValue()) && "true".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
if (PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue().equalsIgnoreCase(value)) {
durationTime = iotDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
} else {
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;
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)) {
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 {
if ("true".equalsIgnoreCase(value)) {
List<Map<String, String>> falseDataList = getIotDataFilterList(iotDataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
if (CollectionUtils.isNotEmpty(falseDataList)) {
String createdTime = falseDataList.get(0).get("createdTime");
String createdTime = falseDataList.get(0).get(PressurePumpRelateEnum.CREATED_TIME.getValue());
try {
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