代码调整

This commit is contained in:
2022-11-10 10:36:08 +08:00
parent 6a3a05d45f
commit 75563a8e24
169 changed files with 1138 additions and 7595 deletions

View File

@@ -6,9 +6,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.event.pojo.param.EventMonitorReportParam;
import com.njcn.event.pojo.vo.EventDipShortDistributionVO;
import com.njcn.event.pojo.vo.EventMonitorReportVO;
import com.njcn.event.pojo.vo.EventRiseDistributionVO;
import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.EventMonitorReportService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
@@ -37,30 +35,53 @@ public class EventMonitorReportController extends BaseController {
private final EventMonitorReportService eventMonitorReportService;
@PostMapping("getDailyReport")
/***
* @author jianghaifei
* @date 2022-10-29 16:37
* @param eventMonitorReportParam
* @return com.njcn.common.pojo.response.HttpResult<java.util.List<com.njcn.event.pojo.vo.EventMonitorReportVO>>
*/
@PostMapping("getMonitorEventCount")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("暂态指标监测点日报")
public HttpResult<List<EventMonitorReportVO>> getDailyReport(@RequestBody EventMonitorReportParam eventMonitorReportParam) {
String methodDescribe = getMethodDescribe("getDailyReport");
List<EventMonitorReportVO> list = eventMonitorReportService.getDailyReport(eventMonitorReportParam);
@ApiOperation("监测点暂态事件发生次数")
public HttpResult<List<EventMonitorReportVO>> getMonitorEventCount(@RequestBody EventMonitorReportParam eventMonitorReportParam) {
String methodDescribe = getMethodDescribe("getMonitorEventCount");
List<EventMonitorReportVO> list = eventMonitorReportService.getMonitorEventCount(eventMonitorReportParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
/***
*
* @author jianghaifei
* @date 2022-10-29 14:08
* @param eventMonitorReportParam
* @return com.njcn.common.pojo.response.HttpResult<com.njcn.event.pojo.vo.EventDipShortDistributionVO>
*/
@PostMapping("getEventDipShortDistribution")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("暂态指标监测点电压暂降和短时中断分布情况")
public HttpResult<EventDipShortDistributionVO> getEventDipShortDistribution(@RequestBody EventMonitorReportParam eventMonitorReportParam) {
public HttpResult<List<EventDipShortDistributionTableVO>> getEventDipShortDistribution(@RequestBody EventMonitorReportParam eventMonitorReportParam) {
String methodDescribe = getMethodDescribe("getEventDipShortDistribution");
EventDipShortDistributionVO eventDipShortDistributionVO = eventMonitorReportService.getEventDipShortDistributionByCond(eventMonitorReportParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventDipShortDistributionVO, methodDescribe);
List<EventDipShortDistributionTableVO> list = eventMonitorReportService.getEventDipShortDistributionByCond(eventMonitorReportParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
/***
*
* @author jianghaifei
* @date 2022-10-29 14:08
* @param eventMonitorReportParam
* @return com.njcn.common.pojo.response.HttpResult<com.njcn.event.pojo.vo.EventRiseDistributionVO>
*/
@PostMapping("getEventRiseDistribution")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("暂态指标监测点电压暂升分布情况")
public HttpResult<EventRiseDistributionVO> getEventRiseDistribution(@RequestBody EventMonitorReportParam eventMonitorReportParam) {
public HttpResult<List<EventRiseDistributionTableVO>> getEventRiseDistribution(@RequestBody EventMonitorReportParam eventMonitorReportParam) {
String methodDescribe = getMethodDescribe("getEventRiseDistribution");
EventRiseDistributionVO eventRiseDistributionVO = eventMonitorReportService.getEventRiseDistributionByCond(eventMonitorReportParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventRiseDistributionVO, methodDescribe);
List<EventRiseDistributionTableVO> list = eventMonitorReportService.getEventRiseDistributionByCond(eventMonitorReportParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -2,6 +2,7 @@ package com.njcn.event.mapper.distribution;
import com.njcn.event.pojo.param.UniversalFrontEndParam;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -23,4 +24,34 @@ public interface PwRmpEventDetailMapper {
* @date 2022/10/31
*/
List<RmpEventDetailPO> getPwRmpEventDetail(UniversalFrontEndParam param);
/**
* 获取暂态事件明细
*
* @param monitorIds 监测点id
* @param eventType 暂态指标类型
* @param startTime 开始时间
* @param endTime 结束时间
* @return 暂态事件明细
*/
List<RmpEventDetailPO> getDetailsOfTransientEvents(@Param("monitorIds") List<String> monitorIds,
@Param("eventType") List<String> eventType,
@Param("startTime") String startTime,
@Param("endTime") String endTime);
/***
* 与上面的方法区别是日期精确到月 yy-MM
* @author jianghaifei
* @date 2022-10-31 16:27
* @param monitorIds
* @param eventType
* @param startTime
* @param endTime
* @return java.util.List<com.njcn.event.pojo.po.RmpEventDetailPO>
*/
List<RmpEventDetailPO> getDetailsOfTransientEventsByMonth(@Param("monitorIds") List<String> monitorIds,
@Param("eventType") List<String> eventType,
@Param("startTime") String startTime,
@Param("endTime") String endTime);
}

View File

@@ -17,4 +17,70 @@
FROM
r_mp_event_detail
</select>
<select id="getDetailsOfTransientEvents" resultType="com.njcn.event.pojo.po.RmpEventDetailPO">
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
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-%d') &gt;= DATE_FORMAT(#{startTime}, '%Y-%m-%d')
</if>
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endTime}, '%Y-%m-%d')
</if>
</select>
<!-- 获取暂态事件明细 与上面的方法区别是日期精确到月 yy-MM -->
<select id="getDetailsOfTransientEventsByMonth" resultType="com.njcn.event.pojo.po.RmpEventDetailPO">
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
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') &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m') &lt;= #{endTime}
</if>
</select>
</mapper>

View File

@@ -30,4 +30,19 @@ public interface RmpEventDetailMapper extends BaseMapper<RmpEventDetailVO> {
@Param("eventType") List<String> eventType,
@Param("startTime") String startTime,
@Param("endTime") String endTime);
/***
* 与上面的方法区别是日期精确到月 yy-MM
* @author jianghaifei
* @date 2022-10-31 16:27
* @param monitorIds
* @param eventType
* @param startTime
* @param endTime
* @return java.util.List<com.njcn.event.pojo.po.RmpEventDetailPO>
*/
List<RmpEventDetailPO> getDetailsOfTransientEventsByMonth(@Param("monitorIds") List<String> monitorIds,
@Param("eventType") List<String> eventType,
@Param("startTime") String startTime,
@Param("endTime") String endTime);
}

View File

@@ -387,12 +387,24 @@
#{type}
</foreach>
<if test="startTime != null and startTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m-%d') &gt;= DATE_FORMAT(#{startTime}, '%Y-%m-%d')
</if>
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endTime}, '%Y-%m-%d')
</if>
<choose>
<when test="dateType != null and dateType == 3">
<if test="startTime != null and startTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m') &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m') &lt;= #{endTime}
</if>
</when>
<when test="dateType != null and dateType == 5">
<if test="startTime != null and startTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m-%d') &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m-%d') &lt;= #{endTime}
</if>
</when>
</choose>
)
r
</select>
@@ -426,12 +438,24 @@
#{type}
</foreach>
<if test="startTime != null and startTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m-%d') &gt;= DATE_FORMAT(#{startTime}, '%Y-%m-%d')
</if>
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endTime}, '%Y-%m-%d')
</if>
<choose>
<when test="dateType != null and dateType == 3">
<if test="startTime != null and startTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m') &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m') &lt;= #{endTime}
</if>
</when>
<when test="dateType != null and dateType == 5">
<if test="startTime != null and startTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m-%d') &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m-%d') &lt;= #{endTime}
</if>
</when>
</choose>
)
r
</select>

