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 ;
2023-12-25 16:42:15 +08:00
import org.apache.commons.lang3.StringUtils ;
2023-10-27 09:27:47 +08:00
import weaver.conn.RecordSet ;
import weaver.general.Util ;
2023-11-16 17:02:34 +08:00
import java.util.HashMap ;
2023-10-27 09:27:47 +08:00
import java.util.List ;
import java.util.Map ;
import java.util.UUID ;
/ * *
* @author : dxfeng
* @createTime : 2023 / 10 / 26
* @version : 1 . 0
* /
public class CheckRepeatResume {
2023-11-16 17:02:34 +08:00
private static CheckRepeatResume instance = new CheckRepeatResume ( ) ;
private CheckRepeatResume ( ) {
// 私有化构造方法
}
public static CheckRepeatResume getInstance ( ) {
return instance ;
}
2023-10-27 09:27:47 +08:00
/ * *
* 校验简历是否加入黑名单
*
* @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-20 18:33:57 +08:00
/ * *
* @param name
* @param mobile
* @param positionId
* @return
* /
2023-11-13 15:21:35 +08:00
public static List < Map < String , Object > > getRepeatPositionResumeList ( String name , String mobile , String positionId ) {
2023-11-16 17:02:34 +08:00
return getRepeatPositionResumeList ( name , mobile , positionId , " " ) ;
}
2023-11-20 18:33:57 +08:00
/ * *
* @param name
* @param mobile
* @param positionId
* @param billId
* @return
* /
2023-11-16 17:02:34 +08:00
public static List < Map < String , Object > > getRepeatPositionResumeList ( String name , String mobile , String positionId , String billId ) {
2023-11-13 15:21:35 +08:00
RecordSet rs = new RecordSet ( ) ;
// 查询状态为待分配、候选中的且未隐藏的数据
2023-12-25 16:42:15 +08:00
String whereSql = " " ;
if ( StringUtils . isBlank ( positionId ) ) {
whereSql = " and (ypzw = ? or ypzw is null) " ;
} else {
whereSql = " and ypzw = ? " ;
}
rs . executeQuery ( " select * from uf_jcl_yppc where formmodeid is not null and zt != 2 and zt != 3 and xm = ? and sjhm = ? " + whereSql + " and id != ? order by zt " , name , mobile , positionId , billId ) ;
2023-11-13 15:21:35 +08:00
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 数据集合
2023-11-16 17:02:34 +08:00
* @return 新插入简历的ID
2023-10-27 09:27:47 +08:00
* /
2023-11-16 17:02:34 +08:00
public int insertResumeMainTable ( Map < String , Object > param ) {
Map < String , Object > map = insertResumeAndReturn ( param ) ;
return Util . getIntValue ( Util . null2String ( map . get ( " mainId " ) ) ) ;
}
/ * *
* 插入简历数据
*
* @param param 数据集合
* @return 简历插入信息
* /
public Map < String , Object > insertResumeAndReturn ( Map < String , Object > param ) {
Map < String , Object > returnMap = new HashMap < > ( ) ;
int mainId = - 1 ;
String sourceId ;
2023-10-27 09:27:47 +08:00
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 ) ;
2023-11-16 17:02:34 +08:00
returnMap . put ( " joinBlackList " , joinBlackList ) ;
returnMap . put ( " isUpdate " , false ) ;
returnMap . put ( " mainId " , mainId ) ;
2023-10-27 09:27:47 +08:00
if ( joinBlackList ) {
2023-11-16 17:02:34 +08:00
return returnMap ;
2023-10-27 09:27:47 +08:00
}
// 按照姓名+手机号查询正常展示的简历数据
List < Map < String , Object > > repeatResumeList = getRepeatResumeList ( name , mobile ) ;
if ( CollectionUtils . isEmpty ( repeatResumeList ) ) {
// 不存在重复数据,直接插入数据库
2023-11-16 17:02:34 +08:00
mainId = insertData ( param ) ;
returnMap . put ( " mainId " , mainId ) ;
return returnMap ;
2023-10-27 09:27:47 +08:00
}
// 新接收的简历为待分配
if ( ApplicationStatusEnum . DISTRIBUTION . getValue ( ) . equals ( status ) ) {
Map < String , Object > sourceResume = repeatResumeList . get ( 0 ) ;
if ( ApplicationStatusEnum . DISTRIBUTION . getValue ( ) . equals ( Util . null2String ( sourceResume . get ( " zt " ) ) ) ) {
// 当前存在待分配的简历
2023-11-16 17:02:34 +08:00
sourceId = Util . null2String ( sourceResume . get ( " id " ) ) ;
2023-10-27 09:27:47 +08:00
//取新简历有值的字段,更新已入库简历没有值的字段,已入库简历有值的字段不做更新,新简历入库并隐藏
2023-11-16 17:02:34 +08:00
mainId = updateSourceResume ( param , sourceResume ) ;
returnMap . put ( " mainId " , mainId ) ;
returnMap . put ( " sourceId " , sourceId ) ;
returnMap . put ( " isUpdate " , true ) ;
return returnMap ;
2023-10-27 09:27:47 +08:00
} else {
// 直接入库,不做任何处理
2023-11-16 17:02:34 +08:00
mainId = insertData ( param ) ;
returnMap . put ( " mainId " , mainId ) ;
return returnMap ;
2023-10-27 09:27:47 +08:00
}
} 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 ) {
// 若有相同职位的数据,新简历直接入库并隐藏
2023-11-16 17:02:34 +08:00
mainId = insertHideData ( param ) ;
returnMap . put ( " mainId " , mainId ) ;
return returnMap ;
2023-10-27 09:27:47 +08:00
} else {
// 没有相同职位的数据,新简历直接入库,不做任何处理
2023-11-16 17:02:34 +08:00
mainId = insertData ( param ) ;
returnMap . put ( " mainId " , mainId ) ;
return returnMap ;
2023-10-27 09:27:47 +08:00
}
}
2023-11-16 17:02:34 +08:00
return returnMap ;
2023-10-27 09:27:47 +08:00
}
/ * *
* 直接插入简历信息
*
* @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 ) ) ;
}
}
}
}
}