@@ -26,6 +26,7 @@ import java.util.stream.Collectors;
public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl < DetectionDataDealMapper , AdHarmonicResult > implements DetectionDataDealService {
private final AdNonHarmonicService adNonHarmonicService ;
private final DetectionDataDealMapper detectionDataDealMapper ;
@Override
@@ -34,10 +35,10 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
String adNonTable = " ad_non_harmonic_ " ;
DynamicTableNameHandler . setTableName ( adNonTable + code ) ;
List < String > monitorIds = adNonHarmonicResultList . stream ( ) . map ( AdNonHarmonicResult : : getMonitorId ) . distinct ( ) . collect ( Collectors . toList ( ) ) ;
if ( CollUtil . isNotEmpty ( monitorIds ) ) {
if ( CollUtil . isNotEmpty ( monitorIds ) ) {
adNonHarmonicService . remove ( new LambdaQueryWrapper < AdNonHarmonicResult > ( ) . in ( AdNonHarmonicResult : : getMonitorId , monitorIds )
. eq ( AdNonHarmonicResult : : getScriptId , adNonHarmonicResultList . get ( 0 ) . getScriptId ( ) )
. eq ( AdNonHarmonicResult : : getSort , adNonHarmonicResultList . get ( 0 ) . getSort ( ) ) ) ;
. eq ( AdNonHarmonicResult : : getScriptId , adNonHarmonicResultList . get ( 0 ) . getScriptId ( ) )
. eq ( AdNonHarmonicResult : : getSort , adNonHarmonicResultList . get ( 0 ) . getSort ( ) ) ) ;
adNonHarmonicService . saveBatch ( adNonHarmonicResultList , 100 ) ;
}
DynamicTableNameHandler . remove ( ) ;
@@ -50,10 +51,10 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
String adTable = " ad_harmonic_ " ;
DynamicTableNameHandler . setTableName ( adTable + code ) ;
List < String > monitorIds = adHarmonicResultList . stream ( ) . map ( AdHarmonicResult : : getMonitorId ) . distinct ( ) . collect ( Collectors . toList ( ) ) ;
if ( CollUtil . isNotEmpty ( monitorIds ) ) {
if ( CollUtil . isNotEmpty ( monitorIds ) ) {
this . remove ( new LambdaQueryWrapper < AdHarmonicResult > ( ) . in ( AdHarmonicResult : : getMonitorId , monitorIds )
. eq ( AdHarmonicResult : : getScriptId , adHarmonicResultList . get ( 0 ) . getScriptId ( ) )
. eq ( AdHarmonicResult : : getSort , adHarmonicResultList . get ( 0 ) . getSort ( ) ) ) ;
. eq ( AdHarmonicResult : : getScriptId , adHarmonicResultList . get ( 0 ) . getScriptId ( ) )
. eq ( AdHarmonicResult : : getSort , adHarmonicResultList . get ( 0 ) . getSort ( ) ) ) ;
this . saveBatch ( adHarmonicResultList , 100 ) ;
}
@@ -67,10 +68,10 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
String adNonTableResult = " ad_non_harmonic_result_ " ;
DynamicTableNameHandler . setTableName ( adNonTableResult + code ) ;
List < String > monitorIds = adNonHarmonicResultList . stream ( ) . map ( AdNonHarmonicResult : : getMonitorId ) . distinct ( ) . collect ( Collectors . toList ( ) ) ;
if ( CollUtil . isNotEmpty ( monitorIds ) ) {
if ( CollUtil . isNotEmpty ( monitorIds ) ) {
adNonHarmonicService . remove ( new LambdaQueryWrapper < AdNonHarmonicResult > ( ) . in ( AdNonHarmonicResult : : getMonitorId , monitorIds )
. eq ( AdNonHarmonicResult : : getScriptId , adNonHarmonicResultList . get ( 0 ) . getScriptId ( ) )
. eq ( AdNonHarmonicResult : : getSort , adNonHarmonicResultList . get ( 0 ) . getSort ( ) ) ) ;
. eq ( AdNonHarmonicResult : : getScriptId , adNonHarmonicResultList . get ( 0 ) . getScriptId ( ) )
. eq ( AdNonHarmonicResult : : getSort , adNonHarmonicResultList . get ( 0 ) . getSort ( ) ) ) ;
adNonHarmonicService . saveBatch ( adNonHarmonicResultList , 100 ) ;
}
DynamicTableNameHandler . remove ( ) ;
@@ -83,10 +84,10 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
String adTableResult = " ad_harmonic_result_ " ;
DynamicTableNameHandler . setTableName ( adTableResult + code ) ;
List < String > monitorIds = adHarmonicResultList . stream ( ) . map ( AdHarmonicResult : : getMonitorId ) . distinct ( ) . collect ( Collectors . toList ( ) ) ;
if ( CollUtil . isNotEmpty ( monitorIds ) ) {
if ( CollUtil . isNotEmpty ( monitorIds ) ) {
this . remove ( new LambdaQueryWrapper < AdHarmonicResult > ( ) . in ( AdHarmonicResult : : getMonitorId , monitorIds )
. eq ( AdHarmonicResult : : getScriptId , adHarmonicResultList . get ( 0 ) . getScriptId ( ) )
. eq ( AdHarmonicResult : : getSort , adHarmonicResultList . get ( 0 ) . getSort ( ) ) ) ;
. eq ( AdHarmonicResult : : getScriptId , adHarmonicResultList . get ( 0 ) . getScriptId ( ) )
. eq ( AdHarmonicResult : : getSort , adHarmonicResultList . get ( 0 ) . getSort ( ) ) ) ;
this . saveBatch ( adHarmonicResultList , 100 ) ;
}
DynamicTableNameHandler . remove ( ) ;
@@ -94,39 +95,42 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
}
@Override
public Map < String , Integer > devResult ( List < String > ids , List < String > valueType , String code ) {
List < AdNonHarmonicResult > noHarm = new ArrayList < > ( ) ;
public Map < String , Integer > devResult ( List < String > ids , List < String > valueType , String code ) {
List < Integer > disabledScriptDtlIndexs = detectionDataDealMapper . listDisabledScriptDtlIndexs ( ids . get ( 0 ) ) ;
List < AdNonHarmonicResult > noHarm = new ArrayList < > ( ) ;
for ( String id : ids ) {
DynamicTableNameHandler . setTableName ( " ad_non_harmonic_result_ " + code ) ;
noHarm . addAll ( adNonHarmonicService . list ( new LambdaQueryWrapper < AdNonHarmonicResult > ( )
. like ( AdNonHarmonicResult : : getMonitorId , id )
. i n( CollUtil . isNotEmpty ( valueType ) , AdNonHarmonicResult : : getAdType , valueType )
)) ;
noHarm . addAll ( adNonHarmonicService . list ( new LambdaQueryWrapper < AdNonHarmonicResult > ( )
. like ( AdNonHarmonicResult : : getMonitorId , id )
. notI n( CollUtil . isNotEmpty ( disabledScriptDtlIndexs ) , AdNonHarmonicResult : : getSort , disabledScriptDtlIndexs )
. in ( CollUtil . isNotEmpty ( valueType ) , AdNonHarmonicResult : : getAdType , valueType )
) ) ;
}
DynamicTableNameHandler . remove ( ) ;
List < AdHarmonicResult > harm = new ArrayList < > ( ) ;
List < AdHarmonicResult > harm = new ArrayList < > ( ) ;
for ( String id : ids ) {
DynamicTableNameHandler . setTableName ( " ad_harmonic_result_ " + code ) ;
harm . addAll ( this . list ( new LambdaQueryWrapper < AdHarmonicResult > ( )
. like ( AdHarmonicResult : : getMonitorId , id )
. i n( CollUtil . isNotEmpty ( valueType ) , AdHarmonicResult : : getAdType , valueType )
) ) ;
harm . addAll ( this . list ( new LambdaQueryWrapper < AdHarmonicResult > ( )
. like ( AdHarmonicResult : : getMonitorId , id )
. notI n( CollUtil . isNotEmpty ( disabledScriptDtlIndexs ) , AdHarmonicResult : : getSort , disabledScriptDtlIndexs )
. in ( CollUtil . isNotEmpty ( valueType ) , AdHarmonicResult : : getAdType , valueType )
) ) ;
}
DynamicTableNameHandler . remove ( ) ;
Map < String , List < Integer > > noHarmMap = noHarm . stream ( ) . collect ( Collectors . groupingBy ( x - > x . getMonitorId ( ) . split ( " _ " ) [ 0 ] ,
Collectors . mapping ( AdNonHarmonicResult : : getResultFlag , Collectors . toList ( ) ) ) ) ;
Map < String , List < Integer > > harmMap = harm . stream ( ) . collect ( Collectors . groupingBy ( x - > x . getMonitorId ( ) . split ( " _ " ) [ 0 ] ,
Collectors . mapping ( AdHarmonicResult : : getResultFlag , Collectors . toList ( ) ) ) ) ;
Map < String , Integer > map = new HashMap < > ( 2 ) ;
Map < String , Integer > map = new HashMap < > ( 2 ) ;
for ( String id : ids ) {
List < Integer > resultFlags = new ArrayList < > ( ) ;
if ( noHarmMap . containsKey ( id ) ) {
List < Integer > resultFlags = new ArrayList < > ( ) ;
if ( noHarmMap . containsKey ( id ) ) {
resultFlags . addAll ( noHarmMap . get ( id ) ) ;
}
if ( harmMap . containsKey ( id ) ) {
if ( harmMap . containsKey ( id ) ) {
resultFlags . addAll ( harmMap . get ( id ) ) ;
}
map . put ( id , isResultFlag ( resultFlags ) ) ;
map . put ( id , isResultFlag ( resultFlags ) ) ;
}
return map ;
}
@@ -134,12 +138,12 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
private static Integer isResultFlag ( List < Integer > resultFlags ) {
// 检测结果( 0:不符合 1:符合 2:/[未检测无结果])
//脚本结果是 1.符合 2.不符合 4.未检测无结果
resultFlags = resultFlags . stream ( ) . filter ( x - > 4 ! = x ) . distinct ( ) . collect ( Collectors . toList ( ) ) ;
resultFlags = resultFlags . stream ( ) . filter ( x - > 4 ! = x ) . distinct ( ) . collect ( Collectors . toList ( ) ) ;
if ( CollUtil . isNotEmpty ( resultFlags ) ) {
if ( resultFlags . contains ( 2 ) ) {
return 0 ;
} else {
switch ( resultFlags . get ( 0 ) ) {
} else {
switch ( resultFlags . get ( 0 ) ) {
case 1 :
return 1 ;
case 2 :