@ -4,21 +4,25 @@ import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject ;
import com.alibaba.fastjson2.JSONObject ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.biutag.supervisiondata.common.interfaces.CompletableFutureUtil ;
import com.biutag.supervisiondata.common.interfaces.CompletableFutureUtil ;
import com.biutag.supervisiondata.common.utils.StreamUtil ;
import com.biutag.supervisiondata.config.cache.RedisDao ;
import com.biutag.supervisiondata.config.cache.RedisDao ;
import com.biutag.supervisiondata.pojo.ClueData ;
import com.biutag.supervisiondata.pojo.constants.Default ;
import com.biutag.supervisiondata.pojo.constants.Default ;
import com.biutag.supervisiondata.pojo.constants.RedisKey ;
import com.biutag.supervisiondata.pojo.constants.RedisKey ;
import com.biutag.supervisiondata.pojo.database.PointOrg ;
import com.biutag.supervisiondata.pojo.database.PointOrg ;
import com.biutag.supervisiondata.pojo.domain.TaskParamDomain ;
import com.biutag.supervisiondata.pojo.entity.ads.GBaseSYRKXX ;
import com.biutag.supervisiondata.pojo.entity.ads.GBaseSYRKXX ;
import com.biutag.supervisiondata.pojo.entity.dwd.GBaseJJD ;
import com.biutag.supervisiondata.pojo.entity.dwd.GBaseJJD ;
import com.biutag.supervisiondata.pojo.entity.mine.RiskModelTaskClue ;
import com.biutag.supervisiondata.pojo.entity.mine.RiskPersonal ;
import com.biutag.supervisiondata.pojo.entity.mine.RiskPersonal ;
import com.biutag.supervisiondata.pojo.entity.mine.RiskTask ;
import com.biutag.supervisiondata.pojo.entity.mine.SupExternalDepart ;
import com.biutag.supervisiondata.pojo.entity.mine.SupExternalDepart ;
import com.biutag.supervisiondata.pojo.enums.DepartType ;
import com.biutag.supervisiondata.pojo.enums.DepartType ;
import com.biutag.supervisiondata.repository.GBaseJJDRepository ;
import com.biutag.supervisiondata.repository.* ;
import com.biutag.supervisiondata.repository.GBaseSYRKXXRepository ;
import com.biutag.supervisiondata.repository.GBaseZDRYRepository ;
import com.biutag.supervisiondata.repository.SupExternalDepartRepository ;
import com.biutag.supervisiondata.service.GBaseJJDService ;
import com.biutag.supervisiondata.service.GBaseJJDService ;
import com.biutag.supervisiondata.service.RiskModelTaskClueService ;
import com.biutag.supervisiondata.service.RiskPersonalService ;
import com.biutag.supervisiondata.service.RiskPersonalService ;
import com.biutag.supervisiondata.util.BhUtil ;
import com.biutag.supervisiondata.util.IdCodeUtil ;
import com.biutag.supervisiondata.util.IdCodeUtil ;
import com.biutag.supervisiondata.util.OrgUtil ;
import com.biutag.supervisiondata.util.OrgUtil ;
import com.biutag.supervisiondata.util.PatternUtil ;
import com.biutag.supervisiondata.util.PatternUtil ;
@ -311,9 +315,105 @@ public class GBaseJJDServiceImpl implements GBaseJJDService {
) . join ( ) ;
) . join ( ) ;
}
}
private final RiskTaskRepository taskRepository ;
private final RiskModelTaskClueService clueService ;
@Override
@Override
public void syncPoliceInstance ( ) {
public void syncPoliceAttack ( TaskParamDomain domain ) {
String startTime = LocalDateTime . of ( 2019 , 12 , 6 , 0 , 0 , 0 ) . format ( DateTimeFormatter . ofPattern ( "yyyy-MM-dd HH:mm:ss" ) ) ;
List < GBaseJJD > result = gBaseJJDRepository . getBaseMapper ( ) . selectAttackPolist ( startTime ) ;
RiskTask task = taskRepository . create ( result . size ( ) , 64 ) ;
// 证件相关警情
Map < String , List < GBaseJJD > > idCodeMap = new WeakHashMap < > ( ) ;
// 手机号相关警情
Map < String , List < GBaseJJD > > mobileMap = new WeakHashMap < > ( ) ;
List < String > idCodes = new ArrayList < > ( ) ;
List < String > mobiles = new ArrayList < > ( ) ;
for ( GBaseJJD gBaseJJD : result ) {
String idCard = PatternUtil . takeIdCard ( gBaseJJD . getCjqk ( ) ) ;
if ( idCard . isEmpty ( ) ) {
idCard = PatternUtil . takeIdCard ( gBaseJJD . getBjnr ( ) ) ;
}
if ( ! idCard . isEmpty ( ) ) {
List < String > tmp = Arrays . stream ( idCard . split ( "," ) ) . toList ( ) ;
// 如果有多个号码,防止警察证件被录入
if ( tmp . size ( ) > 1 ) {
tmp . remove ( 0 ) ;
}
idCodes . addAll ( tmp ) ;
for ( String s : tmp ) {
idCodeMap . computeIfAbsent ( s , k - > new ArrayList < > ( ) ) . add ( gBaseJJD ) ;
}
}
String mobile = PatternUtil . takeMobile ( gBaseJJD . getCjqk ( ) ) ;
if ( mobile . isEmpty ( ) ) {
mobile = PatternUtil . takeMobile ( gBaseJJD . getBjnr ( ) ) ;
}
if ( ! mobile . isEmpty ( ) ) {
List < String > tmp = Arrays . stream ( idCard . split ( "," ) ) . toList ( ) ;
// 如果有多个号码,防止警察证件被录入
if ( tmp . size ( ) > 1 ) {
tmp . remove ( 0 ) ;
}
mobiles . addAll ( tmp ) ;
for ( String s : tmp ) {
mobileMap . computeIfAbsent ( s , k - > new ArrayList < > ( ) ) . add ( gBaseJJD ) ;
}
}
}
List < RiskModelTaskClue > oldList = Optional . ofNullable ( domain . getMap ( ) . get ( task . getModelId ( ) ) ) . orElse ( new ArrayList < > ( ) ) ;
// 按人分
Map < String , List < RiskModelTaskClue > > personOldMap = oldList . stream ( ) . collect ( Collectors . groupingBy ( RiskModelTaskClue : : getIdCode ) ) ;
List < GBaseJJD > jjdList ;
List < RiskModelTaskClue > toInsert = new ArrayList < > ( ) ;
for ( RiskPersonal person : domain . getPersons ( ) ) {
jjdList = Optional . of ( idCodeMap . get ( person . getIdCode ( ) ) ) . orElse ( new ArrayList < > ( ) ) ;
jjdList . addAll ( Optional . of ( mobileMap . get ( person . getMobileNumber ( ) ) ) . orElse ( new ArrayList < > ( ) ) ) ;
if ( jjdList . isEmpty ( ) ) {
continue ;
}
jjdList = jjdList . stream ( ) . filter ( StreamUtil . distinctByKey ( GBaseJJD : : getJjdbh ) ) . toList ( ) ;
List < RiskModelTaskClue > olds = Optional . ofNullable ( personOldMap . get ( person . getIdCode ( ) ) ) . orElse ( new ArrayList < > ( ) ) ;
Map < String , RiskModelTaskClue > oldMap = olds . stream ( ) . collect ( Collectors . toMap ( RiskModelTaskClue : : getCaseIds , Function . identity ( ) , ( val , old ) - > val ) ) ;
for ( GBaseJJD gBaseJJD : jjdList ) {
if ( oldMap . get ( BhUtil . jjdBh ( gBaseJJD . getJjdbh ( ) ) ) ! = null ) {
continue ;
}
ClueData data = ClueData . builder ( )
. name ( person . getName ( ) )
. id ( BhUtil . jjdBh ( gBaseJJD . getJjdbh ( ) ) )
. idCode ( person . getIdCode ( ) )
. tag ( "有平台涉警事件" )
. personId ( person . getId ( ) )
. build ( ) ;
StringBuilder sb = new StringBuilder ( "该人员存在平台涉警事件警情,接警单编号:" + gBaseJJD . getJjdbh ( ) ) ;
if ( gBaseJJD . getBjnr ( ) ! = null & & ! gBaseJJD . getBjnr ( ) . isEmpty ( ) ) {
sb . append ( ",报警内容;" + gBaseJJD . getBjnr ( ) ) ;
}
if ( gBaseJJD . getCjqk ( ) ! = null & & ! gBaseJJD . getCjqk ( ) . isEmpty ( ) ) {
sb . append ( ",处警情况;" + gBaseJJD . getCjqk ( ) ) ;
}
sb . append ( ",增加风险分5分" ) ;
data . setSourceData ( sb . toString ( ) ) ;
try {
data . setEventTime ( gBaseJJD . getBjsj ( ) . toInstant ( ) . atZone ( ZoneId . systemDefault ( ) ) . toLocalDateTime ( ) ) ;
} catch ( Exception ignored ) {
data . setEventTime ( LocalDateTime . now ( ) ) ;
}
toInsert . add ( createClue ( task . getModelId ( ) , 5 , task . getId ( ) , data ) ) ;
}
}
if ( ! toInsert . isEmpty ( ) ) {
clueService . saveClues ( toInsert , Default . WF_IG ) ;
}
taskRepository . updateTask ( task . getId ( ) , toInsert . size ( ) , 0 ) ;
}
}
void toRedisCache ( List < GBaseJJD > jjdList , String keyName ) {
void toRedisCache ( List < GBaseJJD > jjdList , String keyName ) {
@ -419,4 +519,20 @@ public class GBaseJJDServiceImpl implements GBaseJJDService {
}
}
return tmp ;
return tmp ;
}
}
RiskModelTaskClue createClue ( Integer modelId , Integer score , Integer taskId , ClueData data ) {
RiskModelTaskClue clue = new RiskModelTaskClue ( ) ;
clue . setModelId ( modelId ) ;
clue . setScore ( score ) ;
clue . setName ( data . getName ( ) ) ;
clue . setIdCode ( data . getIdCode ( ) ) ;
clue . setTaskId ( taskId ) ;
clue . setData ( data . getSourceData ( ) ) ;
clue . setEventTime ( data . getEventTime ( ) ) ;
clue . setCreateTime ( LocalDateTime . now ( ) ) ;
clue . setUpdateTime ( LocalDateTime . now ( ) ) ;
clue . setCaseIds ( data . getId ( ) ) ;
clue . setRiskReason ( data . getTag ( ) ) ;
return clue ;
}
}
}