新增支持驳回重新审批策略重新发起创建事件

This commit is contained in:
hubin 2025-03-04 22:05:16 +08:00
parent 4b4188abe0
commit e474a80755
5 changed files with 28 additions and 6 deletions

View File

@ -8,6 +8,7 @@ import com.aizuda.bpm.engine.FlowConstants;
import com.aizuda.bpm.engine.FlowLongEngine;
import com.aizuda.bpm.engine.TaskActorProvider;
import com.aizuda.bpm.engine.assist.Assert;
import com.aizuda.bpm.engine.core.enums.TaskEventType;
import com.aizuda.bpm.engine.entity.FlwInstance;
import com.aizuda.bpm.engine.entity.FlwTask;
import com.aizuda.bpm.engine.entity.FlwTaskActor;
@ -83,6 +84,14 @@ public class Execution implements Serializable {
* 针对join节点的处理
*/
private boolean isMerged = false;
/**
* 指定任务事件类型
*/
private TaskEventType taskEventType;
public TaskEventType getTaskEventType() {
return null == taskEventType ? TaskEventType.create : taskEventType;
}
/**
* 用于产生子流程执行对象使用

View File

@ -272,6 +272,9 @@ public class FlowLongEngineImpl implements FlowLongEngine {
*/
final ProcessModel processModel = runtimeService().getProcessModelByInstanceId(instanceId);
// 当前任务事件
TaskEventType taskEventType = null;
/*
* 驳回跳转处理重新审批策略
*/
@ -279,7 +282,10 @@ public class FlowLongEngineImpl implements FlowLongEngine {
// 找到父节点模型处理策略
FlwHisTask parentTask = queryService().getHistTask(flwTask.getParentTaskId());
NodeModel parentNodeModel = processModel.getNode(parentTask.getTaskKey());
if (Objects.equals(2, parentNodeModel.getRejectStart())) {
if (Objects.equals(1, parentNodeModel.getRejectStart())) {
// 驳回重新审批策略 1继续往下执行
taskEventType = TaskEventType.reApproveCreate;
} else if (Objects.equals(2, parentNodeModel.getRejectStart())) {
// 驳回重新审批策略 2回到上一个节点
return this.executeJumpTask(flwTask.getId(), parentTask.getTaskKey(), flowCreator, args, TaskType.reApproveJump).isPresent();
}
@ -311,6 +317,9 @@ public class FlowLongEngineImpl implements FlowLongEngine {
FlwInstance flwInstance = this.getFlwInstance(flwTask.getInstanceId(), flowCreator.getCreateBy());
final Execution execution = this.createExecution(processModel, flwInstance, flwTask, flowCreator, ObjectUtils.getArgs(args));
// 设置当前任务事件
execution.setTaskEventType(taskEventType);
/*
* 按顺序依次审批一个任务按顺序多个参与者依次添加
*/

View File

@ -119,6 +119,10 @@ public enum TaskEventType {
* 驳回重新审批跳转
*/
reApproveJump,
/**
* 驳回重新审批创建
*/
reApproveCreate,
/**
* 自动审批完成
*/

View File

@ -1197,7 +1197,7 @@ public class TaskServiceImpl implements TaskService {
flwTasks.add(flwTask);
// 创建任务监听
this.taskNotify(TaskEventType.create, () -> flwTask, taskActors, nodeModel, flowCreator);
this.taskNotify(execution.getTaskEventType(), () -> flwTask, taskActors, nodeModel, flowCreator);
return flwTasks;
}
@ -1216,7 +1216,7 @@ public class TaskServiceImpl implements TaskService {
this.assignTask(flwTask.getInstanceId(), flwTask.getId(), assignActorType(actorType, nextFlwTaskActor.getActorType()), nextFlwTaskActor);
// 创建任务监听
this.taskNotify(TaskEventType.create, () -> flwTask, Collections.singletonList(nextFlwTaskActor), nodeModel, flowCreator);
this.taskNotify(execution.getTaskEventType(), () -> flwTask, Collections.singletonList(nextFlwTaskActor), nodeModel, flowCreator);
return flwTasks;
}
@ -1232,7 +1232,7 @@ public class TaskServiceImpl implements TaskService {
this.assignTask(newFlwTask.getInstanceId(), newFlwTask.getId(), assignActorType(actorType, t.getActorType()), t);
// 创建任务监听
this.taskNotify(TaskEventType.create, () -> newFlwTask, Collections.singletonList(t), nodeModel, flowCreator);
this.taskNotify(execution.getTaskEventType(), () -> newFlwTask, Collections.singletonList(t), nodeModel, flowCreator);
}
});

View File

@ -6,6 +6,7 @@ import com.aizuda.bpm.engine.core.enums.TaskEventType;
import com.aizuda.bpm.engine.core.enums.NodeApproveSelf;
import com.aizuda.bpm.engine.core.enums.NodeSetType;
import com.aizuda.bpm.engine.entity.FlwTask;
import com.aizuda.bpm.engine.entity.FlwTaskActor;
import com.aizuda.bpm.engine.listener.TaskListener;
import com.aizuda.bpm.engine.model.NodeAssignee;
import com.aizuda.bpm.engine.model.NodeModel;
@ -23,8 +24,7 @@ public class TestTaskListener implements TaskListener {
private FlowLongEngine flowLongEngine;
@Override
public boolean notify(TaskEventType eventType, Supplier<FlwTask> supplier, NodeModel nodeModel,
FlowCreator flowCreator) {
public boolean notify(TaskEventType eventType, Supplier<FlwTask> supplier, List<FlwTaskActor> taskActors, NodeModel nodeModel, FlowCreator flowCreator) {
if (TaskEventType.create.eq(eventType)) {
// 创建任务时候判断是否自动审批通过
Integer approveSelf = nodeModel.getApproveSelf();