View File

@@ -32,4 +32,37 @@
AND DATE_FORMAT(start_time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endTime}, '%Y-%m-%d')
</if>
</select>
<!-- 获取暂态事件明细 与上面的方法区别是日期精确到月 yy-MM -->
<select id="getDetailsOfTransientEventsByMonth" resultType="com.njcn.event.pojo.po.RmpEventDetailPO">
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
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') &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND DATE_FORMAT(start_time, '%Y-%m') &lt;= #{endTime}
</if>
</select>
</mapper>

View File

@@ -1,9 +1,7 @@
package com.njcn.event.service.majornetwork;
import com.njcn.event.pojo.param.EventMonitorReportParam;
import com.njcn.event.pojo.vo.EventDipShortDistributionVO;
import com.njcn.event.pojo.vo.EventMonitorReportVO;
import com.njcn.event.pojo.vo.EventRiseDistributionVO;
import com.njcn.event.pojo.vo.*;
import java.util.List;
@@ -16,9 +14,12 @@ import java.util.List;
*/
public interface EventMonitorReportService {
List<EventMonitorReportVO> getDailyReport(EventMonitorReportParam eventMonitorReportParam);
//监测点暂态事件发生次数
List<EventMonitorReportVO> getMonitorEventCount(EventMonitorReportParam eventMonitorReportParam);
EventDipShortDistributionVO getEventDipShortDistributionByCond(EventMonitorReportParam eventMonitorReportParam);
//暂态指标监测点电压暂降和短时中断分布情况
List<EventDipShortDistributionTableVO> getEventDipShortDistributionByCond(EventMonitorReportParam eventMonitorReportParam);
EventRiseDistributionVO getEventRiseDistributionByCond(EventMonitorReportParam eventMonitorReportParam);
//暂态指标监测点电压暂升分布情况
List<EventRiseDistributionTableVO> getEventRiseDistributionByCond(EventMonitorReportParam eventMonitorReportParam);
}

View File

