@@ -3,6 +3,7 @@ package com.njcn.harmonic.service.impl;
import cn.hutool.core.collection.CollUtil ;
import cn.hutool.core.collection.CollectionUtil ;
import cn.hutool.core.date.DateUtil ;
import cn.hutool.core.util.NumberUtil ;
import cn.hutool.core.util.ObjectUtil ;
import cn.hutool.core.util.StrUtil ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
@@ -51,12 +52,6 @@ import com.njcn.system.enums.DicDataEnum;
import com.njcn.user.api.DeptFeignClient ;
import com.njcn.user.pojo.po.Dept ;
import com.njcn.web.utils.RequestUtil ;
import lombok.AllArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.beans.BeanUtils ;
import org.springframework.stereotype.Service ;
import org.springframework.util.CollectionUtils ;
import java.math.BigDecimal ;
import java.math.RoundingMode ;
@@ -66,8 +61,15 @@ import java.util.function.Function;
import java.util.function.Predicate ;
import java.util.stream.Collectors ;
import lombok.AllArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.beans.BeanUtils ;
import org.springframework.stereotype.Service ;
import org.springframework.util.CollectionUtils ;
/**
*
* Description:
* 接口文档访问地址: http://serverIP:port/swagger-ui.html
* Date: 2022/10/13 8:56【需求编号】
@@ -123,66 +125,66 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
@Override
public List < PollutionSubstationVO > getPollutionSubstationData ( PollutionSubstationQuryParam pollutionSubstationQuryParam ) {
List < PollutionSubstationVO > pollutionSubstationVOList = new ArrayList < > ( ) ;
List < PollutionSubstationVO > pollutionSubstationVOList = new ArrayList < > ( ) ;
/*根据部门获取变电站详情*/
HarmonicPublicParam harmonicPublicParam = new HarmonicPublicParam ( ) ;
BeanUtils . copyProperties ( pollutionSubstationQuryParam , harmonicPublicParam ) ;
BeanUtils . copyProperties ( pollutionSubstationQuryParam , harmonicPublicParam ) ;
harmonicPublicParam . setServerName ( generalInfo . getMicroServiceName ( ) ) ;
List < PollutionSubstationDTO > pollutionSubstationDTOList = new ArrayList < > ( ) ;
List < GeneralDeviceDTO > sub = generalDeviceInfoClient . getPracticalRunDeviceInfoAsSubstation ( harmonicPublicParam ) . getData ( ) ;
sub . forEach ( item - > {
sub . forEach ( item - > {
PollutionSubstationDTO pollutionSubstationDTO = lineFeignClient . getSubstationInfo ( item . getIndex ( ) ) . getData ( ) ;
pollutionSubstationDTOList . add ( pollutionSubstationDTO ) ;
} ) ;
List < String > collect = pollutionSubstationDTOList . stream ( ) . map ( PollutionSubstationDTO : : getId ) . collect ( Collectors . toList ( ) ) ;
List < SubstationDTO > locationData = substationFeignClient . getSubstationById ( collect ) . getData ( ) ;
List < String > collect = pollutionSubstationDTOList . stream ( ) . map ( PollutionSubstationDTO : : getId ) . collect ( Collectors . toList ( ) ) ;
List < SubstationDTO > locationData = substationFeignClient . getSubstationById ( collect ) . getData ( ) ;
/*todo 后期可以把locationData存入redis*/
/*把所有的变电站的污染指数查出来*/
QueryWrapper < RStatPollutionSubstationM > wrapper = new QueryWrapper < > ( ) ;
wrapper . in ( " substation_id " , collect ) .
eq ( " pollution_type " , pollutionSubstationQuryParam . getPollutionStatis ( ) . getId ( ) ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m') " , pollutionSubstationQuryParam . getLocalDate ( ) ) ;
List < RStatPollutionSubstationM > rStatPollutionSubstationMList = pollutionSubstationMMapper . selectList ( wrapper ) ;
QueryWrapper < RStatPollutionSubstationM > wrapper = new QueryWrapper < > ( ) ;
wrapper . in ( " substation_id " , collect ) .
eq ( " pollution_type " , pollutionSubstationQuryParam . getPollutionStatis ( ) . getId ( ) ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m') " , pollutionSubstationQuryParam . getLocalDate ( ) ) ;
List < RStatPollutionSubstationM > rStatPollutionSubstationMList = pollutionSubstationMMapper . selectList ( wrapper ) ;
pollutionSubstationDTOList . forEach ( substationInfo - > {
pollutionSubstationDTOList . forEach ( substationInfo - > {
Integer lineCount = lineFeignClient . getLineCountBySubstation ( substationInfo . getId ( ) ) . getData ( ) ;
Integer deviceCount = lineFeignClient . getDeviceCountBySubstation ( substationInfo . getId ( ) ) . getData ( ) ;
PollutionSubstationVO pollutionSubstationVO = new PollutionSubstationVO ( ) ;
pollutionSubstationVO . setSubstationId ( substationInfo . getId ( ) ) ;
pollutionSubstationVO . setSubstationName ( substationInfo . getName ( ) ) ;
pollutionSubstationVO . setDeviceCount ( deviceCount ) ;
pollutionSubstationVO . setLineCount ( lineCount ) ;
Integer lineCount = lineFeignClient . getLineCountBySubstation ( substationInfo . getId ( ) ) . getData ( ) ;
Integer deviceCount = lineFeignClient . getDeviceCountBySubstation ( substationInfo . getId ( ) ) . getData ( ) ;
PollutionSubstationVO pollutionSubstationVO = new PollutionSubstationVO ( ) ;
pollutionSubstationVO . setSubstationId ( substationInfo . getId ( ) ) ;
pollutionSubstationVO . setSubstationName ( substationInfo . getName ( ) ) ;
pollutionSubstationVO . setDeviceCount ( deviceCount ) ;
pollutionSubstationVO . setLineCount ( lineCount ) ;
/*todo 添加经纬度接口返回数据暂时没有*/
List < SubstationDTO > substationDTOList = locationData . stream ( )
. filter ( temp - > Objects . equals ( substationInfo . getId ( ) , temp . getId ( ) ) )
. collect ( Collectors . toList ( ) ) ;
List < SubstationDTO > substationDTOList = locationData . stream ( )
. filter ( temp - > Objects . equals ( substationInfo . getId ( ) , temp . getId ( ) ) )
. collect ( Collectors . toList ( ) ) ;
SubstationDTO substationDTO = new SubstationDTO ( ) ;
if ( CollectionUtils . isEmpty ( substationDTOList ) ) {
throw new BusinessException ( CommonResponseEnum . INTERNAL_ERROR ) ;
} else {
substationDTO = substationDTOList . get ( 0 ) ;
SubstationDTO substationDTO = new SubstationDTO ( ) ;
if ( CollectionUtils . isEmpty ( substationDTOList ) ) {
throw new BusinessException ( CommonResponseEnum . INTERNAL_ERROR ) ;
} else {
substationDTO = substationDTOList . get ( 0 ) ;
}
pollutionSubstationVO . setLatitude ( substationDTO . getLat ( ) ) ;
pollutionSubstationVO . setLongitude ( substationDTO . getLng ( ) ) ;
pollutionSubstationVO . setLatitude ( substationDTO . getLat ( ) ) ;
pollutionSubstationVO . setLongitude ( substationDTO . getLng ( ) ) ;
List < RStatPollutionSubstationM > rStatPollutionSubstationMS = rStatPollutionSubstationMList . stream ( ) .
filter ( temp - > Objects . equals ( substationInfo . getId ( ) , temp . getSubstationId ( ) ) )
. collect ( Collectors . toList ( ) ) ;
List < RStatPollutionSubstationM > rStatPollutionSubstationMS = rStatPollutionSubstationMList . stream ( ) .
filter ( temp - > Objects . equals ( substationInfo . getId ( ) , temp . getSubstationId ( ) ) )
. collect ( Collectors . toList ( ) ) ;
Double value = 3 . 14159 ;
if ( ! CollectionUtils . isEmpty ( rStatPollutionSubstationMS ) ) {
value = rStatPollutionSubstationMS . get ( 0 ) . getValue ( ) ;
if ( ! CollectionUtils . isEmpty ( rStatPollutionSubstationMS ) ) {
value = rStatPollutionSubstationMS . get ( 0 ) . getValue ( ) ;
}
pollutionSubstationVO . setPollutionData ( value ) ;
pollutionSubstationVO . setPollutionStatis ( pollutionSubstationQuryParam . getStatisticalType ( ) . getName ( ) ) ;
pollutionSubstationVOList . add ( pollutionSubstationVO ) ;
pollutionSubstationVO . setPollutionData ( value ) ;
pollutionSubstationVO . setPollutionStatis ( pollutionSubstationQuryParam . getStatisticalType ( ) . getName ( ) ) ;
pollutionSubstationVOList . add ( pollutionSubstationVO ) ;
} ) ;
List < PollutionSubstationVO > result = pollutionSubstationVOList . stream ( ) . sorted ( Comparator . comparing ( PollutionSubstationVO : : getPollutionData ) . reversed ( ) ) . collect ( Collectors . toList ( ) ) ;
List < PollutionSubstationVO > result = pollutionSubstationVOList . stream ( ) . sorted ( Comparator . comparing ( PollutionSubstationVO : : getPollutionData ) . reversed ( ) ) . collect ( Collectors . toList ( ) ) ;
return result ;
}
@@ -197,8 +199,8 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
@Override
public List < PollutionVO > getDeptSubstationRelations ( HarmonicPublicParam harmonicPublicParam ) {
List < PollutionVO > list = new ArrayList < > ( ) ;
String pollutionType = harmonicPublicParam . getStatisticalType ( ) . getId ( ) ;
String searchBeginTime = harmonicPublicParam . getSearchBeginTime ( ) . substring ( 0 , 10 ) ;
String pollutionType = harmonicPublicParam . getStatisticalType ( ) . getId ( ) ;
String searchBeginTime = harmonicPublicParam . getSearchBeginTime ( ) . substring ( 0 , 10 ) ;
if ( StringUtils . isBlank ( RequestUtil . getDeptIndex ( ) ) ) {
return list ;
}
@@ -210,18 +212,18 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
//获取主网台账信息
List < PmsGeneralDeviceDTO > orgList = pmsGeneralDeviceInfoClient . getPmsDeviceInfoWithInOrg ( pmsDeviceInfoParam ) . getData ( ) ;
orgList . forEach ( temp - > {
PollutionVO pollutionVO = new PollutionVO ( ) ;
String detpid = temp . getIndex ( ) ;
String name = temp . getName ( ) ;
List < String > powers = temp . getPowerrIdList ( ) ;
pollutionVO . setId ( detpid ) ;
pollutionVO . setName ( name + " \ n( " + temp . getMonitorIdList ( ) . size ( ) + " ) " ) ;
pollutionVO . setData ( 3 . 14159 ) ;
setData ( harmonicPublicParam , pollutionType , searchBeginTime , harmonicPublicParam . getSearchEndTime ( ) , pollutionVO , detpid ) ;
if ( CollectionUtil . isNotEmpty ( powers ) ) {
PollutionVO pollutionVO = new PollutionVO ( ) ;
String detpid = temp . getIndex ( ) ;
String name = temp . getName ( ) ;
List < String > powers = temp . getPowerrIdList ( ) ;
pollutionVO . setId ( detpid ) ;
pollutionVO . setName ( name + " \ n( " + temp . getMonitorIdList ( ) . size ( ) + " ) " ) ;
pollutionVO . setData ( 3 . 14159 ) ;
setData ( harmonicPublicParam , pollutionType , searchBeginTime , harmonicPublicParam . getSearchEndTime ( ) , pollutionVO , detpid ) ;
if ( CollectionUtil . isNotEmpty ( powers ) ) {
//子集变电站
List < PollutionVO > powersVO = new ArrayList < > ( ) ;
PmsStatationStatInfoParam param = new PmsStatationStatInfoParam ( ) ;
PmsStatationStatInfoParam param = new PmsStatationStatInfoParam ( ) ;
param . setPowerIds ( powers ) ;
List < PmsStatationStatInfoDTO > data = statationStatClient . getStatationStatInfo ( param ) . getData ( ) ;
//去重解决重复数据
@@ -229,24 +231,24 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
( Collectors . toCollection ( ( ) - >
new TreeSet < > ( Comparator . comparing ( o - > o . getPowerId ( ) ) ) ) , ArrayList : : new ) ) ;
Map < String , Double > stringDoubleMap = setPmsSubData ( harmonicPublicParam , pollutionType , searchBeginTime , powers ) ;
if ( CollectionUtil . isNotEmpty ( data ) ) {
dsData . forEach ( power - > {
PollutionVO pollutionsubVO = new PollutionVO ( ) ;
pollutionsubVO . setId ( power . getPowerId ( ) ) ;
pollutionsubVO . setName ( power . getPowerName ( ) ) ;
pollutionsubVO . setPid ( temp . getIndex ( ) ) ;
if ( CollectionUtil . isNotEmpty ( stringDoubleMap ) ) {
if ( stringDoubleMap . containsKey ( power . getPowerId ( ) ) ) {
if ( CollectionUtil . isNotEmpty ( data ) ) {
dsData . forEach ( power - > {
PollutionVO pollutionsubVO = new PollutionVO ( ) ;
pollutionsubVO . setId ( power . getPowerId ( ) ) ;
pollutionsubVO . setName ( power . getPowerName ( ) ) ;
pollutionsubVO . setPid ( temp . getIndex ( ) ) ;
if ( CollectionUtil . isNotEmpty ( stringDoubleMap ) ) {
if ( stringDoubleMap . containsKey ( power . getPowerId ( ) ) ) {
pollutionsubVO . setData ( stringDoubleMap . get ( power . getPowerId ( ) ) ) ;
}
}
powersVO . add ( pollutionsubVO ) ;
powersVO . add ( pollutionsubVO ) ;
} ) ;
}
powersVO . sort ( ( item1 , item2 ) - > item2 . getData ( ) . compareTo ( item1 . getData ( ) ) ) ;
pollutionVO . setChildren ( powersVO ) ;
pollutionVO . setChildren ( powersVO ) ;
}
list . add ( pollutionVO ) ;
list . add ( pollutionVO ) ;
} ) ;
} else {
@@ -254,7 +256,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
List < GeneralDeviceDTO > sub = generalDeviceInfoClient . getPracticalRunDeviceInfo ( harmonicPublicParam ) . getData ( ) ;
for ( GeneralDeviceDTO temp : sub ) {
List < String > subIndexes = temp . getSubIndexes ( ) ;
if ( CollectionUtil . isEmpty ( subIndexes ) ) {
if ( CollectionUtil . isEmpty ( subIndexes ) ) {
continue ;
}
PollutionVO pollutionVO = new PollutionVO ( ) ;
@@ -262,9 +264,9 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
String name = temp . getName ( ) ;
pollutionVO . setId ( detpid ) ;
pollutionVO . setName ( name + " \ n( " + temp . getLineIndexes ( ) . size ( ) + " ) " ) ;
pollutionVO . setName ( name + " \ n( " + temp . getLineIndexes ( ) . size ( ) + " ) " ) ;
pollutionVO . setData ( 3 . 14159 ) ;
setData ( harmonicPublicParam , pollutionType , searchBeginTime , harmonicPublicParam . getSearchEndTime ( ) , pollutionVO , detpid ) ;
setData ( harmonicPublicParam , pollutionType , searchBeginTime , harmonicPublicParam . getSearchEndTime ( ) , pollutionVO , detpid ) ;
List < PollutionVO > subPollutionVO = new ArrayList < > ( ) ;
subIndexes . forEach ( subIndex - > {
PollutionVO pollutionsubVO = new PollutionVO ( ) ;
@@ -274,14 +276,14 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
pollutionsubVO . setName ( pollutionSubstationDTO . getName ( ) ) ;
pollutionsubVO . setPid ( temp . getIndex ( ) ) ;
pollutionsubVO . setData ( 3 . 14159 ) ;
setSubData ( harmonicPublicParam , pollutionType , searchBeginTime , harmonicPublicParam . getSearchEndTime ( ) , pollutionsubVO , id ) ;
setSubData ( harmonicPublicParam , pollutionType , searchBeginTime , harmonicPublicParam . getSearchEndTime ( ) , pollutionsubVO , id ) ;
subPollutionVO . add ( pollutionsubVO ) ;
} ) ;
pollutionVO . setChildren ( subPollutionVO ) ;
list . add ( pollutionVO ) ;
}
}
if ( ! CollectionUtils . isEmpty ( list ) ) {
if ( ! CollectionUtils . isEmpty ( list ) ) {
List < PollutionVO > listSort = list . stream ( ) . filter ( x - > x . getData ( ) ! = 3 . 14159 ) . sorted ( Comparator . comparing ( PollutionVO : : getData ) . reversed ( ) . thenComparing ( PollutionVO : : getName ) ) . collect ( Collectors . toList ( ) ) ;
listSort . addAll ( list . stream ( ) . filter ( x - > x . getData ( ) = = 3 . 14159 ) . collect ( Collectors . toList ( ) ) ) ;
return listSort ;
@@ -289,125 +291,125 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
return list ;
}
private Map < String , Double > setPmsSubData ( HarmonicPublicParam harmonicPublicParam , String pollutionType , String searchBeginTime , List < String > id ) {
if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_YEAR ) ) {
QueryWrapper < RStatPollutionSubstationYPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . in ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
private Map < String , Double > setPmsSubData ( HarmonicPublicParam harmonicPublicParam , String pollutionType , String searchBeginTime , List < String > id ) {
if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_YEAR ) ) {
QueryWrapper < RStatPollutionSubstationYPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . in ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
List < RStatPollutionSubstationYPO > s = pollutionSubstationYPOMapper . selectList ( wrapper ) ;
return s . stream ( ) . collect ( Collectors . toMap ( RStatPollutionSubstationYPO : : getSubstationId , RStatPollutionSubstationYPO : : getValue ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_QUARTER ) ) {
QueryWrapper < RStatPollutionSubstationQPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . in ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
return s . stream ( ) . collect ( Collectors . toMap ( RStatPollutionSubstationYPO : : getSubstationId , RStatPollutionSubstationYPO : : getValue ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_QUARTER ) ) {
QueryWrapper < RStatPollutionSubstationQPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . in ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
List < RStatPollutionSubstationQPO > s = pollutionSubstationQPOMapper . selectList ( wrapper ) ;
return s . stream ( ) . collect ( Collectors . toMap ( RStatPollutionSubstationQPO : : getSubstationId , RStatPollutionSubstationQPO : : getValue ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_MONTH ) ) {
QueryWrapper < RStatPollutionSubstationM > wrapper = new QueryWrapper < > ( ) ;
wrapper . in ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_MONTH ) ) {
QueryWrapper < RStatPollutionSubstationM > wrapper = new QueryWrapper < > ( ) ;
wrapper . in ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
List < RStatPollutionSubstationM > s = pollutionSubstationMMapper . selectList ( wrapper ) ;
return s . stream ( ) . collect ( Collectors . toMap ( RStatPollutionSubstationM : : getSubstationId , RStatPollutionSubstationM : : getValue ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_DAY ) ) {
QueryWrapper < RStatPollutionSubstationDPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . in ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_DAY ) ) {
QueryWrapper < RStatPollutionSubstationDPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . in ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
List < RStatPollutionSubstationDPO > s = pollutionSubstationDPOMapper . selectList ( wrapper ) ;
return s . stream ( ) . collect ( Collectors . toMap ( RStatPollutionSubstationDPO : : getSubstationId , RStatPollutionSubstationDPO : : getValue ) ) ;
}
return null ;
}
private void setSubData ( HarmonicPublicParam harmonicPublicParam , String pollutionType , String searchBeginTime , String searchEndTime , PollutionVO pollutionsubVO , String id ) {
if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_YEAR ) ) {
QueryWrapper < RStatPollutionSubstationYPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationYPO rStatPollutionSubstationYPO = pollutionSubstationYPOMapper . selectOne ( wrapper ) ;
private void setSubData ( HarmonicPublicParam harmonicPublicParam , String pollutionType , String searchBeginTime , String searchEndTime , PollutionVO pollutionsubVO , String id ) {
if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_YEAR ) ) {
QueryWrapper < RStatPollutionSubstationYPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationYPO rStatPollutionSubstationYPO = pollutionSubstationYPOMapper . selectOne ( wrapper ) ;
Optional . ofNullable ( rStatPollutionSubstationYPO ) . ifPresent ( t - > pollutionsubVO . setData ( t . getValue ( ) ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_QUARTER ) ) {
QueryWrapper < RStatPollutionSubstationQPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationQPO rStatPollutionSubstationQPO = pollutionSubstationQPOMapper . selectOne ( wrapper ) ;
Optional . ofNullable ( rStatPollutionSubstationYPO ) . ifPresent ( t - > pollutionsubVO . setData ( t . getValue ( ) ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_QUARTER ) ) {
QueryWrapper < RStatPollutionSubstationQPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationQPO rStatPollutionSubstationQPO = pollutionSubstationQPOMapper . selectOne ( wrapper ) ;
Optional . ofNullable ( rStatPollutionSubstationQPO ) . ifPresent ( t - > pollutionsubVO . setData ( t . getValue ( ) ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_MONTH ) ) {
QueryWrapper < RStatPollutionSubstationM > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationM rStatPollutionSubstationM = pollutionSubstationMMapper . selectOne ( wrapper ) ;
Optional . ofNullable ( rStatPollutionSubstationQPO ) . ifPresent ( t - > pollutionsubVO . setData ( t . getValue ( ) ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_MONTH ) ) {
QueryWrapper < RStatPollutionSubstationM > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationM rStatPollutionSubstationM = pollutionSubstationMMapper . selectOne ( wrapper ) ;
Optional . ofNullable ( rStatPollutionSubstationM ) . ifPresent ( t - > pollutionsubVO . setData ( t . getValue ( ) ) ) ;
Optional . ofNullable ( rStatPollutionSubstationM ) . ifPresent ( t - > pollutionsubVO . setData ( t . getValue ( ) ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_DAY ) ) {
QueryWrapper < RStatPollutionSubstationDPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationDPO rStatPollutionSubstationDPO = pollutionSubstationDPOMapper . selectOne ( wrapper ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_DAY ) ) {
QueryWrapper < RStatPollutionSubstationDPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationDPO rStatPollutionSubstationDPO = pollutionSubstationDPOMapper . selectOne ( wrapper ) ;
Optional . ofNullable ( rStatPollutionSubstationDPO ) . ifPresent ( t - > pollutionsubVO . setData ( t . getValue ( ) ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_WEEK ) ) {
QueryWrapper < RStatPollutionSubstationDPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
between ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime , searchEndTime )
. orderByDesc ( " value " ) . last ( " limit 1 " ) ;
RStatPollutionSubstationDPO rStatPollutionSubstationDPO = pollutionSubstationDPOMapper . selectOne ( wrapper ) ;
Optional . ofNullable ( rStatPollutionSubstationDPO ) . ifPresent ( t - > pollutionsubVO . setData ( t . getValue ( ) ) ) ;
Optional . ofNullable ( rStatPollutionSubstationDPO ) . ifPresent ( t - > pollutionsubVO . setData ( t . getValue ( ) ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_WEEK ) ) {
QueryWrapper < RStatPollutionSubstationDPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
between ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime , searchEndTime )
. orderByDesc ( " value " ) . last ( " limit 1 " ) ;
RStatPollutionSubstationDPO rStatPollutionSubstationDPO = pollutionSubstationDPOMapper . selectOne ( wrapper ) ;
Optional . ofNullable ( rStatPollutionSubstationDPO ) . ifPresent ( t - > pollutionsubVO . setData ( t . getValue ( ) ) ) ;
}
}
private void setData ( HarmonicPublicParam harmonicPublicParam , String pollutionType , String searchBeginTime , String searchEndTime , PollutionVO pollutionVO , String detpid ) {
private void setData ( HarmonicPublicParam harmonicPublicParam , String pollutionType , String searchBeginTime , String searchEndTime , PollutionVO pollutionVO , String detpid ) {
if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_YEAR ) ) {
QueryWrapper < RStatPollutionOrgYPO > rStatPollutionOrgYPOQueryWrapper = new QueryWrapper < > ( ) ;
rStatPollutionOrgYPOQueryWrapper . eq ( " org_id " , detpid ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionOrgYPO rStatPollutionOrgYPO = rStatPollutionOrgYPOMapper . selectOne ( rStatPollutionOrgYPOQueryWrapper ) ;
Optional . ofNullable ( rStatPollutionOrgYPO ) . ifPresent ( a - > pollutionVO . setData ( BigDecimal . valueOf ( a . getValue ( ) ) . setScale ( 2 , RoundingMode . UP ) . doubleValue ( ) ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_QUARTER ) ) {
QueryWrapper < RStatPollutionOrgQPO > rStatPollutionOrgQPOQueryWrapper = new QueryWrapper < > ( ) ;
rStatPollutionOrgQPOQueryWrapper . eq ( " org_id " , detpid ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionOrgQPO rStatPollutionOrgQPO = rStatPollutionOrgQPOMapper . selectOne ( rStatPollutionOrgQPOQueryWrapper ) ;
Optional . ofNullable ( rStatPollutionOrgQPO ) . ifPresent ( a - > pollutionVO . setData ( BigDecimal . valueOf ( a . getValue ( ) ) . setScale ( 2 , RoundingMode . UP ) . doubleValue ( ) ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_MONTH ) ) {
QueryWrapper < RStatPollutionOrgMPO > rStatPollutionOrgMPOQueryWrapper = new QueryWrapper < > ( ) ;
rStatPollutionOrgMPOQueryWrapper . eq ( " org_id " , detpid ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionOrgMPO rStatPollutionOrgMPO = rStatPollutionOrgMPOMapper . selectOne ( rStatPollutionOrgMPOQueryWrapper ) ;
Optional . ofNullable ( rStatPollutionOrgMPO ) . ifPresent ( a - > pollutionVO . setData ( BigDecimal . valueOf ( a . getValue ( ) ) . setScale ( 2 , RoundingMode . UP ) . doubleValue ( ) ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_DAY ) ) {
QueryWrapper < RStatPollutionOrgDPO > rStatPollutionOrgDPOQueryWrapper = new QueryWrapper < > ( ) ;
rStatPollutionOrgDPOQueryWrapper . eq ( " org_id " , detpid ) .
eq ( " pollution_type " , pollutionType ) .
between ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime , searchEndTime )
if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_YEAR ) ) {
QueryWrapper < RStatPollutionOrgYPO > rStatPollutionOrgYPOQueryWrapper = new QueryWrapper < > ( ) ;
rStatPollutionOrgYPOQueryWrapper . eq ( " org_id " , detpid ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionOrgYPO rStatPollutionOrgYPO = rStatPollutionOrgYPOMapper . selectOne ( rStatPollutionOrgYPOQueryWrapper ) ;
Optional . ofNullable ( rStatPollutionOrgYPO ) . ifPresent ( a - > pollutionVO . setData ( BigDecimal . valueOf ( a . getValue ( ) ) . setScale ( 2 , RoundingMode . UP ) . doubleValue ( ) ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_QUARTER ) ) {
QueryWrapper < RStatPollutionOrgQPO > rStatPollutionOrgQPOQueryWrapper = new QueryWrapper < > ( ) ;
rStatPollutionOrgQPOQueryWrapper . eq ( " org_id " , detpid ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionOrgQPO rStatPollutionOrgQPO = rStatPollutionOrgQPOMapper . selectOne ( rStatPollutionOrgQPOQueryWrapper ) ;
Optional . ofNullable ( rStatPollutionOrgQPO ) . ifPresent ( a - > pollutionVO . setData ( BigDecimal . valueOf ( a . getValue ( ) ) . setScale ( 2 , RoundingMode . UP ) . doubleValue ( ) ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_MONTH ) ) {
QueryWrapper < RStatPollutionOrgMPO > rStatPollutionOrgMPOQueryWrapper = new QueryWrapper < > ( ) ;
rStatPollutionOrgMPOQueryWrapper . eq ( " org_id " , detpid ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionOrgMPO rStatPollutionOrgMPO = rStatPollutionOrgMPOMapper . selectOne ( rStatPollutionOrgMPOQueryWrapper ) ;
Optional . ofNullable ( rStatPollutionOrgMPO ) . ifPresent ( a - > pollutionVO . setData ( BigDecimal . valueOf ( a . getValue ( ) ) . setScale ( 2 , RoundingMode . UP ) . doubleValue ( ) ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_DAY ) ) {
QueryWrapper < RStatPollutionOrgDPO > rStatPollutionOrgDPOQueryWrapper = new QueryWrapper < > ( ) ;
rStatPollutionOrgDPOQueryWrapper . eq ( " org_id " , detpid ) .
eq ( " pollution_type " , pollutionType ) .
between ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime , searchEndTime )
. orderByDesc ( " value " ) . last ( " limit 1 " ) ;
RStatPollutionOrgDPO rStatPollutionOrgDPO = rStatPollutionOrgDPOMapper . selectOne ( rStatPollutionOrgDPOQueryWrapper ) ;
Optional . ofNullable ( rStatPollutionOrgDPO ) . ifPresent ( a - > pollutionVO . setData ( BigDecimal . valueOf ( a . getValue ( ) ) . setScale ( 2 , RoundingMode . UP ) . doubleValue ( ) ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_WEEK ) ) {
QueryWrapper < RStatPollutionOrgDPO > rStatPollutionOrgDPOQueryWrapper = new QueryWrapper < > ( ) ;
rStatPollutionOrgDPOQueryWrapper . eq ( " org_id " , detpid ) .
eq ( " pollution_type " , pollutionType ) .
between ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime , searchEndTime )
RStatPollutionOrgDPO rStatPollutionOrgDPO = rStatPollutionOrgDPOMapper . selectOne ( rStatPollutionOrgDPOQueryWrapper ) ;
Optional . ofNullable ( rStatPollutionOrgDPO ) . ifPresent ( a - > pollutionVO . setData ( BigDecimal . valueOf ( a . getValue ( ) ) . setScale ( 2 , RoundingMode . UP ) . doubleValue ( ) ) ) ;
} else if ( Objects . equals ( harmonicPublicParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_WEEK ) ) {
QueryWrapper < RStatPollutionOrgDPO > rStatPollutionOrgDPOQueryWrapper = new QueryWrapper < > ( ) ;
rStatPollutionOrgDPOQueryWrapper . eq ( " org_id " , detpid ) .
eq ( " pollution_type " , pollutionType ) .
between ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime , searchEndTime )
. orderByDesc ( " value " ) . last ( " limit 1 " ) ;
RStatPollutionOrgDPO rStatPollutionOrgDPO = rStatPollutionOrgDPOMapper . selectOne ( rStatPollutionOrgDPOQueryWrapper ) ;
Optional . ofNullable ( rStatPollutionOrgDPO ) . ifPresent ( a - > pollutionVO . setData ( BigDecimal . valueOf ( a . getValue ( ) ) . setScale ( 2 , RoundingMode . UP ) . doubleValue ( ) ) ) ;
RStatPollutionOrgDPO rStatPollutionOrgDPO = rStatPollutionOrgDPOMapper . selectOne ( rStatPollutionOrgDPOQueryWrapper ) ;
Optional . ofNullable ( rStatPollutionOrgDPO ) . ifPresent ( a - > pollutionVO . setData ( BigDecimal . valueOf ( a . getValue ( ) ) . setScale ( 2 , RoundingMode . UP ) . doubleValue ( ) ) ) ;
}
}
@@ -422,15 +424,15 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
*/
@Override
public List < PollutionSubstationDTO > getSubstationInfoById ( HarmonicPublicParam deptParam ) {
String pollutionType = deptParam . getStatisticalType ( ) . getId ( ) ;
String searchBeginTime = deptParam . getSearchBeginTime ( ) . substring ( 0 , 10 ) ;
String pollutionType = deptParam . getStatisticalType ( ) . getId ( ) ;
String searchBeginTime = deptParam . getSearchBeginTime ( ) . substring ( 0 , 10 ) ;
List < PollutionSubstationDTO > list = new ArrayList < > ( ) ;
if ( deptParam . getType ( ) ! = 0 ) {
PmsDeviceInfoParam pmsDeviceInfoParam = new PmsDeviceInfoParam ( ) ;
//根据部门code获取部门id
Dept dept = deptFeignClient . getDeptByCode ( deptParam . getDeptIndex ( ) ) . getData ( ) ;
if ( ObjectUtil . isNull ( dept ) ) {
if ( ObjectUtil . isNull ( dept ) ) {
return list ;
}
pmsDeviceInfoParam . setDeptIndex ( dept . getId ( ) ) ;
@@ -438,11 +440,11 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
pmsDeviceInfoParam . setStatisticalType ( deptParam . getStatisticalType ( ) ) ;
//获取主网台账信息
List < PmsGeneralDeviceDTO > deviceList = pmsGeneralDeviceInfoClient . getPmsDeviceInfoWithInOrg ( pmsDeviceInfoParam ) . getData ( ) ;
deviceList . forEach ( temp - > {
List < String > powers = temp . getPowerrIdList ( ) ;
deviceList . forEach ( temp - > {
List < String > powers = temp . getPowerrIdList ( ) ;
//变电站不为空
if ( CollectionUtil . isNotEmpty ( powers ) ) {
PmsStatationStatInfoParam param = new PmsStatationStatInfoParam ( ) ;
if ( CollectionUtil . isNotEmpty ( powers ) ) {
PmsStatationStatInfoParam param = new PmsStatationStatInfoParam ( ) ;
param . setPowerIds ( powers ) ;
List < PmsStatationStatInfoDTO > data = statationStatClient . getStatationStatInfo ( param ) . getData ( ) ;
//去重解决重复数据
@@ -450,68 +452,68 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
( Collectors . toCollection ( ( ) - >
new TreeSet < > ( Comparator . comparing ( o - > o . getPowerId ( ) ) ) ) , ArrayList : : new ) ) ;
Map < String , Double > stringDoubleMap = setPmsSubData ( deptParam , pollutionType , searchBeginTime , powers ) ;
if ( CollectionUtil . isNotEmpty ( data ) ) {
dsData . forEach ( power - > {
PollutionSubstationDTO dto = new PollutionSubstationDTO ( ) ;
if ( CollectionUtil . isNotEmpty ( data ) ) {
dsData . forEach ( power - > {
PollutionSubstationDTO dto = new PollutionSubstationDTO ( ) ;
dto . setId ( power . getPowerId ( ) ) ;
dto . setName ( power . getPowerName ( ) ) ;
dto . setVoltageLevel ( power . getPowerVoltageLevel ( ) ) ;
if ( CollectionUtil . isNotEmpty ( stringDoubleMap ) ) {
if ( stringDoubleMap . containsKey ( power . getPowerId ( ) ) ) {
if ( CollectionUtil . isNotEmpty ( stringDoubleMap ) ) {
if ( stringDoubleMap . containsKey ( power . getPowerId ( ) ) ) {
dto . setData ( stringDoubleMap . get ( power . getPowerId ( ) ) ) ;
}
}
list . add ( dto ) ;
list . add ( dto ) ;
} ) ;
}
}
} ) ;
} else {
} else {
deptParam . setServerName ( generalInfo . getMicroServiceName ( ) ) ;
List < GeneralDeviceDTO > sub = generalDeviceInfoClient . getPracticalRunDeviceInfoAsSubstation ( deptParam ) . getData ( ) ;
sub . forEach ( item - > {
sub . forEach ( item - > {
PollutionSubstationDTO pollutionSubstationDTO = lineFeignClient . getSubstationInfo ( item . getIndex ( ) ) . getData ( ) ;
String id = pollutionSubstationDTO . getId ( ) ;
if ( Objects . equals ( deptParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_YEAR ) ) {
QueryWrapper < RStatPollutionSubstationYPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationYPO rStatPollutionSubstationYPO = pollutionSubstationYPOMapper . selectOne ( wrapper ) ;
String id = pollutionSubstationDTO . getId ( ) ;
if ( Objects . equals ( deptParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_YEAR ) ) {
QueryWrapper < RStatPollutionSubstationYPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationYPO rStatPollutionSubstationYPO = pollutionSubstationYPOMapper . selectOne ( wrapper ) ;
Optional . ofNullable ( rStatPollutionSubstationYPO ) . ifPresent ( t - > pollutionSubstationDTO . setData ( t . getValue ( ) ) ) ;
} else if ( Objects . equals ( deptParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_QUARTER ) ) {
QueryWrapper < RStatPollutionSubstationQPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationQPO rStatPollutionSubstationQPO = pollutionSubstationQPOMapper . selectOne ( wrapper ) ;
Optional . ofNullable ( rStatPollutionSubstationYPO ) . ifPresent ( t - > pollutionSubstationDTO . setData ( t . getValue ( ) ) ) ;
} else if ( Objects . equals ( deptParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_QUARTER ) ) {
QueryWrapper < RStatPollutionSubstationQPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationQPO rStatPollutionSubstationQPO = pollutionSubstationQPOMapper . selectOne ( wrapper ) ;
Optional . ofNullable ( rStatPollutionSubstationQPO ) . ifPresent ( t - > pollutionSubstationDTO . setData ( t . getValue ( ) ) ) ;
} else if ( Objects . equals ( deptParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_MONTH ) ) {
QueryWrapper < RStatPollutionSubstationM > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationM rStatPollutionSubstationM = pollutionSubstationMMapper . selectOne ( wrapper ) ;
Optional . ofNullable ( rStatPollutionSubstationQPO ) . ifPresent ( t - > pollutionSubstationDTO . setData ( t . getValue ( ) ) ) ;
} else if ( Objects . equals ( deptParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_MONTH ) ) {
QueryWrapper < RStatPollutionSubstationM > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationM rStatPollutionSubstationM = pollutionSubstationMMapper . selectOne ( wrapper ) ;
Optional . ofNullable ( rStatPollutionSubstationM ) . ifPresent ( t - > pollutionSubstationDTO . setData ( t . getValue ( ) ) ) ;
Optional . ofNullable ( rStatPollutionSubstationM ) . ifPresent ( t - > pollutionSubstationDTO . setData ( t . getValue ( ) ) ) ;
} else if ( Objects . equals ( deptParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_DAY ) ) {
QueryWrapper < RStatPollutionSubstationDPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationDPO rStatPollutionSubstationDPO = pollutionSubstationDPOMapper . selectOne ( wrapper ) ;
} else if ( Objects . equals ( deptParam . getReportFlag ( ) , BizParamConstant . STAT_BIZ_DAY ) ) {
QueryWrapper < RStatPollutionSubstationDPO > wrapper = new QueryWrapper < > ( ) ;
wrapper . eq ( " substation_id " , id ) .
eq ( " pollution_type " , pollutionType ) .
eq ( " DATE_FORMAT( data_date ,'%Y-%m-%d') " , searchBeginTime ) ;
RStatPollutionSubstationDPO rStatPollutionSubstationDPO = pollutionSubstationDPOMapper . selectOne ( wrapper ) ;
Optional . ofNullable ( rStatPollutionSubstationDPO ) . ifPresent ( t - > pollutionSubstationDTO . setData ( t . getValue ( ) ) ) ;
Optional . ofNullable ( rStatPollutionSubstationDPO ) . ifPresent ( t - > pollutionSubstationDTO . setData ( t . getValue ( ) ) ) ;
}
list . add ( pollutionSubstationDTO ) ;
} ) ;
}
if ( ! CollectionUtils . isEmpty ( list ) ) {
if ( ! CollectionUtils . isEmpty ( list ) ) {
return list . stream ( ) . sorted ( Comparator . comparing ( PollutionSubstationDTO : : getData ) . reversed ( ) . thenComparing ( PollutionSubstationDTO : : getName ) ) . collect ( Collectors . toList ( ) ) ;
}
return list ;
@@ -529,54 +531,54 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
harmonicPublicParam . setServerName ( generalInfo . getMicroServiceName ( ) ) ;
List < PollutionLineDTO > list = new ArrayList < > ( ) ;
String pollutionType = harmonicPublicParam . getStatisticalType ( ) . getId ( ) ;
String pollutionType = harmonicPublicParam . getStatisticalType ( ) . getId ( ) ;
PollutionParamDTO paramDTO = new PollutionParamDTO ( ) ;
if ( StringUtils . isBlank ( RequestUtil . getDeptIndex ( ) ) ) {
if ( StringUtils . isBlank ( RequestUtil . getDeptIndex ( ) ) ) {
return list ;
}
if ( harmonicPublicParam . getType ( ) ! = 0 ) {
PmsStatationStatInfoParam param = new PmsStatationStatInfoParam ( ) ;
PmsStatationStatInfoParam param = new PmsStatationStatInfoParam ( ) ;
param . setPowerIds ( Arrays . asList ( harmonicPublicParam . getId ( ) ) ) ;
//获取变电站详情
List < PmsStatationStatInfoDTO > data = statationStatClient . getStatationStatInfo ( param ) . getData ( ) ;
if ( CollectionUtil . isNotEmpty ( data ) ) {
if ( CollectionUtil . isNotEmpty ( data ) ) {
List < String > monitorId = data . stream ( ) . map ( PmsStatationStatInfoDTO : : getMonitorId ) . collect ( Collectors . toList ( ) ) ;
List < RMpPollutionDPO > lineData = rMpPollutionDPOMapper . selectMaxList ( monitorId , pollutionType , harmonicPublicParam . getSearchBeginTime ( ) , harmonicPublicParam . getSearchEndTime ( ) ) ;
List < RMpPollutionDPO > lineData = rMpPollutionDPOMapper . selectMaxList ( monitorId , pollutionType , harmonicPublicParam . getSearchBeginTime ( ) , harmonicPublicParam . getSearchEndTime ( ) ) ;
Map < String , Double > lineMap = lineData . stream ( ) . collect ( Collectors . toMap ( RMpPollutionDPO : : getLineId , RMpPollutionDPO : : getValue ) ) ;
PollutionLineDTO dto ;
for ( PmsStatationStatInfoDTO power : data ) {
dto = new PollutionLineDTO ( ) ;
dto = new PollutionLineDTO ( ) ;
dto . setId ( power . getMonitorId ( ) ) ;
dto . setName ( power . getMonitorName ( ) ) ;
dto . setPowerCompany ( power . getOrgName ( ) ) ;
dto . setSubstation ( power . getPowerName ( ) ) ;
dto . setBusBar ( power . getBusBarName ( ) ) ;
dto . setSubstationId ( power . getPowerId ( ) ) ;
if ( CollectionUtil . isNotEmpty ( lineMap ) ) {
if ( lineMap . containsKey ( power . getMonitorId ( ) ) ) {
if ( CollectionUtil . isNotEmpty ( lineMap ) ) {
if ( lineMap . containsKey ( power . getMonitorId ( ) ) ) {
dto . setData ( lineMap . get ( power . getMonitorId ( ) ) ) ;
}
}
list . add ( dto ) ;
list . add ( dto ) ;
}
}
} else {
} else {
List < String > line = new ArrayList < > ( ) ;
List < GeneralDeviceDTO > sub = generalDeviceInfoClient . getPracticalRunDeviceInfoAsSubstation ( harmonicPublicParam ) . getData ( ) ;
sub . forEach ( item - > {
if ( Objects . equals ( harmonicPublicParam . getId ( ) , item . getIndex ( ) ) ) {
if ( ! CollectionUtils . isEmpty ( item . getLineIndexes ( ) ) ) {
sub . forEach ( item - > {
if ( Objects . equals ( harmonicPublicParam . getId ( ) , item . getIndex ( ) ) ) {
if ( ! CollectionUtils . isEmpty ( item . getLineIndexes ( ) ) ) {
line . addAll ( item . getLineIndexes ( ) ) ;
}
}
} ) ;
if ( ! CollectionUtils . isEmpty ( line ) ) {
if ( ! CollectionUtils . isEmpty ( line ) ) {
paramDTO . setLineList ( line ) ;
list = lineFeignClient . getLineInfo ( paramDTO ) . getData ( ) ;
List < RMpPollutionDPO > lineData = rMpPollutionDPOMapper . selectMaxList ( line , pollutionType , harmonicPublicParam . getSearchBeginTime ( ) , harmonicPublicParam . getSearchEndTime ( ) ) ;
if ( ! CollectionUtils . isEmpty ( lineData ) ) {
list . stream ( ) . map ( list1 - > lineData . stream ( ) . filter ( list2 - > Objects . equals ( list1 . getId ( ) , list2 . getLineId ( ) ) ) . findAny ( ) . map ( m - > {
list1 . setData ( m . getValue ( ) ) ;
List < RMpPollutionDPO > lineData = rMpPollutionDPOMapper . selectMaxList ( line , pollutionType , harmonicPublicParam . getSearchBeginTime ( ) , harmonicPublicParam . getSearchEndTime ( ) ) ;
if ( ! CollectionUtils . isEmpty ( lineData ) ) {
list . stream ( ) . map ( list1 - > lineData . stream ( ) . filter ( list2 - > Objects . equals ( list1 . getId ( ) , list2 . getLineId ( ) ) ) . findAny ( ) . map ( m - > {
list1 . setData ( m . getValue ( ) ) ;
return list1 ;
} ) ) . collect ( Collectors . toList ( ) ) ;
}
@@ -589,9 +591,9 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
@Override
public List < PollutionLineDTO > getLineRankTop10 ( HarmonicPublicParam param ) {
List < PollutionLineDTO > list = new ArrayList < > ( ) ;
if ( param . getType ( ) = = 0 ) {
public List < PollutionLineDTO > getLineRankTop10 ( HarmonicPublicParam param ) {
List < PollutionLineDTO > list = new ArrayList < > ( ) ;
if ( param . getType ( ) = = 0 ) {
param . setServerName ( generalInfo . getMicroServiceName ( ) ) ;
List < String > lineList = new ArrayList < > ( ) ;
PollutionParamDTO paramDTO = new PollutionParamDTO ( ) ;
@@ -607,7 +609,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
if ( ! CollectionUtils . isEmpty ( lineList ) ) {
paramDTO . setLineList ( lineList ) ;
list = lineFeignClient . getLineInfo ( paramDTO ) . getData ( ) ;
List < PublicDTO > result = rMpPollutionDPOMapper . getTop10Line ( lineList , DateUtil . beginOfDay ( DateUtil . parse ( param . getSearchBeginTime ( ) ) ) , DateUtil . endOfDay ( DateUtil . parse ( param . getSearchEndTime ( ) ) ) , param . getStatisticalType ( ) . getId ( ) ) ;
List < PublicDTO > result = rMpPollutionDPOMapper . getTop10Line ( lineList , DateUtil . beginOfDay ( DateUtil . parse ( param . getSearchBeginTime ( ) ) ) , DateUtil . endOfDay ( DateUtil . parse ( param . getSearchEndTime ( ) ) ) , param . getStatisticalType ( ) . getId ( ) ) ;
if ( ! CollectionUtils . isEmpty ( result ) ) {
list . stream ( ) . map ( list1 - > result . stream ( ) . filter ( list2 - > Objects . equals ( list1 . getId ( ) , list2 . getId ( ) ) ) . findAny ( ) . map ( m - > {
list1 . setData ( m . getData ( ) ) ;
@@ -628,14 +630,15 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
pmsDeviceInfoParam . setStatisticalType ( param . getStatisticalType ( ) ) ;
//获取主网台账信息
List < PmsGeneralDeviceDTO > deviceList = pmsGeneralDeviceInfoClient . getPmsDeviceInfoWithInOrg ( pmsDeviceInfoParam ) . getData ( ) ;
List < String > monitorIdList = new ArrayList < > ( ) ;
List < String > monitorIdList = new ArrayList < > ( ) ;
deviceList . forEach ( dept - > {
monitorIdList . addAll ( dept . getMonitorIdList ( ) ) ;
} ) ;
if ( CollectionUtil . isNotEmpty ( monitorIdList ) ) {
if ( CollectionUtil . isNotEmpty ( monitorIdList ) ) {
//获取监测点数据
List < PublicDTO > lineData = rMpPollutionDPOMapper . getTop10Line ( monitorIdList , DateUtil . beginOfDay ( DateUtil . parse ( param . getSearchBeginTime ( ) ) ) , DateUtil . endOfDay ( DateUtil . parse ( param . getSearchEndTime ( ) ) ) , param . getStatisticalType ( ) . getId ( ) ) ; if ( CollectionUtil . isEmpty ( lineData ) ) {
List < PublicDTO > lineData = rMpPollutionDPOMapper . getTop10Line ( monitorIdList , DateUtil . beginOfDay ( DateUtil . parse ( param . getSearchBeginTime ( ) ) ) , DateUtil . endOfDay ( DateUtil . parse ( param . getSearchEndTime ( ) ) ) , param . getStatisticalType ( ) . getId ( ) ) ;
if ( CollectionUtil . isEmpty ( lineData ) ) {
return list ;
}
//获取主网监测点信息
@@ -643,9 +646,9 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
Map < String , Monitor > monitorMap = data . stream ( ) . collect ( Collectors . toMap ( Monitor : : getId , Function . identity ( ) , ( key1 , kye2 ) - > key1 ) ) ;
PollutionLineDTO dto ;
for ( PublicDTO lineDatum : lineData ) {
if ( monitorMap . containsKey ( lineDatum . getId ( ) ) ) {
if ( monitorMap . containsKey ( lineDatum . getId ( ) ) ) {
Monitor monitor = monitorMap . get ( lineDatum . getId ( ) ) ;
dto = new PollutionLineDTO ( ) ;
dto = new PollutionLineDTO ( ) ;
dto . setId ( monitor . getId ( ) ) ;
dto . setName ( monitor . getName ( ) ) ;
dto . setPowerCompany ( monitor . getOrgName ( ) ) ;
@@ -672,16 +675,16 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
//全部变电站
List < String > subAll = collect . stream ( ) . map ( SubGetBase : : getId ) . distinct ( ) . collect ( Collectors . toList ( ) ) ;
//国网变电站
List < String > subGw = collect . stream ( ) . filter ( x - > 1 = = x . getIsUpToGrid ( ) ) . map ( SubGetBase : : getId ) . distinct ( ) . collect ( Collectors . toList ( ) ) ;
List < String > subGw = collect . stream ( ) . filter ( x - > 1 = = x . getIsUpToGrid ( ) ) . map ( SubGetBase : : getId ) . distinct ( ) . collect ( Collectors . toList ( ) ) ;
GridDiagramVO vo = new GridDiagramVO ( ) ;
GridDiagramVO vo = new GridDiagramVO ( ) ;
List < Double > info = new ArrayList < > ( ) ;
List < Double > gwInfo = new ArrayList < > ( ) ;
if ( CollUtil . isNotEmpty ( subAll ) ) {
switch ( param . getType ( ) ) {
if ( CollUtil . isNotEmpty ( subAll ) ) {
switch ( param . getType ( ) ) {
case 1 :
List < RStatPollutionSubstationYPO > substationYlist = pollutionSubstationYPOMapper . selectList ( new LambdaQueryWrapper < RStatPollutionSubstationYPO > ( )
. select ( RStatPollutionSubstationYPO : : getSubstationId , RStatPollutionSubstationYPO : : getValue )
. select ( RStatPollutionSubstationYPO : : getSubstationId , RStatPollutionSubstationYPO : : getValue )
. in ( CollUtil . isNotEmpty ( subAll ) , RStatPollutionSubstationYPO : : getSubstationId , subAll )
. in ( CollUtil . isNotEmpty ( param . getIds ( ) ) , RStatPollutionSubstationYPO : : getPollutionType , param . getIds ( ) )
. ge ( StrUtil . isNotBlank ( param . getStartTime ( ) ) , RStatPollutionSubstationYPO : : getDataDate , DateUtil . beginOfDay ( DateUtil . parse ( param . getStartTime ( ) ) ) )
@@ -689,12 +692,12 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
) ;
info . addAll ( substationYlist . stream ( ) . map ( RStatPollutionSubstationYPO : : getValue ) . collect ( Collectors . toList ( ) ) ) ;
gwInfo . addAll ( substationYlist . stream ( )
. filter ( x - > subGw . contains ( x . getSubstationId ( ) ) )
. map ( RStatPollutionSubstationYPO : : getValue ) . collect ( Collectors . toList ( ) ) ) ;
. filter ( x - > subGw . contains ( x . getSubstationId ( ) ) )
. map ( RStatPollutionSubstationYPO : : getValue ) . collect ( Collectors . toList ( ) ) ) ;
break ;
case 2 :
List < RStatPollutionSubstationQPO > substationQlist = pollutionSubstationQPOMapper . selectList ( new LambdaQueryWrapper < RStatPollutionSubstationQPO > ( )
. select ( RStatPollutionSubstationQPO : : getSubstationId , RStatPollutionSubstationQPO : : getValue )
. select ( RStatPollutionSubstationQPO : : getSubstationId , RStatPollutionSubstationQPO : : getValue )
. in ( CollUtil . isNotEmpty ( subAll ) , RStatPollutionSubstationQPO : : getSubstationId , subAll )
. in ( CollUtil . isNotEmpty ( param . getIds ( ) ) , RStatPollutionSubstationQPO : : getPollutionType , param . getIds ( ) )
. ge ( StrUtil . isNotBlank ( param . getStartTime ( ) ) , RStatPollutionSubstationQPO : : getDataDate , DateUtil . beginOfDay ( DateUtil . parse ( param . getStartTime ( ) ) ) )
@@ -702,12 +705,12 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
) ;
info . addAll ( substationQlist . stream ( ) . map ( RStatPollutionSubstationQPO : : getValue ) . collect ( Collectors . toList ( ) ) ) ;
gwInfo . addAll ( substationQlist . stream ( )
. filter ( x - > subGw . contains ( x . getSubstationId ( ) ) )
. filter ( x - > subGw . contains ( x . getSubstationId ( ) ) )
. map ( RStatPollutionSubstationQPO : : getValue ) . collect ( Collectors . toList ( ) ) ) ;
break ;
case 3 :
List < RStatPollutionSubstationM > substationMlist = pollutionSubstationMMapper . selectList ( new LambdaQueryWrapper < RStatPollutionSubstationM > ( )
. select ( RStatPollutionSubstationM : : getSubstationId , RStatPollutionSubstationM : : getValue )
. select ( RStatPollutionSubstationM : : getSubstationId , RStatPollutionSubstationM : : getValue )
. in ( CollUtil . isNotEmpty ( subAll ) , RStatPollutionSubstationM : : getSubstationId , subAll )
. in ( CollUtil . isNotEmpty ( param . getIds ( ) ) , RStatPollutionSubstationM : : getPollutionType , param . getIds ( ) )
. ge ( StrUtil . isNotBlank ( param . getStartTime ( ) ) , RStatPollutionSubstationM : : getDataDate , DateUtil . beginOfDay ( DateUtil . parse ( param . getStartTime ( ) ) ) )
@@ -715,12 +718,12 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
) ;
info . addAll ( substationMlist . stream ( ) . map ( RStatPollutionSubstationM : : getValue ) . collect ( Collectors . toList ( ) ) ) ;
gwInfo . addAll ( substationMlist . stream ( )
. filter ( x - > subGw . contains ( x . getSubstationId ( ) ) )
. filter ( x - > subGw . contains ( x . getSubstationId ( ) ) )
. map ( RStatPollutionSubstationM : : getValue ) . collect ( Collectors . toList ( ) ) ) ;
break ;
case 4 :
List < RStatPollutionSubstationDPO > substationDlist = pollutionSubstationDPOMapper . selectList ( new LambdaQueryWrapper < RStatPollutionSubstationDPO > ( )
. select ( RStatPollutionSubstationDPO : : getSubstationId , RStatPollutionSubstationDPO : : getValue )
. select ( RStatPollutionSubstationDPO : : getSubstationId , RStatPollutionSubstationDPO : : getValue )
. in ( CollUtil . isNotEmpty ( subAll ) , RStatPollutionSubstationDPO : : getSubstationId , subAll )
. in ( CollUtil . isNotEmpty ( param . getIds ( ) ) , RStatPollutionSubstationDPO : : getPollutionType , param . getIds ( ) )
. ge ( StrUtil . isNotBlank ( param . getStartTime ( ) ) , RStatPollutionSubstationDPO : : getDataDate , DateUtil . beginOfDay ( DateUtil . parse ( param . getStartTime ( ) ) ) )
@@ -728,7 +731,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
) ;
info . addAll ( substationDlist . stream ( ) . map ( RStatPollutionSubstationDPO : : getValue ) . collect ( Collectors . toList ( ) ) ) ;
gwInfo . addAll ( substationDlist . stream ( )
. filter ( x - > subGw . contains ( x . getSubstationId ( ) ) )
. filter ( x - > subGw . contains ( x . getSubstationId ( ) ) )
. map ( RStatPollutionSubstationDPO : : getValue ) . collect ( Collectors . toList ( ) ) ) ;
break ;
@@ -741,9 +744,9 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
@Override
public Page < PollutionGridDiagramDTO > getPollutionAlarmPageData ( StatSubstationBizBaseParam param ) {
Map < String , String > map = new HashMap < > ( ) ;
map . put ( " V " , dicDataFeignClient . getDicDataByCode ( DicDataEnum . V_HARMONIC . getCode ( ) ) . getData ( ) . getId ( ) ) ;
map . put ( " I " , dicDataFeignClient . getDicDataByCode ( DicDataEnum . I_ALL . getCode ( ) ) . getData ( ) . getId ( ) ) ;
Map < String , String > map = new HashMap < > ( ) ;
map . put ( " V " , dicDataFeignClient . getDicDataByCode ( DicDataEnum . V_HARMONIC . getCode ( ) ) . getData ( ) . getId ( ) ) ;
map . put ( " I " , dicDataFeignClient . getDicDataByCode ( DicDataEnum . I_ALL . getCode ( ) ) . getData ( ) . getId ( ) ) ;
DeptGetLineParam deptGetLineParam = new DeptGetLineParam ( ) ;
deptGetLineParam . setDeptId ( param . getId ( ) ) ;
deptGetLineParam . setPowerFlag ( 0 ) ;
@@ -758,21 +761,21 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
//根据部门统计有多少干扰源(设备数量)
Map < String , SubGetBase > substationMap = substationList . stream ( ) . collect ( Collectors . toMap ( SubGetBase : : getId , Function . identity ( ) ) ) ;
List < String > subIDS = new ArrayList < > ( ) ;
if ( 0 = = param . getType ( ) ) {
List < String > subIDS = new ArrayList < > ( ) ;
if ( 0 = = param . getType ( ) ) {
//全部变电站
subIDS . addAll ( collect . stream ( ) . map ( SubGetBase : : getId ) . distinct ( ) . collect ( Collectors . toList ( ) ) ) ;
} else {
} else {
//国网变电站
subIDS . addAll ( collect . stream ( ) . filter ( x - > 1 = = x . getIsUpToGrid ( ) ) . map ( SubGetBase : : getId ) . distinct ( ) . collect ( Collectors . toList ( ) ) ) ;
subIDS . addAll ( collect . stream ( ) . filter ( x - > 1 = = x . getIsUpToGrid ( ) ) . map ( SubGetBase : : getId ) . distinct ( ) . collect ( Collectors . toList ( ) ) ) ;
}
Page < PollutionGridDiagramDTO > pollutionPage = pollutionSubstationMMapper . selectBySubstationPage ( new Page < > ( param . getPageNum ( ) , param . getPageSize ( ) )
, subIDS , map , param . getStartTime ( ) , param . getEndTime ( ) ) ;
List < PollutionGridDiagramDTO > records = pollutionPage . getRecords ( ) ;
if ( CollUtil . isNotEmpty ( records ) ) {
records . forEach ( x - > {
if ( substationMap . containsKey ( x . getId ( ) ) ) {
if ( CollUtil . isNotEmpty ( records ) ) {
records . forEach ( x - > {
if ( substationMap . containsKey ( x . getId ( ) ) ) {
SubGetBase subGetBase = substationMap . get ( x . getId ( ) ) ;
x . setName ( subGetBase . getName ( ) ) ;
x . setPowerCompany ( subGetBase . getOrgName ( ) ) ;
@@ -791,7 +794,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
List < GeneralDeviceDTO > data = generalDeviceInfoClient . getPracticalRunDeviceInfo ( param . getDeviceInfoParam ( ) ) . getData ( ) ;
List < String > subIds = data . stream ( ) . flatMap ( x - > x . getSubIndexes ( ) . stream ( ) ) . collect ( Collectors . toList ( ) ) ;
List < RStatPollutionSubstationM > substationMlist = pollutionSubstationMMapper . selectList ( new LambdaQueryWrapper < RStatPollutionSubstationM > ( )
. select ( RStatPollutionSubstationM : : getSubstationId , RStatPollutionSubstationM : : getValue )
. select ( RStatPollutionSubstationM : : getSubstationId , RStatPollutionSubstationM : : getValue )
. in ( CollUtil . isNotEmpty ( subIds ) , RStatPollutionSubstationM : : getSubstationId , subIds )
. in ( CollUtil . isNotEmpty ( param . getIds ( ) ) , RStatPollutionSubstationM : : getPollutionType , param . getIds ( ) )
. ge ( StrUtil . isNotBlank ( param . getSearchBeginTime ( ) ) , RStatPollutionSubstationM : : getDataDate , DateUtil . beginOfDay ( DateUtil . parse ( param . getSearchBeginTime ( ) ) ) )
@@ -800,7 +803,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
List < String > dept ;
for ( GeneralDeviceDTO datum : data ) {
List < RStatPollutionSubstationM > collect = substationMlist . stream ( ) . filter ( x - > datum . getSubIndexes ( ) . contains ( x . getSubstationId ( ) ) ) . collect ( Collectors . toList ( ) ) ;
dept = new ArrayList < > ( ) ;
dept = new ArrayList < > ( ) ;
dept . add ( datum . getName ( ) ) ;
dept . add ( String . valueOf ( datum . getSubIndexes ( ) . size ( ) ) ) ;
dept . addAll ( addList ( collect ) ) ;
@@ -817,47 +820,80 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
deptGetLineParam . setDeptId ( deptIndex ) ;
deptGetLineParam . setLineRunFlag ( 0 ) ;
List < DeptGetChildrenMoreDTO > list = commTerminalGeneralClient . deptGetLine ( deptGetLineParam ) . getData ( ) ;
//获取所有监测信息
List < LineDevGetDTO > lineNameList = list . stream ( ) . flatMap ( x - > x . getLineBaseList ( ) . stream ( ) ) . distinct ( ) . collect ( Collectors . toList ( ) ) ;
Map < String , String > lineOrgName = lineNameList . stream ( ) . collect ( Collectors . toMap ( LineDevGetDTO : : getPointId , LineDevGetDTO : : getUnitName ) ) ;
//获取监测点集合
Map < String , List < String > > lineMap = this . getLineMap ( list , searchValue ) ;
Map < String , List < String > > lineMap = this . getLineMap ( list , searchValue ) ;
List < String > lineList = lineMap . values ( ) . stream ( )
. flatMap ( List : : stream )
. distinct ( )
. collect ( Collectors . toList ( ) ) ;
if ( CollUtil . isNotEmpty ( lineList ) ) {
if ( CollUtil . isNotEmpty ( lineList ) ) {
//获取监测点的超标数据
List < RStatLimitRateDPO > limitRateList = rStatLimitRateDMapper . getAllOverTimes ( lineList , startTime , endTime ) ;
List < RStatLimitRateDPO > limitRateList = rStatLimitRateDMapper . getAllOverTimes ( lineList , startTime , endTime ) ;
Map < String , RStatLimitRateDPO > monitorMap = limitRateList . stream ( ) . collect ( Collectors . toMap ( RStatLimitRateDPO : : getLineId , Function . identity ( ) ) ) ;
//todo 获取监测点污染数据
List < RMpPollutionDPO > lineData = rMpPollutionDPOMapper . selectList ( new LambdaQueryWrapper < RMpPollutionDPO > ( )
. in ( CollUtil . isNotEmpty ( lineList ) , RMpPollutionDPO : : getLineId , lineList )
. ge ( StrUtil . isNotBlank ( startTime ) , RMpPollutionDPO : : getDataDate , DateUtil . beginOfDay ( DateUtil . parse ( startTime ) ) )
. le ( StrUtil . isNotBlank ( endTime ) , RMpPollutionDPO : : getDataDate , DateUtil . endOfDay ( DateUtil . parse ( endTime ) ) )
) ;
//谐波电压
String v = dicDataFeignClient . getDicDataByCode ( DicDataEnum . V_HARMONIC . getCode ( ) ) . getData ( ) . getId ( ) ;
List < RMpPollutionDPO > harmonicV = lineData . stream ( ) . filter ( x - > v . equals ( x . getPollutionType ( ) ) ) . collect ( Collectors . toList ( ) ) ;
//谐波电流
String i = dicDataFeignClient . getDicDataByCode ( DicDataEnum . I_ALL . getCode ( ) ) . getData ( ) . getId ( ) ;
List < RMpPollutionDPO > harmonicI = lineData . stream ( ) . filter ( x - > i . equals ( x . getPollutionType ( ) ) ) . collect ( Collectors . toList ( ) ) ;
//获取监测点详细信息
List < LineDetail > lineDetailList = lineFeignClient . getLineDetail ( lineList ) . getData ( ) ;
Map < String , List < LineDetail > > lineDetailMap = lineDetailList . stream ( ) . collect ( Collectors . groupingBy ( LineDetail : : getPowerSubstationNam e) ) ;
lineDetailMap . forEach ( ( k , v ) - > {
if ( StrUtil . isNotBlank ( searchValu e) ) {
lineDetailList = lineDetailList . stream ( ) . filter ( item - > item . getPowerSubstationName ( ) . contains ( searchValue ) ) . collect ( Collectors . toList ( ) ) ;
}
Map < String , List < LineDetail > > lineDetailMap = lineDetailList . stream ( ) . filter ( x - > StrUtil . isNotBlank ( x . getPowerSubstationName ( ) ) ) . collect ( Collectors . groupingBy ( LineDetail : : getPowerSubstationName ) ) ;
lineDetailMap . forEach ( ( key , value ) - > {
AtomicInteger alarmTime = new AtomicInteger ( ) ;
SubstationVo vo = new SubstationVo ( ) ;
vo . setDeptName ( " " ) ;
vo . setSubstationName ( k ) ;
vo . setDwLineList ( v . stream ( ) . filter ( t - > Objects . equals ( t . getPowerFlag ( ) , 0 ) ) . map ( LineDetail : : getId ) . collect ( Collectors . toList ( ) ) ) ;
vo . setYhLineList ( v . stream ( ) . filter ( t - > Objects . equals ( t . getPowerFlag ( ) , 1 ) ) . map ( LineDetail : : getId ) . collect ( Collectors . toList ( ) ) ) ;
v . forEach ( item - > {
alarmTime . set ( alarmTime . get ( ) + monitorMap . get ( item . getId ( ) ) . getAllTime ( ) ) ;
vo . setDeptName ( lineOrgName . get ( value . get ( 0 ) . getId ( ) ) ) ;
vo . setSubstationName ( key ) ;
List < String > gridSide = value . stream ( ) . filter ( t - > Objects . equals ( t . getPowerFlag ( ) , 0 ) ) . map ( LineDetail : : getId ) . collect ( Collectors . toList ( ) ) ;
List < String > notGridSide = value . stream ( ) . filter ( t - > Objects . equals ( t . getPowerFlag ( ) , 1 ) ) . map ( LineDetail : : getId ) . collect ( Collectors . toList ( ) ) ;
vo . setDwLineList ( lineNameList . stream ( ) . filter ( x - > gridSide . contains ( x . getPointId ( ) ) ) . map ( LineDevGetDTO : : getPointName ) . sorted ( ) . collect ( Collectors . toList ( ) ) ) ;
vo . setYhLineList ( lineNameList . stream ( ) . filter ( x - > notGridSide . contains ( x . getPoint Id ( ) ) ) . map ( LineDevGetDTO : : getPointName ) . sorted ( ) . collect ( Collectors . toList ( ) ) ) ;
value . forEach ( item - > {
if ( monitorMap . containsKey ( item . getId ( ) ) ) {
alarmTime . set ( alarmTime . get ( ) + monitorMap . get ( item . getId ( ) ) . getAllTime ( ) ) ;
}
} ) ;
vo . setAlarmFreq ( alarmTime . get ( ) * 1 . 0 / v . size ( ) ) ;
vo . setAlarmFreq ( NumberUtil . round ( alarmTime. get ( ) * 1 . 0 / value . size ( ) , 2 ) . doubleValue ( ) );
OptionalDouble maxV = harmonicV . stream ( ) . filter ( x - > value . contains ( x . getLineId ( ) ) ) . mapToDouble ( RMpPollutionDPO : : getValue ) . max ( ) ;
vo . setVPollutionData ( maxV . isPresent ( ) ? maxV . getAsDouble ( ) : 0 . 0D ) ;
OptionalDouble maxI = harmonicI . stream ( ) . filter ( x - > value . contains ( x . getLineId ( ) ) ) . mapToDouble ( RMpPollutionDPO : : getValue ) . max ( ) ;
vo . setIPollutionData ( maxI . isPresent ( ) ? maxV . getAsDouble ( ) : 0 . 0D ) ;
result . add ( vo ) ;
} ) ;
}
return result ;
}
public Map < String , List < String > > getLineMap ( List < DeptGetChildrenMoreDTO > list , String searchValue ) {
Map < String , List < String > > map = new HashMap < > ( ) ;
list . forEach ( it - > {
/**
* 监测点名称筛选
* @param list
* @param searchValue
* @return
*/
public Map < String , List < String > > getLineMap ( List < DeptGetChildrenMoreDTO > list , String searchValue ) {
Map < String , List < String > > map = new HashMap < > ( ) ;
list . forEach ( it - > {
Predicate < LineDevGetDTO > voltageFilter = item - > true ;
if ( ! Objects . isNull ( searchValue ) & & ! Objects . equals ( searchValue , " " ) ) {
if ( ! Objects . isNull ( searchValue ) & & ! Objects . equals ( searchValue , " " ) ) {
voltageFilter = item - > item . getPointName ( ) . contains ( searchValue ) ;
}
Predicate < LineDevGetDTO > combinedFilter = voltageFilter ;
map . put ( it . getUnitName ( ) , it . getLineBaseList ( ) . stream ( )
map . put ( it . getUnitName ( ) , it . getLineBaseList ( ) . stream ( )
. filter ( combinedFilter )
. map ( LineDevGetDTO : : getPointId )
. distinct ( )
@@ -868,7 +904,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
private List < String > addList ( List < RStatPollutionSubstationM > substationMlist ) {
List < String > info = new ArrayList < > ( ) ;
List < String > info = new ArrayList < > ( ) ;
Integer num1 = 0 ;
Integer num2 = 0 ;
Integer num3 = 0 ;