|
|
|
|
@@ -1,14 +1,17 @@
|
|
|
|
|
package com.njcn.harmonic.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.njcn.common.pojo.constant.BizParamConstant;
|
|
|
|
|
import com.njcn.common.pojo.exception.BusinessException;
|
|
|
|
|
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
|
|
|
|
|
import com.njcn.common.utils.PubUtils;
|
|
|
|
|
import com.njcn.dataProcess.pojo.po.RStatDataHarmRateVD;
|
|
|
|
|
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
|
|
|
|
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
|
|
|
|
|
import com.njcn.device.biz.pojo.po.Overlimit;
|
|
|
|
|
@@ -16,19 +19,21 @@ import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
|
|
|
|
|
import com.njcn.device.biz.utils.COverlimitUtil;
|
|
|
|
|
import com.njcn.event.api.EventDetailFeignClient;
|
|
|
|
|
import com.njcn.event.pojo.po.EventDetail;
|
|
|
|
|
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
|
|
|
|
import com.njcn.harmonic.enums.HarmonicResponseEnum;
|
|
|
|
|
import com.njcn.harmonic.mapper.StatHarmonicOrgDMapper;
|
|
|
|
|
import com.njcn.harmonic.mapper.StatHarmonicOrgMMapper;
|
|
|
|
|
import com.njcn.harmonic.mapper.StatHarmonicOrgQMapper;
|
|
|
|
|
import com.njcn.harmonic.mapper.StatHarmonicOrgYMapper;
|
|
|
|
|
import com.njcn.harmonic.mapper.*;
|
|
|
|
|
import com.njcn.harmonic.pojo.QueryResultLimitVO;
|
|
|
|
|
import com.njcn.harmonic.pojo.param.HistoryHarmParam;
|
|
|
|
|
import com.njcn.harmonic.pojo.param.HistoryParam;
|
|
|
|
|
import com.njcn.harmonic.pojo.param.NormHistoryParam;
|
|
|
|
|
import com.njcn.harmonic.pojo.po.RStatDataVD;
|
|
|
|
|
import com.njcn.harmonic.pojo.po.day.*;
|
|
|
|
|
import com.njcn.harmonic.pojo.vo.AssessEvaluation;
|
|
|
|
|
import com.njcn.harmonic.pojo.vo.EventDetailVO;
|
|
|
|
|
import com.njcn.harmonic.pojo.vo.HistoryDataResultVO;
|
|
|
|
|
import com.njcn.harmonic.pojo.vo.StatHarmonicOrgVO;
|
|
|
|
|
import com.njcn.harmonic.service.HistoryResultService;
|
|
|
|
|
import com.njcn.harmonic.service.IRStatDataVDService;
|
|
|
|
|
import com.njcn.influx.imapper.CommonMapper;
|
|
|
|
|
import com.njcn.influx.imapper.DataHarmRateVMapper;
|
|
|
|
|
import com.njcn.influx.imapper.DataIMapper;
|
|
|
|
|
@@ -44,12 +49,15 @@ import com.njcn.system.pojo.po.DictData;
|
|
|
|
|
import com.njcn.user.api.DeptFeignClient;
|
|
|
|
|
import com.njcn.user.pojo.dto.DeptDTO;
|
|
|
|
|
import com.njcn.web.utils.WebUtil;
|
|
|
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
import lombok.SneakyThrows;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
@@ -90,6 +98,10 @@ public class HistoryResultServiceImpl implements HistoryResultService {
|
|
|
|
|
|
|
|
|
|
private final DicDataFeignClient dicDataFeignClient;
|
|
|
|
|
|
|
|
|
|
private final RStatDataIDMapper dataIDMapper;
|
|
|
|
|
private final RStatDataVDMapper dataVDMapper;
|
|
|
|
|
private final RStatDataHarmRateVDMapper dataHarmRateVDMapper;
|
|
|
|
|
private final RStatDataHarmRateIDMapper dataHarmRateIDMapper;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<HistoryDataResultVO> getHistoryResult(HistoryParam historyParam) {
|
|
|
|
|
@@ -1078,6 +1090,99 @@ public class HistoryResultServiceImpl implements HistoryResultService {
|
|
|
|
|
return new HarmHistoryDataDTO(historyData, overLimit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public AssessEvaluation getHarmIAndHarmVData(StatisticsBizBaseParam param) {
|
|
|
|
|
String id = param.getId();
|
|
|
|
|
String startTime = param.getStartTime();
|
|
|
|
|
String endTime = param.getEndTime();
|
|
|
|
|
List<RStatDataIDPO> rStatDataIDPOS = dataIDMapper.selectList(new LambdaQueryWrapper<RStatDataIDPO>()
|
|
|
|
|
.eq(RStatDataIDPO::getLineId, id)
|
|
|
|
|
.eq(RStatDataIDPO::getValueType,"CP95")
|
|
|
|
|
.in(RStatDataIDPO::getPhaseType,Arrays.asList("A","B","C"))
|
|
|
|
|
.ge(RStatDataIDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))
|
|
|
|
|
.le(RStatDataIDPO::getTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
|
|
|
|
|
);
|
|
|
|
|
List<RStatDataVD> rStatDataVDS = dataVDMapper.selectList(new LambdaQueryWrapper<RStatDataVD>()
|
|
|
|
|
.eq(RStatDataVD::getLineId, id)
|
|
|
|
|
.eq(RStatDataVD::getValueType,"CP95")
|
|
|
|
|
.in(RStatDataVD::getPhasicType,Arrays.asList("A","B","C"))
|
|
|
|
|
.ge(RStatDataVD::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))
|
|
|
|
|
.le(RStatDataVD::getTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
|
|
|
|
|
);
|
|
|
|
|
List<RStatDataHarmrateVDPO> harmV = dataHarmRateVDMapper.selectList(new LambdaQueryWrapper<RStatDataHarmrateVDPO>()
|
|
|
|
|
.eq(RStatDataHarmrateVDPO::getLineId, id)
|
|
|
|
|
.eq(RStatDataHarmrateVDPO::getValueType,"CP95")
|
|
|
|
|
.in(RStatDataHarmrateVDPO::getPhaseType,Arrays.asList("A","B","C"))
|
|
|
|
|
.ge(RStatDataHarmrateVDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))
|
|
|
|
|
.le(RStatDataHarmrateVDPO::getTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
List<RStatDataHarmrateIDPO> harmI = dataHarmRateIDMapper.selectList(new LambdaQueryWrapper<RStatDataHarmrateIDPO>()
|
|
|
|
|
.eq(RStatDataHarmrateIDPO::getLineId, id)
|
|
|
|
|
.eq(RStatDataHarmrateIDPO::getValueType,"CP95")
|
|
|
|
|
.in(RStatDataHarmrateIDPO::getPhaseType,Arrays.asList("A","B","C"))
|
|
|
|
|
.ge(RStatDataHarmrateIDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))
|
|
|
|
|
.le(RStatDataHarmrateIDPO::getTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
AssessEvaluation assessEvaluation=new AssessEvaluation();
|
|
|
|
|
List<Double> iMax=new ArrayList<>();
|
|
|
|
|
List<Double> uMax=new ArrayList<>();
|
|
|
|
|
if(CollUtil.isNotEmpty(rStatDataIDPOS)&&CollUtil.isNotEmpty(rStatDataVDS)&&CollUtil.isNotEmpty(harmV)&&CollUtil.isNotEmpty(harmI)){
|
|
|
|
|
Double iNeg = rStatDataIDPOS.stream().map(RStatDataIDPO::getINeg).max(Comparator.naturalOrder()).get();
|
|
|
|
|
assessEvaluation.setINeg(iNeg);
|
|
|
|
|
BigDecimal vUnbalance = rStatDataVDS.stream().map(RStatDataVD::getVUnbalance).max(Comparator.naturalOrder()).get();
|
|
|
|
|
assessEvaluation.setUnbalance(vUnbalance.doubleValue());
|
|
|
|
|
for (int i = 2; i < 51; i++) {
|
|
|
|
|
uMax.add(reflectDataV(harmV,"v"+i).stream().max(Comparator.naturalOrder()).get());
|
|
|
|
|
iMax.add(reflectDataI(harmI,"i"+i).stream().max(Comparator.naturalOrder()).get());
|
|
|
|
|
}
|
|
|
|
|
assessEvaluation.setIMax(iMax);
|
|
|
|
|
assessEvaluation.setUMax(uMax);
|
|
|
|
|
}else{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return assessEvaluation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Double> reflectDataV(List<RStatDataHarmrateVDPO> harmVList,String attribute) {
|
|
|
|
|
Field field;
|
|
|
|
|
try {
|
|
|
|
|
field = RStatDataHarmrateVDPO.class.getDeclaredField(attribute);
|
|
|
|
|
} catch (NoSuchFieldException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
field.setAccessible(true);
|
|
|
|
|
return harmVList.stream().map(temp -> {
|
|
|
|
|
Double o;
|
|
|
|
|
try {
|
|
|
|
|
o = (Double) field.get(temp);
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
return o;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Double> reflectDataI(List<RStatDataHarmrateIDPO> harmIList,String attribute) {
|
|
|
|
|
Field field;
|
|
|
|
|
try {
|
|
|
|
|
field = RStatDataHarmrateIDPO.class.getDeclaredField(attribute);
|
|
|
|
|
} catch (NoSuchFieldException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
field.setAccessible(true);
|
|
|
|
|
return harmIList.stream().map(temp -> {
|
|
|
|
|
Double o;
|
|
|
|
|
try {
|
|
|
|
|
o = (Double) field.get(temp);
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
return o;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
* 获取指定次数 监测点的历史谐波电流数据
|
|
|
|
|
* @author hongawen
|
|
|
|
|
|