1.修改冀北日曲线bug

This commit is contained in:
wr
2023-08-16 10:47:49 +08:00
parent 500e4e3444
commit 49e939c550

View File

@@ -363,7 +363,7 @@ public class StatationStatServiceImpl extends ServiceImpl<StatationStatMapper, S
@Override @Override
public List<StatationStat> getStatationStatList(String orgID) { public List<StatationStat> getStatationStatList(String orgID) {
if(StrUtil.isBlank(orgID)){ if (StrUtil.isBlank(orgID)) {
throw new BusinessException(PmsDeviceResponseEnum.NO_ID_ORG); throw new BusinessException(PmsDeviceResponseEnum.NO_ID_ORG);
} }
List<DeptDTO> deptInfos = deptFeignClient.getDeptDescendantIndexes(orgID, Stream.of(0, 1).collect(Collectors.toList())).getData(); List<DeptDTO> deptInfos = deptFeignClient.getDeptDescendantIndexes(orgID, Stream.of(0, 1).collect(Collectors.toList())).getData();
@@ -376,7 +376,7 @@ public class StatationStatServiceImpl extends ServiceImpl<StatationStatMapper, S
} }
@Override @Override
public List<StatationStatVO.Curve> getStatationStatCurve(String subID,String voltageLevel,Integer type) { public List<StatationStatVO.Curve> getStatationStatCurve(String subID, String voltageLevel, Integer type) {
List<StatationStatVO.Curve> curves = new ArrayList<>(); List<StatationStatVO.Curve> curves = new ArrayList<>();
if (StrUtil.isBlank(subID)) { if (StrUtil.isBlank(subID)) {
throw new BusinessException(PmsDeviceResponseEnum.NO_ID_STATION); throw new BusinessException(PmsDeviceResponseEnum.NO_ID_STATION);
@@ -384,21 +384,23 @@ public class StatationStatServiceImpl extends ServiceImpl<StatationStatMapper, S
//获取主网信息,没有则获取配网信息 //获取主网信息,没有则获取配网信息
List<Monitor> list = iMonitorService.list(new LambdaQueryWrapper<Monitor>() List<Monitor> list = iMonitorService.list(new LambdaQueryWrapper<Monitor>()
.eq(Monitor::getPowerrId, subID) .eq(Monitor::getPowerrId, subID)
.eq(Monitor::getVoltageLevel,voltageLevel) .eq(Monitor::getVoltageLevel, voltageLevel)
); );
if (CollUtil.isEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
// String lineId = list.get(0).getLineId(); String lineId = list.get(0).getLineId();
addCurves(null,type,curves); addCurves(lineId, type, curves);
}else { } else {
List<PmsMonitorBaseDTO> disMonitorAllList = distributionMonitorMapper.getDisMonitorAllList(subID, 1); List<PmsMonitorBaseDTO> disMonitorAllList = distributionMonitorMapper.getDisMonitorAllList(subID, 1);
List<PmsMonitorBaseDTO> disMonitors = disMonitorAllList.stream().filter(x -> x.equals(voltageLevel)).collect(Collectors.toList()); List<PmsMonitorBaseDTO> disMonitors = disMonitorAllList.stream().filter(x -> x.equals(voltageLevel)).collect(Collectors.toList());
if(CollUtil.isNotEmpty(disMonitors)){ if (CollUtil.isNotEmpty(disMonitors)) {
String monitorId = disMonitors.get(0).getMonitorId(); String monitorId = disMonitors.get(0).getMonitorId();
addCurves(monitorId,type,curves); addCurves(monitorId, type, curves);
} }
} }
curves.sort(Comparator.comparing(r -> r.getTime())); if(CollUtil.isNotEmpty(curves)){
curves.sort(Comparator.comparing(r -> r.getTime()));
}
return curves; return curves;
} }
@@ -429,35 +431,36 @@ public class StatationStatServiceImpl extends ServiceImpl<StatationStatMapper, S
/** /**
* 对象添加 * 对象添加
*
* @param LineID 监测点id ff2d9674c1f1ecce7f33a5bf17fc4f2d * @param LineID 监测点id ff2d9674c1f1ecce7f33a5bf17fc4f2d
* @param type 0=谐波 1=总有功 * @param type 0=谐波 1=总有功
* @param curves 初始集合 * @param curves 初始集合
* @return * @return
*/ */
private List<StatationStatVO.Curve> addCurves(String LineID,Integer type,List<StatationStatVO.Curve> curves){ private List<StatationStatVO.Curve> addCurves(String LineID, Integer type, List<StatationStatVO.Curve> curves) {
if(type==0){ if (type == 0) {
List<DataV> dataV = iDataVService.getHarmonicDataV(LineID, List<DataV> dataV = iDataVService.getHarmonicDataV(LineID,
DateUtil.beginOfDay(DateUtil.date()).toString() DateUtil.beginOfDay(DateUtil.date()).toString()
, DateUtil.endOfDay(DateUtil.date()).toString()); , DateUtil.endOfDay(DateUtil.date()).toString());
if(CollUtil.isNotEmpty(dataV)){ if (CollUtil.isNotEmpty(dataV)) {
Map<Instant, Double> collect = dataV.stream().collect(Collectors.toMap(DataV::getTime, DataV::getVThd, (c1, c2) -> c1 > c2 ? c1 : c2)); Map<Instant, Double> collect = dataV.stream().collect(Collectors.toMap(DataV::getTime, DataV::getVThd, (c1, c2) -> c1 > c2 ? c1 : c2));
collect.forEach((key,value)->{ collect.forEach((key, value) -> {
StatationStatVO.Curve curve =new StatationStatVO.Curve(); StatationStatVO.Curve curve = new StatationStatVO.Curve();
curve.setTime(Date.from(key)); curve.setTime(Date.from(key));
curve.setNum( BigDecimal.valueOf(value).setScale(3, RoundingMode.HALF_UP)); curve.setNum(BigDecimal.valueOf(value).setScale(3, RoundingMode.HALF_UP));
curves.add(curve); curves.add(curve);
}); });
} }
}else{ } else {
List<DataHarmPowerP> dataHarmPowerP = dataHarmPowerPService.getHarmonicPowerP(LineID, List<DataHarmPowerP> dataHarmPowerP = dataHarmPowerPService.getHarmonicPowerP(LineID,
DateUtil.beginOfDay(DateUtil.date()).toString() DateUtil.beginOfDay(DateUtil.date()).toString()
, DateUtil.endOfDay(DateUtil.date()).toString()); , DateUtil.endOfDay(DateUtil.date()).toString());
if(CollUtil.isNotEmpty(dataHarmPowerP)){ if (CollUtil.isNotEmpty(dataHarmPowerP)) {
Map<Instant, Double> dataHarmPowerPMap = dataHarmPowerP.stream().collect(Collectors.toMap(DataHarmPowerP::getTime, DataHarmPowerP::getP, (c1, c2) -> c1 > c2 ? c1 : c2)); Map<Instant, Double> dataHarmPowerPMap = dataHarmPowerP.stream().collect(Collectors.toMap(DataHarmPowerP::getTime, DataHarmPowerP::getP, (c1, c2) -> c1 > c2 ? c1 : c2));
dataHarmPowerPMap.forEach((key,value)->{ dataHarmPowerPMap.forEach((key, value) -> {
StatationStatVO.Curve curve =new StatationStatVO.Curve(); StatationStatVO.Curve curve = new StatationStatVO.Curve();
curve.setTime(Date.from(key)); curve.setTime(Date.from(key));
curve.setNum( BigDecimal.valueOf(value).setScale(3, RoundingMode.HALF_UP)); curve.setNum(BigDecimal.valueOf(value).setScale(3, RoundingMode.HALF_UP));
curves.add(curve); curves.add(curve);
}); });
} }