国网上送接口底层算法实现

This commit is contained in:
2023-12-13 17:36:17 +08:00
parent e49998797d
commit eaaa3b0efc
15 changed files with 698 additions and 71 deletions

View File

@@ -126,4 +126,6 @@ public class LineDataDto {
private Double v50; private Double v50;
private Double iNeg;
} }

View File

@@ -209,6 +209,9 @@ public class RDimVoltageD {
@TableField(value = "v_50") @TableField(value = "v_50")
private Double v50; private Double v50;
@TableField(value = "i_neg")
private Double iNeg;
public RDimVoltageD() { public RDimVoltageD() {
this.v = 3.1415926; this.v = 3.1415926;
this.vUnbalance = 3.1415926; this.vUnbalance = 3.1415926;
@@ -264,6 +267,7 @@ public class RDimVoltageD {
this.v48 = 3.1415926; this.v48 = 3.1415926;
this.v49 = 3.1415926; this.v49 = 3.1415926;
this.v50 = 3.1415926; this.v50 = 3.1415926;
this.iNeg = 3.1415926;
} }
} }

View File

@@ -215,6 +215,9 @@ public class RDimVoltageM {
@TableField(value = "v_50") @TableField(value = "v_50")
private Double v50; private Double v50;
@TableField(value = "i_neg")
private Double iNeg;
public RDimVoltageM() { public RDimVoltageM() {
this.v = 3.1415926; this.v = 3.1415926;
this.vUnbalance = 3.1415926; this.vUnbalance = 3.1415926;
@@ -270,6 +273,7 @@ public class RDimVoltageM {
this.v48 = 3.1415926; this.v48 = 3.1415926;
this.v49 = 3.1415926; this.v49 = 3.1415926;
this.v50 = 3.1415926; this.v50 = 3.1415926;
this.iNeg = 3.1415926;
} }

View File

@@ -215,6 +215,9 @@ public class RDimVoltageY {
@TableField(value = "v_50") @TableField(value = "v_50")
private Double v50; private Double v50;
@TableField(value = "i_neg")
private Double iNeg;
public RDimVoltageY() { public RDimVoltageY() {
this.v = 3.14159; this.v = 3.14159;
this.vUnbalance = 3.14159; this.vUnbalance = 3.14159;
@@ -270,6 +273,7 @@ public class RDimVoltageY {
this.v48 = 3.14159; this.v48 = 3.14159;
this.v49 = 3.14159; this.v49 = 3.14159;
this.v50 = 3.14159; this.v50 = 3.14159;
this.iNeg = 3.14159;
} }

View File

@@ -0,0 +1,127 @@
package com.njcn.harmonic.pojo.po.upload;
import com.baomidou.mybatisplus.annotation.TableName;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import lombok.Data;
/**
* <p>
* 电能质量基准水平评估数据-日表
* </p>
*
* @author xuyang
* @since 2023-12-12
*/
@Data
@TableName("r_upload_evaluation_data_d")
public class RUploadEvaluationDataD {
private static final long serialVersionUID = 1L;
/**
* uuid
*/
private String id;
/**
* 省级单位id
*/
@MppMultiId
private String provinceId;
/**
* 省级单位名称
*/
private String provinceName;
/**
* 市级单位id
*/
@MppMultiId
private String cityId;
/**
* 市级单位名称
*/
private String cityName;
/**
* 县级单位id
*/
@MppMultiId
private String countyId;
/**
* 县级单位名称
*/
private String countyName;
/**
* 谐波次数(次数应取2-50)
*/
@MppMultiId
private Integer harmonicNum;
/**
* 指标类型(01:电压 02:长时间闪变 03:三相电压不平衡 04:电压总谐波畸变率 05:各次谐波电压 06:负序电流)
*/
@MppMultiId
private String indexType;
/**
* 数据来源(01:仅在线监测 02:在线监测与现场测试)
*/
@MppMultiId
private String dataSources;
/**
* 监测母线数量
*/
private Integer monitorBusNum = 0;
/**
* 母线监测率(%)
*/
private Double monitorBusRate = 0.0d;
/**
* 在运母线数量
*/
private Integer onlineBusNum = 0;
/**
* 均值
*/
private Double avgValue;
/**
* 标准差
*/
private Double standardDeviation;
/**
* 统计日期
*/
@MppMultiId
private String statisticalDate;
/**
* 统计层级(3:省 4:市 5:县)
*/
@MppMultiId
private String statisticalLevel;
/**
* 统计类型(01:年 02:月 03:日)
*/
@MppMultiId
private String statisticalType;
/**
* 电压等级
*/
@MppMultiId
private String voltageLevel;
}

View File

@@ -37,6 +37,22 @@ public enum UploadEnum {
DISTRIBUTION_FLAG_01("01","主网"), DISTRIBUTION_FLAG_01("01","主网"),
DISTRIBUTION_FLAG_02("02","配网"), DISTRIBUTION_FLAG_02("02","配网"),
/**
* 指标类型(01:电压 02:长时间闪变 03:三相电压不平衡 04:电压总谐波畸变率 05:各次谐波电压 06:负序电流)
*/
INDEX_TYPE_01("01","电压"),
INDEX_TYPE_02("02","长时间闪变"),
INDEX_TYPE_03("03","三相电压不平衡"),
INDEX_TYPE_04("04","电压总谐波畸变率"),
INDEX_TYPE_05("05","各次谐波电压"),
INDEX_TYPE_06("06","负序电流"),
/**
* 数据来源(01:仅在线监测 02:在线监测与现场测试)
*/
DATA_SOURCES_01("01","仅在线监测"),
DATA_SOURCES_02("02","在线监测与现场测试"),
; ;
private final String code; private final String code;

View File

@@ -0,0 +1,50 @@
package com.njcn.prepare.harmonic.pojo.dto;
import lombok.Data;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/12/12 16:32
*/
@Data
public class BusBarDto {
/**
* 单位id
*/
private String orgId;
/**
* 电压等级实体
*/
private List<VoltageChild> voltageChild;
@Data
public static class VoltageChild {
/**
* 电压等级
*/
private String voltageLevel;
/**
* 监测母线数量
*/
private Integer monitorBusNum;
/**
* 在运母线数量
*/
private Integer onlineBusNum;
/**
* 监测率
*/
private Double monitorRate;
}
}

View File

@@ -12,6 +12,7 @@ import com.njcn.prepare.harmonic.service.mysql.area.RStatOrgService;
import com.njcn.prepare.harmonic.service.mysql.dim.*; import com.njcn.prepare.harmonic.service.mysql.dim.*;
import com.njcn.prepare.harmonic.service.mysql.line.PollutionService; import com.njcn.prepare.harmonic.service.mysql.line.PollutionService;
import com.njcn.prepare.harmonic.service.mysql.newalgorithm.*; import com.njcn.prepare.harmonic.service.mysql.newalgorithm.*;
import com.njcn.prepare.harmonic.service.mysql.upload.IRUploadEvaluationDataDService;
import com.njcn.prepare.harmonic.service.mysql.send.ConverterdetailstatisticsPOService; import com.njcn.prepare.harmonic.service.mysql.send.ConverterdetailstatisticsPOService;
import com.njcn.prepare.harmonic.service.mysql.send.PqTypicalSourceCreatePOService; import com.njcn.prepare.harmonic.service.mysql.send.PqTypicalSourceCreatePOService;
import com.njcn.prepare.harmonic.service.mysql.upload.IRUploadPointStatisticalDataDService; import com.njcn.prepare.harmonic.service.mysql.upload.IRUploadPointStatisticalDataDService;
@@ -75,6 +76,7 @@ public class OrgPointExecutor extends BaseExecutor{
private final ConverterdetailstatisticsPOService converterdetailstatisticsPOService; private final ConverterdetailstatisticsPOService converterdetailstatisticsPOService;
private final PqTypicalSourceCreatePOService pqTypicalSourceCreatePOService; private final PqTypicalSourceCreatePOService pqTypicalSourceCreatePOService;
private final IRUploadEvaluationDataDService irUploadEvaluationDataDService;
/** /**
* *
* 3.3.2. 单位标数据质量 * 3.3.2. 单位标数据质量
@@ -648,4 +650,18 @@ public class OrgPointExecutor extends BaseExecutor{
CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam = bindCmp.getRequestData(); CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam = bindCmp.getRequestData();
pqTypicalSourceCreatePOService.handlerDay(calculatedParam); pqTypicalSourceCreatePOService.handlerDay(calculatedParam);
} }
/**
* 河北国网上送接口
* 2.4.1.8接收电能质量基准水平评估数据接口
* xuyang
*/
@LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "rUploadEvaluationData", nodeType = NodeTypeEnum.COMMON)
public boolean rUploadEvaluationDataAccess(NodeComponent bindCmp) {
return isAccess(bindCmp);
}
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "rUploadEvaluationData", nodeType = NodeTypeEnum.COMMON)
public void rUploadEvaluationDataProcess(NodeComponent bindCmp) {
irUploadEvaluationDataDService.insertEvaluationDataDay(bindCmp.getRequestData());
}
} }

View File

@@ -19,7 +19,8 @@
B.v31,B.v32,B.v33,B.v34,B.v35, B.v31,B.v32,B.v33,B.v34,B.v35,
B.v36,B.v37,B.v38,B.v39,B.v40, B.v36,B.v37,B.v38,B.v39,B.v40,
B.v41,B.v42,B.v43,B.v44,B.v45, B.v41,B.v42,B.v43,B.v44,B.v45,
B.v46,B.v47,B.v48,B.v49,B.v50 B.v46,B.v47,B.v48,B.v49,B.v50,
E.iNeg
from from
( (
select select
@@ -128,5 +129,26 @@
group by `time`,line_id group by `time`,line_id
) D ) D
on A.`time` = D.`time` and A.line_id = D.line_id on A.`time` = D.`time` and A.line_id = D.line_id
inner join
(
select
`time`,
line_id,
max(i_neg) iNeg
from
r_stat_data_i_d
where
`time` between #{startTime} and #{endTime}
and phasic_type = 'T'
and value_type in ('CP95')
<if test="collection != null and collection.size() > 0">
and line_id in
<foreach collection="collection" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
group by `time`,line_id
) E
on A.`time` = E.`time` and A.line_id = E.line_id
</select> </select>
</mapper> </mapper>

View File

@@ -0,0 +1,16 @@
package com.njcn.prepare.harmonic.mapper.mysql.upload;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.harmonic.pojo.po.upload.RUploadEvaluationDataD;
/**
* <p>
* 电能质量基准水平评估数据-日表 Mapper 接口
* </p>
*
* @author xuyang
* @since 2023-12-12
*/
public interface RUploadEvaluationDataDMapper extends MppBaseMapper<RUploadEvaluationDataD> {
}

View File

@@ -18,6 +18,7 @@ import com.njcn.harmonic.pojo.dto.LineDataDto;
import com.njcn.prepare.harmonic.service.mysql.dim.IRDimVoltageDService; import com.njcn.prepare.harmonic.service.mysql.dim.IRDimVoltageDService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate; import java.time.LocalDate;
@@ -74,19 +75,9 @@ public class RDimVoltageDServiceImpl extends MppServiceImpl<RDimVoltageDMapper,
Map<String, List<GeneratrixWire>> map1 = list4.stream().collect(Collectors.groupingBy(GeneratrixWire::getScale)); Map<String, List<GeneratrixWire>> map1 = list4.stream().collect(Collectors.groupingBy(GeneratrixWire::getScale));
//循环分组数据,获取母线下监测点数据 //循环分组数据,获取母线下监测点数据
map1.forEach((k, v) -> { map1.forEach((k, v) -> {
rDimVoltageD.setVoltageType(k); RDimVoltageD dto = assignment(k,rDimVoltageD,v,list1,list2);
//不同电压等级下母线的id result.add(dto);
List<String> list5 = v.stream().map(GeneratrixWire::getId).collect(Collectors.toList());
//获取这些母线下的监测点
List<Monitor> list6 = list1.stream().filter(obj -> list5.contains(obj.getLineId())).collect(Collectors.toList());
//获取监测点数据
List<LineDataDto> list7 = list2.stream().filter(vo->list6.stream().map(Monitor::getId).collect(Collectors.toList()).contains(vo.getLineId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(list7)){
//赋值
assignment(list7,rDimVoltageD);
}
}); });
result.add(rDimVoltageD);
} }
}); });
} }
@@ -130,64 +121,76 @@ public class RDimVoltageDServiceImpl extends MppServiceImpl<RDimVoltageDMapper,
/** /**
* 给实体赋值 * 给实体赋值
* @param list7 数据集合
* @param rDimVoltageD 对象 * @param rDimVoltageD 对象
*/ */
public void assignment(List<LineDataDto> list7, RDimVoltageD rDimVoltageD) { public RDimVoltageD assignment(String voltage, RDimVoltageD rDimVoltageD, List<GeneratrixWire> list1, List<Monitor> list2, List<LineDataDto> list3) {
rDimVoltageD.setV(list7.stream().mapToDouble(LineDataDto::getRms).average().orElse(0d)); RDimVoltageD result = new RDimVoltageD();
rDimVoltageD.setVUnbalance(list7.stream().mapToDouble(LineDataDto::getVUnbalance).average().orElse(0d)); BeanUtils.copyProperties(rDimVoltageD,result);
rDimVoltageD.setPst(list7.stream().mapToDouble(LineDataDto::getPst).average().orElse(0d)); result.setVoltageType(voltage);
rDimVoltageD.setVThd(list7.stream().mapToDouble(LineDataDto::getVThd).average().orElse(0d)); //不同电压等级下母线的id
rDimVoltageD.setV1(list7.stream().mapToDouble(LineDataDto::getV1).average().orElse(0d)); List<String> l1 = list1.stream().map(GeneratrixWire::getId).collect(Collectors.toList());
rDimVoltageD.setV2(list7.stream().mapToDouble(LineDataDto::getV2).average().orElse(0d)); //获取这些母线下的监测点
rDimVoltageD.setV3(list7.stream().mapToDouble(LineDataDto::getV3).average().orElse(0d)); List<Monitor> l2 = list2.stream().filter(obj -> l1.contains(obj.getLineId())).collect(Collectors.toList());
rDimVoltageD.setV4(list7.stream().mapToDouble(LineDataDto::getV4).average().orElse(0d)); //获取监测点数据
rDimVoltageD.setV5(list7.stream().mapToDouble(LineDataDto::getV5).average().orElse(0d)); List<LineDataDto> l3 = list3.stream().filter(vo->l2.stream().map(Monitor::getId).collect(Collectors.toList()).contains(vo.getLineId())).collect(Collectors.toList());
rDimVoltageD.setV6(list7.stream().mapToDouble(LineDataDto::getV6).average().orElse(0d)); if (CollectionUtil.isNotEmpty(l3)){
rDimVoltageD.setV7(list7.stream().mapToDouble(LineDataDto::getV7).average().orElse(0d)); result.setV(l3.stream().mapToDouble(LineDataDto::getRms).average().orElse(0d));
rDimVoltageD.setV8(list7.stream().mapToDouble(LineDataDto::getV8).average().orElse(0d)); result.setVUnbalance(l3.stream().mapToDouble(LineDataDto::getVUnbalance).average().orElse(0d));
rDimVoltageD.setV9(list7.stream().mapToDouble(LineDataDto::getV9).average().orElse(0d)); result.setPst(l3.stream().mapToDouble(LineDataDto::getPst).average().orElse(0d));
rDimVoltageD.setV10(list7.stream().mapToDouble(LineDataDto::getV10).average().orElse(0d)); result.setVThd(l3.stream().mapToDouble(LineDataDto::getVThd).average().orElse(0d));
rDimVoltageD.setV11(list7.stream().mapToDouble(LineDataDto::getV11).average().orElse(0d)); result.setV1(l3.stream().mapToDouble(LineDataDto::getV1).average().orElse(0d));
rDimVoltageD.setV12(list7.stream().mapToDouble(LineDataDto::getV12).average().orElse(0d)); result.setV2(l3.stream().mapToDouble(LineDataDto::getV2).average().orElse(0d));
rDimVoltageD.setV13(list7.stream().mapToDouble(LineDataDto::getV13).average().orElse(0d)); result.setV3(l3.stream().mapToDouble(LineDataDto::getV3).average().orElse(0d));
rDimVoltageD.setV14(list7.stream().mapToDouble(LineDataDto::getV14).average().orElse(0d)); result.setV4(l3.stream().mapToDouble(LineDataDto::getV4).average().orElse(0d));
rDimVoltageD.setV15(list7.stream().mapToDouble(LineDataDto::getV15).average().orElse(0d)); result.setV5(l3.stream().mapToDouble(LineDataDto::getV5).average().orElse(0d));
rDimVoltageD.setV16(list7.stream().mapToDouble(LineDataDto::getV16).average().orElse(0d)); result.setV6(l3.stream().mapToDouble(LineDataDto::getV6).average().orElse(0d));
rDimVoltageD.setV17(list7.stream().mapToDouble(LineDataDto::getV17).average().orElse(0d)); result.setV7(l3.stream().mapToDouble(LineDataDto::getV7).average().orElse(0d));
rDimVoltageD.setV18(list7.stream().mapToDouble(LineDataDto::getV18).average().orElse(0d)); result.setV8(l3.stream().mapToDouble(LineDataDto::getV8).average().orElse(0d));
rDimVoltageD.setV19(list7.stream().mapToDouble(LineDataDto::getV19).average().orElse(0d)); result.setV9(l3.stream().mapToDouble(LineDataDto::getV9).average().orElse(0d));
rDimVoltageD.setV20(list7.stream().mapToDouble(LineDataDto::getV20).average().orElse(0d)); result.setV10(l3.stream().mapToDouble(LineDataDto::getV10).average().orElse(0d));
rDimVoltageD.setV21(list7.stream().mapToDouble(LineDataDto::getV21).average().orElse(0d)); result.setV11(l3.stream().mapToDouble(LineDataDto::getV11).average().orElse(0d));
rDimVoltageD.setV22(list7.stream().mapToDouble(LineDataDto::getV22).average().orElse(0d)); result.setV12(l3.stream().mapToDouble(LineDataDto::getV12).average().orElse(0d));
rDimVoltageD.setV23(list7.stream().mapToDouble(LineDataDto::getV23).average().orElse(0d)); result.setV13(l3.stream().mapToDouble(LineDataDto::getV13).average().orElse(0d));
rDimVoltageD.setV24(list7.stream().mapToDouble(LineDataDto::getV24).average().orElse(0d)); result.setV14(l3.stream().mapToDouble(LineDataDto::getV14).average().orElse(0d));
rDimVoltageD.setV25(list7.stream().mapToDouble(LineDataDto::getV25).average().orElse(0d)); result.setV15(l3.stream().mapToDouble(LineDataDto::getV15).average().orElse(0d));
rDimVoltageD.setV26(list7.stream().mapToDouble(LineDataDto::getV26).average().orElse(0d)); result.setV16(l3.stream().mapToDouble(LineDataDto::getV16).average().orElse(0d));
rDimVoltageD.setV27(list7.stream().mapToDouble(LineDataDto::getV27).average().orElse(0d)); result.setV17(l3.stream().mapToDouble(LineDataDto::getV17).average().orElse(0d));
rDimVoltageD.setV28(list7.stream().mapToDouble(LineDataDto::getV28).average().orElse(0d)); result.setV18(l3.stream().mapToDouble(LineDataDto::getV18).average().orElse(0d));
rDimVoltageD.setV29(list7.stream().mapToDouble(LineDataDto::getV29).average().orElse(0d)); result.setV19(l3.stream().mapToDouble(LineDataDto::getV19).average().orElse(0d));
rDimVoltageD.setV30(list7.stream().mapToDouble(LineDataDto::getV30).average().orElse(0d)); result.setV20(l3.stream().mapToDouble(LineDataDto::getV20).average().orElse(0d));
rDimVoltageD.setV31(list7.stream().mapToDouble(LineDataDto::getV31).average().orElse(0d)); result.setV21(l3.stream().mapToDouble(LineDataDto::getV21).average().orElse(0d));
rDimVoltageD.setV32(list7.stream().mapToDouble(LineDataDto::getV32).average().orElse(0d)); result.setV22(l3.stream().mapToDouble(LineDataDto::getV22).average().orElse(0d));
rDimVoltageD.setV33(list7.stream().mapToDouble(LineDataDto::getV33).average().orElse(0d)); result.setV23(l3.stream().mapToDouble(LineDataDto::getV23).average().orElse(0d));
rDimVoltageD.setV34(list7.stream().mapToDouble(LineDataDto::getV34).average().orElse(0d)); result.setV24(l3.stream().mapToDouble(LineDataDto::getV24).average().orElse(0d));
rDimVoltageD.setV35(list7.stream().mapToDouble(LineDataDto::getV35).average().orElse(0d)); result.setV25(l3.stream().mapToDouble(LineDataDto::getV25).average().orElse(0d));
rDimVoltageD.setV36(list7.stream().mapToDouble(LineDataDto::getV36).average().orElse(0d)); result.setV26(l3.stream().mapToDouble(LineDataDto::getV26).average().orElse(0d));
rDimVoltageD.setV37(list7.stream().mapToDouble(LineDataDto::getV37).average().orElse(0d)); result.setV27(l3.stream().mapToDouble(LineDataDto::getV27).average().orElse(0d));
rDimVoltageD.setV38(list7.stream().mapToDouble(LineDataDto::getV38).average().orElse(0d)); result.setV28(l3.stream().mapToDouble(LineDataDto::getV28).average().orElse(0d));
rDimVoltageD.setV39(list7.stream().mapToDouble(LineDataDto::getV39).average().orElse(0d)); result.setV29(l3.stream().mapToDouble(LineDataDto::getV29).average().orElse(0d));
rDimVoltageD.setV40(list7.stream().mapToDouble(LineDataDto::getV40).average().orElse(0d)); result.setV30(l3.stream().mapToDouble(LineDataDto::getV30).average().orElse(0d));
rDimVoltageD.setV41(list7.stream().mapToDouble(LineDataDto::getV41).average().orElse(0d)); result.setV31(l3.stream().mapToDouble(LineDataDto::getV31).average().orElse(0d));
rDimVoltageD.setV42(list7.stream().mapToDouble(LineDataDto::getV42).average().orElse(0d)); result.setV32(l3.stream().mapToDouble(LineDataDto::getV32).average().orElse(0d));
rDimVoltageD.setV43(list7.stream().mapToDouble(LineDataDto::getV43).average().orElse(0d)); result.setV33(l3.stream().mapToDouble(LineDataDto::getV33).average().orElse(0d));
rDimVoltageD.setV44(list7.stream().mapToDouble(LineDataDto::getV44).average().orElse(0d)); result.setV34(l3.stream().mapToDouble(LineDataDto::getV34).average().orElse(0d));
rDimVoltageD.setV45(list7.stream().mapToDouble(LineDataDto::getV45).average().orElse(0d)); result.setV35(l3.stream().mapToDouble(LineDataDto::getV35).average().orElse(0d));
rDimVoltageD.setV46(list7.stream().mapToDouble(LineDataDto::getV46).average().orElse(0d)); result.setV36(l3.stream().mapToDouble(LineDataDto::getV36).average().orElse(0d));
rDimVoltageD.setV47(list7.stream().mapToDouble(LineDataDto::getV47).average().orElse(0d)); result.setV37(l3.stream().mapToDouble(LineDataDto::getV37).average().orElse(0d));
rDimVoltageD.setV48(list7.stream().mapToDouble(LineDataDto::getV48).average().orElse(0d)); result.setV38(l3.stream().mapToDouble(LineDataDto::getV38).average().orElse(0d));
rDimVoltageD.setV49(list7.stream().mapToDouble(LineDataDto::getV49).average().orElse(0d)); result.setV39(l3.stream().mapToDouble(LineDataDto::getV39).average().orElse(0d));
rDimVoltageD.setV50(list7.stream().mapToDouble(LineDataDto::getV50).average().orElse(0d)); result.setV40(l3.stream().mapToDouble(LineDataDto::getV40).average().orElse(0d));
result.setV41(l3.stream().mapToDouble(LineDataDto::getV41).average().orElse(0d));
result.setV42(l3.stream().mapToDouble(LineDataDto::getV42).average().orElse(0d));
result.setV43(l3.stream().mapToDouble(LineDataDto::getV43).average().orElse(0d));
result.setV44(l3.stream().mapToDouble(LineDataDto::getV44).average().orElse(0d));
result.setV45(l3.stream().mapToDouble(LineDataDto::getV45).average().orElse(0d));
result.setV46(l3.stream().mapToDouble(LineDataDto::getV46).average().orElse(0d));
result.setV47(l3.stream().mapToDouble(LineDataDto::getV47).average().orElse(0d));
result.setV48(l3.stream().mapToDouble(LineDataDto::getV48).average().orElse(0d));
result.setV49(l3.stream().mapToDouble(LineDataDto::getV49).average().orElse(0d));
result.setV50(l3.stream().mapToDouble(LineDataDto::getV50).average().orElse(0d));
result.setINeg(l3.stream().mapToDouble(LineDataDto::getINeg).average().orElse(0d));
}
return result;
} }
} }

