自动完成任务创建人允许参数传入且定时任务允许子类重写
This commit is contained in:
parent
75b9be2749
commit
bb322a8da3
@ -179,27 +179,37 @@ public interface FlowLongEngine {
|
||||
/**
|
||||
* 自动完成任务
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @param args 任务参数
|
||||
* @param taskId 任务ID
|
||||
* @param args 任务参数
|
||||
* @param flowCreator 任务创建者
|
||||
* @return true 成功 false 失败
|
||||
*/
|
||||
boolean autoCompleteTask(Long taskId, Map<String, Object> args);
|
||||
boolean autoCompleteTask(Long taskId, Map<String, Object> args, FlowCreator flowCreator);
|
||||
|
||||
default boolean autoCompleteTask(Long taskId, FlowCreator flowCreator) {
|
||||
return this.autoCompleteTask(taskId, null, flowCreator);
|
||||
}
|
||||
|
||||
default boolean autoCompleteTask(Long taskId) {
|
||||
return this.autoCompleteTask(taskId, null);
|
||||
return this.autoCompleteTask(taskId, FlowCreator.ADMIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动拒绝任务
|
||||
*
|
||||
* @param flwTask 任务对象
|
||||
* @param args 任务参数
|
||||
* @param flwTask 任务对象
|
||||
* @param args 任务参数
|
||||
* @param flowCreator 任务创建者
|
||||
* @return true 成功 false 失败
|
||||
*/
|
||||
boolean autoRejectTask(FlwTask flwTask, Map<String, Object> args);
|
||||
boolean autoRejectTask(FlwTask flwTask, Map<String, Object> args, FlowCreator flowCreator);
|
||||
|
||||
default boolean autoRejectTask(FlwTask flwTask, FlowCreator flowCreator) {
|
||||
return this.autoRejectTask(flwTask, null, flowCreator);
|
||||
}
|
||||
|
||||
default boolean autoRejectTask(FlwTask flwTask) {
|
||||
return this.autoRejectTask(flwTask, null);
|
||||
return this.autoRejectTask(flwTask, FlowCreator.ADMIN);
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,6 +7,7 @@ package com.aizuda.bpm.engine;
|
||||
import com.aizuda.bpm.engine.assist.Assert;
|
||||
import com.aizuda.bpm.engine.assist.DateUtils;
|
||||
import com.aizuda.bpm.engine.assist.ObjectUtils;
|
||||
import com.aizuda.bpm.engine.core.FlowCreator;
|
||||
import com.aizuda.bpm.engine.core.FlowLongContext;
|
||||
import com.aizuda.bpm.engine.core.enums.TaskType;
|
||||
import com.aizuda.bpm.engine.entity.FlwTask;
|
||||
@ -89,7 +90,7 @@ public abstract class FlowLongScheduler {
|
||||
else if (null != flwTask.getExpireTime()) {
|
||||
// 定时器任务或触发器任务直接执行通过
|
||||
if (TaskType.timer.eq(flwTask.getTaskType()) || TaskType.trigger.eq(flwTask.getTaskType())) {
|
||||
if (!flowLongEngine.autoCompleteTask(flwTask.getId())) {
|
||||
if (!flowLongEngine.autoCompleteTask(flwTask.getId(), this.getAutoFlowCreator())) {
|
||||
log.info("Scheduling [taskName={}] failed to execute autoCompleteTask", flwTask.getTaskName());
|
||||
}
|
||||
continue;
|
||||
@ -108,12 +109,12 @@ public abstract class FlowLongScheduler {
|
||||
context.getRuntimeService().timeout(flwTask.getInstanceId());
|
||||
} else if (Objects.equals(termMode, 0)) {
|
||||
// 自动通过
|
||||
if (!flowLongEngine.autoCompleteTask(flwTask.getId())) {
|
||||
if (!flowLongEngine.autoCompleteTask(flwTask.getId(), this.getAutoFlowCreator())) {
|
||||
log.info("Scheduling failed to execute autoCompleteTask");
|
||||
}
|
||||
} else if (Objects.equals(termMode, 1)) {
|
||||
// 自动拒绝
|
||||
if (!flowLongEngine.autoRejectTask(flwTask)) {
|
||||
if (!flowLongEngine.autoRejectTask(flwTask, this.getAutoFlowCreator())) {
|
||||
log.info("Scheduling failed to execute autoRejectTask");
|
||||
}
|
||||
}
|
||||
@ -136,4 +137,12 @@ public abstract class FlowLongScheduler {
|
||||
}
|
||||
this.remindParam = remindParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动完成流程任务创建者
|
||||
* <p>默认为管理员,子类可以重写为自定义用户</p>
|
||||
*/
|
||||
public FlowCreator getAutoFlowCreator() {
|
||||
return FlowCreator.ADMIN;
|
||||
}
|
||||
}
|
||||
|
@ -147,16 +147,16 @@ public class FlowLongEngineImpl implements FlowLongEngine {
|
||||
* 自动完成任务
|
||||
*/
|
||||
@Override
|
||||
public boolean autoCompleteTask(Long taskId, Map<String, Object> args) {
|
||||
return executeTask(taskId, FlowCreator.ADMIN, null, TaskState.autoComplete, TaskEventType.autoComplete);
|
||||
public boolean autoCompleteTask(Long taskId, Map<String, Object> args, FlowCreator flowCreator) {
|
||||
return executeTask(taskId, flowCreator, null, TaskState.autoComplete, TaskEventType.autoComplete);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动拒绝任务
|
||||
*/
|
||||
@Override
|
||||
public boolean autoRejectTask(FlwTask flwTask, Map<String, Object> args) {
|
||||
Optional<FlwTask> flwTaskOptional = taskService().rejectTask(flwTask, FlowCreator.ADMIN, args);
|
||||
public boolean autoRejectTask(FlwTask flwTask, Map<String, Object> args, FlowCreator flowCreator) {
|
||||
Optional<FlwTask> flwTaskOptional = taskService().rejectTask(flwTask, flowCreator, args);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Auto reject taskId={}", flwTask.getId());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user