2023-10-27 15:18:54 +08:00
package com.engine.recruit.conn ;
2023-10-27 09:27:47 +08:00
import com.engine.recruit.enums.ApplicationStatusEnum ;
import org.apache.commons.collections.CollectionUtils ;
import weaver.conn.RecordSet ;
import weaver.general.Util ;
import java.util.List ;
import java.util.Map ;
import java.util.UUID ;
/ * *
* @author : dxfeng
* @createTime : 2023 / 10 / 26
* @version : 1 . 0
* /
public class CheckRepeatResume {
/ * *
* 校验简历是否加入黑名单
*
* @param name 姓名
* @param mobile 手机号
* @return
* /
2023-11-13 15:21:35 +08:00
public static boolean joinBlackList ( String name , String mobile ) {
2023-10-27 09:27:47 +08:00
// 在这里编写你的方法逻辑
RecordSet rs = new RecordSet ( ) ;
rs . executeQuery ( " select id from uf_jcl_rck where sfjrhmd =0 and xm = ? and sjhm = ? " , name , mobile ) ;
return rs . next ( ) ;
}
2023-11-13 15:21:35 +08:00
public static List < Map < String , Object > > getRepeatPositionResumeList ( String name , String mobile , String positionId ) {
RecordSet rs = new RecordSet ( ) ;
// 查询状态为待分配、候选中的且未隐藏的数据
rs . executeQuery ( " select * from uf_jcl_yppc where formmodeid is not null and zt != 2 and zt != 3 and xm = ? and sjhm = ? and ypzw = ? order by zt " , name , mobile , positionId ) ;
return RecruitRecordSet . getRecordMapList ( rs ) ;
}
2023-10-27 09:27:47 +08:00
/ * *
* 根据姓名 、 手机号查询重复的简历数据
*
* @param name 姓名
* @param mobile 手机号
* @return
* /
private List < Map < String , Object > > getRepeatResumeList ( String name , String mobile ) {
RecordSet rs = new RecordSet ( ) ;
// 查询状态为待分配、候选中的且未隐藏的数据
rs . executeQuery ( " select * from uf_jcl_yppc where formmodeid is not null and zt != 2 and zt != 3 and xm = ? and sjhm =? order by zt " , name , mobile ) ;
return RecruitRecordSet . getRecordMapList ( rs ) ;
}
/ * *
* 插入简历数据
*
* @param param 数据集合
* @return
* /
public synchronized int insertResumeMainTable ( Map < String , Object > param ) {
String name = Util . null2String ( param . get ( " xm " ) ) ;
String mobile = Util . null2String ( param . get ( " sjhm " ) ) ;
String status = Util . null2String ( param . get ( " zt " ) ) ;
String positionId = Util . null2String ( param . get ( " ypzw " ) ) ;
// 黑名单校验,黑名单人员不入库
boolean joinBlackList = joinBlackList ( name , mobile ) ;
if ( joinBlackList ) {
return - 1 ;
}
// 按照姓名+手机号查询正常展示的简历数据
List < Map < String , Object > > repeatResumeList = getRepeatResumeList ( name , mobile ) ;
if ( CollectionUtils . isEmpty ( repeatResumeList ) ) {
// 不存在重复数据,直接插入数据库
return insertData ( param ) ;
}
// 新接收的简历为待分配
if ( ApplicationStatusEnum . DISTRIBUTION . getValue ( ) . equals ( status ) ) {
Map < String , Object > sourceResume = repeatResumeList . get ( 0 ) ;
if ( ApplicationStatusEnum . DISTRIBUTION . getValue ( ) . equals ( Util . null2String ( sourceResume . get ( " zt " ) ) ) ) {
// 当前存在待分配的简历
//取新简历有值的字段,更新已入库简历没有值的字段,已入库简历有值的字段不做更新,新简历入库并隐藏
updateSourceResume ( param , sourceResume ) ;
return - 1 ;
} else {
// 直接入库,不做任何处理
return insertData ( param ) ;
}
} else if ( ApplicationStatusEnum . CANDIDATE . getValue ( ) . equals ( status ) ) {
// 新简历为候选中
boolean hasSamePosition = false ;
for ( Map < String , Object > sourceResume : repeatResumeList ) {
if ( positionId . equals ( Util . null2String ( sourceResume . get ( " ypzw " ) ) ) ) {
hasSamePosition = true ;
}
}
if ( hasSamePosition ) {
// 若有相同职位的数据,新简历直接入库并隐藏
return insertHideData ( param ) ;
} else {
// 没有相同职位的数据,新简历直接入库,不做任何处理
return insertData ( param ) ;
}
}
return - 1 ;
}
/ * *
* 直接插入简历信息
*
* @param dataMap 数据集合
* @return
* /
private int insertData ( Map < String , Object > dataMap ) {
String uuid = UUID . randomUUID ( ) . toString ( ) ;
dataMap . put ( " modeuuid " , uuid ) ;
RecordSet rs = new RecordSet ( ) ;
int formModeId = - 1 ;
rs . executeQuery ( " select id from modeinfo where formid =( select id from workflow_bill where tablename = 'uf_jcl_yppc' ) " ) ;
if ( rs . next ( ) ) {
formModeId = rs . getInt ( " id " ) ;
}
dataMap . put ( " formmodeid " , formModeId ) ;
2023-11-02 14:26:03 +08:00
RecruitRecordSet . buildModeInsertFields ( dataMap , 1 ) ;
RecruitRecordSet . insertData ( dataMap , " uf_jcl_yppc " ) ;
2023-10-31 14:34:05 +08:00
return RecruitRecordSet . refreshRight ( uuid , " uf_jcl_yppc " , formModeId , 1 ) ;
2023-10-27 09:27:47 +08:00
}
/ * *
* 插入数据库并隐藏
*
* @param dataMap 数据集合
* @return
* /
private int insertHideData ( Map < String , Object > dataMap ) {
String uuid = UUID . randomUUID ( ) . toString ( ) ;
dataMap . put ( " modeuuid " , uuid ) ;
RecordSet rs = new RecordSet ( ) ;
2023-11-02 14:26:03 +08:00
RecruitRecordSet . buildModeInsertFields ( dataMap , 1 ) ;
RecruitRecordSet . insertData ( dataMap , " uf_jcl_yppc " ) ;
2023-10-27 09:27:47 +08:00
rs . executeQuery ( " select id from uf_jcl_yppc where modeuuid=' " + uuid + " ' " ) ;
if ( rs . next ( ) ) {
return Util . getIntValue ( rs . getString ( " id " ) ) ;
}
return - 1 ;
}
/ * *
* 更新简历信息
*
* @param param 新简历数据集合
* @param sourceResume 源简历数据集合
* @return
* /
private int updateSourceResume ( Map < String , Object > param , Map < String , Object > sourceResume ) {
replaceNullValues ( param , sourceResume ) ;
// 处理操作人员、操作时间
2023-11-02 14:26:03 +08:00
RecruitRecordSet . buildModeUpdateFields ( sourceResume , 1 ) ;
2023-10-27 09:27:47 +08:00
RecruitRecordSet . updateDataById ( sourceResume , " uf_jcl_yppc " ) ;
// 更新数据
2023-11-02 14:26:03 +08:00
RecruitRecordSet . buildModeInsertFields ( param , 1 ) ;
2023-10-27 09:27:47 +08:00
return insertHideData ( param ) ;
}
/ * *
* 替换sourceResume中为null或者为空的值
*
* @param param 新简历数据集合
* @param sourceResume 源简历数据集合
* /
private void replaceNullValues ( Map < String , Object > param , Map < String , Object > sourceResume ) {
for ( Map . Entry < String , Object > entry : sourceResume . entrySet ( ) ) {
String key = entry . getKey ( ) ;
Object value = entry . getValue ( ) ;
if ( value = = null | | " " . equals ( value ) ) {
if ( param . containsKey ( key ) ) {
sourceResume . put ( key , param . get ( key ) ) ;
}
}
}
}
}