新增分配任务责任人领导的脚本逻辑
在流程定义中,扩展了任务分配规则,包括新的脚本LEADER_X7,该脚本被设计为分配任务给入职部门的领导。此更新涉及修改BpmTaskRuleScriptEnum,以支持新的任务分配需求,并实现相应的脚本处理类BpmTaskEntryLeaderScript来计算任务的候选用户。
This commit is contained in:
parent
983b743ba9
commit
7ac6fbade0
@ -20,7 +20,8 @@ public enum BpmTaskRuleScriptEnum {
|
||||
LEADER_X3(22L, "流程发起人的三级领导"),
|
||||
LEADER_X4(23L, "审批人的一级领导"),
|
||||
LEADER_X5(24L, "调岗部门领导"),
|
||||
LEADER_X6(25L, "分配任务的责任人");
|
||||
LEADER_X6(25L, "分配任务的责任人"),
|
||||
LEADER_X7(26L, "入职部门领导");
|
||||
|
||||
/**
|
||||
* 脚本编号
|
||||
|
@ -0,0 +1,69 @@
|
||||
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.BpmOAEntryDO;
|
||||
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.BpmOAEntryService;
|
||||
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 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;
|
||||
|
||||
public class BpmTaskEntryLeaderScript implements BpmTaskAssignScript {
|
||||
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
@Resource
|
||||
private BpmOAEntryService entryService;
|
||||
|
||||
@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 取到调岗流程表单
|
||||
BpmOAEntryDO entryDO = entryService.getEntryByProcessInstanceId(processInstance.getProcessInstanceId());
|
||||
//获取调岗部门ID
|
||||
Long deptId = entryDO.getEntryDeptId();
|
||||
|
||||
//根据部门ID 获取部门信息
|
||||
DeptRespDTO dept = deptApi.getDept(deptId).getCheckedData();
|
||||
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_X7;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user