View File

@@ -143,6 +143,7 @@ public class RDimVoltageMServiceImpl extends MppServiceImpl<RDimVoltageMMapper,
rDimVoltageM.setV48(list.stream().mapToDouble(RDimVoltageD::getV48).average().orElse(0d)); rDimVoltageM.setV48(list.stream().mapToDouble(RDimVoltageD::getV48).average().orElse(0d));
rDimVoltageM.setV49(list.stream().mapToDouble(RDimVoltageD::getV49).average().orElse(0d)); rDimVoltageM.setV49(list.stream().mapToDouble(RDimVoltageD::getV49).average().orElse(0d));
rDimVoltageM.setV50(list.stream().mapToDouble(RDimVoltageD::getV50).average().orElse(0d)); rDimVoltageM.setV50(list.stream().mapToDouble(RDimVoltageD::getV50).average().orElse(0d));
rDimVoltageM.setINeg(list.stream().mapToDouble(RDimVoltageD::getINeg).average().orElse(0d));
return rDimVoltageM; return rDimVoltageM;
} }
@@ -151,7 +152,7 @@ public class RDimVoltageMServiceImpl extends MppServiceImpl<RDimVoltageMMapper,
* @param list 数据集合 * @param list 数据集合
*/ */
public RDimVoltageM getSd(List<RDimVoltageD> list, String orgId, LocalDate time, String voltageLevel,RDimVoltageM rDimVoltageM) { public RDimVoltageM getSd(List<RDimVoltageD> list, String orgId, LocalDate time, String voltageLevel,RDimVoltageM rDimVoltageM) {
double limit = 3.1415926000000005; double limit = 3.1415926;
RDimVoltageM rDimVoltageM1 = new RDimVoltageM(); RDimVoltageM rDimVoltageM1 = new RDimVoltageM();
rDimVoltageM1.setOrgId(orgId); rDimVoltageM1.setOrgId(orgId);
rDimVoltageM1.setStatisDate(time); rDimVoltageM1.setStatisDate(time);
@@ -211,6 +212,7 @@ public class RDimVoltageMServiceImpl extends MppServiceImpl<RDimVoltageMMapper,
rDimVoltageM1.setV48(rDimVoltageM.getV48() == limit ? limit : calculateStandardDeviation(list.stream().map(RDimVoltageD::getV48).collect(Collectors.toList()),rDimVoltageM.getV48())); rDimVoltageM1.setV48(rDimVoltageM.getV48() == limit ? limit : calculateStandardDeviation(list.stream().map(RDimVoltageD::getV48).collect(Collectors.toList()),rDimVoltageM.getV48()));
rDimVoltageM1.setV49(rDimVoltageM.getV49() == limit ? limit : calculateStandardDeviation(list.stream().map(RDimVoltageD::getV49).collect(Collectors.toList()),rDimVoltageM.getV49())); rDimVoltageM1.setV49(rDimVoltageM.getV49() == limit ? limit : calculateStandardDeviation(list.stream().map(RDimVoltageD::getV49).collect(Collectors.toList()),rDimVoltageM.getV49()));
rDimVoltageM1.setV50(rDimVoltageM.getV50() == limit ? limit : calculateStandardDeviation(list.stream().map(RDimVoltageD::getV50).collect(Collectors.toList()),rDimVoltageM.getV50())); rDimVoltageM1.setV50(rDimVoltageM.getV50() == limit ? limit : calculateStandardDeviation(list.stream().map(RDimVoltageD::getV50).collect(Collectors.toList()),rDimVoltageM.getV50()));
rDimVoltageM1.setINeg(rDimVoltageM.getINeg() == limit ? limit : calculateStandardDeviation(list.stream().map(RDimVoltageD::getINeg).collect(Collectors.toList()),rDimVoltageM.getINeg()));
return rDimVoltageM1; return rDimVoltageM1;
} }

