绑定业务主键businessKey
/**
* 绑定业务主键
*/
@Test
public void bindingBusinessKey() {
// 获取RuntimeService
RuntimeService runtimeService = defaultProcessEngine.getRuntimeService(); // 启动流程实例并绑定业务主键
ProcessInstance holiday = runtimeService.startProcessInstanceByKey("holiday", "1001"); // 输出业务主键信息
System.out.println("业务主键:" + holiday.getBusinessKey());
}
流程定义的挂起和激活,流程定义一旦挂起,该定义下的所有流程实例都将无法提交
/**
* 流程定义的全部挂起和激活
*/
@Test
public void suspendOrActivateProcessDefinition() { // 获取RepositoryService
RepositoryService repositoryService = defaultProcessEngine.getRepositoryService(); // 查询唯一的流程定义
ProcessDefinition holiday = repositoryService.createProcessDefinitionQuery().processDefinitionKey("holiday").singleResult(); // 查看是否激活
boolean suspended = holiday.isSuspended(); String processDefinitionId = holiday.getId(); if (suspended) {
// 如果没激活 就激活
repositoryService.activateProcessDefinitionById(processDefinitionId, true, null);
System.out.println("流程定义:" + processDefinitionId + "激活");
} else {
// 如果激活 就挂起
repositoryService.suspendProcessDefinitionById(processDefinitionId, true, null);
System.out.println("流程定义:" + processDefinitionId + "挂起");
} }
单个流程实例挂起操作,单个流程实例的挂起并不会影响其他流程实例的提交和执行
/**
* 单个流程实例挂起操作
*/
@Test
public void suspendOrActiveProcessInstance(){ // 启动的流程实例ID
String processInstanceId = "17501"; // 获取RuntimeService
RuntimeService runtimeService = defaultProcessEngine.getRuntimeService(); // 查询流程实例
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); boolean suspended = processInstance.isSuspended(); if(suspended){
runtimeService.activateProcessInstanceById(processInstanceId);
System.out.println("流程实例:"+processInstanceId+"激活");
}else{
runtimeService.suspendProcessInstanceById(processInstanceId);
System.out.println("流程实例:"+processInstanceId+"挂起");
} }
作者:彼岸舞
时间:2020\09\04
内容关于:Activiti工作流
本文来源于网络,只做技术分享,一概不负任何责任