diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/SubstationServiceImpl.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/SubstationServiceImpl.java index 7863cf200..cb3017502 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/SubstationServiceImpl.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/SubstationServiceImpl.java @@ -68,11 +68,13 @@ public class SubstationServiceImpl extends ServiceImpl dictDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE_STAND.getCode()).getData(); Map dictDataMap = dictDataList.stream().collect(Collectors.toMap(DictData::getId,Function.identity())); stationList.forEach(item->{ - LedgerSelectVO ledgerSelectVO = new LedgerSelectVO(); - BeanUtil.copyProperties(item,ledgerSelectVO); - ledgerSelectVO.setVoltageLevel(stationMap.get(item.getId()).getScale()); - ledgerSelectVO.setVoltageName(dictDataMap.get(ledgerSelectVO.getVoltageLevel()).getName()); - result.add(ledgerSelectVO); + if(stationMap.containsKey(item.getId())){ + LedgerSelectVO ledgerSelectVO = new LedgerSelectVO(); + BeanUtil.copyProperties(item,ledgerSelectVO); + ledgerSelectVO.setVoltageLevel(stationMap.get(item.getId()).getScale()); + ledgerSelectVO.setVoltageName(dictDataMap.get(ledgerSelectVO.getVoltageLevel()).getName()); + result.add(ledgerSelectVO); + } }); return result; } diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/api/RmpEventDetailFeignClient.java b/pqs-event/event-api/src/main/java/com/njcn/event/api/RmpEventDetailFeignClient.java index b2910df45..bb7699cc4 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/api/RmpEventDetailFeignClient.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/api/RmpEventDetailFeignClient.java @@ -7,8 +7,10 @@ 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.param.GridDiagramParam; import com.njcn.event.api.fallback.EventDetailFeignClientFallbackFactory; import com.njcn.event.api.fallback.RmpEventDetailFeignClientFallbackFactory; +import com.njcn.event.pojo.dto.EventCount; import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.vo.AdvanceEventDetailVO; @@ -41,4 +43,7 @@ public interface RmpEventDetailFeignClient { */ @GetMapping("/queryEventDetailByEventId") HttpResult queryEventDetailByEventId(@RequestParam("eventId")String eventId); + + @PostMapping("/getEventCount") + HttpResult> getEventCount(@RequestBody GridDiagramParam param); } diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/RmpEventDetailFeignClientFallbackFactory.java b/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/RmpEventDetailFeignClientFallbackFactory.java index ddb40fd6d..d082b8f9f 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/RmpEventDetailFeignClientFallbackFactory.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/RmpEventDetailFeignClientFallbackFactory.java @@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.response.HttpResult; +import com.njcn.device.pq.pojo.param.GridDiagramParam; import com.njcn.event.api.EventDetailFeignClient; import com.njcn.event.api.RmpEventDetailFeignClient; +import com.njcn.event.pojo.dto.EventCount; import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.vo.AdvanceEventDetailVO; @@ -41,6 +43,12 @@ public class RmpEventDetailFeignClientFallbackFactory implements FallbackFactory log.error("{}异常,降级处理,异常为:{}", "查询暂降明细", throwable.toString()); throw new BusinessException(finalExceptionEnum); } + + @Override + public HttpResult> getEventCount(GridDiagramParam param) { + log.error("{}异常,降级处理,异常为:{}", "根据特征幅值进行统计", throwable.toString()); + throw new BusinessException(finalExceptionEnum); + } }; } } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/RmpEventDetailController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/RmpEventDetailController.java index fa4fa5411..d01f236c7 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/RmpEventDetailController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/RmpEventDetailController.java @@ -8,6 +8,8 @@ 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.param.GridDiagramParam; +import com.njcn.event.pojo.dto.EventCount; import com.njcn.event.pojo.param.EventBaseParam; import com.njcn.event.pojo.param.UniversalFrontEndParam; import com.njcn.event.pojo.po.RmpEventDetailPO; @@ -146,4 +148,12 @@ public class RmpEventDetailController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getEventCount") + @ApiOperation("根据特征幅值进行统计") + public HttpResult> getEventCount(@RequestBody GridDiagramParam param) { + String methodDescribe = getMethodDescribe("getEventCount"); + List eventCount = rmpEventDetailService.getEventCount(param); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventCount, methodDescribe); + } } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/RmpEventDetailMapper.java b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/RmpEventDetailMapper.java index 1b2c1ce33..63be2edf0 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/RmpEventDetailMapper.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/RmpEventDetailMapper.java @@ -1,6 +1,8 @@ package com.njcn.event.mapper.majornetwork; +import cn.hutool.core.date.DateTime; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.njcn.event.pojo.dto.EventCount; import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.vo.RmpEventDetailVO; import org.apache.ibatis.annotations.Mapper; @@ -53,4 +55,6 @@ public interface RmpEventDetailMapper extends BaseMapper { * @return */ RmpEventDetailPO getByEventId(@Param("id") String id); + + List getEventCount(@Param("startTime")String startTime,@Param("endTime")String endTime); } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/mapping/RmpEventDetailMapper.xml b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/mapping/RmpEventDetailMapper.xml index fd955a91d..eec9701f6 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/mapping/RmpEventDetailMapper.xml +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/majornetwork/mapping/RmpEventDetailMapper.xml @@ -74,4 +74,15 @@ r_mp_event_detail where event_id=#{id} + 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 b9322b6b7..259e44ee2 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 @@ -3,6 +3,7 @@ package com.njcn.event.service.majornetwork.Impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; @@ -37,6 +38,7 @@ import com.njcn.device.pq.pojo.vo.GridDiagramVO; import com.njcn.event.enums.EventResponseEnum; import com.njcn.event.mapper.majornetwork.RMpEventDetailMMapper; import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper; +import com.njcn.event.pojo.dto.EventCount; import com.njcn.event.pojo.param.EventBaseParam; import com.njcn.event.pojo.param.UniversalFrontEndParam; import com.njcn.event.pojo.po.RmpEventDetailPO; @@ -435,6 +437,21 @@ public class RmpEventDetailServiceImpl extends ServiceImpl getEventCount(GridDiagramParam param) { + List eventCounts = rmpEventDetailMapper.getEventCount(param.getSearchBeginTime(), param.getSearchEndTime()); + Map eventMap = eventCounts.stream().collect(Collectors.toMap(EventCount::getLineId, pojo -> pojo)); + List eventCountList = new ArrayList<>(); + for (String id : param.getIds()) { + EventCount eventCountTemp = eventMap.get(id); + if (Objects.isNull(eventCountTemp)) { + eventCountTemp = new EventCount(id); + } + eventCountList.add(eventCountTemp); + } + return eventCountList; + } + private List setData(List gwLineAllIds, List list) { List info=new ArrayList<>(); 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 26ee7129d..be7cd0d12 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 @@ -6,6 +6,7 @@ import com.njcn.common.pojo.param.StatisticsBizBaseParam; import com.njcn.common.pojo.response.HttpResult; import com.njcn.device.pq.pojo.param.GridDiagramParam; import com.njcn.device.pq.pojo.vo.GridDiagramVO; +import com.njcn.event.pojo.dto.EventCount; import com.njcn.event.pojo.param.EventBaseParam; import com.njcn.event.pojo.param.UniversalFrontEndParam; import com.njcn.event.pojo.po.RmpEventDetailPO; @@ -80,4 +81,7 @@ public interface RmpEventDetailService extends IService { List> getImMonitorEvents(EventBaseParam param); + + + List getEventCount(GridDiagramParam param); } diff --git a/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/GdPollution.java b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/GdPollution.java new file mode 100644 index 000000000..016020d37 --- /dev/null +++ b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/GdPollution.java @@ -0,0 +1,27 @@ +package com.njcn.harmonic.pojo.excel.pollution; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import cn.afterturn.easypoi.excel.annotation.ExcelCollection; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class GdPollution implements Serializable { + + /** + * 供电公司名称 + */ + @Excel(name = "供电公司", width = 30, needMerge = true) + private String gdName; + + + /** + * 变电站集合 + * name不要赋值 + */ + @ExcelCollection(name = "") + private List substationPollutionList; + +} diff --git a/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/LineItemPollution.java b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/LineItemPollution.java new file mode 100644 index 000000000..c26451dfe --- /dev/null +++ b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/LineItemPollution.java @@ -0,0 +1,84 @@ +package com.njcn.harmonic.pojo.excel.pollution; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class LineItemPollution implements Serializable { + + + /** + * 终端名称 + */ + @Excel(name = "终端名称", width = 30, replace = "/_null") + private String devName; + + /** + * 终端厂家 + */ + @Excel(name = "终端厂家", width = 30, replace = "/_null") + private String manufacturer; + + /** + * 终端型号 + */ + @Excel(name = "终端型号", width = 30, replace = "/_null") + private String devType; + + /** + * 终端投运时间 + */ + @Excel(name = "投运时间", width = 30, replace = "/_null") + private String loginTime; + + /** + * 监测点名称 + */ + @Excel(name = "监测点名称", width = 35, replace = "/_null") + private String lineName; + + /** + * 统计间隔 + */ + @Excel(name = "统计间隔", width = 30, replace = "/_null") + private Integer interval; + + /** + * 谐波电压污染值 + */ + @Excel(name = "谐波电压污染值", width = 35, replace = "/_null") + private Double vHarmonicValue; + + @Excel(name = "谐波电压污染值", width = 35, replace = "/_null") + private Double iHarmonicValue; + + /** + * 暂升次数 1.1~1.8 + * 10ms ~ 1min + */ +// @Excel(name = "暂升次数(次)", width = 32, replace = "/_null") + private Integer upCounts; + + /** + * 暂降次数 0.1~0.9 + * 10ms ~ 1min + */ +// @Excel(name = "电压暂降(次)", width = 32, replace = "/_null") + private Integer downCounts; + + /** + * 短时中断 0~0.1 + * 10ms ~ 1min + */ +// @Excel(name = "短时中断(次)", width = 32, replace = "/_null") + private Integer breakCounts; + + /** + * 备注 + */ + @Excel(name = "备注", width = 30, replace = "/_null") + private String remark; + +} diff --git a/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/LinePollution.java b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/LinePollution.java new file mode 100644 index 000000000..e912f3d45 --- /dev/null +++ b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/LinePollution.java @@ -0,0 +1,152 @@ +package com.njcn.harmonic.pojo.excel.pollution; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class LinePollution implements Serializable { + + + /** + * 供电公司名称 + */ + @Excel(name = "供电公司", width = 30) + private String gdName; + + /** + * 所属变电站 + */ + @Excel(name = "变电站", width = 30) + private String subStationName; + + /** + * 终端名称 + */ + @Excel(name = "终端名称", width = 30) + private String devName; + + /** + * 终端厂家 + */ + @Excel(name = "终端厂家", width = 30) + private String manufacturer; + + /** + * 终端型号 + */ + @Excel(name = "终端型号", width = 30) + private String devType; + + /** + * 终端投运时间 + */ + @Excel(name = "投运时间", width = 30) + private String loginTime; + + /** + * 监测点索引 + */ + private String lineId; + + /** + * 监测点名称 + */ + @Excel(name = "监测点名称", width = 30) + private String lineName; + + /** + * 位置,电网侧&非电网侧 + */ + @Excel(name = "监测位置", width = 30) + private String powerFlag; + + /** + * 新增 + * 监测点电压等级 + */ + @Excel(name = "监测点电压等级", width = 30) + private String lineVoltage; + + /** + * 干扰源类型 + */ + @Excel(name = "干扰源类型", width = 30) + private String loadType; + + /** + * 监测对象 + */ + @Excel(name = "监测对象名称", width = 30) + private String objName; + + /** + * 统计间隔 + */ + @Excel(name = "统计间隔", width = 30) + private Integer interval; + + /** + * 新增 + * 在线率 + */ + @Excel(name = "在线率(%)", width = 30) + private Double onlineRate; + + /** + * 新增 + * 完整性 + */ + @Excel(name = "完整率(%)", width = 30) + private Double integrity; + + /** + * 谐波电压污染值 + */ + @Excel(name = "谐波电压污染值", width = 20) + private Double vHarmonicValue; + + /** + * 谐波电压污染值 + */ + @Excel(name = "谐波电流污染值", width = 20) + private Double iHarmonicValue; + + /** + * 暂升次数 1.1~1.8 + * 10ms ~ 1min + */ + @Excel(name = "暂升次数(次)", width = 20) + private Integer upCounts; + + /** + * 暂降次数 0.1~0.9 + * 10ms ~ 1min + */ + @Excel(name = "电压暂降(次)", width = 20) + private Integer downCounts; + + /** + * 短时中断 0~0.1 + * 10ms ~ 1min + */ + @Excel(name = "短时中断(次)", width = 20) + private Integer breakCounts; + + @Excel(name = "是否关联敏感用户", width = 30, replace = "/_null") + private String isMg; + + @Excel(name = "敏感及重要用户", width = 30,replace = "/_null") + private String importUser; + + @Excel(name = "一类监测点", width = 30,replace = "/_null") + private String monitorId; + +// /** +// * 备注 +// */ +// @Excel(name = "备注", width = 30, replace = "/_null") +// private String remark; + +} diff --git a/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/LoadTypeLineItemPollution.java b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/LoadTypeLineItemPollution.java new file mode 100644 index 000000000..d3761a3d4 --- /dev/null +++ b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/LoadTypeLineItemPollution.java @@ -0,0 +1,92 @@ +package com.njcn.harmonic.pojo.excel.pollution; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class LoadTypeLineItemPollution implements Serializable { + + /** + * 所属变电站 + */ + @Excel(name = "变电站", width = 30, needMerge = true) + private String subStationName; + + /** + * 终端名称 + */ + @Excel(name = "终端名称", width = 30, replace = "/_null") + private String devName; + + /** + * 终端厂家 + */ + @Excel(name = "终端厂家", width = 30, replace = "/_null") + private String manufacturer; + + /** + * 终端型号 + */ + @Excel(name = "终端型号", width = 30, replace = "/_null") + private String devType; + + /** + * 终端投运时间 + */ + @Excel(name = "投运时间", width = 30, replace = "/_null") + private String loginTime; + + /** + * 监测点名称 + */ + @Excel(name = "监测点名称", width = 30, replace = "/_null") + private String lineName; + + /** + * 统计间隔 + */ + @Excel(name = "统计间隔", width = 30, replace = "/_null") + private Integer interval; + + /** + * 谐波电压污染值 + */ + @Excel(name = "测点谐波电压污染值", width = 20, replace = "/_null") + private Double vHarmonicValue; + + /** + * 谐波电压污染值 + */ + @Excel(name = "测点谐波电流污染值", width = 20, replace = "/_null") + private Double iHarmonicValue; + + /** + * 暂升次数 1.1~1.8 + * 10ms ~ 1min + */ +// @Excel(name = "暂升次数(次)", width = 20, replace = "/_null") + private Integer upCounts; + + /** + * 暂降次数 0.1~0.9 + * 10ms ~ 1min + */ +// @Excel(name = "电压暂降(次)", width = 20, replace = "/_null") + private Integer downCounts; + + /** + * 短时中断 0~0.1 + * 10ms ~ 1min + */ +// @Excel(name = "短时中断(次)", width = 20, replace = "/_null") + private Integer breakCounts; + + /** + * 备注 + */ + @Excel(name = "备注", width = 30, replace = "/_null") + private String remark; + +} diff --git a/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/ObjPollution.java b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/ObjPollution.java new file mode 100644 index 000000000..880f63195 --- /dev/null +++ b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/ObjPollution.java @@ -0,0 +1,46 @@ +package com.njcn.harmonic.pojo.excel.pollution; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import cn.afterturn.easypoi.excel.annotation.ExcelCollection; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class ObjPollution implements Serializable { + + /** + * 对象名称 + */ + @Excel(name = "用户名称", width = 30, needMerge = true) + private String objName; + + /** + * 干扰源类型 + */ + @Excel(name = "干扰源类型", width = 30, needMerge = true) + private String loadType; + + /** + * 行业类型 + */ + @Excel(name = "行业类型", width = 30, needMerge = true) + private String businessType; + + /** + * 用户污染值 + */ + @Excel(name = "用户谐波电压污染值", width = 30, needMerge = true) + private String objVValue; + + @Excel(name = "用户谐波电流污染值", width = 30, needMerge = true) + private String objIValue; + + /** + * 下面监测点详细污染值 + */ + @ExcelCollection(name = "") + private List lineItemPollutionList; + +} diff --git a/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/PowerFlagPollution.java b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/PowerFlagPollution.java new file mode 100644 index 000000000..ae551167d --- /dev/null +++ b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/PowerFlagPollution.java @@ -0,0 +1,35 @@ +package com.njcn.harmonic.pojo.excel.pollution; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import cn.afterturn.easypoi.excel.annotation.ExcelCollection; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class PowerFlagPollution implements Serializable { + + /** + * 监测位置 + */ + @Excel(name = "监测位置", width = 30, needMerge = true) + private String powerFlag; + + + /** + * 监测污染值 + */ + @Excel(name = "监测谐波电压污染值", width = 40, needMerge = true, replace = "/_null") + private String powerVValue; + + @Excel(name = "监测谐波电流污染值", width = 40, needMerge = true, replace = "/_null") + private String powerIValue; + /** + * 当前位置下,各测点的污染数据 + */ + @ExcelCollection(name = "") + private List lineItemPollutionList; + + +} diff --git a/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/SubstationPollution.java b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/SubstationPollution.java new file mode 100644 index 000000000..7b446c4c6 --- /dev/null +++ b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/pojo/excel/pollution/SubstationPollution.java @@ -0,0 +1,40 @@ +package com.njcn.harmonic.pojo.excel.pollution; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import cn.afterturn.easypoi.excel.annotation.ExcelCollection; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class SubstationPollution implements Serializable { + + + /** + * 所属变电站 + */ + @Excel(name = "变电站", width = 30, needMerge = true) + private String subStationName; + + /** + * 电站污染值 + */ + @Excel(name = "电站谐波电压污染值", width = 25, needMerge = true) + private String subVStationValue; + + + /** + * 电站污染值 + */ + @Excel(name = "电站谐波电流污染值", width = 25, needMerge = true) + private String subIStationValue; + + /** + * 电网侧&非电网侧 + * name不要赋值 + */ + @ExcelCollection(name = "") + private List powerFlagPollutionList; + +} diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/PollutionSubstationController.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/PollutionSubstationController.java index e18c07400..74f436757 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/PollutionSubstationController.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/PollutionSubstationController.java @@ -10,6 +10,7 @@ import com.njcn.device.biz.pojo.dto.PollutionLineDTO; import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO; import com.njcn.harmonic.pojo.param.HarmonicPublicParam; import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam; +import com.njcn.harmonic.pojo.param.StatSubstationBizBaseParam; import com.njcn.harmonic.pojo.vo.PollutionSubstationVO; import com.njcn.harmonic.pojo.vo.PollutionVO; import com.njcn.harmonic.pojo.vo.SubstationVo; @@ -21,6 +22,7 @@ import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.MediaType; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -119,4 +121,36 @@ public class PollutionSubstationController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @ApiOperation(value ="导出监测点谐波污染值",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) + @GetMapping(value ="/downPollutionLineCalc",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) + public void downPollutionLineCalc(@RequestParam(value = "startTime") String startTime, + @RequestParam(value = "endTime") String endTime) { + StatSubstationBizBaseParam param=new StatSubstationBizBaseParam(); + param.setStartTime(startTime); + param.setEndTime(endTime); + pollutionSubstationService.downPollutionLineCalc(param); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @ApiOperation(value ="导出用户谐波电压污染值",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) + @GetMapping(value ="/downPollutionUserCalc",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) + public void downPollutionUserCalc(@RequestParam(value = "startTime") String startTime, + @RequestParam(value = "endTime") String endTime) { + StatSubstationBizBaseParam param=new StatSubstationBizBaseParam(); + param.setStartTime(startTime); + param.setEndTime(endTime); + pollutionSubstationService.downPollutionUserCalc(param); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @ApiOperation(value ="导出变电站谐波电压污染值",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) + @GetMapping(value ="/downPollutionSubCalc",produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) + public void downPollutionSubCalc(@RequestParam(value = "startTime") String startTime, + @RequestParam(value = "endTime") String endTime) { + StatSubstationBizBaseParam param=new StatSubstationBizBaseParam(); + param.setStartTime(startTime); + param.setEndTime(endTime); + pollutionSubstationService.downPollutionSubCalc(param); + } } diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/mapper/RMpPollutionDPOMapper.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/mapper/RMpPollutionDPOMapper.java index 34c8f9cac..955387e3e 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/mapper/RMpPollutionDPOMapper.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/mapper/RMpPollutionDPOMapper.java @@ -33,4 +33,9 @@ public interface RMpPollutionDPOMapper extends BaseMapper { @Param("start") DateTime searchBeginTime, @Param("end") DateTime searchEndTime, @Param("pollutionType") String id); + + List selectSumList(@Param("ids") List line, + @Param("pollutionType") List pollutionType, + @Param("statTime") String statTime, + @Param("endTime") String endTime); } \ No newline at end of file diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/mapper/mapping/RMpPollutionDPOMapper.xml b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/mapper/mapping/RMpPollutionDPOMapper.xml index 9d4920aa4..598c2decb 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/mapper/mapping/RMpPollutionDPOMapper.xml +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/mapper/mapping/RMpPollutionDPOMapper.xml @@ -67,6 +67,36 @@ GROUP BY l.line_id; + diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/PollutionSubstationService.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/PollutionSubstationService.java index 46b604eac..a11b32496 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/PollutionSubstationService.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/PollutionSubstationService.java @@ -89,4 +89,23 @@ public interface PollutionSubstationService extends IService> getPollutionAlarmList(GridDiagramParam param); List getSubstationInfo(String deptIndex, String searchValue, String startTime, String endTime); + + + /** + * 导出监测点谐波污染值 + * @param param + */ + void downPollutionLineCalc(StatSubstationBizBaseParam param); + + /** + * 导出用户谐波电压污染值 + */ + void downPollutionUserCalc(StatSubstationBizBaseParam param); + + + /** + * 变电站谐波电压污染值 + * @param param + */ + void downPollutionSubCalc(StatSubstationBizBaseParam param); } diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/PollutionSubstationServiceImpl.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/PollutionSubstationServiceImpl.java index eaf58f501..601b9cff9 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/PollutionSubstationServiceImpl.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/service/impl/PollutionSubstationServiceImpl.java @@ -1,5 +1,6 @@ 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; @@ -14,10 +15,12 @@ import com.njcn.common.config.GeneralInfo; import com.njcn.common.pojo.constant.BizParamConstant; import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.common.utils.PubUtils; +import com.njcn.device.biz.commApi.CommLineClient; import com.njcn.device.biz.commApi.CommTerminalGeneralClient; -import com.njcn.device.biz.enums.RunFlagEnum; import com.njcn.device.biz.pojo.dto.*; import com.njcn.device.biz.pojo.param.DeptGetLineParam; +import com.njcn.device.biz.pojo.po.Overlimit; import com.njcn.device.pms.api.MonitorClient; import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient; import com.njcn.device.pms.api.StatationStatClient; @@ -34,12 +37,17 @@ import com.njcn.device.pq.enums.PowerFlagEnum; import com.njcn.device.pq.pojo.dto.*; import com.njcn.device.pq.pojo.param.GridDiagramParam; import com.njcn.device.pq.pojo.param.LineBaseQueryParam; +import com.njcn.device.pq.pojo.param.OnlineRateParam; import com.njcn.device.pq.pojo.po.Line; import com.njcn.device.pq.pojo.po.LineDetail; import com.njcn.device.pq.pojo.vo.GridDiagramVO; -import com.njcn.harmonic.constant.Param; +import com.njcn.device.pq.pojo.vo.RStatIntegrityVO; +import com.njcn.device.pq.pojo.vo.RStatOnlinerateVO; +import com.njcn.event.api.RmpEventDetailFeignClient; +import com.njcn.event.pojo.dto.EventCount; import com.njcn.harmonic.mapper.*; import com.njcn.harmonic.pojo.dto.PublicDTO; +import com.njcn.harmonic.pojo.excel.pollution.*; import com.njcn.harmonic.pojo.param.HarmonicPublicParam; import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam; import com.njcn.harmonic.pojo.param.StatSubstationBizBaseParam; @@ -49,12 +57,14 @@ import com.njcn.harmonic.pojo.vo.PollutionSubstationVO; import com.njcn.harmonic.pojo.vo.PollutionVO; import com.njcn.harmonic.pojo.vo.SubstationVo; import com.njcn.harmonic.service.PollutionSubstationService; +import com.njcn.poi.excel.ExcelUtil; import com.njcn.supervision.api.UserLedgerFeignClient; import com.njcn.supervision.pojo.param.user.UserReportParam; -import com.njcn.supervision.pojo.vo.user.NewUserReportVO; import com.njcn.supervision.pojo.vo.user.UserLedgerVO; import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.enums.DicDataEnum; +import com.njcn.system.enums.DicDataTypeEnum; +import com.njcn.system.pojo.po.DictData; import com.njcn.user.api.DeptFeignClient; import com.njcn.user.pojo.po.Dept; import com.njcn.web.utils.RequestUtil; @@ -65,6 +75,7 @@ import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; import java.util.stream.Collectors; +import java.util.stream.Stream; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -102,9 +113,7 @@ public class PollutionSubstationServiceImpl extends ServiceImplit != 3.14159).max().orElse(3.14159); + double exe = subPollutionVO.stream().mapToDouble(PollutionVO::getData).filter(it -> it != 3.14159).max().orElse(3.14159); pollutionVO.setData(exe); pollutionVO.setChildren(subPollutionVO); list.add(pollutionVO); @@ -648,12 +658,12 @@ public class PollutionSubstationServiceImpl extends ServiceImpl lineDetailList = lineFeignClient.getMonitorByObjId(harmonicPublicParam.getId()).getData(); if (CollUtil.isNotEmpty(lineDetailList)) { List ids = lineDetailList.stream().map(LineDetail::getId).collect(Collectors.toList()); - return commDataDeal(ids,paramDTO,harmonicPublicParam); + return commDataDeal(ids, paramDTO, harmonicPublicParam); } } @@ -662,21 +672,21 @@ public class PollutionSubstationServiceImpl extends ServiceImpl commDataDeal(List ids,PollutionParamDTO paramDTO,HarmonicPublicParam harmonicPublicParam){ - paramDTO.setLineList(ids); - List list = lineFeignClient.getLineInfo(paramDTO).getData(); - List lineData = rMpPollutionDPOMapper.selectMaxList(ids, harmonicPublicParam.getStatisticalType().getId(), harmonicPublicParam.getSearchBeginTime(), harmonicPublicParam.getSearchEndTime()); - Map map = lineData.stream().collect(Collectors.toMap(RMpPollutionDPO::getLineId,Function.identity())); - if (!CollectionUtils.isEmpty(lineData)) { - list.stream().sorted(Comparator.comparing(PollutionLineDTO::getData).reversed().thenComparing(PollutionLineDTO::getName)).forEach(item->{ - if(map.containsKey(item.getId())){ - item.setData(map.get(item.getId()).getValue()); - }else { - item.setData(3.14159); - } - }); - } - return list; + private List commDataDeal(List ids, PollutionParamDTO paramDTO, HarmonicPublicParam harmonicPublicParam) { + paramDTO.setLineList(ids); + List list = lineFeignClient.getLineInfo(paramDTO).getData(); + List lineData = rMpPollutionDPOMapper.selectMaxList(ids, harmonicPublicParam.getStatisticalType().getId(), harmonicPublicParam.getSearchBeginTime(), harmonicPublicParam.getSearchEndTime()); + Map map = lineData.stream().collect(Collectors.toMap(RMpPollutionDPO::getLineId, Function.identity())); + if (!CollectionUtils.isEmpty(lineData)) { + list.stream().sorted(Comparator.comparing(PollutionLineDTO::getData).reversed().thenComparing(PollutionLineDTO::getName)).forEach(item -> { + if (map.containsKey(item.getId())) { + item.setData(map.get(item.getId()).getValue()); + } else { + item.setData(3.14159); + } + }); + } + return list; } @@ -687,21 +697,21 @@ public class PollutionSubstationServiceImpl extends ServiceImpl generalDeviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(param).getData(); - List ids = generalDeviceDTOList.stream().filter(it->CollUtil.isNotEmpty(it.getLineIndexes())).flatMap(it->it.getLineIndexes().stream()).collect(Collectors.toList()); + List ids = generalDeviceDTOList.stream().filter(it -> CollUtil.isNotEmpty(it.getLineIndexes())).flatMap(it -> it.getLineIndexes().stream()).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(ids)) { List result = rMpPollutionDPOMapper.getTop10Line(ids, DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())), DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())), param.getStatisticalType().getId()); if (!CollectionUtils.isEmpty(result)) { List monitorIds = result.stream().map(PublicDTO::getId).distinct().collect(Collectors.toList()); paramDTO.setLineList(monitorIds); List monitorList = lineFeignClient.getLineInfo(paramDTO).getData(); - Map monitorMap = monitorList.stream().collect(Collectors.toMap(PollutionLineDTO::getId,Function.identity())); - list = result.stream().map(it->{ + Map monitorMap = monitorList.stream().collect(Collectors.toMap(PollutionLineDTO::getId, Function.identity())); + list = result.stream().map(it -> { PollutionLineDTO pollutionLineDTO = new PollutionLineDTO(); - pollutionLineDTO.setData(NumberUtil.round(it.getData(),2).doubleValue()); + pollutionLineDTO.setData(NumberUtil.round(it.getData(), 2).doubleValue()); PollutionLineDTO monitor = monitorMap.get(it.getId()); - pollutionLineDTO.setName(monitor.getSubstation()+"_"+monitor.getName()); + pollutionLineDTO.setName(monitor.getSubstation() + "_" + monitor.getName()); return pollutionLineDTO; - }).sorted(Comparator.comparing(PollutionLineDTO::getData,Comparator.reverseOrder())).collect(Collectors.toList()); + }).sorted(Comparator.comparing(PollutionLineDTO::getData, Comparator.reverseOrder())).collect(Collectors.toList()); } } return list; @@ -960,6 +970,272 @@ public class PollutionSubstationServiceImpl extends ServiceImpl finalLinePollutionList = pollutionCalcList(startDate, endDate); + // 全部监测点计算完毕后根据污染值从大到小进行排序 + finalLinePollutionList = finalLinePollutionList.stream() + .sorted(Comparator.comparing(LinePollution::getVHarmonicValue).reversed()) + .collect(Collectors.toList()); + ExcelUtil.exportExcel("监测点谐波电压污染值" + endDate + ".xlsx", LinePollution.class, finalLinePollutionList); + } + + private List pollutionCalcList(String startDate,String endDate) { + List linePollutionList = new ArrayList<>(); + List lineIdList = commTerminalGeneralClient.getRunMonitorIds().getData(); + GridDiagramParam eventParam = new GridDiagramParam(); + eventParam.setIds(lineIdList); + eventParam.setSearchBeginTime(startDate); + eventParam.setSearchEndTime(endDate); + + List eventCounts = detailFeignClient.getEventCount(eventParam).getData(); + Map eventMap = new HashMap<>(); + if (CollUtil.isNotEmpty(eventCounts)) { + eventMap.putAll(eventCounts.stream().collect(Collectors.toMap(EventCount::getLineId, Function.identity()))); + } + // 获取所有监测点的元信息 + List lineInfoDTOList = commLineClient.getPollutionLineInfo(lineIdList).getData(); + + //获取监测点的数据完整性 + OnlineRateParam onlineRateParam = new OnlineRateParam(); + onlineRateParam.setStartTime(startDate); + onlineRateParam.setEndTime(endDate); + List integrityVOS = lineFeignClient.getOnIntegrityByIds(onlineRateParam).getData(); + Map integrityMap = integrityVOS.stream().collect(Collectors.toMap(RStatIntegrityVO::getLineIndex, RStatIntegrityVO::getIntegrityRate)); + + //获取装置在线率 + List onLineRateVOS = generalDeviceInfoClient.getOnlineRateByDevIds(onlineRateParam).getData(); + Map onlineRateMap = onLineRateVOS.stream().collect(Collectors.toMap(RStatOnlinerateVO::getDevIndex, RStatOnlinerateVO::getOnlineRate)); + List dictDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.POLLUTION_CALC.getCode()).getData(); + Map dictData = dictDataList.stream().collect(Collectors.toMap(DictData::getCode, DictData::getId)); + String vHarmonicLimit = dictData.get(DicDataEnum.V_HARMONIC_LIMIT.getCode()); + String iAllLimit = dictData.get(DicDataEnum.I_ALL_LIMIT.getCode()); + List rMpPollutionDPOS = rMpPollutionDPOMapper.selectSumList(lineIdList, Arrays.asList(vHarmonicLimit, iAllLimit), startDate, endDate); + Map calcMap = new HashMap<>(); + if (CollUtil.isNotEmpty(rMpPollutionDPOS)) { + calcMap.putAll(rMpPollutionDPOS.stream().collect(Collectors.toMap(x -> x.getLineId() + "_" + x.getPollutionType(), RMpPollutionDPO::getValue))); + } + if (CollUtil.isNotEmpty(lineIdList)) { + // 获取谐波电压数据&总畸变率&越限限值计算基础污染值 + for (int i = 0; i < lineIdList.size(); i++) { + String lineId = lineIdList.get(i); + LinePollution linePollution = new LinePollution(); + linePollution.setLineId(lineId); + //获取监测点数据完整性 + linePollution.setIntegrity(Objects.isNull(integrityMap.get(lineId)) ? 0.0 : integrityMap.get(lineId)); + //获取监测点限值 + Overlimit overlimit = commTerminalGeneralClient.getOverLimitData(lineId).getData(); + LineDevGetDTO lineDetailData = commTerminalGeneralClient.getMonitorDetail(lineId).getData(); + if (Objects.isNull(overlimit) || Objects.isNull(lineDetailData)) { + // 如果没有查到限值跳过,后期需要记录这种异常 + continue; + } + linePollution.setLineName(lineDetailData.getPointName()); + linePollution.setInterval(lineDetailData.getInterval()); + // 计算谐波电压的污染值 + linePollution.setVHarmonicValue(calcMap.containsKey(lineId+"_"+vHarmonicLimit)?calcMap.get(lineId+"_"+vHarmonicLimit):0.0); + // 计算谐波电流的污染值 + linePollution.setIHarmonicValue(calcMap.containsKey(lineId+"_"+iAllLimit )?calcMap.get(lineId+"_"+iAllLimit):0.0); + // 获取暂态数据 + BeanUtil.copyProperties(eventMap.get(lineId), linePollution); + //获取该监测点其他元信息 + Optional any = lineInfoDTOList.stream().filter(item -> item.getLineId().equals(lineId)).findAny(); + if (any.isPresent()) { + PollutionLineInfoDTO data = any.get(); + BeanUtil.copyProperties(data, linePollution, true); + Float vo2 = onlineRateMap.get(data.getDeviceId()); + linePollution.setOnlineRate(Objects.isNull(vo2) ? 0.0 : vo2); + } + linePollutionList.add(linePollution); + } + } + return linePollutionList; + } + + @Override + public void downPollutionUserCalc(StatSubstationBizBaseParam param) { + // 处理干扰源用户的报告 + String startDate = DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())).toString(); + String endDate = DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())).toString(); + List loadTypeLineList = pollutionCalcList(startDate, endDate); + /** + * 1、首先过滤:重要变电站、一类变电站、跨省计量关点 todo...待优化 + * 2、过滤后,以监测对象分组统计数据有多个测点的需要出结果 + */ + List loadTypeSubStation = Stream.of("重要变电站", "一类变电站", "跨省计量关点").collect(Collectors.toList()); + loadTypeLineList = loadTypeLineList.stream().filter(item -> !loadTypeSubStation.contains(item.getLoadType())).collect(Collectors.toList()); + // 监测对象分组 + Map> loadTypeMap = loadTypeLineList.stream().collect(Collectors.groupingBy(LinePollution::getObjName)); + List objPollutions = new ArrayList<>(); + Set objNameSet = loadTypeMap.keySet(); + for (String objName : objNameSet) { + ObjPollution objPollution = new ObjPollution(); + List linePollutions = loadTypeMap.get(objName); + objPollution.setObjName(linePollutions.get(0).getObjName()); + objPollution.setLoadType(linePollutions.get(0).getLoadType()); +// objPollution.setBusinessType(linePollutions.get(0).getBusinessType()); + // 求出平均污染值 + double objVValue = linePollutions.stream() + .mapToDouble(o -> o.getVHarmonicValue()) + .sum(); + objPollution.setObjVValue(PubUtils.doubleRound(2, objVValue) + ""); + + double objIValue = linePollutions.stream() + .mapToDouble(o -> o.getIHarmonicValue()) + .sum(); + objPollution.setObjIValue(PubUtils.doubleRound(2, objIValue) + ""); + + // 处理该监测对象下面监测点的信息 + List loadTypeLineItemPollutions = new ArrayList<>(); + for (LinePollution linePollution : linePollutions) { + LoadTypeLineItemPollution loadTypeLineItemPollution = new LoadTypeLineItemPollution(); + BeanUtil.copyProperties(linePollution, loadTypeLineItemPollution, true); + loadTypeLineItemPollutions.add(loadTypeLineItemPollution); + } + objPollution.setLineItemPollutionList(loadTypeLineItemPollutions); + objPollutions.add(objPollution); + } + // 排序 + objPollutions= objPollutions.stream() + .sorted(Comparator.comparing(ObjPollution::getObjVValue).reversed()) + .collect(Collectors.toList()); + ExcelUtil.exportExcel("用户谐波电压污染值" + endDate + ".xlsx", ObjPollution.class, objPollutions); + } + + @Override + public void downPollutionSubCalc(StatSubstationBizBaseParam param) { + // 处理干扰源用户的报告 + String startDate = DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())).toString(); + String endDate = DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())).toString(); + List linePollutionList = pollutionCalcList(startDate, endDate); + // 整合变电站待导出的数据 + List gdPollutionList = new ArrayList<>(); + // 以供电公司分组 + Map> gdMap = linePollutionList.stream() + .collect(Collectors.groupingBy(LinePollution::getGdName)); + // 同一供电公司以变电站分组 + Set gdNameSet = gdMap.keySet(); + for (String gdName : gdNameSet) { + // 初始化gd实体 + GdPollution gdPollution = new GdPollution(); + gdPollution.setGdName(gdName); + List gdLinePollution = gdMap.get(gdName); + // 以变电站分组 + Map> subMap = gdLinePollution.stream() + .collect(Collectors.groupingBy(LinePollution::getSubStationName)); + Set subNameMap = subMap.keySet(); + List substationPollutions = new ArrayList<>(); + for (String subName : subNameMap) { + // 初始化变电站实体 + SubstationPollution substationPollution = new SubstationPollution(); + substationPollution.setSubStationName(subName); + List subLinePollution = subMap.get(subName); + // 需要区分电网侧、非电网侧 + Map> powerFlagLinePollution = subLinePollution.stream().collect(Collectors.groupingBy(LinePollution::getPowerFlag)); + + List powerFlagPollutionList = new ArrayList<>(); + // 电网侧 + List temp = powerFlagLinePollution.get("电网侧"); + PowerFlagPollution powerFlagPollution1 = new PowerFlagPollution(); + powerFlagPollution1.setPowerFlag("电网侧"); + List lineItemPollutionList1 = new ArrayList<>(); + if (CollUtil.isNotEmpty(temp)) { + // 计算电网侧下所有监测点谐波电压平均污染值 + double subVValue = temp.stream() + .mapToDouble(o -> o.getVHarmonicValue()) + .average() + .orElse(0.0); + // 电网侧污染值 + powerFlagPollution1.setPowerVValue(PubUtils.doubleRound(2, subVValue) + ""); + + // 计算电网侧下所有监测点谐波电流平均污染值 + double subIValue = temp.stream() + .mapToDouble(o -> o.getIHarmonicValue()) + .average() + .orElse(0.0); + // 电网侧污染值 + powerFlagPollution1.setPowerIValue(PubUtils.doubleRound(2, subIValue) + ""); + + // 设备信息 + for (LinePollution linePollution : temp) { + LineItemPollution lineItemPollution = new LineItemPollution(); + BeanUtil.copyProperties(linePollution, lineItemPollution, true); + lineItemPollutionList1.add(lineItemPollution); + } + } else { + // 仅有非电网侧时,电网侧赋予空置 + LineItemPollution lineItemPollution = new LineItemPollution(); + lineItemPollutionList1.add(lineItemPollution); + } + // 设备信息注入监测位置对象中 + powerFlagPollution1.setLineItemPollutionList(lineItemPollutionList1); + powerFlagPollutionList.add(powerFlagPollution1); + + + // 非电网侧 + List temp1 = powerFlagLinePollution.get("非电网侧"); + PowerFlagPollution powerFlagPollution2 = new PowerFlagPollution(); + powerFlagPollution2.setPowerFlag("非电网侧"); + List lineItemPollutionList2 = new ArrayList<>(); + if (CollUtil.isNotEmpty(temp1)) { + // 计算电网侧下所有监测点谐波电压平均污染值 + double subVValue = temp1.stream() + .mapToDouble(o -> o.getVHarmonicValue()) + .average() + .orElse(0.0); + // 电网侧污染值 + powerFlagPollution2.setPowerVValue(PubUtils.doubleRound(2, subVValue) + ""); + + // 计算电网侧下所有监测点谐波电流平均污染值 + double subIValue = temp1.stream() + .mapToDouble(o -> o.getIHarmonicValue()) + .average() + .orElse(0.0); + // 电网侧污染值 + powerFlagPollution2.setPowerIValue(PubUtils.doubleRound(2, subIValue) + ""); + for (LinePollution linePollution : temp1) { + LineItemPollution lineItemPollution = new LineItemPollution(); + BeanUtil.copyProperties(linePollution, lineItemPollution, true); + lineItemPollutionList2.add(lineItemPollution); + } + } else { + // 仅有非电网侧时,电网侧赋予空置 + LineItemPollution lineItemPollution = new LineItemPollution(); + lineItemPollutionList2.add(lineItemPollution); + } + // 设备信息注入监测位置对象中 + powerFlagPollution2.setLineItemPollutionList(lineItemPollutionList2); + powerFlagPollutionList.add(powerFlagPollution2); + + substationPollution.setPowerFlagPollutionList(powerFlagPollutionList); + // 如果电网侧有污染值,就作为变电站的污染值,否则就用非电网侧的污染值作为该变电站污染值 + if (Objects.nonNull(powerFlagPollution1.getPowerVValue())) { + substationPollution.setSubVStationValue(powerFlagPollution1.getPowerVValue()); + } else { + substationPollution.setSubVStationValue(powerFlagPollution2.getPowerVValue()); + } + if (Objects.nonNull(powerFlagPollution1.getPowerIValue())) { + substationPollution.setSubIStationValue(powerFlagPollution1.getPowerIValue()); + } else { + substationPollution.setSubIStationValue(powerFlagPollution2.getPowerIValue()); + } + substationPollutions.add(substationPollution); + } + + // 针对这个供电公司下的变电站污染值排序 + substationPollutions.sort(Comparator.comparingDouble(o -> Double.parseDouble(o.getSubVStationValue()))); + Collections.reverse(substationPollutions); +// List finalSubstation = substationPollutions.stream().sorted((Comparator.comparingDouble(SubstationPollution::getSubStationValue)) +// .reversed()) +// .collect(Collectors.toList()); + gdPollution.setSubstationPollutionList(substationPollutions); + gdPollutionList.add(gdPollution); + } + ExcelUtil.exportExcel("变电站谐波电压污染值" + endDate + ".xlsx", GdPollution.class, gdPollutionList); + } + private List addList(List substationMlist) { List info = new ArrayList<>();