2023-09-25 16:57:28 +08:00
|
|
|
|
package weaver.formmode.recruit.modeexpand.written;
|
2023-09-22 13:38:04 +08:00
|
|
|
|
|
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;
|
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
|
import lombok.Builder;
|
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
|
import lombok.NoArgsConstructor;
|
2023-09-22 13:38:04 +08:00
|
|
|
|
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;
|
2023-09-22 13:38:04 +08:00
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
|
import weaver.general.Util;
|
2023-09-27 13:35:02 +08:00
|
|
|
|
import weaver.hrm.User;
|
2023-09-22 13:38:04 +08:00
|
|
|
|
import weaver.soa.workflow.request.*;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
2023-10-27 17:08:12 +08:00
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
|
import java.util.regex.Pattern;
|
2023-09-22 13:38:04 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* <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";
|
2023-10-27 17:08:12 +08:00
|
|
|
|
private static final RecordSet recordSet = new RecordSet();
|
2023-09-22 13:38:04 +08:00
|
|
|
|
|
|
|
|
|
|
@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());
|
|
|
|
|
|
}
|
|
|
|
|
|
// 填充建模数据基本信息
|
2023-09-27 13:35:02 +08:00
|
|
|
|
User user = (User) param.get("user");
|
2023-09-22 13:38:04 +08:00
|
|
|
|
mainDataMap.put("formmodeid", formModeId);
|
2023-09-27 13:35:02 +08:00
|
|
|
|
mainDataMap.put("modedatacreater", user.getUID());
|
2023-09-22 13:38:04 +08:00
|
|
|
|
String dateTime = DateUtil.getFullDate();
|
|
|
|
|
|
String[] split = dateTime.split(" ");
|
|
|
|
|
|
mainDataMap.put("modedatacreatedate", split[0]);
|
|
|
|
|
|
mainDataMap.put("modedatacreatetime", split[1]);
|
2023-09-27 13:35:02 +08:00
|
|
|
|
mainDataMap.put("modedatamodifier", user.getUID());
|
2023-09-22 13:38:04 +08:00
|
|
|
|
mainDataMap.put("modedatamodifydatetime", dateTime);
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (Map<String, Object> detailDataMap : detailMapList) {
|
|
|
|
|
|
List<List<Object>> paramList = new ArrayList<>();
|
|
|
|
|
|
buildParamList(detailDataMap, paramList);
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(paramList)) {
|
|
|
|
|
|
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 ) 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-09-22 13:38:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-10-27 17:08:12 +08:00
|
|
|
|
|
|
|
|
|
|
// 发送信息
|
|
|
|
|
|
int billId = Util.getIntValue(requestInfo.getRequestid());
|
|
|
|
|
|
sendMessage(billId);
|
2023-09-22 13:38:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
} 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"));
|
|
|
|
|
|
paramList.add(param);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-27 17:08:12 +08:00
|
|
|
|
|
|
|
|
|
|
private void sendMessage(int billId) {
|
2023-10-31 16:54:39 +08:00
|
|
|
|
String querySql = "select b.ypz,b.ypzw,b.sjh,b.yx,a.yjtzmb ,a.bssj ,a.bsdd,a.yjnr,a.tzypz from uf_jcl_apbs a \n" +
|
2023-10-27 17:08:12 +08:00
|
|
|
|
"left join uf_jcl_apbs_dt1 b on a.id = b.mainid where a.id = ?";
|
2023-11-03 14:47:34 +08:00
|
|
|
|
recordSet.executeQuery(querySql, billId);
|
2023-10-27 17:08:12 +08:00
|
|
|
|
String yjnr;
|
2023-10-31 16:54:39 +08:00
|
|
|
|
String tzypz = "";
|
2023-10-27 17:08:12 +08:00
|
|
|
|
List<WrittenPerson> writtenPersonList = new ArrayList<>();
|
|
|
|
|
|
while (recordSet.next()) {
|
|
|
|
|
|
yjnr = recordSet.getString("yjnr");
|
2023-10-31 16:54:39 +08:00
|
|
|
|
tzypz = recordSet.getString("tzypz");
|
2023-10-27 17:08:12 +08:00
|
|
|
|
|
|
|
|
|
|
Pattern patten = Pattern.compile("\\$(.*?)\\$");//编译正则表达式
|
|
|
|
|
|
Matcher matcher = patten.matcher(yjnr);// 指定要匹配的字符串
|
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
|
|
|
while (matcher.find()) { //此处find()每次被调用后,会偏移到下一个匹配
|
2023-11-03 14:47:34 +08:00
|
|
|
|
matcher.appendReplacement(sb, Util.null2String(recordSet.getString(matcher.group().replace("$", ""))));
|
2023-10-27 17:08:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
matcher.appendTail(sb);
|
|
|
|
|
|
|
|
|
|
|
|
writtenPersonList.add(WrittenPerson.builder()
|
|
|
|
|
|
.name(Util.null2String(recordSet.getString("ypz")))
|
|
|
|
|
|
.jobName(Util.null2String(recordSet.getString("ypzw")))
|
|
|
|
|
|
.time(Util.null2String(recordSet.getString("bssj")))
|
|
|
|
|
|
.phone(Util.null2String(recordSet.getString("sjh")))
|
|
|
|
|
|
.email(Util.null2String(recordSet.getString("yx")))
|
|
|
|
|
|
.address(Util.null2String(recordSet.getString("bsdd")))
|
|
|
|
|
|
.content(Util.null2String(sb)).build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (WrittenPerson writtenPerson : writtenPersonList) {
|
|
|
|
|
|
|
2023-11-03 14:47:34 +08:00
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
2023-10-31 16:54:39 +08:00
|
|
|
|
String[] strings = tzypz.split(",");
|
2023-10-27 17:08:12 +08:00
|
|
|
|
for (String s : strings) {
|
|
|
|
|
|
switch (s) {
|
|
|
|
|
|
case "0":
|
|
|
|
|
|
// 邮件
|
|
|
|
|
|
params.put("sendTo", writtenPerson.getEmail());
|
|
|
|
|
|
params.put("emailTitle", RecruitModeUtil.getEmailTitle(s));
|
|
|
|
|
|
params.put("emailContent", writtenPerson.getContent());
|
|
|
|
|
|
RecruitMessageUtils.SendEmail(params);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "1":
|
|
|
|
|
|
// 短信
|
|
|
|
|
|
params.put("receiver", writtenPerson.getPhone());
|
|
|
|
|
|
params.put("content", writtenPerson.getContent());
|
|
|
|
|
|
RecruitMessageUtils.sendSMS(params);
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Data
|
|
|
|
|
|
@Builder
|
|
|
|
|
|
@NoArgsConstructor
|
|
|
|
|
|
@AllArgsConstructor
|
|
|
|
|
|
private static class WrittenPerson {
|
|
|
|
|
|
String name;
|
|
|
|
|
|
String jobName;
|
|
|
|
|
|
String time;
|
|
|
|
|
|
String address;
|
|
|
|
|
|
String phone;
|
|
|
|
|
|
String email;
|
|
|
|
|
|
String content;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-22 13:38:04 +08:00
|
|
|
|
}
|