generated from dxfeng/secondev-chapanda-feishu
180 lines
6.1 KiB
Java
180 lines
6.1 KiB
Java
package com.engine.recruit.conn;
|
|
|
|
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
|
|
*/
|
|
private boolean joinBlackList(String name, String mobile) {
|
|
// 在这里编写你的方法逻辑
|
|
RecordSet rs = new RecordSet();
|
|
rs.executeQuery("select id from uf_jcl_rck where sfjrhmd =0 and xm = ? and sjhm = ?", name, mobile);
|
|
return rs.next();
|
|
}
|
|
|
|
/**
|
|
* 根据姓名、手机号查询重复的简历数据
|
|
*
|
|
* @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);
|
|
RecruitRecordSet.buildModeBaseFields(dataMap, 1);
|
|
return RecruitRecordSet.refreshRight(uuid, "uf_jcl_yppc", formModeId);
|
|
}
|
|
|
|
/**
|
|
* 插入数据库并隐藏
|
|
*
|
|
* @param dataMap 数据集合
|
|
* @return
|
|
*/
|
|
private int insertHideData(Map<String, Object> dataMap) {
|
|
String uuid = UUID.randomUUID().toString();
|
|
dataMap.put("modeuuid", uuid);
|
|
RecordSet rs = new RecordSet();
|
|
RecruitRecordSet.buildModeBaseFields(dataMap, 1);
|
|
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);
|
|
// 处理操作人员、操作时间
|
|
RecruitRecordSet.buildModeBaseFields(sourceResume, 1);
|
|
RecruitRecordSet.updateDataById(sourceResume, "uf_jcl_yppc");
|
|
// 更新数据
|
|
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));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|