新增薪酬调整任务分配脚本和相关功能
- 新增 BpmTaskSalaryLeaderScript 类,用于处理薪酬调整任务的分配 - 在 BpmTaskRuleScriptEnum 枚举中添加 LEADER_X8项 - 修改 BpmOASalaryAdjustmentServiceImpl 以支持薪酬调整流程 - 更新 BpmTaskEntryLeaderScript 以修复部门层级判断逻辑
This commit is contained in:
parent
40819c8d6f
commit
ca9b6b6d28
@ -21,7 +21,8 @@ public enum BpmTaskRuleScriptEnum {
|
|||||||
LEADER_X4(23L, "审批人的一级领导"),
|
LEADER_X4(23L, "审批人的一级领导"),
|
||||||
LEADER_X5(24L, "调岗部门领导"),
|
LEADER_X5(24L, "调岗部门领导"),
|
||||||
LEADER_X6(25L, "分配任务的责任人"),
|
LEADER_X6(25L, "分配任务的责任人"),
|
||||||
LEADER_X7(26L, "入职部门领导");
|
LEADER_X7(26L, "入职部门领导"),
|
||||||
|
LEADER_X8(27L, "调薪部门领导");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 脚本编号
|
* 脚本编号
|
||||||
|
@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|||||||
import org.flowable.engine.delegate.DelegateExecution;
|
import org.flowable.engine.delegate.DelegateExecution;
|
||||||
import org.flowable.engine.runtime.ProcessInstance;
|
import org.flowable.engine.runtime.ProcessInstance;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -21,11 +22,14 @@ import java.util.Set;
|
|||||||
import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet;
|
import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet;
|
||||||
import static java.util.Collections.emptySet;
|
import static java.util.Collections.emptySet;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class BpmTaskEntryLeaderScript implements BpmTaskAssignScript {
|
public class BpmTaskEntryLeaderScript implements BpmTaskAssignScript {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
@Lazy // 解决循环依赖
|
||||||
private DeptApi deptApi;
|
private DeptApi deptApi;
|
||||||
@Resource
|
@Resource
|
||||||
|
@Lazy // 解决循环依赖
|
||||||
private BpmOAEntryService entryService;
|
private BpmOAEntryService entryService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@ -47,7 +51,7 @@ public class BpmTaskEntryLeaderScript implements BpmTaskAssignScript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//根据流程实例ID 取到调岗流程表单
|
//根据流程实例ID 取到调岗流程表单
|
||||||
BpmOAEntryDO entryDO = entryService.getEntryByProcessInstanceId(processInstance.getProcessInstanceId());
|
BpmOAEntryDO entryDO = entryService.getEntry(Long.valueOf(processInstance.getBusinessKey()));
|
||||||
//获取调岗部门ID
|
//获取调岗部门ID
|
||||||
Long deptId = entryDO.getEntryDeptId();
|
Long deptId = entryDO.getEntryDeptId();
|
||||||
|
|
||||||
@ -56,7 +60,7 @@ public class BpmTaskEntryLeaderScript implements BpmTaskAssignScript {
|
|||||||
if (dept.getLevel() > 3) { //判断部门层级
|
if (dept.getLevel() > 3) { //判断部门层级
|
||||||
|
|
||||||
String[] flag = dept.getFlag().split("-");
|
String[] flag = dept.getFlag().split("-");
|
||||||
dept = deptApi.getDept(Long.valueOf(flag[2])).getCheckedData();
|
dept = deptApi.getDept(Long.valueOf(flag[3])).getCheckedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
return dept.getLeaderUserId() != null ? asSet(dept.getLeaderUserId()) : emptySet();
|
return dept.getLeaderUserId() != null ? asSet(dept.getLeaderUserId()) : emptySet();
|
||||||
|
@ -0,0 +1,75 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOASalaryAdjustmentDO;
|
||||||
|
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum;
|
||||||
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.oa.BpmOASalaryAdjustmentService;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||||
|
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
|
||||||
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||||
|
import org.flowable.engine.delegate.DelegateExecution;
|
||||||
|
import org.flowable.engine.runtime.ProcessInstance;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet;
|
||||||
|
import static java.util.Collections.emptySet;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class BpmTaskSalaryLeaderScript implements BpmTaskAssignScript {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DeptApi deptApi;
|
||||||
|
@Resource
|
||||||
|
@Lazy // 解决循环依赖
|
||||||
|
private BpmOASalaryAdjustmentService salaryAdjustmentService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
@Lazy // 解决循环依赖
|
||||||
|
private BpmProcessInstanceService bpmProcessInstanceService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
@Lazy // 解决循环依赖
|
||||||
|
private BpmTaskService bpmTaskService ;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Long> calculateTaskCandidateUsers(DelegateExecution execution) {
|
||||||
|
|
||||||
|
// 获得发起人
|
||||||
|
ProcessInstance processInstance = bpmProcessInstanceService.getProcessInstance(execution.getProcessInstanceId());
|
||||||
|
List<BpmTaskRespVO> bpmTaskRespVOs = bpmTaskService.getTaskListByProcessInstanceId(processInstance.getProcessInstanceId());
|
||||||
|
if (CollUtil.isEmpty(bpmTaskRespVOs)) {
|
||||||
|
return emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据流程实例ID 取到调岗流程表单
|
||||||
|
BpmOASalaryAdjustmentDO salaryAdjustmentDO = salaryAdjustmentService.getSalaryAdjustment(Long.valueOf(processInstance.getBusinessKey()));
|
||||||
|
//获取调岗部门ID
|
||||||
|
Long deptId = salaryAdjustmentDO.getAdjustmentDeptId();
|
||||||
|
|
||||||
|
//根据部门ID 获取部门信息
|
||||||
|
DeptRespDTO dept = deptApi.getDept(deptId).getCheckedData();
|
||||||
|
// 调整人为部门负责人时
|
||||||
|
if (dept.getLeaderUserId().equals(salaryAdjustmentDO.getAdjustmentUserId())) {
|
||||||
|
dept = deptApi.getDept(dept.getParentId()).getCheckedData();
|
||||||
|
}else if (dept.getLevel() > 3) { //判断部门层级
|
||||||
|
|
||||||
|
String[] flag = dept.getFlag().split("-");
|
||||||
|
dept = deptApi.getDept(Long.valueOf(flag[3])).getCheckedData();
|
||||||
|
}
|
||||||
|
|
||||||
|
return dept.getLeaderUserId() != null ? asSet(dept.getLeaderUserId()) : emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BpmTaskRuleScriptEnum getEnum() {
|
||||||
|
return BpmTaskRuleScriptEnum.LEADER_X8;
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,11 @@ import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOASalaryAdjustmentDO;
|
|||||||
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOASalaryAdjustmentMapper;
|
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOASalaryAdjustmentMapper;
|
||||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||||
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
|
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
|
||||||
|
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||||
|
import io.netty.util.internal.StringUtil;
|
||||||
|
import org.mapstruct.ap.internal.util.Strings;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
@ -21,7 +26,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
|
|||||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_SALARY_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_SALARY_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OA 薪资付款申请 Service 实现类
|
* OA 薪资调整申请 Service 实现类
|
||||||
*
|
*
|
||||||
* @author 符溶馨
|
* @author 符溶馨
|
||||||
*/
|
*/
|
||||||
@ -30,7 +35,7 @@ import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_SALARY_NOT
|
|||||||
public class BpmOASalaryAdjustmentServiceImpl extends BpmOABaseService implements BpmOASalaryAdjustmentService{
|
public class BpmOASalaryAdjustmentServiceImpl extends BpmOABaseService implements BpmOASalaryAdjustmentService{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OA 薪资付款对应的流程定义 KEY
|
* OA 薪资调整对应的流程定义 KEY
|
||||||
*/
|
*/
|
||||||
public static final String PROCESS_KEY = "oa_salary_adjustment_2";
|
public static final String PROCESS_KEY = "oa_salary_adjustment_2";
|
||||||
|
|
||||||
@ -43,16 +48,39 @@ public class BpmOASalaryAdjustmentServiceImpl extends BpmOABaseService implement
|
|||||||
@Resource
|
@Resource
|
||||||
private BpmHistoryProcessInstanceService historyProcessInstanceService;
|
private BpmHistoryProcessInstanceService historyProcessInstanceService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DeptApi deptApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ConfigApi configApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createSalaryAdjustment(Long userId, BpmOASalaryAdjustmentCreateReqVO createReqVO) {
|
public Long createSalaryAdjustment(Long userId, BpmOASalaryAdjustmentCreateReqVO createReqVO) {
|
||||||
|
|
||||||
//插入OA 薪资付款申请
|
//插入OA 薪资调整申请
|
||||||
BpmOASalaryAdjustmentDO salary = BpmOASalaryAdjustmentConvert.INSTANCE.convert(createReqVO).setUserId(userId)
|
BpmOASalaryAdjustmentDO salary = BpmOASalaryAdjustmentConvert.INSTANCE.convert(createReqVO).setUserId(userId)
|
||||||
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
|
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
|
||||||
salaryMapper.insert(salary) ;
|
salaryMapper.insert(salary) ;
|
||||||
|
|
||||||
// 发起 BPM 流程
|
// 获取调整人所在部门信息
|
||||||
|
DeptRespDTO deptRespDTO = deptApi.getDept(createReqVO.getAdjustmentDeptId()).getCheckedData();
|
||||||
|
|
||||||
|
// 配置变量 调整人部门flag
|
||||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||||
|
processInstanceVariables.put("company_dept_flag", deptRespDTO.getFlag());
|
||||||
|
|
||||||
|
if (deptRespDTO.getLevel() == 2 && deptRespDTO.getLeaderUserId().equals(createReqVO.getAdjustmentUserId())) {
|
||||||
|
processInstanceVariables.put("is_leader", 1);
|
||||||
|
}else {
|
||||||
|
processInstanceVariables.put("is_leader", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询配置文件,获取行政部门编号
|
||||||
|
String hrDeptId = configApi.getConfigKey("system_hr_dept").getCheckedData();
|
||||||
|
if (Strings.isNotEmpty(hrDeptId)) {
|
||||||
|
processInstanceVariables.put("hr_dept", hrDeptId);
|
||||||
|
}
|
||||||
|
// 发起 BPM 流程
|
||||||
String processInstanceId = processInstanceApi.createProcessInstance(userId,
|
String processInstanceId = processInstanceApi.createProcessInstance(userId,
|
||||||
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||||
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(salary.getId()))).getCheckedData();
|
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(salary.getId()))).getCheckedData();
|
||||||
|
Loading…
Reference in New Issue
Block a user