weaver-hrm-recruit/src/com/engine/recruit/conn/CheckRepeatResume.java

352 lines
12 KiB
Java
Raw Normal View History

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;
2024-07-04 15:38:01 +08:00
import weaver.common.DateUtil;
2023-10-27 09:27:47 +08:00
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
2023-10-27 09:27:47 +08:00
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 detailDataList
* @param tableName
* @param mainId
* @param sourceId
*/
2024-05-13 10:49:25 +08:00
public synchronized void insertResumeDetailTable(List<RecruitDataMap<Object>> detailDataList, String tableName, String mainId, String sourceId) {
if (CollectionUtils.isEmpty(detailDataList)) {
return;
}
boolean isUpdate = false;
if (StringUtils.isNotBlank(sourceId)) {
RecordSet rs = new RecordSet();
rs.executeQuery("select * from " + tableName + " where mainid = ? ", sourceId);
isUpdate = rs.getCounts() == 0;
}
try {
for (RecruitDataMap<Object> dataMap : detailDataList) {
// 明细表关联新数据
dataMap.put("mainid", mainId);
RecruitRecordSet.insertData(dataMap, tableName);
// 明细表关联已有数据
if (isUpdate) {
dataMap.put("mainid", sourceId);
RecruitRecordSet.insertData(dataMap, tableName);
}
}
} catch (Exception e) {
new BaseBean().writeLog(tableName + "明细表数据插入失败", e);
}
}
2023-11-16 17:02:34 +08:00
/**
* 插入简历数据
*
* @param param 数据集合
* @return 简历插入信息
*/
2024-05-13 10:49:25 +08:00
public synchronized Map<String, Object> insertResumeAndReturn(Map<String, Object> param) {
2023-11-16 17:02:34 +08:00
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);
2024-02-01 13:31:14 +08:00
int formModeId = ApplicantCommonInfo.getModeIdByTableName("uf_jcl_yppc");
2023-10-27 09:27:47 +08:00
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);
2024-07-04 15:38:01 +08:00
// 更新投递时间为最新的 by zsy 20240704 待分配的投递时间要根据最新的去更新
sourceResume.put("tdsj", DateUtil.getDateTime());
2023-10-27 09:27:47 +08:00
// 处理操作人员、操作时间
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));
}
}
}
}
/**
* 获取开始时间和结束时间
*
* @param date
* @return
*/
public static RecruitDataMap<Object> getDateRange(String date, boolean isStudy) {
2024-05-13 10:50:23 +08:00
RecruitDataMap<Object> dataRangeMap = new RecruitDataMap();
if (StringUtils.isBlank(date)) {
return dataRangeMap;
2024-05-13 10:50:23 +08:00
} else {
String[] split = date.split("-");
String end;
if (split.length > 0) {
end = getFormatDate(split[0]);
if (end.length() == 4) {
if (isStudy) {
end = end + "-09-01";
} else {
end = "";
}
}
2024-05-13 10:50:23 +08:00
dataRangeMap.put("kssj", end);
}
2024-05-13 10:50:23 +08:00
if (split.length > 1) {
end = getFormatDate(split[1]);
if (end.length() == 4) {
if (isStudy) {
end = end + "-07-01";
} else {
end = "";
}
}
2024-05-13 10:50:23 +08:00
dataRangeMap.put("jssj", end);
}
2024-05-13 10:50:23 +08:00
return dataRangeMap;
}
}
/**
* 获取yyyy-MM-dd时间格式日期
*
* @param dateStr
* @return
*/
private static String getFormatDate(String dateStr) {
//
dateStr = dateStr.replace(".", "-").replace("\\/", "-");
if (dateStr.length() == 7) {
return dateStr + "-01";
} else if (dateStr.length() == 10) {
return dateStr;
} else if (dateStr.length() == 4) {
return dateStr;
}
return "";
}
2023-10-27 09:27:47 +08:00
}