监测点指标告警月统计算法
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
package com.njcn.harmonic.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/9 19:58
|
||||
*/
|
||||
@Data
|
||||
public class RMpMonitorAlarmCountMDTO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 监测点Id
|
||||
*/
|
||||
private String measurementPointId;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
private LocalDate dataDate;
|
||||
|
||||
/**
|
||||
* 电压偏差告警情况(0:否 1:是)
|
||||
*/
|
||||
private Integer vdevAlarmInfo;
|
||||
|
||||
/**
|
||||
* 电压偏差严重度
|
||||
*/
|
||||
private Double vdevSeverity;
|
||||
|
||||
/**
|
||||
* 频率偏差告警情况(0:否 1:是)
|
||||
*/
|
||||
private Integer freqAlarmInfo;
|
||||
|
||||
/**
|
||||
* 频率偏差严重度
|
||||
*/
|
||||
private Double freqSeverity;
|
||||
|
||||
/**
|
||||
* 三相电压不平衡度告警情况(0:否 1:是)
|
||||
*/
|
||||
private Integer unbalanceAlarmInfo;
|
||||
|
||||
/**
|
||||
* 三相电压不平衡严重度
|
||||
*/
|
||||
private Double unbalanceSeverity;
|
||||
|
||||
/**
|
||||
* 谐波电压告警情况(0:否 1:是)
|
||||
*/
|
||||
private Integer vAlarmInfo;
|
||||
|
||||
/**
|
||||
* 谐波电压严重度
|
||||
*/
|
||||
private Double vSeverity;
|
||||
|
||||
/**
|
||||
* 闪变告警情况(0:否 1:是)
|
||||
*/
|
||||
private Integer flickerAlarmInfo;
|
||||
|
||||
/**
|
||||
* 闪变严重度
|
||||
*/
|
||||
private Double flickerSeverity;
|
||||
|
||||
/**
|
||||
* 电压暂降告警情况(0:否 1:是)
|
||||
*/
|
||||
private Integer sagAlarmInfo;
|
||||
|
||||
/**
|
||||
* 电压暂降严重度
|
||||
*/
|
||||
private Double sagSeverity;
|
||||
|
||||
/**
|
||||
* 短时中断告警情况(0:否 1:是)
|
||||
*/
|
||||
private Integer interruptAlarmInfo;
|
||||
|
||||
/**
|
||||
* 短时中断严重度
|
||||
*/
|
||||
private Double interruptSeverity;
|
||||
|
||||
/**
|
||||
* 稳态指标评级结果之和(0 较差 1中等 2较好)
|
||||
*/
|
||||
private Double harmonicTypeGradeTotal;
|
||||
|
||||
/**
|
||||
* 暂态指标评级结果之和(0 较差 1中等 2较好)
|
||||
*/
|
||||
private Double eventTypeGradeTotal;
|
||||
|
||||
/**
|
||||
* 稳态指标评级结果(0 较差 1中等 2较好)
|
||||
*/
|
||||
private Integer harmonicTypeGrade;
|
||||
|
||||
/**
|
||||
* 暂态指标评级结果(0 较差 1中等 2较好)
|
||||
*/
|
||||
private Integer eventTypeGrade;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.njcn.harmonic.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 监测点告警统计-月表
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-09
|
||||
*/
|
||||
@Data
|
||||
@TableName("r_mp_monitor_alarm_count_m")
|
||||
public class RMpMonitorAlarmCountMPO implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 监测点Id
|
||||
*/
|
||||
@MppMultiId(value = "measurement_point_id")
|
||||
private String measurementPointId;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
@MppMultiId(value = "data_date")
|
||||
private LocalDate dataDate;
|
||||
|
||||
/**
|
||||
* 电压偏差告警情况(0:否 1:是)
|
||||
*/
|
||||
private Integer vdevAlarmInfo;
|
||||
|
||||
/**
|
||||
* 电压偏差严重度
|
||||
*/
|
||||
private Double vdevSeverity;
|
||||
|
||||
/**
|
||||
* 频率偏差告警情况(0:否 1:是)
|
||||
*/
|
||||
private Integer freqAlarmInfo;
|
||||
|
||||
/**
|
||||
* 频率偏差严重度
|
||||
*/
|
||||
private Double freqSeverity;
|
||||
|
||||
/**
|
||||
* 三相电压不平衡度告警情况(0:否 1:是)
|
||||
*/
|
||||
private Integer unbalanceAlarmInfo;
|
||||
|
||||
/**
|
||||
* 三相电压不平衡严重度
|
||||
*/
|
||||
private Double unbalanceSeverity;
|
||||
|
||||
/**
|
||||
* 谐波电压告警情况(0:否 1:是)
|
||||
*/
|
||||
private Integer vAlarmInfo;
|
||||
|
||||
/**
|
||||
* 谐波电压严重度
|
||||
*/
|
||||
private Double vSeverity;
|
||||
|
||||
/**
|
||||
* 闪变告警情况(0:否 1:是)
|
||||
*/
|
||||
private Integer flickerAlarmInfo;
|
||||
|
||||
/**
|
||||
* 闪变严重度
|
||||
*/
|
||||
private Double flickerSeverity;
|
||||
|
||||
/**
|
||||
* 电压暂降告警情况(0:否 1:是)
|
||||
*/
|
||||
private Integer sagAlarmInfo;
|
||||
|
||||
/**
|
||||
* 电压暂降严重度
|
||||
*/
|
||||
private Double sagSeverity;
|
||||
|
||||
/**
|
||||
* 短时中断告警情况(0:否 1:是)
|
||||
*/
|
||||
private Integer interruptAlarmInfo;
|
||||
|
||||
/**
|
||||
* 短时中断严重度
|
||||
*/
|
||||
private Double interruptSeverity;
|
||||
|
||||
/**
|
||||
* 稳态指标评级结果(0 较差 1中等 2较好)
|
||||
*/
|
||||
private Integer harmonicTypeGrade;
|
||||
|
||||
/**
|
||||
* 暂态指标评级结果(0 较差 1中等 2较好)
|
||||
*/
|
||||
private Integer eventTypeGrade;
|
||||
|
||||
|
||||
}
|
||||
@@ -8,6 +8,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.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.prepare.harmonic.service.mysql.area.IRMpMonitorAlarmCountMService;
|
||||
import com.njcn.prepare.harmonic.service.mysql.area.RMpTargetWarnDService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -35,10 +36,12 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("/alarmDetailData")
|
||||
@Api(tags = "监测点指标告警明细")
|
||||
@AllArgsConstructor
|
||||
public class RMpTargetWarnDController extends BaseController {
|
||||
public class RMpTargetWarnController extends BaseController {
|
||||
|
||||
private final RMpTargetWarnDService rMpTargetWarnDService;
|
||||
|
||||
private final IRMpMonitorAlarmCountMService rMpMonitorAlarmCountMService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||
@PostMapping("/alarmDay")
|
||||
@ApiOperation("监测点指标告警日统计(新)")
|
||||
@@ -49,5 +52,15 @@ public class RMpTargetWarnDController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||
@PostMapping("/alarmMonth")
|
||||
@ApiOperation("监测点指标告警月统计(新)")
|
||||
@ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
|
||||
public HttpResult<Boolean> alarmMonth(@RequestBody @Validated LineParam lineParam) {
|
||||
String methodDescribe = getMethodDescribe("alarmMonth");
|
||||
rMpMonitorAlarmCountMService.alarmMonth(lineParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.njcn.prepare.harmonic.mapper.mysql.area;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.harmonic.pojo.po.RMpMonitorAlarmCountMPO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 监测点告警统计-月表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-09
|
||||
*/
|
||||
@Mapper
|
||||
public interface RMpMonitorAlarmCountMMapper extends MppBaseMapper<RMpMonitorAlarmCountMPO> {
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.njcn.prepare.harmonic.mapper.mysql.area;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.harmonic.pojo.dto.RMpMonitorAlarmCountMDTO;
|
||||
import com.njcn.harmonic.pojo.po.RMpTargetWarnDPO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -15,4 +19,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
*/
|
||||
@Mapper
|
||||
public interface RMpTargetWarnDMapper extends MppBaseMapper<RMpTargetWarnDPO> {
|
||||
|
||||
List<RMpMonitorAlarmCountMDTO> getDate(@Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.prepare.harmonic.mapper.mysql.area.RMpMonitorAlarmCountMMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -23,4 +23,34 @@
|
||||
measurement_point_id, data_date, is_effective, is_harmonic, is_event, is_warn, is_v_dev_warn,
|
||||
is_freq_warn, is_unbalance_warn, is_v_warn, is_flicker_warn, is_sag_warn, is_interrupt_warn
|
||||
</sql>
|
||||
|
||||
<select id="getDate" resultType="com.njcn.harmonic.pojo.dto.RMpMonitorAlarmCountMDTO">
|
||||
select
|
||||
#{startTime} dataDate,
|
||||
measurement_point_id measurementPointId,
|
||||
case when sum(is_v_dev_warn) > 0 then 1 else 0 end vdevAlarmInfo,
|
||||
sum(is_v_dev_warn)/count(distinct data_date) vdevSeverity,
|
||||
case when sum(is_freq_warn) > 0 then 1 else 0 end freqAlarmInfo,
|
||||
sum(is_freq_warn)/count(distinct data_date) freqSeverity,
|
||||
case when sum(is_unbalance_warn) > 0 then 1 else 0 end unbalanceAlarmInfo,
|
||||
sum(is_unbalance_warn)/count(distinct data_date) unbalanceSeverity,
|
||||
case when sum(is_v_warn) > 0 then 1 else 0 end vAlarmInfo,
|
||||
sum(is_v_warn)/count(distinct data_date) vSeverity,
|
||||
case when sum(is_flicker_warn) > 0 then 1 else 0 end flickerAlarmInfo,
|
||||
sum(is_flicker_warn)/count(distinct data_date) flickerSeverity,
|
||||
case when sum(is_sag_warn) > 0 then 1 else 0 end sagAlarmInfo,
|
||||
sum(is_sag_warn)/count(distinct data_date) sagSeverity,
|
||||
case when sum(is_interrupt_warn) > 0 then 1 else 0 end interruptAlarmInfo,
|
||||
sum(is_interrupt_warn)/count(distinct data_date) interruptSeverity,
|
||||
sum(is_v_dev_warn)/count(distinct data_date)+sum(is_freq_warn)/count(distinct data_date)+sum(is_unbalance_warn)/count(distinct data_date)+sum(is_v_warn)/count(distinct data_date)+sum(is_flicker_warn)/count(distinct data_date) harmonicTypeGradeTotal,
|
||||
sum(is_sag_warn)/count(distinct data_date)+sum(is_interrupt_warn)/count(distinct data_date) eventTypeGradeTotal
|
||||
from
|
||||
r_mp_target_warn_d
|
||||
where
|
||||
data_date between #{startTime} and #{endTime}
|
||||
group by measurement_point_id
|
||||
order by harmonicTypeGradeTotal desc,eventTypeGradeTotal desc
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.njcn.prepare.harmonic.service.mysql.Impl.area;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.harmonic.pojo.dto.RMpMonitorAlarmCountMDTO;
|
||||
import com.njcn.harmonic.pojo.po.RMpMonitorAlarmCountMPO;
|
||||
import com.njcn.prepare.harmonic.mapper.mysql.area.RMpMonitorAlarmCountMMapper;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.prepare.harmonic.service.mysql.area.IRMpMonitorAlarmCountMService;
|
||||
import com.njcn.prepare.harmonic.service.mysql.area.RMpTargetWarnDService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 监测点告警统计-月表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-09
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class RMpMonitorAlarmCountMServiceImpl extends MppServiceImpl<RMpMonitorAlarmCountMMapper, RMpMonitorAlarmCountMPO> implements IRMpMonitorAlarmCountMService {
|
||||
|
||||
private final RMpTargetWarnDService rMpTargetWarnDService;
|
||||
|
||||
@Override
|
||||
public void alarmMonth(LineParam lineParam) {
|
||||
List<RMpMonitorAlarmCountMDTO> monthList = rMpTargetWarnDService.getDate(lineParam);
|
||||
if (!CollectionUtils.isEmpty(monthList)){
|
||||
List<RMpMonitorAlarmCountMPO> result = new ArrayList<>();
|
||||
List<RMpMonitorAlarmCountMDTO> harmonicList = new ArrayList<>(),eventList = new ArrayList<>();
|
||||
//判断稳态指标评级结果-根据稳态指标严重度之和排序(去除严重度为0的数据在作比较)
|
||||
List<RMpMonitorAlarmCountMDTO> list1 = monthList.stream().filter(item->item.getHarmonicTypeGradeTotal()>0).collect(Collectors.toList());
|
||||
List<RMpMonitorAlarmCountMDTO> list2 = monthList.stream().filter(item->item.getHarmonicTypeGradeTotal()<=0).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(list1)){
|
||||
for (int i = 0; i < list1.size(); i++) {
|
||||
if (i < list1.size()*0.3){
|
||||
list1.get(i).setHarmonicTypeGrade(0);
|
||||
} else if (i >= list1.size()*0.3 && i < list1.size()*0.7){
|
||||
list1.get(i).setHarmonicTypeGrade(1);
|
||||
} else {
|
||||
list1.get(i).setHarmonicTypeGrade(2);
|
||||
}
|
||||
harmonicList.add(list1.get(i));
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(list2)){
|
||||
list2.forEach(item->{
|
||||
item.setHarmonicTypeGrade(2);
|
||||
harmonicList.add(item);
|
||||
});
|
||||
}
|
||||
//判断暂态指标评级结果-根据暂态指标严重度之和排序(去除严重度为0的数据在作比较)
|
||||
List<RMpMonitorAlarmCountMDTO> list3 = harmonicList.stream().filter(item->item.getEventTypeGradeTotal()>0).collect(Collectors.toList());
|
||||
List<RMpMonitorAlarmCountMDTO> list4 = harmonicList.stream().filter(item->item.getEventTypeGradeTotal()<=0).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(list3)){
|
||||
for (int i = 0; i < list3.size(); i++) {
|
||||
if (i < list3.size()*0.3){
|
||||
list3.get(i).setEventTypeGrade(0);
|
||||
} else if (i >= list3.size()*0.3 && i < list3.size()*0.7){
|
||||
list3.get(i).setEventTypeGrade(1);
|
||||
} else {
|
||||
list3.get(i).setEventTypeGrade(2);
|
||||
}
|
||||
eventList.add(list3.get(i));
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(list4)){
|
||||
list4.forEach(item->{
|
||||
item.setEventTypeGrade(2);
|
||||
eventList.add(item);
|
||||
});
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(eventList)){
|
||||
eventList.forEach(item->{
|
||||
RMpMonitorAlarmCountMPO rMpMonitorAlarmCountMpo = new RMpMonitorAlarmCountMPO();
|
||||
BeanUtils.copyProperties(item,rMpMonitorAlarmCountMpo);
|
||||
result.add(rMpMonitorAlarmCountMpo);
|
||||
});
|
||||
this.saveOrUpdateBatchByMultiId(result,50);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,12 @@ import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.harmonic.pojo.dto.RMpMonitorAlarmCountMDTO;
|
||||
import com.njcn.harmonic.pojo.po.RMpTargetWarnDPO;
|
||||
import com.njcn.prepare.harmonic.mapper.mysql.area.RMpTargetWarnDMapper;
|
||||
import com.njcn.prepare.harmonic.mapper.mysql.day.RStatDataVDMapper;
|
||||
import com.njcn.prepare.harmonic.pojo.dto.AlarmDetailDayDTO;
|
||||
import com.njcn.prepare.harmonic.pojo.dto.RMpTargetWarnDDTO;
|
||||
import com.njcn.prepare.harmonic.pojo.mysql.po.line.RMpTargetDiffDPO;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.prepare.harmonic.service.mysql.area.RMpTargetWarnDService;
|
||||
import com.njcn.prepare.harmonic.service.mysql.line.AlarmDetailService;
|
||||
@@ -98,8 +98,12 @@ public class RMpTargetWarnDServiceImpl extends MppServiceImpl<RMpTargetWarnDMapp
|
||||
}
|
||||
|
||||
@Override
|
||||
public void alarmMonth(LineParam lineParam) {
|
||||
|
||||
public List<RMpMonitorAlarmCountMDTO> getDate(LineParam lineParam) {
|
||||
int year = Integer.parseInt(lineParam.getDataDate().split("-")[0]);
|
||||
int month = Integer.parseInt(lineParam.getDataDate().split("-")[1]);
|
||||
String startTime = PublicUtil.getFisrtDayOfMonth(year,month);
|
||||
String endTime = PublicUtil.getLastDayOfMonth(year,month);
|
||||
return this.baseMapper.getDate(startTime,endTime);
|
||||
}
|
||||
|
||||
public List<RMpTargetWarnDPO> getData(String time){
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.prepare.harmonic.service.mysql.area;
|
||||
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 监测点告警统计-月表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-09
|
||||
*/
|
||||
public interface IRMpMonitorAlarmCountMService {
|
||||
|
||||
/**
|
||||
* @Description: 监测点指标告警月统计
|
||||
* @author: xuyang
|
||||
*/
|
||||
void alarmMonth(LineParam lineParam);
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.prepare.harmonic.service.mysql.area;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||
import com.njcn.harmonic.pojo.dto.RMpMonitorAlarmCountMDTO;
|
||||
import com.njcn.harmonic.pojo.po.RMpTargetWarnDPO;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
|
||||
@@ -36,5 +37,5 @@ public interface RMpTargetWarnDService extends IMppService<RMpTargetWarnDPO> {
|
||||
* @Description: 监测点指标告警月统计
|
||||
* @author: xuyang
|
||||
*/
|
||||
void alarmMonth(LineParam lineParam);
|
||||
List<RMpMonitorAlarmCountMDTO> getDate(LineParam lineParam);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user