diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/CommunicateServiceImpl.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/CommunicateServiceImpl.java index a34fc98aa..2b34ab8d2 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/CommunicateServiceImpl.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/CommunicateServiceImpl.java @@ -2,33 +2,26 @@ package com.njcn.device.pq.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; -import com.njcn.device.pq.mapper.OnlineRateMapper; import com.njcn.device.pq.mapper.RStatIntegrityDMapper; import com.njcn.device.pq.mapper.RStatOnlinerateDMapper; import com.njcn.device.pq.pojo.param.OnlineRateParam; import com.njcn.device.pq.pojo.param.PulicTimeParam; import com.njcn.device.pq.pojo.param.PulicTimeStatisParam; -import com.njcn.device.pq.pojo.po.LineDataIntegrity; -import com.njcn.device.pq.pojo.po.RStatOnlinerateD; import com.njcn.device.pq.pojo.vo.*; import com.njcn.device.pq.service.CommunicateService; -import com.njcn.device.pq.service.IRStatOnlinerateDService; import com.njcn.device.pq.service.LineService; import com.njcn.device.pq.utils.PublicDateUtil; import com.njcn.influxdb.utils.InfluxDbUtils; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import org.apache.commons.lang.StringUtils; -import org.influxdb.dto.QueryResult; import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.*; -import static com.njcn.influxdb.param.InfluxDBPublicParam.*; /** * @author denghuajun @@ -97,30 +90,48 @@ public class CommunicateServiceImpl implements CommunicateService { deviceOnlineDataList.add(inter); } } else { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date dt = simpleDateFormat.parse(pulicTimeParam.getSearchBeginTime()); - Date dtDate = simpleDateFormat.parse(pulicTimeParam.getSearchEndTime()); - Integer year = Integer.valueOf(String.format("%tY", dt)); - Integer mon = Integer.valueOf(String.format("%tm", dt)); - Integer day = Integer.valueOf(String.format("%td", dtDate)); - List intervalTime = this.getIntervalDateTime(year, mon,day); - for (String interTime : intervalTime) { - DeviceOnlineDataVO inter = new DeviceOnlineDataVO(); - String startTime, endTime; - inter.setMonth(interTime.substring(5, 7)); - inter.setYear(interTime.substring(0, 4)); - inter.setDay(interTime.substring(8)); - startTime =sdf.format(DateUtil.beginOfDay(DateUtil.parse(interTime))); - endTime = sdf.format(DateUtil.endOfDay(DateUtil.parse(interTime))); - floatList = getCondition(devId, startTime, endTime, 1); - if (floatList == 0) { - inter.setOnlineRate(3.14159f); - } else { - inter.setOnlineRate(Float.parseFloat(decimalFormat.format(floatList))); + List intervalTime = this.getIntervalTime(pulicTimeParam.getSearchBeginTime(),pulicTimeParam.getSearchEndTime()); + for (int j = 0; j < intervalTime.size(); j++) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date dt ; + Date dtDate; + if(j==0){ + dt= simpleDateFormat.parse(pulicTimeParam.getSearchBeginTime()); + }else{ + String startTime = PublicDateUtil.getFisrtDayOfMonth(Integer.parseInt(intervalTime.get(j).substring(0, 4)), Integer.parseInt(intervalTime.get(j).substring(5))); + dt= simpleDateFormat.parse(startTime); + + } + int beginDay = Integer.valueOf(String.format("%td", dt)); + if(j==intervalTime.size()-1){ + dtDate= simpleDateFormat.parse(pulicTimeParam.getSearchEndTime()); + }else{ + String startTime = PublicDateUtil.getLastDayOfMonth(Integer.parseInt(intervalTime.get(j).substring(0, 4)), Integer.parseInt(intervalTime.get(j).substring(5))); + dtDate= simpleDateFormat.parse(startTime); + } + Integer year = Integer.valueOf(String.format("%tY", dt)); + Integer mon = Integer.valueOf(String.format("%tm", dt)); + + Integer day = Integer.valueOf(String.format("%td", dtDate)); + List dayTime = this.getIntervalDateTime(year,beginDay, mon, day); + for (String interTime : dayTime) { + DeviceOnlineDataVO inter = new DeviceOnlineDataVO(); + String startTime, endTime; + inter.setMonth(interTime.substring(5, 7)); + inter.setYear(interTime.substring(0, 4)); + inter.setDay(interTime.substring(8)); + startTime =simpleDateFormat.format(DateUtil.beginOfDay(DateUtil.parse(interTime))); + endTime = simpleDateFormat.format(DateUtil.endOfDay(DateUtil.parse(interTime))); + floatList = getCondition(devId, startTime, endTime, 1); + if (floatList == 0) { + inter.setOnlineRate(3.14159f); + } else { + inter.setOnlineRate(Float.parseFloat(decimalFormat.format(floatList))); + } + deviceOnlineDataList.add(inter); } - deviceOnlineDataList.add(inter); } + } return deviceOnlineDataList; } @@ -290,13 +301,13 @@ public class CommunicateServiceImpl implements CommunicateService { } @SneakyThrows - private List getIntervalDateTime(Integer startTime, Integer endTime,Integer dd) { + private List getIntervalDateTime(Integer startTime, int beginDay,Integer endTime,Integer dd) { List list = new ArrayList<>(); Calendar calendar = Calendar.getInstance(Locale.CHINA); calendar.set(startTime, endTime - 1, 1); int year = calendar.get(Calendar.YEAR);//年份 int month = calendar.get(Calendar.MONTH) + 1;//月份 - for (int i = 1; i <= dd; i++) { + for (int i = beginDay; i <= dd; i++) { String date = null; if (month < 10 && i < 10) { date = year + "-0" + month + "-0" + i; diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/api/EventDetailFeignClient.java b/pqs-event/event-api/src/main/java/com/njcn/event/api/EventDetailFeignClient.java index 9a2678cee..a40b8c1b3 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/api/EventDetailFeignClient.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/api/EventDetailFeignClient.java @@ -4,12 +4,15 @@ import com.njcn.common.pojo.constant.ServerInfo; import com.njcn.common.pojo.response.HttpResult; import com.njcn.event.api.fallback.EventDetailFeignClientFallbackFactory; import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.vo.GeneralVO; +import io.swagger.annotations.ApiOperation; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import java.util.List; +import java.util.Map; /** * @author denghuajun @@ -41,4 +44,11 @@ public interface EventDetailFeignClient { @PostMapping("/getEventDetailLimit") HttpResult> getEventDetailLimit(@RequestBody List lineIndexes, @RequestParam("startTime")String startTime, @RequestParam("endTime")String endTime,@RequestParam("pageSize") Integer pageSize,@RequestParam("pageNum") Integer pageNum); + /** + * 根据监测点集合获取短时终端,电压暂升,电压暂降数量 + * @return 暂降事件信息 + */ + @PostMapping("/getEventDetailCount") + HttpResult> getEventDetailCount(@RequestBody Map condMap); + } diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/EventDetailFeignClientFallbackFactory.java b/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/EventDetailFeignClientFallbackFactory.java index 8571ed99f..23f1a994c 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/EventDetailFeignClientFallbackFactory.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/EventDetailFeignClientFallbackFactory.java @@ -5,12 +5,14 @@ import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.response.HttpResult; import com.njcn.event.api.EventDetailFeignClient; import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.vo.GeneralVO; import com.njcn.event.utils.EventlEnumUtil; import feign.hystrix.FallbackFactory; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import java.util.List; +import java.util.Map; /** * @author denghuajun @@ -48,6 +50,12 @@ public class EventDetailFeignClientFallbackFactory implements FallbackFactory> getEventDetailCount(Map condMap) { + log.error("{}异常,降级处理,异常为:{}", "根据监测点集合获取短时终端,电压暂升,电压暂降数量", throwable.toString()); + throw new BusinessException(finalExceptionEnum); + } + }; } } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/EventDetailController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/EventDetailController.java index 834e13b49..8e1671e0e 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/EventDetailController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/EventDetailController.java @@ -6,7 +6,9 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.LogUtil; +import com.njcn.event.mapper.majornetwork.EventDetailMapper; import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.vo.GeneralVO; import com.njcn.event.service.majornetwork.EventDetailService; import com.njcn.web.controller.BaseController; import io.swagger.annotations.Api; @@ -20,6 +22,7 @@ import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * @author denghuajun @@ -35,6 +38,7 @@ import java.util.List; public class EventDetailController extends BaseController { private final EventDetailService eventDetailService; + private final EventDetailMapper eventDetailMapper; /** * 获取暂降事件 @@ -124,6 +128,17 @@ public class EventDetailController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } - + /** + * 根据监测点集合获取短时终端,电压暂升,电压暂降 + * @return + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getEventDetailCount") + @ApiOperation("根据监测点集合获取各个监测点的统计类型数量") + public HttpResult> getEventDetail(@RequestBody Map condMap) { + String methodDescribe = getMethodDescribe("getEventDetail"); + List generalVOS = eventDetailMapper.ListEventType(condMap); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, generalVOS, methodDescribe); + } } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/mapping/EventDetailMapper.xml b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/mapping/EventDetailMapper.xml index 20196c9b7..fe45bb7d8 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/mapping/EventDetailMapper.xml +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/mapping/EventDetailMapper.xml @@ -18,9 +18,9 @@ diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java index 2f58b1e2c..e35103909 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java @@ -1083,7 +1083,7 @@ public class ReportServiceImpl implements ReportService { sheetAt.setColumnWidth(0, 24 * 256); sheetAt.setColumnWidth(1, 24 * 256); sheetAt.setColumnWidth(2, 24 * 256); - sheetAt.setColumnWidth(3, 24 * 256); + sheetAt.setColumnWidth(3, 44 * 256); sheetAt.setColumnWidth(4, 24 * 256); sheetAt.setColumnWidth(5, 24 * 256); sheetAt.setColumnWidth(6, 24 * 256); @@ -1164,7 +1164,7 @@ public class ReportServiceImpl implements ReportService { cell6.setCellValue(vo.getLoadType()); cell7.setCellValue(vo.getFeatureAmplitude()*100); cell8.setCellValue(vo.getDuration()); - cell9.setCellValue(vo.getSeverity()); + cell9.setCellValue(BigDecimal.valueOf(vo.getSeverity()).setScale(2, RoundingMode.HALF_UP).doubleValue()); } } @@ -1279,11 +1279,11 @@ public class ReportServiceImpl implements ReportService { sheetAt.setColumnWidth(0, 24 * 256); sheetAt.setColumnWidth(1, 24 * 256); sheetAt.setColumnWidth(2, 24 * 256); - sheetAt.setColumnWidth(3, 24 * 256); + sheetAt.setColumnWidth(3, 44 * 256); sheetAt.setColumnWidth(4, 24 * 256); sheetAt.setColumnWidth(5, 24 * 256); sheetAt.setColumnWidth(6, 24 * 256); - sheetAt.setColumnWidth(7, 24 * 256); + sheetAt.setColumnWidth(7, 50 * 256); sheetAt.setColumnWidth(8, 24 * 256); sheetAt.setColumnWidth(9, 24 * 256); sheetAt.setColumnWidth(10, 24 * 256); @@ -1320,9 +1320,9 @@ public class ReportServiceImpl implements ReportService { setCellStyle(r1Cell4, "监测点", cellStyle); setCellStyle(r1Cell5, "监测点电压等级", cellStyle); setCellStyle(r1Cell6, "干扰源类型", cellStyle); - setCellStyle(r1Cell7, "暂降(骤升)幅值(%)", cellStyle); - setCellStyle(r1Cell8, "持续时间(s)", cellStyle); - setCellStyle(r1Cell9, "暂态事件严重度", cellStyle); + setCellStyle(r1Cell7, "监测点对象名称", cellStyle); + setCellStyle(r1Cell8, "暂降(骤升)幅值(%)", cellStyle); + setCellStyle(r1Cell9, "持续时间(s)", cellStyle); setCellStyle(r1Cell10, "暂态类型(机器判断)", cellStyle); List severity = sheetDetailed(businessParam); for (int i = 0; i < severity.size(); i++) { @@ -1360,7 +1360,7 @@ public class ReportServiceImpl implements ReportService { cell4.setCellValue(vo.getLineName()); cell5.setCellValue(vo.getVoltageScale()); cell6.setCellValue(vo.getLoadType()); - cell7.setCellValue(vo.getObjName()); + cell7.setCellValue(vo.getObjName()==null||vo.getObjName()==""?"/":vo.getObjName()); cell8.setCellValue(vo.getFeatureAmplitude()*100); cell9.setCellValue(vo.getDuration()); cell10.setCellValue(vo.getAdvanceType()); @@ -1370,11 +1370,11 @@ public class ReportServiceImpl implements ReportService { public void sheet5(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){ sheets.createSheet("暂降次数统计"); HSSFSheet sheetAt = sheets.getSheetAt(4); - sheetAt.setColumnWidth(0, 9 * 256); - sheetAt.setColumnWidth(1, 24 * 256); + sheetAt.setColumnWidth(0, 24 * 256); + sheetAt.setColumnWidth(1, 30 * 256); sheetAt.setColumnWidth(2, 24 * 256); - sheetAt.setColumnWidth(3, 24 * 256); - sheetAt.setColumnWidth(4, 24 * 256); + sheetAt.setColumnWidth(3, 50 * 256); + sheetAt.setColumnWidth(4, 44 * 256); sheetAt.setColumnWidth(5, 24 * 256); sheetAt.setColumnWidth(6, 24 * 256); sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 0, 0)); @@ -1427,7 +1427,7 @@ public class ReportServiceImpl implements ReportService { cell0.setCellValue(i+1); cell1.setCellValue(vo.getLineName()); cell2.setCellValue(vo.getLoadType()); - cell3.setCellValue(vo.getObjName()); + cell3.setCellValue(vo.getObjName()==null||vo.getObjName()==""?"/":vo.getObjName()); cell4.setCellValue(vo.getSubName()); cell5.setCellValue(vo.getGdName()); cell6.setCellValue(vo.getTimes()); @@ -1437,11 +1437,11 @@ public class ReportServiceImpl implements ReportService { public void sheet6(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){ sheets.createSheet("暂升次数统计"); HSSFSheet sheetAt = sheets.getSheetAt(5); - sheetAt.setColumnWidth(0, 9 * 256); - sheetAt.setColumnWidth(1, 24 * 256); + sheetAt.setColumnWidth(0, 24 * 256); + sheetAt.setColumnWidth(1, 30 * 256); sheetAt.setColumnWidth(2, 24 * 256); - sheetAt.setColumnWidth(3, 24 * 256); - sheetAt.setColumnWidth(4, 24 * 256); + sheetAt.setColumnWidth(3, 50 * 256); + sheetAt.setColumnWidth(4, 44 * 256); sheetAt.setColumnWidth(5, 24 * 256); sheetAt.setColumnWidth(6, 24 * 256); sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 0, 0)); @@ -1494,7 +1494,7 @@ public class ReportServiceImpl implements ReportService { cell0.setCellValue(i+1); cell1.setCellValue(vo.getLineName()); cell2.setCellValue(vo.getLoadType()); - cell3.setCellValue(vo.getObjName()); + cell3.setCellValue(vo.getObjName()==null||vo.getObjName()==""?"/":vo.getObjName()); cell4.setCellValue(vo.getSubName()); cell5.setCellValue(vo.getGdName()); cell6.setCellValue(vo.getTimes()); @@ -1504,11 +1504,11 @@ public class ReportServiceImpl implements ReportService { public void sheet7(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){ sheets.createSheet("短时中断次数统计"); HSSFSheet sheetAt = sheets.getSheetAt(6); - sheetAt.setColumnWidth(0, 9 * 256); - sheetAt.setColumnWidth(1, 24 * 256); + sheetAt.setColumnWidth(0, 24 * 256); + sheetAt.setColumnWidth(1, 30 * 256); sheetAt.setColumnWidth(2, 24 * 256); - sheetAt.setColumnWidth(3, 24 * 256); - sheetAt.setColumnWidth(4, 24 * 256); + sheetAt.setColumnWidth(3, 50 * 256); + sheetAt.setColumnWidth(4, 44 * 256); sheetAt.setColumnWidth(5, 24 * 256); sheetAt.setColumnWidth(6, 24 * 256); sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 0, 0)); @@ -1561,7 +1561,7 @@ public class ReportServiceImpl implements ReportService { cell0.setCellValue(i+1); cell1.setCellValue(vo.getLineName()); cell2.setCellValue(vo.getLoadType()); - cell3.setCellValue(vo.getObjName()); + cell3.setCellValue(vo.getObjName()==null||vo.getObjName()==""?"/":vo.getObjName()); cell4.setCellValue(vo.getSubName()); cell5.setCellValue(vo.getGdName()); cell6.setCellValue(vo.getTimes()); diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/AnalyzeServiceImpl.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/AnalyzeServiceImpl.java index 50c94c0c4..7986ac388 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/AnalyzeServiceImpl.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/AnalyzeServiceImpl.java @@ -2,11 +2,11 @@ package com.njcn.harmonic.service.impl; import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.CharUtil; +import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; @@ -18,6 +18,7 @@ import com.njcn.device.pq.pojo.dto.OverLimitLineDTO; import com.njcn.device.pq.pojo.dto.PollutionParamDTO; import com.njcn.device.pq.pojo.dto.WarningSubstationDTO; import com.njcn.event.api.EventDetailFeignClient; +import com.njcn.event.pojo.vo.GeneralVO; import com.njcn.harmonic.constant.Param; import com.njcn.harmonic.mapper.RStatLimitRateDMapper; import com.njcn.harmonic.mapper.RStatLimitTargetMapper; @@ -27,7 +28,6 @@ import com.njcn.harmonic.pojo.excel.monitor.MonitorExcel; import com.njcn.harmonic.pojo.excel.monitor.OverLimitDays; import com.njcn.harmonic.pojo.excel.monitor.UTimes; import com.njcn.harmonic.pojo.excel.substation.SubstationExcel; -import com.njcn.harmonic.pojo.po.EventDetail; import com.njcn.harmonic.pojo.po.LimitTarget; import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO; import com.njcn.harmonic.pojo.po.day.RStatLimitTargetDPO; @@ -55,6 +55,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.time.Instant; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -132,7 +133,7 @@ public class AnalyzeServiceImpl implements IAnalyzeService { List line = new ArrayList<>(), subInfo = new ArrayList<>(); List substationDTOList = new ArrayList<>(); Map> map = new HashMap<>(); - Map> map2 = new HashMap<>(); + Map map2 = new HashMap<>(); param.setServerName(generalInfo.getMicroServiceName()); List list = new ArrayList<>(); List subList = generalDeviceInfoClient.getPracticalRunDeviceInfoAsSubstation(param).getData(); @@ -152,9 +153,9 @@ public class AnalyzeServiceImpl implements IAnalyzeService { if (!CollectionUtils.isEmpty(limitRateList)) { map = limitRateList.stream().collect(Collectors.groupingBy(RStatLimitRateDPO::getLineId)); } - List eventDetailList = getEventDetail(line, param.getSearchBeginTime(), param.getSearchEndTime()); + List eventDetailList = getEventDetail(line, param.getSearchBeginTime(), param.getSearchEndTime(), eventStatis); if (!CollectionUtils.isEmpty(eventDetailList)) { - map2 = eventDetailList.stream().collect(Collectors.groupingBy(com.njcn.event.pojo.po.EventDetail::getLineId)); + map2 = eventDetailList.stream().collect(Collectors.toMap(GeneralVO::getId, Function.identity())); } } for (GeneralDeviceDTO item : temList) { @@ -213,27 +214,15 @@ public class AnalyzeServiceImpl implements IAnalyzeService { } } //暂降统计 - if (!CollectionUtils.isEmpty(map2.get(item2))) { - List eventDetailList = map2.get(item2); - if (!CollectionUtils.isEmpty(eventDetailList)) { - for (com.njcn.event.pojo.po.EventDetail item3 : eventDetailList) { - String eventType = item3.getEventType(); - List code = eventStatis.stream().filter(x -> x.getId().equals(eventType)) - .map(DictData::getCode).collect(Collectors.toList()); - if (CollUtil.isNotEmpty(code)) { - if (DicDataEnum.VOLTAGE_DIP.getCode().equals(code.get(0))) { - eventDowns++; - } - if (DicDataEnum.VOLTAGE_RISE.getCode().equals(code.get(0))) { - eventUps++; - } - if (DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(code.get(0))) { - eventInterrupts++; - } - - } - - } + if (ObjectUtil.isNotNull(map2.get(item2))) { + GeneralVO eventDetailList = map2.get(item2); + if (ObjectUtil.isNotNull(eventDetailList)) { + //电压暂降 + eventDowns += eventDetailList.getSagsCount(); + //电压暂升 + eventUps += eventDetailList.getUpCount(); + //电压暂升 + eventInterrupts += eventDetailList.getBreakCount(); } } if (eventDowns > 0) { @@ -781,8 +770,16 @@ public class AnalyzeServiceImpl implements IAnalyzeService { return result; } - public List getEventDetail(List list, String startTime, String endTime) { - return eventDetailFeignClient.getEventDetail(list, startTime, endTime).getData(); + public List getEventDetail(List list, String startTime, String endTime, List eventStatis) { + Map dictMap = eventStatis.stream().collect(Collectors.toMap(DictData::getCode, DictData::getId)); + HashMap condMap = new HashMap<>(); + condMap.put("startTime", DateUtil.beginOfDay(DateUtil.parse(startTime)).toString()); + condMap.put("endTime", DateUtil.endOfDay(DateUtil.parse(endTime)).toString()); + condMap.put("ids", list); + condMap.put(DicDataEnum.VOLTAGE_DIP.getCode(), dictMap.get(DicDataEnum.VOLTAGE_DIP.getCode())); //电压暂降 + condMap.put(DicDataEnum.SHORT_INTERRUPTIONS.getCode(), dictMap.get(DicDataEnum.SHORT_INTERRUPTIONS.getCode())); //短时中断 + condMap.put(DicDataEnum.VOLTAGE_RISE.getCode(), dictMap.get(DicDataEnum.VOLTAGE_RISE.getCode())); //电压暂升 + return eventDetailFeignClient.getEventDetailCount(condMap).getData(); } public List getOverDays(List list, String startTime, String endTime) {