@@ -24,7 +24,6 @@ import java.util.*;
import java.util.stream.Collectors ;
import java.util.stream.Collectors ;
/**
/**
*
* Description:
* Description:
* 接口文档访问地址: http://serverIP:port/swagger-ui.html
* 接口文档访问地址: http://serverIP:port/swagger-ui.html
* Date: 2022/10/13 8:56【需求编号】
* Date: 2022/10/13 8:56【需求编号】
@@ -60,51 +59,58 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
@Override
@Override
public List < PollutionSubstationVO > getPollutionSubstationData ( PollutionSubstationQuryParam pollutionSubstationQuryParam ) {
public List < PollutionSubstationVO > getPollutionSubstationData ( PollutionSubstationQuryParam pollutionSubstationQuryParam ) {
List < PollutionSubstationVO > pollutionSubstationVOList = new ArrayList < > ( ) ;
List < PollutionSubstationVO > pollutionSubstationVOList = new ArrayList < > ( ) ;
/*根据部门获取变电站详情*/
/*根据部门获取变电站详情*/
HarmonicPublicParam harmonicPublicParam = new HarmonicPublicParam ( ) ;
HarmonicPublicParam harmonicPublicParam = new HarmonicPublicParam ( ) ;
BeanUtils . copyProperties ( pollutionSubstationQuryParam , harmonicPublicParam ) ;
BeanUtils . copyProperties ( pollutionSubstationQuryParam , harmonicPublicParam ) ;
harmonicPublicParam . setServerName ( generalInfo . getMicroServiceName ( ) ) ;
harmonicPublicParam . setServerName ( generalInfo . getMicroServiceName ( ) ) ;
List < PollutionSubstationDTO > pollutionSubstationDTOList = new ArrayList < > ( ) ;
List < PollutionSubstationDTO > pollutionSubstationDTOList = new ArrayList < > ( ) ;
List < GeneralDeviceDTO > sub = generalDeviceInfoClient . getPracticalRunDeviceInfoAsSubstation ( harmonicPublicParam ) . getData ( ) ;
List < GeneralDeviceDTO > sub = generalDeviceInfoClient . getPracticalRunDeviceInfoAsSubstation ( harmonicPublicParam ) . getData ( ) ;
sub . forEach ( item - > {
sub . forEach ( item - > {
PollutionSubstationDTO pollutionSubstationDTO = lineFeignClient . getSubstationInfo ( item . getIndex ( ) ) . getData ( ) ;
PollutionSubstationDTO pollutionSubstationDTO = lineFeignClient . getSubstationInfo ( item . getIndex ( ) ) . getData ( ) ;
pollutionSubstationDTOList . add ( pollutionSubstationDTO ) ;
pollutionSubstationDTOList . add ( pollutionSubstationDTO ) ;
} ) ;
} ) ;
List < String > collect = pollutionSubstationDTOList . stream ( ) . map ( PollutionSubstationDTO : : getId ) . collect ( Collectors . toList ( ) ) ;
List < String > collect = pollutionSubstationDTOList . stream ( ) . map ( PollutionSubstationDTO : : getId ) . collect ( Collectors . toList ( ) ) ;
List < SubstationDTO > locationData = substationFeignClient . getSubstationById ( collect ) . getData ( ) ;
List < SubstationDTO > locationData = substationFeignClient . getSubstationById ( collect ) . getData ( ) ;
/*todo 后期可以把locationData存入redis*/
/*todo 后期可以把locationData存入redis*/
/*把所有的变电站的污染指数查出来*/
/*把所有的变电站的污染指数查出来*/
QueryWrapper < RStatPollutionSubstationM > wrapper = new QueryWrapper < > ( ) ;
QueryWrapper < RStatPollutionSubstationM > wrapper = new QueryWrapper < > ( ) ;
wrapper . in ( " substation_id " , collect ) .
wrapper . in ( " substation_id " , collect ) .
eq ( " pollution_type " , pollutionSubstationQuryParam . getPollutionStatis ( ) . getId ( ) ) .
eq ( " pollution_type " , pollutionSubstationQuryParam . getPollutionStatis ( ) . getId ( ) ) .
apply ( " DATE_FORMAT( data_date ,'%Y-%m') = ' " + pollutionSubstationQuryParam . getLocalDate ( ) + " ' " ) ;
apply ( " DATE_FORMAT( data_date ,'%Y-%m') = ' " + pollutionSubstationQuryParam . getLocalDate ( ) + " ' " ) ;
List < RStatPollutionSubstationM > rStatPollutionSubstationMList = pollutionSubstationMMapper . selectList ( wrapper ) ;
List < RStatPollutionSubstationM > rStatPollutionSubstationMList = pollutionSubstationMMapper . selectList ( wrapper ) ;
pollutionSubstationDTOList . forEach ( substationInfo - > {
pollutionSubstationDTOList . forEach ( substationInfo - > {
PollutionSubstationVO pollutionSubstationVO = new PollutionSubstationVO ( ) ;
PollutionSubstationVO pollutionSubstationVO = new PollutionSubstationVO ( ) ;
pollutionSubstationVO . setSubstationId ( substationInfo . getId ( ) ) ;
pollutionSubstationVO . setSubstationId ( substationInfo . getId ( ) ) ;
pollutionSubstationVO . setSubstationName ( substationInfo . getName ( ) ) ;
pollutionSubstationVO . setSubstationName ( substationInfo . getName ( ) ) ;
/*todo 添加经纬度接口返回数据暂时没有*/
/*todo 添加经纬度接口返回数据暂时没有*/
SubstationDTO substationDTO = locationData . stream ( ) . filter ( temp - > Objects . equals ( substationInfo . getId ( ) , temp . getId ( ) ) ) .
SubstationDTO substationDTO = locationData
collect ( Collectors . toList ( ) ) . get ( 0 ) ;
. stream ( )
. filter ( temp - > Objects . equals ( substationInfo . getId ( ) , temp . getId ( ) ) )
. collect ( Collectors . toList ( ) )
. get ( 0 ) ;
pollutionSubstationVO . setLatitude ( substationDTO . getLat ( ) ) ;
pollutionSubstationVO . setLatitude ( substationDTO . getLat ( ) ) ;
pollutionSubstationVO . setLongitude ( substationDTO . getLng ( ) ) ;
pollutionSubstationVO . setLongitude ( substationDTO . getLng ( ) ) ;
Double value = Optional . ofNullable (
Double value = Optional . ofNullable (
rStatPollutionSubstationMList . stream ( ) . filter ( temp - > Objects . equals ( substationInfo . getId ( ) , temp . getSubstationId ( ) ) ) .
rStatPollutionSubstationMList
collect ( Collectors . toList ( ) ) . get ( 0 ) . getValue ( )
. stream ( )
) . orElse ( new Double ( " 0.00 " ) ) ;
. filter ( temp - > Objects . equals ( substationInfo . getId ( ) , temp . getSubstationId ( ) ) )
pollutionSubstationVO . setPollutionData ( value ) ;
. collect ( Collectors . toList ( ) )
pollutionSubstationVO . setPollutionStatis ( pollutionSubstationQuryParam . getStatisticalType ( ) . getName ( ) ) ;
. get ( 0 )
pollutionSubstationVOList . add ( pollutionSubstationVO ) ;
. getValue ( )
) . orElse ( new Double ( " 0.00 " ) ) ;
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 ;
return result ;
}
}