diff --git a/src/com/engine/recruit/enums/PositionThirdChannelEnum.java b/src/com/engine/recruit/enums/PositionThirdChannelEnum.java new file mode 100644 index 0000000..443f235 --- /dev/null +++ b/src/com/engine/recruit/enums/PositionThirdChannelEnum.java @@ -0,0 +1,42 @@ +package com.engine.recruit.enums; + +/** + * 发布渠道枚举类 + * + * @author:dxfeng + * @createTime: 2023/10/08 + * @version: 1.0 + */ +public enum PositionThirdChannelEnum { + /** + * 发布渠道 + */ + BOSS("0"), + ZHI_LIAN("1"), + D51_JOB("2"), + LA_GOU("3"), + LIE_PIN("4"); + + PositionThirdChannelEnum(String value) { + this.value = value; + } + + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public static PositionThirdChannelEnum getEnum(String value) { + for (PositionThirdChannelEnum item : PositionThirdChannelEnum.values()) { + if (item.value.equalsIgnoreCase(value)) { + return item; + } + } + throw new RuntimeException("不支持的发布渠道"); + } +} diff --git a/src/weaver/formmode/recruit/modeexpand/position/ClosePositionModeExpand.java b/src/weaver/formmode/recruit/modeexpand/position/ClosePositionModeExpand.java new file mode 100644 index 0000000..64660ad --- /dev/null +++ b/src/weaver/formmode/recruit/modeexpand/position/ClosePositionModeExpand.java @@ -0,0 +1,56 @@ +package weaver.formmode.recruit.modeexpand.position; + +import com.weaver.rpa.sdk.clients.application.resume.ERPAResumeSDKClient; +import com.weaver.rpa.sdk.clients.core.ERPASDKClients; +import weaver.conn.RecordSet; +import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2023/10/07 + * @version: 1.0 + */ +public class ClosePositionModeExpand extends AbstractModeExpandJavaCodeNew { + + @Override + public Map doModeExpand(Map param) { + String tableName = "uf_jcl_zp_zpzw"; + + Map result = new HashMap<>(16); + try { + User user = (User) param.get("user"); + int billId; + int modeId; + RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo"); + if (requestInfo != null) { + billId = Util.getIntValue(requestInfo.getRequestid()); + modeId = Util.getIntValue(requestInfo.getWorkflowid()); + if (billId > 0 && modeId > 0) { + RecordSet rs = new RecordSet(); + rs.executeQuery("select qllgwid from " + tableName + " where id = ?", billId); + if (rs.next()) { + long jobId = Long.parseLong(rs.getString("qllgwid")); + ERPAResumeSDKClient client = ERPASDKClients.getResumeSDKClient(); + client.start(); + String userId = String.valueOf(user.getUID()); + client.closeResumeJob(userId, jobId); + rs.executeUpdate("update " + tableName + " set qdfbzt = ? where id = ?", jobId, 5, billId); + } + } + } + } catch (Exception e) { + new BaseBean().writeLog(e); + result.put("errmsg", e.getMessage()); + result.put("flag", "false"); + } + return result; + } + +} diff --git a/src/weaver/formmode/recruit/modeexpand/position/ReleasePositionModeExpand.java b/src/weaver/formmode/recruit/modeexpand/position/ReleasePositionModeExpand.java new file mode 100644 index 0000000..d370b42 --- /dev/null +++ b/src/weaver/formmode/recruit/modeexpand/position/ReleasePositionModeExpand.java @@ -0,0 +1,90 @@ +package weaver.formmode.recruit.modeexpand.position; + +import com.weaver.rpa.sdk.clients.application.resume.ERPAResumeSDKClient; +import com.weaver.rpa.sdk.clients.application.resume.entity.ResumeJobDto; +import com.weaver.rpa.sdk.clients.core.ERPASDKClients; +import weaver.conn.RecordSet; +import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; +import weaver.formmode.recruit.modeexpand.util.RecruitPositionUtil; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.soa.workflow.request.MainTableInfo; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2023/10/07 + * @version: 1.0 + */ +public class ReleasePositionModeExpand extends AbstractModeExpandJavaCodeNew { + + @Override + public Map doModeExpand(Map param) { + String tableName = "uf_jcl_zp_zpzw"; + + Map result = new HashMap<>(16); + try { + User user = (User) param.get("user"); + int billId; + int modeId; + RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo"); + if (requestInfo != null) { + billId = Util.getIntValue(requestInfo.getRequestid()); + modeId = Util.getIntValue(requestInfo.getWorkflowid()); + if (billId > 0 && modeId > 0) { + long jobId = -1; + RecordSet rs = new RecordSet(); + rs.executeQuery("select qllgwid from " + tableName + " where id = ?", billId); + if (rs.next()) { + jobId = Long.parseLong(rs.getString("qllgwid")); + } + ERPAResumeSDKClient client = ERPASDKClients.getResumeSDKClient(); + Map map = new HashMap<>(16); + MainTableInfo mainTableInfo = requestInfo.getMainTableInfo(); + Property[] properties = mainTableInfo.getProperty(); + for (Property property : properties) { + map.put(property.getName(), property.getValue()); + } + ResumeJobDto resumeJobDto = RecruitPositionUtil.convertMap2ResumeJobDto(map); + // 发布千里聆职位 + if (!RecruitPositionUtil.checkAvailable(client)) { + new BaseBean().writeLog("千里聆未开通简历应用。"); + result.put("errmsg", "千里聆未开通简历应用。"); + result.put("flag", "false"); + } + String userId = String.valueOf(user.getUID()); + // TODO 测试数据 userId = "26"; + // 未创建职位,则先创建职位 + if (jobId == -1) { + // 创建千里聆职位 + jobId = client.addResumeJob(userId, resumeJobDto); + // 更新千里聆ID到建模表单 + rs.executeUpdate("update " + tableName + " set qllgwid = ? where id = ?", jobId, billId); + } + + // 发布职位 + client.setRobotAuthority(userId,userId,false); + client.start(); + List platformIds = resumeJobDto.getPlatformIds(); + for (Integer platformId : platformIds) { + client.releaseResumeJob(userId, jobId, platformId); + } + // 更新状态为已发布 + rs.executeUpdate("update " + tableName + " set qdfbzt = ? where id = ?", 2, billId); + } + } + } catch (Exception e) { + new BaseBean().writeLog(e); + result.put("errmsg", e.getMessage()); + result.put("flag", "false"); + } + return result; + } + +} \ No newline at end of file diff --git a/src/weaver/formmode/recruit/modeexpand/util/ApplicantCommonInfo.java b/src/weaver/formmode/recruit/modeexpand/util/ApplicantCommonInfo.java index daa0f41..366eaeb 100644 --- a/src/weaver/formmode/recruit/modeexpand/util/ApplicantCommonInfo.java +++ b/src/weaver/formmode/recruit/modeexpand/util/ApplicantCommonInfo.java @@ -1,7 +1,11 @@ package weaver.formmode.recruit.modeexpand.util; +import org.apache.commons.lang3.StringUtils; import weaver.conn.RecordSet; +import java.util.ArrayList; +import java.util.List; + /** * @author:dxfeng * @createTime: 2023/09/27 @@ -40,7 +44,7 @@ public class ApplicantCommonInfo { /** - * 获取取消理由 + * 获取表单下拉框展示文本 * * @param formId 表单ID * @param fieldName 字段明湖曾 @@ -56,4 +60,27 @@ public class ApplicantCommonInfo { } return cancelReason; } + + + /** + * 获取招聘通用浏览按钮展示内容 + * + * @param id 浏览按钮ID + * @return 浏览按钮展示文本 + */ + public static String getRecruitCommonBrowserValue(String id) { + if (StringUtils.isBlank(id)) { + return ""; + } + List value = new ArrayList<>(); + RecordSet rs = new RecordSet(); + String[] split = id.split(","); + for (String s : split) { + rs.executeQuery("select xxnr from uf_sjzd where id = ?", id); + if (rs.next()) { + value.add(rs.getString("xxnr")); + } + } + return StringUtils.join(value, ","); + } } diff --git a/src/weaver/formmode/recruit/modeexpand/util/RecruitPositionUtil.java b/src/weaver/formmode/recruit/modeexpand/util/RecruitPositionUtil.java new file mode 100644 index 0000000..d0ef547 --- /dev/null +++ b/src/weaver/formmode/recruit/modeexpand/util/RecruitPositionUtil.java @@ -0,0 +1,191 @@ +package weaver.formmode.recruit.modeexpand.util; + +import cn.hutool.core.convert.Convert; +import com.alibaba.fastjson.JSON; +import com.engine.recruit.enums.PositionThirdChannelEnum; +import com.weaver.rpa.sdk.clients.application.resume.ERPAResumeSDKClient; +import com.weaver.rpa.sdk.clients.application.resume.common.ResumePlatform; +import com.weaver.rpa.sdk.clients.application.resume.entity.ResumeJobDto; +import com.weaver.rpa.sdk.utils.HttpClientUtils; +import weaver.general.BaseBean; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 招聘职位工具类 + * + * @author:dxfeng + * @createTime: 2023/10/08 + * @version: 1.0 + */ +public class RecruitPositionUtil { + + /** + * 将Map转换成ResumeJobDto对象 + * + * @param map 数据集合 + * @return ResumeJobDto对象 + */ + public static ResumeJobDto convertMap2ResumeJobDto(Map map) { + String positionName = Convert.toStr(map.get("zpzwmc"));//职位名称 + String positionDuty = Convert.toStr(map.get("gwzz"));//职位职责 + String finishTime = Convert.toStr(map.get("zpjzrq"));//完成时间 + String education = ApplicantCommonInfo.getRecruitCommonBrowserValue(Convert.toStr(map.get("zdxlyq")));//学历要求 + String workYears = ApplicantCommonInfo.getRecruitCommonBrowserValue(Convert.toStr(map.get("gznx")));//工作年限 + String positionNature = ApplicantCommonInfo.getRecruitCommonBrowserValue(Convert.toStr(map.get("zwxz")));//职位性质 + Integer salaryMin = Convert.toInt(map.get("zdxzk"), 0);//最低薪酬 + Integer salaryMax = Convert.toInt(map.get("zgxzk"), 0);// 最高薪酬 + Integer xcyfs = Convert.toInt(map.get("xzyfs"), 12);// 薪酬月份数 + Integer workingDays = Convert.toInt(map.get("sxmzdgts"), 1);// 实习每周到岗天数 + Integer internshipDuration = Convert.toInt(map.get("sxscy"), 1);// 实习时长(月) + String jobCategory = "不限";//职位类别 + + int experienceValue = -1;//不限 + if ("应届毕业生".equals(workYears)) { + experienceValue = 1; + } else if ("一年以内".equals(workYears)) { + experienceValue = 1; + } else if ("1-3年".equals(workYears)) { + experienceValue = 2; + } else if ("3-5年".equals(workYears)) { + experienceValue = 3; + } else if ("5-10年".equals(workYears)) { + experienceValue = 5; + } else if ("10年以上".equals(workYears)) { + experienceValue = 6; + } + + + int educationValue = -1; //不限 + if ("博士".equals(education)) { + educationValue = 8; + } else if ("MBA/EMBA".equals(education)) { + educationValue = 7; + } else if ("硕士".equals(education)) { + educationValue = 6; + } else if ("本科".equals(education)) { + educationValue = 5; + } else if ("大专".equals(education)) { + educationValue = 4; + } else if ("中专/中技".equals(education)) { + educationValue = 3; + } else if ("高中".equals(education)) { + educationValue = 2; + } else if ("初中及以下".equals(education)) { + educationValue = 1; + } + + int resumeType = 1;// 兼职、全职 + if ("实习".equals(positionNature)) { + resumeType = 3; + } else if ("校招".equals(positionNature)) { + resumeType = 2; + } + + + // 招聘职位类型与特殊设置字段 + ResumeJobDto resumeJobDto = new ResumeJobDto(); + resumeJobDto.setResumeType(resumeType); // (必填,默认社招)招聘类型 1:社招 2:校招 3:实习 + resumeJobDto.setStopReumeTimeLong(stringTurnLong(finishTime));// (校招必填)仅校招: 招聘截止时间(时间戳) + resumeJobDto.setRequirementsTime(internshipDuration); // (实习必填,默认1个月)仅实习: 实习时长 1~12 单位:(月) + resumeJobDto.setWorkDate(workingDays); // (实习必填,默认1天)仅实习: 每周到岗天数 1~7 单位:(天) + + // 招聘职位基本描述 + resumeJobDto.setJobname(positionName); // 配置职位名称 + resumeJobDto.setJobdesc(positionDuty); // 配置职位描述 + resumeJobDto.setJobType(jobCategory); // 配置职位类别 + + // 招聘职位条件 + //resumeJobDto.setKeywordStr(Lists.newArrayList("java")); // 职位关键词 + resumeJobDto.setExperience(experienceValue); // (必填,默认不限)经验要求(实习无此字段) -1:不限 1:一年以下 2:1~3年 3:3~5年 5:5~10年 6:10年以上 + resumeJobDto.setEducation(educationValue); // (必填,默认不限)学历要求 -1:不限 1:初中及以下 2:高中 3:中专/中技 4:大专 5:本科 6:硕士 7:MBA/EMBA 8:博士 + + //薪资福利 + resumeJobDto.setExpectSalaryStart(salaryMin); // (必填)薪资范围开始 单位:(社招/校招: 千元/月 实习:元/日) + resumeJobDto.setExpectSalaryStop(salaryMax); // (必填)薪资范围截止 单位:(社招/校招: 千元/月 实习:元/日) + resumeJobDto.setExpectSalaryMonth(xcyfs); // (必填,默认12个月)薪资月份数(实习无此字段) 12~24 + + // (必填)要发布的渠道(平台)Id + List platformIds = matchPlatform(Convert.toStr(map.get("dsfqd"))); + resumeJobDto.setPlatformIds(platformIds); + + // 简历匹配度设置 + resumeJobDto.setMappingageStart(-1); // (必填,默认不限)匹配年龄age开始 -1:不限 + resumeJobDto.setMappingageStop(-1);// (必填,默认不限)匹配年龄age开始 -1:不限 + resumeJobDto.setMappingSex(-1);// (必填,默认不限)匹配性别 -1:不限 0:女 1:男 + resumeJobDto.setMappingeducationStr(Collections.singletonList(-1));// (必填,默认不限)匹配学历 -1:不限 1:初中及以下 2:高中 3:中专/中技 4:大专 5:本科 6:硕士 7:MBA/EMBA 8:博士 + resumeJobDto.setMappingexperienceStr(Collections.singletonList(-1));// (必填,默认不限)匹配经验 -1:不限 1:1年内 2:1~3年 3:3~5年 4:5~10年 5:10年以上 +// resumeJobDto.setMappingKeywordStr(Lists.newArrayList()); // 匹配关键词内容 + resumeJobDto.setMappingStatus(1); // (必填,默认任一命中)匹配模式 1:任一命中 2:全部命中 + + return resumeJobDto; + } + + /** + * 将字符串形式的时间转换为长整型时间戳 + * + * @param timeString 字符串形式的时间 + * @return 长整型时间戳 + */ + private static long stringTurnLong(String timeString) { + try { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date date = dateFormat.parse(timeString); + return date.getTime(); + } catch (ParseException e) { + //e.printStackTrace(); + new BaseBean().writeLog(e); + } + return 0; + } + + /** + * 匹配三方发布平台 + * + * @param platformIds 发布平台ids + * @return 发布平台 + */ + private static List matchPlatform(String platformIds) { + String[] split = platformIds.split(","); + List platformIdList = new ArrayList<>(); + for (String platformId : split) { + if (platformId == null) { + continue; + } + PositionThirdChannelEnum channelEnum = PositionThirdChannelEnum.getEnum(platformId); + switch (channelEnum) { + case BOSS: + platformIdList.add(ResumePlatform.BOSSZHIPIN); + break; + case LIE_PIN: + platformIdList.add(ResumePlatform.LIEPIN); + break; + case LA_GOU: + platformIdList.add(ResumePlatform.LAGO); + break; + case D51_JOB: + platformIdList.add(ResumePlatform.QIANCHENGWUYOU); + break; + case ZHI_LIAN: + platformIdList.add(ResumePlatform.ZHILIANZHAOPIN); + break; + default: + break; + } + } + return platformIdList; + } + + public static boolean checkAvailable(ERPAResumeSDKClient client) { + HttpClientUtils.setTimeout(10000);//默认10秒 + if (client == null || !client.available()) { + new BaseBean().writeLog("checkAvailable!client=" + JSON.toJSONString(client)); + return false; + } else { + return true; + } + } + +}