package weaver.formmode.recruit.modeexpand.interview; import com.engine.recruit.util.RecruitMessageUtils; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import weaver.common.DateUtil; import weaver.conn.RecordSet; import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; import weaver.formmode.recruit.modeexpand.util.RecruitModeUtil; import weaver.formmode.setup.ModeRightInfo; import weaver.general.BaseBean; import weaver.general.Util; import weaver.hrm.User; import weaver.soa.workflow.request.*; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** *

聚才林招聘

* 批量面试推送面试评价 * * @author:dxfeng * @createTime: 2023/09/22 * @version: 1.0 */ public class BatchAddInterviewResultModeExpand extends AbstractModeExpandJavaCodeNew { private static final String MODE_TABLE_NAME = "uf_jcl_ms"; /** * 消息来源ID */ private final String messageType; /** * 消息提醒标题 */ private final String title; public BatchAddInterviewResultModeExpand() { super(); messageType = RecruitModeUtil.getRecruitPropValue("INTERVIEW_MESSAGE_TYPE"); title = RecruitModeUtil.getRecruitPropValue("INTERVIEW_ADD_MESSAGE_TITLE"); } @Override public Map doModeExpand(Map param) { Map result = new HashMap<>(); try { RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo"); if (requestInfo != null) { int formModeId = -1; int formId = -1; RecordSet rs = new RecordSet(); rs.executeQuery("select id from workflow_bill where tablename = ?", MODE_TABLE_NAME); if (rs.next()) { formId = rs.getInt("id"); } rs.executeQuery("select id from modeinfo where formid =?", formId); if (rs.next()) { formModeId = rs.getInt("id"); } MainTableInfo mainTableInfo = requestInfo.getMainTableInfo(); Property[] properties = mainTableInfo.getProperty(); Map mainDataMap = new HashMap<>(); for (Property property : properties) { mainDataMap.put(property.getName(), RecruitModeUtil.parseBlankToNull(property.getValue())); } User user = (User) param.get("user"); // 填充建模数据基本信息 mainDataMap.put("formmodeid", formModeId); mainDataMap.put("modedatacreater", user.getUID()); String dateTime = DateUtil.getFullDate(); String[] split = dateTime.split(" "); mainDataMap.put("modedatacreatedate", split[0]); mainDataMap.put("modedatacreatetime", split[1]); mainDataMap.put("modedatamodifier", null); mainDataMap.put("modedatamodifydatetime", null); mainDataMap.put("modedatacreatertype", "0"); //mainDataMap.put("bsapid", requestInfo.getRequestid()); List> detailMapList = new ArrayList<>(); DetailTableInfo detailTableInfo = requestInfo.getDetailTableInfo(); DetailTable detailTable = detailTableInfo.getDetailTable(0); Row[] rows = detailTable.getRow(); for (Row row : rows) { Map detailDataMap = new HashMap<>(mainDataMap); Cell[] cells = row.getCell(); for (Cell cell : cells) { detailDataMap.put(cell.getName(), RecruitModeUtil.parseBlankToNull(cell.getValue())); } detailMapList.add(detailDataMap); } String insertSql = "insert into " + MODE_TABLE_NAME + " (modeuuid, modedatacreatertype, formmodeid, modedatacreater, modedatacreatedate, modedatacreatetime, modedatamodifier, modedatamodifydatetime, pcid, ypz, ypzw, tdsj, sjhm, dzyx, tzypz, msfs, mshj, msc, msg, ptmsg, ptmsgsfcymspj, msrq, zt) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; StringBuilder msgBuilder = new StringBuilder(); for (Map detailDataMap : detailMapList) { List paramList = buildParamList(detailDataMap); if (CollectionUtils.isNotEmpty(paramList)) { String uuid = UUID.randomUUID().toString(); paramList.add(0, uuid); rs.executeUpdate(insertSql, paramList); rs.executeQuery("select id from " + MODE_TABLE_NAME + " where modeuuid='" + uuid + "'"); if (rs.next()) { // 权限重构 int bid = Util.getIntValue(rs.getString("id")); ModeRightInfo modeRightInfo = new ModeRightInfo(); modeRightInfo.setNewRight(true); modeRightInfo.editModeDataShare(user.getUID(), formModeId, bid); getApplicantsInfo(msgBuilder, Util.null2String(detailDataMap.get("ypz")), Util.null2String(detailDataMap.get("ypzw"))); } } } if (StringUtils.isNotBlank(msgBuilder)) { msgBuilder.insert(0, RecruitModeUtil.getResourceNames(requestInfo.getCreatorid()) + "安排了一场面试
"); String msrq = Util.null2String(mainDataMap.get("msrq")); String msg = Util.null2String(mainDataMap.get("msg")); String ptmsg = Util.null2String(mainDataMap.get("ptmsg")); String msdd = Util.null2String(mainDataMap.get("msdd")); msgBuilder.append("面试时间:").append(msrq).append(";面试官:").append(RecruitModeUtil.getResourceNames(msg)).append(",").append(RecruitModeUtil.getResourceNames(ptmsg)).append("
"); msgBuilder.append("面试地址:").append(msdd); // 消息发送 Set userIdSet = new HashSet<>(); userIdSet.addAll(Arrays.asList(msg.split(","))); userIdSet.addAll(Arrays.asList(ptmsg.split(","))); RecruitModeUtil.messagePush(messageType, title, msgBuilder.toString(), userIdSet, user.getUID()); // 面试邮件、短信发送 int billId = Util.getIntValue(requestInfo.getRequestid()); sendMessage(billId); } } } catch (Exception e) { new BaseBean().writeLog(e); result.put("errmsg", "自定义出错信息"); result.put("flag", "false"); } return result; } /** * 构建批量插入数据集合 * * @param map 表单参数 */ private List buildParamList(Map map) { List param = new ArrayList<>(); // 填充建模表相关字段 param.add(map.get("modedatacreatertype")); param.add(map.get("formmodeid")); param.add(map.get("modedatacreater")); param.add(map.get("modedatacreatedate")); param.add(map.get("modedatacreatetime")); param.add(map.get("modedatamodifier")); param.add(map.get("modedatamodifydatetime")); // 表单字段 // 批次ID param.add(map.get("pcid")); // 应聘者 param.add(map.get("ypz")); // 投递职位 param.add(map.get("ypzw")); // 投递时间 param.add(map.get("tdsj")); // 手机号码 param.add(map.get("sjhm")); // 电子邮箱 param.add(map.get("dzyx")); // 通知应聘者 param.add(map.get("tzypz")); // 面试方式 param.add(map.get("msfs")); // 面试环节 param.add(map.get("mshj")); // 面试轮次 param.add(map.get("msc")); // 面试官 param.add(map.get("msg")); // 陪同面试官 param.add(map.get("ptmsg")); // 陪同面试官是否参与面试评价 param.add(map.get("ptmsgsfcymspj")); // 面试日期 param.add(map.get("msrq")); // 面试状态,默认值:待面试 param.add("0"); return param; } /** * 获取应聘者信息 * * @param msgBuilder 消息内容 * @param applicantId 应聘者ID * @param positionId 应聘职位ID */ private void getApplicantsInfo(StringBuilder msgBuilder, String applicantId, String positionId) { if (StringUtils.isAnyBlank(applicantId, positionId)) { return; } RecordSet rs = new RecordSet(); rs.executeQuery("select xm from uf_jcl_yppc where id = ?", applicantId); if (rs.next()) { msgBuilder.append("应聘者:").append(rs.getString("xm")); } rs.executeQuery("select zpzwmc from uf_jcl_zp_zpzw where id = ?", positionId); if (rs.next()) { msgBuilder.append(";应聘职位:").append(rs.getString("zpzwmc")); } msgBuilder.append("
"); } private void sendMessage(int billId) { String querySql = RecruitModeUtil.getQuerySql("uf_jcl_plapms"); RecordSet rs = new RecordSet(); rs.executeQuery(querySql,billId); String yjnr; String yjtzmb = ""; List interviewPersonList = new ArrayList<>(); while (rs.next()) { yjtzmb = Util.null2String(rs.getString("yjtzmb")); yjnr = rs.getString("yjnr"); Pattern patten = Pattern.compile("\\$(.*?)\\$");//编译正则表达式 Matcher matcher = patten.matcher(yjnr);// 指定要匹配的字符串 StringBuffer sb = new StringBuffer(); while (matcher.find()) { //此处find()每次被调用后,会偏移到下一个匹配 matcher.appendReplacement(sb,Util.null2String(rs.getString(matcher.group().replace("$","")))); } matcher.appendTail(sb); interviewPersonList.add(InterviewPerson.builder() .name(Util.null2String(rs.getString("ypz"))) .jobName(Util.null2String(rs.getString("ypzw"))) .time(Util.null2String(rs.getString("bssj"))) .phone(Util.null2String(rs.getString("sjh"))) .email(Util.null2String(rs.getString("yx"))) .address(Util.null2String(rs.getString("bsdd"))) .content(Util.null2String(sb)).build()); } for (InterviewPerson interviewPerson : interviewPersonList) { Map params = new HashMap<>(); String[] strings = yjtzmb.split(","); for (String s : strings) { switch (s) { case "0": // 邮件 params.put("sendTo", interviewPerson.getEmail()); params.put("emailTitle", RecruitModeUtil.getEmailTitle(s)); params.put("emailContent", interviewPerson.getContent()); RecruitMessageUtils.SendEmail(params); break; case "1": // 短信 params.put("receiver", interviewPerson.getPhone()); params.put("content", interviewPerson.getContent()); RecruitMessageUtils.sendSMS(params); break; default: break; } } } } @Data @Builder @NoArgsConstructor @AllArgsConstructor private static class InterviewPerson { String name; String jobName; String time; String address; String phone; String email; String content; } }