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

item:稳压泵统计与分析优化涉及业务调整

parent 484165db
......@@ -38,24 +38,32 @@ public interface IPressurePumpService {
/**
* 获取所有稳压泵最近一次启停间隔,min
*
* @param dataList
* @param dataListFilterTrue
* @param dataListFilterFalse
* @param nowStrLong
*/
long getAllPressurePumpStartStopInterval(List<IotDataVO> dataList, String nowStrLong);
long getAllPressurePumpStartStopInterval(List<IotDataVO> dataList, List<IotDataVO> dataListFilterTrue, List<IotDataVO> dataListFilterFalse, String nowStrLong);
/**
* 获取稳压泵一定时间内启动频率或次数
*
* @param hour
* @param dataList
* @param dateNow
*/
int getAllPressurePumpStartFrequency(double hour, Date dateNow);
int getAllPressurePumpStartFrequency(double hour, List<IotDataVO> dataList, Date dateNow);
/**
* 获取稳压泵最近一次启停时长,min
*
* @param dataList
* @param dataListFilterTrue
* @param dataListFilterFalse
* @param nowStrLong
*/
long getAllPressurePumpStartStopDuration(List<IotDataVO> dataList, String nowStrLong);
long getAllPressurePumpStartStopDuration(List<IotDataVO> dataList, List<IotDataVO> dataListFilterTrue, List<IotDataVO> dataListFilterFalse, String nowStrLong);
/**
* 获取稳压泵指定启泵前 minutes 分钟,管网压力差绝对值
......@@ -97,4 +105,31 @@ public interface IPressurePumpService {
*/
List<Map<String, String>> getIotCommonListData(String startTime, String endTime, String prefix, String suffix, String key, String fieldKey);
/**
* 数据根据指定值过滤
* @param dataList
* @param value
*/
List<IotDataVO> getDataListFilter(List<IotDataVO> dataList, String value);
/**
* 获取稳压泵数据,redis没有,从iot取
*
* @param infoCode
* @param equipmentCode
* @param top
* @param nameKey
* @param bizOrgCode
* @param iotCode
* @return
*/
Map<String, List<IotDataVO>> getDataList(String infoCode, String equipmentCode, String top, String nameKey, String bizOrgCode, String iotCode);
/**
* map 转化为对象
* @param map
* @param aClass
* @return
*/
Object mapToObject(Map<String,String> map,Class<?> aClass) throws IllegalAccessException, InstantiationException;
}
......@@ -9,7 +9,6 @@ import com.yeejoin.equipmanage.common.enums.PressurePumpRelateEnum;
import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.utils.UnitTransformUtil;
import com.yeejoin.equipmanage.common.vo.IotDataVO;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.mapper.EmergencyMapper;
import com.yeejoin.equipmanage.service.IEmergencyService;
import com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmLogService;
......@@ -21,8 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.*;
import java.util.stream.Collectors;
......@@ -48,9 +45,6 @@ public class EmergencyServiceImpl implements IEmergencyService {
private SupervisionVideoServiceImpl supervisionVideoService;
@Autowired
private IotFeign iotFeign;
@Autowired
private IPressurePumpService pressurePumpService;
@Value("${equipment.pressurepump.start}")
......@@ -235,71 +229,39 @@ public class EmergencyServiceImpl implements IEmergencyService {
Map map = infoList.get(0);
String equipmentCode = map.get("equipmentCode").toString();
String faultNameKey = map.get("faultNameKey").toString();
String top = map.get("top").toString();
// 1. 判断稳压泵整体是否故障
List<EquipmentSpecificAlarmLog> alarmLogList = equipmentSpecificAlarmLogService.getAlarmLogInfoList(equipmentCode, faultNameKey, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), PressurePumpRelateEnum.UN_CLEAN_TIME.getValue(), bizOrgCode);
PressurePumpAnalysisEnum.PRESSURE_PUMP_FAULT.setValue(CollectionUtils.isEmpty(alarmLogList) ? PressurePumpRelateEnum.NOT_FAULT.getValue() : PressurePumpRelateEnum.FAULT.getValue());
// 获取redis稳压泵缓存数据,默认JSON配置最近4小时
List<IotDataVO> DataList = pressurePumpService.getDataToRedis(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), pressurePumpStart, null);
List<IotDataVO> DataPipeList = pressurePumpService.getDataToRedis(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), pressurePumpPipePressure, null);
String top = map.get("top").toString();
// 通过 equipmentCode 获取装备
List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, bizOrgCode);
if (!ObjectUtils.isEmpty(pumpInfoList)) {
String iotCode = pumpInfoList.get(0).get("iotCode").toString();
if (iotCode.length() > 8) {
String prefix = iotCode.substring(0, 8);
//获取iot的数据
if(ObjectUtils.isEmpty(DataList)){
DataList = getIotData(top, prefix, pressurePumpStart);
}
if(ObjectUtils.isEmpty(DataPipeList)){
DataPipeList = getIotData(top, prefix, pressurePumpPipePressure);
}
} else {
throw new BadRequest("装备物联编码错误,请确认!");
}
}
// 获取稳压泵数据,redis没有,从iot取
Map<String, List<IotDataVO>> dataMap = pressurePumpService.getDataList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), equipmentCode, top, pressurePumpStart, bizOrgCode, null);
List<IotDataVO> dataList = dataMap.get("dataList");
List<IotDataVO> dataListFilterTrue = dataMap.get("dataListFilterTrue");
List<IotDataVO> dataListFilterFalse = dataMap.get("dataListFilterFalse");
Map<String, List<IotDataVO>> dataPipMap = pressurePumpService.getDataList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), equipmentCode, top, pressurePumpPipePressure, bizOrgCode, null);
List<IotDataVO> dataPipeList = dataPipMap.get("dataList");
String nowStrLong = DateUtils.getDateNowString();
// 2. 最近一次启停间隔
long interval = pressurePumpService.getAllPressurePumpStartStopInterval(DataList, nowStrLong);
// 3. 最近一次启动时长
long duration = pressurePumpService.getAllPressurePumpStartStopDuration(DataList, nowStrLong);
// 6. 管网压力状态
double pressureDiff = pressurePumpService.getAllPressurePumpPipePressureDiff(DataList, DataPipeList, PressurePumpRelateEnum.PRESSURE_PUMP_START_BEFORE_MINUTE.getValue());
Date dateNow = DateUtils.getDateNow();
// 2. 最近一次启停间隔
long interval = pressurePumpService.getAllPressurePumpStartStopInterval(dataList, dataListFilterTrue, dataListFilterFalse, nowStrLong);
PressurePumpAnalysisEnum.PRESSURE_PUMP_INTERVAL.setValue(interval);
// 3. 最近一次启动时长
long duration = pressurePumpService.getAllPressurePumpStartStopDuration(dataList, dataListFilterTrue, dataListFilterFalse, nowStrLong);
PressurePumpAnalysisEnum.PRESSURE_PUMP_DURATION.setValue(duration);
// 4. 半小时启动
int halfFrequency = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.HALF_HOUR.getValue()), dateNow);
int halfFrequency = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.HALF_HOUR.getValue()), dataListFilterTrue, dateNow);
PressurePumpAnalysisEnum.PRESSURE_PUMP_HALF.setValue(halfFrequency);
// 5. 2小时启动
int twoFrequency = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.TWO_HOUR.getValue()), dateNow);
int twoFrequency = pressurePumpService.getAllPressurePumpStartFrequency(Double.parseDouble(PressurePumpRelateEnum.TWO_HOUR.getValue()), dataListFilterTrue, dateNow);
PressurePumpAnalysisEnum.PRESSURE_PUMP_TWO.setValue(twoFrequency);
// 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());
}
return PressurePumpAnalysisEnum.getList();
}
private List<IotDataVO> getIotData(String top, String prefix, String indexKey) {
List<IotDataVO> DataList = new ArrayList<>();
List<Map<String, String>> iotDataList = pressurePumpService.getIotTopSingleField(top, prefix, null, null, indexKey);
//将iot的List<Map<String, String>>转化为List<IotDataVO>类型
iotDataList.stream().forEach(e -> {
try {
IotDataVO iotDataVO = (IotDataVO) supervisionVideoService.mapToObject(e, IotDataVO.class);
DataList.add(iotDataVO);
} catch (Exception el) {
throw new BadRequest("IOT数据类型转换失败");
}
});
return DataList;
}
@Override
public Map<String, Object> getPressurePumpStatusChart(String startTime, String endTime, String bizOrgCode) {
Map<String, Object> map = new LinkedHashMap<>();
......
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