招聘阶段 同步功能开发

This commit is contained in:
dxfeng 2024-02-29 17:59:17 +08:00
parent 63f8e16adb
commit a2bc9fb687
9 changed files with 489 additions and 6 deletions

View File

@ -84,14 +84,12 @@ public class RecruitRecordSet {
public static void updateDataById(Map<String, Object> dataMap, String tableName) {
List<String> fieldList = new ArrayList<>();
List<Object> dataList = new ArrayList<>();
List<String> paramList = new ArrayList<>();
String id = Util.null2String(dataMap.get("id"));
dataMap.remove("id");
dataMap.forEach((key, value) -> {
fieldList.add(key + " = ? ");
dataList.add(value);
paramList.add("?");
});
dataList.add(id);
String updateSql = "update " + tableName + " set " + StringUtils.join(fieldList, ",") + " where id = ? ";
@ -102,6 +100,20 @@ public class RecruitRecordSet {
}
}
/**
* 删除数据
*
* @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());
}
}
/**
* 构建建模表基本数据
*

View File

@ -10,6 +10,7 @@ import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
@ -43,4 +44,13 @@ public class RecruitFlowController {
Map<String, Object> params = ParamUtil.request2Map(request);
return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getRecruitFlowWrapper(user)::getRecruitStepList, params);
}
@POST
@Path("/syncRecruitStepInfo")
@Produces(MediaType.APPLICATION_JSON)
public String syncRecruitStepInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> params = ParamUtil.request2Map(request);
return new ResponseResult<Map<String, Object>, Map<String, Object>>(user).run(getRecruitFlowWrapper(user)::syncRecruitStepInfo, params);
}
}

View File

@ -0,0 +1,42 @@
package com.engine.recruit.entity.recruitflow.po;
import lombok.*;
import java.util.Objects;
/**
* @author:dxfeng
* @createTime: 2024/02/29
* @version: 1.0
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class RecruitStepDt1 {
private String id;
private String mainid;
private String czan;
private String zdyxsmc;
private String tzymdz;
private String sfqy;
private String tzymbt;
private String zssx;
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
RecruitStepDt1 stepDt1 = (RecruitStepDt1) o;
return czan.equals(stepDt1.czan);
}
@Override
public int hashCode() {
return Objects.hash(czan);
}
}

View File

@ -0,0 +1,23 @@
package com.engine.recruit.entity.recruitflow.po;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author:dxfeng
* @createTime: 2024/02/29
* @version: 1.0
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class RecruitStepDt2 {
private String id;
private String mainid;
private String ymbt;
private String ymdz;
private String zssx;
}

View File

@ -26,4 +26,13 @@ public interface RecruitFlowService {
* @return 招聘阶段
*/
Map<String, Object> getRecruitStepList(Map<String, Object> param);
/**
* 同步招聘阶段
*
* @param param
* @return
*/
Map<String, Object> syncRecruitStepInfo(Map<String, Object> param);
}

View File

@ -73,7 +73,9 @@ public class InitRecruitDataServiceImpl extends Service implements InitRecruitDa
searchCodeMap.put("招聘需求管理", "b129634bf72d46b8bed0291f84efd2e0");
searchCodeMap.put("招聘职位", "c024e527c964437bb568bebbb48d89a5");
searchCodeMap.put("应聘者", "1d48211cd1634b19bdc6f7df40cd1337");
searchCodeMap.put("筛选反馈", "b746e3cf80454289a3ade2b17147e297");
//searchCodeMap.put("筛选反馈", "b746e3cf80454289a3ade2b17147e297");
// TODO 改造为筛选反馈树
searchCodeMap.put("筛选反馈", "669a72259c0c47e49a97f5b68692ed34");
searchCodeMap.put("笔试结果", "1b56a7492fb84f2b9e5ae022fde333f0");
searchCodeMap.put("面试", "496ecc32a87045888f224ad3151e635b");
searchCodeMap.put("薪酬谈判", "ffe1bafcef5942f5853e68b76e5098d2");

View File

