代码调整;监测点指标告警日统计部分算法
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
package com.njcn.prepare.harmonic.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/5/8 18:36
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AlarmDetailDayDTO {
|
||||||
|
|
||||||
|
private String lineId;
|
||||||
|
|
||||||
|
private Double vlDev;
|
||||||
|
|
||||||
|
private Double freqDev;
|
||||||
|
|
||||||
|
private Double vUnbalance;
|
||||||
|
|
||||||
|
private Double vHarmonic;
|
||||||
|
|
||||||
|
private Double plt;
|
||||||
|
|
||||||
|
private Double sagTimes;
|
||||||
|
|
||||||
|
private Double interruptTimes;
|
||||||
|
}
|
||||||
@@ -155,6 +155,15 @@ public class PublicUtil {
|
|||||||
return localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
return localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取去年今日
|
||||||
|
*/
|
||||||
|
public static String getLastYearDay(String time) {
|
||||||
|
LocalDate localDate = LocalDate.parse(time).minusYears(1);
|
||||||
|
return localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 根据电压字典获取电压等级
|
* @Description: 根据电压字典获取电压等级
|
||||||
* @Param: [id, dictDataList]
|
* @Param: [id, dictDataList]
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.njcn.prepare.harmonic.controller.line;
|
||||||
|
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.constant.OperateType;
|
||||||
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
|
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.line.IRMpTargetWarnDService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-05-08
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/alarmDetailData")
|
||||||
|
@Api(tags = "监测点指标告警明细")
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class RMpTargetWarnDController extends BaseController {
|
||||||
|
|
||||||
|
private final IRMpTargetWarnDService irMpTargetWarnDService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xuyang
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||||
|
@PostMapping("/alarmDay")
|
||||||
|
@ApiOperation("监测点指标告警日统计")
|
||||||
|
@ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
|
||||||
|
public HttpResult<Boolean> alarmDay(@RequestBody @Validated LineParam lineParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("alarmDay");
|
||||||
|
irMpTargetWarnDService.alarmDay(lineParam);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -2,6 +2,24 @@ package com.njcn.prepare.harmonic.mapper.mysql.day;
|
|||||||
|
|
||||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||||
import com.njcn.harmonic.pojo.po.day.RStatDataVDPO;
|
import com.njcn.harmonic.pojo.po.day.RStatDataVDPO;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.dto.AlarmDetailDayDTO;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.mysql.po.line.RMpTargetDiffDPO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface RStatDataVDMapper extends MppBaseMapper<RStatDataVDPO> {
|
public interface RStatDataVDMapper extends MppBaseMapper<RStatDataVDPO> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取本年的所有(监测点日报表)稳态指标最大值(有的取最大值,有的取95概率大值)
|
||||||
|
* @param time 时间
|
||||||
|
* @return 集合
|
||||||
|
*/
|
||||||
|
List<RMpTargetDiffDPO> getDayData(@Param("time") String time);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取本年的所有(监测点日报表)稳态指标最大值(有的取最大值,有的取95概率大值)求一个平均值
|
||||||
|
*/
|
||||||
|
List<AlarmDetailDayDTO> getAvgDayData(@Param("startTime") String time, @Param("endTime") String endTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,4 +2,162 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!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.day.RStatDataVDMapper">
|
<mapper namespace="com.njcn.prepare.harmonic.mapper.mysql.day.RStatDataVDMapper">
|
||||||
|
|
||||||
|
<select id="getDayData" resultType="com.njcn.prepare.harmonic.pojo.mysql.po.line.RMpTargetDiffDPO">
|
||||||
|
select
|
||||||
|
A.time,
|
||||||
|
A.lineId,
|
||||||
|
coalesce(A.vUnbalance, 0) vUnbalance,
|
||||||
|
coalesce(A.v, 0) vHarmonic,
|
||||||
|
coalesce(B.vlDev, 0) vlDev,
|
||||||
|
coalesce(B.freqDev, 0) freqDev,
|
||||||
|
coalesce(C.plt, 0) plt,
|
||||||
|
coalesce(D.sagTimes, 0) sagTimes,
|
||||||
|
coalesce(D.interruptTimes, 0) interruptTimes
|
||||||
|
from
|
||||||
|
(
|
||||||
|
select
|
||||||
|
`time`,
|
||||||
|
line_id lineId,
|
||||||
|
max(v_unbalance) vUnbalance,
|
||||||
|
max(greatest(v_thd, v_1, v_2, v_3, v_4, v_5, v_6, v_7, v_8, v_9, v_10, v_11, v_12, v_13, v_14, v_15, v_16, v_17, v_18, v_19, v_20, v_21, v_22, v_23, v_24, v_25, v_26, v_27, v_28, v_29, v_30, v_31, v_32, v_33, v_34, v_35, v_36, v_37, v_38, v_39, v_40, v_41, v_42, v_43, v_44, v_45, v_46, v_47, v_48, v_49, v_50)) v
|
||||||
|
from
|
||||||
|
r_stat_data_v_d t0
|
||||||
|
where
|
||||||
|
`time` = #{time}
|
||||||
|
and value_type = 'CP95'
|
||||||
|
group by
|
||||||
|
`time`,
|
||||||
|
line_id
|
||||||
|
) A
|
||||||
|
left join
|
||||||
|
(
|
||||||
|
select
|
||||||
|
`time`,
|
||||||
|
line_id lineId,
|
||||||
|
max(abs(vl_dev)) vlDev,
|
||||||
|
max(abs(freq_dev)) freqDev
|
||||||
|
from
|
||||||
|
r_stat_data_v_d t0
|
||||||
|
where
|
||||||
|
`time` = #{time}
|
||||||
|
and value_type = 'MAX'
|
||||||
|
group by
|
||||||
|
`time`,
|
||||||
|
line_id
|
||||||
|
) B
|
||||||
|
on A.time = B.time and A.lineId = B.lineId
|
||||||
|
left join
|
||||||
|
(
|
||||||
|
select
|
||||||
|
`time` ,
|
||||||
|
line_id lineId,
|
||||||
|
max(plt) plt
|
||||||
|
from
|
||||||
|
r_stat_data_plt_d
|
||||||
|
where
|
||||||
|
`time` = #{time}
|
||||||
|
and value_type = 'MAX'
|
||||||
|
group by
|
||||||
|
`time`,
|
||||||
|
line_id
|
||||||
|
) C
|
||||||
|
on A.time = C.time and A.lineId = C.lineId
|
||||||
|
left join
|
||||||
|
(
|
||||||
|
select
|
||||||
|
measurement_point_id lineId,
|
||||||
|
data_date dataDate,
|
||||||
|
sag_times sagTimes,
|
||||||
|
interrupt_times interruptTimes
|
||||||
|
from
|
||||||
|
r_mp_event_detail_d
|
||||||
|
where
|
||||||
|
data_date = #{time}
|
||||||
|
) D
|
||||||
|
on A.time = D.dataDate and A.lineId = D.lineId
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getAvgDayData" resultType="com.njcn.prepare.harmonic.pojo.dto.AlarmDetailDayDTO">
|
||||||
|
select
|
||||||
|
Y.lineId,
|
||||||
|
avg(Y.vUnbalance) vUnbalance,
|
||||||
|
avg(Y.vHarmonic) vHarmonic,
|
||||||
|
avg(Y.vlDev) vlDev,
|
||||||
|
avg(Y.freqDev) freqDev,
|
||||||
|
avg(Y.plt) plt,
|
||||||
|
avg(Y.sagTimes) sagTimes,
|
||||||
|
avg(Y.interruptTimes) interruptTimes
|
||||||
|
from
|
||||||
|
(
|
||||||
|
select
|
||||||
|
A.time,
|
||||||
|
A.lineId,
|
||||||
|
coalesce(A.vUnbalance, 0) vUnbalance,
|
||||||
|
coalesce(A.v, 0) vHarmonic,
|
||||||
|
coalesce(B.vlDev, 0) vlDev,
|
||||||
|
coalesce(B.freqDev, 0) freqDev,
|
||||||
|
coalesce(C.plt, 0) plt,
|
||||||
|
coalesce(D.sagTimes, 0) sagTimes,
|
||||||
|
coalesce(D.interruptTimes, 0) interruptTimes
|
||||||
|
from
|
||||||
|
(
|
||||||
|
select
|
||||||
|
`time`,
|
||||||
|
line_id lineId,
|
||||||
|
max(v_unbalance) vUnbalance,
|
||||||
|
max(greatest(v_thd, v_1, v_2, v_3, v_4, v_5, v_6, v_7, v_8, v_9, v_10, v_11, v_12, v_13, v_14, v_15, v_16, v_17, v_18, v_19, v_20, v_21, v_22, v_23, v_24, v_25, v_26, v_27, v_28, v_29, v_30, v_31, v_32, v_33, v_34, v_35, v_36, v_37, v_38, v_39, v_40, v_41, v_42, v_43, v_44, v_45, v_46, v_47, v_48, v_49, v_50)) v
|
||||||
|
from
|
||||||
|
r_stat_data_v_d t0
|
||||||
|
where
|
||||||
|
`time` between #{startTime} and #{endTime} and value_type = 'CP95'
|
||||||
|
group by `time`,line_id
|
||||||
|
) A
|
||||||
|
left join
|
||||||
|
(
|
||||||
|
select
|
||||||
|
`time`,
|
||||||
|
line_id lineId,
|
||||||
|
max(abs(vl_dev)) vlDev,
|
||||||
|
max(abs(freq_dev)) freqDev
|
||||||
|
from
|
||||||
|
r_stat_data_v_d t0
|
||||||
|
where
|
||||||
|
`time` between #{startTime} and #{endTime} and value_type = 'MAX'
|
||||||
|
group by `time`,line_id
|
||||||
|
) B
|
||||||
|
on
|
||||||
|
A.time = B.time
|
||||||
|
and A.lineId = B.lineId
|
||||||
|
left join
|
||||||
|
(
|
||||||
|
select
|
||||||
|
`time` ,
|
||||||
|
line_id lineId,
|
||||||
|
max(plt) plt
|
||||||
|
from
|
||||||
|
r_stat_data_plt_d
|
||||||
|
where
|
||||||
|
`time` between #{startTime} and #{endTime} and value_type = 'MAX'
|
||||||
|
group by `time`,line_id
|
||||||
|
) C
|
||||||
|
on
|
||||||
|
A.time = C.time
|
||||||
|
and A.lineId = C.lineId
|
||||||
|
left join
|
||||||
|
(
|
||||||
|
select
|
||||||
|
measurement_point_id lineId,
|
||||||
|
data_date dataDate,
|
||||||
|
sag_times sagTimes,
|
||||||
|
interrupt_times interruptTimes
|
||||||
|
from
|
||||||
|
r_mp_event_detail_d
|
||||||
|
where
|
||||||
|
data_date between #{startTime} and #{endTime}
|
||||||
|
) D
|
||||||
|
on
|
||||||
|
A.time = D.dataDate and A.lineId = D.lineId
|
||||||
|
) Y
|
||||||
|
group by Y.lineId
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.prepare.harmonic.mapper.mysql.line;
|
package com.njcn.prepare.harmonic.mapper.mysql.line;
|
||||||
|
|
||||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.dto.AlarmDetailDayDTO;
|
||||||
import com.njcn.prepare.harmonic.pojo.mysql.po.line.RMpTargetDiffDPO;
|
import com.njcn.prepare.harmonic.pojo.mysql.po.line.RMpTargetDiffDPO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
@@ -12,11 +13,6 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface AlarmMapper extends MppBaseMapper<RMpTargetDiffDPO> {
|
public interface AlarmMapper extends MppBaseMapper<RMpTargetDiffDPO> {
|
||||||
|
|
||||||
/**
|
List<AlarmDetailDayDTO> getAvgDiffData(@Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||||
* 获取监测点每日指标数据
|
|
||||||
* @param time 时间
|
|
||||||
* @return 集合
|
|
||||||
*/
|
|
||||||
List<RMpTargetDiffDPO> getDayData(@Param("time") String time);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,79 +2,19 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!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.line.AlarmMapper">
|
<mapper namespace="com.njcn.prepare.harmonic.mapper.mysql.line.AlarmMapper">
|
||||||
|
|
||||||
<select id="getDayData" resultType="com.njcn.prepare.harmonic.pojo.mysql.po.line.RMpTargetDiffDPO">
|
<select id="getAvgDiffData" resultType="com.njcn.prepare.harmonic.pojo.dto.AlarmDetailDayDTO">
|
||||||
select
|
select
|
||||||
A.time,
|
line_id lineId,
|
||||||
A.lineId,
|
avg(vl_dev) vlDev,
|
||||||
coalesce(A.vUnbalance, 0) vUnbalance,
|
avg(freq_dev) freqDev,
|
||||||
coalesce(A.v, 0) vHarmonic,
|
avg(v_unbalance) vUnbalance,
|
||||||
coalesce(B.vlDev, 0) vlDev,
|
avg(v_harmonic) vHarmonic,
|
||||||
coalesce(B.freqDev, 0) freqDev,
|
avg(plt) plt,
|
||||||
coalesce(C.plt, 0) plt,
|
avg(sag_times) sagTimes,
|
||||||
coalesce(D.sagTimes, 0) sagTimes,
|
avg(interrupt_times) interruptTimes
|
||||||
coalesce(D.interruptTimes, 0) interruptTimes
|
|
||||||
from
|
from
|
||||||
(
|
r_mp_target_diff_d
|
||||||
select
|
where `time` between #{startTime} and #{endTime}
|
||||||
`time`,
|
group by line_id
|
||||||
line_id lineId,
|
|
||||||
max(abs(v_unbalance)) vUnbalance,
|
|
||||||
max(greatest(abs(v_thd), v_1, v_2, v_3, v_4, v_5, v_6, v_7, v_8, v_9, v_10, v_11, v_12, v_13, v_14, v_15, v_16, v_17, v_18, v_19, v_20, v_21, v_22, v_23, v_24, v_25, v_26, v_27, v_28, v_29, v_30, v_31, v_32, v_33, v_34, v_35, v_36, v_37, v_38, v_39, v_40, v_41, v_42, v_43, v_44, v_45, v_46, v_47, v_48, v_49, v_50)) v
|
|
||||||
from
|
|
||||||
r_stat_data_v_d t0
|
|
||||||
where
|
|
||||||
`time` = #{time}
|
|
||||||
and value_type = 'CP95'
|
|
||||||
group by
|
|
||||||
`time`,
|
|
||||||
line_id
|
|
||||||
) A
|
|
||||||
left join
|
|
||||||
(
|
|
||||||
select
|
|
||||||
`time`,
|
|
||||||
line_id lineId,
|
|
||||||
max(abs(vl_dev)) vlDev,
|
|
||||||
max(abs(freq_dev)) freqDev
|
|
||||||
from
|
|
||||||
r_stat_data_v_d t0
|
|
||||||
where
|
|
||||||
`time` = #{time}
|
|
||||||
and value_type = 'MAX'
|
|
||||||
group by
|
|
||||||
`time`,
|
|
||||||
line_id
|
|
||||||
) B
|
|
||||||
on A.time = B.time and A.lineId = B.lineId
|
|
||||||
left join
|
|
||||||
(
|
|
||||||
select
|
|
||||||
`time` ,
|
|
||||||
line_id lineId,
|
|
||||||
max(plt) plt
|
|
||||||
from
|
|
||||||
r_stat_data_plt_d
|
|
||||||
where
|
|
||||||
`time` = #{time}
|
|
||||||
and value_type = 'MAX'
|
|
||||||
group by
|
|
||||||
`time`,
|
|
||||||
line_id
|
|
||||||
) C
|
|
||||||
on A.time = C.time and A.lineId = C.lineId
|
|
||||||
left join
|
|
||||||
(
|
|
||||||
select
|
|
||||||
measurement_point_id lineId,
|
|
||||||
data_date dataDate,
|
|
||||||
sag_times sagTimes,
|
|
||||||
interrupt_times interruptTimes
|
|
||||||
from
|
|
||||||
r_mp_event_detail_d
|
|
||||||
where
|
|
||||||
data_date = #{time}
|
|
||||||
) D
|
|
||||||
on A.time = D.dataDate and A.lineId = D.lineId
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ import com.njcn.device.pms.pojo.po.DistributionMonitor;
|
|||||||
import com.njcn.device.pms.pojo.po.Monitor;
|
import com.njcn.device.pms.pojo.po.Monitor;
|
||||||
import com.njcn.harmonic.pojo.po.RMpTargetWarnDPO;
|
import com.njcn.harmonic.pojo.po.RMpTargetWarnDPO;
|
||||||
import com.njcn.prepare.harmonic.mapper.mysql.area.RMpTargetWarnDMapper;
|
import com.njcn.prepare.harmonic.mapper.mysql.area.RMpTargetWarnDMapper;
|
||||||
|
import com.njcn.prepare.harmonic.mapper.mysql.day.RStatDataVDMapper;
|
||||||
import com.njcn.prepare.harmonic.mapper.mysql.line.*;
|
import com.njcn.prepare.harmonic.mapper.mysql.line.*;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.dto.AlarmDetailDayDTO;
|
||||||
import com.njcn.prepare.harmonic.pojo.mysql.po.line.RMpTargetDiffDPO;
|
import com.njcn.prepare.harmonic.pojo.mysql.po.line.RMpTargetDiffDPO;
|
||||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||||
import com.njcn.prepare.harmonic.service.mysql.line.AlarmDetailService;
|
import com.njcn.prepare.harmonic.service.mysql.line.AlarmDetailService;
|
||||||
@@ -23,10 +25,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -61,6 +60,8 @@ public class AlarmDetailServiceImpl extends MppServiceImpl<AlarmMapper, RMpTarge
|
|||||||
|
|
||||||
private final RMpPltReportDPOMapper rMpPltReportDPOMapper;
|
private final RMpPltReportDPOMapper rMpPltReportDPOMapper;
|
||||||
|
|
||||||
|
private final RStatDataVDMapper rStatDataVDMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 电压偏差告警日统计
|
* 电压偏差告警日统计
|
||||||
* @author qijian
|
* @author qijian
|
||||||
@@ -138,12 +139,20 @@ public class AlarmDetailServiceImpl extends MppServiceImpl<AlarmMapper, RMpTarge
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AlarmDetailDayDTO> getAvgDiffData(LineParam lineParam) {
|
||||||
|
String startTime = lineParam.getDataDate();
|
||||||
|
String endTime = PublicUtil.getLastYearDay(startTime);
|
||||||
|
//计算本年的rm值
|
||||||
|
return this.baseMapper.getAvgDiffData(startTime,endTime);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成指标差值日统计
|
* 生成指标差值日统计
|
||||||
*/
|
*/
|
||||||
public void diffData(String startTime, String endTime) {
|
public void diffData(String startTime, String endTime) {
|
||||||
List<RMpTargetDiffDPO> localData = this.baseMapper.getDayData(startTime);
|
List<RMpTargetDiffDPO> localData = rStatDataVDMapper.getDayData(startTime);
|
||||||
List<RMpTargetDiffDPO> yesterdayData = this.baseMapper.getDayData(endTime);
|
List<RMpTargetDiffDPO> yesterdayData = rStatDataVDMapper.getDayData(endTime);
|
||||||
if (!CollectionUtils.isEmpty(localData) && !CollectionUtils.isEmpty(yesterdayData)){
|
if (!CollectionUtils.isEmpty(localData) && !CollectionUtils.isEmpty(yesterdayData)){
|
||||||
//取两个集合的交集,做算法处理取绝对值
|
//取两个集合的交集,做算法处理取绝对值
|
||||||
List<RMpTargetDiffDPO> intersectionList = localData.stream().map(map->yesterdayData.stream().filter(m->Objects.equals(m.getLineId(),map.getLineId())).findFirst().map(m->{
|
List<RMpTargetDiffDPO> intersectionList = localData.stream().map(map->yesterdayData.stream().filter(m->Objects.equals(m.getLineId(),map.getLineId())).findFirst().map(m->{
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package com.njcn.prepare.harmonic.service.mysql.Impl.line;
|
||||||
|
|
||||||
|
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||||
|
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.mysql.po.line.RMpTargetDiffDPO;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||||
|
import com.njcn.prepare.harmonic.service.mysql.line.AlarmDetailService;
|
||||||
|
import com.njcn.prepare.harmonic.service.mysql.line.IRMpTargetWarnDService;
|
||||||
|
import com.njcn.prepare.harmonic.utils.PublicUtil;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.checkerframework.checker.units.qual.A;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-05-08
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class RMpTargetWarnDServiceImpl extends MppServiceImpl<RMpTargetWarnDMapper, RMpTargetWarnDPO> implements IRMpTargetWarnDService {
|
||||||
|
|
||||||
|
private final AlarmDetailService alarmDetailService;
|
||||||
|
|
||||||
|
private final RStatDataVDMapper rStatDataVDMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void alarmDay(LineParam lineParam) {
|
||||||
|
//本年的rm值
|
||||||
|
List<AlarmDetailDayDTO> rmList = alarmDetailService.getAvgDiffData(lineParam);
|
||||||
|
//本年的CL值
|
||||||
|
List<AlarmDetailDayDTO> clList = rStatDataVDMapper.getAvgDayData(lineParam.getDataDate(), PublicUtil.getLastYearDay(lineParam.getDataDate()));
|
||||||
|
//本年的RL值
|
||||||
|
List<AlarmDetailDayDTO> rlList = rmList.stream().map(item->{
|
||||||
|
AlarmDetailDayDTO alarmDetailDayDTO = new AlarmDetailDayDTO();
|
||||||
|
alarmDetailDayDTO.setLineId(item.getLineId());
|
||||||
|
alarmDetailDayDTO.setVlDev(item.getVlDev()*3.3);
|
||||||
|
alarmDetailDayDTO.setFreqDev(item.getFreqDev()*3.3);
|
||||||
|
alarmDetailDayDTO.setVUnbalance(item.getVUnbalance()*3.3);
|
||||||
|
alarmDetailDayDTO.setVHarmonic(item.getVHarmonic()*3.3);
|
||||||
|
alarmDetailDayDTO.setSagTimes(item.getSagTimes()*3.3);
|
||||||
|
alarmDetailDayDTO.setInterruptTimes(item.getInterruptTimes()*3.3);
|
||||||
|
return alarmDetailDayDTO;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
//本年的UCL值
|
||||||
|
List<AlarmDetailDayDTO> uclList = rmList.stream().map(map->clList.stream().filter(m-> Objects.equals(m.getLineId(),map.getLineId())).findFirst().map(m->{
|
||||||
|
AlarmDetailDayDTO alarmDetailDayDTO = new AlarmDetailDayDTO();
|
||||||
|
alarmDetailDayDTO.setLineId(map.getLineId());
|
||||||
|
alarmDetailDayDTO.setVlDev(m.getVlDev()+map.getVlDev()*3);
|
||||||
|
alarmDetailDayDTO.setFreqDev(m.getFreqDev()+map.getFreqDev()*3);
|
||||||
|
alarmDetailDayDTO.setVUnbalance(m.getVUnbalance()+map.getVUnbalance()*3);
|
||||||
|
alarmDetailDayDTO.setVHarmonic(m.getVHarmonic()+map.getVHarmonic()*3);
|
||||||
|
alarmDetailDayDTO.setSagTimes(m.getSagTimes()+map.getSagTimes()*3);
|
||||||
|
alarmDetailDayDTO.setInterruptTimes(m.getInterruptTimes()+map.getInterruptTimes()*3);
|
||||||
|
return alarmDetailDayDTO;
|
||||||
|
}).orElse(null)).filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void alarmMonth(LineParam lineParam) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.njcn.prepare.harmonic.service.mysql.line;
|
package com.njcn.prepare.harmonic.service.mysql.line;
|
||||||
|
|
||||||
|
import com.njcn.prepare.harmonic.pojo.dto.AlarmDetailDayDTO;
|
||||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监测点指标告警明细
|
* 监测点指标告警明细
|
||||||
*
|
*
|
||||||
@@ -20,4 +23,6 @@ public interface AlarmDetailService {
|
|||||||
boolean alarmDetailAlarm(LineParam lineParam);
|
boolean alarmDetailAlarm(LineParam lineParam);
|
||||||
|
|
||||||
void targetDiff(LineParam lineParam);
|
void targetDiff(LineParam lineParam);
|
||||||
|
|
||||||
|
List<AlarmDetailDayDTO> getAvgDiffData(LineParam lineParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.njcn.prepare.harmonic.service.mysql.line;
|
||||||
|
|
||||||
|
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-05-08
|
||||||
|
*/
|
||||||
|
public interface IRMpTargetWarnDService {
|
||||||
|
|
||||||
|
void alarmDay(LineParam lineParam);
|
||||||
|
|
||||||
|
void alarmMonth(LineParam lineParam);
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user