河北PMS算法调整-监测点告警统计查询接口调整
This commit is contained in:
@@ -18,6 +18,8 @@ public class LineDevGetDTO {
|
||||
*/
|
||||
private String unitId;
|
||||
|
||||
private String unitName;
|
||||
|
||||
/**
|
||||
* 监测点索引
|
||||
*/
|
||||
|
||||
@@ -153,6 +153,8 @@ public class CommTerminalServiceImpl implements CommTerminalService {
|
||||
if (finalMap.containsKey(i)) {
|
||||
finalMap.get(i).forEach(it -> {
|
||||
LineDevGetDTO lineDevGetDTO = new LineDevGetDTO();
|
||||
lineDevGetDTO.setUnitId(it.getOrgId());
|
||||
lineDevGetDTO.setUnitName(it.getOrgName());
|
||||
lineDevGetDTO.setPointId(it.getId());
|
||||
lineDevGetDTO.setInterval(it.getStatisticalInterval());
|
||||
lineDevGetDTO.setDevId(it.getTerminalId());
|
||||
@@ -160,6 +162,7 @@ public class CommTerminalServiceImpl implements CommTerminalService {
|
||||
lineDevGetDTO.setLineType(1);
|
||||
lineDevGetDTO.setLineTag(it.getMonitorTag());
|
||||
lineDevGetDTO.setObjType(it.getObjType());
|
||||
lineDevGetDTO.setPointName(it.getName());
|
||||
//预处理模块需要的id修改value为id
|
||||
lineDevGetDTO.setVoltageLevel(it.getVoltageLevel());
|
||||
lineDevGetDTO.setIsUpToGrid(it.getIsUpToGrid());
|
||||
|
||||
@@ -5,11 +5,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO;
|
||||
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
|
||||
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
|
||||
import com.njcn.device.pms.mapper.majornetwork.RMpMonitorAlarmCountMMapper;
|
||||
import com.njcn.device.pms.pojo.param.RMpMonitorAlarmCountMParam;
|
||||
import com.njcn.device.pms.pojo.po.Monitor;
|
||||
import com.njcn.device.pms.pojo.po.RMpMonitorAlarmCountM;
|
||||
import com.njcn.device.pms.pojo.vo.RMpMonitorAlarmCountMVO;
|
||||
import com.njcn.device.pms.service.ledgerManger.CommTerminalService;
|
||||
import com.njcn.device.pms.service.majornetwork.IMonitorService;
|
||||
import com.njcn.device.pms.service.majornetwork.RMpMonitorAlarmCountMService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
@@ -24,10 +28,7 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -47,6 +48,8 @@ implements RMpMonitorAlarmCountMService {
|
||||
|
||||
private final IMonitorService iMonitorService; //【主网监测点】服务类
|
||||
|
||||
private final CommTerminalService commTerminalService;
|
||||
|
||||
/***
|
||||
* 根据条件查询监测点告警统计(月)(主网)
|
||||
* @author jianghaifei
|
||||
@@ -56,6 +59,7 @@ implements RMpMonitorAlarmCountMService {
|
||||
*/
|
||||
@Override
|
||||
public List<RMpMonitorAlarmCountMVO> getRMpMonitorAlarmCountMList(RMpMonitorAlarmCountMParam rMpMonitorAlarmCountMParam) {
|
||||
List<RMpMonitorAlarmCountMVO> resultList = new ArrayList<>();
|
||||
//提取查询条件
|
||||
String id = rMpMonitorAlarmCountMParam.getId(); //单位id
|
||||
if (StringUtils.isBlank(id)) {
|
||||
@@ -63,72 +67,78 @@ implements RMpMonitorAlarmCountMService {
|
||||
}
|
||||
String startTime = rMpMonitorAlarmCountMParam.getStartTime(); //开始时间
|
||||
String endTime = rMpMonitorAlarmCountMParam.getEndTime(); //结束时间
|
||||
String monitorObjectType = rMpMonitorAlarmCountMParam.getMonitorObjectType(); //监测点对象类型id
|
||||
//监测对象类型
|
||||
if (StringUtils.isBlank(rMpMonitorAlarmCountMParam.getMonitorObjectType())){
|
||||
return resultList;
|
||||
}
|
||||
List<String> monitorObjectType = StringUtils.isNotBlank(rMpMonitorAlarmCountMParam.getMonitorObjectType()) ? Arrays.asList(rMpMonitorAlarmCountMParam.getMonitorObjectType().split(",")) : null;
|
||||
//电压等级
|
||||
if (StringUtils.isBlank(rMpMonitorAlarmCountMParam.getVoltageLevel())){
|
||||
return resultList;
|
||||
}
|
||||
List<String> voltageLevelParamList = StringUtils.isNotBlank(rMpMonitorAlarmCountMParam.getVoltageLevel()) ? Arrays.asList(rMpMonitorAlarmCountMParam.getVoltageLevel().split(",")) : null; //电压等级
|
||||
String monitorName = rMpMonitorAlarmCountMParam.getMeasurementPointName(); //监测点名称
|
||||
|
||||
//获取所有子部门信息
|
||||
// List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(id, WebUtil.filterDeptType()).getData();
|
||||
/*获取下级子部门信息*/
|
||||
List<DeptDTO> deptDTOList = deptFeignClient.getDepSonDetailByDeptId (id).getData ( );
|
||||
if (CollUtil.isEmpty(deptDTOList)) {
|
||||
throw new BusinessException(CommonResponseEnum.NO_DATA, "部门不存在");
|
||||
}
|
||||
//单位code集合
|
||||
List<String> orgCodeList = deptDTOList.stream().map(DeptDTO::getCode).collect(Collectors.toList());
|
||||
//将单位信息转为map集合 key: 单位code value: 单位实体
|
||||
Map<String, DeptDTO> deptDTOMap = deptDTOList.stream().collect(Collectors.toMap(DeptDTO::getCode, deptDTO -> deptDTO));
|
||||
|
||||
//获取电压等级的字典
|
||||
List<DictData> voltageLevelList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
|
||||
//将电压等级信息转成map,key:id value:name
|
||||
Map<String, String> voltageLevelMap = voltageLevelList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));
|
||||
//获取监测点类型字典
|
||||
List<DictData> monitorTypeList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.LINE_TYPE.getCode()).getData();
|
||||
//获取监测点标签字典
|
||||
List<DictData> monitorTypeList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.MONITORING_LABELS.getCode()).getData();
|
||||
//将监测点类型字典信息转为map集合 key: 字典id value: 字典名称
|
||||
Map<String, String> monitorTypeMap = monitorTypeList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));
|
||||
//获取主网id
|
||||
String dataType = dicDataFeignClient.getDicDataByCode(DicDataEnum.MAINNET_POINT.getCode()).getData().getId();
|
||||
//根据部门id获取监测点
|
||||
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
|
||||
deptGetLineParam.setDeptId(id);
|
||||
List<DeptGetChildrenMoreDTO> dept = commTerminalService.deptGetLine(deptGetLineParam);
|
||||
List<LineDevGetDTO> lineDto = new ArrayList<>();
|
||||
|
||||
//根据条件查询单位下面的所有监测点
|
||||
LambdaQueryWrapper<Monitor> monitorLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
monitorLambdaQueryWrapper.in(Monitor::getOrgId, orgCodeList) //单位code
|
||||
.eq(StringUtils.isNotBlank(monitorObjectType), Monitor::getMonitorTag, monitorObjectType) //监测点对象类型id
|
||||
.in(CollUtil.isNotEmpty(voltageLevelParamList), Monitor::getVoltageLevel, voltageLevelParamList) //电压等级id
|
||||
.like(StringUtils.isNotBlank(monitorName), Monitor::getName, monitorName); //监测点名称
|
||||
//监测点集合
|
||||
List<Monitor> monitorList = iMonitorService.list(monitorLambdaQueryWrapper);
|
||||
//监测点id集合
|
||||
List<String> monitorIdList = monitorList.stream().map(Monitor::getId).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(monitorIdList)) {
|
||||
return new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(dept)){
|
||||
for (DeptGetChildrenMoreDTO item : dept) {
|
||||
lineDto.addAll(item.getLineBaseList());
|
||||
}
|
||||
//获取监测点集合(去重、根据前端传递的参数)
|
||||
if (CollUtil.isNotEmpty(lineDto)){
|
||||
lineDto = lineDto.stream().collect(
|
||||
Collectors.collectingAndThen(
|
||||
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(LineDevGetDTO::getPointId))), ArrayList::new));
|
||||
//根据前端传递的条件筛选监测点
|
||||
lineDto = lineDto.stream().filter(pojo-> monitorObjectType.contains(pojo.getLineTag()) && voltageLevelParamList.contains(pojo.getVoltageLevel())).collect(Collectors.toList());
|
||||
if (!Objects.isNull(monitorName)){
|
||||
lineDto = lineDto.stream().filter(pojo->pojo.getPointName().contains(monitorName)).collect(Collectors.toList());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(lineDto)){
|
||||
List<String> lineList = lineDto.stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<RMpMonitorAlarmCountM> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(RMpMonitorAlarmCountM::getMeasurementPointId, lineList)
|
||||
.ge(RMpMonitorAlarmCountM::getDataDate, startTime)
|
||||
.le(RMpMonitorAlarmCountM::getDataDate, endTime);
|
||||
List<RMpMonitorAlarmCountM> alarmCountMList = this.list(lambdaQueryWrapper);
|
||||
Map<String,List<RMpMonitorAlarmCountM>> map = alarmCountMList.stream().collect(Collectors.groupingBy(RMpMonitorAlarmCountM::getMeasurementPointId));
|
||||
for (LineDevGetDTO item2 : lineDto) {
|
||||
RMpMonitorAlarmCountMVO vo = new RMpMonitorAlarmCountMVO();
|
||||
if (CollUtil.isNotEmpty(map.get(item2.getPointId()))){
|
||||
BeanUtils.copyProperties(map.get(item2.getPointId()).get(0), vo);
|
||||
}
|
||||
//所属单位名称
|
||||
vo.setOrgName(item2.getUnitId());
|
||||
vo.setOrgNo(item2.getUnitName());
|
||||
vo.setMeasurementPointId(item2.getPointId());
|
||||
vo.setMeasurementPointName(item2.getPointName());
|
||||
//监测点类型id
|
||||
vo.setMonitorType(item2.getLineTag());
|
||||
//监测点类型名称
|
||||
vo.setMonitorTypeName(monitorTypeMap.get(item2.getLineTag()));
|
||||
//电压等级id
|
||||
vo.setVoltageLevel(item2.getVoltageLevel());
|
||||
//电压等级
|
||||
vo.setVoltageLevelName(voltageLevelMap.get(item2.getVoltageLevel()));
|
||||
resultList.add(vo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//监测点map key:监测点id value:监测点实体
|
||||
Map<String, Monitor> monitorMap = monitorList.stream().collect(Collectors.toMap(Monitor::getId, monitor -> monitor));
|
||||
//根据监测点idList等条件查询【监测点告警月统计】表数据
|
||||
LambdaQueryWrapper<RMpMonitorAlarmCountM> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(RMpMonitorAlarmCountM::getMeasurementPointId, monitorIdList)
|
||||
.ge(RMpMonitorAlarmCountM::getDataDate, startTime)
|
||||
.le(RMpMonitorAlarmCountM::getDataDate, endTime);
|
||||
List<RMpMonitorAlarmCountM> alarmCountMList = this.list(lambdaQueryWrapper);
|
||||
List<RMpMonitorAlarmCountMVO> resultList;
|
||||
if (CollUtil.isNotEmpty(alarmCountMList)) {
|
||||
//封装前端展示的数据
|
||||
resultList = alarmCountMList.stream().map(item -> {
|
||||
RMpMonitorAlarmCountMVO rMpMonitorAlarmCountMVO = new RMpMonitorAlarmCountMVO();
|
||||
BeanUtils.copyProperties(item, rMpMonitorAlarmCountMVO);
|
||||
//单位信息
|
||||
rMpMonitorAlarmCountMVO.setOrgName(deptDTOMap.get(monitorMap.get(item.getMeasurementPointId()).getOrgId()).getName()); //所属单位名称
|
||||
//监测点信息
|
||||
rMpMonitorAlarmCountMVO.setMeasurementPointName(monitorMap.get(item.getMeasurementPointId()).getName());//监测点名称
|
||||
rMpMonitorAlarmCountMVO.setMonitorTypeName(monitorTypeMap.get(monitorMap.get(item.getMeasurementPointId()).getMonitorType()));//监测点类型名称
|
||||
rMpMonitorAlarmCountMVO.setMonitorType(monitorMap.get(item.getMeasurementPointId()).getMonitorType());//监测点类型id
|
||||
rMpMonitorAlarmCountMVO.setVoltageLevel(monitorMap.get(item.getMeasurementPointId()).getVoltageLevel()); //电压等级id
|
||||
rMpMonitorAlarmCountMVO.setVoltageLevelName(voltageLevelMap.get(monitorMap.get(item.getMeasurementPointId()).getVoltageLevel())); //电压等级
|
||||
return rMpMonitorAlarmCountMVO;
|
||||
}).collect(Collectors.toList());
|
||||
} else {
|
||||
resultList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(resultList)){
|
||||
resultList = resultList.stream().sorted(Comparator.comparing(RMpMonitorAlarmCountMVO::getOrgName).reversed()).collect(Collectors.toList());
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user