diff --git a/src/com/api/mzg/web/RecruitMobileController.java b/src/com/api/mzg/web/RecruitMobileController.java new file mode 100644 index 0000000..18f16b4 --- /dev/null +++ b/src/com/api/mzg/web/RecruitMobileController.java @@ -0,0 +1,12 @@ +package com.api.mzg.web; + +import javax.ws.rs.Path; + +/** + * @author:dxfeng + * @createTime: 2024/09/05 + * @version: 1.0 + */ +@Path("/jcl/mzg/mobile") +public class RecruitMobileController extends com.engine.mzg.web.RecruitMobileController{ +} diff --git a/src/com/engine/mzg/conn/RecruitCommon.java b/src/com/engine/mzg/conn/RecruitCommon.java new file mode 100644 index 0000000..74f1cc8 --- /dev/null +++ b/src/com/engine/mzg/conn/RecruitCommon.java @@ -0,0 +1,59 @@ +package com.engine.mzg.conn; + +import weaver.conn.RecordSet; + +/** + * @author:dxfeng + * @createTime: 2024/09/05 + * @version: 1.0 + */ +public class RecruitCommon { + + + /** + * 获取配置 + * + * @param key + * @return + */ + public static String getSettingValue(String key) { + RecordSet rs = new RecordSet(); + rs.executeQuery("select pzz from uf_recruit_setting where pzx = ? ", key); + if (rs.next()) { + return rs.getString("pzz"); + } + return ""; + } + + /** + * 根据表名,获取表单ID + * + * @param modeTable + * @return + */ + public static int getFormIdByTableName(String modeTable) { + int formId = -1; + RecordSet rs = new RecordSet(); + rs.executeQuery("select id from workflow_bill where tablename = ? ", modeTable); + if (rs.next()) { + formId = rs.getInt("id"); + } + return formId; + } + + /** + * 根据建模表名,获取建模ID + * + * @param modeTable + * @return + */ + public static int getModeIdByTableName(String modeTable) { + int formModeId = -1; + RecordSet rs = new RecordSet(); + rs.executeQuery("select id from modeinfo where formid =( select id from workflow_bill where tablename = ? ) and isdelete = 0 order by id", modeTable); + if (rs.next()) { + formModeId = rs.getInt("id"); + } + return formModeId; + } +} diff --git a/src/com/engine/mzg/conn/RecruitRecordSet.java b/src/com/engine/mzg/conn/RecruitRecordSet.java new file mode 100644 index 0000000..40c28d1 --- /dev/null +++ b/src/com/engine/mzg/conn/RecruitRecordSet.java @@ -0,0 +1,168 @@ +package com.engine.mzg.conn; + +import com.engine.mzg.exception.CustomizeRunTimeException; +import com.engine.mzg.util.RecruitUtil; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.formmode.IgnoreCaseHashMap; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.Util; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2023/10/19 + * @version: 1.0 + */ +public class RecruitRecordSet { + + /** + * 获取单个记录映射 + * + * @param rs RecordSet + * @return + */ + public static Map getSingleRecordMap(RecordSet rs) { + Map dataMap = new IgnoreCaseHashMap<>(); + if (rs.next()) { + String[] columnNames = rs.getColumnName(); + for (String columnName : columnNames) { + dataMap.put(columnName, RecruitUtil.parseBlankToNull(rs.getString(columnName))); + } + } + return dataMap; + } + + public static List> getRecordMapList(RecordSet rs) { + List> list = new ArrayList<>(); + while (rs.next()) { + String[] columnNames = rs.getColumnName(); + Map dataMap = new IgnoreCaseHashMap<>(); + for (String columnName : columnNames) { + dataMap.put(columnName.toLowerCase(), RecruitUtil.parseBlankToNull(rs.getString(columnName))); + } + list.add(dataMap); + } + return list; + } + + /** + * 插入数据 + * + * @param dataMap 数据集合 + * @param tableName 表名 + */ + public static void insertData(Map dataMap, String tableName) { + List fieldList = new ArrayList<>(); + List dataList = new ArrayList<>(); + List paramList = new ArrayList<>(); + + dataMap.forEach((key, value) -> { + if (null != value) { + String valueStr = String.valueOf(value); + if (StringUtils.isNotBlank(valueStr)) { + fieldList.add(key); + dataList.add(valueStr); + paramList.add("?"); + } + } + }); + String insertSql = " insert into " + tableName + "(" + StringUtils.join(fieldList, ",") + ") values (" + StringUtils.join(paramList, ",") + ")"; + RecordSet rs = new RecordSet(); + rs.executeUpdate(insertSql, dataList); + if (StringUtils.isNotBlank(rs.getExceptionMsg())) { + throw new CustomizeRunTimeException(rs.getExceptionMsg()); + } + } + + /** + * 根据ID更新数据 + * + * @param dataMap + * @param tableName + */ + public static void updateDataById(Map dataMap, String tableName) { + List fieldList = new ArrayList<>(); + List dataList = new ArrayList<>(); + String id = Util.null2String(dataMap.get("id")); + dataMap.remove("id"); + + dataMap.forEach((key, value) -> { + fieldList.add(key + " = ? "); + dataList.add(value); + }); + dataList.add(id); + String updateSql = "update " + tableName + " set " + StringUtils.join(fieldList, ",") + " where id = ? "; + RecordSet rs = new RecordSet(); + rs.executeUpdate(updateSql, dataList); + if (StringUtils.isNotBlank(rs.getExceptionMsg())) { + throw new CustomizeRunTimeException(rs.getExceptionMsg()); + } + } + + /** + * 删除数据 + * + * @param deleteSql + */ + public static void deleteData(String deleteSql) { + RecordSet rs = new RecordSet(); + rs.executeUpdate(deleteSql); + if (StringUtils.isNotBlank(rs.getExceptionMsg())) { + throw new CustomizeRunTimeException(rs.getExceptionMsg()); + } + } + + + /** + * 构建建模表基本数据 + * + * @param mainDataMap 参数集合 + */ + public static void buildModeInsertFields(Map mainDataMap, int userId) { + String dateTime = DateUtil.getFullDate(); + String[] dateSplit = dateTime.split(" "); + mainDataMap.put("modedatacreater", userId); + mainDataMap.put("modedatacreatedate", dateSplit[0]); + mainDataMap.put("modedatacreatetime", dateSplit[1]); + mainDataMap.put("modedatacreatertype", "0"); + } + + /** + * 构建建模表基本数据 + * + * @param mainDataMap 参数集合 + */ + public static void buildModeUpdateFields(Map mainDataMap, int userId) { + String dateTime = DateUtil.getFullDate(); + mainDataMap.put("modedatamodifier", userId); + mainDataMap.put("modedatamodifydatetime", dateTime); + } + + /** + * 建模表数据权限重构 + * + * @param uuid + * @param modeTable + * @param formModeId + */ + public static int refreshRight(String uuid, String modeTable, int formModeId, int creator) { + RecordSet rs = new RecordSet(); + rs.executeQuery("select id from " + modeTable + " where modeuuid='" + uuid + "'"); + if (rs.next()) { + //建模数据的id + int bid = Util.getIntValue(rs.getString("id")); + ModeRightInfo modeRightInfo = new ModeRightInfo(); + modeRightInfo.setNewRight(true); + //新建的时候添加共享 + modeRightInfo.editModeDataShare(creator, formModeId, bid); + return bid; + } + return -1; + } + +} diff --git a/src/com/engine/mzg/enums/EmailTemplateEnum.java b/src/com/engine/mzg/enums/EmailTemplateEnum.java new file mode 100644 index 0000000..1c7dfcc --- /dev/null +++ b/src/com/engine/mzg/enums/EmailTemplateEnum.java @@ -0,0 +1,54 @@ +package com.engine.mzg.enums; + +/** + * 邮件模板类型 + * + * @author:dxfeng + * @createTime: 2023/09/13 + * @version: 1.0 + */ +public enum EmailTemplateEnum { + /** + * 性格测评 + */ + DISC(0, "性格测评"), + /** + * 应聘登记 + */ + REGIST(1, "应聘登记"), + /** + * 面试 + */ + INTERVIEW(2, "面试"), + /** + * offer + */ + OFFER(3, "offer"); + + EmailTemplateEnum(Integer value, String desc) { + this.value = value; + this.desc = desc; + } + + + private Integer value; + + + private String desc; + + public Integer getValue() { + return value; + } + + public void setValue(Integer value) { + this.value = value; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } +} diff --git a/src/com/engine/mzg/service/RecruitMobileService.java b/src/com/engine/mzg/service/RecruitMobileService.java new file mode 100644 index 0000000..470c562 --- /dev/null +++ b/src/com/engine/mzg/service/RecruitMobileService.java @@ -0,0 +1,19 @@ +package com.engine.mzg.service; + +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2024/09/04 + * @version: 1.0 + */ +public interface RecruitMobileService { + + /** + * 移动建模,提交DISC测试 + * + * @param params + * @return + */ + Map submitDiscTest(Map params); +} diff --git a/src/com/engine/mzg/service/impl/RecruitMobileServiceImpl.java b/src/com/engine/mzg/service/impl/RecruitMobileServiceImpl.java new file mode 100644 index 0000000..36b4c72 --- /dev/null +++ b/src/com/engine/mzg/service/impl/RecruitMobileServiceImpl.java @@ -0,0 +1,54 @@ +package com.engine.mzg.service.impl; + +import com.engine.core.impl.Service; +import com.engine.mzg.exception.CustomizeRunTimeException; +import com.engine.mzg.service.RecruitMobileService; +import weaver.conn.RecordSet; +import weaver.formmode.IgnoreCaseHashMap; +import weaver.formmode.mzg.modeexpand.disc.AddDiscExpand; +import weaver.general.Util; + +import java.util.Map; +import java.util.regex.Matcher; + +/** + * @author:dxfeng + * @createTime: 2024/09/04 + * @version: 1.0 + */ +public class RecruitMobileServiceImpl extends Service implements RecruitMobileService { + @Override + public Map submitDiscTest(Map params) { + String billId = Util.null2String(params.get("billId")); + // 更新DISC表中,统计各项汇总 + RecordSet rs = new RecordSet(); + rs.executeQuery("select * from uf_recruit_disc where id = ? ", billId); + if (rs.next()) { + int countD = 0; + int countI = 0; + int countS = 0; + int countC = 0; + Map dataMap = new IgnoreCaseHashMap<>(); + String[] columnNames = rs.getColumnName(); + for (String columnName : columnNames) { + Matcher matcher = AddDiscExpand.PATTERN.matcher(columnName); + if (matcher.matches()) { + String value = rs.getString(columnName); + if ("0".equals(value)) { + countD++; + } else if ("1".equals(value)) { + countI++; + } else if ("2".equals(value)) { + countS++; + } else if ("3".equals(value)) { + countC++; + } + } + } + rs.executeUpdate("update uf_recruit_disc set dxhj = ? ,ixhj = ?, sxhj = ?, cxhj = ? where id = ? ", countD, countI, countS, countC, billId); + } else { + throw new CustomizeRunTimeException("数据异常,提交失败,请联系HR"); + } + return null; + } +} diff --git a/src/com/engine/mzg/util/RecruitUtil.java b/src/com/engine/mzg/util/RecruitUtil.java new file mode 100644 index 0000000..bc9b10d --- /dev/null +++ b/src/com/engine/mzg/util/RecruitUtil.java @@ -0,0 +1,320 @@ +package com.engine.mzg.util; + +import com.api.mobilemode.util.FieldHandler; +import com.cloudstore.dev.api.bean.MessageBean; +import com.cloudstore.dev.api.bean.MessageType; +import com.cloudstore.dev.api.util.Util_Message; +import com.engine.mzg.conn.RecruitCommon; +import com.weaver.formmodel.data.manager.FormInfoManager; +import com.weaver.formmodel.data.model.Formfield; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.util.IOUtils; +import weaver.common.MessageUtil; +import weaver.conn.RecordSet; +import weaver.docs.docs.*; +import weaver.email.EmailWorkRunnable; +import weaver.file.ImageFileManager; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; + +import java.io.IOException; +import java.io.InputStream; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author:dxfeng + * @createTime: 2023/09/26 + * @version: 1.0 + */ +public class RecruitUtil { + /** + * 邮件、短信发送,替换内容正则表达式 + */ + private static final Pattern EMAIL_PATTERN = Pattern.compile(Pattern.quote("{") + "(.*?)" + Pattern.quote("}")); + /** + * 消息中心,替换内容正则表达式 + */ + private static final Pattern MSG_PATTERN = Pattern.compile(Pattern.quote("$") + "(.*?)" + Pattern.quote("$")); + + public static boolean sendEmail(String sendTo, String emailTitle, String emailContent) { + return MessageUtil.sendEmail(sendTo, emailTitle, emailContent); + } + + /** + * @param sendTo 收件人 + * @param emailTitle 邮件标题 + * @param emailContent 邮件内容 + * @param imageFileIds 邮件附件,imageFile表记录id,多个时英文逗号分隔 + * @return + */ + public static boolean sendEmailWithFile(String sendTo, String emailTitle, String emailContent, String imageFileIds) { + EmailWorkRunnable emailWorkRunnable = new EmailWorkRunnable(sendTo, Util.toHtmlMode(emailTitle), Util.toHtmlMode(emailContent)); + emailWorkRunnable.setImagefileids(imageFileIds); + return emailWorkRunnable.emailCommonRemind(); + } + + /** + * 消息推送 + * + * @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) { + messagePush(messageType, title, context, userIdList, creater, "", ""); + } + + /** + * @param messageType 消息来源 + * @param title 消息标题 + * @param context 消息内容 + * @param userIdList 接收人ID集合 + * @param creater 消息创建者 + * @param linkUrl 待办跳转地址 + * @param linkMobileUrl 移动端跳转地址 + */ + public static void messagePush(String messageType, String title, String context, Set userIdList, Integer creater, String linkUrl, String linkMobileUrl) { + MessageType message = MessageType.newInstance(Integer.parseInt(messageType)); + try { + MessageBean messageBean = Util_Message.createMessage(message, userIdList, title, context, linkUrl, linkMobileUrl); + 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); + } + } + + + /** + * 转换空字符串为null + * + * @param str 字符串 + * @return 转换后的字符串 + */ + public static Object parseBlankToNull(String str) { + return StringUtils.isBlank(str) ? null : str; + } + + /** + * 转换空字符串为null + * + * @param obj 对象 + * @return 转换后的字符串 + */ + public static String parseBlankToNull(Object obj) { + return Objects.isNull(obj) ? null : StringUtils.isBlank(obj.toString()) ? null : obj.toString(); + } + + + /** + * 生成附件ID + * + * @param inputStream + * @param filename + * @return + */ + public static int generateImageFileId(InputStream inputStream, String filename) { + int imageFileId; + try { + byte[] bytes = IOUtils.toByteArray(inputStream); + ImageFileManager ifm = new ImageFileManager(); + ifm.setData(bytes); + ifm.setImagFileName(filename); + imageFileId = ifm.saveImageFile(); + } catch (IOException e) { + throw new RuntimeException(e); + } + return imageFileId; + } + + public static List getFieldList(String tableName) { + int formId = RecruitCommon.getFormIdByTableName(tableName); + return FormInfoManager.getInstance().getAllField(formId); + } + + public static String getFieldShowName(Formfield formfield, String fieldValue) { + User user = new User(1); + return FieldHandler.getFieldValue(fieldValue, formfield, true, user); + } + + public static String getReplaceContent(String content, Map> fieldMapList, Map paramsData) { + Matcher matcher = EMAIL_PATTERN.matcher(content); + // 指定要匹配的字符串 + StringBuffer sb = new StringBuffer(); + while (matcher.find()) { + String replace = matcher.group(1); + + List formFieldList = fieldMapList.get(replace); + if (CollectionUtils.isEmpty(formFieldList)) { + continue; + } + // 多个相同名称的字段,只取第一个 + Formfield formfield = formFieldList.get(0); + String replaceValue = Util.null2String(paramsData.get(formfield.getFieldname().toLowerCase())); + String fieldShowName = RecruitUtil.getFieldShowName(formfield, replaceValue).replaceAll("<[^>]*>", ""); + matcher.appendReplacement(sb, Util.null2String(fieldShowName)); + } + matcher.appendTail(sb); + return sb.toString(); + } + + /** + * 消息中心,替换消息内容 + * + * @param content + * @param fieldMap + * @param paramsData + * @return + */ + public static String getMsgReplaceStr(String content, Map fieldMap, Map paramsData) { + Matcher matcher = MSG_PATTERN.matcher(content); + // 指定要匹配的字符串 + StringBuffer sb = new StringBuffer(); + while (matcher.find()) { + String replace = matcher.group(1); + + Formfield formfield = fieldMap.get(replace); + String replaceValue = Util.null2String(paramsData.get(formfield.getFieldname().toLowerCase())); + String fieldShowName = RecruitUtil.getFieldShowName(formfield, replaceValue).replaceAll("<[^>]*>", ""); + matcher.appendReplacement(sb, Util.null2String(fieldShowName)); + } + matcher.appendTail(sb); + return sb.toString(); + } + + /** + * 附件imageFieldId生成docId + * + * @param secCategory + * @param imageFieldId + * @param user + * @return + * @throws Exception + */ + public static int createDocId(int secCategory, int imageFieldId, User user) throws Exception { + ImageFileManager manager = new ImageFileManager(); + manager.getImageFileInfoById(imageFieldId); + String filenameqc = manager.getImageFileName(); + String filenamebc = filenameqc.substring(0, filenameqc.lastIndexOf(".")); + RecordSet rs = new RecordSet(); + DocManager dm = new DocManager(); + DocImageManager imgManger = new DocImageManager(); + + imgManger.setDocfiletype("2"); + + int docId = dm.getNextDocId(rs); + imgManger.setDocid(docId); + imgManger.setImagefileid(imageFieldId); + imgManger.setImagefilename(filenameqc); + imgManger.setIsextfile("1"); + imgManger.AddDocImageInfo(); + + String date = TimeUtil.getCurrentDateString(); + String time = TimeUtil.getOnlyCurrentTimeString(); + dm.setId(docId); + dm.setMaincategory(0); + dm.setSubcategory(0); + dm.setSeccategory(secCategory); + dm.setLanguageid(user.getLanguage()); + + dm.setDocstatus("1"); + dm.setDocsubject(filenamebc); + dm.setDoccreaterid(user.getUID()); + dm.setDocCreaterType(user.getLogintype()); + dm.setUsertype(user.getLogintype()); + dm.setOwnerid(user.getUID()); + dm.setOwnerType(user.getLogintype()); + dm.setDoclastmoduserid(user.getUID()); + dm.setDocLastModUserType(user.getLogintype()); + dm.setDoccreatedate(date); + dm.setDoclastmoddate(date); + dm.setDoccreatetime(time); + dm.setDoclastmodtime(time); + dm.setDoclangurage(user.getLanguage()); + dm.setKeyword(filenameqc); + dm.setIsapprover("0"); + dm.setIsreply(""); + dm.setDocdepartmentid(user.getUserDepartment()); + dm.setDocreplyable("1"); + dm.setAccessorycount(1); + dm.setParentids("" + docId); + dm.setUserid(user.getUID()); + DocCoder docCoder = new DocCoder(); + dm.setDocCode(docCoder.getDocCoder("" + secCategory)); + dm.setDocEditionId(dm.getNextEditionId(rs)); + dm.setDocEdition(1); + dm.AddDocInfo(); + dm.AddShareInfo(); + DocViewer DocViewer = new DocViewer(); + DocViewer.setDocShareByDoc("" + docId); + DocComInfo dc = new DocComInfo(); + dc.addDocInfoCache("" + docId); + return docId; + } + + public static String getImageFileIdsByDocIds(String docId) { + if (StringUtils.isBlank(docId)) { + return ""; + } + List imageFileIds = new ArrayList<>(); + String[] split = docId.split(","); + try { + for (String s : split) { + if (StringUtils.isBlank(s)) { + continue; + } + DocImageManager imgManger = new DocImageManager(); + imgManger.setDocid(Integer.parseInt(s)); + + imgManger.selectDocImageInfo(); + imgManger.next(); + imageFileIds.add(imgManger.getImagefileid()); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + + + return StringUtils.join(imageFileIds, ","); + } + + /** + * 获取邮件模板主题 + * + * @param id + */ + public static String getEmailTitle(String id) { + RecordSet recordSet = new RecordSet(); + String emailTitle = ""; + recordSet.executeQuery("select yjzt from uf_jcl_yjtzmb where id = ?", id); + if (recordSet.next()) { + emailTitle = recordSet.getString("yjzt"); + } + return emailTitle; + } + +} diff --git a/src/com/engine/mzg/web/RecruitMobileController.java b/src/com/engine/mzg/web/RecruitMobileController.java new file mode 100644 index 0000000..a5252cd --- /dev/null +++ b/src/com/engine/mzg/web/RecruitMobileController.java @@ -0,0 +1,40 @@ +package com.engine.mzg.web; + +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.mzg.service.RecruitMobileService; +import com.engine.mzg.service.impl.RecruitMobileServiceImpl; +import com.engine.mzg.util.ResponseResult; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2024/09/05 + * @version: 1.0 + */ +public class RecruitMobileController { + + public RecruitMobileService getService(User user) { + return ServiceUtil.getService(RecruitMobileServiceImpl.class, user); + } + + @GET + @Path("/submitDiscTest") + @Produces(MediaType.APPLICATION_JSON) + public String submitDiscTest(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map params = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getService(user)::submitDiscTest, params); + + } +} diff --git a/src/weaver/formmode/mzg/modeexpand/disc/AddDiscExpand.java b/src/weaver/formmode/mzg/modeexpand/disc/AddDiscExpand.java new file mode 100644 index 0000000..c842f10 --- /dev/null +++ b/src/weaver/formmode/mzg/modeexpand/disc/AddDiscExpand.java @@ -0,0 +1,72 @@ +package weaver.formmode.mzg.modeexpand.disc; + +import weaver.conn.RecordSet; +import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; +import weaver.general.BaseBean; +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.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author:dxfeng + * @createTime: 2024/09/02 + * @version: 1.0 + */ +public class AddDiscExpand extends AbstractModeExpandJavaCodeNew { + public static final Pattern PATTERN = Pattern.compile("^q([1-9]|[1-3][0-9]|40)$"); + + @Override + public Map doModeExpand(Map param) { + Map result = new HashMap<>(); + try { + 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) { + // 计算各个选项的值 + int countD = 0; + int countI = 0; + int countS = 0; + int countC = 0; + RecordSet rs = new RecordSet(); + MainTableInfo mainTableInfo = requestInfo.getMainTableInfo(); + Property[] properties = mainTableInfo.getProperty(); + for (Property property : properties) { + String name = property.getName(); + Matcher matcher = PATTERN.matcher(name); + if (!matcher.matches()) { + continue; + } + if ("0".equals(property.getValue())) { + countD++; + } else if ("1".equals(property.getValue())) { + countI++; + } else if ("2".equals(property.getValue())) { + countS++; + } else if ("3".equals(property.getValue())) { + countC++; + } + } + + // 更新各个选项的个数 + rs.executeUpdate("update uf_recruit_disc set dxhj = ? ,ixhj = ?, sxhj = ?, cxhj = ? where id = ? ", countD, countI, countS, countC, billId); + + } + } + } catch (Exception e) { + new BaseBean().writeLog(e); + result.put("errmsg", "DISC数据统计异常"); + result.put("flag", "false"); + } + return result; + } +} diff --git a/src/weaver/formmode/mzg/modeexpand/resume/SendDiscExpand.java b/src/weaver/formmode/mzg/modeexpand/resume/SendDiscExpand.java new file mode 100644 index 0000000..9974511 --- /dev/null +++ b/src/weaver/formmode/mzg/modeexpand/resume/SendDiscExpand.java @@ -0,0 +1,118 @@ +package weaver.formmode.mzg.modeexpand.resume; + +import com.engine.mzg.conn.RecruitCommon; +import com.engine.mzg.conn.RecruitRecordSet; +import com.engine.mzg.enums.EmailTemplateEnum; +import com.engine.mzg.exception.CustomizeRunTimeException; +import com.engine.mzg.util.RecruitUtil; +import com.weaver.formmodel.data.model.Formfield; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.formmode.IgnoreCaseHashMap; +import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; +import weaver.general.BaseBean; +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.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * 发送DISC性格测评 + * + * @author:dxfeng + * @createTime: 2024/09/05 + * @version: 1.0 + */ +public class SendDiscExpand extends AbstractModeExpandJavaCodeNew { + @Override + public Map doModeExpand(Map param) { + Map result = new HashMap<>(); + try { + int billId; + RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo"); + if (requestInfo != null) { + billId = Util.getIntValue(requestInfo.getRequestid()); + IgnoreCaseHashMap mainDataMap = new IgnoreCaseHashMap<>(); + MainTableInfo mainTableInfo = requestInfo.getMainTableInfo(); + Property[] properties = mainTableInfo.getProperty(); + for (Property property : properties) { + mainDataMap.put(property.getName(), property.getValue()); + } + + RecordSet rs = new RecordSet(); + String mobileAppidDisc = RecruitCommon.getSettingValue("MOBILE_APPID_DISC"); + String mobileUrlDisc = RecruitCommon.getSettingValue("MOBILE_URL_DISC"); + String httpUrl = RecruitCommon.getSettingValue("HTTP_URL"); + rs.executeQuery("select noLoginUser from mobileappbaseinfo where id = ?", mobileAppidDisc); + int creator = -1; + if (rs.next()) { + creator = rs.getInt("noLoginUser"); + } + if (-1 == creator) { + throw new CustomizeRunTimeException("未配置免登陆访问用户,请检查移动建模应用配置"); + } + + String sendTo = Util.null2String(mainDataMap.get("dzyx")); + if (StringUtils.isBlank(sendTo)) { + throw new CustomizeRunTimeException("电子邮箱为空,邮件发送失败"); + } + String emailTitle = ""; + String emailContent = ""; + rs.executeQuery("select yjzt ,yjnr from uf_recruit_email where mblx =? ", EmailTemplateEnum.DISC.getValue()); + if (rs.next()) { + emailTitle = rs.getString("yjzt"); + emailContent = rs.getString("yjnr"); + } + + if (StringUtils.isBlank(emailTitle) || StringUtils.isBlank(emailContent)) { + throw new CustomizeRunTimeException("请检查邮件模板设置"); + } + + + // 插入DISC测评表数据 + IgnoreCaseHashMap dataMap = new IgnoreCaseHashMap<>(); + String uuid = UUID.randomUUID().toString(); + dataMap.put("modeuuid", uuid); + int formModeId = RecruitCommon.getModeIdByTableName("uf_recruit_disc"); + dataMap.put("formmodeid", formModeId); + // 构建建模表基本数据 + RecruitRecordSet.buildModeInsertFields(dataMap, creator); + dataMap.put("xm", billId); + dataMap.put("sqzw", mainDataMap.get("sqzw")); + dataMap.put("lxfs", mainDataMap.get("lxfs")); + + dataMap.put("modedatastatus", "0"); + // 插入数据 + RecruitRecordSet.insertData(dataMap, "uf_recruit_disc"); + + int id = RecruitRecordSet.refreshRight(uuid, "uf_recruit_disc", formModeId, creator); + + // 测评ID反写简历中心表,更新状态 + rs.executeUpdate("update uf_recruit_resume set cpzt = ? ,cpglid = ? where id = ? ", 1, id, billId); + + // 发送邮件 + // 查询字段信息 + List fieldList = RecruitUtil.getFieldList("uf_recruit_resume"); + Map> fieldMapList = fieldList.stream().collect(Collectors.groupingBy(Formfield::getFieldname)); + String url = httpUrl + mobileUrlDisc + "&billid=" + id; + if (StringUtils.isNotBlank(url)) { + url = "链接地址"; + } + emailContent = emailContent.replace("{链接地址}", url); + emailContent = RecruitUtil.getReplaceContent(emailContent, fieldMapList, mainDataMap); + RecruitUtil.sendEmail(sendTo, emailTitle, emailContent); + } + } catch (Exception e) { + new BaseBean().writeLog(e); + result.put("errmsg", e.getMessage()); + result.put("flag", "false"); + } + return result; + } +} diff --git a/src/weaver/formmode/mzg/modeexpand/resume/SendRegistExpand.java b/src/weaver/formmode/mzg/modeexpand/resume/SendRegistExpand.java new file mode 100644 index 0000000..75f90ba --- /dev/null +++ b/src/weaver/formmode/mzg/modeexpand/resume/SendRegistExpand.java @@ -0,0 +1,119 @@ +package weaver.formmode.mzg.modeexpand.resume; + +import com.engine.mzg.conn.RecruitCommon; +import com.engine.mzg.conn.RecruitRecordSet; +import com.engine.mzg.enums.EmailTemplateEnum; +import com.engine.mzg.exception.CustomizeRunTimeException; +import com.engine.mzg.util.RecruitUtil; +import com.weaver.formmodel.data.model.Formfield; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.formmode.IgnoreCaseHashMap; +import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; +import weaver.general.BaseBean; +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.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * 发送应聘登记 + * + * @author:dxfeng + * @createTime: 2024/09/05 + * @version: 1.0 + */ + +public class SendRegistExpand extends AbstractModeExpandJavaCodeNew { + @Override + public Map doModeExpand(Map param) { + Map result = new HashMap<>(); + try { + int billId; + RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo"); + if (requestInfo != null) { + billId = Util.getIntValue(requestInfo.getRequestid()); + IgnoreCaseHashMap mainDataMap = new IgnoreCaseHashMap<>(); + MainTableInfo mainTableInfo = requestInfo.getMainTableInfo(); + Property[] properties = mainTableInfo.getProperty(); + for (Property property : properties) { + mainDataMap.put(property.getName(), property.getValue()); + } + + RecordSet rs = new RecordSet(); + String mobileAppidRegist = RecruitCommon.getSettingValue("MOBILE_APPID_REGIST"); + String mobileUrlRegist = RecruitCommon.getSettingValue("MOBILE_URL_REGIST"); + String httpUrl = RecruitCommon.getSettingValue("HTTP_URL"); + rs.executeQuery("select noLoginUser from mobileappbaseinfo where id = ?", mobileAppidRegist); + int creator = -1; + if (rs.next()) { + creator = rs.getInt("noLoginUser"); + } + if (-1 == creator) { + throw new CustomizeRunTimeException("未配置免登陆访问用户,请检查移动建模应用配置"); + } + + String sendTo = Util.null2String(mainDataMap.get("dzyx")); + if (StringUtils.isBlank(sendTo)) { + throw new CustomizeRunTimeException("电子邮箱为空,邮件发送失败"); + } + String emailTitle = ""; + String emailContent = ""; + rs.executeQuery("select yjzt ,yjnr from uf_recruit_email where mblx =? ", EmailTemplateEnum.REGIST.getValue()); + if (rs.next()) { + emailTitle = rs.getString("yjzt"); + emailContent = rs.getString("yjnr"); + } + + if (StringUtils.isBlank(emailTitle) || StringUtils.isBlank(emailContent)) { + throw new CustomizeRunTimeException("请检查邮件模板设置"); + } + + + // 插入应聘登记数据 + IgnoreCaseHashMap dataMap = new IgnoreCaseHashMap<>(); + String uuid = UUID.randomUUID().toString(); + dataMap.put("modeuuid", uuid); + int formModeId = RecruitCommon.getModeIdByTableName("uf_recruit_regist"); + dataMap.put("formmodeid", formModeId); + // 构建建模表基本数据 + RecruitRecordSet.buildModeInsertFields(dataMap, creator); + dataMap.put("xmzw", mainDataMap.get("xm")); + dataMap.put("sqzw", mainDataMap.get("sqzw")); + dataMap.put("lldh", mainDataMap.get("lxfs")); + + //dataMap.put("modedatastatus", "0"); + // 插入数据 + RecruitRecordSet.insertData(dataMap, "uf_recruit_regist"); + + int id = RecruitRecordSet.refreshRight(uuid, "uf_recruit_regist", formModeId, creator); + + // 测评ID反写简历中心表,更新状态 + rs.executeUpdate("update uf_recruit_resume set xxcjzt = ? ,ypdjid = ? where id = ? ", 1, id, billId); + + // 发送邮件 + // 查询字段信息 + List fieldList = RecruitUtil.getFieldList("uf_recruit_resume"); + Map> fieldMapList = fieldList.stream().collect(Collectors.groupingBy(Formfield::getFieldname)); + String url = httpUrl + mobileUrlRegist + "&billid=" + id; + if (StringUtils.isNotBlank(url)) { + url = "链接地址"; + } + emailContent = emailContent.replace("{链接地址}", url); + emailContent = RecruitUtil.getReplaceContent(emailContent, fieldMapList, mainDataMap); + RecruitUtil.sendEmail(sendTo, emailTitle, emailContent); + } + } catch (Exception e) { + new BaseBean().writeLog(e); + result.put("errmsg", e.getMessage()); + result.put("flag", "false"); + } + return result; + } +}