2023-09-26 15:21:22 +08:00
|
|
|
package weaver.formmode.recruit.modeexpand.util;
|
|
|
|
|
|
2023-11-09 14:34:44 +08:00
|
|
|
import com.api.mobilemode.util.FieldHandler;
|
2023-09-26 15:21:22 +08:00
|
|
|
import com.cloudstore.dev.api.bean.MessageBean;
|
|
|
|
|
import com.cloudstore.dev.api.bean.MessageType;
|
|
|
|
|
import com.cloudstore.dev.api.util.Util_Message;
|
2023-11-09 14:34:44 +08:00
|
|
|
import com.engine.recruit.conn.ApplicantCommonInfo;
|
|
|
|
|
import com.weaver.formmodel.data.manager.FormInfoManager;
|
|
|
|
|
import com.weaver.formmodel.data.model.Formfield;
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
2023-09-26 18:50:30 +08:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2023-10-17 15:18:53 +08:00
|
|
|
import org.apache.poi.util.IOUtils;
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.docs.docs.DocCoder;
|
|
|
|
|
import weaver.docs.docs.DocComInfo;
|
|
|
|
|
import weaver.docs.docs.DocImageManager;
|
|
|
|
|
import weaver.docs.docs.DocManager;
|
|
|
|
|
import weaver.file.ImageFileManager;
|
2023-09-26 15:21:22 +08:00
|
|
|
import weaver.general.BaseBean;
|
2023-10-17 15:18:53 +08:00
|
|
|
import weaver.general.TimeUtil;
|
2023-11-09 14:34:44 +08:00
|
|
|
import weaver.general.Util;
|
2023-10-17 15:18:53 +08:00
|
|
|
import weaver.hrm.User;
|
2023-09-26 15:21:22 +08:00
|
|
|
import weaver.hrm.resource.ResourceComInfo;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
2023-11-13 09:42:14 +08:00
|
|
|
import java.io.InputStream;
|
2023-10-27 16:50:24 +08:00
|
|
|
import java.util.*;
|
2023-11-09 14:34:44 +08:00
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
2023-09-26 15:21:22 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author:dxfeng
|
|
|
|
|
* @createTime: 2023/09/26
|
|
|
|
|
* @version: 1.0
|
|
|
|
|
*/
|
|
|
|
|
public class RecruitModeUtil {
|
2023-11-09 14:34:44 +08:00
|
|
|
private static final Pattern MSG_PATTERN = Pattern.compile(Pattern.quote("{") + "(.*?)" + Pattern.quote("}"));
|
|
|
|
|
|
2023-12-11 13:28:27 +08:00
|
|
|
|
2023-09-26 15:21:22 +08:00
|
|
|
/**
|
|
|
|
|
* 消息推送
|
|
|
|
|
*
|
|
|
|
|
* @param messageType 消息来源
|
|
|
|
|
* @param title 消息标题
|
|
|
|
|
* @param context 消息内容
|
|
|
|
|
* @param userIdList 接收人ID集合
|
|
|
|
|
* @param creater 消息创建者
|
|
|
|
|
*/
|
|
|
|
|
public static void messagePush(String messageType, String title, String context, Set<String> userIdList, Integer creater) {
|
2023-10-20 15:52:26 +08:00
|
|
|
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<String> userIdList, Integer creater, String linkUrl, String linkMobileUrl) {
|
2023-09-26 15:21:22 +08:00
|
|
|
MessageType message = MessageType.newInstance(Integer.parseInt(messageType));
|
|
|
|
|
try {
|
2023-10-20 15:52:26 +08:00
|
|
|
MessageBean messageBean = Util_Message.createMessage(message, userIdList, title, context, linkUrl, linkMobileUrl);
|
2023-09-26 15:21:22 +08:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-26 18:50:30 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 转换空字符串为null
|
|
|
|
|
*
|
|
|
|
|
* @param str 字符串
|
|
|
|
|
* @return 转换后的字符串
|
|
|
|
|
*/
|
|
|
|
|
public static Object parseBlankToNull(String str) {
|
|
|
|
|
return StringUtils.isBlank(str) ? null : str;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-17 15:18:53 +08:00
|
|
|
/**
|
|
|
|
|
* 转换空字符串为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
|
|
|
|
|
*/
|
2023-11-13 09:42:14 +08:00
|
|
|
public static int generateImageFileId(InputStream inputStream, String filename) {
|
2023-10-17 15:18:53 +08:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-09 14:34:44 +08:00
|
|
|
public static List<Formfield> getFieldList(String tableName) {
|
|
|
|
|
int formId = ApplicantCommonInfo.getFormIdByTableName(tableName);
|
|
|
|
|
return FormInfoManager.getInstance().getAllField(formId);
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-09 18:06:31 +08:00
|
|
|
public static String getFieldShowName(Formfield formfield, String fieldValue) {
|
2023-11-09 14:34:44 +08:00
|
|
|
User user = new User(1);
|
2024-01-09 18:06:31 +08:00
|
|
|
return FieldHandler.getFieldValue(fieldValue, formfield, true, user);
|
2023-11-09 14:34:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getReplaceContent(String content, Map<String, List<Formfield>> fieldMapList, Map<String, Object> paramsData) {
|
|
|
|
|
Matcher matcher = MSG_PATTERN.matcher(content);
|
|
|
|
|
// 指定要匹配的字符串
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
while (matcher.find()) {
|
|
|
|
|
String replace = matcher.group(1);
|
|
|
|
|
|
|
|
|
|
List<Formfield> 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 = RecruitModeUtil.getFieldShowName(formfield, replaceValue).replaceAll("<[^>]*>", "");
|
|
|
|
|
matcher.appendReplacement(sb, Util.null2String(fieldShowName));
|
|
|
|
|
}
|
|
|
|
|
matcher.appendTail(sb);
|
|
|
|
|
return sb.toString();
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-17 15:18:53 +08:00
|
|
|
/**
|
|
|
|
|
* 附件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();
|
|
|
|
|
DocComInfo dc = new DocComInfo();
|
|
|
|
|
dc.addDocInfoCache("" + docId);
|
|
|
|
|
return docId;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-08 09:37:13 +08:00
|
|
|
public static String getImageFileIdsByDocIds(String docId) {
|
|
|
|
|
if (StringUtils.isBlank(docId)) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
List<String> 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, ",");
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-27 16:50:24 +08:00
|
|
|
/**
|
|
|
|
|
* 获取邮件模板主题
|
2023-11-08 09:37:13 +08:00
|
|
|
*
|
2023-10-27 16:50:24 +08:00
|
|
|
* @param id
|
|
|
|
|
*/
|
2023-11-08 09:37:13 +08:00
|
|
|
public static String getEmailTitle(String id) {
|
2023-10-27 16:50:24 +08:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-26 15:21:22 +08:00
|
|
|
}
|