查询历史流程变量
/** * 查询历史流程变量 */ @org.junit.Test public void historyVariable() { HistoricVariableInstance variable = processEngine.getHistoryService().createHistoricVariableInstanceQuery().variableName("审核意见") .processInstanceId("47501").singleResult(); // 流程变量名 System.out.println(variable.getVariableName()); // 流程变量的值 System.out.println(variable.getValue()); }17.根据流程变量走不同的流程
流程图
代码:
package com.cjrj.bootactividemo; import java.util.HashMap; import java.util.Map; import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngines; import org.activiti.engine.repository.Deployment; import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.task.Task; import org.junit.Test; /** * * 审核附加流程变量 * * @author Jamin * */ public class Test2 { ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); @Test public void test() { // 部署 Deployment deploy = processEngine.getRepositoryService().createDeployment() .addClasspathResource("bpm/test.bpmn").addClasspathResource("bpm/test.png").name("test") .deploy(); // 启动 ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("myProcess"); Task task = processEngine.getTaskService().createTaskQuery().taskAssignee("张三") .processInstanceId(pi.getId()).singleResult(); // 审批附加流程变量 Map<String, Object> map = new HashMap<String, Object>(); map.put("message", "重要"); processEngine.getTaskService().complete(task.getId(), map); // 查询李四的任务 Task task1 = processEngine.getTaskService().createTaskQuery().taskAssignee("李四") .processInstanceId(pi.getId()).singleResult(); // 如果message是重要task1不为空,如果message是不重要的task为空 if (task1 != null) { System.out.println(task1.getName()); } else { System.out.println("结束"); } } }
排他网关