测试文档bug调整
This commit is contained in:
@@ -0,0 +1,207 @@
|
||||
package com.njcn.prepare.harmonic.pojo.bo.excel;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Data
|
||||
public class DataVDetail implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* 供电公司名称
|
||||
*/
|
||||
@Excel(name = "时间", width = 30)
|
||||
private String time;
|
||||
|
||||
/**
|
||||
* 所属变电站
|
||||
*/
|
||||
@Excel(name = "变电站", width = 30)
|
||||
private String subStationName;
|
||||
|
||||
/**
|
||||
* 终端名称
|
||||
*/
|
||||
@Excel(name = "终端名称", width = 30)
|
||||
private String devName;
|
||||
|
||||
/**
|
||||
* 监测点索引
|
||||
*/
|
||||
private String lineId;
|
||||
|
||||
/**
|
||||
* 监测点名称
|
||||
*/
|
||||
@Excel(name = "监测点名称", width = 30)
|
||||
private String lineName;
|
||||
|
||||
/**
|
||||
* 相别
|
||||
*/
|
||||
@Excel(name = "相别", width = 30)
|
||||
private String phaseType;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* 监测点电压等级
|
||||
*/
|
||||
@Excel(name = "监测点电压等级", width = 30)
|
||||
private String lineVoltage;
|
||||
|
||||
@Excel(name = "电压总谐波畸变率", width = 10)
|
||||
private Double vThd;
|
||||
|
||||
@Excel(name = "2次谐波电压含有率", width = 10)
|
||||
private Double v2;
|
||||
|
||||
@Excel(name = "3次谐波电压含有率", width = 10)
|
||||
private Double v3;
|
||||
|
||||
@Excel(name = "4次谐波电压含有率", width = 10)
|
||||
private Double v4;
|
||||
|
||||
@Excel(name = "5次谐波电压含有率", width = 10)
|
||||
private Double v5;
|
||||
|
||||
@Excel(name = "6次谐波电压含有率", width = 10)
|
||||
private Double v6;
|
||||
|
||||
@Excel(name = "7次谐波电压含有率", width = 10)
|
||||
private Double v7;
|
||||
|
||||
@Excel(name = "8次谐波电压含有率", width = 10)
|
||||
private Double v8;
|
||||
|
||||
@Excel(name = "9次谐波电压含有率", width = 10)
|
||||
private Double v9;
|
||||
|
||||
@Excel(name = "10次谐波电压含有率", width = 10)
|
||||
private Double v10;
|
||||
|
||||
@Excel(name = "11次谐波电压含有率", width = 10)
|
||||
private Double v11;
|
||||
|
||||
@Excel(name = "12次谐波电压含有率", width = 10)
|
||||
private Double v12;
|
||||
|
||||
@Excel(name = "13次谐波电压含有率", width = 10)
|
||||
private Double v13;
|
||||
|
||||
@Excel(name = "14次谐波电压含有率", width = 10)
|
||||
private Double v14;
|
||||
|
||||
@Excel(name = "15次谐波电压含有率", width = 10)
|
||||
private Double v15;
|
||||
|
||||
@Excel(name = "16次谐波电压含有率", width = 10)
|
||||
private Double v16;
|
||||
|
||||
@Excel(name = "17次谐波电压含有率", width = 10)
|
||||
private Double v17;
|
||||
|
||||
@Excel(name = "18次谐波电压含有率", width = 10)
|
||||
private Double v18;
|
||||
|
||||
@Excel(name = "19次谐波电压含有率", width = 10)
|
||||
private Double v19;
|
||||
|
||||
@Excel(name = "20次谐波电压含有率", width = 10)
|
||||
private Double v20;
|
||||
|
||||
@Excel(name = "21次谐波电压含有率", width = 10)
|
||||
private Double v21;
|
||||
|
||||
@Excel(name = "22次谐波电压含有率", width = 10)
|
||||
private Double v22;
|
||||
|
||||
@Excel(name = "23次谐波电压含有率", width = 10)
|
||||
private Double v23;
|
||||
|
||||
@Excel(name = "24次谐波电压含有率", width = 10)
|
||||
private Double v24;
|
||||
|
||||
@Excel(name = "25次谐波电压含有率", width = 10)
|
||||
private Double v25;
|
||||
|
||||
@Excel(name = "26次谐波电压含有率", width = 10)
|
||||
private Double v26;
|
||||
|
||||
@Excel(name = "27次谐波电压含有率", width = 10)
|
||||
private Double v27;
|
||||
|
||||
@Excel(name = "28次谐波电压含有率", width = 10)
|
||||
private Double v28;
|
||||
|
||||
@Excel(name = "29次谐波电压含有率", width = 10)
|
||||
private Double v29;
|
||||
|
||||
@Excel(name = "30次谐波电压含有率", width = 10)
|
||||
private Double v30;
|
||||
|
||||
@Excel(name = "31次谐波电压含有率", width = 10)
|
||||
private Double v31;
|
||||
|
||||
@Excel(name = "32次谐波电压含有率", width = 10)
|
||||
private Double v32;
|
||||
|
||||
@Excel(name = "33次谐波电压含有率", width = 10)
|
||||
private Double v33;
|
||||
|
||||
@Excel(name = "34次谐波电压含有率", width = 10)
|
||||
private Double v34;
|
||||
|
||||
@Excel(name = "35次谐波电压含有率", width = 10)
|
||||
private Double v35;
|
||||
|
||||
@Excel(name = "36次谐波电压含有率", width = 10)
|
||||
private Double v36;
|
||||
|
||||
@Excel(name = "37次谐波电压含有率", width = 10)
|
||||
private Double v37;
|
||||
|
||||
@Excel(name = "38次谐波电压含有率", width = 10)
|
||||
private Double v38;
|
||||
|
||||
@Excel(name = "39次谐波电压含有率", width = 10)
|
||||
private Double v39;
|
||||
|
||||
@Excel(name = "40次谐波电压含有率", width = 10)
|
||||
private Double v40;
|
||||
|
||||
@Excel(name = "41次谐波电压含有率", width = 10)
|
||||
private Double v41;
|
||||
|
||||
@Excel(name = "42次谐波电压含有率", width = 10)
|
||||
private Double v42;
|
||||
|
||||
@Excel(name = "43次谐波电压含有率", width = 10)
|
||||
private Double v43;
|
||||
|
||||
@Excel(name = "44次谐波电压含有率", width = 10)
|
||||
private Double v44;
|
||||
|
||||
@Excel(name = "45次谐波电压含有率", width = 10)
|
||||
private Double v45;
|
||||
|
||||
@Excel(name = "46次谐波电压含有率", width = 10)
|
||||
private Double v46;
|
||||
|
||||
@Excel(name = "47次谐波电压含有率", width = 10)
|
||||
private Double v47;
|
||||
|
||||
@Excel(name = "48次谐波电压含有率", width = 10)
|
||||
private Double v48;
|
||||
|
||||
@Excel(name = "49次谐波电压含有率", width = 10)
|
||||
private Double v49;
|
||||
|
||||
@Excel(name = "50次谐波电压含有率", width = 10)
|
||||
private Double v50;
|
||||
|
||||
}
|
||||
@@ -277,7 +277,6 @@ public class MeasurementExecutor extends BaseExecutor {
|
||||
|
||||
@LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "dataHarmPowerP", nodeType = NodeTypeEnum.COMMON)
|
||||
public boolean dataToDayAccess7(NodeComponent bindCmp) {return isAccess(bindCmp);}
|
||||
|
||||
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "dataHarmPowerP", nodeType = NodeTypeEnum.COMMON)
|
||||
public void dataToDayProcess7(NodeComponent bindCmp) {dayDataService.dataHarmPowerPHardler(bindCmp.getRequestData());}
|
||||
|
||||
|
||||
@@ -3,4 +3,9 @@ package com.njcn.prepare.harmonic.service.influxdb;
|
||||
public interface IPollutionCalc {
|
||||
|
||||
void calcAllLineValue();
|
||||
|
||||
//按监测点获取各地市谐波电压原始数据
|
||||
void getDataVByLineId();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.time.Instant;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -299,6 +301,55 @@ public class PollutionCalcImpl implements IPollutionCalc {
|
||||
System.out.println("程序执行完毕,总耗时:" + time + "秒");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDataVByLineId() {
|
||||
List<DataVDetail> linePollutionList = new ArrayList<>();
|
||||
String yesterdayDate = "2025-03-10";
|
||||
String beginDay = "2025-02-10 00:00:00";
|
||||
String endDay = "2025-03-10 23:59:59";
|
||||
List<String> lineIdList = Arrays.asList("123","456","789");
|
||||
List<PollutionLineInfoDTO> lineInfoDTOList = commLineClient.getPollutionLineInfo(lineIdList).getData();
|
||||
if (CollUtil.isNotEmpty(lineIdList)) {
|
||||
// 获取谐波电压数据 电压总谐波畸变率 + 2—50次谐波电压含有率
|
||||
for (int i = 0; i < lineIdList.size(); i++) {
|
||||
String lineId = lineIdList.get(i);
|
||||
DataVDetail linePollution = new DataVDetail();
|
||||
linePollution.setLineId(lineId);
|
||||
//获取监测点限值
|
||||
//Overlimit overlimit = commTerminalGeneralClient.getOverLimitData(lineId).getData();
|
||||
LineDevGetDTO lineDetailData = commTerminalGeneralClient.getMonitorDetail(lineId).getData();
|
||||
linePollution.setLineName(lineDetailData.getPointName());
|
||||
//获取该监测点其他元信息
|
||||
Optional<PollutionLineInfoDTO> any = lineInfoDTOList.stream().filter(item -> item.getLineId().equals(lineId)).findAny();
|
||||
if (any.isPresent()) {
|
||||
PollutionLineInfoDTO data = any.get();
|
||||
BeanUtil.copyProperties(data, linePollution, true);
|
||||
}
|
||||
linePollutionList = getData(linePollution,beginDay,endDay);
|
||||
}
|
||||
}
|
||||
|
||||
List<DataVDetail> finalLinePollutionList = new ArrayList<>(linePollutionList);
|
||||
// 全部监测点计算完毕后按时间排序
|
||||
finalLinePollutionList.sort(Comparator.comparing(DataVDetail::getTime).thenComparing(DataVDetail::getPhaseType));
|
||||
Collections.reverse(finalLinePollutionList);
|
||||
|
||||
// 监测点的污染值计算完毕后,输出到指定目录。目前目录是写死的,待后期调整成配置可供用户选择下载。todo...
|
||||
// 导出监测点污染值
|
||||
String folder = "c:\\njcn";
|
||||
File file = new File(folder);
|
||||
if (!file.exists()) {
|
||||
boolean mkdirs = file.mkdirs();
|
||||
if (!mkdirs) {
|
||||
System.out.println("无法创建文件夹");
|
||||
return;
|
||||
}
|
||||
}
|
||||
String fileName = folder + "\\各地市谐波电压数据详情" + yesterdayDate + ".xlsx";
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportLinePollution(exportParams, LinePollution.class, finalLinePollutionList, fileName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 输出下载文件
|
||||
@@ -325,11 +376,122 @@ public class PollutionCalcImpl implements IPollutionCalc {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取规定时间内谐波电压数据
|
||||
* 谐波电压包含 电压总谐波畸变率 + 2~50次谐波电压含有率
|
||||
* @param linePollution 监测点信息
|
||||
*/
|
||||
private List<DataVDetail> getData(DataVDetail linePollution, String startTime, String endTime) {
|
||||
List<DataVDetail> linePollutionList = new ArrayList<>();
|
||||
|
||||
InfluxQueryWrapper dataVQueryWrapper = new InfluxQueryWrapper(DataV.class);
|
||||
dataVQueryWrapper.select(DataV::getVThd)
|
||||
.select(DataV::getPhaseType)
|
||||
.eq(DataV::getLineId, linePollution.getLineId())
|
||||
.eq(DataV::getValueType, InfluxDbSqlConstant.CP95)
|
||||
.ne(DataV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T)
|
||||
.between(DataV::getTime, startTime, endTime);
|
||||
List<DataV> vthResultList = dataVMapper.getStatisticsByWraper(dataVQueryWrapper);
|
||||
|
||||
InfluxQueryWrapper dataVQueryWrapper2 = new InfluxQueryWrapper(DataHarmRateV.class);
|
||||
dataVQueryWrapper2.samePrefixAndSuffix(InfluxDbSqlConstant.V, "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
dataVQueryWrapper2.eq(DataHarmRateV::getLineId, linePollution.getLineId())
|
||||
.eq(DataHarmRateV::getValueType, InfluxDbSqlConstant.CP95)
|
||||
.ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T)
|
||||
.between(DataHarmRateV::getTime, startTime, endTime);
|
||||
List<DataHarmRateV> vthResultList2 = dataHarmRateVMapper.getStatisticsByWraper(dataVQueryWrapper2);
|
||||
|
||||
if (CollUtil.isNotEmpty(vthResultList) && CollUtil.isNotEmpty(vthResultList2)) {
|
||||
Map<Instant,List<DataV>> map1 = vthResultList.stream().collect(Collectors.groupingBy(DataV::getTime));
|
||||
Map<Instant, Map<String, DataV>> map1ByPhase = map1.entrySet().stream()
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
entry -> entry.getValue().stream()
|
||||
.collect(Collectors.toMap(DataV::getPhaseType, dataV -> dataV))
|
||||
));
|
||||
Map<Instant,List<DataHarmRateV>> map2 = vthResultList2.stream().collect(Collectors.groupingBy(DataHarmRateV::getTime));
|
||||
Map<Instant, Map<String, DataHarmRateV>> map2ByPhase = map2.entrySet().stream()
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
entry -> entry.getValue().stream()
|
||||
.collect(Collectors.toMap(DataHarmRateV::getPhaseType, dataHarmRateV -> dataHarmRateV))
|
||||
));
|
||||
// 获取两个 Map 的时间交集
|
||||
Set<Instant> commonTimes = new HashSet<>(map1.keySet());
|
||||
commonTimes.retainAll(map2.keySet());
|
||||
for (Instant time : commonTimes) {
|
||||
Map<String, DataV> phaseData1 = map1ByPhase.get(time);
|
||||
Map<String, DataHarmRateV> phaseData2 = map2ByPhase.get(time);
|
||||
// 遍历 phaseData1 的所有 phaseType
|
||||
phaseData1.forEach((phaseType, dataV) -> {
|
||||
// 在 phaseData2 中查找匹配的 phaseType
|
||||
DataHarmRateV harmRateV = phaseData2.get(phaseType);
|
||||
if (harmRateV != null) {
|
||||
DataVDetail detail = new DataVDetail();
|
||||
BeanUtil.copyProperties(linePollution,detail);
|
||||
detail.setTime(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(time));
|
||||
detail.setPhaseType(phaseType); // 设置相别
|
||||
detail.setVThd(dataV.getVThd()); // 设置 DataV 的值
|
||||
detail.setV2(harmRateV.getV2());
|
||||
detail.setV3(harmRateV.getV3());
|
||||
detail.setV4(harmRateV.getV4());
|
||||
detail.setV5(harmRateV.getV5());
|
||||
detail.setV6(harmRateV.getV6());
|
||||
detail.setV7(harmRateV.getV7());
|
||||
detail.setV8(harmRateV.getV8());
|
||||
detail.setV9(harmRateV.getV9());
|
||||
detail.setV10(harmRateV.getV10());
|
||||
detail.setV11(harmRateV.getV11());
|
||||
detail.setV12(harmRateV.getV12());
|
||||
detail.setV13(harmRateV.getV13());
|
||||
detail.setV14(harmRateV.getV14());
|
||||
detail.setV15(harmRateV.getV15());
|
||||
detail.setV16(harmRateV.getV16());
|
||||
detail.setV17(harmRateV.getV17());
|
||||
detail.setV18(harmRateV.getV18());
|
||||
detail.setV19(harmRateV.getV19());
|
||||
detail.setV20(harmRateV.getV20());
|
||||
detail.setV21(harmRateV.getV21());
|
||||
detail.setV22(harmRateV.getV22());
|
||||
detail.setV23(harmRateV.getV23());
|
||||
detail.setV24(harmRateV.getV24());
|
||||
detail.setV25(harmRateV.getV25());
|
||||
detail.setV26(harmRateV.getV26());
|
||||
detail.setV27(harmRateV.getV27());
|
||||
detail.setV28(harmRateV.getV28());
|
||||
detail.setV29(harmRateV.getV29());
|
||||
detail.setV30(harmRateV.getV30());
|
||||
detail.setV31(harmRateV.getV31());
|
||||
detail.setV32(harmRateV.getV32());
|
||||
detail.setV33(harmRateV.getV33());
|
||||
detail.setV34(harmRateV.getV34());
|
||||
detail.setV35(harmRateV.getV35());
|
||||
detail.setV36(harmRateV.getV36());
|
||||
detail.setV37(harmRateV.getV37());
|
||||
detail.setV38(harmRateV.getV38());
|
||||
detail.setV39(harmRateV.getV39());
|
||||
detail.setV40(harmRateV.getV40());
|
||||
detail.setV41(harmRateV.getV41());
|
||||
detail.setV42(harmRateV.getV42());
|
||||
detail.setV43(harmRateV.getV43());
|
||||
detail.setV44(harmRateV.getV44());
|
||||
detail.setV45(harmRateV.getV45());
|
||||
detail.setV46(harmRateV.getV46());
|
||||
detail.setV47(harmRateV.getV47());
|
||||
detail.setV48(harmRateV.getV48());
|
||||
detail.setV49(harmRateV.getV49());
|
||||
detail.setV50(harmRateV.getV50());
|
||||
linePollutionList.add(detail);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return linePollutionList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算谐波电压的污染值,包含了电压总畸变率和谐波电压2~25次
|
||||
*
|
||||
* @param linePollution 监测点信息
|
||||
* @param overlimit 当前监测点限值
|
||||
*/
|
||||
private double calcVAllPollutionValue(LinePollution linePollution, Overlimit overlimit, String startTime, String endTime) {
|
||||
//最大值
|
||||
|
||||
Reference in New Issue
Block a user