diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/GridDiagramEventController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/GridDiagramEventController.java new file mode 100644 index 000000000..49b9a0f88 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/GridDiagramEventController.java @@ -0,0 +1,52 @@ +package com.njcn.event.controller.majornetwork; + +import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.enums.common.LogEnum; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.common.utils.HttpResultUtil; +import com.njcn.device.pq.pojo.vo.GridDiagramVO; +import com.njcn.event.service.majornetwork.RmpEventDetailService; +import com.njcn.harmonic.pojo.param.StatSubstationBizBaseParam; +import com.njcn.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + + +@Validated +@Slf4j +@RestController +@RequestMapping("/gridDiagram") +@Api(tags = "冀北电网一张图信息展示") +@AllArgsConstructor +public class GridDiagramEventController extends BaseController { + + private final RmpEventDetailService rmpEventDetailService; + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getEventLevelEvaluation") + @ApiOperation("暂态电能质量水平评价") + public HttpResult getSubLineGiveAnAlarm(@RequestBody StatSubstationBizBaseParam param) { + String methodDescribe = getMethodDescribe("getSubLineGiveAnAlarm"); + GridDiagramVO eventLevelEvaluation = rmpEventDetailService.getEventLevelEvaluation(param); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventLevelEvaluation, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getEventStatisticsList") + @ApiOperation("暂态统计详情") + public HttpResult> getEventStatisticsList(@RequestBody StatSubstationBizBaseParam param) { + String methodDescribe = getMethodDescribe("getEventStatisticsList"); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/RmpEventDetailServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/RmpEventDetailServiceImpl.java index fef9d961e..550aecd01 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/RmpEventDetailServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/RmpEventDetailServiceImpl.java @@ -4,12 +4,17 @@ 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.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.common.pojo.dto.SimpleDTO; import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.device.biz.commApi.CommTerminalGeneralClient; +import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO; +import com.njcn.device.biz.pojo.dto.LineDevGetDTO; +import com.njcn.device.biz.pojo.param.DeptGetLineParam; import com.njcn.device.pms.api.DistributionMonitorClient; import com.njcn.device.pms.api.MonitorClient; import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient; @@ -22,16 +27,19 @@ import com.njcn.device.pms.pojo.po.Monitor; import com.njcn.device.pq.api.GeneralDeviceInfoClient; import com.njcn.device.pq.api.LineFeignClient; import com.njcn.device.pq.pojo.vo.AreaLineInfoVO; +import com.njcn.device.pq.pojo.vo.GridDiagramVO; import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper; import com.njcn.event.pojo.param.UniversalFrontEndParam; import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.vo.*; import com.njcn.event.service.majornetwork.RmpEventDetailService; +import com.njcn.harmonic.pojo.param.StatSubstationBizBaseParam; import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.enums.DicDataTypeEnum; import com.njcn.event.enums.EventResponseEnum; import com.njcn.system.pojo.po.DictData; import com.njcn.user.api.DeptFeignClient; +import com.njcn.user.pojo.dto.DeptDTO; import com.njcn.web.factory.PageFactory; import com.njcn.web.pojo.param.BaseParam; import com.njcn.web.utils.RequestUtil; @@ -72,7 +80,7 @@ public class RmpEventDetailServiceImpl extends ServiceImpl info = new ArrayList<>(); + List gwInfo = new ArrayList<>(); + + //获取部门数据关系 + List data = deptFeignClient.getDepSonDetailByDeptId(param.getId()).getData(); + List deptIDS = data.stream().map(x -> x.getId()).collect(Collectors.toList()); + DeptGetLineParam deptGetLineParam = new DeptGetLineParam(); + deptGetLineParam.setDeptId(param.getId()); + List deptGetChildrenMoreDTOS = commTerminalGeneralClient.deptGetLine(deptGetLineParam).getData(); + List collect = deptGetChildrenMoreDTOS.stream() + .filter(x->deptIDS.contains(x.getUnitId())) + .flatMap(x -> x.getLineBaseList().stream()).collect(Collectors.toList()); + + List lineAllIds = collect.stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList()); + List gwLineAllIds = collect.stream().filter(x->1==x.getIsUpToGrid()).map(LineDevGetDTO::getPointId).collect(Collectors.toList()); + + List list = this.list(new LambdaQueryWrapper() + .in(CollUtil.isNotEmpty(lineAllIds), RmpEventDetailPO::getMeasurementPointId, lineAllIds) + .ge(StrUtil.isNotBlank(param.getStartTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))) + .le(StrUtil.isNotBlank(param.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))) + ); + + Map deptLineMap = deptGetChildrenMoreDTOS.stream().collect(Collectors.toMap(DeptGetChildrenMoreDTO::getUnitId, Function.identity())); + GridDiagramVO.LineStatistics lineStatistics; + GridDiagramVO.LineStatistics gwLineStatistics; + for (DeptDTO datum : data) { + if (deptLineMap.containsKey(datum.getId())) { + lineStatistics = new GridDiagramVO.LineStatistics(); + lineStatistics.setOrgId(datum.getId()); + lineStatistics.setOrgName(datum.getName()); + gwLineStatistics = new GridDiagramVO.LineStatistics(); + gwLineStatistics.setOrgId(datum.getId()); + gwLineStatistics.setOrgName(datum.getName()); + List lineBaseList = deptLineMap.get(datum.getId()).getLineBaseList(); + List lineIds = lineBaseList.stream().map(LineDevGetDTO::getPointId).distinct().collect(Collectors.toList()); + List gwLineIds = lineBaseList.stream().filter(x -> 1==x.getIsUpToGrid()).map(LineDevGetDTO::getPointId).distinct().collect(Collectors.toList()); + long count = list.stream().filter(x -> lineIds.contains(x.getMeasurementPointId())).map(RmpEventDetailPO::getEventId).count(); + long gwCount = list.stream().filter(x -> gwLineIds.contains(x.getMeasurementPointId())).map(RmpEventDetailPO::getEventId).count(); + lineStatistics.setCount(count); + gwLineStatistics.setCount(gwCount); + info.add(lineStatistics); + gwInfo.add(gwLineStatistics); + } + } + gridDiagramVO.setData(setData(gridDiagramVO, lineAllIds, list)); + gridDiagramVO.setGwData(setData(gridDiagramVO, gwLineAllIds, list)); + setData(gridDiagramVO, gwLineAllIds, list); + gridDiagramVO.setInfo(info); + gridDiagramVO.setGwInfo(gwInfo); + return gridDiagramVO; + } + + + private Double setData(GridDiagramVO gridDiagramVO, List gwLineAllIds, List list) { + List asGwDouble = list.stream() + .filter(x -> ObjectUtil.isNotNull(x.getSeverity())) + .filter(x -> gwLineAllIds.contains(x.getMeasurementPointId())) + .map(RmpEventDetailPO::getSeverity).collect(Collectors.toList()); + if(CollUtil.isNotEmpty(asGwDouble)){ + return asGwDouble.stream().mapToDouble(Double::doubleValue).average().getAsDouble(); + }else{ + return 0.0; + } + } + /** * 内部枚举类:高级算法处理事件的标识描述 */ diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/RmpEventDetailService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/RmpEventDetailService.java index 43ddad8ba..0f40c76e7 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/RmpEventDetailService.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/RmpEventDetailService.java @@ -2,14 +2,14 @@ package com.njcn.event.service.majornetwork; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.device.pq.pojo.vo.GridDiagramVO; import com.njcn.event.pojo.param.UniversalFrontEndParam; import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.vo.AdvanceEventDetailVO; import com.njcn.event.pojo.vo.RmpEventDetailVO; -import com.njcn.event.pojo.vo.TransientVO; +import com.njcn.harmonic.pojo.param.StatSubstationBizBaseParam; import com.njcn.system.pojo.po.DictData; import com.njcn.web.pojo.param.BaseParam; -import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -56,4 +56,7 @@ public interface RmpEventDetailService extends IService { * @date 2023/7/28 */ RmpEventDetailPO queryEventDetailByEventId(String eventId); + + GridDiagramVO getEventLevelEvaluation(StatSubstationBizBaseParam param); + }