@@ -10,6 +10,8 @@ import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil ;
import cn.hutool.json.JSONUtil ;
import com.alibaba.fastjson.JSON ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
import com.github.yulichang.wrapper.MPJLambdaWrapper ;
import com.google.common.collect.BiMap ;
import com.google.common.collect.HashBiMap ;
@@ -30,6 +32,9 @@ import com.njcn.gather.device.pojo.enums.CommonEnum;
import com.njcn.gather.device.pojo.enums.PatternEnum ;
import com.njcn.gather.device.pojo.po.PqDev ;
import com.njcn.gather.device.service.IPqDevService ;
import com.njcn.gather.err.service.IPqErrSysService ;
import com.njcn.gather.monitor.pojo.po.PqMonitor ;
import com.njcn.gather.monitor.service.IPqMonitorService ;
import com.njcn.gather.plan.pojo.enums.DataSourceEnum ;
import com.njcn.gather.plan.pojo.po.AdPlan ;
import com.njcn.gather.plan.pojo.po.AdPlanTestConfig ;
@@ -113,6 +118,8 @@ public class ResultServiceImpl implements IResultService {
private final IPqScriptCheckDataService iPqScriptCheckDataService ;
private final IPqDevService iPqDevService ;
private final IAdPariService adPairService ;
private final IPqMonitorService pqMonitorService ;
private final IPqErrSysService pqErrSysService ;
/**
* 谐波类code, 取树形字典表中的code
@@ -1637,9 +1644,56 @@ public class ResultServiceImpl implements IResultService {
@Override
public MonitorResultVO getMonitorResult ( String devId ) {
public List < MonitorResultVO> getMonitorResult ( String devId ) {
PqDev dev = pqDevService . getById ( devId ) ;
AdPlan plan = adPlanService . getById ( dev . getPlanId ( ) ) ;
String errorSysName = pqErrSysService . getPqErrSysById ( plan . getErrorSysId ( ) ) . getName ( ) ;
return null ;
List < PqMonitor > pqMonitorList = pqMonitorService . lambdaQuery ( ) . eq ( PqMonitor : : getDevId , devId ) . isNotNull ( PqMonitor : : getResultType ) . list ( ) ;
List < MonitorResultVO > list = new ArrayList < > ( ) ;
MonitorResultVO result ;
for ( PqMonitor pqMonitor : pqMonitorList ) {
result = new MonitorResultVO ( ) ;
result . setMonitorId ( pqMonitor . getDevId ( ) + CnSocketUtil . SPLIT_TAG + pqMonitor . getNum ( ) ) ;
result . setErrorSysName ( errorSysName ) ;
result . setMonitorNum ( pqMonitor . getNum ( ) ) ;
result . setQualifiedNum ( pqMonitor . getQualifiedNum ( ) ) ;
List < AdPair > records = adPairService . page ( new Page < > ( 1 , 1 ) ,
new LambdaQueryWrapper < AdPair > ( ) . eq ( AdPair : : getDevMonitorId , result . getMonitorId ( ) )
. eq ( AdPair : : getPlanId , plan . getId ( ) ) . orderByDesc ( AdPair : : getNum ) )
. getRecords ( ) ;
if ( CollUtil . isNotEmpty ( records ) ) {
result . setTotalNum ( records . get ( 0 ) . getNum ( ) ) ;
result . setUnQualifiedNum ( result . getTotalNum ( ) - result . getQualifiedNum ( ) ) ;
}
String resultType = pqMonitor . getResultType ( ) ;
result . setResultType ( resultType ) ;
DataSourceEnum dataSourceEnum = DataSourceEnum . ofByValue ( resultType ) ;
switch ( Objects . requireNonNull ( dataSourceEnum ) ) {
case REAL_DATA :
result . setCheckResult ( pqMonitor . getRealtimeResult ( ) ) ;
result . setWhichTime ( pqMonitor . getRealtimeNum ( ) ) ;
result . setResultOrigin ( dataSourceEnum . getMsg ( ) ) ;
break ;
case WAVE_DATA :
result . setCheckResult ( pqMonitor . getRecordedResult ( ) ) ;
List < String > waveData = StrUtil . split ( pqMonitor . getRecordedNum ( ) , CnSocketUtil . SPLIT_TAG ) ;
result . setWhichTime ( waveData . get ( 0 ) ) ;
result . setResultType ( resultType + CnSocketUtil . SPLIT_TAG + waveData . get ( 1 ) ) ;
result . setResultOrigin ( dataSourceEnum . getMsg ( ) + waveData . get ( 1 ) ) ;
break ;
default :
break ;
}
list . add ( result ) ;
}
return list ;
}
@Override
@@ -1651,12 +1705,17 @@ public class ResultServiceImpl implements IResultService {
PqDev dev = pqDevService . getById ( split [ 0 ] ) ;
String planId = dev . getPlanId ( ) ;
AdPlan plan = adPlanService . getById ( planId ) ;
if ( ! plan . getFatherPlanId ( ) . equals ( CommonEnum . FATHER_ID . getValue ( ) ) ) {
plan = adPlanService . getById ( plan . getFatherPlanId ( ) ) ;
}
AdPlan finalPlan = plan ;
// 实时数据结果
List < ContrastNonHarmonicResult > nonHarmonicResults = contrastNonHarmonicService . listAllResultData ( String . valueOf ( p lan. getCode ( ) ) , null , null , false , monitorId , null ) ;
List < ContrastNonHarmonicResult > nonHarmonicResults = contrastNonHarmonicService . listAllResultData ( String . valueOf ( finalP lan. getCode ( ) ) , null , null , false , monitorId , null ) ;
Map < Integer , List < ContrastNonHarmonicResult > > numMap = nonHarmonicResults . stream ( )
. sorted ( Comparator . comparing ( ContrastNonHarmonicResult : : getNum ) )
. collect ( Collectors . groupingBy ( ContrastNonHarmonicResult : : getNum , LinkedHashMap : : new , Collectors . toList ( ) ) ) ;
numMap . forEach ( ( num , resultList ) - > {
List < DataSourceResultVO > dataSourceResultVOList = new ArrayList < > ( ) ;
@@ -1668,7 +1727,7 @@ public class ResultServiceImpl implements IResultService {
dataSourceResultVOList . add ( realDataSourceResultVO ) ;
// 录波数据结果
List < ContrastNonHarmonicResult > waveNonHarmonicResults = contrastNonHarmonicService . listAllResultData ( String . valueOf ( p lan. getCode ( ) ) , num , null , true , monitorId , null ) ;
List < ContrastNonHarmonicResult > waveNonHarmonicResults = contrastNonHarmonicService . listAllResultData ( String . valueOf ( finalP lan. getCode ( ) ) , num , null , true , monitorId , null ) ;
Map < Integer , List < ContrastNonHarmonicResult > > waveNumMap = waveNonHarmonicResults . stream ( )
. sorted ( Comparator . comparing ( ContrastNonHarmonicResult : : getWaveNum ) )
. collect ( Collectors . groupingBy ( ContrastNonHarmonicResult : : getWaveNum , LinkedHashMap : : new , Collectors . toList ( ) ) ) ;