bug修改

This commit is contained in:
2023-05-23 16:50:42 +08:00
parent b5a0e4c9e3
commit fd97f5fd78
3 changed files with 40 additions and 53 deletions

View File

@@ -56,7 +56,7 @@ public class COverlimitUtil {
/** /**
* 电压限值 * 电压偏差限值
* *
*/ */
public static void voltageDeviation(Overlimit overlimit,Float voltageLevel) { public static void voltageDeviation(Overlimit overlimit,Float voltageLevel) {

View File

@@ -1792,6 +1792,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
DeviceBak deviceBak = new DeviceBak(); DeviceBak deviceBak = new DeviceBak();
deviceBak.setId(temp.getId()); deviceBak.setId(temp.getId());
deviceBak.setDevId(oracleTerminalExcel.getDeviceId()); deviceBak.setDevId(oracleTerminalExcel.getDeviceId());
deviceBakService.removeById(oracleTerminalExcel.getDeviceId());
deviceBakService.saveOrUpdate(deviceBak); deviceBakService.saveOrUpdate(deviceBak);
} }
//添加终端索引 //添加终端索引
@@ -1907,6 +1908,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
LineBak lineBak = new LineBak(); LineBak lineBak = new LineBak();
lineBak.setId(temp.getId()); lineBak.setId(temp.getId());
lineBak.setLineId(oracleTerminalExcel.getId()); lineBak.setLineId(oracleTerminalExcel.getId());
lineBakService.removeById(oracleTerminalExcel.getId());
lineBakService.save(lineBak); lineBakService.save(lineBak);
OverLimitExcel overLimitExcel = overLimitList.get(0); OverLimitExcel overLimitExcel = overLimitList.get(0);
Overlimit overlimit = new Overlimit(); Overlimit overlimit = new Overlimit();

View File

@@ -34,6 +34,7 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -51,38 +52,36 @@ public class THDistortionServiceImpl implements THDistortionService {
private final THDistortionMapper thDistortionMapper; private final THDistortionMapper thDistortionMapper;
private final InfluxDbUtils influxDbUtils;
private final RMpVThdMapper rMpVThdMapper; private final RMpVThdMapper rMpVThdMapper;
private final LineFeignClient lineFeignClient; private final LineFeignClient lineFeignClient;
private final IRStatDataVDService statDataVDService; private final IRStatDataVDService statDataVDService;
@Override @Override
public List<THDistortionVO> getTHDistortionData(DeviceInfoParam.BusinessParam thDistortionParam) { public List<THDistortionVO> getTHDistortionData(DeviceInfoParam.BusinessParam thDistortionParam) {
List<THDistortionVO> thDistortionVOS = new ArrayList<>(); List<THDistortionVO> thDistortionVOS = new ArrayList<>();
List<String> lineList = new ArrayList<>();
//按照条件获取实际运行终端综合信息 //按照条件获取实际运行终端综合信息
List<GeneralDeviceDTO> deviceList = generalDeviceInfoClient.getPracticalRunDeviceInfo(new DeviceInfoParam(thDistortionParam.getStatisticalType(), thDistortionParam.getDeptIndex(), generalInfo.getMicroServiceName(), thDistortionParam.getScale(), thDistortionParam.getManufacturer(), thDistortionParam.getLoadType())).getData(); List<GeneralDeviceDTO> deviceList = generalDeviceInfoClient.getPracticalRunDeviceInfo(new DeviceInfoParam(thDistortionParam.getStatisticalType(), thDistortionParam.getDeptIndex(), generalInfo.getMicroServiceName(), thDistortionParam.getScale(), thDistortionParam.getManufacturer(), thDistortionParam.getLoadType())).getData();
//组装监测点Top层集合 //组装监测点Top层集合
for (GeneralDeviceDTO generalDeviceDTO : deviceList) { for (GeneralDeviceDTO generalDeviceDTO : deviceList) {
if (CollectionUtils.isEmpty(generalDeviceDTO.getDeviceIndexes())) { List<String> lineIndexes = generalDeviceDTO.getLineIndexes();
if (CollectionUtils.isEmpty(lineIndexes)) {
continue; continue;
} }
THDistortionVO thDistortionVO = new THDistortionVO(); THDistortionVO thDistortionVO = new THDistortionVO();
thDistortionVO.setId(generalDeviceDTO.getIndex()); thDistortionVO.setId(generalDeviceDTO.getIndex());
thDistortionVO.setName(generalDeviceDTO.getName()); thDistortionVO.setName(generalDeviceDTO.getName());
if (!CollectionUtils.isEmpty(generalDeviceDTO.getLineIndexes())) {
List<String> lineIndexes = generalDeviceDTO.getLineIndexes();
//查找畸变率 //查找畸变率
List<PublicDTO> condition = getCondition(lineIndexes, thDistortionParam.getSearchBeginTime(), thDistortionParam.getSearchEndTime()); List<PublicDTO> condition = getCondition(lineIndexes, thDistortionParam.getSearchBeginTime(), thDistortionParam.getSearchEndTime());
thDistortionVO.setDistortion(roundHalfUp(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); List<THDistortionVO> treeList = getTreeData(lineIndexes, condition);
thDistortionVO.setChildren(treeList); thDistortionVO.setChildren(treeList);
}
thDistortionVOS.add(thDistortionVO); thDistortionVOS.add(thDistortionVO);
} }
@@ -193,7 +192,7 @@ public class THDistortionServiceImpl implements THDistortionService {
/** /**
* 获取父级每层数据 * 获取父级每层数据
*/ */
private List<THDistortionVO> getTreeData(List<String> lineIndexes, DeviceInfoParam.BusinessParam thDistortionParam) { private List<THDistortionVO> getTreeData(List<String> lineIndexes,List<PublicDTO> condition) {
//监测点集合 //监测点集合
List<THDistortionVO> monitorList = thDistortionMapper.getLineData(lineIndexes); List<THDistortionVO> monitorList = thDistortionMapper.getLineData(lineIndexes);
//母线集合 //母线集合
@@ -205,21 +204,18 @@ public class THDistortionServiceImpl implements THDistortionService {
//供电公司集合 //供电公司集合
List<THDistortionVO> powerCompanyList = thDistortionMapper.getLineInfoByList(substationList.stream().map(THDistortionVO::getPid).distinct().collect(Collectors.toList())); List<THDistortionVO> powerCompanyList = thDistortionMapper.getLineInfoByList(substationList.stream().map(THDistortionVO::getPid).distinct().collect(Collectors.toList()));
//查询监测点谐波畸变率
List<PublicDTO> condition = getCondition(lineIndexes, thDistortionParam.getSearchBeginTime(), thDistortionParam.getSearchEndTime());
if (!CollectionUtils.isEmpty(monitorList)) {
//根据监测点集合组装谐波畸变率
monitorList.stream().map(list1 -> condition.stream().filter(list2 -> Objects.equals(list1.getId(), list2.getId())).findAny().map(m -> {
list1.setDistortion(roundHalfUp(m.getData()));
return list1;
})).collect(Collectors.toList());
// busBarList.stream().peek(item -> item.setChildren(getChildCategoryList(item, monitorList))).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(monitorList)) {
// deviceList.stream().peek(item -> item.setChildren(getChildCategoryList(item, busBarList))).collect(Collectors.toList()); Map<String, PublicDTO> map = condition.stream().collect(Collectors.toMap(PublicDTO::getId, Function.identity()));
// substationList.stream().peek(item -> item.setChildren(getChildesList(item, monitorList))).collect(Collectors.toList());
for(THDistortionVO thDistortionVO:monitorList) {
if (map.containsKey(thDistortionVO.getId())) {
thDistortionVO.setDistortion(map.get(thDistortionVO.getId()).getData());
}
}
setChildesList(substationList, monitorList); setChildesList(substationList, monitorList);
setFatherDistortion(substationList); setFatherDistortion(substationList);
powerCompanyList.stream().peek(item -> item.setChildren(getChildCategoryList(item, substationList))).collect(Collectors.toList()); powerCompanyList = powerCompanyList.stream().peek(item -> item.setChildren(getChildCategoryList(item, substationList))).collect(Collectors.toList());
setFatherDistortion(powerCompanyList); setFatherDistortion(powerCompanyList);
} }
@@ -248,33 +244,22 @@ public class THDistortionServiceImpl implements THDistortionService {
*/ */
private List<PublicDTO> getCondition(List<String> lineIndexes, String startTime, String endTime) { private List<PublicDTO> getCondition(List<String> lineIndexes, String startTime, String endTime) {
List<PublicDTO> publicDTOList = new ArrayList<>(); List<PublicDTO> publicDTOList = new ArrayList<>();
List<String> phasicType = new ArrayList<>();
phasicType.add(Param.PHASIC_TYPEA);
phasicType.add(Param.PHASIC_TYPEB);
phasicType.add(Param.PHASIC_TYPEC);
//数据库查询 //数据库查询
List<RStatDataVD> info = statDataVDService.list(new LambdaQueryWrapper<RStatDataVD>() QueryWrapper<RMpVThd> queryWrapper = new QueryWrapper<>();
.in(RStatDataVD::getLineId, lineIndexes) queryWrapper.select("max(v_thd) vThd,measurement_point_id").lambda()
.ge(StrUtil.isNotBlank(startTime), RStatDataVD::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime))) .in(RMpVThd::getMeasurementPointId, lineIndexes)
.le(StrUtil.isNotBlank(endTime), RStatDataVD::getTime, DateUtil.endOfDay(DateUtil.parse(endTime))) .ge(StrUtil.isNotBlank(startTime), RMpVThd::getDataDate, DateUtil.beginOfDay(DateUtil.parse(startTime)))
.le(StrUtil.isNotBlank(endTime), RMpVThd::getDataDate, DateUtil.endOfDay(DateUtil.parse(endTime)))
.eq(RMpVThd::getDataType, 0).groupBy(RMpVThd::getMeasurementPointId);
// .eq(RStatDataVD::getQualityFlag, 1) List<RMpVThd> info = rMpVThdMapper.selectList(queryWrapper);
.eq(RStatDataVD::getQualityFlag, 0)
.in(RStatDataVD::getPhasicType, phasicType)
.eq(RStatDataVD::getValueType, Param.VALUE_TYPEAVG)
);
if (CollUtil.isNotEmpty(info)) { if (CollUtil.isNotEmpty(info)) {
//根据id分组先乘以100.在取平均值,在四舍五入 info.forEach(item->{
Map<String, List<BigDecimal>> collect = info.stream().filter(x -> x.getVThd() != null).collect(Collectors.groupingBy(RStatDataVD::getLineId, Collectors.mapping(RStatDataVD::getVThd, Collectors.toList()))); PublicDTO publicDTO = new PublicDTO();
Map<String, Double> vthdMap = info.stream().filter(x -> x.getVThd() != null).collect(Collectors.groupingBy(RStatDataVD::getLineId, publicDTO.setId(item.getMeasurementPointId());
Collectors.averagingDouble(x -> x.getVThd().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()))); publicDTO.setData(item.getVThd());
PublicDTO publicDTO;
for (Map.Entry<String, Double> entry : vthdMap.entrySet()) {
publicDTO = new PublicDTO();
publicDTO.setId(entry.getKey());
publicDTO.setData(entry.getValue());
publicDTOList.add(publicDTO); publicDTOList.add(publicDTO);
} });
} }
return publicDTOList; return publicDTOList;
} }