@ -1,12 +1,14 @@
package com.engine.recruit.service.impl;
import cn.hutool.core.convert.Convert;
import com.engine.core.impl.Service;
import com.engine.recruit.entity.recruitflow.po.RecruitButton;
import com.engine.recruit.entity.recruitflow.po.RecruitStepPo;
import com.engine.recruit.entity.recruitflow.po.RecruitTabPo;
import com.engine.recruit.conn.RecruitDataMap;
import com.engine.recruit.conn.RecruitRecordSet;
import com.engine.recruit.entity.recruitflow.po.*;
import com.engine.recruit.exception.CustomizeRunTimeException;
import com.engine.recruit.service.RecruitFlowService;
import com.engine.recruit.util.RecruitFlowUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.Util;
@ -15,6 +17,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author:dxfeng
@ -127,4 +130,238 @@ public class RecruitFlowServiceImpl extends Service implements RecruitFlowServic
returnMap.put("currentStageId", currentStageId);
return returnMap;
}
@Override
public Map<String, Object> syncRecruitStepInfo(Map<String, Object> param) {
String stepId = Util.null2String(param.get("stepId"));
String recruitFlowId = Util.null2String(param.get("recruitFlowId"));
String checkedValue = Util.null2String(param.get("checkedValue"));
if (StringUtils.isBlank(stepId)) {
throw new CustomizeRunTimeException("未获取到所选招聘阶段,请刷新后重试");
}
if (StringUtils.isBlank(recruitFlowId)) {
throw new CustomizeRunTimeException("同步流程为空,请选择同步流程");
}
if (StringUtils.isBlank(checkedValue)) {
throw new CustomizeRunTimeException("请选择同步选项");
}
// 判断该流程是否有该阶段没有该阶段的不做操作
String flowStepId = getFlowStepId(stepId, recruitFlowId);
if (StringUtils.isBlank(flowStepId)) {
throw new CustomizeRunTimeException("所选流程不具备当前招聘阶段,同步失败");
}
switch (checkedValue) {
case "syncAdd":
syncAdd(stepId, flowStepId);
break;
case "syncOrder":
syncOrder(stepId, flowStepId);
break;
case "syncAll":
syncAll(stepId, flowStepId);
break;
case "syncTab":
syncTab(stepId, flowStepId);
break;
default:
throw new CustomizeRunTimeException("未识别的同步方式");
}
return null;
}
/**
* 同步新增操作
* 直接将缺失的操作按钮追加在原有按钮后方
*
* @param stepId
* @param flowStepId
*/
private void syncAdd(String stepId, String flowStepId) {
List<RecruitStepDt1> stepDt1List = getStepDt1List(stepId);
List<RecruitStepDt1> flowStepDt1List = getStepDt1List(flowStepId);
// 比较差异,只保留flowStepDt1List中没有的元素
List<RecruitStepDt1> result = stepDt1List.stream()
.filter(item -> !flowStepDt1List.contains(item))
.collect(Collectors.toList());
// 元素追加
Integer order = 0;
if (CollectionUtils.isNotEmpty(flowStepDt1List)) {
String zssx = flowStepDt1List.get(flowStepDt1List.size() - 1).getZssx();
if (StringUtils.isNotBlank(zssx)) {
order = Convert.toInt(zssx);
}
}
for (RecruitStepDt1 stepDt1 : result) {
order += 10;
RecruitDataMap<Object> dataMap = new RecruitDataMap<>();
dataMap.put("mainid", flowStepId);
dataMap.put("czan", stepDt1.getCzan());
dataMap.put("zdyxsmc", stepDt1.getZdyxsmc());
dataMap.put("tzymdz", stepDt1.getTzymdz());
dataMap.put("sfqy", stepDt1.getSfqy());
dataMap.put("tzymbt", stepDt1.getTzymbt());
dataMap.put("zssx", order.toString());
RecruitRecordSet.insertData(dataMap, "uf_jcl_zpjdsz_dt1");
}
}
/**
* 同步操作顺序
* 比较差异按顺序插空进入
*
* @param stepId
* @param flowStepId
*/
private void syncOrder(String stepId, String flowStepId) {
List<RecruitStepDt1> stepDt1List = getStepDt1List(stepId);
List<RecruitStepDt1> flowStepDt1List = getStepDt1List(flowStepId);
// 只保留stepDt1List中相同的元素
flowStepDt1List.retainAll(stepDt1List);
int index = 0;
for (int i = 0; i < stepDt1List.size(); i++) {
RecruitStepDt1 character = stepDt1List.get(i);
if (flowStepDt1List.contains(character)) {
RecruitStepDt1 remove = flowStepDt1List.get(index++);
stepDt1List.set(i, remove);
}
}
// 调整展示顺序
int order = 0;
for (RecruitStepDt1 stepDt1 : stepDt1List) {
RecruitDataMap<Object> dataMap = new RecruitDataMap<>();
dataMap.put("zssx", order += 10);
dataMap.put("id", stepDt1.getId());
RecruitRecordSet.updateDataById(dataMap, "uf_jcl_zpjdsz_dt1");
}
}
/**
* 同步所有操作覆盖替换
*
* @param stepId
* @param flowStepId
*/
private void syncAll(String stepId, String flowStepId) {
List<RecruitStepDt1> stepDt1List = getStepDt1List(stepId);
// 删除原有的数据
String deleteSql = "delete from uf_jcl_zpjdsz_dt1 where mainid = " + flowStepId;
RecruitRecordSet.deleteData(deleteSql);
for (RecruitStepDt1 stepDt1 : stepDt1List) {
RecruitDataMap<Object> dataMap = new RecruitDataMap<>();
dataMap.put("mainid", flowStepId);
dataMap.put("czan", stepDt1.getCzan());
dataMap.put("zdyxsmc", stepDt1.getZdyxsmc());
dataMap.put("tzymdz", stepDt1.getTzymdz());
dataMap.put("sfqy", stepDt1.getSfqy());
dataMap.put("tzymbt", stepDt1.getTzymbt());
dataMap.put("zssx", stepDt1.getZssx());
RecruitRecordSet.insertData(dataMap, "uf_jcl_zpjdsz_dt1");
}
}
/**
* 同步卡片展示tab页面
*
* @param stepId
* @param flowStepId
*/
private void syncTab(String stepId, String flowStepId) {
List<RecruitStepDt2> stepDt2List = getStepDt2List(stepId);
// 删除原有的数据
String deleteSql = "delete from uf_jcl_zpjdsz_dt2 where mainid = " + flowStepId;
RecruitRecordSet.deleteData(deleteSql);
int order = 0;
for (RecruitStepDt2 stepDt2 : stepDt2List) {
order += 10;
RecruitDataMap<Object> dataMap = new RecruitDataMap<>();
dataMap.put("mainid", flowStepId);
dataMap.put("ymbt", stepDt2.getYmbt());
dataMap.put("ymdz", stepDt2.getYmdz());
dataMap.put("zssx", Integer.toString(order));
RecruitRecordSet.insertData(dataMap, "uf_jcl_zpjdsz_dt2");
}
}
/**
* 获取流程对应的当前阶段ID
*
* @param stepId
* @param recruitFlowId
* @return
*/
private String getFlowStepId(String stepId, String recruitFlowId) {
RecordSet rs = new RecordSet();
rs.executeQuery("select id from uf_jcl_zpjdsz where zplc = ? and zpjd = ?", recruitFlowId, stepId);
if (rs.next()) {
return rs.getString("id");
}
return "";
}
/**
* 根据阶段ID获取该阶段所有的按钮配置集合
*
* @param stepId
* @return
*/
private List<RecruitStepDt1> getStepDt1List(String stepId) {
List<RecruitStepDt1> list = new ArrayList<>();
RecordSet rs = new RecordSet();
rs.executeQuery("select * from uf_jcl_zpjdsz_dt1 where mainid = ? order by zssx", stepId);
while (rs.next()) {
RecruitStepDt1 stepDt1 = RecruitStepDt1.builder()
.id(rs.getString("id"))
.mainid(rs.getString("mainid"))
.czan(rs.getString("czan"))
.zdyxsmc(rs.getString("zdyxsmc"))
.tzymdz(rs.getString("tzymdz"))
.sfqy(rs.getString("sfqy"))
.tzymbt(rs.getString("tzymbt"))
.zssx(rs.getString("zssx"))
.build();
list.add(stepDt1);
}
return list;
}
/**
* 根据阶段ID获取该阶段所有的tab页面配置集合
*
* @param stepId
* @return
*/
private List<RecruitStepDt2> getStepDt2List(String stepId) {
List<RecruitStepDt2> list = new ArrayList<>();
RecordSet rs = new RecordSet();
rs.executeQuery("select * from uf_jcl_zpjdsz_dt2 where mainid = ? order by zssx", stepId);
while (rs.next()) {
RecruitStepDt2 stepDt1 = RecruitStepDt2.builder()
.id(rs.getString("id"))
.mainid(rs.getString("mainid"))
.ymbt(rs.getString("ymbt"))
.ymdz(rs.getString("ymdz"))
.zssx(rs.getString("zssx"))
.build();
list.add(stepDt1);
}
return list;
}
}

