zbj//1.算法 优化

This commit is contained in:
zhangbaojian
2023-07-05 15:51:45 +08:00
parent 920aead30f
commit e19555075d

View File

@@ -96,6 +96,7 @@ public class RStatSubstationServiceImpl implements RStatSubstationService {
} }
//天表 //天表
@Async("asyncExecutor")
public void rStatSubstationDHandler(List<DeptGetSubStationDTO> data, String dataDate, Integer type) { public void rStatSubstationDHandler(List<DeptGetSubStationDTO> data, String dataDate, Integer type) {
List<RStatSubstationDPO> rStatSubstationDPOS = new ArrayList<>(); List<RStatSubstationDPO> rStatSubstationDPOS = new ArrayList<>();
Date date = DateUtil.parse(dataDate); Date date = DateUtil.parse(dataDate);
@@ -113,18 +114,25 @@ public class RStatSubstationServiceImpl implements RStatSubstationService {
} }
} }
List<String> zw = zwList.stream().distinct().collect(Collectors.toList()); zwList.addAll(pwList);
List<String> pw = pwList.stream().distinct().collect(Collectors.toList()); List<String> resultL = zwList.stream().distinct().collect(Collectors.toList());
//主网 if (!CollectionUtils.isEmpty(resultL)) {
if (!CollectionUtils.isEmpty(zw)) {
zw.forEach(z -> { resultL.forEach(z -> {
//获取监测点对象集合 //获取监测点对象集合
LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData(); LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData();
if (Objects.nonNull(lineDevGetDTOs.getZwList())) { if (Objects.nonNull(lineDevGetDTOs.getZwList()) || Objects.nonNull(lineDevGetDTOs.getPwList())) {
//获取监测点id集合 //获取监测点id集合
List<String> lineIds = lineDevGetDTOs.getZwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList()); List<String> lineIds = new ArrayList<>();
List<String> pLineIds = new ArrayList<>();
if (Objects.nonNull(lineDevGetDTOs.getZwList())) {
lineIds = lineDevGetDTOs.getZwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
}
if (Objects.nonNull(lineDevGetDTOs.getPwList())) {
pLineIds = lineDevGetDTOs.getPwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
lineIds.addAll(pLineIds);
}
//判空 //判空
if (!CollectionUtils.isEmpty(lineIds)) { if (!CollectionUtils.isEmpty(lineIds)) {
int sw = 0, sa = 0, in = 0, result = 0; int sw = 0, sa = 0, in = 0, result = 0;
@@ -226,124 +234,15 @@ public class RStatSubstationServiceImpl implements RStatSubstationService {
} }
//配网
if (!CollectionUtils.isEmpty(pw)) {
pw.forEach(p -> {
//获取监测点对象集合
LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(p).getData();
if (Objects.nonNull(lineDevGetDTOs.getPwList())) {
//获取监测点id集合
List<String> lineIds = lineDevGetDTOs.getPwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
//判空
if (!CollectionUtils.isEmpty(lineIds)) {
int sw = 0, sa = 0, in = 0, result = 0;
//r_mp_target_warn_d 表中字段求和
Map<String, Object> warnSum = rMpTargetWarnDMapper.getSumDate(dataDate, dataDate, lineIds);
//r_mp_part_harmonic_detail_d 表中字段求和
Map<String, Object> partSum = rMpPartHarmonicDetailDMapper.getPartSum(dataDate, dataDate, lineIds);
//r_mp_surplus_harmonic_detail_d 表中字段求和
Map<String, Object> surplusSum = mpSurplusHarmonicDetailDMapper.getSurplusSum(dataDate, dataDate, lineIds);
//r_mp_event_detail_d 表中字段求和及计数
Map<String, Object> eventDetailSumAndCount = rMpEventDetailDMapper.getSumAndCount(dataDate, dataDate, lineIds);
RStatSubstationDPO rStatSubstationDPO = new RStatSubstationDPO();
rStatSubstationDPO.setDataDate(localDate);
rStatSubstationDPO.setSubstationId(p);
if (!CollectionUtils.isEmpty(warnSum)) {
rStatSubstationDPO.setEffectiveMeasurementCount(warnSum.containsKey("iECount") ?
Integer.parseInt(warnSum.get("iECount").toString()) : 0);
} else {
rStatSubstationDPO.setEffectiveMeasurementCount(0);
}
if (!CollectionUtils.isEmpty(partSum)) {
rStatSubstationDPO.setHarmonicCount(partSum.containsKey("isHarmonicCount") ?
Integer.parseInt(partSum.get("isHarmonicCount").toString()) : 0);
rStatSubstationDPO.setFreqCount(partSum.containsKey("isFreqCount") ?
Integer.parseInt(partSum.get("isFreqCount").toString()) : 0);
rStatSubstationDPO.setVDevCount(partSum.containsKey("isVDevCount") ?
Integer.parseInt(partSum.get("isVDevCount").toString()) : 0);
rStatSubstationDPO.setVCount(partSum.containsKey("isVCount") ?
Integer.parseInt(partSum.get("isVCount").toString()) : 0);
rStatSubstationDPO.setICount(partSum.containsKey("isICount") ?
Integer.parseInt(partSum.get("isICount").toString()) : 0);
rStatSubstationDPO.setUnbalanceCount(partSum.containsKey("isUnbalanceCount") ?
Integer.parseInt(partSum.get("isUnbalanceCount").toString()) : 0);
rStatSubstationDPO.setINegCount(partSum.containsKey("isINegCount") ?
Integer.parseInt(partSum.get("isINegCount").toString()) : 0);
} else {
rStatSubstationDPO.setHarmonicCount(0);
rStatSubstationDPO.setFreqCount(0);
rStatSubstationDPO.setVDevCount(0);
rStatSubstationDPO.setVCount(0);
rStatSubstationDPO.setICount(0);
rStatSubstationDPO.setUnbalanceCount(0);
rStatSubstationDPO.setINegCount(0);
}
if (!CollectionUtils.isEmpty(surplusSum)) {
rStatSubstationDPO.setFlickerCount(surplusSum.containsKey("isFlickerCount") ?
Integer.parseInt(surplusSum.get("isFlickerCount").toString()) : 0);
rStatSubstationDPO.setInuharmCount(surplusSum.containsKey("isInuharmCount") ?
Integer.parseInt(surplusSum.get("isInuharmCount").toString()) : 0);
} else {
rStatSubstationDPO.setFlickerCount(0);
rStatSubstationDPO.setInuharmCount(0);
}
if (!CollectionUtils.isEmpty(eventDetailSumAndCount)) {
rStatSubstationDPO.setEventMeasurementCount(eventDetailSumAndCount.containsKey("resultCount") ?
Integer.parseInt(eventDetailSumAndCount.get("resultCount").toString()) : 0);
if (eventDetailSumAndCount.containsKey("swellTimesSum")) {
sw = Integer.parseInt(eventDetailSumAndCount.get("swellTimesSum").toString());
}
if (eventDetailSumAndCount.containsKey("sagTimesSum")) {
sa = Integer.parseInt(eventDetailSumAndCount.get("sagTimesSum").toString());
}
if (eventDetailSumAndCount.containsKey("interruptTimesSum")) {
in = Integer.parseInt(eventDetailSumAndCount.get("interruptTimesSum").toString());
}
result = sw + sa + in;
rStatSubstationDPO.setEventCount(result);
rStatSubstationDPO.setSwellMeasurementCount(eventDetailSumAndCount.containsKey("swellTimesCount") ?
Integer.parseInt(eventDetailSumAndCount.get("swellTimesCount").toString()) : 0);
rStatSubstationDPO.setSwellCount(sw);
rStatSubstationDPO.setSagMeasurementCount(eventDetailSumAndCount.containsKey("sagTimesCount") ?
Integer.parseInt(eventDetailSumAndCount.get("sagTimesCount").toString()) : 0);
rStatSubstationDPO.setSagCount(sa);
rStatSubstationDPO.setInterruptMeasurementCount(eventDetailSumAndCount.containsKey("interruptTimesCount") ?
Integer.parseInt(eventDetailSumAndCount.get("interruptTimesCount").toString()) : 0);
rStatSubstationDPO.setInterruptCount(in);
} else {
rStatSubstationDPO.setEventMeasurementCount(0);
rStatSubstationDPO.setEventCount(0);
rStatSubstationDPO.setSwellMeasurementCount(0);
rStatSubstationDPO.setSwellCount(0);
rStatSubstationDPO.setSagMeasurementCount(0);
rStatSubstationDPO.setSagCount(0);
rStatSubstationDPO.setInterruptMeasurementCount(0);
rStatSubstationDPO.setInterruptCount(0);
}
rStatSubstationDPOS.add(rStatSubstationDPO);
}
}
});
}
if (!CollectionUtils.isEmpty(rStatSubstationDPOS)) { if (!CollectionUtils.isEmpty(rStatSubstationDPOS)) {
List<RStatSubstationDPO> collect = rStatSubstationDPOS.stream().distinct().collect(Collectors.toList()); List<RStatSubstationDPO> collect = rStatSubstationDPOS.stream().distinct().collect(Collectors.toList());
rStatSubstationDPOService.saveOrUpdateBatchByMultiId(collect, 500); rStatSubstationDPOService.saveOrUpdateBatchByMultiId(collect, 500);
} }
} }
//月表 //月表
@Async("asyncExecutor")
public void rStatSubstationMHandler(List<DeptGetSubStationDTO> data, String dataDate, Integer type) { public void rStatSubstationMHandler(List<DeptGetSubStationDTO> data, String dataDate, Integer type) {
List<RStatSubstationMPO> rStatSubstationMPOS = new ArrayList<>(); List<RStatSubstationMPO> rStatSubstationMPOS = new ArrayList<>();
Date date = DateUtil.parse(dataDate); Date date = DateUtil.parse(dataDate);
@@ -372,19 +271,25 @@ public class RStatSubstationServiceImpl implements RStatSubstationService {
} }
} }
List<String> zw = zwList.stream().distinct().collect(Collectors.toList()); zwList.addAll(pwList);
List<String> pw = pwList.stream().distinct().collect(Collectors.toList()); List<String> resultL = zwList.stream().distinct().collect(Collectors.toList());
//主网 if (!CollectionUtils.isEmpty(resultL)) {
if (!CollectionUtils.isEmpty(zw)) {
zw.forEach(z -> { resultL.forEach(z -> {
//获取监测点对象集合 //获取监测点对象集合
LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData(); LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData();
if (Objects.nonNull(lineDevGetDTOs.getZwList())) { if (Objects.nonNull(lineDevGetDTOs.getZwList()) || Objects.nonNull(lineDevGetDTOs.getPwList())) {
//获取监测点id集合 //获取监测点id集合
List<String> lineIds = lineDevGetDTOs.getZwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList()); List<String> lineIds = new ArrayList<>();
//判空 List<String> pLineIds = new ArrayList<>();
if (Objects.nonNull(lineDevGetDTOs.getZwList())) {
lineIds = lineDevGetDTOs.getZwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
}
if (Objects.nonNull(lineDevGetDTOs.getPwList())) {
pLineIds = lineDevGetDTOs.getPwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
lineIds.addAll(pLineIds);
}
if (!CollectionUtils.isEmpty(lineIds)) { if (!CollectionUtils.isEmpty(lineIds)) {
//r_mp_target_warn_d 表中字段求和 //r_mp_target_warn_d 表中字段求和
Map<String, Object> warnSum = rMpTargetWarnDMapper.getSumDate(startTime, endTime, lineIds); Map<String, Object> warnSum = rMpTargetWarnDMapper.getSumDate(startTime, endTime, lineIds);
@@ -532,163 +437,6 @@ public class RStatSubstationServiceImpl implements RStatSubstationService {
} }
//配网
if (!CollectionUtils.isEmpty(pw)) {
pw.forEach(p -> {
//获取监测点对象集合
LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(p).getData();
if (Objects.nonNull(lineDevGetDTOs.getPwList())) {
//获取监测点id集合
List<String> lineIds = lineDevGetDTOs.getPwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
//判空
if (!CollectionUtils.isEmpty(lineIds)) {
//r_mp_target_warn_d 表中字段求和
Map<String, Object> warnSum = rMpTargetWarnDMapper.getSumDate(startTime, endTime, lineIds);
//r_mp_part_harmonic_detail_m 表中字段求和
Map<String, Object> partSum = rMpPartHarmonicDetailMMapper.getPartSum(startTime, endTime, lineIds);
//r_mp_surplus_harmonic_detail_m 表中字段求和
Map<String, Object> surplusSum = mpSurplusHarmonicDetailMMapper.getSurplusSum(startTime, endTime, lineIds);
//r_stat_substation_d 表中字段求和及计数
Map<String, Object> eventDetailSumAndCount = rStatSubstationDPOMapper.getSumAndCount(startTime, endTime, p);
RStatSubstationMPO rStatSubstationMPO = new RStatSubstationMPO();
rStatSubstationMPO.setDataDate(localDate);
rStatSubstationMPO.setSubstationId(p);
if (!CollectionUtils.isEmpty(warnSum)) {
rStatSubstationMPO.setEffectiveMeasurementAccrued(warnSum.containsKey("iECount") ?
Integer.parseInt(warnSum.get("iECount").toString()) : 0);
} else {
rStatSubstationMPO.setEffectiveMeasurementAccrued(0);
}
if (!CollectionUtils.isEmpty(partSum)) {
rStatSubstationMPO.setHarmonicCount(partSum.containsKey("measurementOverDayCount") ?
Integer.parseInt(partSum.get("measurementOverDayCount").toString()) : 0);
rStatSubstationMPO.setFreqCount(partSum.containsKey("freqOverDayCount") ?
Integer.parseInt(partSum.get("freqOverDayCount").toString()) : 0);
rStatSubstationMPO.setVDevCount(partSum.containsKey("vDevOverDayCount") ?
Integer.parseInt(partSum.get("vDevOverDayCount").toString()) : 0);
rStatSubstationMPO.setVCount(partSum.containsKey("vOverDayCount") ?
Integer.parseInt(partSum.get("vOverDayCount").toString()) : 0);
rStatSubstationMPO.setICount(partSum.containsKey("iOverDayCount") ?
Integer.parseInt(partSum.get("iOverDayCount").toString()) : 0);
rStatSubstationMPO.setUnbalanceCount(partSum.containsKey("unbalanceOverDayCount") ?
Integer.parseInt(partSum.get("unbalanceOverDayCount").toString()) : 0);
rStatSubstationMPO.setINegCount(partSum.containsKey("iNegOverDayCount") ?
Integer.parseInt(partSum.get("iNegOverDayCount").toString()) : 0);
} else {
rStatSubstationMPO.setHarmonicCount(0);
rStatSubstationMPO.setFreqCount(0);
rStatSubstationMPO.setVDevCount(0);
rStatSubstationMPO.setVCount(0);
rStatSubstationMPO.setICount(0);
rStatSubstationMPO.setUnbalanceCount(0);
rStatSubstationMPO.setINegCount(0);
}
if (!CollectionUtils.isEmpty(surplusSum)) {
rStatSubstationMPO.setFlickerCount(surplusSum.containsKey("flickerOverDayCount") ?
Integer.parseInt(surplusSum.get("flickerOverDayCount").toString()) : 0);
rStatSubstationMPO.setInuharmCount(surplusSum.containsKey("inuharmOverDayCount") ?
Integer.parseInt(surplusSum.get("inuharmOverDayCount").toString()) : 0);
} else {
rStatSubstationMPO.setFlickerCount(0);
rStatSubstationMPO.setInuharmCount(0);
}
if (!CollectionUtils.isEmpty(eventDetailSumAndCount)) {
rStatSubstationMPO.setEffectiveMeasurementAverage(eventDetailSumAndCount.containsKey("effectiveMeasurementCountAvg") ?
Float.parseFloat(eventDetailSumAndCount.get("effectiveMeasurementCountAvg").toString()) : 0.0f);
rStatSubstationMPO.setHarmonicOverDay(eventDetailSumAndCount.containsKey("harmonicCountCount") ?
Float.parseFloat(eventDetailSumAndCount.get("harmonicCountCount").toString()) : 0.0f);
rStatSubstationMPO.setFreqOverDay(eventDetailSumAndCount.containsKey("freqCountCount") ?
Float.parseFloat(eventDetailSumAndCount.get("freqCountCount").toString()) : 0.0f);
rStatSubstationMPO.setVDevOverDay(eventDetailSumAndCount.containsKey("vDevCountCount") ?
Float.parseFloat(eventDetailSumAndCount.get("vDevCountCount").toString()) : 0.0f);
rStatSubstationMPO.setVOverDay(eventDetailSumAndCount.containsKey("vCountCount") ?
Float.parseFloat(eventDetailSumAndCount.get("vCountCount").toString()) : 0.0f);
rStatSubstationMPO.setIOverDay(eventDetailSumAndCount.containsKey("iCountCount") ?
Float.parseFloat(eventDetailSumAndCount.get("iCountCount").toString()) : 0.0f);
rStatSubstationMPO.setUnbalanceOverDay(eventDetailSumAndCount.containsKey("unbalanceCountCount") ?
Float.parseFloat(eventDetailSumAndCount.get("unbalanceCountCount").toString()) : 0.0f);
rStatSubstationMPO.setINegOverDay(eventDetailSumAndCount.containsKey("iNegCountCount") ?
Float.parseFloat(eventDetailSumAndCount.get("iNegCountCount").toString()) : 0.0f);
rStatSubstationMPO.setFlickerOverDay(eventDetailSumAndCount.containsKey("flickerCountCount") ?
Float.parseFloat(eventDetailSumAndCount.get("flickerCountCount").toString()) : 0.0f);
rStatSubstationMPO.setInuharmOverDay(eventDetailSumAndCount.containsKey("inuharmCountCount") ?
Float.parseFloat(eventDetailSumAndCount.get("inuharmCountCount").toString()) : 0.0f);
rStatSubstationMPO.setEventCount(eventDetailSumAndCount.containsKey("eventCountSum") ?
Integer.parseInt(eventDetailSumAndCount.get("eventCountSum").toString()) : 0);
rStatSubstationMPO.setEventFreq(eventDetailSumAndCount.containsKey("eventCountFrequency") ?
Float.parseFloat(eventDetailSumAndCount.get("eventCountFrequency").toString()) : 0.0f);
rStatSubstationMPO.setSagCount(eventDetailSumAndCount.containsKey("sagCountSum") ?
Integer.parseInt(eventDetailSumAndCount.get("sagCountSum").toString()) : 0);
rStatSubstationMPO.setSagFreq(eventDetailSumAndCount.containsKey("sagCountFrequency") ?
Float.parseFloat(eventDetailSumAndCount.get("sagCountFrequency").toString()) : 0.0f);
rStatSubstationMPO.setSwellCount(eventDetailSumAndCount.containsKey("swellCountSum") ?
Integer.parseInt(eventDetailSumAndCount.get("swellCountSum").toString()) : 0);
rStatSubstationMPO.setSwellFreq(eventDetailSumAndCount.containsKey("swellCountFrequency") ?
Float.parseFloat(eventDetailSumAndCount.get("swellCountFrequency").toString()) : 0.0f);
rStatSubstationMPO.setInterruptCount(eventDetailSumAndCount.containsKey("interruptCountSum") ?
Integer.parseInt(eventDetailSumAndCount.get("interruptCountSum").toString()) : 0);
rStatSubstationMPO.setInterruptFreq(eventDetailSumAndCount.containsKey("interruptCountFrequency") ?
Float.parseFloat(eventDetailSumAndCount.get("interruptCountFrequency").toString()) : 0.0f);
} else {
rStatSubstationMPO.setEffectiveMeasurementAverage(0.0f);
rStatSubstationMPO.setHarmonicOverDay(0.0f);
rStatSubstationMPO.setFreqOverDay(0.0f);
rStatSubstationMPO.setVDevOverDay(0.0f);
rStatSubstationMPO.setVOverDay(0.0f);
rStatSubstationMPO.setIOverDay(0.0f);
rStatSubstationMPO.setUnbalanceOverDay(0.0f);
rStatSubstationMPO.setINegOverDay(0.0f);
rStatSubstationMPO.setFlickerOverDay(0.0f);
rStatSubstationMPO.setInuharmOverDay(0.0f);
rStatSubstationMPO.setEventCount(0);
rStatSubstationMPO.setEventFreq(0.0f);
rStatSubstationMPO.setSagCount(0);
rStatSubstationMPO.setSagFreq(0.0f);
rStatSubstationMPO.setSwellCount(0);
rStatSubstationMPO.setSwellFreq(0.0f);
rStatSubstationMPO.setInterruptCount(0);
rStatSubstationMPO.setInterruptFreq(0.0f);
}
rStatSubstationMPOS.add(rStatSubstationMPO);
}
}
});
}
if (!CollectionUtils.isEmpty(rStatSubstationMPOS)) { if (!CollectionUtils.isEmpty(rStatSubstationMPOS)) {
List<RStatSubstationMPO> collect = rStatSubstationMPOS.stream().distinct().collect(Collectors.toList()); List<RStatSubstationMPO> collect = rStatSubstationMPOS.stream().distinct().collect(Collectors.toList());
rStatSubstationMPOService.saveOrUpdateBatchByMultiId(collect, 500); rStatSubstationMPOService.saveOrUpdateBatchByMultiId(collect, 500);
@@ -696,6 +444,7 @@ public class RStatSubstationServiceImpl implements RStatSubstationService {
} }
//季表 //季表
@Async("asyncExecutor")
public void rStatSubstationQHandler(List<DeptGetSubStationDTO> data, String dataDate, Integer type) { public void rStatSubstationQHandler(List<DeptGetSubStationDTO> data, String dataDate, Integer type) {
List<RStatSubstationQPO> rStatSubstationQPOS = new ArrayList<>(); List<RStatSubstationQPO> rStatSubstationQPOS = new ArrayList<>();
Date date = DateUtil.parse(dataDate); Date date = DateUtil.parse(dataDate);
@@ -726,18 +475,25 @@ public class RStatSubstationServiceImpl implements RStatSubstationService {
} }
} }
List<String> zw = zwList.stream().distinct().collect(Collectors.toList()); zwList.addAll(pwList);
List<String> pw = pwList.stream().distinct().collect(Collectors.toList()); List<String> resultL = zwList.stream().distinct().collect(Collectors.toList());
//主网 if (!CollectionUtils.isEmpty(resultL)) {
if (!CollectionUtils.isEmpty(zw)) {
zw.forEach(z -> { resultL.forEach(z -> {
//获取监测点对象集合 //获取监测点对象集合
LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData(); LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData();
if (Objects.nonNull(lineDevGetDTOs.getZwList())) { if (Objects.nonNull(lineDevGetDTOs.getZwList()) || Objects.nonNull(lineDevGetDTOs.getPwList())) {
//获取监测点id集合 //获取监测点id集合
List<String> lineIds = lineDevGetDTOs.getZwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList()); List<String> lineIds = new ArrayList<>();
List<String> pLineIds = new ArrayList<>();
if (Objects.nonNull(lineDevGetDTOs.getZwList())) {
lineIds = lineDevGetDTOs.getZwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
}
if (Objects.nonNull(lineDevGetDTOs.getPwList())) {
pLineIds = lineDevGetDTOs.getPwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
lineIds.addAll(pLineIds);
}
//判空 //判空
if (!CollectionUtils.isEmpty(lineIds)) { if (!CollectionUtils.isEmpty(lineIds)) {
//r_mp_target_warn_d 表中字段求和 //r_mp_target_warn_d 表中字段求和
@@ -858,135 +614,6 @@ public class RStatSubstationServiceImpl implements RStatSubstationService {
} }
//配网
if (!CollectionUtils.isEmpty(pw)) {
pw.forEach(p -> {
//获取监测点对象集合
LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(p).getData();
if (Objects.nonNull(lineDevGetDTOs.getPwList())) {
//获取监测点id集合
List<String> lineIds = lineDevGetDTOs.getPwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
//判空
if (!CollectionUtils.isEmpty(lineIds)) {
//r_mp_target_warn_d 表中字段求和
Map<String, Object> warnSum = rMpTargetWarnDMapper.getSumDate(startTime, endTime, lineIds);
//r_stat_substation_d 表中字段求和及计数
Map<String, Object> eventDetailSumAndCountD = rStatSubstationDPOMapper.getSumAndCountQ(startTime, endTime, p);
//r_stat_substation_m 表中字段求和及计数
Map<String, Object> eventDetailSumAndCountM = rStatSubstationMPOMapper.getSumAndCount(startTime, endTime, p);
RStatSubstationQPO rStatSubstationQPO = new RStatSubstationQPO();
rStatSubstationQPO.setDataDate(localDate);
rStatSubstationQPO.setSubstationId(p);
if (!CollectionUtils.isEmpty(warnSum)) {
rStatSubstationQPO.setEffectiveMeasurementAccrued(warnSum.containsKey("iECount") ?
Integer.parseInt(warnSum.get("iECount").toString()) : 0);
} else {
rStatSubstationQPO.setEffectiveMeasurementAccrued(0);
}
if (!CollectionUtils.isEmpty(eventDetailSumAndCountM)) {
rStatSubstationQPO.setEffectiveMeasurementAverage(eventDetailSumAndCountM.containsKey("effectiveMeasurementCountAvg") ?
Float.parseFloat(eventDetailSumAndCountM.get("effectiveMeasurementCountAvg").toString()) : 0.0f);
rStatSubstationQPO.setHarmonicAverageOverDay(eventDetailSumAndCountM.containsKey("harmonicAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("harmonicAverageOverDay").toString()) : 0.0f);
rStatSubstationQPO.setFreqAverageOverDay(eventDetailSumAndCountM.containsKey("freqAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("freqAverageOverDay").toString()) : 0.0f);
rStatSubstationQPO.setVDevAverageOverDay(eventDetailSumAndCountM.containsKey("vDevAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("vDevAverageOverDay").toString()) : 0.0f);
rStatSubstationQPO.setVAverageOverDay(eventDetailSumAndCountM.containsKey("vAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("vAverageOverDay").toString()) : 0.0f);
rStatSubstationQPO.setIAverageOverDay(eventDetailSumAndCountM.containsKey("iAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("iAverageOverDay").toString()) : 0.0f);
rStatSubstationQPO.setUnbalanceAverageOverDay(eventDetailSumAndCountM.containsKey("unbalanceAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("unbalanceAverageOverDay").toString()) : 0.0f);
rStatSubstationQPO.setINegAverageOverDay(eventDetailSumAndCountM.containsKey("iNegAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("iNegAverageOverDay").toString()) : 0.0f);
rStatSubstationQPO.setFlickerAverageOverDay(eventDetailSumAndCountM.containsKey("flickerAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("flickerAverageOverDay").toString()) : 0.0f);
rStatSubstationQPO.setInuharmAverageOverDay(eventDetailSumAndCountM.containsKey("inuharmAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("inuharmAverageOverDay").toString()) : 0.0f);
rStatSubstationQPO.setEventCount(eventDetailSumAndCountM.containsKey("eventCountSum") ?
Integer.parseInt(eventDetailSumAndCountM.get("eventCountSum").toString()) : 0);
if (!Objects.equals("0", eventDetailSumAndCountD.get("eventMeasurementCountSum").toString())) {
String value = df.format(Float.parseFloat(eventDetailSumAndCountM.get("eventCountSum").toString())
/ Float.parseFloat(eventDetailSumAndCountD.get("eventMeasurementCountSum").toString()));
rStatSubstationQPO.setEventFreq(Float.parseFloat(value));
} else {
rStatSubstationQPO.setEventFreq(0.0f);
}
rStatSubstationQPO.setSagCount(eventDetailSumAndCountM.containsKey("sagCountSum") ?
Integer.parseInt(eventDetailSumAndCountM.get("sagCountSum").toString()) : 0);
if (!Objects.equals("0", eventDetailSumAndCountD.get("sagMeasurementCountSum").toString())) {
String value = df.format(Float.parseFloat(eventDetailSumAndCountM.get("sagCountSum").toString())
/ Float.parseFloat(eventDetailSumAndCountD.get("sagMeasurementCountSum").toString()));
rStatSubstationQPO.setSagFreq(Float.parseFloat(value));
} else {
rStatSubstationQPO.setSagFreq(0.0f);
}
rStatSubstationQPO.setSwellCount(eventDetailSumAndCountM.containsKey("swellCountSum") ?
Integer.parseInt(eventDetailSumAndCountM.get("swellCountSum").toString()) : 0);
if (!Objects.equals("0", eventDetailSumAndCountD.get("swellMeasurementCountSum").toString())) {
String value = df.format(Float.parseFloat(eventDetailSumAndCountM.get("swellCountSum").toString())
/ Float.parseFloat(eventDetailSumAndCountD.get("swellMeasurementCountSum").toString()));
rStatSubstationQPO.setSwellFreq(Float.parseFloat(value));
} else {
rStatSubstationQPO.setSwellFreq(0.0f);
}
rStatSubstationQPO.setInterruptCount(eventDetailSumAndCountM.containsKey("interruptCountSum") ?
Integer.parseInt(eventDetailSumAndCountM.get("interruptCountSum").toString()) : 0);
if (!Objects.equals("0", eventDetailSumAndCountD.get("interruptMeasurementCountSum").toString())) {
String value = df.format(Float.parseFloat(eventDetailSumAndCountM.get("interruptCountSum").toString())
/ Float.parseFloat(eventDetailSumAndCountD.get("interruptMeasurementCountSum").toString()));
rStatSubstationQPO.setInterruptFreq(Float.parseFloat(value));
} else {
rStatSubstationQPO.setInterruptFreq(0.0f);
}
} else {
rStatSubstationQPO.setEffectiveMeasurementAverage(0.0f);
rStatSubstationQPO.setHarmonicAverageOverDay(0.0f);
rStatSubstationQPO.setFreqAverageOverDay(0.0f);
rStatSubstationQPO.setVDevAverageOverDay(0.0f);
rStatSubstationQPO.setVAverageOverDay(0.0f);
rStatSubstationQPO.setIAverageOverDay(0.0f);
rStatSubstationQPO.setUnbalanceAverageOverDay(0.0f);
rStatSubstationQPO.setINegAverageOverDay(0.0f);
rStatSubstationQPO.setFlickerAverageOverDay(0.0f);
rStatSubstationQPO.setInuharmAverageOverDay(0.0f);
rStatSubstationQPO.setEventCount(0);
rStatSubstationQPO.setEventFreq(0.0f);
rStatSubstationQPO.setSagCount(0);
rStatSubstationQPO.setSagFreq(0.0f);
rStatSubstationQPO.setSwellCount(0);
rStatSubstationQPO.setSwellFreq(0.0f);
rStatSubstationQPO.setInterruptCount(0);
rStatSubstationQPO.setInterruptFreq(0.0f);
}
rStatSubstationQPOS.add(rStatSubstationQPO);
}
}
});
}
if (!CollectionUtils.isEmpty(rStatSubstationQPOS)) { if (!CollectionUtils.isEmpty(rStatSubstationQPOS)) {
List<RStatSubstationQPO> collect = rStatSubstationQPOS.stream().distinct().collect(Collectors.toList()); List<RStatSubstationQPO> collect = rStatSubstationQPOS.stream().distinct().collect(Collectors.toList());
rStatSubstationQPOService.saveOrUpdateBatchByMultiId(collect, 500); rStatSubstationQPOService.saveOrUpdateBatchByMultiId(collect, 500);
@@ -994,6 +621,7 @@ public class RStatSubstationServiceImpl implements RStatSubstationService {
} }
//年表 //年表
@Async("asyncExecutor")
public void rStatSubstationYHandler(List<DeptGetSubStationDTO> data, String dataDate, Integer type) { public void rStatSubstationYHandler(List<DeptGetSubStationDTO> data, String dataDate, Integer type) {
List<RStatSubstationYPO> rStatSubstationYPOS = new ArrayList<>(); List<RStatSubstationYPO> rStatSubstationYPOS = new ArrayList<>();
Date date = DateUtil.parse(dataDate); Date date = DateUtil.parse(dataDate);
@@ -1023,19 +651,25 @@ public class RStatSubstationServiceImpl implements RStatSubstationService {
} }
} }
List<String> zw = zwList.stream().distinct().collect(Collectors.toList()); zwList.addAll(pwList);
List<String> pw = pwList.stream().distinct().collect(Collectors.toList()); List<String> resultL = zwList.stream().distinct().collect(Collectors.toList());
//主网 if (!CollectionUtils.isEmpty(resultL)) {
if (!CollectionUtils.isEmpty(zw)) {
zw.forEach(z -> { resultL.forEach(z -> {
//获取监测点对象集合 //获取监测点对象集合
LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData(); LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData();
//判空 if (Objects.nonNull(lineDevGetDTOs.getZwList()) || Objects.nonNull(lineDevGetDTOs.getPwList())) {
if (Objects.nonNull(lineDevGetDTOs.getZwList())) {
//获取监测点id集合 //获取监测点id集合
List<String> lineIds = lineDevGetDTOs.getZwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList()); List<String> lineIds = new ArrayList<>();
List<String> pLineIds = new ArrayList<>();
if (Objects.nonNull(lineDevGetDTOs.getZwList())) {
lineIds = lineDevGetDTOs.getZwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
}
if (Objects.nonNull(lineDevGetDTOs.getPwList())) {
pLineIds = lineDevGetDTOs.getPwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
lineIds.addAll(pLineIds);
}
//判空 //判空
if (!CollectionUtils.isEmpty(lineIds)) { if (!CollectionUtils.isEmpty(lineIds)) {
//r_mp_target_warn_d 表中字段求和 //r_mp_target_warn_d 表中字段求和
@@ -1156,135 +790,6 @@ public class RStatSubstationServiceImpl implements RStatSubstationService {
} }
//配网
if (!CollectionUtils.isEmpty(pw)) {
pw.forEach(p -> {
//获取监测点对象集合
LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(p).getData();
if (Objects.nonNull(lineDevGetDTOs.getPwList())) {
//获取监测点id集合
List<String> lineIds = lineDevGetDTOs.getPwList().stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
//判空
if (!CollectionUtils.isEmpty(lineIds)) {
//r_mp_target_warn_d 表中字段求和
Map<String, Object> warnSum = rMpTargetWarnDMapper.getSumDate(startTime, endTime, lineIds);
//r_stat_substation_d 表中字段求和及计数
Map<String, Object> eventDetailSumAndCountD = rStatSubstationDPOMapper.getSumAndCountQ(startTime, endTime, p);
//r_stat_substation_m 表中字段求和及计数
Map<String, Object> eventDetailSumAndCountM = rStatSubstationMPOMapper.getSumAndCount(startTime, endTime, p);
RStatSubstationYPO rStatSubstationYPO = new RStatSubstationYPO();
rStatSubstationYPO.setDataDate(localDate);
rStatSubstationYPO.setSubstationId(p);
if (!CollectionUtils.isEmpty(warnSum)) {
rStatSubstationYPO.setEffectiveMeasurementAccrued(warnSum.containsKey("iECount") ?
Integer.parseInt(warnSum.get("iECount").toString()) : 0);
} else {
rStatSubstationYPO.setEffectiveMeasurementAccrued(0);
}
if (!CollectionUtils.isEmpty(eventDetailSumAndCountM)) {
rStatSubstationYPO.setEffectiveMeasurementAverage(eventDetailSumAndCountM.containsKey("effectiveMeasurementCountAvg") ?
Float.parseFloat(eventDetailSumAndCountM.get("effectiveMeasurementCountAvg").toString()) : 0.0f);
rStatSubstationYPO.setHarmonicAverageOverDay(eventDetailSumAndCountM.containsKey("harmonicAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("harmonicAverageOverDay").toString()) : 0.0f);
rStatSubstationYPO.setFreqAverageOverDay(eventDetailSumAndCountM.containsKey("freqAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("freqAverageOverDay").toString()) : 0.0f);
rStatSubstationYPO.setVDevAverageOverDay(eventDetailSumAndCountM.containsKey("vDevAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("vDevAverageOverDay").toString()) : 0.0f);
rStatSubstationYPO.setVAverageOverDay(eventDetailSumAndCountM.containsKey("vAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("vAverageOverDay").toString()) : 0.0f);
rStatSubstationYPO.setIAverageOverDay(eventDetailSumAndCountM.containsKey("iAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("iAverageOverDay").toString()) : 0.0f);
rStatSubstationYPO.setUnbalanceAverageOverDay(eventDetailSumAndCountM.containsKey("unbalanceAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("unbalanceAverageOverDay").toString()) : 0.0f);
rStatSubstationYPO.setINegAverageOverDay(eventDetailSumAndCountM.containsKey("iNegAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("iNegAverageOverDay").toString()) : 0.0f);
rStatSubstationYPO.setFlickerAverageOverDay(eventDetailSumAndCountM.containsKey("flickerAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("flickerAverageOverDay").toString()) : 0.0f);
rStatSubstationYPO.setInuharmAverageOverDay(eventDetailSumAndCountM.containsKey("inuharmAverageOverDay") ?
Float.parseFloat(eventDetailSumAndCountM.get("inuharmAverageOverDay").toString()) : 0.0f);
rStatSubstationYPO.setEventCount(eventDetailSumAndCountM.containsKey("eventCountSum") ?
Integer.parseInt(eventDetailSumAndCountM.get("eventCountSum").toString()) : 0);
if (!Objects.equals("0", eventDetailSumAndCountD.get("eventMeasurementCountSum").toString())) {
String value = df.format(Float.parseFloat(eventDetailSumAndCountM.get("eventCountSum").toString())
/ Float.parseFloat(eventDetailSumAndCountD.get("eventMeasurementCountSum").toString()));
rStatSubstationYPO.setEventFreq(Float.parseFloat(value));
} else {
rStatSubstationYPO.setEventFreq(0.0f);
}
rStatSubstationYPO.setSagCount(eventDetailSumAndCountM.containsKey("sagCountSum") ?
Integer.parseInt(eventDetailSumAndCountM.get("sagCountSum").toString()) : 0);
if (!Objects.equals("0", eventDetailSumAndCountD.get("sagMeasurementCountSum").toString())) {
String value = df.format(Float.parseFloat(eventDetailSumAndCountM.get("sagCountSum").toString())
/ Float.parseFloat(eventDetailSumAndCountD.get("sagMeasurementCountSum").toString()));
rStatSubstationYPO.setSagFreq(Float.parseFloat(value));
} else {
rStatSubstationYPO.setSagFreq(0.0f);
}
rStatSubstationYPO.setSwellCount(eventDetailSumAndCountM.containsKey("swellCountSum") ?
Integer.parseInt(eventDetailSumAndCountM.get("swellCountSum").toString()) : 0);
if (!Objects.equals("0", eventDetailSumAndCountD.get("swellMeasurementCountSum").toString())) {
String value = df.format(Float.parseFloat(eventDetailSumAndCountM.get("swellCountSum").toString())
/ Float.parseFloat(eventDetailSumAndCountD.get("swellMeasurementCountSum").toString()));
rStatSubstationYPO.setSwellFreq(Float.parseFloat(value));
} else {
rStatSubstationYPO.setSwellFreq(0.0f);
}
rStatSubstationYPO.setInterruptCount(eventDetailSumAndCountM.containsKey("interruptCountSum") ?
Integer.parseInt(eventDetailSumAndCountM.get("interruptCountSum").toString()) : 0);
if (!Objects.equals("0", eventDetailSumAndCountD.get("interruptMeasurementCountSum").toString())) {
String value = df.format(Float.parseFloat(eventDetailSumAndCountM.get("interruptCountSum").toString())
/ Float.parseFloat(eventDetailSumAndCountD.get("interruptMeasurementCountSum").toString()));
rStatSubstationYPO.setInterruptFreq(Float.parseFloat(value));
} else {
rStatSubstationYPO.setInterruptFreq(0.0f);
}
} else {
rStatSubstationYPO.setEffectiveMeasurementAverage(0.0f);
rStatSubstationYPO.setHarmonicAverageOverDay(0.0f);
rStatSubstationYPO.setFreqAverageOverDay(0.0f);
rStatSubstationYPO.setVDevAverageOverDay(0.0f);
rStatSubstationYPO.setVAverageOverDay(0.0f);
rStatSubstationYPO.setIAverageOverDay(0.0f);
rStatSubstationYPO.setUnbalanceAverageOverDay(0.0f);
rStatSubstationYPO.setINegAverageOverDay(0.0f);
rStatSubstationYPO.setFlickerAverageOverDay(0.0f);
rStatSubstationYPO.setInuharmAverageOverDay(0.0f);
rStatSubstationYPO.setEventCount(0);
rStatSubstationYPO.setEventFreq(0.0f);
rStatSubstationYPO.setSagCount(0);
rStatSubstationYPO.setSagFreq(0.0f);
rStatSubstationYPO.setSwellCount(0);
rStatSubstationYPO.setSwellFreq(0.0f);
rStatSubstationYPO.setInterruptCount(0);
rStatSubstationYPO.setInterruptFreq(0.0f);
}
rStatSubstationYPOS.add(rStatSubstationYPO);
}
}
});
}
if (!CollectionUtils.isEmpty(rStatSubstationYPOS)) { if (!CollectionUtils.isEmpty(rStatSubstationYPOS)) {
List<RStatSubstationYPO> collect = rStatSubstationYPOS.stream().distinct().collect(Collectors.toList()); List<RStatSubstationYPO> collect = rStatSubstationYPOS.stream().distinct().collect(Collectors.toList());
rStatSubstationYPOService.saveOrUpdateBatchByMultiId(collect, 500); rStatSubstationYPOService.saveOrUpdateBatchByMultiId(collect, 500);