From 3603341c8afbe6579b63657ca5abeb41dfac870b Mon Sep 17 00:00:00 2001 From: dxfeng Date: Tue, 26 Sep 2023 15:21:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92-=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E5=AE=89=E6=8E=92=E3=80=81=E5=8F=96=E6=B6=88=E9=9D=A2?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WEB-INF/prop/jclRecruit.properties | 6 + .../BatchAddInterviewResultModeExpand.java | 112 ++++++++++---- .../CancelInterviewResultModeExpand.java | 137 ++++++++++++++++++ .../modeexpand/util/RecruitModeUtil.java | 70 +++++++++ 4 files changed, 293 insertions(+), 32 deletions(-) create mode 100644 WEB-INF/prop/jclRecruit.properties create mode 100644 src/weaver/formmode/recruit/modeexpand/interview/CancelInterviewResultModeExpand.java create mode 100644 src/weaver/formmode/recruit/modeexpand/util/RecruitModeUtil.java diff --git a/WEB-INF/prop/jclRecruit.properties b/WEB-INF/prop/jclRecruit.properties new file mode 100644 index 0000000..92a968d --- /dev/null +++ b/WEB-INF/prop/jclRecruit.properties @@ -0,0 +1,6 @@ +#面试相关消息提醒,消息来源 +INTERVIEW_MESSAGE_TYPE=85 +#添加面试消息提醒表弟 +INTERVIEW_ADD_MESSAGE_TITLE=面试安排提醒 +#取消面试消息提醒表弟 +INTERVIEW_CANCEL_MESSAGE_TITLE=取消面试提醒 \ No newline at end of file diff --git a/src/weaver/formmode/recruit/modeexpand/interview/BatchAddInterviewResultModeExpand.java b/src/weaver/formmode/recruit/modeexpand/interview/BatchAddInterviewResultModeExpand.java index b8efa5e..d03d27e 100644 --- a/src/weaver/formmode/recruit/modeexpand/interview/BatchAddInterviewResultModeExpand.java +++ b/src/weaver/formmode/recruit/modeexpand/interview/BatchAddInterviewResultModeExpand.java @@ -5,11 +5,13 @@ 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.soa.workflow.request.*; +import java.io.UnsupportedEncodingException; import java.util.*; /** @@ -23,6 +25,22 @@ import java.util.*; 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() throws UnsupportedEncodingException { + super(); + messageType = RecruitModeUtil.getRecruitPropValue("INTERVIEW_MESSAGE_TYPE"); + title = RecruitModeUtil.getRecruitPropValue("INTERVIEW_ADD_MESSAGE_TITLE"); + } + @Override public Map doModeExpand(Map param) { Map result = new HashMap<>(); @@ -30,8 +48,13 @@ public class BatchAddInterviewResultModeExpand extends AbstractModeExpandJavaCod RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo"); if (requestInfo != null) { int formModeId = -1; + int formId = -1; RecordSet rs = new RecordSet(); - rs.executeQuery("select id from modeinfo where formid =( select id from workflow_bill where tablename = ? )", MODE_TABLE_NAME); + 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"); } @@ -67,19 +90,40 @@ public class BatchAddInterviewResultModeExpand extends AbstractModeExpandJavaCod 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 = new ArrayList<>(); - buildParamList(detailDataMap, paramList); + List paramList = buildParamList(detailDataMap); if (CollectionUtils.isNotEmpty(paramList)) { - 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(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"; - for (List objects : paramList) { - String uuid = UUID.randomUUID().toString(); - objects.add(0, uuid); - rs.executeUpdate(insertSql, objects); - refreshRight(rs, uuid, formModeId); + 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(1, formModeId, bid); + getApplicantsInfo(msgBuilder, Util.null2String(detailDataMap.get("ypz")), Util.null2String(detailDataMap.get("tdzw"))); } } } + 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, Integer.parseInt(requestInfo.getCreatorid())); + } } } catch (Exception e) { new BaseBean().writeLog(e); @@ -93,10 +137,9 @@ public class BatchAddInterviewResultModeExpand extends AbstractModeExpandJavaCod /** * 构建批量插入数据集合 * - * @param map 表单参数 - * @param paramList 待插入数据集合 + * @param map 表单参数 */ - private void buildParamList(Map map, List> paramList) { + private List buildParamList(Map map) { List param = new ArrayList<>(); // 填充建模表相关字段 param.add(map.get("modedatacreatertype")); @@ -139,26 +182,7 @@ public class BatchAddInterviewResultModeExpand extends AbstractModeExpandJavaCod // 面试状态,默认值:待面试 param.add("0"); - paramList.add(param); - } - - /** - * 权限重构 - * - * @param rs RecordSet - * @param uuid UUID - * @param formModeId 建模ID - */ - private void refreshRight(RecordSet rs, String uuid, int formModeId) { - rs.executeQuery("select id from " + MODE_TABLE_NAME + " where modeuuid='" + uuid + "'"); - if (rs.next()) { - //建模数据的id - int bid = Util.getIntValue(rs.getString("id")); - ModeRightInfo modeRightInfo = new ModeRightInfo(); - modeRightInfo.setNewRight(true); - //新建的时候添加共享 - modeRightInfo.editModeDataShare(1, formModeId, bid); - } + return param; } @@ -171,4 +195,28 @@ public class BatchAddInterviewResultModeExpand extends AbstractModeExpandJavaCod private Object parseBlankToNull(String str) { return StringUtils.isBlank(str) ? null : str; } + + + /** + * 获取应聘者信息 + * + * @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("
"); + } } diff --git a/src/weaver/formmode/recruit/modeexpand/interview/CancelInterviewResultModeExpand.java b/src/weaver/formmode/recruit/modeexpand/interview/CancelInterviewResultModeExpand.java new file mode 100644 index 0000000..f3c2623 --- /dev/null +++ b/src/weaver/formmode/recruit/modeexpand/interview/CancelInterviewResultModeExpand.java @@ -0,0 +1,137 @@ +package weaver.formmode.recruit.modeexpand.interview; + +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; +import weaver.formmode.recruit.modeexpand.util.RecruitModeUtil; +import weaver.general.Util; +import weaver.soa.workflow.request.MainTableInfo; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.*; + +/** + * @author:dxfeng + * @createTime: 2023/09/26 + * @version: 1.0 + */ +public class CancelInterviewResultModeExpand extends AbstractModeExpandJavaCodeNew { + private static final String MODE_TABLE_NAME = "uf_jcl_ms"; + + /** + * 消息来源ID + */ + private final String messageType; + + /** + * 消息提醒标题 + */ + private final String title; + + public CancelInterviewResultModeExpand() { + super(); + messageType = RecruitModeUtil.getRecruitPropValue("INTERVIEW_MESSAGE_TYPE"); + title = RecruitModeUtil.getRecruitPropValue("INTERVIEW_CANCEL_MESSAGE_TITLE"); + } + + @Override + public Map doModeExpand(Map param) { + Map result = new HashMap<>(); + String cancelInterview = Util.null2String(param.get("cancelInterview")); + if (!"true".equals(cancelInterview)) { + return result; + } + try { + //数据id + int billId; + //模块id + 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) { + MainTableInfo mainTableInfo = requestInfo.getMainTableInfo(); + Property[] properties = mainTableInfo.getProperty(); + Map mainDataMap = new HashMap<>(); + for (Property property : properties) { + mainDataMap.put(property.getName(), property.getValue()); + } + + // 更新面试状态为“已取消” + RecordSet rs = new RecordSet(); + rs.executeUpdate("update " + MODE_TABLE_NAME + " set zt = 4 where id = ?", billId); + + // 发送消息 + StringBuilder msgBuilder = new StringBuilder(); + getApplicantsInfo(msgBuilder, Util.null2String(mainDataMap.get("ypz")), Util.null2String(mainDataMap.get("ypzw"))); + + + if (StringUtils.isNotBlank(msgBuilder)) { + String formId = Util.null2String(param.get("formId")); + msgBuilder.insert(0, RecruitModeUtil.getResourceNames(requestInfo.getCreatorid()) + "取消了面试,请知悉。取消原因:" + getCancelReason(formId, Util.null2String(mainDataMap.get("qxyy"))) + "
"); + 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, Integer.parseInt(requestInfo.getCreatorid())); + } + + } + } + } catch (Exception e) { + result.put("errmsg", "自定义出错信息"); + result.put("flag", "false"); + } + return result; + } + + /** + * 获取应聘者信息 + * + * @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("
"); + } + + /** + * 获取取消理由 + * + * @param formId 表单ID + * @param value 下拉框值 + * @return + */ + private String getCancelReason(String formId, String value) { + String cancelReason = ""; + RecordSet rs = new RecordSet(); + rs.executeQuery("select selectname from workflow_selectitem where fieldid =( select id from workflow_billfield where billid = ? and fieldname = 'qxyy' ) and selectvalue =?", formId, value); + if (rs.next()) { + cancelReason = rs.getString("selectname"); + } + return cancelReason; + } +} + diff --git a/src/weaver/formmode/recruit/modeexpand/util/RecruitModeUtil.java b/src/weaver/formmode/recruit/modeexpand/util/RecruitModeUtil.java new file mode 100644 index 0000000..4d67e09 --- /dev/null +++ b/src/weaver/formmode/recruit/modeexpand/util/RecruitModeUtil.java @@ -0,0 +1,70 @@ +package weaver.formmode.recruit.modeexpand.util; + +import com.cloudstore.dev.api.bean.MessageBean; +import com.cloudstore.dev.api.bean.MessageType; +import com.cloudstore.dev.api.util.Util_Message; +import weaver.general.BaseBean; +import weaver.hrm.resource.ResourceComInfo; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.Set; + +/** + * @author:dxfeng + * @createTime: 2023/09/26 + * @version: 1.0 + */ +public class RecruitModeUtil { + /** + * 消息推送 + * + * @param messageType 消息来源 + * @param title 消息标题 + * @param context 消息内容 + * @param userIdList 接收人ID集合 + * @param creater 消息创建者 + */ + public static void messagePush(String messageType, String title, String context, Set userIdList, Integer creater) { + MessageType message = MessageType.newInstance(Integer.parseInt(messageType)); + try { + MessageBean messageBean = Util_Message.createMessage(message, userIdList, title, context, "", ""); + messageBean.setCreater(creater); + Util_Message.store(messageBean); + } catch (IOException e) { + new BaseBean().writeLog(e); + e.printStackTrace(); + } + } + + /** + * 获取人员姓名 + * + * @param ids 人员ID + * @return 人员姓名 + */ + public static String getResourceNames(String ids) { + try { + return new ResourceComInfo().getLastnames(ids); + } catch (Exception e) { + new BaseBean().writeLog(e); + throw new RuntimeException(e); + } + } + + /** + * 获取聚才林招聘相关配置文件 + * + * @param key + * @return + */ + public static String getRecruitPropValue(String key) { + String value = new BaseBean().getPropValue("jclRecruit", key); + try { + value = new String(value.getBytes("ISO-8859-1"), "utf-8"); + } catch (UnsupportedEncodingException e) { + new BaseBean().writeLog(e); + } + return value; + } +}