You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
weaver-develop/src/com/engine/mzg/service/impl/RecruitMobileServiceImpl.java

220 lines
9.7 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.engine.mzg.service.impl;
import com.engine.core.impl.Service;
import com.engine.mzg.conn.RecruitCommon;
import com.engine.mzg.conn.RecruitRecordSet;
import com.engine.mzg.entity.SyncTableField;
import com.engine.mzg.exception.CustomizeRunTimeException;
import com.engine.mzg.service.RecruitMobileService;
import com.engine.mzg.util.RecruitUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.formmode.IgnoreCaseHashMap;
import weaver.formmode.mzg.modeexpand.disc.AddDiscExpand;
import weaver.general.Util;
import java.util.*;
import java.util.regex.Matcher;
/**
* @author:dxfeng
* @createTime: 2024/09/04
* @version: 1.0
*/
public class RecruitMobileServiceImpl extends Service implements RecruitMobileService {
@Override
public Map<String, Object> submitDiscTest(Map<String, Object> 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;
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;
}
@Override
public Map<String, Object> submitRegist(Map<String, Object> params) {
// 判断是否已经创建面试台账,未创建则插入数据,已创建则更新数据,发起面试流程后,不允许再次提交
String billId = Util.null2String(params.get("billId"));
String targetTable = Util.null2String(params.get("targetTable"));
String sourceTable = Util.null2String(params.get("sourceTable"));
if (StringUtils.isBlank(billId)) {
throw new CustomizeRunTimeException("数据流转异常请联系HR确认");
}
RecordSet rs = new RecordSet();
rs.executeQuery("select id,mslcid from uf_recruit_ms where ypdjid = ? ", billId);
String msId = "";
String mslcId = "";
if (rs.next()) {
msId = rs.getString("id");
mslcId = rs.getString("mslcid");
}
// 是否新增面试数据
boolean isAdd = StringUtils.isBlank(msId);
if (StringUtils.isNotBlank(mslcId)) {
throw new CustomizeRunTimeException("当前数据已登记结束,无法重复提交");
}
rs.executeQuery("select * from uf_recruit_table where target_table = ? and source_table =? ", targetTable, sourceTable);
String mainTableId = "";
if (rs.next()) {
mainTableId = rs.getString("id");
}
if (StringUtils.isNotBlank(mainTableId)) {
// 查询配置的字段,更新或者插入数据
List<SyncTableField> fields = getSyncTableFields(mainTableId);
rs.executeQuery("select * from " + sourceTable + " where id = ? ", billId);
IgnoreCaseHashMap<String, String> buildDataMap = new IgnoreCaseHashMap<>();
if (rs.next()) {
for (SyncTableField field : fields) {
String value = RecruitUtil.parseBlankToNull(rs.getString(field.getSourceField()));
if (StringUtils.isNotBlank(value)) {
buildDataMap.put(field.getTargetField(), value);
}
}
// 根据职位,设置部门的值
rs.executeQuery("select sqbm from uf_recruit_zpxqglb where id = ?", buildDataMap.get("sqzw"));
if (rs.next()) {
buildDataMap.put("bm", rs.getString("sqbm"));
}
if (isAdd) {
// 新增
String uuid = UUID.randomUUID().toString();
buildDataMap.put("modeuuid", uuid);
int formModeId = RecruitCommon.getModeIdByTableName(targetTable);
buildDataMap.put("formmodeid", formModeId);
// 构建建模表基本数据
buildDataMap.put("ypdjid", billId);
buildDataMap.put("mslx", "0");
buildDataMap.put("mszt", "0");
RecruitRecordSet.buildModeInsertFields(buildDataMap, 1);
RecruitRecordSet.insertData(buildDataMap, targetTable);
msId = String.valueOf(RecruitRecordSet.refreshRight(uuid, targetTable, formModeId, 1));
} else {
// 更新
buildDataMap.put("id", msId);
RecruitRecordSet.updateDataById(buildDataMap, targetTable);
}
}
// 更新明细表,明细表删除后重新插入数据
rs.executeQuery("select * from uf_recruit_table where source_table like '" + sourceTable + "_dt%' and target_table like '" + targetTable + "_dt%' ");
while (rs.next()) {
mainTableId = rs.getString("id");
String sourceDetailTable = rs.getString("source_table");
String targetDetailTable = rs.getString("target_table");
List<SyncTableField> syncTableFields = getSyncTableFields(mainTableId);
// 删除明细表数据
RecordSet recordSet = new RecordSet();
recordSet.executeUpdate(" delete from " + targetDetailTable + " where mainid = ?", msId);
recordSet.executeQuery("select * from " + sourceDetailTable + " where mainid = ? ", billId);
while (recordSet.next()) {
buildDataMap = new IgnoreCaseHashMap<>();
buildDataMap.put("mainid", msId);
for (SyncTableField field : syncTableFields) {
String value = RecruitUtil.parseBlankToNull(recordSet.getString(field.getSourceField()));
if (StringUtils.isNotBlank(value)) {
buildDataMap.put(field.getTargetField(), value);
}
}
RecruitRecordSet.insertData(buildDataMap, targetDetailTable);
}
}
}
return null;
}
@Override
public Map<String, Object> updateOfferStatus(Map<String, Object> params) {
Map<String, Object> returnMap = new HashMap<>(3);
String status = Util.null2String(params.get("status"));
String uuid = Util.null2String(params.get("uuid"));
returnMap.put("type", "error");
returnMap.put("message", "反馈失败");
if (StringUtils.isBlank(status) || StringUtils.isBlank(uuid)) {
returnMap.put("description", "反馈失败,请直接点击邮件中的链接地址访问,请勿修改链接内容。");
return returnMap;
}
RecordSet rs = new RecordSet();
rs.executeQuery("select fkjg from uf_recruit_lytzs where modeuuid = ? ", uuid);
String fkjg = "";
if (rs.next()) {
fkjg = rs.getString("fkjg");
} else {
returnMap.put("description", "反馈失败offer信息有误请联系相应HR确认");
return returnMap;
}
if (StringUtils.isNotBlank(fkjg) && !"0".equals(fkjg)) {
returnMap.put("description", "您已成功反馈,请勿重复反馈。");
return returnMap;
}
if ("1".equals(status)) {
returnMap.put("type", "success");
returnMap.put("message", "已接受offer");
returnMap.put("description", "您已接受offer期待您的加入请按期准备报道如有问题可以联系相应HR");
rs.executeUpdate("update uf_recruit_lytzs set fkjg = ? where modeuuid = ? ", status, uuid);
} else if ("2".equals(status)) {
returnMap.put("type", "info");
returnMap.put("message", "已拒绝offer");
returnMap.put("description", "您已拒绝offer感谢您的应聘。希望您能够找到真正适合自己的工作。");
rs.executeUpdate("update uf_recruit_lytzs set fkjg = ? where modeuuid = ? ", status, uuid);
}
return returnMap;
}
/**
* 获取配置的需要同步的字段集合
*
* @param mainTableId
* @return
*/
private static List<SyncTableField> getSyncTableFields(String mainTableId) {
RecordSet rs = new RecordSet();
rs.executeQuery("select * from uf_recruit_table_dt1 where mainid = ? ", mainTableId);
List<SyncTableField> fields = new ArrayList<>();
while (rs.next()) {
fields.add(SyncTableField.builder().sourceField(rs.getString("source_field")).targetField(rs.getString("target_field")).build());
}
if (CollectionUtils.isEmpty(fields)) {
throw new CustomizeRunTimeException("数据同步配置异常,请检查配置");
}
return fields;
}
}