View File

@@ -142,6 +142,7 @@ public class RDimVoltageYServiceImpl extends MppServiceImpl<RDimVoltageYMapper,
rDimVoltageY.setV48(list.stream().mapToDouble(RDimVoltageD::getV48).average().orElse(0d)); rDimVoltageY.setV48(list.stream().mapToDouble(RDimVoltageD::getV48).average().orElse(0d));
rDimVoltageY.setV49(list.stream().mapToDouble(RDimVoltageD::getV49).average().orElse(0d)); rDimVoltageY.setV49(list.stream().mapToDouble(RDimVoltageD::getV49).average().orElse(0d));
rDimVoltageY.setV50(list.stream().mapToDouble(RDimVoltageD::getV50).average().orElse(0d)); rDimVoltageY.setV50(list.stream().mapToDouble(RDimVoltageD::getV50).average().orElse(0d));
rDimVoltageY.setINeg(list.stream().mapToDouble(RDimVoltageD::getINeg).average().orElse(0d));
return rDimVoltageY; return rDimVoltageY;
} }
@@ -150,7 +151,7 @@ public class RDimVoltageYServiceImpl extends MppServiceImpl<RDimVoltageYMapper,
* @param list 数据集合 * @param list 数据集合
*/ */
public RDimVoltageY getSd(List<RDimVoltageD> list, String orgId, LocalDate time, String voltageLevel,RDimVoltageY rDimVoltageY) { public RDimVoltageY getSd(List<RDimVoltageD> list, String orgId, LocalDate time, String voltageLevel,RDimVoltageY rDimVoltageY) {
double limit = 3.1415926000000005; double limit = 3.1415926;
RDimVoltageY rDimVoltageY1 = new RDimVoltageY(); RDimVoltageY rDimVoltageY1 = new RDimVoltageY();
rDimVoltageY1.setOrgId(orgId); rDimVoltageY1.setOrgId(orgId);
rDimVoltageY1.setStatisDate(time); rDimVoltageY1.setStatisDate(time);
@@ -210,6 +211,7 @@ public class RDimVoltageYServiceImpl extends MppServiceImpl<RDimVoltageYMapper,
rDimVoltageY1.setV48(rDimVoltageY.getV48() == limit ? limit : calculateStandardDeviation(list.stream().map(RDimVoltageD::getV48).collect(Collectors.toList()),rDimVoltageY.getV48())); rDimVoltageY1.setV48(rDimVoltageY.getV48() == limit ? limit : calculateStandardDeviation(list.stream().map(RDimVoltageD::getV48).collect(Collectors.toList()),rDimVoltageY.getV48()));
rDimVoltageY1.setV49(rDimVoltageY.getV49() == limit ? limit : calculateStandardDeviation(list.stream().map(RDimVoltageD::getV49).collect(Collectors.toList()),rDimVoltageY.getV49())); rDimVoltageY1.setV49(rDimVoltageY.getV49() == limit ? limit : calculateStandardDeviation(list.stream().map(RDimVoltageD::getV49).collect(Collectors.toList()),rDimVoltageY.getV49()));
rDimVoltageY1.setV50(rDimVoltageY.getV50() == limit ? limit : calculateStandardDeviation(list.stream().map(RDimVoltageD::getV50).collect(Collectors.toList()),rDimVoltageY.getV50())); rDimVoltageY1.setV50(rDimVoltageY.getV50() == limit ? limit : calculateStandardDeviation(list.stream().map(RDimVoltageD::getV50).collect(Collectors.toList()),rDimVoltageY.getV50()));
rDimVoltageY1.setINeg(rDimVoltageY.getINeg() == limit ? limit : calculateStandardDeviation(list.stream().map(RDimVoltageD::getINeg).collect(Collectors.toList()),rDimVoltageY.getINeg()));
return rDimVoltageY1; return rDimVoltageY1;
} }

