@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.* ;
import cn.hutool.core.util.* ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper ;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper ;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils ;
import com.biutag.supervision.constants.enums.ComfortStatus ;
import com.biutag.supervision.constants.enums.ComfortStatus ;
import com.biutag.supervision.constants.enums.ProcessingStatusEnum ;
import com.biutag.supervision.constants.enums.ProcessingStatusEnum ;
import com.biutag.supervision.constants.enums.RpcApplyTypeEnum ;
import com.biutag.supervision.constants.enums.RpcApplyTypeEnum ;
@ -24,6 +25,8 @@ import java.time.LocalDateTime;
import java.time.Month ;
import java.time.Month ;
import java.time.ZoneId ;
import java.time.ZoneId ;
import java.util.* ;
import java.util.* ;
import java.util.function.Function ;
import java.util.logging.Level ;
import java.util.stream.Collectors ;
import java.util.stream.Collectors ;
import static com.biutag.supervision.util.TimeUtil.SECONDS_OF_A_DAY ;
import static com.biutag.supervision.util.TimeUtil.SECONDS_OF_A_DAY ;
@ -113,6 +116,7 @@ public class Job {
private final SupDepartService departService ;
private final SupDepartService departService ;
private final DwdAsjZfbaAjjbxxMapper dwdAsjZfbaAjjbxxMapper ;
private final DwdAsjZfbaAjjbxxMapper dwdAsjZfbaAjjbxxMapper ;
private final SupDepartMapper supDepartMapper ;
private final SupDepartMapper supDepartMapper ;
private final RpcApplyPersonService rpcApplyPersonService ;
private final RpcApplyPersonService rpcApplyPersonService ;
private final DwdAsjZfbaWfrwfxxMapper dwdAsjZfbaWfrwfxxMapper ;
private final DwdAsjZfbaWfrwfxxMapper dwdAsjZfbaWfrwfxxMapper ;
private final RpcInfringerResultService rpcInfringerResultService ;
private final RpcInfringerResultService rpcInfringerResultService ;
@ -124,7 +128,7 @@ public class Job {
// 每天一次 23:30:00
// 每天一次 23:30:00
//todo 维权信息
//todo 维权信息
// @Scheduled(cron = "0 30 23 * * ?")
// @Scheduled(cron = "0 30 23 * * ?")
public void righ ts( ) throws ParseException {
public void te stFun ( ) throws ParseException {
log . info ( "rights--------------------" ) ;
log . info ( "rights--------------------" ) ;
log . info ( "维权信息抓取中---------------------" ) ;
log . info ( "维权信息抓取中---------------------" ) ;
// 维权
// 维权
@ -372,6 +376,269 @@ public class Job {
log . info ( "录入完成-------------" ) ;
log . info ( "录入完成-------------" ) ;
}
}
//todo 维权信息
public void rights ( ) throws ParseException {
log . info ( "rights--------------------" ) ;
log . info ( "维权信息抓取中---------------------" ) ;
// 维权
SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) ;
Date startTime = sdf . parse ( "2025-01-01 00:00:00" ) ;
Date endTime = sdf . parse ( "2025-12-30 00:00:00" ) ;
List < DwdAsjZfbaShrxx > shrxxList = dwdAsjZfbaShrxxService . list ( startTime , endTime ) ;
if ( CollectionUtil . isEmpty ( shrxxList ) ) {
log . info ( "时间范围内无受害人信息" ) ;
return ;
}
log . info ( "数据:{}条" , shrxxList . size ( ) ) ;
List < String > zjList = shrxxList . stream ( ) . map ( DwdAsjZfbaShrxx : : getZj )
. filter ( StrUtil : : isNotBlank )
. distinct ( ) . toList ( ) ;
List < TXsshrxxb > tXsshrxxbs = tXsshrxxbService . getListAllByZjs ( zjList ) ;
if ( CollectionUtil . isEmpty ( tXsshrxxbs ) ) {
log . info ( "未找到受伤民辅警" ) ;
return ;
}
//单位数据 map
List < SupDepart > departs = departService . list ( ) ;
//单位简称 map
Map < String , SupDepart > ShortNameMap = departs . stream ( ) . collect ( Collectors . toMap (
SupDepart : : getShortName , // Key提取函数
Function . identity ( ) , // Value直接使用对象本身
( existing , replacement ) - > existing // 解决键冲突(保留已有值)
) ) ;
//单位名称 map
Map < String , SupDepart > NameMap = departs . stream ( ) . collect ( Collectors . toMap (
SupDepart : : getName , // Key提取函数
Function . identity ( ) , // Value直接使用对象本身
( existing , replacement ) - > existing // 解决键冲突(保留已有值)
) ) ;
//单位id map
Map < String , SupDepart > departIdMap = departs . stream ( ) . collect ( Collectors . toMap (
SupDepart : : getId , // Key提取函数
Function . identity ( ) , // Value直接使用对象本身
( existing , replacement ) - > existing // 解决键冲突(保留已有值)
) ) ;
//受害人信息处理
tXsshrxxbs = tXsshrxxbs . stream ( ) . filter ( s - > StrUtil . isNotBlank ( s . getGmsfhm ( ) ) ) . map ( s - > {
SupPolice police = policeService . getByIdCode ( s . getGmsfhm ( ) ) ;
if ( ObjectUtil . isNotEmpty ( police ) ) {
s . setEmpNo ( police . getEmpNo ( ) ) ;
String departId = police . getOrgId ( ) ;
s . setDepartId ( departId ) ;
s . setJob ( police . getJob ( ) ) ;
if ( departIdMap . containsKey ( departId ) ) {
s . setDepartName ( departIdMap . get ( departId ) . getShortName ( ) ) ;
}
}
return s ;
} ) . toList ( ) ;
log . info ( "受害人信息数量数据:{}条" , tXsshrxxbs . size ( ) ) ;
//处理为受害人map
Map < String , List < TXsshrxxb > > xsshrxxbMap = tXsshrxxbs . stream ( )
. filter ( s - > StrUtil . isNotBlank ( s . getAjbh ( ) ) )
. collect ( Collectors . groupingBy ( TXsshrxxb : : getAjbh ) ) ;
log . info ( "处理后受害人数量数据:{}条" , xsshrxxbMap . size ( ) ) ;
List < String > ajbhList = new ArrayList < > ( xsshrxxbMap . keySet ( ) ) ;
//办案人员信息List
Map < String , DwdRyZfbaBaryxx > zfbaBaryxxMap = new HashMap < > ( ) ;
//案件 rpc_apply
for ( String ajbh : ajbhList ) {
try {
//获取案件基本信息
DwdAsjZfbaAjjbxx ajjbxx = dwdAsjZfbaAjjbxxMapper . selectByAjbh ( ajbh ) ;
if ( ObjectUtil . isEmpty ( ajjbxx ) ) {
log . info ( "案件[" + ajbh + "]未找到基本信息" ) ;
continue ;
}
//获取受害人列表
List < TXsshrxxb > tXsshrxxbList = xsshrxxbMap . get ( ajbh ) ;
if ( CollectionUtil . isEmpty ( tXsshrxxbList ) ) {
log . info ( "未找到受害人" ) ;
continue ;
}
//嫌疑人
List < DwdAsjZfbaWfrwfxx > wfrwfxxes = dwdAsjZfbaWfrwfxxMapper . selectList ( new LambdaQueryWrapper < DwdAsjZfbaWfrwfxx > ( ) . eq ( DwdAsjZfbaWfrwfxx : : getAjbh , ajbh ) ) ;
//办案人
DwdRyZfbaBaryxx dwdRyZfbaBaryxx = zfbaBaryxxMap . computeIfAbsent (
ajjbxx . getBar1id ( ) ,
k - > dwdRyZfbaBaryxxService . selectDataById ( k )
) ;
//受害人警号查询
TXsshrxxb oneShr = tXsshrxxbList . get ( 0 ) ;
RpcApply rpcApply = new RpcApply ( ) ;
//1、案件基本信息
rpcApply . setNumber ( ajbh ) ;
rpcApply . setCaseNumber ( ajbh ) ;
rpcApply . setCaseName ( ajjbxx . getAjmc ( ) ) ;
rpcApply . setCrtTime ( LocalDateTime . now ( ) ) ;
rpcApply . setUptTime ( LocalDateTime . now ( ) ) ;
rpcApply . setDepartId ( oneShr . getDepartId ( ) ) ;
rpcApply . setDepartName ( oneShr . getDepartName ( ) ) ;
//申请时间
rpcApply . setApplyDate ( LocalDate . now ( ) ) ;
//2、申请人信息
rpcApply . setApplicantEmpName ( oneShr . getXm ( ) ) ;
rpcApply . setApplicantEmpNo ( oneShr . getEmpNo ( ) ) ;
//3、案件信息 案发时间
rpcApply . setHappenTime ( oneShr . getShrq ( ) . toInstant ( ) . atZone ( ZoneId . systemDefault ( ) ) . toLocalDateTime ( ) ) ;
//简要案情
rpcApply . setFactReason ( ajjbxx . getJyaq ( ) ) ;
//案发基本类型
rpcApply . setIncidentLinkName ( ajjbxx . getAjlbmc ( ) ) ;
// 申请类型
rpcApply . setType ( RpcApplyTypeEnum . RIGHTS_PROTECTION . getValue ( ) ) ;
// 设置案件类型和处理方式
if ( "刑事" . equals ( ajjbxx . getAjbzmc ( ) ) ) {
// rpcApply.setInfringerHandle("刑事追究");
rpcApply . setCaseType ( "1" ) ;
}
if ( "行政" . equals ( ajjbxx . getAjbzmc ( ) ) ) {
// rpcApply.setInfringerHandle("行政处罚");
rpcApply . setCaseType ( "2" ) ;
}
if ( StrUtil . isNotEmpty ( ajjbxx . getBadwidmc ( ) ) ) {
String unitName = ajjbxx . getBadwidmc ( ) ;
log . info ( "单位名称:" , ajjbxx . getBadwidmc ( ) ) ;
if ( ! unitName . contains ( "长沙市公安局" ) ) {
unitName = unitName . split ( "湖南省" ) [ 1 ] ;
}
if ( NameMap . containsKey ( unitName ) ) {
//处理单位
SupDepart supDepart = NameMap . get ( unitName ) ;
rpcApply . setHandleDepartId ( supDepart . getId ( ) ) ;
rpcApply . setHandleDepartName ( supDepart . getShortName ( ) ) ;
//获取二级单位的信息
String statisticsGroupName = null ;
final String CHANGSHA_POLICE = "长沙市公安局" ;
// 判断是否为非长沙市公安局
if ( unitName ! = null & & ! unitName . contains ( CHANGSHA_POLICE ) ) {
// 非长沙市公安局
String badwidmc = ajjbxx . getBadwidmc ( ) ;
if ( badwidmc ! = null & & ! badwidmc . isEmpty ( ) ) {
// 优化字符串处理,使用indexOf代替split以提高性能
int juIndex = badwidmc . indexOf ( '局' ) ;
if ( juIndex > 0 ) {
String beforeJu = badwidmc . substring ( 0 , juIndex ) ;
int shengIndex = beforeJu . indexOf ( '省' ) ;
if ( shengIndex > 0 & & shengIndex < beforeJu . length ( ) - 1 ) {
String afterSheng = beforeJu . substring ( shengIndex + 1 ) ;
statisticsGroupName = "湖南省长沙市公安局" + afterSheng + "局" ;
} else {
log . info ( "无法分割'省'或'省'后没有有效内容: {}" , beforeJu ) ;
}
} else {
log . info ( "无法在{}中找到'局'字" , badwidmc ) ;
}
}
}
if ( ShortNameMap . containsKey ( statisticsGroupName ) ) {
SupDepart groupDept = ShortNameMap . get ( statisticsGroupName ) ;
rpcApply . setSecondDepartId ( groupDept . getId ( ) ) ;
}
}
}
// 已办结
rpcApply . setRpcStatus ( ComfortStatus . completed . name ( ) ) ;
//办案人
if ( ObjectUtil . isNotEmpty ( dwdRyZfbaBaryxx ) & & StrUtil . isNotBlank ( dwdRyZfbaBaryxx . getZjhm ( ) ) ) {
SupPolice policeData = policeService . getByIdCode ( dwdRyZfbaBaryxx . getZjhm ( ) ) ;
if ( ObjectUtil . isNotEmpty ( policeData ) ) {
rpcApply . setInputEmpNo ( policeData . getEmpNo ( ) ) ;
} else {
log . info ( "未找到身份证号[" + dwdRyZfbaBaryxx . getZjhm ( ) + "]对应的警察信息" ) ;
}
}
//嫌疑人
if ( ArrayUtil . isNotEmpty ( wfrwfxxes ) ) {
String suspectNames = wfrwfxxes . stream ( )
. filter ( obj - > StrUtil . isNotBlank ( obj . getXm ( ) ) )
. map ( DwdAsjZfbaWfrwfxx : : getXm )
. collect ( Collectors . joining ( "、" ) ) ;
String disposeMethods = wfrwfxxes . stream ( )
. filter ( obj - > StrUtil . isNotBlank ( obj . getClfs ( ) ) )
. map ( DwdAsjZfbaWfrwfxx : : getClfs )
. collect ( Collectors . joining ( ";" ) ) ;
rpcApply . setInfringerName ( suspectNames ) ;
// 只有当存在实际处理方式时才覆盖默认值
if ( StrUtil . isNotBlank ( disposeMethods ) ) {
rpcApply . setInfringerHandle ( disposeMethods ) ;
}
}
//去除历史数据后,需调整为rpc_id
rpcApplyService . remove ( new LambdaQueryWrapper < RpcApply > ( ) . eq ( RpcApply : : getNumber , ajbh ) . eq ( RpcApply : : getType , "1" ) ) ;
rpcApply . setCaseCategory ( ajjbxx . getAjlbmc ( ) ) ;
boolean saveSuccess = rpcApplyService . saveOrUpdate ( rpcApply ) ;
if ( ! saveSuccess | | ObjectUtils . isEmpty ( rpcApply . getRpcId ( ) ) ) {
log . info ( "案件[" + ajbh + "]RPC申请保存失败或未生成RPC ID" ) ;
continue ;
}
//嫌疑人
if ( CollectionUtil . isNotEmpty ( wfrwfxxes ) ) {
for ( DwdAsjZfbaWfrwfxx suspect : wfrwfxxes ) {
try {
if ( StrUtil . isNotEmpty ( suspect . getZjhm ( ) ) ) {
//去除历史数据后,需删除
rpcInfringerResultService . remove ( new LambdaQueryWrapper < RpcInfringerResult > ( ) . eq ( RpcInfringerResult : : getIdCode , suspect . getZjhm ( ) ) ) ;
}
RpcInfringerResult result = new RpcInfringerResult ( ) ;
result . setId ( IdUtil . fastSimpleUUID ( ) ) ;
result . setRpcId ( rpcApply . getRpcId ( ) ) ;
result . setTortName ( suspect . getXm ( ) ) ;
result . setDefendHandleWayName ( suspect . getClfs ( ) ) ;
result . setIdCode ( suspect . getZjhm ( ) ) ;
if ( StrUtil . isNotBlank ( suspect . getXbmc ( ) ) ) {
String gender = suspect . getXbmc ( ) . split ( "性" ) [ 0 ] ;
result . setGender ( gender ) ;
}
rpcInfringerResultService . saveOrUpdate ( result ) ;
} catch ( Exception e ) {
log . info ( "处理嫌疑人[" + suspect . getXm ( ) + "]信息时发生异常:" + e . getMessage ( ) ) ;
}
}
}
for ( TXsshrxxb victim : tXsshrxxbList ) {
try {
RpcApplyPerson person = new RpcApplyPerson ( ) ;
person . setRpcId ( rpcApply . getRpcId ( ) ) ;
person . setType ( RpcApplyTypeEnum . RIGHTS_PROTECTION . getValue ( ) ) ;
person . setEmpNo ( victim . getEmpNo ( ) ) ;
person . setEmpName ( victim . getXm ( ) ) ;
if ( StrUtil . isNotEmpty ( victim . getXbmc ( ) ) ) {
person . setGender ( victim . getXbmc ( ) . split ( "性" ) [ 0 ] ) ;
}
rpcApplyPersonService . saveOrUpdate ( person ) ;
} catch ( Exception e ) {
log . info ( "处理受害人[" + victim . getXm ( ) + "]信息时发生异常:" + e . getMessage ( ) ) ;
}
}
log . info ( "案件[" + ajbh + "]维权信息处理完成" ) ;
} catch ( Exception e ) {
log . info ( "处理案件[" + ajbh + "]时发生异常:" + e . getMessage ( ) ) ;
}
}
}
private final ZhkshDutyScheduleDcMapper zhkshDutyScheduleDcMapper ;
private final ZhkshDutyScheduleDcMapper zhkshDutyScheduleDcMapper ;
private final SupRotaMapper supRotaMapper ;
private final SupRotaMapper supRotaMapper ;