mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
BPM:新增顺序会签、或签的能力
This commit is contained in:
parent
f5f73adcbb
commit
a1defeb48a
@ -6,6 +6,7 @@ import org.flowable.bpmn.model.Activity;
|
|||||||
import org.flowable.bpmn.model.UserTask;
|
import org.flowable.bpmn.model.UserTask;
|
||||||
import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior;
|
import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior;
|
||||||
import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior;
|
import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior;
|
||||||
|
import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior;
|
||||||
import org.flowable.engine.impl.bpmn.behavior.UserTaskActivityBehavior;
|
import org.flowable.engine.impl.bpmn.behavior.UserTaskActivityBehavior;
|
||||||
import org.flowable.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFactory;
|
import org.flowable.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFactory;
|
||||||
|
|
||||||
@ -28,11 +29,16 @@ public class BpmActivityBehaviorFactory extends DefaultActivityBehaviorFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParallelMultiInstanceBehavior createParallelMultiInstanceBehavior(Activity activity,
|
public ParallelMultiInstanceBehavior createParallelMultiInstanceBehavior(Activity activity,
|
||||||
AbstractBpmnActivityBehavior innerActivityBehavior) {
|
AbstractBpmnActivityBehavior behavior) {
|
||||||
return new BpmParallelMultiInstanceBehavior(activity, innerActivityBehavior)
|
return new BpmParallelMultiInstanceBehavior(activity, behavior)
|
||||||
.setTaskCandidateInvoker(taskCandidateInvoker);
|
.setTaskCandidateInvoker(taskCandidateInvoker);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @ke:SequentialMultiInstanceBehavior 这个抽空也可以看看
|
@Override
|
||||||
|
public SequentialMultiInstanceBehavior createSequentialMultiInstanceBehavior(Activity activity,
|
||||||
|
AbstractBpmnActivityBehavior behavior) {
|
||||||
|
return new BpmSequentialMultiInstanceBehavior(activity, behavior)
|
||||||
|
.setTaskCandidateInvoker(taskCandidateInvoker);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior;
|
|||||||
import cn.iocoder.yudao.framework.flowable.core.util.FlowableUtils;
|
import cn.iocoder.yudao.framework.flowable.core.util.FlowableUtils;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.flowable.bpmn.model.Activity;
|
import org.flowable.bpmn.model.Activity;
|
||||||
import org.flowable.engine.delegate.DelegateExecution;
|
import org.flowable.engine.delegate.DelegateExecution;
|
||||||
import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior;
|
import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior;
|
||||||
@ -17,12 +16,11 @@ import java.util.Set;
|
|||||||
* 第二步,将【多个】任务候选人们,设置到 DelegateExecution 的 collectionVariable 变量中,以便 BpmUserTaskActivityBehavior 使用它
|
* 第二步,将【多个】任务候选人们,设置到 DelegateExecution 的 collectionVariable 变量中,以便 BpmUserTaskActivityBehavior 使用它
|
||||||
*
|
*
|
||||||
* @author kemengkai
|
* @author kemengkai
|
||||||
* @date 2022-04-21 16:57
|
* @since 2022-04-21 16:57
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Setter
|
||||||
public class BpmParallelMultiInstanceBehavior extends ParallelMultiInstanceBehavior {
|
public class BpmParallelMultiInstanceBehavior extends ParallelMultiInstanceBehavior {
|
||||||
|
|
||||||
@Setter
|
|
||||||
private BpmTaskCandidateInvoker taskCandidateInvoker;
|
private BpmTaskCandidateInvoker taskCandidateInvoker;
|
||||||
|
|
||||||
public BpmParallelMultiInstanceBehavior(Activity activity,
|
public BpmParallelMultiInstanceBehavior(Activity activity,
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
package cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.flowable.core.util.FlowableUtils;
|
||||||
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.flowable.bpmn.model.Activity;
|
||||||
|
import org.flowable.engine.delegate.DelegateExecution;
|
||||||
|
import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior;
|
||||||
|
import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior;
|
||||||
|
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义的【串行】的【多个】流程任务的 assignee 负责人的分配
|
||||||
|
*
|
||||||
|
* 本质上,实现和 {@link BpmParallelMultiInstanceBehavior} 一样,只是继承的类不一样
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
public class BpmSequentialMultiInstanceBehavior extends SequentialMultiInstanceBehavior {
|
||||||
|
|
||||||
|
private BpmTaskCandidateInvoker taskCandidateInvoker;
|
||||||
|
|
||||||
|
public BpmSequentialMultiInstanceBehavior(Activity activity, AbstractBpmnActivityBehavior innerActivityBehavior) {
|
||||||
|
super(activity, innerActivityBehavior);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 逻辑和 {@link BpmParallelMultiInstanceBehavior#resolveNrOfInstances(DelegateExecution)} 类似
|
||||||
|
*
|
||||||
|
* 差异的点:是在【第二步】的时候,需要返回 LinkedHashSet 集合!因为它需要有序!
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected int resolveNrOfInstances(DelegateExecution execution) {
|
||||||
|
// 第一步,设置 collectionVariable 和 CollectionVariable
|
||||||
|
// 从 execution.getVariable() 读取所有任务处理人的 key
|
||||||
|
super.collectionExpression = null; // collectionExpression 和 collectionVariable 是互斥的
|
||||||
|
super.collectionVariable = FlowableUtils.formatCollectionVariable(execution.getCurrentActivityId());
|
||||||
|
// 从 execution.getVariable() 读取当前所有任务处理的人的 key
|
||||||
|
super.collectionElementVariable = FlowableUtils.formatCollectionElementVariable(execution.getCurrentActivityId());
|
||||||
|
|
||||||
|
// 第二步,获取任务的所有处理人
|
||||||
|
Set<Long> assigneeUserIds = new LinkedHashSet<>(taskCandidateInvoker.calculateUsers(execution)); // 保证有序!!!
|
||||||
|
execution.setVariable(super.collectionVariable, assigneeUserIds);
|
||||||
|
return assigneeUserIds.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -47,7 +47,8 @@ public class BpmUserTaskActivityBehavior extends UserTaskActivityBehavior {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Long calculateTaskCandidateUsers(DelegateExecution execution) {
|
private Long calculateTaskCandidateUsers(DelegateExecution execution) {
|
||||||
// 情况一,如果是多实例的任务,例如说会签、或签等情况,则从 Variable 中获取。它的任务处理人在 BpmParallelMultiInstanceBehavior 中已经被分配了
|
// 情况一,如果是多实例的任务,例如说会签、或签等情况,则从 Variable 中获取。
|
||||||
|
// 顺序审批可见 BpmSequentialMultiInstanceBehavior,并发审批可见 BpmSequentialMultiInstanceBehavior
|
||||||
if (super.multiInstanceActivityBehavior != null) {
|
if (super.multiInstanceActivityBehavior != null) {
|
||||||
return execution.getVariable(super.multiInstanceActivityBehavior.getCollectionElementVariable(), Long.class);
|
return execution.getVariable(super.multiInstanceActivityBehavior.getCollectionElementVariable(), Long.class);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user