flowable如果在启动流程的时候设置流程实例的名称
背景:本来提供了设置name的接口,但是由于很多情况,流程还没有发起就结束了,这种就很难设置他的name,那么我们如何做呢?
1. 继承StartProcessInstanceCmd
public class StartProcessNameProcessInstanceCmd<T> extends StartProcessInstanceCmd<T> { public StartProcessNameProcessInstanceCmd(String processInstanceName, String processDefinitionKey,String businessKey, Map<String, Object> variables, String tenantId) { super(processDefinitionKey, null, businessKey, variables,tenantId); this.processInstanceName = processInstanceName; } }
2. 启动的时候我们直接用命令来启动流程即可
ProcessInstance processInstance = managementService.executeCommand(new StartProcessNameProcessInstanceCmd<ProcessInstance>(params.getFormName(), params.getProcessDefinitionKey().trim(),
params.getBusinessKey().trim(), params.getVariables(), params.getSystemSn().trim()));