1.pms配网查询信息优化
This commit is contained in:
@@ -33,13 +33,7 @@
|
||||
SELECT
|
||||
event_id as eventId,
|
||||
measurement_point_id as measurementPointId,
|
||||
Event_Type as eventType,
|
||||
start_time as startTime,
|
||||
Duration as duration,
|
||||
feature_amplitude as featureAmplitude,
|
||||
phase as phase,
|
||||
event_describe as eventDescribe,
|
||||
wave_path as wavePath
|
||||
Event_Type as eventType
|
||||
FROM
|
||||
r_mp_event_detail
|
||||
WHERE
|
||||
@@ -67,32 +61,29 @@
|
||||
SELECT
|
||||
event_id as eventId,
|
||||
measurement_point_id as measurementPointId,
|
||||
Event_Type as eventType,
|
||||
start_time as startTime,
|
||||
Duration as duration,
|
||||
feature_amplitude as featureAmplitude,
|
||||
phase as phase,
|
||||
event_describe as eventDescribe,
|
||||
wave_path as wavePath
|
||||
Event_Type as eventType
|
||||
FROM
|
||||
r_mp_event_detail
|
||||
WHERE
|
||||
measurement_point_id IN
|
||||
<foreach collection="monitorIds" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
<if test="eventType != null and eventType.size() >0">
|
||||
AND Event_Type IN
|
||||
<foreach collection="eventType" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND DATE_FORMAT(start_time, '%Y-%m') >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND DATE_FORMAT(start_time, '%Y-%m') <= #{endTime}
|
||||
</if>
|
||||
<where>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND DATE_FORMAT(start_time, '%Y-%m') >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND DATE_FORMAT(start_time, '%Y-%m') <= #{endTime}
|
||||
</if>
|
||||
<if test="monitorIds != null and monitorIds.size() != 0 ">
|
||||
and measurement_point_id IN
|
||||
<foreach collection="monitorIds" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="eventType != null and eventType.size() >0">
|
||||
AND Event_Type IN
|
||||
<foreach collection="eventType" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectByIdAndValue" resultType="com.njcn.event.pojo.po.EventDetailNew">
|
||||
SELECT
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
@@ -54,17 +55,17 @@ public class PwEventMonitorReportServiceImpl implements PwEventMonitorReportServ
|
||||
*/
|
||||
@Override
|
||||
public List<EventMonitorReportVO> getMonitorEventCount(EventMonitorReportParam eventMonitorReportParam) {
|
||||
List<EventMonitorReportVO> resultList = new ArrayList<>();
|
||||
//提取查询参数
|
||||
|
||||
String startTime = eventMonitorReportParam.getStartTime(); //开始时间
|
||||
String endTime = eventMonitorReportParam.getEndTime(); //结束时间
|
||||
Integer type = eventMonitorReportParam.getType(); //时间类型(日/月)
|
||||
|
||||
//查询监测点信息
|
||||
List<PwPmsMonitorDTO> monitorList = this.getMonitorList(eventMonitorReportParam);
|
||||
List<String> monitorIdList = monitorList.stream().map(PwPmsMonitorDTO::getMonitorId).collect(Collectors.toList()); //监测点id信息
|
||||
|
||||
Map<String, PwPmsMonitorDTO> monitorMap = monitorList.stream().collect(Collectors.toMap(PwPmsMonitorDTO::getMonitorId, Function.identity(),(kye1,key2)->kye1));
|
||||
// List<PwPmsMonitorDTO> monitorList = this.getMonitorList(eventMonitorReportParam);
|
||||
PwPmsMonitorParam pwPmsMonitorParam = new PwPmsMonitorParam();
|
||||
pwPmsMonitorParam.setOrgId(eventMonitorReportParam.getId());
|
||||
List<String> monitorIdList = pmsGeneralDeviceInfoClient.getPwPmsMonitorIds(pwPmsMonitorParam).getData();
|
||||
|
||||
//获取电压等级的字典
|
||||
List<DictData> voltageLevelList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
|
||||
@@ -85,48 +86,57 @@ public class PwEventMonitorReportServiceImpl implements PwEventMonitorReportServ
|
||||
detailList = rmpEventDetailMapper.getDetailsOfTransientEvents(monitorIdList, null, startTime, endTime);
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(detailList)) {
|
||||
//todo 获取监测点信息接口
|
||||
pwPmsMonitorParam.setMonitorName(eventMonitorReportParam.getMonitorName());
|
||||
//台区名称(监测点名称)
|
||||
pwPmsMonitorParam.setIds(detailList.stream().map(RmpEventDetailPO::getMeasurementPointId).distinct().collect(Collectors.toList()));
|
||||
List<PwPmsMonitorDTO> monitorList = pwMonitorClient.getPwNewMonitorList(pwPmsMonitorParam).getData();
|
||||
|
||||
Map<String, List<RmpEventDetailPO>> groupByMIdDetailMap = detailList.stream().collect(Collectors.groupingBy(RmpEventDetailPO::getMeasurementPointId, Collectors.toList()));
|
||||
List<EventMonitorReportVO> resultList = new ArrayList<>();
|
||||
groupByMIdDetailMap.forEach((key, monitorEventDetailList) -> {
|
||||
//封装返回需要返回的信息
|
||||
PwPmsMonitorDTO pmsMonitorDTO = monitorMap.get(key);
|
||||
Map<String, PwPmsMonitorDTO> monitorMap = monitorList.stream().collect(Collectors.toMap(PwPmsMonitorDTO::getMonitorId, Function.identity(),(kye1,key2)->kye1));
|
||||
|
||||
EventMonitorReportVO eventMonitorReportVO = new EventMonitorReportVO();
|
||||
eventMonitorReportVO.setDate(startTime); //查询时间
|
||||
//监测点基本信息
|
||||
eventMonitorReportVO.setMonitorId(pmsMonitorDTO.getMonitorId()); //监测点id
|
||||
eventMonitorReportVO.setMonitorName(pmsMonitorDTO.getMonitorName()); //监测点name
|
||||
eventMonitorReportVO.setOrgId(pmsMonitorDTO.getOrgId()); //单位id
|
||||
eventMonitorReportVO.setOrgName(pmsMonitorDTO.getOrgName()); //单位name
|
||||
eventMonitorReportVO.setVoltageLevel(pmsMonitorDTO.getVoltageLevel()); //监测点电压等级
|
||||
eventMonitorReportVO.setVoltageLevelName(voltageLevelMap.get(pmsMonitorDTO.getVoltageLevel())); //监测点电压等级名称
|
||||
//暂升、暂降、短时中断次数
|
||||
Map<String, List<RmpEventDetailPO>> countMap = monitorEventDetailList.stream().collect(Collectors.groupingBy(RmpEventDetailPO::getEventType, Collectors.toList()));
|
||||
countMap.forEach((countKey, value) -> {
|
||||
String code = eventStatisMap.get(countKey).getCode();
|
||||
//电压暂降次数
|
||||
if (DicDataEnum.VOLTAGE_DIP.getCode().equalsIgnoreCase(code)) {
|
||||
eventMonitorReportVO.setVoltageDipCount(CollUtil.isNotEmpty(value) ? value.size() : 0);
|
||||
}
|
||||
//电压暂升次数
|
||||
if (DicDataEnum.VOLTAGE_RISE.getCode().equalsIgnoreCase(code)) {
|
||||
eventMonitorReportVO.setVoltageRiseCount(CollUtil.isNotEmpty(value) ? value.size() : 0);
|
||||
}
|
||||
//短时中断
|
||||
if (DicDataEnum.SHORT_INTERRUPTIONS.getCode().equalsIgnoreCase(code)) {
|
||||
eventMonitorReportVO.setShortInterruptionCount(CollUtil.isNotEmpty(value) ? value.size() : 0);
|
||||
}
|
||||
Map<String, List<RmpEventDetailPO>> groupByMIdDetailMap = detailList.stream().collect(Collectors.groupingBy(RmpEventDetailPO::getMeasurementPointId, Collectors.toList()));
|
||||
|
||||
groupByMIdDetailMap.forEach((key, monitorEventDetailList) -> {
|
||||
//封装返回需要返回的信息
|
||||
if (monitorMap.containsKey(key)) {
|
||||
PwPmsMonitorDTO pmsMonitorDTO = monitorMap.get(key);
|
||||
EventMonitorReportVO eventMonitorReportVO = new EventMonitorReportVO();
|
||||
eventMonitorReportVO.setDate(startTime); //查询时间
|
||||
//监测点基本信息
|
||||
eventMonitorReportVO.setMonitorId(pmsMonitorDTO.getMonitorId()); //监测点id
|
||||
eventMonitorReportVO.setMonitorName(pmsMonitorDTO.getMonitorName()); //监测点name
|
||||
eventMonitorReportVO.setOrgId(pmsMonitorDTO.getOrgId()); //单位id
|
||||
eventMonitorReportVO.setOrgName(pmsMonitorDTO.getOrgName()); //单位name
|
||||
eventMonitorReportVO.setVoltageLevel(pmsMonitorDTO.getVoltageLevel()); //监测点电压等级
|
||||
eventMonitorReportVO.setVoltageLevelName(voltageLevelMap.get(pmsMonitorDTO.getVoltageLevel())); //监测点电压等级名称
|
||||
//暂升、暂降、短时中断次数
|
||||
Map<String, List<RmpEventDetailPO>> countMap = monitorEventDetailList.stream().collect(Collectors.groupingBy(RmpEventDetailPO::getEventType, Collectors.toList()));
|
||||
countMap.forEach((countKey, value) -> {
|
||||
String code = eventStatisMap.get(countKey).getCode();
|
||||
//电压暂降次数
|
||||
if (DicDataEnum.VOLTAGE_DIP.getCode().equalsIgnoreCase(code)) {
|
||||
eventMonitorReportVO.setVoltageDipCount(CollUtil.isNotEmpty(value) ? value.size() : 0);
|
||||
}
|
||||
//电压暂升次数
|
||||
if (DicDataEnum.VOLTAGE_RISE.getCode().equalsIgnoreCase(code)) {
|
||||
eventMonitorReportVO.setVoltageRiseCount(CollUtil.isNotEmpty(value) ? value.size() : 0);
|
||||
}
|
||||
//短时中断
|
||||
if (DicDataEnum.SHORT_INTERRUPTIONS.getCode().equalsIgnoreCase(code)) {
|
||||
eventMonitorReportVO.setShortInterruptionCount(CollUtil.isNotEmpty(value) ? value.size() : 0);
|
||||
}
|
||||
|
||||
});
|
||||
//重新校验设置属性值,避免值是null
|
||||
eventMonitorReportVO.setVoltageDipCount(eventMonitorReportVO.getVoltageDipCount() == null ? 0 : eventMonitorReportVO.getVoltageDipCount());
|
||||
eventMonitorReportVO.setVoltageRiseCount(eventMonitorReportVO.getVoltageRiseCount() == null ? 0 : eventMonitorReportVO.getVoltageRiseCount());
|
||||
eventMonitorReportVO.setShortInterruptionCount(eventMonitorReportVO.getShortInterruptionCount() == null ? 0 : eventMonitorReportVO.getShortInterruptionCount());
|
||||
|
||||
resultList.add(eventMonitorReportVO);
|
||||
}
|
||||
});
|
||||
//重新校验设置属性值,避免值是null
|
||||
eventMonitorReportVO.setVoltageDipCount(eventMonitorReportVO.getVoltageDipCount() == null ? 0 : eventMonitorReportVO.getVoltageDipCount());
|
||||
eventMonitorReportVO.setVoltageRiseCount(eventMonitorReportVO.getVoltageRiseCount() == null ? 0 : eventMonitorReportVO.getVoltageRiseCount());
|
||||
eventMonitorReportVO.setShortInterruptionCount(eventMonitorReportVO.getShortInterruptionCount() == null ? 0 : eventMonitorReportVO.getShortInterruptionCount());
|
||||
|
||||
resultList.add(eventMonitorReportVO);
|
||||
});
|
||||
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@@ -333,25 +343,4 @@ public class PwEventMonitorReportServiceImpl implements PwEventMonitorReportServ
|
||||
list.add(entity110);
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取单位(及子孙单位)下的监测点信息(抽取的公共方法)
|
||||
* @author jianghaifei
|
||||
* @date 2022-10-29 17:37
|
||||
* @param eventMonitorReportParam
|
||||
* @return java.util.List<com.njcn.device.pms.pojo.dto.PmsMonitorDTO>
|
||||
*/
|
||||
private List<PwPmsMonitorDTO> getMonitorList(EventMonitorReportParam eventMonitorReportParam) {
|
||||
//提起参数
|
||||
String id = eventMonitorReportParam.getId(); //单位id
|
||||
String monitorName = eventMonitorReportParam.getMonitorName(); //台区名称
|
||||
|
||||
//根据条件查询单位下面的所有配网监测点
|
||||
PwPmsMonitorParam pwPmsMonitorParam = new PwPmsMonitorParam();
|
||||
pwPmsMonitorParam.setOrgId(id); //单位id
|
||||
pwPmsMonitorParam.setMonitorName(monitorName); //台区名称(监测点名称)
|
||||
List<PwPmsMonitorDTO> pwMonitorList = pwMonitorClient.getPwMonitorList(pwPmsMonitorParam).getData();
|
||||
|
||||
return pwMonitorList;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user