@@ -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 ServiceImpl<RStatPollutionSu
private final GeneralDeviceInfoClient generalDeviceInfoClient ;
private final LineFeignClient lineFeignClient ;
private final GeneralInfo generalInfo ;
@@ -114,12 +123,13 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
private final RStatPollutionOrgDPOMapper rStatPollutionOrgDPOMapper ;
private final RMpPollutionDPOMapper rMpPollutionDPOMapper ;
private final CommTerminalGeneralClient commTerminalGeneralClient ;
private final DicDataFeignClient dicDataFeignClient ;
private final RStatLimitRateDMapper rStatLimitRateDMapper ;
private final UserLedgerFeignClient userLedgerFeignClient ;
private final RmpEventDetailFeignClient detailFeignClient ;
private final CommLineClient commLineClient ;
/**
* @param pollutionSubstationQuryParam
@@ -322,7 +332,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
}
}
double exe = subPollutionVO . stream ( ) . mapToDouble ( PollutionVO : : getData ) . filter ( it - > it ! = 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<RStatPollutionSu
}
}
} ) ;
return commDataDeal ( line , paramDTO , harmonicPublicParam ) ;
return commDataDeal ( line , paramDTO , harmonicPublicParam ) ;
} else {
List < LineDetail > lineDetailList = lineFeignClient . getMonitorByObjId ( harmonicPublicParam . getId ( ) ) . getData ( ) ;
if ( CollUtil . isNotEmpty ( lineDetailList ) ) {
List < String > 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<RStatPollutionSu
}
private List < PollutionLineDTO > commDataDeal ( List < String > ids , PollutionParamDTO paramDTO , HarmonicPublicParam harmonicPublicParam ) {
paramDTO . setLineList ( ids ) ;
List < PollutionLineDTO > list = lineFeignClient . getLineInfo ( paramDTO ) . getData ( ) ;
List < RMpPollutionDPO > lineData = rMpPollutionDPOMapper . selectMaxList ( ids , harmonicPublicParam . getStatisticalType ( ) . getId ( ) , harmonicPublicParam . getSearchBeginTime ( ) , harmonicPublicParam . getSearchEndTime ( ) ) ;
Map < String , RMpPollutionDPO > 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 < PollutionLineDTO > commDataDeal ( List < String > ids , PollutionParamDTO paramDTO , HarmonicPublicParam harmonicPublicParam ) {
paramDTO . setLineList ( ids ) ;
List < PollutionLineDTO > list = lineFeignClient . getLineInfo ( paramDTO ) . getData ( ) ;
List < RMpPollutionDPO > lineData = rMpPollutionDPOMapper . selectMaxList ( ids , harmonicPublicParam . getStatisticalType ( ) . getId ( ) , harmonicPublicParam . getSearchBeginTime ( ) , harmonicPublicParam . getSearchEndTime ( ) ) ;
Map < String , RMpPollutionDPO > 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<RStatPollutionSu
param . setServerName ( generalInfo . getMicroServiceName ( ) ) ;
PollutionParamDTO paramDTO = new PollutionParamDTO ( ) ;
List < GeneralDeviceDTO > generalDeviceDTOList = generalDeviceInfoClient . getPracticalRunDeviceInfo ( param ) . getData ( ) ;
List < String > ids = generalDeviceDTOList . stream ( ) . filter ( it - > CollUtil . isNotEmpty ( it . getLineIndexes ( ) ) ) . flatMap ( it - > it . getLineIndexes ( ) . stream ( ) ) . collect ( Collectors . toList ( ) ) ;
List < String > ids = generalDeviceDTOList . stream ( ) . filter ( it - > CollUtil . isNotEmpty ( it . getLineIndexes ( ) ) ) . flatMap ( it - > it . getLineIndexes ( ) . stream ( ) ) . collect ( Collectors . toList ( ) ) ;
if ( ! CollectionUtils . isEmpty ( ids ) ) {
List < PublicDTO > result = rMpPollutionDPOMapper . getTop10Line ( ids , DateUtil . beginOfDay ( DateUtil . parse ( param . getSearchBeginTime ( ) ) ) , DateUtil . endOfDay ( DateUtil . parse ( param . getSearchEndTime ( ) ) ) , param . getStatisticalType ( ) . getId ( ) ) ;
if ( ! CollectionUtils . isEmpty ( result ) ) {
List < String > monitorIds = result . stream ( ) . map ( PublicDTO : : getId ) . distinct ( ) . collect ( Collectors . toList ( ) ) ;
paramDTO . setLineList ( monitorIds ) ;
List < PollutionLineDTO > monitorList = lineFeignClient . getLineInfo ( paramDTO ) . getData ( ) ;
Map < String , PollutionLineDTO > monitorMap = monitorList . stream ( ) . collect ( Collectors . toMap ( PollutionLineDTO : : getId , Function . identity ( ) ) ) ;
list = result . stream ( ) . map ( it - > {
Map < String , PollutionLineDTO > 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<RStatPollutionSu
return result ;
}
@Override
public void downPollutionLineCalc ( StatSubstationBizBaseParam param ) {
String startDate = DateUtil . beginOfDay ( DateUtil . parse ( param . getStartTime ( ) ) ) . toString ( ) ;
String endDate = DateUtil . beginOfDay ( DateUtil . parse ( param . getStartTime ( ) ) ) . toString ( ) ;
List < LinePollution > 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 < LinePollution > pollutionCalcList ( String startDate , String endDate ) {
List < LinePollution > linePollutionList = new ArrayList < > ( ) ;
List < String > lineIdList = commTerminalGeneralClient . getRunMonitorIds ( ) . getData ( ) ;
GridDiagramParam eventParam = new GridDiagramParam ( ) ;
eventParam . setIds ( lineIdList ) ;
eventParam . setSearchBeginTime ( startDate ) ;
eventParam . setSearchEndTime ( endDate ) ;
List < EventCount > eventCounts = detailFeignClient . getEventCount ( eventParam ) . getData ( ) ;
Map < String , EventCount > eventMap = new HashMap < > ( ) ;
if ( CollUtil . isNotEmpty ( eventCounts ) ) {
eventMap . putAll ( eventCounts . stream ( ) . collect ( Collectors . toMap ( EventCount : : getLineId , Function . identity ( ) ) ) ) ;
}
// 获取所有监测点的元信息
List < PollutionLineInfoDTO > lineInfoDTOList = commLineClient . getPollutionLineInfo ( lineIdList ) . getData ( ) ;
//获取监测点的数据完整性
OnlineRateParam onlineRateParam = new OnlineRateParam ( ) ;
onlineRateParam . setStartTime ( startDate ) ;
onlineRateParam . setEndTime ( endDate ) ;
List < RStatIntegrityVO > integrityVOS = lineFeignClient . getOnIntegrityByIds ( onlineRateParam ) . getData ( ) ;
Map < String , Double > integrityMap = integrityVOS . stream ( ) . collect ( Collectors . toMap ( RStatIntegrityVO : : getLineIndex , RStatIntegrityVO : : getIntegrityRate ) ) ;
//获取装置在线率
List < RStatOnlinerateVO > onLineRateVOS = generalDeviceInfoClient . getOnlineRateByDevIds ( onlineRateParam ) . getData ( ) ;
Map < String , Float > onlineRateMap = onLineRateVOS . stream ( ) . collect ( Collectors . toMap ( RStatOnlinerateVO : : getDevIndex , RStatOnlinerateVO : : getOnlineRate ) ) ;
List < DictData > dictDataList = dicDataFeignClient . getDicDataByTypeCode ( DicDataTypeEnum . POLLUTION_CALC . getCode ( ) ) . getData ( ) ;
Map < String , String > 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 < RMpPollutionDPO > rMpPollutionDPOS = rMpPollutionDPOMapper . selectSumList ( lineIdList , Arrays . asList ( vHarmonicLimit , iAllLimit ) , startDate , endDate ) ;
Map < String , Double > 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 < PollutionLineInfoDTO > 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 < LinePollution > loadTypeLineList = pollutionCalcList ( startDate , endDate ) ;
/**
* 1、首先过滤: 重要变电站、一类变电站、跨省计量关点 todo...待优化
* 2、过滤后, 以监测对象分组统计数据有多个测点的需要出结果
*/
List < String > loadTypeSubStation = Stream . of ( " 重要变电站 " , " 一类变电站 " , " 跨省计量关点 " ) . collect ( Collectors . toList ( ) ) ;
loadTypeLineList = loadTypeLineList . stream ( ) . filter ( item - > ! loadTypeSubStation . contains ( item . getLoadType ( ) ) ) . collect ( Collectors . toList ( ) ) ;
// 监测对象分组
Map < String , List < LinePollution > > loadTypeMap = loadTypeLineList . stream ( ) . collect ( Collectors . groupingBy ( LinePollution : : getObjName ) ) ;
List < ObjPollution > objPollutions = new ArrayList < > ( ) ;
Set < String > objNameSet = loadTypeMap . keySet ( ) ;
for ( String objName : objNameSet ) {
ObjPollution objPollution = new ObjPollution ( ) ;
List < LinePollution > 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 < LoadTypeLineItemPollution > 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 < LinePollution > linePollutionList = pollutionCalcList ( startDate , endDate ) ;
// 整合变电站待导出的数据
List < GdPollution > gdPollutionList = new ArrayList < > ( ) ;
// 以供电公司分组
Map < String , List < LinePollution > > gdMap = linePollutionList . stream ( )
. collect ( Collectors . groupingBy ( LinePollution : : getGdName ) ) ;
// 同一供电公司以变电站分组
Set < String > gdNameSet = gdMap . keySet ( ) ;
for ( String gdName : gdNameSet ) {
// 初始化gd实体
GdPollution gdPollution = new GdPollution ( ) ;
gdPollution . setGdName ( gdName ) ;
List < LinePollution > gdLinePollution = gdMap . get ( gdName ) ;
// 以变电站分组
Map < String , List < LinePollution > > subMap = gdLinePollution . stream ( )
. collect ( Collectors . groupingBy ( LinePollution : : getSubStationName ) ) ;
Set < String > subNameMap = subMap . keySet ( ) ;
List < SubstationPollution > substationPollutions = new ArrayList < > ( ) ;
for ( String subName : subNameMap ) {
// 初始化变电站实体
SubstationPollution substationPollution = new SubstationPollution ( ) ;
substationPollution . setSubStationName ( subName ) ;
List < LinePollution > subLinePollution = subMap . get ( subName ) ;
// 需要区分电网侧、非电网侧
Map < String , List < LinePollution > > powerFlagLinePollution = subLinePollution . stream ( ) . collect ( Collectors . groupingBy ( LinePollution : : getPowerFlag ) ) ;
List < PowerFlagPollution > powerFlagPollutionList = new ArrayList < > ( ) ;
// 电网侧
List < LinePollution > temp = powerFlagLinePollution . get ( " 电网侧 " ) ;
PowerFlagPollution powerFlagPollution1 = new PowerFlagPollution ( ) ;
powerFlagPollution1 . setPowerFlag ( " 电网侧 " ) ;
List < LineItemPollution > 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 < LinePollution > temp1 = powerFlagLinePollution . get ( " 非电网侧 " ) ;
PowerFlagPollution powerFlagPollution2 = new PowerFlagPollution ( ) ;
powerFlagPollution2 . setPowerFlag ( " 非电网侧 " ) ;
List < LineItemPollution > 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<SubstationPollution> 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 < String > addList ( List < RStatPollutionSubstationM > substationMlist ) {
List < String > info = new ArrayList < > ( ) ;