update - 创建流程实例时,可动态设置是否异步
This commit is contained in:
parent
38b57a4448
commit
81fad65127
@ -68,6 +68,7 @@ import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.engine.runtime.ActivityInstance;
|
||||
import org.flowable.engine.runtime.NativeActivityInstanceQuery;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.flowable.engine.runtime.ProcessInstanceBuilder;
|
||||
import org.flowable.engine.runtime.ProcessInstanceQuery;
|
||||
import org.flowable.form.api.FormInfo;
|
||||
import org.flowable.spring.SpringProcessEngineConfiguration;
|
||||
@ -303,16 +304,20 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
|
||||
: Objects.isNull(definition) ? "" : definition.getName();
|
||||
|
||||
// 设置流程名字
|
||||
ProcessInstance instance = runtimeService.createProcessInstanceBuilder()
|
||||
ProcessInstanceBuilder instanceBuilder = runtimeService.createProcessInstanceBuilder()
|
||||
.processDefinitionId(Objects.isNull(definition) ? dto.getProcessDefinitionId() : definition.getId())
|
||||
.businessKey(dto.getBusinessKey())
|
||||
.variables(dto.getVariables())
|
||||
.name(name)
|
||||
.overrideProcessDefinitionTenantId(dto.getTenantId())
|
||||
// 异步开始
|
||||
.startAsync();
|
||||
// 同步开始
|
||||
// .start();
|
||||
.overrideProcessDefinitionTenantId(dto.getTenantId());
|
||||
ProcessInstance instance;
|
||||
if (dto.getAsync()) {
|
||||
// 异步开始
|
||||
instance = instanceBuilder.startAsync();
|
||||
} else {
|
||||
// 同步开始
|
||||
instance = instanceBuilder.start();
|
||||
}
|
||||
Authentication.setAuthenticatedUserId(null);
|
||||
return instance.getProcessInstanceId();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user