View File

@@ -0,0 +1,24 @@
package com.njcn.prepare.harmonic.service.mysql.upload;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO;
import com.njcn.harmonic.pojo.po.upload.RUploadEvaluationDataD;
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
/**
* <p>
* 电能质量基准水平评估数据-日表 服务类
* </p>
*
* @author xuyang
* @since 2023-12-12
*/
public interface IRUploadEvaluationDataDService extends IService<RUploadEvaluationDataD> {
/**
* 电能质量基准水平评估数据-日表
* @param calculatedParam
*/
void insertEvaluationDataDay(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam);
}

View File

@@ -0,0 +1,335 @@
package com.njcn.prepare.harmonic.service.mysql.upload.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.dto.DeptGetBase;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO;
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
import com.njcn.device.pms.pojo.po.GeneratrixWire;
import com.njcn.device.pms.pojo.po.Monitor;
import com.njcn.harmonic.pojo.po.dim.RDimVoltageD;
import com.njcn.harmonic.pojo.po.upload.RUploadEvaluationDataD;
import com.njcn.prepare.harmonic.enums.UploadEnum;
import com.njcn.prepare.harmonic.mapper.mysql.dim.GeneratrixWireMapper;
import com.njcn.prepare.harmonic.mapper.mysql.dim.RDimVoltageDMapper;
import com.njcn.prepare.harmonic.mapper.mysql.line.PmsMonitorMapper;
import com.njcn.prepare.harmonic.mapper.mysql.upload.RUploadEvaluationDataDMapper;
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
import com.njcn.prepare.harmonic.pojo.dto.BusBarDto;
import com.njcn.prepare.harmonic.service.mysql.upload.IRUploadEvaluationDataDService;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.po.Dept;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 电能质量基准水平评估数据-日表 服务实现类
* </p>
*
* @author xuyang
* @since 2023-12-12
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEvaluationDataDMapper, RUploadEvaluationDataD> implements IRUploadEvaluationDataDService {
private final RDimVoltageDMapper rDimVoltageDMapper;
private final DeptFeignClient deptFeignClient;
private final PmsMonitorMapper pmsMonitorMapper;
private final GeneratrixWireMapper generatrixWireMapper;
private final DicDataFeignClient dicDataFeignClient;
private final CommTerminalGeneralClient commTerminalGeneralClient;
@Override
public void insertEvaluationDataDay(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam) {
List<RUploadEvaluationDataD> result = new ArrayList<>();
//获取监测点信息
List<Monitor> list1 = getPmsMonitor();
//获取母线信息
List<GeneratrixWire> list2 = getBusBarInfo();
//获取【在运】字典id
List<DictData> dicDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.LINE_STATE.getCode()).getData();
DictData dictData = dicDataList.stream().filter(o->Objects.equals(o.getCode(), DicDataEnum.RUN.getCode())).findFirst().orElse(null);
//获取单位下各电压等级数据
List<BusBarDto> busBarList = getBusBarNum(list1,list2,dictData.getId());
List<BusBarDto> allDept = getAllDeptLineNum(busBarList);
//获取省级单位id
Dept data = deptFeignClient.getRootDept().getData();
String provinceId = deptFeignClient.getDepSonIdByDeptId(data.getId()).getData().get(0);
Dept dept = deptFeignClient.getDeptById(provinceId).getData();
//获取所有单位
List<Dept> deptList = deptFeignClient.getAllDept().getData();
Map<String,List<Dept>> deptMap = deptList.stream().collect(Collectors.groupingBy(Dept::getCode));
List<DeptGetChildrenMoreDTO> list = calculatedParam.getIdList();
//获取母线相关数据
Map<String,List<RDimVoltageD>> dimMap = getDimVoltageData(calculatedParam.getDataDate());
//数据处理
list.forEach(item->{
if (Objects.equals(Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_1.getCode()),item.getDeptLevel())){
return;
}
List<RDimVoltageD> l1 = dimMap.get(item.getUnitId());
if (CollectionUtil.isNotEmpty(l1)){
l1.forEach(item2->{
RUploadEvaluationDataD dto = getLineNum(allDept,item2.getVoltageType(),item.getUnitId());
if (dto.getMonitorBusNum() !=0 ){
RUploadEvaluationDataD rUploadEvaluationDataD = new RUploadEvaluationDataD();
rUploadEvaluationDataD.setId(IdUtil.simpleUUID());
rUploadEvaluationDataD.setProvinceId(dept.getCode());
rUploadEvaluationDataD.setProvinceName(dept.getName());
rUploadEvaluationDataD.setDataSources(UploadEnum.DATA_SOURCES_01.getCode());
rUploadEvaluationDataD.setStatisticalDate(calculatedParam.getDataDate());
rUploadEvaluationDataD.setStatisticalType(UploadEnum.STATISTICAL_TYPE_03.getCode());
judgeLevel(item.getDeptLevel(),rUploadEvaluationDataD,item.getUnitId(),item.getUnitName(),deptList,deptMap);
//电压
RUploadEvaluationDataD dto1 = channelData(rUploadEvaluationDataD,item2.getV(),UploadEnum.INDEX_TYPE_01.getCode(),0,item2.getVoltageType(),dto);
result.add(dto1);
//长时间闪变
RUploadEvaluationDataD dto2 = channelData(rUploadEvaluationDataD,item2.getPst(),UploadEnum.INDEX_TYPE_02.getCode(),0,item2.getVoltageType(),dto);
result.add(dto2);
//三相电压不平衡
RUploadEvaluationDataD dto3 = channelData(rUploadEvaluationDataD,item2.getVUnbalance(),UploadEnum.INDEX_TYPE_03.getCode(),0,item2.getVoltageType(),dto);
result.add(dto3);
//电压总谐波畸变率
RUploadEvaluationDataD dto4 = channelData(rUploadEvaluationDataD,item2.getVThd(),UploadEnum.INDEX_TYPE_04.getCode(),0,item2.getVoltageType(),dto);
result.add(dto4);
//各次谐波电压
List<Double> harmonic = Arrays.asList(item2.getV2(),item2.getV3(),item2.getV4(),item2.getV5()
,item2.getV6(),item2.getV7(),item2.getV8(),item2.getV9(),item2.getV10(),item2.getV11()
,item2.getV12(),item2.getV13(),item2.getV14(),item2.getV15(),item2.getV16(),item2.getV17()
,item2.getV18(),item2.getV19(),item2.getV20(),item2.getV21(),item2.getV22(),item2.getV23()
,item2.getV24(),item2.getV25(),item2.getV26(),item2.getV27(),item2.getV28(),item2.getV29()
,item2.getV30(),item2.getV31(),item2.getV32(),item2.getV33(),item2.getV34(),item2.getV35()
,item2.getV36(),item2.getV37(),item2.getV38(),item2.getV39(),item2.getV40(),item2.getV41()
,item2.getV42(),item2.getV43(),item2.getV44(),item2.getV45(),item2.getV46(),item2.getV47()
,item2.getV48(),item2.getV49(),item2.getV50());
channelHarmonicData(rUploadEvaluationDataD,result,harmonic,UploadEnum.INDEX_TYPE_05.getCode(),item2.getVoltageType(),dto);
//负序电流
RUploadEvaluationDataD dto6 = channelData(rUploadEvaluationDataD,item2.getINeg(),UploadEnum.INDEX_TYPE_06.getCode(),0,item2.getVoltageType(),dto);
result.add(dto6);
}
});
}
});
if (CollectionUtil.isNotEmpty(result)){
this.saveOrUpdateBatchByMultiId(result,1000);
}
}
/**
* 获取区域母线不同电压等级指标数据日表
*/
public Map<String,List<RDimVoltageD>> getDimVoltageData(String time) {
Map<String,List<RDimVoltageD>> map = new HashMap<>();
LambdaQueryWrapper<RDimVoltageD> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(RDimVoltageD::getStatisDate,time);
List<RDimVoltageD> list = rDimVoltageDMapper.selectList(lambdaQueryWrapper);
if (CollectionUtil.isNotEmpty(list)){
map = list.stream().collect(Collectors.groupingBy(RDimVoltageD::getOrgId));
}
return map;
}
/**
* 获取监测点信息
*/
public List<Monitor> getPmsMonitor() {
LambdaQueryWrapper<Monitor> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(Monitor::getStatus, DataStateEnum.ENABLE.getCode());
return pmsMonitorMapper.selectList(lambdaQueryWrapper);
}
/**
* 获取母线信息
*/
public List<GeneratrixWire> getBusBarInfo() {
LambdaQueryWrapper<GeneratrixWire> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(GeneratrixWire::getStatus, DataStateEnum.ENABLE.getCode());
return generatrixWireMapper.selectList(lambdaQueryWrapper);
}
/**
* 获取已知单位母线数量
*/
public List<BusBarDto> getBusBarNum(List<Monitor> list1, List<GeneratrixWire> list2, String code) {
List<BusBarDto> result = new ArrayList<>();
Map<String, List<Monitor>> map = list1.stream().collect(Collectors.groupingBy(Monitor::getOrgId));
map.forEach((k,v)->{
List<BusBarDto.VoltageChild> children = new ArrayList<>();
BusBarDto busBarDto = new BusBarDto();
busBarDto.setOrgId(k);
//所有母线集合
List<String> allLine = v.stream().map(Monitor::getLineId).collect(Collectors.toList());
//在运母线集合
List<String> online = v.stream().filter(o->Objects.equals(o.getMonitorState(),code)).map(Monitor::getLineId).collect(Collectors.toList());
List<GeneratrixWire> list3 = list2.stream().filter(o->allLine.contains(o.getId())).collect(Collectors.toList());
Map<String, List<GeneratrixWire>> map2 = list3.stream().collect(Collectors.groupingBy(GeneratrixWire::getScale));
map2.forEach((k1,v1)->{
BusBarDto.VoltageChild voltageChild = new BusBarDto.VoltageChild();
voltageChild.setVoltageLevel(getVoltage(k1));
voltageChild.setMonitorBusNum(v1.size());
List<GeneratrixWire> list4 = v1.stream().filter(o->online.contains(o.getId())).collect(Collectors.toList());
voltageChild.setOnlineBusNum(list4.size());
voltageChild.setMonitorRate(list4.size()*100.0/v1.size());
children.add(voltageChild);
});
busBarDto.setVoltageChild(children);
result.add(busBarDto);
});
return result;
}
/**
* 组装所有单位下各个电压等级的母线数量
*/
public List<BusBarDto> getAllDeptLineNum(List<BusBarDto> list) {
List<BusBarDto> result = new ArrayList<>();
//获取所有部门信息
Dept data = deptFeignClient.getRootDept().getData();
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
deptGetLineParam.setDeptId(data.getId());
List<DeptGetBase> deptList = commTerminalGeneralClient.getDeptChildrenByParent(deptGetLineParam).getData();
deptList.forEach(item->{
List<BusBarDto.VoltageChild> children = new ArrayList<>();
List<BusBarDto.VoltageChild> child = new ArrayList<>();
BusBarDto busBarDto = new BusBarDto();
busBarDto.setOrgId(item.getUnitId());
//获取当前部门下 包含母线数量的部门
List<BusBarDto> newList = list.stream().filter(o->item.getUnitChildrenList().contains(o.getOrgId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(newList)){
newList.forEach(item2->{
child.addAll(item2.getVoltageChild());
});
Map<String,List<BusBarDto.VoltageChild>> map = child.stream().collect(Collectors.groupingBy(BusBarDto.VoltageChild::getVoltageLevel));
map.forEach((k,v)->{
BusBarDto.VoltageChild c1 = new BusBarDto.VoltageChild();
c1.setVoltageLevel(k);
int monitorBusNum = v.stream().mapToInt(BusBarDto.VoltageChild::getMonitorBusNum).sum();
c1.setMonitorBusNum(monitorBusNum);
int online = v.stream().mapToInt(BusBarDto.VoltageChild::getOnlineBusNum).sum();
c1.setOnlineBusNum(online);
c1.setMonitorRate(monitorBusNum==0?0:online*100.0/monitorBusNum);
children.add(c1);
});
busBarDto.setVoltageChild(children);
}
result.add(busBarDto);
});
return result;
}
/**
* 生成母线数量
*/
public RUploadEvaluationDataD getLineNum(List<BusBarDto> allDept, String voltage, String deptId) {
RUploadEvaluationDataD dto = new RUploadEvaluationDataD();
BusBarDto dto2 = allDept.stream().filter(o->Objects.equals(o.getOrgId(),deptId)).findFirst().orElse(null);
if (!Objects.isNull(dto2)){
List<BusBarDto.VoltageChild> list = dto2.getVoltageChild();
if (CollectionUtil.isNotEmpty(list)){
list.forEach(item->{
if (Objects.equals(item.getVoltageLevel(),this.getVoltage(voltage))){
dto.setMonitorBusNum(item.getMonitorBusNum());
dto.setOnlineBusNum(item.getOnlineBusNum());
dto.setMonitorBusRate(item.getMonitorRate());
}
});
}
}
return dto;
}
/**
* 判断单位层级
*/
public void judgeLevel(Integer level, RUploadEvaluationDataD rUploadEvaluationDataD, String id, String name, List<Dept> deptList, Map<String,List<Dept>> map) {
String result = "";
if (Objects.equals(level,Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_2.getCode()))){
result = UploadEnum.STATISTICAL_LEVEL_3.getCode();
rUploadEvaluationDataD.setCityId("");
rUploadEvaluationDataD.setCountyId("");
} else if (Objects.equals(level,Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_3.getCode()))) {
result = UploadEnum.STATISTICAL_LEVEL_4.getCode();
rUploadEvaluationDataD.setCityId(id);
rUploadEvaluationDataD.setCityName(name);
rUploadEvaluationDataD.setCountyId("");
} else if (Objects.equals(level,Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_4.getCode()))) {
result = UploadEnum.STATISTICAL_LEVEL_5.getCode();
List<String> list = Arrays.stream(map.get(id).get(0).getPids().split(",")).map(String::trim).collect(Collectors.toList());
String parentCode = deptList.stream().filter(o->Objects.equals(o.getId(),list.get(3))).findFirst().orElse(null).getCode();
rUploadEvaluationDataD.setCityId(parentCode);
rUploadEvaluationDataD.setCityName(map.get(parentCode).get(0).getName());
rUploadEvaluationDataD.setCountyId(id);
rUploadEvaluationDataD.setCountyName(name);
}
rUploadEvaluationDataD.setStatisticalLevel(result);
}
/**
* 单个指标数据处理
*/
public RUploadEvaluationDataD channelData(RUploadEvaluationDataD rUploadEvaluationDataD,Double value, String indexType, Integer harmonicNum, String voltage,RUploadEvaluationDataD rUploadEvaluationDataD2) {
RUploadEvaluationDataD dto = new RUploadEvaluationDataD();
BeanUtils.copyProperties(rUploadEvaluationDataD,dto);
dto.setAvgValue(value);
dto.setIndexType(indexType);
dto.setHarmonicNum(harmonicNum);
dto.setStandardDeviation(value==3.1415926?3.1415926:0d);
dto.setVoltageLevel(this.getVoltage(voltage));
dto.setMonitorBusNum(rUploadEvaluationDataD2.getMonitorBusNum());
dto.setOnlineBusNum(rUploadEvaluationDataD2.getOnlineBusNum());
dto.setMonitorBusRate(rUploadEvaluationDataD2.getMonitorBusRate());
return dto;
}
/**
* 各次谐波电压数据处理
*/
public void channelHarmonicData(RUploadEvaluationDataD rUploadEvaluationDataD,List<RUploadEvaluationDataD> result,List<Double> valueList, String indexType, String voltage,RUploadEvaluationDataD rUploadEvaluationDataD2) {
for (int i = 0; i < valueList.size(); i++) {
RUploadEvaluationDataD dto = new RUploadEvaluationDataD();
BeanUtils.copyProperties(rUploadEvaluationDataD,dto);
dto.setAvgValue(valueList.get(i));
dto.setIndexType(indexType);
dto.setHarmonicNum(i+2);
dto.setStandardDeviation(valueList.get(i)==3.1415926?3.1415926:0d);
dto.setVoltageLevel(this.getVoltage(voltage));
dto.setMonitorBusNum(rUploadEvaluationDataD2.getMonitorBusNum());
dto.setOnlineBusNum(rUploadEvaluationDataD2.getOnlineBusNum());
dto.setMonitorBusRate(rUploadEvaluationDataD2.getMonitorBusRate());
result.add(dto);
}
}
/**
* 电压等级转换
*/
public String getVoltage(String voltage) {
DictData dictData = dicDataFeignClient.getDicDataById(voltage).getData();
Integer code = dictData.getAlgoDescribe();
if (Objects.isNull(code)){
return "99";
}
return (code < 10) ? "0" + code : String.valueOf(code);
}
}