Commit b0dd3c67 authored by 高建强's avatar 高建强

item:稳压泵今日累计提交

parent a96501c6
......@@ -134,5 +134,5 @@ public interface IPressurePumpService {
*/
Object mapToObject(Map<String,String> map,Class<?> aClass, String indexKey) throws IllegalAccessException, InstantiationException;
List<PressurePumpCountVo> getDayAvgDataList(List<Map<String, Object>> pumpInfoList, String infoCode, String equipmentCode, String nameKey, String bizOrgCode, long countExpire);
List<PressurePumpCountVo> getDayAvgDataList(List<Map<String, Object>> pumpInfoList, String infoCode, String countRedisKey, String equipmentCode, String nameKey, String bizOrgCode, long countExpire);
}
......@@ -233,6 +233,7 @@ public class EmergencyServiceImpl implements IEmergencyService {
String pipePressureEquipmentCode = map.get("pipePressureEquipmentCode").toString();
String faultNameKey = map.get("faultNameKey").toString();
String top = map.get("top").toString();
String countRedisKey = map.get("countRedisKey").toString();
long countExpire = Long.parseLong(map.get("countExpire").toString());
// 1. 判断稳压泵整体是否故障
List<EquipmentSpecificAlarmLog> alarmLogList = equipmentSpecificAlarmLogService.getAlarmLogInfoList(equipmentCode, faultNameKey, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), PressurePumpRelateEnum.UN_CLEAN_TIME.getValue(), bizOrgCode);
......@@ -262,13 +263,13 @@ public class EmergencyServiceImpl implements IEmergencyService {
// PressurePumpAnalysisEnum.PRESSURE_PUMP_TWO.setValue(twoFrequency);
// 5. 今日启动次数,前3天启动次数的均值
// 获取稳压泵数据,redis没有,从iot取
List<PressurePumpCountVo> dayAvgDataList = pressurePumpService.getDayAvgDataList(pumpInfoList, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), equipmentCode, pressurePumpStart, bizOrgCode, countExpire);
List<PressurePumpCountVo> dayAvgDataList = pressurePumpService.getDayAvgDataList(pumpInfoList, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, equipmentCode, pressurePumpStart, bizOrgCode, countExpire);
AtomicInteger dayAvgFrequency = new AtomicInteger();
if (!CollectionUtils.isEmpty(dayAvgDataList)) {
dayAvgDataList.forEach(x -> dayAvgFrequency.addAndGet(x.getValue()));
}
// int dayAvgFrequency = pressurePumpService.getAllPressurePumpStartDayAvgFrequency(Double.parseDouble(PressurePumpRelateEnum.DAY_AVG.getValue()), dataListFilterTrue, dateNow);
PressurePumpAnalysisEnum.PRESSURE_PUMP_DAY_AVG.setValue(dayAvgFrequency.get());
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());
......
......@@ -129,9 +129,9 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
return list;
}
public List<PressurePumpCountVo> getCountDataToRedisByDateBetween(String infoCode, String nameKey, String iotCode, Date startDate, Date endDate) {
public List<PressurePumpCountVo> getCountDataToRedisByDateBetween(String infoCode, String countRedisKey, String nameKey, String iotCode, Date startDate, Date endDate) {
List<PressurePumpCountVo> list = new ArrayList<>();
Set<String> keys = redisUtils.getKeys(String.join(":", infoCode, nameKey, StringUtils.isNotEmpty(iotCode) ? iotCode : ""));
Set<String> keys = redisUtils.getKeys(String.join(":", infoCode, countRedisKey, nameKey, StringUtils.isNotEmpty(iotCode) ? iotCode : ""));
if (CollectionUtils.isNotEmpty(keys)) {
keys.forEach(x -> {
String[] split = x.split(":");
......@@ -290,18 +290,18 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
}
@Override
public List<PressurePumpCountVo> getDayAvgDataList(List<Map<String, Object>> pumpInfoList, String infoCode, String equipmentCode, String nameKey, String bizOrgCode, long countExpire) {
public List<PressurePumpCountVo> getDayAvgDataList(List<Map<String, Object>> pumpInfoList, String infoCode, String countRedisKey, String equipmentCode, String nameKey, String bizOrgCode, long countExpire) {
try {
Date dateNow = DateUtils.convertStrToDate(DateUtils.getDateNowString(), DateUtils.DATE_PATTERN);
Date beforeDate = DateUtils.dateAddDays(dateNow, Integer.parseInt(PressurePumpRelateEnum.DAY_AVG.getValue()));
List<PressurePumpCountVo> dataList = getCountDataToRedisByDateBetween(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), nameKey, null, beforeDate, dateNow);
List<PressurePumpCountVo> dataList = getCountDataToRedisByDateBetween(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, nameKey, null, beforeDate, dateNow);
if (CollectionUtils.isNotEmpty(pumpInfoList) && (CollectionUtils.isEmpty(dataList) || dataList.size() < Math.abs(Integer.parseInt(PressurePumpRelateEnum.DAY_AVG.getValue())))) {
// iot获取数据,返回并存储redis
String startTime = DateUtils.convertDateToString(dateNow, DateUtils.DATE_PATTERN);
String endTime = DateUtils.convertDateToString(beforeDate, DateUtils.DATE_PATTERN);
String startTime = DateUtils.convertDateToString(beforeDate, DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(dateNow, DateUtils.DATE_TIME_PATTERN);
Object iotCode = pumpInfoList.get(0).get("iotCode");
String prefix = ObjectUtils.isEmpty(iotCode) ? "" : iotCode.toString().substring(0, 8);
dataList = getIotCountData(startTime, endTime, infoCode, prefix, null, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), nameKey, countExpire);
dataList = getIotCountData(startTime, endTime, infoCode, countRedisKey, prefix, null, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), nameKey, countExpire);
}
return dataList;
} catch (ParseException e) {
......@@ -310,7 +310,7 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
return Collections.emptyList();
}
private List<PressurePumpCountVo> getIotCountData(String startTime, String endTime, String infoCode, String prefix, String suffix, String key, String fieldKey, long expire) {
private List<PressurePumpCountVo> getIotCountData(String startTime, String endTime, String infoCode, String countRedisKey, String prefix, String suffix, String key, String fieldKey, long expire) {
List<Map<String, String>> dataMapList = getIotCommonListData(startTime, endTime, prefix, suffix, key, fieldKey);
if (CollectionUtils.isNotEmpty(dataMapList) && StringUtils.isNotBlank(key)) {
Map<String, List<Map<String, String>>> dataMap = dataMapList.stream().filter(y -> y.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && y.get(fieldKey) != null && key.equalsIgnoreCase(y.get(fieldKey))).collect(Collectors.groupingBy(e -> e.get(PressurePumpRelateEnum.CREATED_TIME.getValue()).substring(0, 10)));
......@@ -320,10 +320,11 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
for (String time : dataMap.keySet()) {
PressurePumpCountVo countVo = new PressurePumpCountVo();
countVo.setTime(time);
countVo.setValue(dataMap.get(key).size());
countVo.setValue(dataMap.get(time).size());
// 获取的数据存储到redis
String topic = String.join(":", infoCode, fieldKey, iotCode, time);
String topic = String.join(":", infoCode, countRedisKey, fieldKey, iotCode, time);
redisUtils.set(topic, JSON.toJSONString(countVo), expire);
dataList.add(countVo);
}
return dataList;
}
......
......@@ -8,6 +8,7 @@
"countExpire": 1209600,
"equipmentCode": "92010800KAL44",
"pipePressureEquipmentCode": "92011000T5Q44",
"top": "100"
"top": "100",
"countRedisKey": "Count"
}
]
\ No newline at end of file
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