weaver-hrm-recruit/src/weaver/formmode/recruit/modeexpand/written/BatchAddWrittenResultModeEx...

158 lines
7.0 KiB
Java
Raw Normal View History

2023-09-25 16:57:28 +08:00
package weaver.formmode.recruit.modeexpand.written;
2023-11-03 14:47:34 +08:00
import com.engine.recruit.conn.RecruitRecordSet;
2023-10-27 17:08:12 +08:00
import com.engine.recruit.util.RecruitMessageUtils;
2023-11-09 14:34:44 +08:00
import com.weaver.formmodel.data.model.Formfield;
import org.apache.commons.collections.CollectionUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
2023-10-27 17:08:12 +08:00
import weaver.formmode.recruit.modeexpand.util.RecruitModeUtil;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.soa.workflow.request.*;
import java.util.*;
2023-11-09 14:34:44 +08:00
import java.util.stream.Collectors;
/**
* <p>聚才林招聘</p>
* 批量安排笔试推笔试结果
*
* @author:dxfeng
* @createTime: 2023/09/21
* @version: 1.0
*/
public class BatchAddWrittenResultModeExpand extends AbstractModeExpandJavaCodeNew {
private static final String MODE_TABLE_NAME = "uf_jcl_bs";
@Override
public Map<String, String> doModeExpand(Map<String, Object> param) {
Map<String, String> result = new HashMap<>();
try {
RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo");
if (requestInfo != null) {
int formModeId = -1;
RecordSet rs = new RecordSet();
rs.executeQuery("select id from modeinfo where formid =( select id from workflow_bill where tablename = ? )", MODE_TABLE_NAME);
if (rs.next()) {
formModeId = rs.getInt("id");
}
MainTableInfo mainTableInfo = requestInfo.getMainTableInfo();
Property[] properties = mainTableInfo.getProperty();
Map<String, Object> mainDataMap = new HashMap<>();
for (Property property : properties) {
mainDataMap.put(property.getName(), 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]);
2023-11-03 14:49:19 +08:00
mainDataMap.put("modedatamodifier", null);
mainDataMap.put("modedatamodifydatetime", null);
mainDataMap.put("modedatacreatertype", "0");
mainDataMap.put("bsapid", requestInfo.getRequestid());
List<Map<String, Object>> detailMapList = new ArrayList<>();
DetailTableInfo detailTableInfo = requestInfo.getDetailTableInfo();
DetailTable detailTable = detailTableInfo.getDetailTable(0);
Row[] rows = detailTable.getRow();
for (Row row : rows) {
Map<String, Object> detailDataMap = new HashMap<>(mainDataMap);
Cell[] cells = row.getCell();
for (Cell cell : cells) {
detailDataMap.put(cell.getName(), cell.getValue());
}
detailMapList.add(detailDataMap);
}
2023-11-09 14:34:44 +08:00
String tzypz = Util.null2String(mainDataMap.get("tzypz"));
String yjnr = Util.null2String(mainDataMap.get("yjnr"));
String yjtzmb = Util.null2String(mainDataMap.get("yjtzmb"));
List<String> sendTypeList = Arrays.asList(tzypz.split(","));
boolean sendEmail = sendTypeList.contains("0");
boolean sendSms = sendTypeList.contains("1");
String emailTitle = RecruitModeUtil.getEmailTitle(yjtzmb);
List<Formfield> fieldList = RecruitModeUtil.getFieldList("uf_jcl_apbs");
Map<String, List<Formfield>> fieldMapList = fieldList.stream().collect(Collectors.groupingBy(Formfield::getLabelName));
for (Map<String, Object> detailDataMap : detailMapList) {
List<List<Object>> paramList = new ArrayList<>();
buildParamList(detailDataMap, paramList);
if (CollectionUtils.isNotEmpty(paramList)) {
2023-11-09 14:34:44 +08:00
String insertSql = "insert into " + MODE_TABLE_NAME + " (modeuuid, modedatacreatertype, formmodeid, modedatacreater, modedatacreatedate, modedatacreatetime, modedatamodifier, modedatamodifydatetime, pcid, ypz, ypzw, bsmc, bssj, bssm, tdsj, bsapid, sjh, yx, bsdd ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
for (List<Object> objects : paramList) {
String uuid = UUID.randomUUID().toString();
objects.add(0, uuid);
rs.executeUpdate(insertSql, objects);
2023-11-03 14:47:34 +08:00
RecruitRecordSet.refreshRight(uuid, MODE_TABLE_NAME, formModeId, user.getUID());
}
}
2023-11-09 14:34:44 +08:00
// 发送邮件
String msgContent = RecruitModeUtil.getReplaceContent(yjnr, fieldMapList, detailDataMap);
String yx = Util.null2String(detailDataMap.get("yx"));
String sjh = Util.null2String(detailDataMap.get("sjh"));
if (sendEmail) {
RecruitMessageUtils.SendEmail(yx, emailTitle, msgContent);
2023-10-27 17:08:12 +08:00
2023-11-09 14:34:44 +08:00
}
if (sendSms) {
RecruitMessageUtils.sendSMS(sjh, msgContent);
}
}
}
} catch (Exception e) {
new BaseBean().writeLog(e);
result.put("errmsg", "自定义出错信息");
result.put("flag", "false");
}
return result;
}
/**
* 构建批量插入数据集合
*
* @param map 表单参数
* @param paramList 待插入数据集合
*/
private void buildParamList(Map<String, Object> map, List<List<Object>> paramList) {
List<Object> 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("bsmc"));
// 笔试时间
param.add(map.get("bssj"));
// 笔试说明
param.add(map.get("bssm"));
param.add(map.get("tdsj"));
param.add(map.get("bsapid"));
param.add(map.get("sjh"));
param.add(map.get("yx"));
2023-11-09 14:34:44 +08:00
param.add(map.get("bsdd"));
paramList.add(param);
}
}