@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl ;
import com.njcn.common.config.GeneralInfo ;
import com.njcn.common.pojo.constant.BizParamConstant ;
import com.njcn.common.pojo.dto.SimpleDTO ;
import com.njcn.common.pojo.enums.response.CommonResponseEnum ;
import com.njcn.common.pojo.exception.BusinessException ;
import com.njcn.common.utils.PubUtils ;
@@ -34,6 +35,7 @@ import com.njcn.device.pq.api.SubstationFeignClient;
import com.njcn.device.pq.enums.LineBaseEnum ;
import com.njcn.device.pq.enums.PowerFlagEnum ;
import com.njcn.device.pq.pojo.dto.* ;
import com.njcn.device.pq.pojo.param.DeviceInfoParam ;
import com.njcn.device.pq.pojo.param.GridDiagramParam ;
import com.njcn.device.pq.pojo.param.LineBaseQueryParam ;
import com.njcn.device.pq.pojo.param.OnlineRateParam ;
@@ -128,7 +130,6 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
private final RmpEventDetailFeignClient detailFeignClient ;
private final CommLineClient commLineClient ;
/**
* @param pollutionSubstationQuryParam
* @Description: getPollutionSubstationData
@@ -758,8 +759,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
public GridDiagramVO getPollutionAlarmData ( StatSubstationBizBaseParam param ) {
DeptGetLineParam deptGetLineParam = new DeptGetLineParam ( ) ;
deptGetLineParam . setDeptId ( param . getId ( ) ) ;
deptGetLineParam . setPowerFlag ( 0 ) ;
deptGetLineParam . setLineRunFlag ( 0 ) ;
deptGetLineParam . setIsUpToGrid ( param . getIsUpToGrid ( ) ) ;
List < DeptGetSubStationDTO . Info > deptGetChildrenMoreDTOS = commTerminalGeneralClient . deptGetSubStationInfo ( deptGetLineParam ) . getData ( ) ;
//获取全部变电站信息
List < SubGetBase > collect = deptGetChildrenMoreDTOS . stream ( ) . flatMap ( x - > x . getStationIds ( ) . stream ( ) ) . collect ( Collectors . toList ( ) ) ;
@@ -880,25 +880,27 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
@Override
public List < List < String > > getPollutionAlarmList ( GridDiagramParam param ) {
List < List < String > > info = new ArrayList < > ( ) ;
param . getDeviceInfoParam ( ) . setPowerFlag ( 0 ) ;
p aram. g etDeviceInfoParam ( ) . s etLineRunFlag ( 0 ) ;
List < GeneralDeviceDTO > data = generalDeviceInfoClient . g etPracticalRunDeviceInfo ( param . getDeviceInfoParam ( ) ) .getData ( ) ;
List < String > subIds = data . stream ( ) . flatMap ( x - > x . getSubIndexes ( ) . stream ( ) ) . collect ( Collectors . toList ( ) ) ;
List < R StatPollutionSubstationM > substationMlist = pollutionSubstationMMapper . selectList ( new LambdaQueryWrapper < RStatPollutionSubstationM > ( )
. select ( RStatPollutionSubs tationM : : 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 ( ) ) ) )
. le ( StrUtil . isNotBlank ( param . getSearchEndTime ( ) ) , RStatPollutionSubstationM : : getDataDate , DateUtil . endOfDay ( DateUtil . parse ( param . getSearchEndTime ( ) ) ) )
) ;
DeptGetLineParam deptGetLineParam = new DeptGetLineParam ( ) ;
deptGetLineP aram. s etDeptId ( param . g etOrgId ( ) ) ;
deptGetLineParam . s etIsUpToGrid ( param . getDeviceInfoParam ( ) . getMonitorFlag ( ) ) ;
List < DeptGetSubStationDTO . Info > deptSub = commTerminalGeneralClient . deptGetSubStationInfo ( deptGetLineParam ) . getData ( ) ;
List < String > lineIdList = deptSub . stream ( )
. flatMap ( x - > x . getS tationIds ( ) . stream ( ) . flatMap ( d - > d . getUnitChildrenList ( ) . stream ( ) ) )
. distinct ( )
. collect ( Collectors . toList ( ) ) ;
List < RMpPollutionDPO > rMpPollutionDPOS = rMpPollutionDPOMapper . selectSumList ( lineIdList ,
Arrays . asList ( " b33a2946cb2d4f2641f485cf7720ecc7 " ) ,
DateUtil . beginOfDay ( DateUtil . parse ( param . getSearchBeginTime ( ) ) ) . toString ( ) ,
DateUtil . endOfDay ( DateUtil . parse ( param . getSearchEndTime ( ) ) ) . toString ( ) ) ;
List < String > dept ;
for ( GeneralDeviceDTO datum : data ) {
List < RStatPollutionSubstationM > collect = substationMlist . stream ( ) . filter ( x - > datum . getSubIndexes ( ) . contain s( x . getSubstation Id ( ) ) ) . collect ( Collectors . toList ( ) ) ;
dept = new ArrayList < > ( ) ;
dept . add ( datum . getName ( ) ) ;
dept . add ( String . valueOf ( datum . getSubIndexe s ( ) . size ( ) ) ) ;
dept . addAll ( addList ( collect ) ) ;
info . add ( dept ) ;
for ( DeptGetSubStationDTO . Info datum : deptSub ) {
if ( ! datum . getUnitId ( ) . equal s( param . getOrg Id ( ) ) ) {
dept = new ArrayList < > ( ) ;
dept . add ( datum . getUnit Name ( ) ) ;
dept . add ( String . valueOf ( datum . getStationId s ( ) . size ( ) ) ) ;
dept . addAll ( addList ( rMpPollutionDPOS , datum . getStationIds ( ) ) ) ;
info . add ( dept ) ;
}
}
return info ;
}
@@ -966,23 +968,26 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
@Override
public List < LinePollution > downPollutionLineCalc ( StatSubstationBizBaseParam param ) {
List < LinePollution > finalLinePollutionList = pollutionCalcList ( p aram) ;
DeviceInfoParam deviceInfoParam = new DeviceInfoP aram( );
deviceInfoParam . setLineRunFlag ( 0 ) ;
deviceInfoParam . setDeptIndex ( param . getId ( ) ) ;
deviceInfoParam . setStatisticalType ( new SimpleDTO ( ) ) ;
List < GeneralDeviceDTO > data1 = generalDeviceInfoClient . getPracticalRunDeviceInfo ( deviceInfoParam ) . getData ( ) ;
List < String > lineIdList = data1 . stream ( ) . flatMap ( x - > x . getLineIndexes ( ) . stream ( ) ) . distinct ( ) . collect ( Collectors . toList ( ) ) ;
List < LinePollution > finalLinePollutionList = pollutionCalcList ( param , lineIdList ) ;
// 全部监测点计算完毕后根据污染值从大到小进行排序
finalLinePollutionList = finalLinePollutionList . stream ( )
finalLinePollutionList = finalLinePollutionList . stream ( )
. sorted ( Comparator . comparing ( LinePollution : : getHarmonicValue ) . reversed ( ) )
. collect ( Collectors . toList ( ) ) ;
return finalLinePollutionList ;
return finalLinePollutionList ;
}
private List < LinePollution > pollutionCalcList ( StatSubstationBizBaseParam param ) {
private List < LinePollution > pollutionCalcList ( StatSubstationBizBaseParam param , List < String > lineIdList ) {
String startDate = param . getStartTime ( ) ;
String endDate = param . getEndTime ( ) ;
List < LinePollution > linePollutionList = new ArrayList < > ( ) ;
GridDiagramParam eventParam = new GridDiagramParam ( ) ;
List < String > lineIdList = generalDeviceInfoClient . deptGetRunLine ( param . getId ( ) ) . getData ( ) ;
eventParam . setIds ( lineIdList ) ;
eventParam . setSearchBeginTime ( param . getStartTime ( ) ) ;
@@ -1015,8 +1020,8 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
}
if ( CollUtil . isNotEmpty ( lineIdList ) ) {
// 获取谐波电压数据&总畸变率&越限限值计算基础污染值
for ( String lineId : lineIdList ) {
if ( lineMap . containsKey ( lineId ) ) {
for ( String lineId : lineIdList ) {
if ( lineMap . containsKey ( lineId ) ) {
PollutionLineInfoDTO data = lineMap . get ( lineId ) ;
LinePollution linePollution = new LinePollution ( ) ;
// 获取暂态数据
@@ -1026,9 +1031,9 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
BigDecimal vo2 = onlineRateMap . get ( data . getDeviceId ( ) ) ;
linePollution . setOnlineRate ( Objects . isNull ( vo2 ) ? 0 . 0f : vo2 . floatValue ( ) ) ;
//获取监测点数据完整性
linePollution . setIntegrity ( Objects . isNull ( integrityMap . get ( lineId ) ) ? 0 . 0 : integrityMap . get ( lineId ) . doubleValue ( ) > 100 ? 100 . 0 : integrityMap . get ( lineId ) . doubleValue ( ) ) ;
linePollution . setIntegrity ( Objects . isNull ( integrityMap . get ( lineId ) ) ? 0 . 0 : integrityMap . get ( lineId ) . doubleValue ( ) > 100 ? 100 . 0 : integrityMap . get ( lineId ) . doubleValue ( ) ) ;
// 计算谐波的污染值
linePollution . setHarmonicValue ( calcMap . containsKey ( lineId ) ? calcMap . get ( lineId ) > 100 ? 100 . 0 : integrityMap . get ( lineId ) . doubleValue ( ) : 0 . 0 ) ;
linePollution . setHarmonicValue ( calcMap . containsKey ( lineId ) ? calcMap . get ( lineId ) . doubleValue ( ) : 0 . 0 ) ;
linePollution . setInterval ( data . getTimeInterval ( ) ) ;
linePollutionList . add ( linePollution ) ;
}
@@ -1040,7 +1045,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
@Override
public void downPollutionUserCalc ( StatSubstationBizBaseParam param ) {
// 处理干扰源用户的报告
List < LinePollution > loadTypeLineList = pollutionCalcList ( param ) ;
List < LinePollution > loadTypeLineList = pollutionCalcList ( param , null );
/**
* 1、首先过滤: 重要变电站、一类变电站、跨省计量关点 todo...待优化
* 2、过滤后, 以监测对象分组统计数据有多个测点的需要出结果
@@ -1064,7 +1069,6 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
objPollution . setObjVValue ( PubUtils . doubleRound ( 2 , objVValue ) + " " ) ;
// 处理该监测对象下面监测点的信息
List < LoadTypeLineItemPollution > loadTypeLineItemPollutions = new ArrayList < > ( ) ;
for ( LinePollution linePollution : linePollutions ) {
@@ -1076,7 +1080,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
objPollutions . add ( objPollution ) ;
}
// 排序
objPollutions = objPollutions . stream ( )
objPollutions = objPollutions . stream ( )
. sorted ( Comparator . comparing ( ObjPollution : : getObjVValue ) . reversed ( ) )
. collect ( Collectors . toList ( ) ) ;
ExcelUtil . exportExcel ( " 用户谐波电压污染值 " + param . getEndTime ( ) + " .xlsx " , ObjPollution . class , objPollutions ) ;
@@ -1084,27 +1088,33 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
@Override
public List < SubstationPollution > downPollutionSubCalc ( StatSubstationBizBaseParam param ) {
DeviceInfoParam deviceInfoParam = new DeviceInfoParam ( ) ;
deviceInfoParam . setDeptIndex ( param . getId ( ) ) ;
deviceInfoParam . setStatisticalType ( new SimpleDTO ( ) ) ;
List < GeneralDeviceDTO > data1 = generalDeviceInfoClient . getPracticalAllDeviceInfoAsSubstation ( deviceInfoParam ) . getData ( ) ;
List < String > lineIdList = data1 . stream ( ) . flatMap ( x - > x . getLineIndexes ( ) . stream ( ) ) . distinct ( ) . collect ( Collectors . toList ( ) ) ;
List < SubstationPollution > substationPollutions = new ArrayList < > ( ) ;
// 处理干扰源用户的报告
List < LinePollution > linePollutionList = pollutionCalcList ( param ) ;
List < LinePollution > linePollutionList = pollutionCalcList ( param , lineIdList );
// 以变电站分组
Map < String , List < LinePollution > > subMap = linePollutionList . stream ( )
. collect ( Collectors . groupingBy ( x - > x . getGdName ( ) + " _ " + x . getSubStationName ( ) + " _ " + x . getSubVoltage ( ) ) ) ;
subMap . forEach ( ( key , value ) - > {
. collect ( Collectors . groupingBy ( x - > x . getSubStationId ( ) + " _ " + x . getGdName ( ) + " _ " + x . getSubStationName ( ) + " _ " + x . getSubVoltage ( ) ) ) ;
subMap . forEach ( ( key , value ) - > {
String [ ] name = key . split ( " _ " ) ;
SubstationPollution substationPollution = new SubstationPollution ( ) ;
substationPollution . setGdName ( name [ 0 ] ) ;
substationPollution . setSubStationName ( name [ 1 ] ) ;
substationPollution . setSubVoltage ( name [ 2 ] ) ;
substationPollution . setGdName ( name [ 1 ] ) ;
substationPollution . setSubStationName ( name [ 2 ] ) ;
substationPollution . setSubVoltage ( name [ 3 ] ) ;
double subVValue = value . stream ( )
. mapToDouble ( o - > o . getHarmonicValue ( ) )
. average ( )
. orElse ( 0 . 0 ) ;
. sum ( ) ;
substationPollution . setSubVStationValue ( PubUtils . doubleRound ( 2 , subVValue ) + " " ) ;
List < PowerFlagPollution > lineItemPollutionList = new ArrayList < > ( ) ;
for ( LinePollution linePollution : value ) {
PowerFlagPollution lineItemPollution = new PowerFlagPollution ( ) ;
BeanUtil . copyProperties ( linePollution , lineItemPollution , true ) ;
lineItemPollution . setVHarmonicValue ( linePollution . getHarmonicValue ( ) ) ;
lineItemPollutionList . add ( lineItemPollution ) ;
}
substationPollution . setPowerFlagPollutionList ( lineItemPollutionList ) ;
@@ -1112,30 +1122,65 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
} ) ;
substationPollutions . sort ( Comparator . comparingDouble ( o - > Double . parseDouble ( o . getSubVStationValue ( ) ) ) ) ;
Collections . reverse ( substationPollutions ) ;
return substationPollutions ;
return substationPollutions ;
}
@Override
public List < UserLinePollution > getSumList ( OnlineRateParam . Info param ) {
List < UserLinePollution > info = new ArrayList < > ( ) ;
UserReportParam userReportParam = new UserReportParam ( ) ;
userReportParam . setUserType ( 6 ) ;
List < UserLedgerVO > userLedgerVOList = userLedgerFeignClient . selectUserList ( userReportParam ) . getData ( ) ;
Map < String , List < UserLedgerVO > > userMap = userLedgerVOList . stream ( ) . filter ( x - > StrUtil . isNotBlank ( x . getLineId ( ) ) ) . collect ( Collectors . groupingBy ( UserLedgerVO : : getLineId ) ) ;
List < RMpPollutionDPO > rMpPollutionDPOS = rMpPollutionDPOMapper . selectSumList ( param . getIds ( ) , param . getDicData ( ) , param . getStartTime ( ) , param . getEndTime ( ) ) ;
Map < String , Double > pollutionMap = rMpPollutionDPOS . stream ( ) . collect ( Collectors . toMap ( RMpPollutionDPO : : getLineId , RMpPollutionDPO : : getValue ) ) ;
UserLinePollution user ;
for ( String id : param . getIds ( ) ) {
user = new UserLinePollution ( ) ;
user . setLineId ( id ) ;
if ( pollutionMap . containsKey ( id ) ) {
user . setVHarmonicValue ( pollutionMap . get ( id ) ) ;
} else {
user . setVHarmonicValue ( 0 . 0 ) ;
}
List < UserLinePollution . User > userList = new ArrayList < > ( ) ;
if ( userMap . containsKey ( id ) ) {
List < UserLedgerVO > userLedgerVOS = userMap . get ( id ) ;
userList . addAll ( BeanUtil . copyToList ( userLedgerVOS , UserLinePollution . User . class ) ) ;
}
user . setUserList ( userList ) ;
info . add ( user ) ;
}
return info ;
}
private List < String > addList ( List < RStat PollutionSubstationM > substationMlist ) {
private List < String > addList ( List < RMp PollutionDPO > pollLinelist , List < SubGetBase > notNum ) {
List < String > info = new ArrayList < > ( ) ;
Integer num1 = 0 ;
Integer num2 = 0 ;
Integer num3 = 0 ;
Integer num4 = 0 ;
Integer num5 = 0 ;
for ( RStatPollutionSubstationM x : substationMlist ) {
Double valu e = x . getValue ( ) ;
//无污染 轻微污染 轻度污染 中度污染 重度污染
if ( 0 < = value & & value < 1 ) {
num1 + + ;
} else if ( 1 < = value & & value < 1 . 2 ) {
num2 + + ;
} else if ( 1 . 2 < = value & & value < 1 . 6 ) {
num3 + + ;
} else if ( 1 . 6 < = value & & value < 2 ) {
num4 + + ;
} else if ( 2 < = value ) {
num5 + + ;
Integer num6 = 0 ;
for ( SubGetBase subGetBas e : notNum ) {
List < RMpPollutionDPO > linePoll = pollLinelist . stream ( ) . filter ( x - > subGetBase . getUnitChildrenList ( ) . contains ( x . getLineId ( ) ) ) . collect ( Collectors . toList ( ) ) ;
if ( CollUtil . isNotEmpty ( linePoll ) ) {
Double value = linePoll . stream ( ) . mapToDouble ( RMpPollutionDPO : : getValue ) . sum ( ) ;
//无污染 轻微污染0-100 轻度污染100-1000 中度污染1000-10000 重度污染10000
if ( 0 = = value ) {
num1 + + ;
} else if ( 0 < value & & value < 100 ) {
num2 + + ;
} else if ( 100 < = value & & value < 1000 ) {
num3 + + ;
} else if ( 1000 < = value & & value < 10000 ) {
num4 + + ;
} else if ( 10000 < = value ) {
num5 + + ;
}
} else {
num6 + + ;
}
}
info . add ( String . valueOf ( num1 ) ) ;
@@ -1143,6 +1188,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
info . add ( String . valueOf ( num3 ) ) ;
info . add ( String . valueOf ( num4 ) ) ;
info . add ( String . valueOf ( num5 ) ) ;
info . add ( String . valueOf ( num6 ) ) ;
return info ;
}
}