@@ -68,7 +68,7 @@ public class EventDetailServiceImpl implements EventDetailService {
public List<EventDetail> getEventDetail(List<String> lineIndexes, String startTime, String endTime, List<Integer> waveType) {
//组装sql语句
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(startTime))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(endTime))).append("' and ");
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(startTime))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(endTime))).append("' and (");
for (int i = 0; i < lineIndexes.size(); i++) {
if (lineIndexes.size() - i != 1) {
stringBuilder.append("line_id ='").append(lineIndexes.get(i)).append("' or ");
@@ -76,18 +76,18 @@ public class EventDetailServiceImpl implements EventDetailService {
stringBuilder.append("line_id ='").append(lineIndexes.get(i)).append("' ");
}
}
stringBuilder.append(" and ");
stringBuilder.append(") and (");
for (int i = 0; i < waveType.size(); i++) {
if (waveType.size() - i != 1) {
stringBuilder.append("wave_type ='").append(waveType.get(i)).append("' or ");
stringBuilder.append("wave_type =").append(waveType.get(i)).append(" or ");
} else {
stringBuilder.append("wave_type ='").append(waveType.get(i)).append("' ");
stringBuilder.append("wave_type =").append(waveType.get(i)).append(" ");
}
}
stringBuilder.append(") order by time desc ");
stringBuilder.append(" tz('Asia/Shanghai')");
//sql语句
String sql = "SELECT * FROM pqs_eventdetail WHERE " + stringBuilder;
System.out.println("sql------------->>>"+sql);
//结果集
QueryResult result = influxDbUtils.query(sql);
//结果集映射到对象中
@@ -102,7 +102,7 @@ public class EventDetailServiceImpl implements EventDetailService {
public List<EventDetail> getEventDetailLimit(List<String> lineIndexes, String startTime, String endTime, Integer pageSize, Integer pageNum, List<Integer> waveType) {
//组装sql语句
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(startTime))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(endTime))).append("' and ");
stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(startTime))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(endTime))).append("' and (");
for (int i = 0; i < lineIndexes.size(); i++) {
if (lineIndexes.size() - i != 1) {
stringBuilder.append("line_id ='").append(lineIndexes.get(i)).append("' or ");
@@ -110,20 +110,19 @@ public class EventDetailServiceImpl implements EventDetailService {
stringBuilder.append("line_id ='").append(lineIndexes.get(i)).append("' ");
}
}
stringBuilder.append(" and ");
stringBuilder.append(") and (");
for (int i = 0; i < waveType.size(); i++) {
if (waveType.size() - i != 1) {
stringBuilder.append("wave_type ='").append(waveType.get(i)).append("' or ");
stringBuilder.append("wave_type =").append(waveType.get(i)).append(" or ");
} else {
stringBuilder.append("wave_type ='").append(waveType.get(i)).append("' ");
stringBuilder.append("wave_type =").append(waveType.get(i)).append(" ");
}
}
stringBuilder.append(") order by time desc ");
int i = (pageNum - 1)*pageSize;
stringBuilder.append("LIMIT ").append(pageSize).append(" OFFSET ").append(i).append(" tz('Asia/Shanghai')");
//sql语句
String sql = "SELECT * FROM pqs_eventdetail WHERE " + stringBuilder;
System.out.println(sql);
//结果集
QueryResult result = influxDbUtils.query(sql);
//结果集映射到对象中

View File

@@ -1,6 +1,7 @@
package com.njcn.event.service.majornetwork.Impl;
import cn.hutool.core.collection.CollUtil;
import com.njcn.common.pojo.constant.BizParamConstant;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.api.MonitorClient;
@@ -10,9 +11,7 @@ import com.njcn.event.mapper.majornetwork.EventDistributionStatisticsMapper;
import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper;
import com.njcn.event.pojo.param.EventMonitorReportParam;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.EventDipShortDistributionVO;
import com.njcn.event.pojo.vo.EventMonitorReportVO;
import com.njcn.event.pojo.vo.EventRiseDistributionVO;
import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.EventMonitorReportService;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
@@ -49,21 +48,39 @@ public class EventMonitorReportServiceImpl implements EventMonitorReportService
private final EventDistributionStatisticsMapper eventDistributionStatisticsMapper;
/***
* 监测点暂态事件发生次数
* @author jianghaifei
* @date 2022-10-29 18:05
* @param eventMonitorReportParam
* @return java.util.List<com.njcn.event.pojo.vo.EventMonitorReportVO>
*/
@Override
public List<EventMonitorReportVO> getDailyReport(EventMonitorReportParam eventMonitorReportParam) {
public List<EventMonitorReportVO> getMonitorEventCount(EventMonitorReportParam eventMonitorReportParam) {
//提取查询参数
String monitorName = eventMonitorReportParam.getMonitorName(); //监测点名称
String id = eventMonitorReportParam.getId(); //单位id
// String monitorName = eventMonitorReportParam.getMonitorName(); //监测点名称
// String id = eventMonitorReportParam.getId(); //单位id
String startTime = eventMonitorReportParam.getStartTime(); //开始时间
String endTime = eventMonitorReportParam.getEndTime(); //截止时间
String endTime = eventMonitorReportParam.getEndTime(); //结束时间
Integer type = eventMonitorReportParam.getType(); //时间类型(日/月)
/****** 获取监测点信息(version1.0) ******/
//获取所有子部门信息
List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(id, WebUtil.filterDeptType()).getData();
if (CollUtil.isEmpty(deptDTOList)) {
throw new BusinessException(CommonResponseEnum.NO_DATA, "部门不存在");
}
//单位id集合
List<String> orgNoList = deptDTOList.stream().map(DeptDTO::getId).collect(Collectors.toList());
// List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(id, WebUtil.filterDeptType()).getData();
// if (CollUtil.isEmpty(deptDTOList)) {
// throw new BusinessException(CommonResponseEnum.NO_DATA, "部门不存在");
// }
// //单位id集合
// List<String> orgNoList = deptDTOList.stream().map(DeptDTO::getId).collect(Collectors.toList());
// //查询监测点信息version1.0
// PmsMonitorParam pmsMonitorParam = new PmsMonitorParam();
// pmsMonitorParam.setMonitorName(monitorName); //监测点名称
// pmsMonitorParam.setOrgIds(orgNoList); //单位ids
// List<PmsMonitorDTO> monitorList = monitorClient.getMonitorInfoListByCond(pmsMonitorParam).getData(); //监测点信息
//查询监测点信息 (version2.0)
List<PmsMonitorDTO> monitorList = this.getMonitorList(eventMonitorReportParam);
List<String> monitorIdList = monitorList.stream().map(PmsMonitorDTO::getId).collect(Collectors.toList()); //监测点id信息
Map<String, PmsMonitorDTO> monitorMap = monitorList.stream().collect(Collectors.toMap(PmsMonitorDTO::getId, monitor -> monitor));
//获取电压等级的字典
List<DictData> voltageLevelList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
@@ -74,18 +91,17 @@ public class EventMonitorReportServiceImpl implements EventMonitorReportService
//将暂态指标信息转成mapkeyid value实体
Map<String, DictData> eventStatisMap = eventStatisList.stream().collect(Collectors.toMap(DictData::getId, data -> data));
//将暂态指标信息转成mapkeycode value实体
Map<String, DictData> eventStatisMapByCode = eventStatisList.stream().collect(Collectors.toMap(DictData::getCode, data -> data));
//查询监测点信息
PmsMonitorParam pmsMonitorParam = new PmsMonitorParam();
pmsMonitorParam.setMonitorName(monitorName); //监测点名称
pmsMonitorParam.setOrgIds(orgNoList); //单位ids
List<PmsMonitorDTO> monitorList = monitorClient.getMonitorInfoListByCond(pmsMonitorParam).getData(); //监测点信息
List<String> monitorIdList = monitorList.stream().map(PmsMonitorDTO::getId).collect(Collectors.toList()); //监测点id信息
Map<String, PmsMonitorDTO> monitorMap = monitorList.stream().collect(Collectors.toMap(PmsMonitorDTO::getId, monitor -> monitor));
// Map<String, DictData> eventStatisMapByCode = eventStatisList.stream().collect(Collectors.toMap(DictData::getCode, data -> data));
//查询暂态事件明细
List<RmpEventDetailPO> detailList = rmpEventDetailMapper.getDetailsOfTransientEvents(monitorIdList, null, startTime, endTime);
List<RmpEventDetailPO> detailList;
if (BizParamConstant.STAT_BIZ_MONTH.equals(type + "")) { //按月查
detailList = rmpEventDetailMapper.getDetailsOfTransientEventsByMonth(monitorIdList, null, startTime, endTime);
} else { //按日查
detailList = rmpEventDetailMapper.getDetailsOfTransientEvents(monitorIdList, null, startTime, endTime);
}
Map<String, List<RmpEventDetailPO>> groupByMIdDetailMap = detailList.stream().collect(Collectors.groupingBy(RmpEventDetailPO::getMeasurementPointId, Collectors.toList()));
List<EventMonitorReportVO> resultList = new ArrayList<>();
groupByMIdDetailMap.forEach((key, monitorEventDetailList) -> {
@@ -105,19 +121,21 @@ public class EventMonitorReportServiceImpl implements EventMonitorReportService
Map<String, List<RmpEventDetailPO>> countMap = monitorEventDetailList.stream().collect(Collectors.groupingBy(RmpEventDetailPO::getEventType, Collectors.toList()));
countMap.forEach((countKey, value) -> {
String code = eventStatisMap.get(countKey).getCode();
switch (code) {
case "Voltage_Dip":
eventMonitorReportVO.setVoltageDipCount(CollUtil.isNotEmpty(value) ? value.size() : 0); //电压暂降次数
break;
case "Voltage_Rise":
eventMonitorReportVO.setVoltageRiseCount(CollUtil.isNotEmpty(value) ? value.size() : 0); //电压暂升次数
break;
case "Short_Interruptions":
eventMonitorReportVO.setShortInterruptionCount(CollUtil.isNotEmpty(value) ? value.size() : 0); //短时中断
break;
default: break;
//电压暂降次数
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());
@@ -154,25 +172,29 @@ public class EventMonitorReportServiceImpl implements EventMonitorReportService
* @return com.njcn.event.pojo.vo.EventDipShortDistributionVO
*/
@Override
public EventDipShortDistributionVO getEventDipShortDistributionByCond(EventMonitorReportParam eventMonitorReportParam) {
public List<EventDipShortDistributionTableVO> getEventDipShortDistributionByCond(EventMonitorReportParam eventMonitorReportParam) {
//提取参数
String monitorName = eventMonitorReportParam.getMonitorName(); //监测点名称
String id = eventMonitorReportParam.getId(); //单位id
// String monitorName = eventMonitorReportParam.getMonitorName(); //监测点名称
// String id = eventMonitorReportParam.getId(); //单位id
String startTime = eventMonitorReportParam.getStartTime(); //开始时间
String endTime = eventMonitorReportParam.getEndTime(); //结束时间
Integer type = eventMonitorReportParam.getType(); //时间类型(日/月)
//获取所有子部门信息
List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(id, WebUtil.filterDeptType()).getData();
if (CollUtil.isEmpty(deptDTOList)) {
throw new BusinessException(CommonResponseEnum.NO_DATA, "部门不存在");
}
//单位id集合
List<String> orgNoList = deptDTOList.stream().map(DeptDTO::getId).collect(Collectors.toList());
//查询监测点信息
PmsMonitorParam pmsMonitorParam = new PmsMonitorParam();
pmsMonitorParam.setMonitorName(monitorName); //监测点名称
pmsMonitorParam.setOrgIds(orgNoList); //单位ids
List<PmsMonitorDTO> monitorList = monitorClient.getMonitorInfoListByCond(pmsMonitorParam).getData(); //监测点信息
/****** 获取监测点信息(version1.0) ******/
// //获取所有子部门信息
// List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(id, WebUtil.filterDeptType()).getData();
// if (CollUtil.isEmpty(deptDTOList)) {
// throw new BusinessException(CommonResponseEnum.NO_DATA, "部门不存在");
// }
// //单位id集合
// List<String> orgNoList = deptDTOList.stream().map(DeptDTO::getId).collect(Collectors.toList());
// //查询监测点信息
// PmsMonitorParam pmsMonitorParam = new PmsMonitorParam();
// pmsMonitorParam.setMonitorName(monitorName); //监测点名称
// pmsMonitorParam.setOrgIds(orgNoList); //单位ids
// List<PmsMonitorDTO> monitorList = monitorClient.getMonitorInfoListByCond(pmsMonitorParam).getData(); //监测点信息
//查询监测点信息(version2.0)
List<PmsMonitorDTO> monitorList = this.getMonitorList(eventMonitorReportParam);
List<String> monitorIdList = monitorList.stream().map(PmsMonitorDTO::getId).collect(Collectors.toList()); //监测点id集合
//获取暂态指标的字典
@@ -186,17 +208,207 @@ public class EventMonitorReportServiceImpl implements EventMonitorReportService
condMap.put("startTime", startTime);
condMap.put("endTime", endTime);
condMap.put("eventTypeList", Arrays.asList(eventStatisMapByCode.get(DicDataEnum.VOLTAGE_DIP.getCode()).getId(), eventStatisMapByCode.get(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getId()));
condMap.put("dateType", type);
EventDipShortDistributionVO eventDipShortDistribution = eventDistributionStatisticsMapper.getEventDipShortDistributionByCond(condMap);
return eventDistributionStatisticsMapper.getEventDipShortDistributionByCond(condMap);
//设置返回数据
List<EventDipShortDistributionTableVO> list = new ArrayList<>();
//特征幅值[80,90]
EventDipShortDistributionTableVO entity8090 = new EventDipShortDistributionTableVO();
entity8090.setFeatureAmplitude("[80,90]");
entity8090.setDuration100(eventDipShortDistribution.getFeatureAmp90with100ms()); //持续时间10ms-100ms
entity8090.setDuration250(eventDipShortDistribution.getFeatureAmp90with250ms()); //持续时间100ms-250ms
entity8090.setDuration500(eventDipShortDistribution.getFeatureAmp90with500ms()); //持续时间250ms-500ms
entity8090.setDuration1000(eventDipShortDistribution.getFeatureAmp90with1000ms()); //持续时间500ms-1000ms
entity8090.setDuration3000(eventDipShortDistribution.getFeatureAmp90with3000ms()); //持续时间1000ms-3000ms
entity8090.setDuration10000(eventDipShortDistribution.getFeatureAmp90with10000ms()); //持续时间3000ms-10000ms
entity8090.setDuration20000(eventDipShortDistribution.getFeatureAmp90with20000ms()); //持续时间10000ms-20000ms
entity8090.setDuration60000(eventDipShortDistribution.getFeatureAmp90with60000ms()); //持续时间20000ms-60000ms
list.add(entity8090);
//特征幅值[70,80)
EventDipShortDistributionTableVO entity7080 = new EventDipShortDistributionTableVO();
entity7080.setFeatureAmplitude("[70,80)");
entity7080.setDuration100(eventDipShortDistribution.getFeatureAmp80with100ms()); //持续时间10ms-100ms
entity7080.setDuration250(eventDipShortDistribution.getFeatureAmp80with250ms()); //持续时间100ms-250ms
entity7080.setDuration500(eventDipShortDistribution.getFeatureAmp80with500ms()); //持续时间250ms-500ms
entity7080.setDuration1000(eventDipShortDistribution.getFeatureAmp80with1000ms()); //持续时间500ms-1000ms
entity7080.setDuration3000(eventDipShortDistribution.getFeatureAmp80with3000ms()); //持续时间1000ms-3000ms
entity7080.setDuration10000(eventDipShortDistribution.getFeatureAmp80with10000ms()); //持续时间3000ms-10000ms
entity7080.setDuration20000(eventDipShortDistribution.getFeatureAmp80with20000ms()); //持续时间10000ms-20000ms
entity7080.setDuration60000(eventDipShortDistribution.getFeatureAmp80with60000ms()); //持续时间20000ms-60000ms
list.add(entity7080);
//特征幅值[60,70)
EventDipShortDistributionTableVO entity6070 = new EventDipShortDistributionTableVO();
entity6070.setFeatureAmplitude("[60,70)");
entity6070.setDuration100(eventDipShortDistribution.getFeatureAmp70with100ms()); //持续时间10ms-100ms
entity6070.setDuration250(eventDipShortDistribution.getFeatureAmp70with250ms()); //持续时间100ms-250ms
entity6070.setDuration500(eventDipShortDistribution.getFeatureAmp70with500ms()); //持续时间250ms-500ms
entity6070.setDuration1000(eventDipShortDistribution.getFeatureAmp70with1000ms()); //持续时间500ms-1000ms
entity6070.setDuration3000(eventDipShortDistribution.getFeatureAmp70with3000ms()); //持续时间1000ms-3000ms
entity6070.setDuration10000(eventDipShortDistribution.getFeatureAmp70with10000ms()); //持续时间3000ms-10000ms
entity6070.setDuration20000(eventDipShortDistribution.getFeatureAmp70with20000ms()); //持续时间10000ms-20000ms
entity6070.setDuration60000(eventDipShortDistribution.getFeatureAmp70with60000ms()); //持续时间20000ms-60000ms
list.add(entity6070);
//特征幅值[50,60)
EventDipShortDistributionTableVO entity5060 = new EventDipShortDistributionTableVO();
entity5060.setFeatureAmplitude("[50,60)");
entity5060.setDuration100(eventDipShortDistribution.getFeatureAmp60with100ms()); //持续时间10ms-100ms
entity5060.setDuration250(eventDipShortDistribution.getFeatureAmp60with250ms()); //持续时间100ms-250ms
entity5060.setDuration500(eventDipShortDistribution.getFeatureAmp60with500ms()); //持续时间250ms-500ms
entity5060.setDuration1000(eventDipShortDistribution.getFeatureAmp60with1000ms()); //持续时间500ms-1000ms
entity5060.setDuration3000(eventDipShortDistribution.getFeatureAmp60with3000ms()); //持续时间1000ms-3000ms
entity5060.setDuration10000(eventDipShortDistribution.getFeatureAmp60with10000ms()); //持续时间3000ms-10000ms
entity5060.setDuration20000(eventDipShortDistribution.getFeatureAmp60with20000ms()); //持续时间10000ms-20000ms
entity5060.setDuration60000(eventDipShortDistribution.getFeatureAmp60with60000ms()); //持续时间20000ms-60000ms
list.add(entity5060);
//特征幅值[40,50)
EventDipShortDistributionTableVO entity4050 = new EventDipShortDistributionTableVO();
entity4050.setFeatureAmplitude("[40,50)");
entity4050.setDuration100(eventDipShortDistribution.getFeatureAmp50with100ms()); //持续时间10ms-100ms
entity4050.setDuration250(eventDipShortDistribution.getFeatureAmp50with250ms()); //持续时间100ms-250ms
entity4050.setDuration500(eventDipShortDistribution.getFeatureAmp50with500ms()); //持续时间250ms-500ms
entity4050.setDuration1000(eventDipShortDistribution.getFeatureAmp50with1000ms()); //持续时间500ms-1000ms
entity4050.setDuration3000(eventDipShortDistribution.getFeatureAmp50with3000ms()); //持续时间1000ms-3000ms
entity4050.setDuration10000(eventDipShortDistribution.getFeatureAmp50with10000ms()); //持续时间3000ms-10000ms
entity4050.setDuration20000(eventDipShortDistribution.getFeatureAmp50with20000ms()); //持续时间10000ms-20000ms
entity4050.setDuration60000(eventDipShortDistribution.getFeatureAmp50with60000ms()); //持续时间20000ms-60000ms
list.add(entity4050);
//特征幅值[30,40)
EventDipShortDistributionTableVO entity3040 = new EventDipShortDistributionTableVO();
entity3040.setFeatureAmplitude("[30,40)");
entity3040.setDuration100(eventDipShortDistribution.getFeatureAmp40with100ms()); //持续时间10ms-100ms
entity3040.setDuration250(eventDipShortDistribution.getFeatureAmp40with250ms()); //持续时间100ms-250ms
entity3040.setDuration500(eventDipShortDistribution.getFeatureAmp40with500ms()); //持续时间250ms-500ms
entity3040.setDuration1000(eventDipShortDistribution.getFeatureAmp40with1000ms()); //持续时间500ms-1000ms
entity3040.setDuration3000(eventDipShortDistribution.getFeatureAmp40with3000ms()); //持续时间1000ms-3000ms
entity3040.setDuration10000(eventDipShortDistribution.getFeatureAmp40with10000ms()); //持续时间3000ms-10000ms
entity3040.setDuration20000(eventDipShortDistribution.getFeatureAmp40with20000ms()); //持续时间10000ms-20000ms
entity3040.setDuration60000(eventDipShortDistribution.getFeatureAmp40with60000ms()); //持续时间20000ms-60000ms
list.add(entity3040);
//特征幅值[20,30)
EventDipShortDistributionTableVO entity2030 = new EventDipShortDistributionTableVO();
entity2030.setFeatureAmplitude("[20,30)");
entity2030.setDuration100(eventDipShortDistribution.getFeatureAmp30with100ms()); //持续时间10ms-100ms
entity2030.setDuration250(eventDipShortDistribution.getFeatureAmp30with250ms()); //持续时间100ms-250ms
entity2030.setDuration500(eventDipShortDistribution.getFeatureAmp30with500ms()); //持续时间250ms-500ms
entity2030.setDuration1000(eventDipShortDistribution.getFeatureAmp30with1000ms()); //持续时间500ms-1000ms
entity2030.setDuration3000(eventDipShortDistribution.getFeatureAmp30with3000ms()); //持续时间1000ms-3000ms
entity2030.setDuration10000(eventDipShortDistribution.getFeatureAmp30with10000ms()); //持续时间3000ms-10000ms
entity2030.setDuration20000(eventDipShortDistribution.getFeatureAmp30with20000ms()); //持续时间10000ms-20000ms
entity2030.setDuration60000(eventDipShortDistribution.getFeatureAmp30with60000ms()); //持续时间20000ms-60000ms
list.add(entity2030);
//特征幅值[10,20)
EventDipShortDistributionTableVO entity1020 = new EventDipShortDistributionTableVO();
entity1020.setFeatureAmplitude("[10,20)");
entity1020.setDuration100(eventDipShortDistribution.getFeatureAmp20with100ms()); //持续时间10ms-100ms
entity1020.setDuration250(eventDipShortDistribution.getFeatureAmp20with250ms()); //持续时间100ms-250ms
entity1020.setDuration500(eventDipShortDistribution.getFeatureAmp20with500ms()); //持续时间250ms-500ms
entity1020.setDuration1000(eventDipShortDistribution.getFeatureAmp20with1000ms()); //持续时间500ms-1000ms
entity1020.setDuration3000(eventDipShortDistribution.getFeatureAmp20with3000ms()); //持续时间1000ms-3000ms
entity1020.setDuration10000(eventDipShortDistribution.getFeatureAmp20with10000ms()); //持续时间3000ms-10000ms
entity1020.setDuration20000(eventDipShortDistribution.getFeatureAmp20with20000ms()); //持续时间10000ms-20000ms
entity1020.setDuration60000(eventDipShortDistribution.getFeatureAmp20with60000ms()); //持续时间20000ms-60000ms
list.add(entity1020);
//特征幅值[0,10)
EventDipShortDistributionTableVO entity10 = new EventDipShortDistributionTableVO();
entity10.setFeatureAmplitude("[0,10)");
entity10.setDuration100(eventDipShortDistribution.getFeatureAmp10with100ms()); //持续时间10ms-100ms
entity10.setDuration250(eventDipShortDistribution.getFeatureAmp10with250ms()); //持续时间100ms-250ms
entity10.setDuration500(eventDipShortDistribution.getFeatureAmp10with500ms()); //持续时间250ms-500ms
entity10.setDuration1000(eventDipShortDistribution.getFeatureAmp10with1000ms()); //持续时间500ms-1000ms
entity10.setDuration3000(eventDipShortDistribution.getFeatureAmp10with3000ms()); //持续时间1000ms-3000ms
entity10.setDuration10000(eventDipShortDistribution.getFeatureAmp10with10000ms()); //持续时间3000ms-10000ms
entity10.setDuration20000(eventDipShortDistribution.getFeatureAmp10with20000ms()); //持续时间10000ms-20000ms
entity10.setDuration60000(eventDipShortDistribution.getFeatureAmp10with60000ms()); //持续时间20000ms-60000ms
list.add(entity10);
return list;
}
/***
* 暂态指标监测点电压暂升分布情况
* @author jianghaifei
* @date 2022-10-29 14:08
* @param eventMonitorReportParam
* @return com.njcn.event.pojo.vo.EventRiseDistributionVO
*/
@Override
public EventRiseDistributionVO getEventRiseDistributionByCond(EventMonitorReportParam eventMonitorReportParam) {
public List<EventRiseDistributionTableVO> getEventRiseDistributionByCond(EventMonitorReportParam eventMonitorReportParam) {
//提取参数
// String monitorName = eventMonitorReportParam.getMonitorName(); //监测点名称
// String id = eventMonitorReportParam.getId(); //单位id
String startTime = eventMonitorReportParam.getStartTime(); //开始时间
String endTime = eventMonitorReportParam.getEndTime(); //结束时间
Integer type = eventMonitorReportParam.getType(); //时间类型(日/月)
/****** 获取监测点信息(version1.0) ******/
// //获取所有子部门信息
// List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(id, WebUtil.filterDeptType()).getData();
// if (CollUtil.isEmpty(deptDTOList)) {
// throw new BusinessException(CommonResponseEnum.NO_DATA, "部门不存在");
// }
// //单位id集合
// List<String> orgNoList = deptDTOList.stream().map(DeptDTO::getId).collect(Collectors.toList());
// //查询监测点信息
// PmsMonitorParam pmsMonitorParam = new PmsMonitorParam();
// pmsMonitorParam.setMonitorName(monitorName); //监测点名称
// pmsMonitorParam.setOrgIds(orgNoList); //单位ids
// List<PmsMonitorDTO> monitorList = monitorClient.getMonitorInfoListByCond(pmsMonitorParam).getData(); //监测点信息
//查询监测点信息(version2.0)
List<PmsMonitorDTO> monitorList = this.getMonitorList(eventMonitorReportParam);
List<String> monitorIdList = monitorList.stream().map(PmsMonitorDTO::getId).collect(Collectors.toList()); //监测点id集合
//获取暂态指标的字典
List<DictData> eventStatisList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
//将暂态指标信息转成mapkeycode value实体
Map<String, DictData> eventStatisMapByCode = eventStatisList.stream().collect(Collectors.toMap(DictData::getCode, data -> data));
//暂升分布情况
Map<String, Object> riseCondMap = new HashMap<>();
riseCondMap.put("monitorIdList", monitorIdList);
riseCondMap.put("startTime", startTime);
riseCondMap.put("endTime", endTime);
riseCondMap.put("eventTypeList", Collections.singletonList(eventStatisMapByCode.get(DicDataEnum.VOLTAGE_RISE.getCode()).getId()));
riseCondMap.put("dateType", type);
EventRiseDistributionVO eventRiseDistribution = eventDistributionStatisticsMapper.getEventRiseDistributionByCond(riseCondMap);
//设置返回数据
List<EventRiseDistributionTableVO> list = new ArrayList<>();
//特征幅值U1≥120
EventRiseDistributionTableVO entity120 = new EventRiseDistributionTableVO();
entity120.setFeatureAmplitude("≥120");
entity120.setDuration500(eventRiseDistribution.getFeatureAmp120with500ms()); //持续时间100ms-500ms
entity120.setDuration5000(eventRiseDistribution.getFeatureAmp120with5000ms()); //持续时间500ms-5000ms
entity120.setDuration60000(eventRiseDistribution.getFeatureAmp120with60000ms()); //持续时间5000ms-60000ms
list.add(entity120);
//特征幅值-120-110
EventRiseDistributionTableVO entity110 = new EventRiseDistributionTableVO();
entity110.setFeatureAmplitude("-120,110");
entity110.setDuration500(eventRiseDistribution.getFeatureAmp110with500ms()); //持续时间100ms-500ms
entity110.setDuration5000(eventRiseDistribution.getFeatureAmp110with5000ms()); //持续时间500ms-5000ms
entity110.setDuration60000(eventRiseDistribution.getFeatureAmp110with60000ms()); //持续时间5000ms-60000ms
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<PmsMonitorDTO> getMonitorList(EventMonitorReportParam eventMonitorReportParam) {
//提取参数
String monitorName = eventMonitorReportParam.getMonitorName(); //监测点名称
String id = eventMonitorReportParam.getId(); //单位id
String startTime = eventMonitorReportParam.getStartTime(); //开始时间
String endTime = eventMonitorReportParam.getEndTime(); //结束时间
//获取所有子部门信息
List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(id, WebUtil.filterDeptType()).getData();
@@ -210,19 +422,7 @@ public class EventMonitorReportServiceImpl implements EventMonitorReportService
pmsMonitorParam.setMonitorName(monitorName); //监测点名称
pmsMonitorParam.setOrgIds(orgNoList); //单位ids
List<PmsMonitorDTO> monitorList = monitorClient.getMonitorInfoListByCond(pmsMonitorParam).getData(); //监测点信息
List<String> monitorIdList = monitorList.stream().map(PmsMonitorDTO::getId).collect(Collectors.toList()); //监测点id集合
//获取暂态指标的字典
List<DictData> eventStatisList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
//将暂态指标信息转成mapkeycode value实体
Map<String, DictData> eventStatisMapByCode = eventStatisList.stream().collect(Collectors.toMap(DictData::getCode, data -> data));
//暂升分布情况
Map<String, Object> riseCondMap = new HashMap<>();
riseCondMap.put("monitorIdList", monitorIdList);
riseCondMap.put("startTime", startTime);
riseCondMap.put("endTime", endTime);
riseCondMap.put("eventTypeList", Collections.singletonList(eventStatisMapByCode.get(DicDataEnum.VOLTAGE_RISE.getCode()).getId()));
return eventDistributionStatisticsMapper.getEventRiseDistributionByCond(riseCondMap);
return monitorList;
}
}