谐波畸变bug修复&&区域统计bug修复

This commit is contained in:
zhuxinyu
2023-04-12 18:15:32 +08:00
parent f49134860b
commit 7c6a129ac0
6 changed files with 65 additions and 91 deletions

View File

@@ -78,7 +78,7 @@ public class THDistortionServiceImpl implements THDistortionService {
//查找畸变率
List<PublicDTO> condition = getCondition(lineIndexes, thDistortionParam.getSearchBeginTime(), thDistortionParam.getSearchEndTime());
thDistortionVO.setDistortion(condition.stream().mapToDouble(PublicDTO::getData).average().orElse(3.14159));
thDistortionVO.setDistortion(roundHalfUp(condition.stream().mapToDouble(PublicDTO::getData).average().orElse(3.14159)));
//组装父级数据树
List<THDistortionVO> treeList = getTreeData(lineIndexes, thDistortionParam);
thDistortionVO.setChildren(treeList);
@@ -162,7 +162,7 @@ public class THDistortionServiceImpl implements THDistortionService {
List<THDistortionVO> children = thDistortionVO.getChildren();
List<THDistortionVO> tempList = children.stream().filter(child -> !Objects.equals(child.getDistortion(), 3.14159)).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(tempList)) {
thDistortionVO.setDistortion(tempList.stream().mapToDouble(THDistortionVO::getDistortion).average().orElse(3.14159));
thDistortionVO.setDistortion(roundHalfUp(tempList.stream().mapToDouble(THDistortionVO::getDistortion).average().orElse(3.14159)));
} else {
thDistortionVO.setDistortion(3.14159);
}
@@ -210,7 +210,7 @@ public class THDistortionServiceImpl implements THDistortionService {
if (!CollectionUtils.isEmpty(monitorList)) {
//根据监测点集合组装谐波畸变率
monitorList.stream().map(list1 -> condition.stream().filter(list2 -> Objects.equals(list1.getId(), list2.getId())).findAny().map(m -> {
list1.setDistortion(m.getData());
list1.setDistortion(roundHalfUp(m.getData()));
return list1;
})).collect(Collectors.toList());
@@ -226,6 +226,18 @@ public class THDistortionServiceImpl implements THDistortionService {
return powerCompanyList;
}
/**
* 四舍五入保留两位小数
*/
private Double roundHalfUp (double num) {
if (num == 3.14159) {
return num;
}
BigDecimal b = new BigDecimal(num);
//保留2位小数
return b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
/**
* influxDB查询畸变率
@@ -246,7 +258,8 @@ public class THDistortionServiceImpl implements THDistortionService {
.ge(StrUtil.isNotBlank(startTime), RStatDataVD::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))
.le(StrUtil.isNotBlank(endTime), RStatDataVD::getTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
.eq(RStatDataVD::getQualityFlag, 1)
// .eq(RStatDataVD::getQualityFlag, 1)
.eq(RStatDataVD::getQualityFlag, 0)
.in(RStatDataVD::getPhasicType, phasicType)
.eq(RStatDataVD::getValueType, Param.VALUE_TYPEAVG)
);