监测点基准水平评估算法
This commit is contained in:
@@ -0,0 +1,51 @@
|
|||||||
|
package com.njcn.harmonic.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【基准水平-日】
|
||||||
|
* @author xuyang
|
||||||
|
* @TableName r_mp_benchmark_level_d
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("r_mp_benchmark_level_d")
|
||||||
|
public class RMpBenchmarkLevelD implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点ID
|
||||||
|
*/
|
||||||
|
@MppMultiId
|
||||||
|
private String measurementPointId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成数据的时间,每月统计一次
|
||||||
|
*/
|
||||||
|
@MppMultiId
|
||||||
|
private Date dataDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电压统计值
|
||||||
|
*/
|
||||||
|
private Double voltageAvg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 三相电压不平衡统计值
|
||||||
|
*/
|
||||||
|
private Double unbalanceAvg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电压总谐波畸变率统计值
|
||||||
|
*/
|
||||||
|
private Double vthdAvg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 长时间闪变统计值
|
||||||
|
*/
|
||||||
|
private Double flickerAvg;
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.harmonic.pojo.po;
|
package com.njcn.harmonic.pojo.po;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -19,11 +20,13 @@ public class RMpBenchmarkLevelM implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 监测点ID
|
* 监测点ID
|
||||||
*/
|
*/
|
||||||
|
@MppMultiId
|
||||||
private String measurementPointId;
|
private String measurementPointId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成数据的时间,每月统计一次
|
* 生成数据的时间,每月统计一次
|
||||||
*/
|
*/
|
||||||
|
@MppMultiId
|
||||||
private Date dataDate;
|
private Date dataDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.harmonic.pojo.po;
|
package com.njcn.harmonic.pojo.po;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -20,11 +21,13 @@ public class RMpBenchmarkLevelQ implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 监测点ID
|
* 监测点ID
|
||||||
*/
|
*/
|
||||||
|
@MppMultiId
|
||||||
private String measurementPointId;
|
private String measurementPointId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成数据的时间,每季统计一次
|
* 生成数据的时间,每季统计一次
|
||||||
*/
|
*/
|
||||||
|
@MppMultiId
|
||||||
private Date dataDate;
|
private Date dataDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.harmonic.pojo.po;
|
package com.njcn.harmonic.pojo.po;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -20,11 +21,13 @@ public class RMpBenchmarkLevelY implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 监测点ID
|
* 监测点ID
|
||||||
*/
|
*/
|
||||||
|
@MppMultiId
|
||||||
private String measurementPointId;
|
private String measurementPointId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成数据的时间,每年统计一次
|
* 生成数据的时间,每年统计一次
|
||||||
*/
|
*/
|
||||||
|
@MppMultiId
|
||||||
private Date dataDate;
|
private Date dataDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ import com.njcn.prepare.harmonic.service.mysql.line.RMpEventDetailDService;
|
|||||||
import com.njcn.prepare.harmonic.service.mysql.line.RMpEventDetailService;
|
import com.njcn.prepare.harmonic.service.mysql.line.RMpEventDetailService;
|
||||||
import com.njcn.prepare.harmonic.service.mysql.line.RMpMonitorEvaluateDService;
|
import com.njcn.prepare.harmonic.service.mysql.line.RMpMonitorEvaluateDService;
|
||||||
import com.njcn.prepare.harmonic.service.mysql.line.*;
|
import com.njcn.prepare.harmonic.service.mysql.line.*;
|
||||||
|
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.IRMpBenchmarkLevelDService;
|
||||||
|
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.IRMpBenchmarkLevelMService;
|
||||||
|
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.IRMpBenchmarkLevelQService;
|
||||||
|
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.IRMpBenchmarkLevelYService;
|
||||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||||
import com.yomahub.liteflow.annotation.LiteflowMethod;
|
import com.yomahub.liteflow.annotation.LiteflowMethod;
|
||||||
import com.yomahub.liteflow.core.NodeComponent;
|
import com.yomahub.liteflow.core.NodeComponent;
|
||||||
@@ -53,6 +57,10 @@ public class MeasurementExecutor extends BaseExecutor {
|
|||||||
private final PollutionService pollutionService;
|
private final PollutionService pollutionService;
|
||||||
private final RStatDevSignalDPOService rStatDevSignalDPOService;
|
private final RStatDevSignalDPOService rStatDevSignalDPOService;
|
||||||
private final RMpDevEvaluateDetailPOService rMpDevEvaluateDetailPOService;
|
private final RMpDevEvaluateDetailPOService rMpDevEvaluateDetailPOService;
|
||||||
|
private final IRMpBenchmarkLevelDService irMpBenchmarkLevelDService;
|
||||||
|
private final IRMpBenchmarkLevelMService irMpBenchmarkLevelMService;
|
||||||
|
private final IRMpBenchmarkLevelQService irmBenchmarkLevelQService;
|
||||||
|
private final IRMpBenchmarkLevelYService irMpBenchmarkLevelYService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 算法名: 3.3.1.1-----监测点评价
|
* 算法名: 3.3.1.1-----监测点评价
|
||||||
@@ -388,5 +396,40 @@ public class MeasurementExecutor extends BaseExecutor {
|
|||||||
public void rMpDevEvaluateDetailProcess(NodeComponent bindCmp) {
|
public void rMpDevEvaluateDetailProcess(NodeComponent bindCmp) {
|
||||||
rMpDevEvaluateDetailPOService.devEvaluateDetail(bindCmp.getRequestData());
|
rMpDevEvaluateDetailPOService.devEvaluateDetail(bindCmp.getRequestData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 算法名: 3.4.1.9.1-----监测点基准水平评估_日、月、季、年统计(r_mp_benchmark_level_d、r_mp_benchmark_level_m、r_mp_benchmark_level_q、r_mp_benchmark_level_y)
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @date 2023年11月21日 14:40
|
||||||
|
*/
|
||||||
|
@LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "rMpBenchmarkLevel", nodeType = NodeTypeEnum.COMMON)
|
||||||
|
public boolean rMpBenchmarkLevelAccess(NodeComponent bindCmp) {
|
||||||
|
return isAccess(bindCmp);
|
||||||
|
}
|
||||||
|
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "rMpBenchmarkLevel", nodeType = NodeTypeEnum.COMMON)
|
||||||
|
public void rMpBenchmarkLevelProcess(NodeComponent bindCmp) {
|
||||||
|
String tag = bindCmp.getTag();
|
||||||
|
CalculatedParam calculatedParam = bindCmp.getRequestData();
|
||||||
|
if (Objects.equals(tag,"r_mp_benchmark_level_d")){
|
||||||
|
//日表
|
||||||
|
irMpBenchmarkLevelDService.benchmarkLevelD(calculatedParam);
|
||||||
|
} else if (Objects.equals(tag,"r_mp_benchmark_level_m")){
|
||||||
|
if (!calculatedParam.isRepair()) {
|
||||||
|
//月表
|
||||||
|
irMpBenchmarkLevelMService.benchmarkLevelM(calculatedParam);
|
||||||
|
}
|
||||||
|
} else if (Objects.equals(tag,"r_mp_benchmark_level_q")) {
|
||||||
|
if (!calculatedParam.isRepair()) {
|
||||||
|
//季表
|
||||||
|
irmBenchmarkLevelQService.benchmarkLevelQ(calculatedParam);
|
||||||
|
}
|
||||||
|
} else if (Objects.equals(tag,"r_mp_benchmark_level_y")) {
|
||||||
|
if (!calculatedParam.isRepair()) {
|
||||||
|
//年表
|
||||||
|
irMpBenchmarkLevelYService.benchmarkLevelY(calculatedParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/********************************************算法负责人:xy结束***********************************************************/
|
/********************************************算法负责人:xy结束***********************************************************/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,18 @@
|
|||||||
package com.njcn.prepare.harmonic.mapper.mysql.day;
|
package com.njcn.prepare.harmonic.mapper.mysql.day;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||||
import com.njcn.harmonic.pojo.po.day.RStatDataPltDPO;
|
import com.njcn.harmonic.pojo.po.day.RStatDataPltDPO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface RStatDataPltDMapper extends MppBaseMapper<RStatDataPltDPO> {
|
public interface RStatDataPltDMapper extends MppBaseMapper<RStatDataPltDPO> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取监测点基准水平评估
|
||||||
|
*/
|
||||||
|
List<RStatDataPltDPO> getBenchmarkLevel(@Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime, @Param("list") List<String> list);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.njcn.prepare.harmonic.mapper.mysql.day;
|
package com.njcn.prepare.harmonic.mapper.mysql.day;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
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.dto.AlarmDetailDayDTO;
|
||||||
@@ -24,4 +25,9 @@ public interface RStatDataVDMapper extends MppBaseMapper<RStatDataVDPO> {
|
|||||||
List<AlarmDetailDayDTO> getAvgDayData(@Param("startTime") String time, @Param("endTime") String endTime, @Param("list") List<String> list);
|
List<AlarmDetailDayDTO> getAvgDayData(@Param("startTime") String time, @Param("endTime") String endTime, @Param("list") List<String> list);
|
||||||
|
|
||||||
List<RMpTargetWarnDDTO> getTargetWarnD(@Param("time") String time, @Param("list") List<String> list);
|
List<RMpTargetWarnDDTO> getTargetWarnD(@Param("time") String time, @Param("list") List<String> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取监测点基准水平评估
|
||||||
|
*/
|
||||||
|
List<RStatDataVDPO> getBenchmarkLevel(@Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime, @Param("list") List<String> list);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,4 +2,24 @@
|
|||||||
<!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.RStatDataPltDMapper">
|
<mapper namespace="com.njcn.prepare.harmonic.mapper.mysql.day.RStatDataPltDMapper">
|
||||||
|
|
||||||
|
<select id="getBenchmarkLevel" resultType="com.njcn.harmonic.pojo.po.day.RStatDataPltDPO">
|
||||||
|
select
|
||||||
|
`time`,
|
||||||
|
line_id,
|
||||||
|
max(plt) plt
|
||||||
|
from
|
||||||
|
r_stat_data_plt_d
|
||||||
|
where
|
||||||
|
`time` between #{startTime} and #{endTime}
|
||||||
|
and value_type = 'MAX'
|
||||||
|
and phasic_type in ('A','B','C')
|
||||||
|
<if test="list != null and list.size() > 0">
|
||||||
|
and line_id in
|
||||||
|
<foreach collection="list" item="item" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
group by `time`,line_id
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -317,4 +317,74 @@
|
|||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getBenchmarkLevel" resultType="com.njcn.harmonic.pojo.po.day.RStatDataVDPO">
|
||||||
|
select
|
||||||
|
A.`time`,
|
||||||
|
A.line_id lineId,
|
||||||
|
A.rms,
|
||||||
|
C.vUnbalance,
|
||||||
|
B.vThd
|
||||||
|
from
|
||||||
|
(
|
||||||
|
select
|
||||||
|
`time`,
|
||||||
|
line_id,
|
||||||
|
max(rms) rms
|
||||||
|
from
|
||||||
|
r_stat_data_v_d
|
||||||
|
where
|
||||||
|
`time` between #{startTime} and #{endTime}
|
||||||
|
and phasic_type in ('A', 'B', 'C')
|
||||||
|
and value_type in ('AVG')
|
||||||
|
<if test="list != null and list.size() > 0">
|
||||||
|
and line_id in
|
||||||
|
<foreach collection="list" item="item" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
group by `time`, line_id
|
||||||
|
) A
|
||||||
|
inner join
|
||||||
|
(
|
||||||
|
select
|
||||||
|
`time`,
|
||||||
|
line_id,
|
||||||
|
max(v_thd) vThd
|
||||||
|
from
|
||||||
|
r_stat_data_v_d
|
||||||
|
where
|
||||||
|
`time` between #{startTime} and #{endTime}
|
||||||
|
and phasic_type in ('A', 'B', 'C')
|
||||||
|
and value_type in ('CP95')
|
||||||
|
<if test="list != null and list.size() > 0">
|
||||||
|
and line_id in
|
||||||
|
<foreach collection="list" item="item" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
group by `time`,line_id
|
||||||
|
) B
|
||||||
|
on A.`time` = B.`time` and A.line_id = B.line_id
|
||||||
|
inner join
|
||||||
|
(
|
||||||
|
select
|
||||||
|
`time`,
|
||||||
|
line_id,
|
||||||
|
max(v_unbalance) vUnbalance
|
||||||
|
from
|
||||||
|
r_stat_data_v_d
|
||||||
|
where
|
||||||
|
`time` between #{startTime} and #{endTime}
|
||||||
|
and phasic_type = 'T'
|
||||||
|
and value_type in ('CP95')
|
||||||
|
<if test="list != null and list.size() > 0">
|
||||||
|
and line_id in
|
||||||
|
<foreach collection="list" item="item" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
group by `time`,line_id
|
||||||
|
) C
|
||||||
|
on A.`time` = C.`time` and A.line_id = C.line_id
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.njcn.prepare.harmonic.mapper.mysql.newalgorithm;
|
||||||
|
|
||||||
|
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelD;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xuyang
|
||||||
|
*/
|
||||||
|
public interface RMpBenchmarkLevelDMapper extends MppBaseMapper<RMpBenchmarkLevelD> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.njcn.prepare.harmonic.mapper.mysql.newalgorithm;
|
||||||
|
|
||||||
|
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelM;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xuyang
|
||||||
|
*/
|
||||||
|
public interface RMpBenchmarkLevelMMapper extends MppBaseMapper<RMpBenchmarkLevelM> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.njcn.prepare.harmonic.mapper.mysql.newalgorithm;
|
||||||
|
|
||||||
|
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelQ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xuyang
|
||||||
|
*/
|
||||||
|
public interface RMpBenchmarkLevelQMapper extends MppBaseMapper<RMpBenchmarkLevelQ> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.njcn.prepare.harmonic.mapper.mysql.newalgorithm;
|
||||||
|
|
||||||
|
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelQ;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xuyang
|
||||||
|
*/
|
||||||
|
public interface RMpBenchmarkLevelYMapper extends MppBaseMapper<RMpBenchmarkLevelY> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.njcn.prepare.harmonic.service.mysql.newalgorithm;
|
||||||
|
|
||||||
|
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelD;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点基准水平评估_月
|
||||||
|
* xuyang
|
||||||
|
* 2023-11-21
|
||||||
|
*/
|
||||||
|
public interface IRMpBenchmarkLevelDService extends IMppService<RMpBenchmarkLevelD> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 监测点基准水平评估_日
|
||||||
|
* @author: xuyang
|
||||||
|
*/
|
||||||
|
void benchmarkLevelD(CalculatedParam calculatedParam);
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.njcn.prepare.harmonic.service.mysql.newalgorithm;
|
||||||
|
|
||||||
|
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelM;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点基准水平评估_月
|
||||||
|
* xuyang
|
||||||
|
* 2023-11-21
|
||||||
|
*/
|
||||||
|
public interface IRMpBenchmarkLevelMService extends IMppService<RMpBenchmarkLevelM> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 监测点基准水平评估_月
|
||||||
|
* @author: xuyang
|
||||||
|
*/
|
||||||
|
void benchmarkLevelM(CalculatedParam calculatedParam);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.njcn.prepare.harmonic.service.mysql.newalgorithm;
|
||||||
|
|
||||||
|
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelQ;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点基准水平评估_季
|
||||||
|
* xuyang
|
||||||
|
* 2023-11-21
|
||||||
|
*/
|
||||||
|
public interface IRMpBenchmarkLevelQService extends IMppService<RMpBenchmarkLevelQ> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 监测点基准水平评估_季
|
||||||
|
* @author: xuyang
|
||||||
|
*/
|
||||||
|
void benchmarkLevelQ(CalculatedParam calculatedParam);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.njcn.prepare.harmonic.service.mysql.newalgorithm;
|
||||||
|
|
||||||
|
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelY;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点基准水平评估_年
|
||||||
|
* xuyang
|
||||||
|
* 2023-11-21
|
||||||
|
*/
|
||||||
|
public interface IRMpBenchmarkLevelYService extends IMppService<RMpBenchmarkLevelY> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 监测点基准水平评估_年
|
||||||
|
* @author: xuyang
|
||||||
|
*/
|
||||||
|
void benchmarkLevelY(CalculatedParam calculatedParam);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package com.njcn.prepare.harmonic.service.mysql.newalgorithm.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelD;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelM;
|
||||||
|
import com.njcn.harmonic.pojo.po.day.RStatDataPltDPO;
|
||||||
|
import com.njcn.harmonic.pojo.po.day.RStatDataVDPO;
|
||||||
|
import com.njcn.prepare.harmonic.mapper.mysql.day.RStatDataPltDMapper;
|
||||||
|
import com.njcn.prepare.harmonic.mapper.mysql.day.RStatDataVDMapper;
|
||||||
|
import com.njcn.prepare.harmonic.mapper.mysql.newalgorithm.RMpBenchmarkLevelDMapper;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
|
||||||
|
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.IRMpBenchmarkLevelDService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.ListUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:监测点基准水平评估_月
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/11/21 14:50
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RMpBenchmarkLevelDServiceImpl extends MppServiceImpl<RMpBenchmarkLevelDMapper, RMpBenchmarkLevelD> implements IRMpBenchmarkLevelDService {
|
||||||
|
|
||||||
|
private final RStatDataVDMapper rStatDataVDMapper;
|
||||||
|
|
||||||
|
private final RStatDataPltDMapper rStatDataPltDMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
|
public void benchmarkLevelD(CalculatedParam calculatedParam) {
|
||||||
|
log.info(LocalDateTime.now()+"===>监测点基准水平评估_日统计算法开始");
|
||||||
|
List<RMpBenchmarkLevelD> result = new ArrayList<>();
|
||||||
|
List<RStatDataVDPO> vList = new ArrayList<>();
|
||||||
|
List<RStatDataPltDPO> pltList = new ArrayList<>();
|
||||||
|
Map<String, List<RStatDataVDPO>> map1 = new HashMap<>();
|
||||||
|
Map<String, List<RStatDataPltDPO>> map2 = new HashMap<>();
|
||||||
|
List<String> lineIds = calculatedParam.getIdList();
|
||||||
|
DateTime beginDay = DateUtil.beginOfDay(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN));
|
||||||
|
DateTime endDay = DateUtil.endOfDay(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN));
|
||||||
|
//以尺寸100分片,查询数据
|
||||||
|
List<List<String>> pendingIds = ListUtils.partition(lineIds,100);
|
||||||
|
for (List<String> pendingId : pendingIds) {
|
||||||
|
//查询电压表
|
||||||
|
vList.addAll(rStatDataVDMapper.getBenchmarkLevel(beginDay,endDay,pendingId));
|
||||||
|
//查询长闪表
|
||||||
|
pltList.addAll(rStatDataPltDMapper.getBenchmarkLevel(beginDay,endDay,pendingId));
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(vList)){
|
||||||
|
map1 = vList.stream().collect(Collectors.groupingBy(RStatDataVDPO::getLineId));
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(pltList)){
|
||||||
|
map2 = pltList.stream().collect(Collectors.groupingBy(RStatDataPltDPO::getLineId));
|
||||||
|
}
|
||||||
|
for (String item : lineIds) {
|
||||||
|
RMpBenchmarkLevelD rMpBenchmarkLevel = new RMpBenchmarkLevelD();
|
||||||
|
rMpBenchmarkLevel.setMeasurementPointId(item);
|
||||||
|
rMpBenchmarkLevel.setDataDate(beginDay);
|
||||||
|
//初始化数据
|
||||||
|
rMpBenchmarkLevel.setVoltageAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setUnbalanceAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setVthdAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setFlickerAvg(0.0);
|
||||||
|
//稳态-有数据处理
|
||||||
|
List<RStatDataVDPO> l1 = map1.get(item);
|
||||||
|
if (CollectionUtil.isNotEmpty(l1)){
|
||||||
|
double vAvg = l1.stream().mapToDouble(RStatDataVDPO::getRms).average().getAsDouble();
|
||||||
|
double vUnbalanceAvg = l1.stream().mapToDouble(RStatDataVDPO::getVUnbalance).average().getAsDouble();
|
||||||
|
double vThdAvg = l1.stream().mapToDouble(RStatDataVDPO::getVThd).average().getAsDouble();
|
||||||
|
rMpBenchmarkLevel.setVoltageAvg(vAvg);
|
||||||
|
rMpBenchmarkLevel.setUnbalanceAvg(vUnbalanceAvg);
|
||||||
|
rMpBenchmarkLevel.setVthdAvg(vThdAvg);
|
||||||
|
}
|
||||||
|
List<RStatDataPltDPO> l2 = map2.get(item);
|
||||||
|
if (CollectionUtil.isNotEmpty(l2)){
|
||||||
|
double pltAvg = l2.stream().mapToDouble(RStatDataPltDPO::getPlt).average().getAsDouble();
|
||||||
|
rMpBenchmarkLevel.setFlickerAvg(pltAvg);
|
||||||
|
}
|
||||||
|
result.add(rMpBenchmarkLevel);
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(result)){
|
||||||
|
this.saveOrUpdateBatchByMultiId(result,100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
package com.njcn.prepare.harmonic.service.mysql.newalgorithm.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelD;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelM;
|
||||||
|
import com.njcn.prepare.harmonic.mapper.mysql.newalgorithm.RMpBenchmarkLevelMMapper;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
|
||||||
|
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.IRMpBenchmarkLevelDService;
|
||||||
|
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.IRMpBenchmarkLevelMService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.ListUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:监测点基准水平评估_月
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/11/21 14:50
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RMpBenchmarkLevelMServiceImpl extends MppServiceImpl<RMpBenchmarkLevelMMapper, RMpBenchmarkLevelM> implements IRMpBenchmarkLevelMService {
|
||||||
|
|
||||||
|
private final IRMpBenchmarkLevelDService irMpBenchmarkLevelDService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
|
public void benchmarkLevelM(CalculatedParam calculatedParam) {
|
||||||
|
log.info(LocalDateTime.now()+"===>监测点基准水平评估_月统计算法开始");
|
||||||
|
List<RMpBenchmarkLevelM> result = new ArrayList<>();
|
||||||
|
List<RMpBenchmarkLevelD> dList = new ArrayList<>();
|
||||||
|
Map<String,List<RMpBenchmarkLevelD>> map = new HashMap<>();
|
||||||
|
List<String> lineIds = calculatedParam.getIdList();
|
||||||
|
DateTime beginMonth = DateUtil.beginOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN));
|
||||||
|
DateTime endMonth = DateUtil.endOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN));
|
||||||
|
//以尺寸100分片,查询数据
|
||||||
|
List<List<String>> pendingIds = ListUtils.partition(lineIds,100);
|
||||||
|
for (List<String> pendingId : pendingIds) {
|
||||||
|
LambdaQueryWrapper<RMpBenchmarkLevelD> lambdaQueryWrapper = new LambdaQueryWrapper<RMpBenchmarkLevelD>();
|
||||||
|
lambdaQueryWrapper.in(RMpBenchmarkLevelD::getMeasurementPointId,pendingId)
|
||||||
|
.between(RMpBenchmarkLevelD::getDataDate,beginMonth,endMonth);
|
||||||
|
dList.addAll(irMpBenchmarkLevelDService.list(lambdaQueryWrapper));
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(dList)){
|
||||||
|
map = dList.stream().collect(Collectors.groupingBy(RMpBenchmarkLevelD::getMeasurementPointId));
|
||||||
|
}
|
||||||
|
for (String item : lineIds) {
|
||||||
|
RMpBenchmarkLevelM rMpBenchmarkLevel = new RMpBenchmarkLevelM();
|
||||||
|
rMpBenchmarkLevel.setMeasurementPointId(item);
|
||||||
|
rMpBenchmarkLevel.setDataDate(beginMonth);
|
||||||
|
//初始化数据
|
||||||
|
rMpBenchmarkLevel.setVoltageAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setVoltageSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setUnbalanceAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setUnbalanceSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setVthdAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setVthdSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setFlickerAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setFlickerSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setEventAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setEventSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setRiseAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setRiseSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setInterruptAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setInterruptSd(0.0);
|
||||||
|
//稳态-有数据处理
|
||||||
|
List<RMpBenchmarkLevelD> day = map.get(item);
|
||||||
|
if (CollectionUtil.isNotEmpty(day)){
|
||||||
|
//均值
|
||||||
|
double d1 = day.stream().mapToDouble(RMpBenchmarkLevelD::getVoltageAvg).average().orElse(0.0);
|
||||||
|
double d2 = day.stream().mapToDouble(RMpBenchmarkLevelD::getUnbalanceAvg).average().orElse(0.0);
|
||||||
|
double d3 = day.stream().mapToDouble(RMpBenchmarkLevelD::getVthdAvg).average().orElse(0.0);
|
||||||
|
double d4 = day.stream().mapToDouble(RMpBenchmarkLevelD::getFlickerAvg).average().orElse(0.0);
|
||||||
|
rMpBenchmarkLevel.setVoltageAvg(d1);
|
||||||
|
rMpBenchmarkLevel.setUnbalanceAvg(d2);
|
||||||
|
rMpBenchmarkLevel.setVthdAvg(d3);
|
||||||
|
rMpBenchmarkLevel.setFlickerAvg(d4);
|
||||||
|
//标准差
|
||||||
|
List<Double> l1 = day.stream().map(RMpBenchmarkLevelD::getVoltageAvg).collect(Collectors.toList());
|
||||||
|
List<Double> l2 = day.stream().map(RMpBenchmarkLevelD::getUnbalanceAvg).collect(Collectors.toList());
|
||||||
|
List<Double> l3 = day.stream().map(RMpBenchmarkLevelD::getVthdAvg).collect(Collectors.toList());
|
||||||
|
List<Double> l4 = day.stream().map(RMpBenchmarkLevelD::getFlickerAvg).collect(Collectors.toList());
|
||||||
|
rMpBenchmarkLevel.setVoltageSd(calculateStandardDeviation(l1,d1));
|
||||||
|
rMpBenchmarkLevel.setUnbalanceSd(calculateStandardDeviation(l2,d2));
|
||||||
|
rMpBenchmarkLevel.setVthdSd(calculateStandardDeviation(l3,d3));
|
||||||
|
rMpBenchmarkLevel.setFlickerSd(calculateStandardDeviation(l4,d4));
|
||||||
|
}
|
||||||
|
//暂态-暂无算法计算,默认为0
|
||||||
|
result.add(rMpBenchmarkLevel);
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(result)){
|
||||||
|
this.saveOrUpdateBatchByMultiId(result,100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double calculateStandardDeviation(List<Double> data, double mean) {
|
||||||
|
return Math.sqrt(calculateVariance(data, mean));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double calculateVariance(List<Double> data, double mean) {
|
||||||
|
return data.stream()
|
||||||
|
.mapToDouble(Double::doubleValue)
|
||||||
|
.map(value -> Math.pow(value - mean, 2))
|
||||||
|
.average()
|
||||||
|
.orElse(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
package com.njcn.prepare.harmonic.service.mysql.newalgorithm.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelD;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelQ;
|
||||||
|
import com.njcn.prepare.harmonic.mapper.mysql.newalgorithm.RMpBenchmarkLevelQMapper;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
|
||||||
|
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.IRMpBenchmarkLevelDService;
|
||||||
|
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.IRMpBenchmarkLevelQService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.ListUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:监测点基准水平评估_月
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/11/21 14:50
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RMpBenchmarkLevelQServiceImpl extends MppServiceImpl<RMpBenchmarkLevelQMapper, RMpBenchmarkLevelQ> implements IRMpBenchmarkLevelQService {
|
||||||
|
|
||||||
|
private final IRMpBenchmarkLevelDService irMpBenchmarkLevelDService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void benchmarkLevelQ(CalculatedParam calculatedParam) {
|
||||||
|
log.info(LocalDateTime.now()+"===>监测点基准水平评估_季统计算法开始");
|
||||||
|
List<RMpBenchmarkLevelQ> result = new ArrayList<>();
|
||||||
|
List<RMpBenchmarkLevelD> dList = new ArrayList<>();
|
||||||
|
Map<String,List<RMpBenchmarkLevelD>> map = new HashMap<>();
|
||||||
|
List<String> lineIds = calculatedParam.getIdList();
|
||||||
|
DateTime beginMonth = DateUtil.beginOfQuarter(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN));
|
||||||
|
DateTime endMonth = DateUtil.endOfQuarter(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN));
|
||||||
|
//以尺寸100分片,查询数据
|
||||||
|
List<List<String>> pendingIds = ListUtils.partition(lineIds,100);
|
||||||
|
for (List<String> pendingId : pendingIds) {
|
||||||
|
LambdaQueryWrapper<RMpBenchmarkLevelD> lambdaQueryWrapper = new LambdaQueryWrapper<RMpBenchmarkLevelD>();
|
||||||
|
lambdaQueryWrapper.in(RMpBenchmarkLevelD::getMeasurementPointId,pendingId)
|
||||||
|
.between(RMpBenchmarkLevelD::getDataDate,beginMonth,endMonth);
|
||||||
|
dList.addAll(irMpBenchmarkLevelDService.list(lambdaQueryWrapper));
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(dList)){
|
||||||
|
map = dList.stream().collect(Collectors.groupingBy(RMpBenchmarkLevelD::getMeasurementPointId));
|
||||||
|
}
|
||||||
|
for (String item : lineIds) {
|
||||||
|
RMpBenchmarkLevelQ rMpBenchmarkLevel = new RMpBenchmarkLevelQ();
|
||||||
|
rMpBenchmarkLevel.setMeasurementPointId(item);
|
||||||
|
rMpBenchmarkLevel.setDataDate(beginMonth);
|
||||||
|
//初始化数据
|
||||||
|
rMpBenchmarkLevel.setVoltageAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setVoltageSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setUnbalanceAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setUnbalanceSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setVthdAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setVthdSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setFlickerAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setFlickerSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setEventAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setEventSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setRiseAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setRiseSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setInterruptAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setInterruptSd(0.0);
|
||||||
|
//稳态-有数据处理
|
||||||
|
List<RMpBenchmarkLevelD> day = map.get(item);
|
||||||
|
if (CollectionUtil.isNotEmpty(day)){
|
||||||
|
//均值
|
||||||
|
double d1 = day.stream().mapToDouble(RMpBenchmarkLevelD::getVoltageAvg).average().orElse(0.0);
|
||||||
|
double d2 = day.stream().mapToDouble(RMpBenchmarkLevelD::getUnbalanceAvg).average().orElse(0.0);
|
||||||
|
double d3 = day.stream().mapToDouble(RMpBenchmarkLevelD::getVthdAvg).average().orElse(0.0);
|
||||||
|
double d4 = day.stream().mapToDouble(RMpBenchmarkLevelD::getFlickerAvg).average().orElse(0.0);
|
||||||
|
rMpBenchmarkLevel.setVoltageAvg(d1);
|
||||||
|
rMpBenchmarkLevel.setUnbalanceAvg(d2);
|
||||||
|
rMpBenchmarkLevel.setVthdAvg(d3);
|
||||||
|
rMpBenchmarkLevel.setFlickerAvg(d4);
|
||||||
|
//标准差
|
||||||
|
List<Double> l1 = day.stream().map(RMpBenchmarkLevelD::getVoltageAvg).collect(Collectors.toList());
|
||||||
|
List<Double> l2 = day.stream().map(RMpBenchmarkLevelD::getUnbalanceAvg).collect(Collectors.toList());
|
||||||
|
List<Double> l3 = day.stream().map(RMpBenchmarkLevelD::getVthdAvg).collect(Collectors.toList());
|
||||||
|
List<Double> l4 = day.stream().map(RMpBenchmarkLevelD::getFlickerAvg).collect(Collectors.toList());
|
||||||
|
rMpBenchmarkLevel.setVoltageSd(calculateStandardDeviation(l1,d1));
|
||||||
|
rMpBenchmarkLevel.setUnbalanceSd(calculateStandardDeviation(l2,d2));
|
||||||
|
rMpBenchmarkLevel.setVthdSd(calculateStandardDeviation(l3,d3));
|
||||||
|
rMpBenchmarkLevel.setFlickerSd(calculateStandardDeviation(l4,d4));
|
||||||
|
}
|
||||||
|
//暂态-暂无算法计算,默认为0
|
||||||
|
result.add(rMpBenchmarkLevel);
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(result)){
|
||||||
|
this.saveOrUpdateBatchByMultiId(result,100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double calculateStandardDeviation(List<Double> data, double mean) {
|
||||||
|
return Math.sqrt(calculateVariance(data, mean));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double calculateVariance(List<Double> data, double mean) {
|
||||||
|
return data.stream()
|
||||||
|
.mapToDouble(Double::doubleValue)
|
||||||
|
.map(value -> Math.pow(value - mean, 2))
|
||||||
|
.average()
|
||||||
|
.orElse(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
package com.njcn.prepare.harmonic.service.mysql.newalgorithm.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelD;
|
||||||
|
import com.njcn.harmonic.pojo.po.RMpBenchmarkLevelY;
|
||||||
|
import com.njcn.prepare.harmonic.mapper.mysql.newalgorithm.RMpBenchmarkLevelYMapper;
|
||||||
|
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
|
||||||
|
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.IRMpBenchmarkLevelDService;
|
||||||
|
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.IRMpBenchmarkLevelYService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.ListUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:监测点基准水平评估_月
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/11/21 14:50
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RMpBenchmarkLevelYServiceImpl extends MppServiceImpl<RMpBenchmarkLevelYMapper, RMpBenchmarkLevelY> implements IRMpBenchmarkLevelYService {
|
||||||
|
|
||||||
|
private final IRMpBenchmarkLevelDService irMpBenchmarkLevelDService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void benchmarkLevelY(CalculatedParam calculatedParam) {
|
||||||
|
log.info(LocalDateTime.now()+"===>监测点基准水平评估_年统计算法开始");
|
||||||
|
List<RMpBenchmarkLevelY> result = new ArrayList<>();
|
||||||
|
List<RMpBenchmarkLevelD> dList = new ArrayList<>();
|
||||||
|
Map<String,List<RMpBenchmarkLevelD>> map = new HashMap<>();
|
||||||
|
List<String> lineIds = calculatedParam.getIdList();
|
||||||
|
DateTime beginMonth = DateUtil.beginOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN));
|
||||||
|
DateTime endMonth = DateUtil.endOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN));
|
||||||
|
//以尺寸100分片,查询数据
|
||||||
|
List<List<String>> pendingIds = ListUtils.partition(lineIds,100);
|
||||||
|
for (List<String> pendingId : pendingIds) {
|
||||||
|
LambdaQueryWrapper<RMpBenchmarkLevelD> lambdaQueryWrapper = new LambdaQueryWrapper<RMpBenchmarkLevelD>();
|
||||||
|
lambdaQueryWrapper.in(RMpBenchmarkLevelD::getMeasurementPointId,pendingId)
|
||||||
|
.between(RMpBenchmarkLevelD::getDataDate,beginMonth,endMonth);
|
||||||
|
dList.addAll(irMpBenchmarkLevelDService.list(lambdaQueryWrapper));
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(dList)){
|
||||||
|
map = dList.stream().collect(Collectors.groupingBy(RMpBenchmarkLevelD::getMeasurementPointId));
|
||||||
|
}
|
||||||
|
for (String item : lineIds) {
|
||||||
|
RMpBenchmarkLevelY rMpBenchmarkLevel = new RMpBenchmarkLevelY();
|
||||||
|
rMpBenchmarkLevel.setMeasurementPointId(item);
|
||||||
|
rMpBenchmarkLevel.setDataDate(beginMonth);
|
||||||
|
//初始化数据
|
||||||
|
rMpBenchmarkLevel.setVoltageAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setVoltageSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setUnbalanceAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setUnbalanceSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setVthdAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setVthdSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setFlickerAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setFlickerSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setEventAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setEventSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setRiseAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setRiseSd(0.0);
|
||||||
|
rMpBenchmarkLevel.setInterruptAvg(0.0);
|
||||||
|
rMpBenchmarkLevel.setInterruptSd(0.0);
|
||||||
|
//稳态-有数据处理
|
||||||
|
List<RMpBenchmarkLevelD> day = map.get(item);
|
||||||
|
if (CollectionUtil.isNotEmpty(day)){
|
||||||
|
//均值
|
||||||
|
double d1 = day.stream().mapToDouble(RMpBenchmarkLevelD::getVoltageAvg).average().orElse(0.0);
|
||||||
|
double d2 = day.stream().mapToDouble(RMpBenchmarkLevelD::getUnbalanceAvg).average().orElse(0.0);
|
||||||
|
double d3 = day.stream().mapToDouble(RMpBenchmarkLevelD::getVthdAvg).average().orElse(0.0);
|
||||||
|
double d4 = day.stream().mapToDouble(RMpBenchmarkLevelD::getFlickerAvg).average().orElse(0.0);
|
||||||
|
rMpBenchmarkLevel.setVoltageAvg(d1);
|
||||||
|
rMpBenchmarkLevel.setUnbalanceAvg(d2);
|
||||||
|
rMpBenchmarkLevel.setVthdAvg(d3);
|
||||||
|
rMpBenchmarkLevel.setFlickerAvg(d4);
|
||||||
|
//标准差
|
||||||
|
List<Double> l1 = day.stream().map(RMpBenchmarkLevelD::getVoltageAvg).collect(Collectors.toList());
|
||||||
|
List<Double> l2 = day.stream().map(RMpBenchmarkLevelD::getUnbalanceAvg).collect(Collectors.toList());
|
||||||
|
List<Double> l3 = day.stream().map(RMpBenchmarkLevelD::getVthdAvg).collect(Collectors.toList());
|
||||||
|
List<Double> l4 = day.stream().map(RMpBenchmarkLevelD::getFlickerAvg).collect(Collectors.toList());
|
||||||
|
rMpBenchmarkLevel.setVoltageSd(calculateStandardDeviation(l1,d1));
|
||||||
|
rMpBenchmarkLevel.setUnbalanceSd(calculateStandardDeviation(l2,d2));
|
||||||
|
rMpBenchmarkLevel.setVthdSd(calculateStandardDeviation(l3,d3));
|
||||||
|
rMpBenchmarkLevel.setFlickerSd(calculateStandardDeviation(l4,d4));
|
||||||
|
}
|
||||||
|
//暂态-暂无算法计算,默认为0
|
||||||
|
result.add(rMpBenchmarkLevel);
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(result)){
|
||||||
|
this.saveOrUpdateBatchByMultiId(result,100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double calculateStandardDeviation(List<Double> data, double mean) {
|
||||||
|
return Math.sqrt(calculateVariance(data, mean));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double calculateVariance(List<Double> data, double mean) {
|
||||||
|
return data.stream()
|
||||||
|
.mapToDouble(Double::doubleValue)
|
||||||
|
.map(value -> Math.pow(value - mean, 2))
|
||||||
|
.average()
|
||||||
|
.orElse(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user