Commit 076ca9aa authored by 高建强's avatar 高建强

item:稳压泵统计与分析,优化接口调用

parent 24ba1713
...@@ -633,7 +633,7 @@ public class EmergencyController extends AbstractBaseController { ...@@ -633,7 +633,7 @@ public class EmergencyController extends AbstractBaseController {
@PersonIdentify @PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getPressurePumpDay") @GetMapping(value = "/getPressurePumpDay")
@ApiOperation(httpMethod = "GET", value = "四横八纵-稳压泵诊断分析", notes = "四横八纵-稳压泵诊断分析") @ApiOperation(httpMethod = "GET", value = "手动-存储昨日稳压泵启动次数", notes = "手动-存储昨日稳压泵启动次数")
public ResponseModel getPressurePumpDay(@RequestParam(required = false) String bizOrgCode) { public ResponseModel getPressurePumpDay(@RequestParam(required = false) String bizOrgCode) {
if(StringUtils.isEmpty(bizOrgCode)) { if(StringUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
......
...@@ -61,7 +61,7 @@ public interface IEmergencyService { ...@@ -61,7 +61,7 @@ public interface IEmergencyService {
Page<Map<String, Object>> alarmList(Page<Map<String, Object>> page,String bizOrgCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus); Page<Map<String, Object>> alarmList(Page<Map<String, Object>> page,String bizOrgCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus);
List<PressurePumpCountVo> getPressurePumpDay(String bizOrgCode); Map<String, List<PressurePumpCountVo>> getPressurePumpDay(String bizOrgCode);
/** /**
* 稳压泵启动统计 * 稳压泵启动统计
......
...@@ -116,6 +116,7 @@ public interface IPressurePumpService { ...@@ -116,6 +116,7 @@ public interface IPressurePumpService {
/** /**
* 获取稳压泵数据,redis没有,从iot取 * 获取稳压泵数据,redis没有,从iot取
* *
* @param pumpInfoList
* @param infoCode * @param infoCode
* @param equipmentCode * @param equipmentCode
* @param top * @param top
...@@ -124,7 +125,7 @@ public interface IPressurePumpService { ...@@ -124,7 +125,7 @@ public interface IPressurePumpService {
* @param iotCode * @param iotCode
* @return * @return
*/ */
Map<String, List<IotDataVO>> getDataList(String infoCode, String equipmentCode, String top, String nameKey, String bizOrgCode, String iotCode); Map<String, List<IotDataVO>> getDataList(List<Map<String, Object>> pumpInfoList, String infoCode, String equipmentCode, String top, String nameKey, String bizOrgCode, String iotCode);
/** /**
* map 转化为对象 * map 转化为对象
......
...@@ -248,11 +248,11 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -248,11 +248,11 @@ public class EmergencyServiceImpl implements IEmergencyService {
PressurePumpAnalysisEnum.PRESSURE_PUMP_FAULT.setValue(CollectionUtils.isEmpty(alarmLogList) ? PressurePumpRelateEnum.NOT_FAULT.getValue() : PressurePumpRelateEnum.FAULT.getValue()); PressurePumpAnalysisEnum.PRESSURE_PUMP_FAULT.setValue(CollectionUtils.isEmpty(alarmLogList) ? PressurePumpRelateEnum.NOT_FAULT.getValue() : PressurePumpRelateEnum.FAULT.getValue());
// 获取稳压泵数据,redis没有,从iot取 // 获取稳压泵数据,redis没有,从iot取
List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, bizOrgCode); List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, bizOrgCode);
Map<String, List<IotDataVO>> dataMap = pressurePumpService.getDataList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), equipmentCode, top, pressurePumpStart, bizOrgCode, null); Map<String, List<IotDataVO>> dataMap = pressurePumpService.getDataList(pumpInfoList, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), equipmentCode, top, pressurePumpStart, bizOrgCode, null);
List<IotDataVO> dataList = dataMap.get("dataList"); List<IotDataVO> dataList = dataMap.get("dataList");
List<IotDataVO> dataListFilterTrue = dataMap.get("dataListFilterTrue"); List<IotDataVO> dataListFilterTrue = dataMap.get("dataListFilterTrue");
List<IotDataVO> dataListFilterFalse = dataMap.get("dataListFilterFalse"); List<IotDataVO> dataListFilterFalse = dataMap.get("dataListFilterFalse");
Map<String, List<IotDataVO>> dataPipMap = pressurePumpService.getDataList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), pipePressureEquipmentCode, top, pressurePumpPipePressure, bizOrgCode, null); Map<String, List<IotDataVO>> dataPipMap = pressurePumpService.getDataList(pumpInfoList, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), pipePressureEquipmentCode, top, pressurePumpPipePressure, bizOrgCode, null);
List<IotDataVO> dataPipeList = dataPipMap.get("dataList"); List<IotDataVO> dataPipeList = dataPipMap.get("dataList");
String nowStrLong = DateUtils.getDateNowString(); String nowStrLong = DateUtils.getDateNowString();
...@@ -462,10 +462,10 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -462,10 +462,10 @@ public class EmergencyServiceImpl implements IEmergencyService {
} }
@Override @Override
public List<PressurePumpCountVo> getPressurePumpDay(String bizOrgCode) { public Map<String, List<PressurePumpCountVo>> getPressurePumpDay(String bizOrgCode) {
Map<String, List<PressurePumpCountVo>> dataMap = new HashMap<>();
// 从 json 配置文件获取配置信息 // 从 json 配置文件获取配置信息
List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue()); List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue());
List<PressurePumpCountVo> dataList = new ArrayList<>();
if (!CollectionUtils.isEmpty(infoList)) { if (!CollectionUtils.isEmpty(infoList)) {
try { try {
Date dateNow = DateUtils.convertStrToDate(DateUtils.getDateNowString(), DateUtils.DATE_PATTERN); Date dateNow = DateUtils.convertStrToDate(DateUtils.getDateNowString(), DateUtils.DATE_PATTERN);
...@@ -473,18 +473,28 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -473,18 +473,28 @@ public class EmergencyServiceImpl implements IEmergencyService {
// iot获取数据,返回并存储redis // iot获取数据,返回并存储redis
String startTime = DateUtils.convertDateToString(beforeDate, DateUtils.DATE_TIME_PATTERN); String startTime = DateUtils.convertDateToString(beforeDate, DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(dateNow, DateUtils.DATE_TIME_PATTERN); String endTime = DateUtils.convertDateToString(dateNow, DateUtils.DATE_TIME_PATTERN);
Map map = infoList.get(0); Map infoMap = infoList.get(0);
String equipmentCode = map.get("equipmentCode").toString(); String equipmentCode = infoMap.get("equipmentCode").toString();
String countRedisKey = map.get("countRedisKey").toString(); String countRedisKey = infoMap.get("countRedisKey").toString();
long countExpire = Long.parseLong(map.get("countExpire").toString()); long countExpire = Long.parseLong(infoMap.get("countExpire").toString());
List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, bizOrgCode); List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, bizOrgCode);
Object iotCode = pumpInfoList.get(0).get("iotCode"); if (!CollectionUtils.isEmpty(pumpInfoList)){
String prefix = ObjectUtils.isEmpty(iotCode) ? "" : iotCode.toString().substring(0, 8); for (Map<String, Object> map : pumpInfoList) {
dataList = pressurePumpService.getIotCountData(startTime, endTime, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, prefix, null, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), pressurePumpStart, countExpire); // iot获取数据,返回并存储redis
Object iotCode = map.get("iotCode");
if (!ObjectUtils.isEmpty(iotCode)) {
String iotCodeStr = iotCode.toString();
String prefix = ObjectUtils.isEmpty(iotCode) ? "" : iotCodeStr.substring(0, 8);
String suffix = ObjectUtils.isEmpty(iotCode) ? "" : iotCodeStr.substring(8);
List<PressurePumpCountVo> dataList = pressurePumpService.getIotCountData(startTime, endTime, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, prefix, suffix, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), pressurePumpStart, countExpire);
dataMap.put(iotCodeStr, dataList);
}
}
}
} catch (ParseException e) { } catch (ParseException e) {
log.error("redis存稳压泵昨天启动次数失败:{}", e.getMessage()); log.error("redis存稳压泵昨天启动次数失败:{}", e.getMessage());
} }
} }
return dataList; return dataMap;
} }
} }
...@@ -9,7 +9,6 @@ import com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum; ...@@ -9,7 +9,6 @@ import com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum;
import com.yeejoin.equipmanage.common.vo.IotDataVO; import com.yeejoin.equipmanage.common.vo.IotDataVO;
import com.yeejoin.equipmanage.common.vo.PressurePumpCountVo; import com.yeejoin.equipmanage.common.vo.PressurePumpCountVo;
import com.yeejoin.equipmanage.fegin.IotFeign; import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.service.IEquipmentSpecificSerivce;
import com.yeejoin.equipmanage.service.IPressurePumpService; import com.yeejoin.equipmanage.service.IPressurePumpService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -37,9 +36,6 @@ import java.util.stream.Collectors; ...@@ -37,9 +36,6 @@ import java.util.stream.Collectors;
public class PressurePumpServiceImpl implements IPressurePumpService { public class PressurePumpServiceImpl implements IPressurePumpService {
@Autowired @Autowired
private IEquipmentSpecificSerivce equipmentSpecificSerivce;
@Autowired
private IotFeign iotFeign; private IotFeign iotFeign;
@Autowired @Autowired
...@@ -144,7 +140,7 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -144,7 +140,7 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
} catch (IOException e) { } catch (IOException e) {
log.error("获取指标JSON配置信息失败:{}", e.getMessage()); log.error("获取指标JSON配置信息失败:{}", e.getMessage());
} }
List<Map> list = JSONObject.parseArray(json, Map.class); List<Map> list = JSON.parseArray(json, Map.class);
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
return list.stream().filter(x -> code.equals(x.get("code"))).collect(Collectors.toList()); return list.stream().filter(x -> code.equals(x.get("code"))).collect(Collectors.toList());
} }
...@@ -189,7 +185,7 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -189,7 +185,7 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
} }
@Override @Override
public Map<String, List<IotDataVO>> getDataList(String infoCode, String equipmentCode, String top, String nameKey, String bizOrgCode, String iotCode) { public Map<String, List<IotDataVO>> getDataList(List<Map<String, Object>> pumpInfoList, String infoCode, String equipmentCode, String top, String nameKey, String bizOrgCode, String iotCode) {
Map<String, List<IotDataVO>> map = new HashMap<>(); Map<String, List<IotDataVO>> map = new HashMap<>();
// 获取redis稳压泵缓存数据,默认JSON配置最近4小时 // 获取redis稳压泵缓存数据,默认JSON配置最近4小时
List<IotDataVO> dataList = getDataToRedis(infoCode, nameKey, iotCode); List<IotDataVO> dataList = getDataToRedis(infoCode, nameKey, iotCode);
...@@ -199,11 +195,11 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -199,11 +195,11 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
//获取iot的数据 //获取iot的数据
if (pressurePumpPipePressure.equalsIgnoreCase(nameKey)) { if (pressurePumpPipePressure.equalsIgnoreCase(nameKey)) {
if (ObjectUtils.isEmpty(dataList) || dataList.size() < 2) { if (ObjectUtils.isEmpty(dataList) || dataList.size() < 2) {
dataList = getIotData(top, nameKey, equipmentCode, bizOrgCode); dataList = getIotData(pumpInfoList, top, nameKey);
} }
} else { } else {
if (ObjectUtils.isEmpty(dataList) || ObjectUtils.isEmpty(dataListFilterTrue) || ObjectUtils.isEmpty(dataListFilterFalse)) { if (ObjectUtils.isEmpty(dataList) || ObjectUtils.isEmpty(dataListFilterTrue) || ObjectUtils.isEmpty(dataListFilterFalse)) {
dataList = getIotData(top, nameKey, equipmentCode, bizOrgCode); dataList = getIotData(pumpInfoList, top, nameKey);
dataListFilterTrue = getDataListFilter(dataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue()); dataListFilterTrue = getDataListFilter(dataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue());
dataListFilterFalse = getDataListFilter(dataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue()); dataListFilterFalse = getDataListFilter(dataList, PressurePumpRelateEnum.IOT_INDEX_VALUE_FALSE.getValue());
} }
...@@ -214,10 +210,9 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -214,10 +210,9 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
return map; return map;
} }
private List<IotDataVO> getIotData(String top, String nameKey, String equipmentCode, String bizOrgCode) { private List<IotDataVO> getIotData(List<Map<String, Object>> pumpInfoList, String top, String nameKey) {
List<IotDataVO> dataList = new ArrayList<>(); List<IotDataVO> dataList = new ArrayList<>();
// 通过 equipmentCode 获取装备 // 通过 equipmentCode 获取装备
List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, bizOrgCode);
if (!ObjectUtils.isEmpty(pumpInfoList)) { if (!ObjectUtils.isEmpty(pumpInfoList)) {
String iotCode = pumpInfoList.get(0).get("iotCode").toString(); String iotCode = pumpInfoList.get(0).get("iotCode").toString();
if (iotCode.length() > 8) { if (iotCode.length() > 8) {
...@@ -326,17 +321,6 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -326,17 +321,6 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
return Collections.emptyList(); return Collections.emptyList();
} }
// 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());
// }
//
// private List<IotDataVO> getDataListFilter(List<IotDataVO> dataList, String value, Date beforeDate) {
// if (beforeDate != null) {
// return dataList.stream().filter(x -> DateUtils.dateCompare(DateUtils.longStr2Date(x.getCreatedTime()), beforeDate) >= 0 && value.equalsIgnoreCase(x.getValue().toString())).collect(Collectors.toList());
// }
// return dataList.stream().filter(x -> value.equalsIgnoreCase(x.getValue().toString())).collect(Collectors.toList());
// }
private List<IotDataVO> getDataListFilter(List<IotDataVO> dataList, Date beforeDate) { private List<IotDataVO> getDataListFilter(List<IotDataVO> dataList, Date beforeDate) {
if (beforeDate != null) { if (beforeDate != null) {
return dataList.stream().filter(x -> DateUtils.dateCompare(DateUtils.longStr2Date(x.getCreatedTime()), beforeDate) >= 0).collect(Collectors.toList()); return dataList.stream().filter(x -> DateUtils.dateCompare(DateUtils.longStr2Date(x.getCreatedTime()), beforeDate) >= 0).collect(Collectors.toList());
...@@ -344,13 +328,6 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -344,13 +328,6 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
return dataList; return dataList;
} }
// private List<Map<String, String>> getIotDataFilterList(List<Map<String, String>> iotDataList, String value, Date beforeDate) {
// 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()) && 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) {
if (CollectionUtils.isNotEmpty(dataList)) { if (CollectionUtils.isNotEmpty(dataList)) {
......
...@@ -102,7 +102,7 @@ public class SupervisionVideoServiceImpl extends ServiceImpl<SupervisionVideoMap ...@@ -102,7 +102,7 @@ public class SupervisionVideoServiceImpl extends ServiceImpl<SupervisionVideoMap
String nowStrLong = DateUtils.getNowStrLong(); String nowStrLong = DateUtils.getNowStrLong();
// 获取稳压泵数据,redis没有,从iot取 // 获取稳压泵数据,redis没有,从iot取
List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, bizOrgCode); List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, bizOrgCode);
Map<String, List<IotDataVO>> dataMap = pressurePumpService.getDataList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), equipmentCode, top, pressurePumpStart, bizOrgCode, null); Map<String, List<IotDataVO>> dataMap = pressurePumpService.getDataList(pumpInfoList, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), equipmentCode, top, pressurePumpStart, bizOrgCode, null);
List<IotDataVO> dataListFilterTrue = dataMap.get("dataListFilterTrue"); List<IotDataVO> dataListFilterTrue = dataMap.get("dataListFilterTrue");
List<IotDataVO> dataListFilterFalse = dataMap.get("dataListFilterFalse"); List<IotDataVO> dataListFilterFalse = dataMap.get("dataListFilterFalse");
Long interval = 0L; Long interval = 0L;
......
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