diff --git a/src/weaver/interfaces/mzg/cronjob/RecruitReportJob.java b/src/weaver/interfaces/mzg/cronjob/RecruitReportJob.java new file mode 100644 index 0000000..9483449 --- /dev/null +++ b/src/weaver/interfaces/mzg/cronjob/RecruitReportJob.java @@ -0,0 +1,301 @@ +package weaver.interfaces.mzg.cronjob; + +import cn.hutool.core.convert.Convert; +import com.engine.mzg.conn.RecruitCommon; +import com.engine.mzg.conn.RecruitRecordSet; +import com.engine.mzg.exception.CustomizeRunTimeException; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.formmode.IgnoreCaseHashMap; +import weaver.general.Util; +import weaver.hrm.company.DepartmentComInfo; +import weaver.interfaces.schedule.BaseCronJob; + +import java.util.UUID; + +/** + * 招聘报表计划任务 + * + * @author:dxfeng + * @createTime: 2024/10/14 + * @version: 1.0 + */ +public class RecruitReportJob extends BaseCronJob { + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + /** + * 面试流程表名 + */ + String flowTableInterview; + /** + * 面试流程ID + */ + String interviewFlowId; + + @Override + public void execute() { + // 查询招聘需求建模表 + RecordSet rs = new RecordSet(); + try { + rs.writeLog("RecruitReportJob开始执行"); + flowTableInterview = RecruitCommon.getSettingValue("FLOW_TABLE_INTERVIEW"); + interviewFlowId = getWorkflowId(); + if (StringUtils.isBlank(flowTableInterview) || StringUtils.isBlank(interviewFlowId)) { + throw new CustomizeRunTimeException("FLOW_TABLE_INTERVIEW或INTERVIEW_FLOW_ID为空,flowTableInterview=" + flowTableInterview + ",INTERVIEW_FLOW_ID=" + interviewFlowId); + } + // TODO 是否做时间或其他条件限制 + rs.executeQuery("select * from uf_recruit_zpxqglb"); + // 遍历所有岗位岗位 + while (rs.next()) { + IgnoreCaseHashMap dataMap = combinationData(rs); + updateData(dataMap); + } + rs.writeLog("RecruitReportJob执行结束"); + + } catch (Exception e) { + rs.writeLog("RecruitReportJob执行异常", e); + } + + } + + /** + * 组装数据 + * + * @param rs + */ + private IgnoreCaseHashMap combinationData(RecordSet rs) { + // 中心 + String zx = ""; + String sqbm = rs.getString("sqbm"); + if (StringUtils.isNotBlank(sqbm)) { + zx = departmentComInfo.getSubcompanyid1(sqbm); + } + // 招聘岗位名称 + String zpgwmc = rs.getString("id"); + // 招聘数量 + String zpsl = rs.getString("sqzprs"); + // 责任人 + String zrr = rs.getString("zrr"); + // 招聘紧急程度 + String zpjjcd = rs.getString("zpjjcd"); + // 需求提出时间 + String xqtcsj = rs.getString("sqrq"); + // 预计招聘完成时间 + String yjzpwcsj = rs.getString("xydgrq"); + // 到岗时间 + String dgsj = ""; + // 简历推荐数(简历中心该岗位的份数) + int jltjs = countResumeNum(zpgwmc); + // 预约面试数 + int yymss = countInterviewNum(interviewFlowId, zpgwmc); + // 初试通过数 + int cstgs = countFirstNum(interviewFlowId, zpgwmc); + // 复试通过数 + int fstgs = countSecondNum(interviewFlowId, zpgwmc); + // 终试通过数 + int zstgs = countThirdNum(interviewFlowId, zpgwmc); + // 尽调通过数 + int jdtgs = countBackPassNum(zpgwmc); + // 候选人数 + int hxrs = countAcceptOfferNum(zpgwmc); + // 岗位类别 + String gwlb = rs.getString("gwlb"); + + + IgnoreCaseHashMap dataMap = new IgnoreCaseHashMap<>(); + dataMap.put("zx", zx); + dataMap.put("zpgwmc", zpgwmc); + dataMap.put("zpsl", zpsl); + dataMap.put("zpjjcd", zpjjcd); + dataMap.put("xqtcsj", xqtcsj); + dataMap.put("yjzpwcsj", yjzpwcsj); + dataMap.put("dgsj", dgsj); + dataMap.put("jltjs", jltjs); + dataMap.put("yymss", yymss); + dataMap.put("cstgs", cstgs); + dataMap.put("fstgs", fstgs); + dataMap.put("zstgs", zstgs); + dataMap.put("jdtgs", jdtgs); + dataMap.put("hxrs", hxrs); + dataMap.put("gwlb", gwlb); + dataMap.put("zrr", zrr); + + return dataMap; + } + + /** + * 更新数据 + * + * @param dataMap + * @return + */ + private int updateData(IgnoreCaseHashMap dataMap) { + RecordSet recordSet = new RecordSet(); + String zpgwmc = Util.null2String(dataMap.get("zpgwmc")); + // 查询台账中是否有该职位,有则更新,没有则插入 + int id = -1; + recordSet.executeQuery("select id from uf_recruit_report where zpgwmc = ?", zpgwmc); + if (recordSet.next()) { + id = recordSet.getInt("id"); + } + if (id > 0) { + dataMap.put("id", id); + // 责任人不更新 + dataMap.remove("zrr"); + RecruitRecordSet.buildModeUpdateFields(dataMap, 1); + RecruitRecordSet.updateDataById(dataMap, "uf_recruit_report"); + } else { + String uuid = UUID.randomUUID().toString(); + dataMap.put("modeuuid", uuid); + int formModeId = RecruitCommon.getModeIdByTableName("uf_recruit_report"); + dataMap.put("formmodeid", formModeId); + RecruitRecordSet.buildModeInsertFields(dataMap, 1); + RecruitRecordSet.insertData(dataMap, "uf_recruit_report"); + id = RecruitRecordSet.refreshRight(uuid, "uf_recruit_report", formModeId, 1); + } + return id; + } + + + /** + * 获取该职位的简历数量 + * + * @param sqzwId + * @return + */ + private int countResumeNum(String sqzwId) { + RecordSet recordSet = new RecordSet(); + String num = ""; + recordSet.executeQuery("select count(id) as total_count from uf_recruit_resume where sqzw = ?", sqzwId); + if (recordSet.next()) { + num = recordSet.getString("total_count"); + } + return Convert.toInt(num, 0); + + } + + /** + * 获取该职位的背调通过数量 + * + * @param sqzwId + * @return + */ + private int countBackPassNum(String sqzwId) { + RecordSet recordSet = new RecordSet(); + String num = ""; + recordSet.executeQuery("select count(a.id) as total_count from uf_recruit_bd a inner join uf_recruit_ms b on a.bbdr = b.id where a.bdjg = 0 and b.sqzw = ?", sqzwId); + if (recordSet.next()) { + num = recordSet.getString("total_count"); + } + return Convert.toInt(num, 0); + + } + + /** + * 获取该职位的接受offer的数量 + * + * @param sqzwId + * @return + */ + private int countAcceptOfferNum(String sqzwId) { + RecordSet recordSet = new RecordSet(); + String num = ""; + recordSet.executeQuery("select count(a.id) as total_count from uf_recruit_lytzs a inner join uf_recruit_ms b on a.xm = b.id where a.fkjg = 1 and b.sqzw = ?", sqzwId); + if (recordSet.next()) { + num = recordSet.getString("total_count"); + } + return Convert.toInt(num, 0); + + } + + /** + * 统计初试通过的数据 + * + * @param workflowId + * @param sqzwId + * @return + */ + private int countInterviewNum(String workflowId, String sqzwId) { + RecordSet recordSet = new RecordSet(); + String num = ""; + recordSet.executeQuery("select count(distinct a.requestid) as total_count from workflow_currentoperator a inner join workflow_nodebase b on a.nodeid = b.id inner join " + flowTableInterview + " c on a.requestid = c.requestid inner join uf_recruit_ms d on c.requestId = d.mslcid where a.workflowid = ? and b.nodename = ? and c.sqzw =?", workflowId, "第一轮面试", sqzwId); + if (recordSet.next()) { + num = recordSet.getString("total_count"); + } + return Convert.toInt(num, 0); + } + + + /** + * 统计初试通过的数据 + * + * @param workflowId + * @param sqzwId + * @return + */ + private int countFirstNum(String workflowId, String sqzwId) { + RecordSet recordSet = new RecordSet(); + String num = ""; + recordSet.executeQuery("select count(distinct a.requestid) as total_count from workflow_currentoperator a inner join workflow_nodebase b on a.nodeid = b.id inner join " + flowTableInterview + " c on a.requestid = c.requestid inner join uf_recruit_ms d on c.requestId = d.mslcid where a.workflowid = ? and b.nodename = ? and c.sqzw =?", workflowId, "hr面试安排1", sqzwId); + if (recordSet.next()) { + num = recordSet.getString("total_count"); + } + return Convert.toInt(num, 0); + } + + /** + * 统计复试通过的数据 + * + * @param workflowId + * @param sqzwId + * @return + */ + private int countSecondNum(String workflowId, String sqzwId) { + RecordSet recordSet = new RecordSet(); + String num = ""; + recordSet.executeQuery("select count(distinct a.requestid) as total_count from workflow_currentoperator a inner join workflow_nodebase b on a.nodeid = b.id inner join " + flowTableInterview + " c on a.requestid = c.requestid inner join uf_recruit_ms d on c.requestId = d.mslcid where a.workflowid = ? and b.nodename = ? and c.sqzw =?", workflowId, "hr面试安排2", sqzwId); + if (recordSet.next()) { + num = recordSet.getString("total_count"); + } + // 统计两轮面试的数据 + recordSet.executeQuery("select count(*) as total_count from workflow_currentoperator a inner join workflow_nodebase b on a.nodeid = b.id inner join " + flowTableInterview + " c on a.requestid = c.requestid and c.mslc =0 inner join uf_recruit_ms d on c.requestId = d.mslcid where a.workflowid = ? and b.nodename = ? and c.sqzw =?", workflowId, "hr面试安排3", sqzwId); + if (recordSet.next()) { + num += Convert.toInt(recordSet.getString("total_count"), 0); + } + + return Convert.toInt(num, 0); + } + + /** + * 统计终试通过的数据 + * + * @param workflowId + * @param sqzwId + * @return + */ + private int countThirdNum(String workflowId, String sqzwId) { + RecordSet recordSet = new RecordSet(); + String num = ""; + recordSet.executeQuery("select count(distinct a.requestid) as total_count from workflow_currentoperator a inner join workflow_nodebase b on a.nodeid = b.id inner join " + flowTableInterview + " c on a.requestid = c.requestid and c.mslc =1 inner join uf_recruit_ms d on c.requestId = d.mslcid where a.workflowid = ? and b.nodename = ? and c.sqzw =?", workflowId, "hr面试安排3", sqzwId); + if (recordSet.next()) { + num = recordSet.getString("total_count"); + } + return Convert.toInt(num, 0); + } + + + /** + * 获取面试流程ID + * + * @return + */ + private String getWorkflowId() { + RecordSet recordSet = new RecordSet(); + String workflowId = ""; + recordSet.executeQuery("SELECT a.id AS workflowid FROM workflow_base a WHERE a.formid = (SELECT id FROM workflow_bill WHERE tablename = ?)", flowTableInterview); + if (recordSet.next()) { + workflowId = recordSet.getString("workflowid"); + } + return workflowId; + } + +}