From a03bd8006cfefe69c36010a9c35fc6bd53020675 Mon Sep 17 00:00:00 2001 From: xuyang <748613696@qq.com> Date: Wed, 15 Nov 2023 15:49:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=97=E6=B3=95=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../prepare/executor/MeasurementExecutor.java | 40 +- .../prepare/executor/SubStationExecutor.java | 46 + .../RStatSubstationController.java | 2 +- .../newalgorithm/RStatSubstationService.java | 28 +- .../impl/RStatSubstationServiceImpl.java | 990 ++++++++++++++---- 5 files changed, 905 insertions(+), 201 deletions(-) diff --git a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/executor/MeasurementExecutor.java b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/executor/MeasurementExecutor.java index 3dd55a208..f7db75630 100644 --- a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/executor/MeasurementExecutor.java +++ b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/executor/MeasurementExecutor.java @@ -10,6 +10,7 @@ import com.njcn.prepare.harmonic.service.mysql.line.RMpEventDetailDService; import com.njcn.prepare.harmonic.service.mysql.line.RMpEventDetailService; import com.njcn.prepare.harmonic.service.mysql.line.RMpMonitorEvaluateDService; import com.njcn.prepare.harmonic.service.mysql.line.*; +import com.njcn.prepare.harmonic.service.mysql.newalgorithm.RStatSubstationService; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; @@ -53,7 +54,8 @@ public class MeasurementExecutor extends BaseExecutor { private final PollutionService pollutionService; private final RStatDevSignalDPOService rStatDevSignalDPOService; private final RMpDevEvaluateDetailPOService rMpDevEvaluateDetailPOService; - private final NormalLimitService normLimitService; + private final RStatSubstationService rStatSubstationService; + /** * 算法名: 3.3.1.1-----监测点评价 @@ -263,12 +265,16 @@ public class MeasurementExecutor extends BaseExecutor { @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "partHarmonicDetail", nodeType = NodeTypeEnum.COMMON) public void partHarmonicDetailProcess(NodeComponent bindCmp) { String tag = bindCmp.getTag(); + CalculatedParam calculatedParam = bindCmp.getRequestData(); if (Objects.equals(tag,"r_mp_part_harmonic_detail_d")){ //日表 - mpPartHarmonicDetailDService.insertHarmonicDetailDayOne(bindCmp.getRequestData()); + mpPartHarmonicDetailDService.insertHarmonicDetailDayOne(calculatedParam); } else if (Objects.equals(tag,"r_mp_part_harmonic_detail_m")) { - //月表 - mpPartHarmonicDetailMService.insertHarmonicDetailMonthOne(bindCmp.getRequestData()); + //数据补招不执行非日表算法 + if (!calculatedParam.isRepair()) { + //月表 + mpPartHarmonicDetailMService.insertHarmonicDetailMonthOne(calculatedParam); + } } } @@ -286,12 +292,16 @@ public class MeasurementExecutor extends BaseExecutor { @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "surplusHarmonicDetail", nodeType = NodeTypeEnum.COMMON) public void surplusHarmonicDetailProcess(NodeComponent bindCmp) { String tag = bindCmp.getTag(); + CalculatedParam calculatedParam = bindCmp.getRequestData(); if (Objects.equals(tag,"r_mp_surplus_harmonic_detail_d")){ //日表 - mpSurplusHarmonicDetailDService.insertHarmonicDetailDayTwo(bindCmp.getRequestData()); + mpSurplusHarmonicDetailDService.insertHarmonicDetailDayTwo(calculatedParam); } else if (Objects.equals(tag,"r_mp_surplus_harmonic_detail_m")) { - //月表 - mpSurplusHarmonicDetailMService.insertHarmonicDetailMonthTwo(bindCmp.getRequestData()); + //数据补招不执行非日表算法 + if (!calculatedParam.isRepair()) { + //月表 + mpSurplusHarmonicDetailMService.insertHarmonicDetailMonthTwo(calculatedParam); + } } } @@ -339,12 +349,16 @@ public class MeasurementExecutor extends BaseExecutor { @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "rMpTargetWarn", nodeType = NodeTypeEnum.COMMON) public void rMpTargetWarnProcess(NodeComponent bindCmp) { String tag = bindCmp.getTag(); + CalculatedParam calculatedParam = bindCmp.getRequestData(); if (Objects.equals(tag,"r_mp_target_warn_d")){ //日表 - rMpTargetWarnDService.alarmDay(bindCmp.getRequestData()); + rMpTargetWarnDService.alarmDay(calculatedParam); } else if (Objects.equals(tag,"r_mp_target_warn_m")) { - //月表 - rMpMonitorAlarmCountMService.alarmMonth(bindCmp.getRequestData()); + //数据补招不执行非日表算法 + if (!calculatedParam.isRepair()) { + //月表 + rMpMonitorAlarmCountMService.alarmMonth(calculatedParam); + } } } @@ -377,11 +391,5 @@ public class MeasurementExecutor extends BaseExecutor { public void rMpDevEvaluateDetailProcess(NodeComponent bindCmp) { rMpDevEvaluateDetailPOService.devEvaluateDetail(bindCmp.getRequestData()); } - /********************************************算法负责人:xy结束***********************************************************/ - - - - - } diff --git a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/executor/SubStationExecutor.java b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/executor/SubStationExecutor.java index 22370f29f..afd905e59 100644 --- a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/executor/SubStationExecutor.java +++ b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/executor/SubStationExecutor.java @@ -6,6 +6,7 @@ import com.njcn.prepare.bo.CalculatedParam; import com.njcn.prepare.harmonic.service.mysql.area.RStatOrgService; import com.njcn.prepare.harmonic.service.mysql.line.PollutionService; import com.njcn.prepare.harmonic.service.mysql.newalgorithm.ROperatingIndexService; +import com.njcn.prepare.harmonic.service.mysql.newalgorithm.RStatSubstationService; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; @@ -13,6 +14,8 @@ import com.yomahub.liteflow.enums.LiteFlowMethodEnum; import com.yomahub.liteflow.enums.NodeTypeEnum; import lombok.RequiredArgsConstructor; +import java.util.Objects; + /** * Description: * Date: 2023/11/10 10:39【需求编号】 @@ -25,6 +28,7 @@ import lombok.RequiredArgsConstructor; public class SubStationExecutor extends BaseExecutor{ private final PollutionService pollutionService; + private final RStatSubstationService rStatSubstationService; /** @@ -62,4 +66,46 @@ public class SubStationExecutor extends BaseExecutor{ } } } + + + /********************************************算法负责人:xy***********************************************************/ + /** + * 算法名: 3.4.10-----变电站指标统计(r_stat_substation_*) + * + * @author xuyang + * @date 2023年11月15日 10:06 + */ + @LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "rStatSubstation", nodeType = NodeTypeEnum.COMMON) + public boolean rStatSubstationAccess(NodeComponent bindCmp) { + return isAccess(bindCmp); + } + @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "rStatSubstation", nodeType = NodeTypeEnum.COMMON) + public void rStatSubstationProcess(NodeComponent bindCmp) { + String tag = bindCmp.getTag(); + CalculatedParam calculatedParam = bindCmp.getRequestData(); + if (Objects.equals(tag,"r_stat_substation_d")){ + //日表 + rStatSubstationService.handlerD(calculatedParam); + } else if (Objects.equals(tag,"r_stat_substation_m")) { + //数据补招不执行非日表算法 + if (!calculatedParam.isRepair()) { + //月表 + rStatSubstationService.handlerM(calculatedParam); + } + } else if (Objects.equals(tag,"r_stat_substation_q")) { + //数据补招不执行非日表算法 + if (!calculatedParam.isRepair()) { + //季表 + rStatSubstationService.handlerQ(calculatedParam); + } + } else if (Objects.equals(tag,"r_stat_substation_y")) { + //数据补招不执行非日表算法 + if (!calculatedParam.isRepair()) { + //年表 + rStatSubstationService.handlerY(calculatedParam); + } + } + } + /********************************************算法负责人:xy结束***********************************************************/ + } diff --git a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/controller/newalgorithm/RStatSubstationController.java b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/controller/newalgorithm/RStatSubstationController.java index 86cf55229..49057d2ec 100644 --- a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/controller/newalgorithm/RStatSubstationController.java +++ b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/controller/newalgorithm/RStatSubstationController.java @@ -75,7 +75,7 @@ public class RStatSubstationController extends BaseController { List data = commTerminalGeneralClient.deptSubStation(deptGetLineParam).getData(); long start = System.currentTimeMillis(); - rStatSubstationService.handler(data,orgParam.getDataDate(),orgParam.getType()); +// rStatSubstationService.handler(data,orgParam.getDataDate(),orgParam.getType()); long end = System.currentTimeMillis(); System.out.println("该方法总耗时为 ---> "+(end-start)); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); diff --git a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/newalgorithm/RStatSubstationService.java b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/newalgorithm/RStatSubstationService.java index 9a0d37b21..70cd02aa9 100644 --- a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/newalgorithm/RStatSubstationService.java +++ b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/newalgorithm/RStatSubstationService.java @@ -1,6 +1,7 @@ package com.njcn.prepare.harmonic.service.mysql.newalgorithm; import com.njcn.device.biz.pojo.dto.DeptGetSubStationDTO; +import com.njcn.prepare.bo.CalculatedParam; import java.util.List; @@ -11,6 +12,31 @@ import java.util.List; public interface RStatSubstationService { - void handler(List data, String dataDate, Integer type); +// void handler(List data, String dataDate, Integer type); + + /** + * 3.4.10.1.变电站指标统计_日表 + * @param calculatedParam + * fixme 此算法运行速度很慢,后期需要优化改造 + */ + void handlerD(CalculatedParam calculatedParam); + + /** + * 3.4.10.2.变电站指标统计_月表 + * @param calculatedParam + */ + void handlerM(CalculatedParam calculatedParam); + + /** + * 3.4.10.3.变电站指标统计_季表 + * @param calculatedParam + */ + void handlerQ(CalculatedParam calculatedParam); + + /** + * 3.4.10.4.变电站指标统计_年表 + * @param calculatedParam + */ + void handlerY(CalculatedParam calculatedParam); } diff --git a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/newalgorithm/impl/RStatSubstationServiceImpl.java b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/newalgorithm/impl/RStatSubstationServiceImpl.java index 1b395d6ee..fc60ae30b 100644 --- a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/newalgorithm/impl/RStatSubstationServiceImpl.java +++ b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/newalgorithm/impl/RStatSubstationServiceImpl.java @@ -1,6 +1,9 @@ package com.njcn.prepare.harmonic.service.mysql.newalgorithm.impl; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.date.LocalDateTimeUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.njcn.device.biz.commApi.CommTerminalGeneralClient; import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO; @@ -11,6 +14,7 @@ import com.njcn.harmonic.pojo.po.RMpEventDetailDPO; import com.njcn.harmonic.pojo.po.RMpEventDetailMPO; import com.njcn.harmonic.pojo.po.RStatOrgDPO; import com.njcn.harmonic.pojo.po.RStatOrgMPO; +import com.njcn.prepare.bo.CalculatedParam; import com.njcn.prepare.harmonic.mapper.mysql.area.*; import com.njcn.prepare.harmonic.mapper.mysql.line.*; import com.njcn.prepare.harmonic.mapper.mysql.newalgorithm.RStatEventDPOMapper; @@ -24,13 +28,18 @@ import com.njcn.system.enums.DicDataEnum; import com.njcn.system.enums.DicDataTypeEnum; import com.njcn.system.pojo.po.DictData; import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.ListUtils; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; @@ -47,6 +56,7 @@ import java.util.stream.Collectors; */ @Service @RequiredArgsConstructor +@Slf4j public class RStatSubstationServiceImpl implements RStatSubstationService { private final CommTerminalGeneralClient commTerminalGeneralClient; @@ -75,51 +85,42 @@ public class RStatSubstationServiceImpl implements RStatSubstationService { private final RStatSubstationMPOMapper rStatSubstationMPOMapper; +// @Override +// public void handler(List data, String dataDate, Integer type) { +// switch (type) { +// case 1: +// this.rStatSubstationYHandler(data, dataDate, type); +// break; +// case 2: +// this.rStatSubstationQHandler(data, dataDate, type); +// break; +// case 3: +// this.rStatSubstationMHandler(data, dataDate, type); +// break; +// case 5: +// this.rStatSubstationDHandler(data, dataDate, type); +// break; +// default: +// break; +// } +// } + + @Override - public void handler(List data, String dataDate, Integer type) { - switch (type) { - case 1: - this.rStatSubstationYHandler(data, dataDate, type); - break; - case 2: - this.rStatSubstationQHandler(data, dataDate, type); - break; - case 3: - this.rStatSubstationMHandler(data, dataDate, type); - break; - case 5: - this.rStatSubstationDHandler(data, dataDate, type); - break; - default: - break; - } - } - - //天表 + @Transactional(rollbackFor = {Exception.class}) @Async("asyncExecutor") - public void rStatSubstationDHandler(List data, String dataDate, Integer type) { + @SneakyThrows + public void handlerD(CalculatedParam calculatedParam) { + log.info(LocalDateTime.now()+"===>变电站指标统计日表算法开始"); List rStatSubstationDPOS = new ArrayList<>(); - Date date = DateUtil.parse(dataDate); - LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); - - List zwList = new ArrayList<>(); - List pwList = new ArrayList<>(); - - for (DeptGetSubStationDTO datum : data) { - if (!CollectionUtils.isEmpty(datum.getStationIds())) { - zwList.addAll(datum.getStationIds()); - } - if (!CollectionUtils.isEmpty(datum.getPwStationIds())) { - pwList.addAll(datum.getPwStationIds()); - } - } - - zwList.addAll(pwList); - List resultL = zwList.stream().distinct().collect(Collectors.toList()); - - if (!CollectionUtils.isEmpty(resultL)) { - - resultL.forEach(z -> { + String beginDay = LocalDateTimeUtil.format(LocalDateTimeUtil.beginOfDay(LocalDateTimeUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)),DatePattern.NORM_DATETIME_PATTERN); + String endDay = LocalDateTimeUtil.format(LocalDateTimeUtil.endOfDay(LocalDateTimeUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)),DatePattern.NORM_DATETIME_PATTERN); + //变电站id + List subIds = calculatedParam.getIdList(); + //以尺寸100分片,查询数据 + List> pendingIds = ListUtils.partition(subIds,100); + for (List pendingId : pendingIds) { + pendingId.forEach(z -> { //获取监测点对象集合 LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData(); if (Objects.nonNull(lineDevGetDTOs.getZwList()) || Objects.nonNull(lineDevGetDTOs.getPwList())) { @@ -136,18 +137,17 @@ public class RStatSubstationServiceImpl implements RStatSubstationService { //判空 if (!CollectionUtils.isEmpty(lineIds)) { int sw = 0, sa = 0, in = 0, result = 0; - //r_mp_target_warn_d 表中字段求和 - Map warnSum = rMpTargetWarnDMapper.getSumDate(dataDate, dataDate, lineIds); + Map warnSum = rMpTargetWarnDMapper.getSumDate(beginDay, endDay, lineIds); //r_mp_part_harmonic_detail_d 表中字段求和 - Map partSum = rMpPartHarmonicDetailDMapper.getPartSum(dataDate, dataDate, lineIds); + Map partSum = rMpPartHarmonicDetailDMapper.getPartSum(beginDay, endDay, lineIds); //r_mp_surplus_harmonic_detail_d 表中字段求和 - Map surplusSum = mpSurplusHarmonicDetailDMapper.getSurplusSum(dataDate, dataDate, lineIds); + Map surplusSum = mpSurplusHarmonicDetailDMapper.getSurplusSum(beginDay, endDay, lineIds); //r_mp_event_detail_d 表中字段求和及计数 - Map eventDetailSumAndCount = rMpEventDetailDMapper.getSumAndCount(dataDate, dataDate, lineIds); + Map eventDetailSumAndCount = rMpEventDetailDMapper.getSumAndCount(beginDay, endDay, lineIds); RStatSubstationDPO rStatSubstationDPO = new RStatSubstationDPO(); - rStatSubstationDPO.setDataDate(localDate); + rStatSubstationDPO.setDataDate(LocalDateTimeUtil.parseDate(calculatedParam.getDataDate(),DatePattern.NORM_DATE_FORMATTER)); rStatSubstationDPO.setSubstationId(z); if (!CollectionUtils.isEmpty(warnSum)) { @@ -191,7 +191,6 @@ public class RStatSubstationServiceImpl implements RStatSubstationService { rStatSubstationDPO.setFlickerCount(0); rStatSubstationDPO.setInuharmCount(0); } - if (!CollectionUtils.isEmpty(eventDetailSumAndCount)) { rStatSubstationDPO.setEventMeasurementCount(eventDetailSumAndCount.containsKey("resultCount") ? Integer.parseInt(eventDetailSumAndCount.get("resultCount").toString()) : 0); @@ -231,52 +230,28 @@ public class RStatSubstationServiceImpl implements RStatSubstationService { } } }); - } - if (!CollectionUtils.isEmpty(rStatSubstationDPOS)) { - List collect = rStatSubstationDPOS.stream().distinct().collect(Collectors.toList()); - rStatSubstationDPOService.saveOrUpdateBatchByMultiId(collect, 500); - + rStatSubstationDPOService.saveOrUpdateBatchByMultiId(rStatSubstationDPOS, 100); } } - //月表 + @Override + @Transactional(rollbackFor = {Exception.class}) @Async("asyncExecutor") - public void rStatSubstationMHandler(List data, String dataDate, Integer type) { + @SneakyThrows + public void handlerM(CalculatedParam calculatedParam) { + log.info(LocalDateTime.now()+"===>变电站指标统计月表算法开始"); List rStatSubstationMPOS = new ArrayList<>(); - Date date = DateUtil.parse(dataDate); - LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); - //传入字符串日期获取月的起始日期与结束日期 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - - calendar.set(Calendar.DAY_OF_MONTH, 1); // 将日期设置为当月的第一天 - String startTime = sdf.format(calendar.getTime()); // 获取当月的起始日期 - - calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); // 将日期设置为当月的最后一天 - String endTime = sdf.format(calendar.getTime());// 获取当月的结束日期 - - List zwList = new ArrayList<>(); - List pwList = new ArrayList<>(); - - for (DeptGetSubStationDTO datum : data) { - if (!CollectionUtils.isEmpty(datum.getStationIds())) { - zwList.addAll(datum.getStationIds()); - } - if (!CollectionUtils.isEmpty(datum.getPwStationIds())) { - pwList.addAll(datum.getPwStationIds()); - } - } - - zwList.addAll(pwList); - List resultL = zwList.stream().distinct().collect(Collectors.toList()); - - if (!CollectionUtils.isEmpty(resultL)) { - - resultL.forEach(z -> { + String beginMonth = DateUtil.beginOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)).toString(DatePattern.NORM_DATE_PATTERN); + String endMonth = DateUtil.endOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)).toString(DatePattern.NORM_DATE_PATTERN); + //变电站id + List subIds = calculatedParam.getIdList(); + //以尺寸100分片,查询数据 + List> pendingIds = ListUtils.partition(subIds,100); + for (List pendingId : pendingIds) { + pendingId.forEach(z -> { //获取监测点对象集合 LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData(); if (Objects.nonNull(lineDevGetDTOs.getZwList()) || Objects.nonNull(lineDevGetDTOs.getPwList())) { @@ -292,16 +267,16 @@ public class RStatSubstationServiceImpl implements RStatSubstationService { } if (!CollectionUtils.isEmpty(lineIds)) { //r_mp_target_warn_d 表中字段求和 - Map warnSum = rMpTargetWarnDMapper.getSumDate(startTime, endTime, lineIds); + Map warnSum = rMpTargetWarnDMapper.getSumDate(beginMonth, endMonth, lineIds); //r_mp_part_harmonic_detail_m 表中字段求和 - Map partSum = rMpPartHarmonicDetailMMapper.getPartSum(startTime, endTime, lineIds); + Map partSum = rMpPartHarmonicDetailMMapper.getPartSum(beginMonth, endMonth, lineIds); //r_mp_surplus_harmonic_detail_m 表中字段求和 - Map surplusSum = mpSurplusHarmonicDetailMMapper.getSurplusSum(startTime, endTime, lineIds); + Map surplusSum = mpSurplusHarmonicDetailMMapper.getSurplusSum(beginMonth, endMonth, lineIds); //r_stat_substation_d 表中字段求和及计数 - Map eventDetailSumAndCount = rStatSubstationDPOMapper.getSumAndCount(startTime, endTime, z); + Map eventDetailSumAndCount = rStatSubstationDPOMapper.getSumAndCount(beginMonth, endMonth, z); RStatSubstationMPO rStatSubstationMPO = new RStatSubstationMPO(); - rStatSubstationMPO.setDataDate(localDate); + rStatSubstationMPO.setDataDate(LocalDateTimeUtil.parseDate(beginMonth,DatePattern.NORM_DATE_FORMATTER)); rStatSubstationMPO.setSubstationId(z); if (!CollectionUtils.isEmpty(warnSum)) { @@ -434,53 +409,28 @@ public class RStatSubstationServiceImpl implements RStatSubstationService { } } }); - } - if (!CollectionUtils.isEmpty(rStatSubstationMPOS)) { - List collect = rStatSubstationMPOS.stream().distinct().collect(Collectors.toList()); - rStatSubstationMPOService.saveOrUpdateBatchByMultiId(collect, 500); + rStatSubstationMPOService.saveOrUpdateBatchByMultiId(rStatSubstationMPOS, 500); } } - //季表 + @Override + @Transactional(rollbackFor = {Exception.class}) @Async("asyncExecutor") - public void rStatSubstationQHandler(List data, String dataDate, Integer type) { - List rStatSubstationQPOS = new ArrayList<>(); - Date date = DateUtil.parse(dataDate); - LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + @SneakyThrows + public void handlerQ(CalculatedParam calculatedParam) { + log.info(LocalDateTime.now()+"===>变电站指标统计季表算法开始"); DecimalFormat df = new DecimalFormat("0.00"); - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - // 计算季度的开始日期和结束日期 - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - int quarter = (calendar.get(Calendar.MONTH) / 3) + 1; // 计算日期所在的季度 - calendar.set(Calendar.MONTH, (quarter - 1) * 3); // 设置季度开始的月份 - calendar.set(Calendar.DAY_OF_MONTH, 1); // 设置季度开始的日期 - String startTime = sdf.format(calendar.getTime());// 季度开始日期 - calendar.add(Calendar.MONTH, 2); // 添加两个月,使其到季度结束的月份 - calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); // 设置季度结束的日期 - 月份最后一天 - String endTime = sdf.format(calendar.getTime()); // 季度结束日期 - - List zwList = new ArrayList<>(); - List pwList = new ArrayList<>(); - - for (DeptGetSubStationDTO datum : data) { - if (!CollectionUtils.isEmpty(datum.getStationIds())) { - zwList.addAll(datum.getStationIds()); - } - if (!CollectionUtils.isEmpty(datum.getPwStationIds())) { - pwList.addAll(datum.getPwStationIds()); - } - } - - zwList.addAll(pwList); - List resultL = zwList.stream().distinct().collect(Collectors.toList()); - - if (!CollectionUtils.isEmpty(resultL)) { - - resultL.forEach(z -> { + List rStatSubstationQPOS = new ArrayList<>(); + String beginQuarter = DateUtil.beginOfQuarter(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)).toString(DatePattern.NORM_DATE_PATTERN); + String endQuarter = DateUtil.endOfQuarter(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)).toString(DatePattern.NORM_DATE_PATTERN); + //变电站id + List subIds = calculatedParam.getIdList(); + //以尺寸100分片,查询数据 + List> pendingIds = ListUtils.partition(subIds,100); + for (List pendingId : pendingIds) { + pendingId.forEach(z -> { //获取监测点对象集合 LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData(); if (Objects.nonNull(lineDevGetDTOs.getZwList()) || Objects.nonNull(lineDevGetDTOs.getPwList())) { @@ -497,14 +447,14 @@ public class RStatSubstationServiceImpl implements RStatSubstationService { //判空 if (!CollectionUtils.isEmpty(lineIds)) { //r_mp_target_warn_d 表中字段求和 - Map warnSum = rMpTargetWarnDMapper.getSumDate(startTime, endTime, lineIds); + Map warnSum = rMpTargetWarnDMapper.getSumDate(beginQuarter, endQuarter, lineIds); //r_stat_substation_d 表中字段求和及计数 - Map eventDetailSumAndCountD = rStatSubstationDPOMapper.getSumAndCountQ(startTime, endTime, z); + Map eventDetailSumAndCountD = rStatSubstationDPOMapper.getSumAndCountQ(beginQuarter, endQuarter, z); //r_stat_substation_m 表中字段求和及计数 - Map eventDetailSumAndCountM = rStatSubstationMPOMapper.getSumAndCount(startTime, endTime, z); + Map eventDetailSumAndCountM = rStatSubstationMPOMapper.getSumAndCount(beginQuarter, endQuarter, z); RStatSubstationQPO rStatSubstationQPO = new RStatSubstationQPO(); - rStatSubstationQPO.setDataDate(localDate); + rStatSubstationQPO.setDataDate(LocalDateTimeUtil.parseDate(beginQuarter,DatePattern.NORM_DATE_FORMATTER)); rStatSubstationQPO.setSubstationId(z); if (!CollectionUtils.isEmpty(warnSum)) { rStatSubstationQPO.setEffectiveMeasurementAccrued(warnSum.containsKey("iECount") ? @@ -611,52 +561,28 @@ public class RStatSubstationServiceImpl implements RStatSubstationService { } } }); - } - if (!CollectionUtils.isEmpty(rStatSubstationQPOS)) { - List collect = rStatSubstationQPOS.stream().distinct().collect(Collectors.toList()); - rStatSubstationQPOService.saveOrUpdateBatchByMultiId(collect, 500); + rStatSubstationQPOService.saveOrUpdateBatchByMultiId(rStatSubstationQPOS, 100); } } - //年表 + @Override + @Transactional(rollbackFor = {Exception.class}) @Async("asyncExecutor") - public void rStatSubstationYHandler(List data, String dataDate, Integer type) { - List rStatSubstationYPOS = new ArrayList<>(); - Date date = DateUtil.parse(dataDate); - LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + @SneakyThrows + public void handlerY(CalculatedParam calculatedParam) { + log.info(LocalDateTime.now()+"===>变电站指标统计年表算法开始"); DecimalFormat df = new DecimalFormat("0.00"); - - // 获取当前年的起始日期和结束日期 - LocalDate date1 = LocalDate.parse(dataDate, DateTimeFormatter.ISO_DATE); // 将字符串解析为LocalDate对象 - - // 获取当年的开始天 - LocalDate yearStartDate = date1.withDayOfYear(1); - String startTime = yearStartDate.format(DateTimeFormatter.ISO_DATE); // 将LocalDate对象转换为字符串日期 - - // 获取当年的结束天 - LocalDate yearEndDate = date1.withDayOfYear(date1.lengthOfYear()); - String endTime = yearEndDate.format(DateTimeFormatter.ISO_DATE); // 将LocalDate对象转换为字符串日期 - - List zwList = new ArrayList<>(); - List pwList = new ArrayList<>(); - - for (DeptGetSubStationDTO datum : data) { - if (!CollectionUtils.isEmpty(datum.getStationIds())) { - zwList.addAll(datum.getStationIds()); - } - if (!CollectionUtils.isEmpty(datum.getPwStationIds())) { - pwList.addAll(datum.getPwStationIds()); - } - } - - zwList.addAll(pwList); - List resultL = zwList.stream().distinct().collect(Collectors.toList()); - - if (!CollectionUtils.isEmpty(resultL)) { - - resultL.forEach(z -> { + List rStatSubstationYPOS = new ArrayList<>(); + String beginYear = DateUtil.beginOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)).toString(DatePattern.NORM_DATE_PATTERN); + String endYear = DateUtil.endOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)).toString(DatePattern.NORM_DATE_PATTERN); + //变电站id + List subIds = calculatedParam.getIdList(); + //以尺寸100分片,查询数据 + List> pendingIds = ListUtils.partition(subIds,100); + for (List pendingId : pendingIds) { + pendingId.forEach(z -> { //获取监测点对象集合 LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData(); if (Objects.nonNull(lineDevGetDTOs.getZwList()) || Objects.nonNull(lineDevGetDTOs.getPwList())) { @@ -673,14 +599,14 @@ public class RStatSubstationServiceImpl implements RStatSubstationService { //判空 if (!CollectionUtils.isEmpty(lineIds)) { //r_mp_target_warn_d 表中字段求和 - Map warnSum = rMpTargetWarnDMapper.getSumDate(startTime, endTime, lineIds); + Map warnSum = rMpTargetWarnDMapper.getSumDate(beginYear, endYear, lineIds); //r_stat_substation_d 表中字段求和及计数 - Map eventDetailSumAndCountD = rStatSubstationDPOMapper.getSumAndCountQ(startTime, endTime, z); + Map eventDetailSumAndCountD = rStatSubstationDPOMapper.getSumAndCountQ(beginYear, endYear, z); //r_stat_substation_m 表中字段求和及计数 - Map eventDetailSumAndCountM = rStatSubstationMPOMapper.getSumAndCount(startTime, endTime, z); + Map eventDetailSumAndCountM = rStatSubstationMPOMapper.getSumAndCount(beginYear, endYear, z); RStatSubstationYPO rStatSubstationYPO = new RStatSubstationYPO(); - rStatSubstationYPO.setDataDate(localDate); + rStatSubstationYPO.setDataDate(LocalDateTimeUtil.parseDate(beginYear,DatePattern.NORM_DATE_FORMATTER)); rStatSubstationYPO.setSubstationId(z); if (!CollectionUtils.isEmpty(warnSum)) { rStatSubstationYPO.setEffectiveMeasurementAccrued(warnSum.containsKey("iECount") ? @@ -787,13 +713,711 @@ public class RStatSubstationServiceImpl implements RStatSubstationService { } } }); - } - if (!CollectionUtils.isEmpty(rStatSubstationYPOS)) { - List collect = rStatSubstationYPOS.stream().distinct().collect(Collectors.toList()); - rStatSubstationYPOService.saveOrUpdateBatchByMultiId(collect, 500); + rStatSubstationYPOService.saveOrUpdateBatchByMultiId(rStatSubstationYPOS, 100); } } + +// //天表 +// @Async("asyncExecutor") +// public void rStatSubstationDHandler(List data, String dataDate, Integer type) { +// List rStatSubstationDPOS = new ArrayList<>(); +// Date date = DateUtil.parse(dataDate); +// LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); +// +// List zwList = new ArrayList<>(); +// List pwList = new ArrayList<>(); +// +// for (DeptGetSubStationDTO datum : data) { +// if (!CollectionUtils.isEmpty(datum.getStationIds())) { +// zwList.addAll(datum.getStationIds()); +// } +// if (!CollectionUtils.isEmpty(datum.getPwStationIds())) { +// pwList.addAll(datum.getPwStationIds()); +// } +// } +// +// zwList.addAll(pwList); +// List resultL = zwList.stream().distinct().collect(Collectors.toList()); +// +// if (!CollectionUtils.isEmpty(resultL)) { +// +// resultL.forEach(z -> { +// //获取监测点对象集合 +// LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData(); +// if (Objects.nonNull(lineDevGetDTOs.getZwList()) || Objects.nonNull(lineDevGetDTOs.getPwList())) { +// //获取监测点id集合 +// List lineIds = new ArrayList<>(); +// List 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)) { +// int sw = 0, sa = 0, in = 0, result = 0; +// +// //r_mp_target_warn_d 表中字段求和 +// Map warnSum = rMpTargetWarnDMapper.getSumDate(dataDate, dataDate, lineIds); +// //r_mp_part_harmonic_detail_d 表中字段求和 +// Map partSum = rMpPartHarmonicDetailDMapper.getPartSum(dataDate, dataDate, lineIds); +// //r_mp_surplus_harmonic_detail_d 表中字段求和 +// Map surplusSum = mpSurplusHarmonicDetailDMapper.getSurplusSum(dataDate, dataDate, lineIds); +// //r_mp_event_detail_d 表中字段求和及计数 +// Map eventDetailSumAndCount = rMpEventDetailDMapper.getSumAndCount(dataDate, dataDate, lineIds); +// +// RStatSubstationDPO rStatSubstationDPO = new RStatSubstationDPO(); +// rStatSubstationDPO.setDataDate(localDate); +// rStatSubstationDPO.setSubstationId(z); +// +// 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)) { +// List collect = rStatSubstationDPOS.stream().distinct().collect(Collectors.toList()); +// rStatSubstationDPOService.saveOrUpdateBatchByMultiId(collect, 500); +// +// } +// } + +// //月表 +// @Async("asyncExecutor") +// public void rStatSubstationMHandler(List data, String dataDate, Integer type) { +// List rStatSubstationMPOS = new ArrayList<>(); +// Date date = DateUtil.parse(dataDate); +// LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); +// +// //传入字符串日期获取月的起始日期与结束日期 +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); +// Calendar calendar = Calendar.getInstance(); +// calendar.setTime(date); +// +// calendar.set(Calendar.DAY_OF_MONTH, 1); // 将日期设置为当月的第一天 +// String startTime = sdf.format(calendar.getTime()); // 获取当月的起始日期 +// +// calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); // 将日期设置为当月的最后一天 +// String endTime = sdf.format(calendar.getTime());// 获取当月的结束日期 +// +// List zwList = new ArrayList<>(); +// List pwList = new ArrayList<>(); +// +// for (DeptGetSubStationDTO datum : data) { +// if (!CollectionUtils.isEmpty(datum.getStationIds())) { +// zwList.addAll(datum.getStationIds()); +// } +// if (!CollectionUtils.isEmpty(datum.getPwStationIds())) { +// pwList.addAll(datum.getPwStationIds()); +// } +// } +// +// zwList.addAll(pwList); +// List resultL = zwList.stream().distinct().collect(Collectors.toList()); +// +// if (!CollectionUtils.isEmpty(resultL)) { +// +// resultL.forEach(z -> { +// //获取监测点对象集合 +// LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData(); +// if (Objects.nonNull(lineDevGetDTOs.getZwList()) || Objects.nonNull(lineDevGetDTOs.getPwList())) { +// //获取监测点id集合 +// List lineIds = new ArrayList<>(); +// List 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)) { +// //r_mp_target_warn_d 表中字段求和 +// Map warnSum = rMpTargetWarnDMapper.getSumDate(startTime, endTime, lineIds); +// //r_mp_part_harmonic_detail_m 表中字段求和 +// Map partSum = rMpPartHarmonicDetailMMapper.getPartSum(startTime, endTime, lineIds); +// //r_mp_surplus_harmonic_detail_m 表中字段求和 +// Map surplusSum = mpSurplusHarmonicDetailMMapper.getSurplusSum(startTime, endTime, lineIds); +// //r_stat_substation_d 表中字段求和及计数 +// Map eventDetailSumAndCount = rStatSubstationDPOMapper.getSumAndCount(startTime, endTime, z); +// +// RStatSubstationMPO rStatSubstationMPO = new RStatSubstationMPO(); +// rStatSubstationMPO.setDataDate(localDate); +// rStatSubstationMPO.setSubstationId(z); +// +// 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)) { +// List collect = rStatSubstationMPOS.stream().distinct().collect(Collectors.toList()); +// rStatSubstationMPOService.saveOrUpdateBatchByMultiId(collect, 500); +// } +// } + +// //季表 +// @Async("asyncExecutor") +// public void rStatSubstationQHandler(List data, String dataDate, Integer type) { +// List rStatSubstationQPOS = new ArrayList<>(); +// Date date = DateUtil.parse(dataDate); +// LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); +// DecimalFormat df = new DecimalFormat("0.00"); +// +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); +// // 计算季度的开始日期和结束日期 +// Calendar calendar = Calendar.getInstance(); +// calendar.setTime(date); +// int quarter = (calendar.get(Calendar.MONTH) / 3) + 1; // 计算日期所在的季度 +// calendar.set(Calendar.MONTH, (quarter - 1) * 3); // 设置季度开始的月份 +// calendar.set(Calendar.DAY_OF_MONTH, 1); // 设置季度开始的日期 +// String startTime = sdf.format(calendar.getTime());// 季度开始日期 +// calendar.add(Calendar.MONTH, 2); // 添加两个月,使其到季度结束的月份 +// calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); // 设置季度结束的日期 - 月份最后一天 +// String endTime = sdf.format(calendar.getTime()); // 季度结束日期 +// +// List zwList = new ArrayList<>(); +// List pwList = new ArrayList<>(); +// +// for (DeptGetSubStationDTO datum : data) { +// if (!CollectionUtils.isEmpty(datum.getStationIds())) { +// zwList.addAll(datum.getStationIds()); +// } +// if (!CollectionUtils.isEmpty(datum.getPwStationIds())) { +// pwList.addAll(datum.getPwStationIds()); +// } +// } +// +// zwList.addAll(pwList); +// List resultL = zwList.stream().distinct().collect(Collectors.toList()); +// +// if (!CollectionUtils.isEmpty(resultL)) { +// +// resultL.forEach(z -> { +// //获取监测点对象集合 +// LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData(); +// if (Objects.nonNull(lineDevGetDTOs.getZwList()) || Objects.nonNull(lineDevGetDTOs.getPwList())) { +// //获取监测点id集合 +// List lineIds = new ArrayList<>(); +// List 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)) { +// //r_mp_target_warn_d 表中字段求和 +// Map warnSum = rMpTargetWarnDMapper.getSumDate(startTime, endTime, lineIds); +// //r_stat_substation_d 表中字段求和及计数 +// Map eventDetailSumAndCountD = rStatSubstationDPOMapper.getSumAndCountQ(startTime, endTime, z); +// //r_stat_substation_m 表中字段求和及计数 +// Map eventDetailSumAndCountM = rStatSubstationMPOMapper.getSumAndCount(startTime, endTime, z); +// +// RStatSubstationQPO rStatSubstationQPO = new RStatSubstationQPO(); +// rStatSubstationQPO.setDataDate(localDate); +// rStatSubstationQPO.setSubstationId(z); +// 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)) { +// List collect = rStatSubstationQPOS.stream().distinct().collect(Collectors.toList()); +// rStatSubstationQPOService.saveOrUpdateBatchByMultiId(collect, 500); +// } +// } + +// //年表 +// @Async("asyncExecutor") +// public void rStatSubstationYHandler(List data, String dataDate, Integer type) { +// List rStatSubstationYPOS = new ArrayList<>(); +// Date date = DateUtil.parse(dataDate); +// LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); +// DecimalFormat df = new DecimalFormat("0.00"); +// +// // 获取当前年的起始日期和结束日期 +// LocalDate date1 = LocalDate.parse(dataDate, DateTimeFormatter.ISO_DATE); // 将字符串解析为LocalDate对象 +// +// // 获取当年的开始天 +// LocalDate yearStartDate = date1.withDayOfYear(1); +// String startTime = yearStartDate.format(DateTimeFormatter.ISO_DATE); // 将LocalDate对象转换为字符串日期 +// +// // 获取当年的结束天 +// LocalDate yearEndDate = date1.withDayOfYear(date1.lengthOfYear()); +// String endTime = yearEndDate.format(DateTimeFormatter.ISO_DATE); // 将LocalDate对象转换为字符串日期 +// +// List zwList = new ArrayList<>(); +// List pwList = new ArrayList<>(); +// +// for (DeptGetSubStationDTO datum : data) { +// if (!CollectionUtils.isEmpty(datum.getStationIds())) { +// zwList.addAll(datum.getStationIds()); +// } +// if (!CollectionUtils.isEmpty(datum.getPwStationIds())) { +// pwList.addAll(datum.getPwStationIds()); +// } +// } +// +// zwList.addAll(pwList); +// List resultL = zwList.stream().distinct().collect(Collectors.toList()); +// +// if (!CollectionUtils.isEmpty(resultL)) { +// +// resultL.forEach(z -> { +// //获取监测点对象集合 +// LineDevGetBandDTO lineDevGetDTOs = commTerminalGeneralClient.substationGetLine(z).getData(); +// if (Objects.nonNull(lineDevGetDTOs.getZwList()) || Objects.nonNull(lineDevGetDTOs.getPwList())) { +// //获取监测点id集合 +// List lineIds = new ArrayList<>(); +// List 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)) { +// //r_mp_target_warn_d 表中字段求和 +// Map warnSum = rMpTargetWarnDMapper.getSumDate(startTime, endTime, lineIds); +// //r_stat_substation_d 表中字段求和及计数 +// Map eventDetailSumAndCountD = rStatSubstationDPOMapper.getSumAndCountQ(startTime, endTime, z); +// //r_stat_substation_m 表中字段求和及计数 +// Map eventDetailSumAndCountM = rStatSubstationMPOMapper.getSumAndCount(startTime, endTime, z); +// +// RStatSubstationYPO rStatSubstationYPO = new RStatSubstationYPO(); +// rStatSubstationYPO.setDataDate(localDate); +// rStatSubstationYPO.setSubstationId(z); +// 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)) { +// List collect = rStatSubstationYPOS.stream().distinct().collect(Collectors.toList()); +// rStatSubstationYPOService.saveOrUpdateBatchByMultiId(collect, 500); +// } +// } }