View File

@ -25,4 +25,8 @@ public class RecruitFlowWrapper extends Service {
public Map<String, Object> getRecruitStepList(Map<String, Object> param) {
return getRecruitFlowService(user).getRecruitStepList(param);
}
public Map<String, Object> syncRecruitStepInfo(Map<String, Object> param) {
return getRecruitFlowService(user).syncRecruitStepInfo(param);
}
}

View File

@ -0,0 +1,144 @@
package weaver.interfaces.gsjrkg.action;
import com.alibaba.fastjson.JSON;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.MainTableInfo;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import java.util.*;
/**
* @Description: 同步证书到人员卡片个人信息
* @author:dxfeng
* @createTime: 2023/02/20
* @version: 1.0
*/
public class SyncCertificateAction implements Action {
/**
* 建模表表名
*/
private String modeTableName;
/**
* 参数名称建模表字段名人员表字段名
*/
private String params;
private String resourceFieldGroup;
@Override
public String execute(RequestInfo requestInfo) {
BaseBean baseBean = new BaseBean();
if (StringUtils.isBlank(params)) {
requestInfo.getRequestManager().setMessagecontent("自定义接口参数值配置错误");
return Action.FAILURE_AND_CONTINUE;
}
if (StringUtils.isBlank(resourceFieldGroup)) {
// -1:基本信息,1:个人信息,3:工作信息
resourceFieldGroup = "1";
}
Map<String, String> fieldMap = new HashMap<>();
String[] fieldsArray = params.split(";");
for (String fields : fieldsArray) {
String[] field = fields.split(":");
if (field.length == 2) {
fieldMap.put(field[0], field[1]);
}
}
if (fieldMap.size() != fieldsArray.length) {
requestInfo.getRequestManager().setMessagecontent("自定义接口参数值格式错误,请检查");
return Action.FAILURE_AND_CONTINUE;
}
baseBean.writeLog("fieldMap==" + JSON.toJSONString(fieldMap));
Set<String> modeFields = fieldMap.keySet();
Map<String, Set<String>> modeMap = new HashMap<>();
RecordSet rs = new RecordSet();
String resourceId = "";
MainTableInfo mainTableInfo = requestInfo.getMainTableInfo();
Property[] property = mainTableInfo.getProperty();
for (Property item : property) {
String name = item.getName();
String value = Util.null2String(item.getValue());
if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) {
if ("xm".equals(name)) {
resourceId = value;
}
}
}
// 查询当前人员的所有数据
StringBuilder sqlBuilder = new StringBuilder("select ").append(StringUtils.join(modeFields, ",")).append(" from ").append(modeTableName).append(" where xm = ").append(resourceId).append(" order by id");
baseBean.writeLog("selectSql===" + sqlBuilder);
rs.executeQuery(sqlBuilder.toString());
while (rs.next()) {
appendIds(modeFields, rs, modeMap);
}
baseBean.writeLog("modeMap===" + JSON.toJSONString(modeMap));
// 判断有无数据没有的话插入数据
sqlBuilder = new StringBuilder("SELECT id FROM CUS_FIELDDATA where scope ='HrmCustomFieldByInfoType' and scopeid = '").append(resourceFieldGroup).append("' and id =? ");
rs.executeQuery(sqlBuilder.toString(), resourceId);
if (!rs.next()) {
// 插入人员信息数据
rs.executeUpdate("insert into cus_fielddata (scope,scopeid,id) values ('HrmCustomFieldByInfoType','" + resourceFieldGroup + "',?)", resourceId);
}
// 组装更新SQL语句
sqlBuilder = new StringBuilder("update cus_fielddata set ");
for (Map.Entry<String, String> entry : fieldMap.entrySet()) {
Set<String> valueSet = modeMap.get(entry.getKey());
String values = CollectionUtils.isEmpty(valueSet) ? "" : StringUtils.join(valueSet, ",");
sqlBuilder.append(" ").append(entry.getValue()).append(" = '").append(values).append("',");
}
sqlBuilder.deleteCharAt(sqlBuilder.length() - 1);
sqlBuilder.append(" where scope ='HrmCustomFieldByInfoType' and scopeid = ").append(resourceFieldGroup).append(" and id = ").append(resourceId);
baseBean.writeLog("updateSql===" + sqlBuilder);
rs.executeUpdate(sqlBuilder.toString());
return Action.SUCCESS;
}
private void appendIds(Set<String> modeFields, RecordSet rs, Map<String, Set<String>> modeMap) {
BaseBean baseBean = new BaseBean();
for (String modeField : modeFields) {
String ids = rs.getString(modeField);
baseBean.writeLog("modeField==【" + modeField + "】,getString==【" + ids + "");
if (StringUtils.isBlank(ids)) {
continue;
}
if (CollectionUtils.isEmpty(modeMap.get(modeField))) {
modeMap.put(modeField, new HashSet<>());
}
modeMap.get(modeField).addAll(Arrays.asList(ids.split(",")));
}
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
public String getModeTableName() {
return modeTableName;
}
public void setModeTableName(String modeTableName) {
this.modeTableName = modeTableName;
}
public String getResourceFieldGroup() {
return resourceFieldGroup;
}
public void setResourceFieldGroup(String resourceFieldGroup) {
this.resourceFieldGroup = resourceFieldGroup;
}
}