排他网关

当流程执行到这个网关,所有分支都会判断条件是否为true,如果为 true 则执行该分支。排他网关只会选择一个为 true 的分支执行。(即使有两个分支条件都为 true,排他网关也会只选择一条分支去执行)

xml文件




  
    
    
    
    
    
    
    
      
        = 90}]]>
      
    
    
      
        = 75 && score < 90}]]>
      
    
    
      
        
      
    
    
    


    
    
    
    
  

代码:

package com.lala.gateway;

import common.ProcessEngineUtil;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;

public class Exclusive {
    public static void main(String[] args) {
        ProcessEngineUtil processEngineUtil = new ProcessEngineUtil("exclusibe.bpmn20.xml");
        ProcessEngine processEngine = processEngineUtil.getProcessEngine();

        Map variables = new HashMap<>();
        variables.put("key1", "3");
        variables.put("score", "74");
        ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByKey("exclusiveTask", variables);


        List tasks = processEngine.getTaskService().createTaskQuery().list();
        for (Task task : tasks) {
            System.out.println("task.name = {}" + task.getName());
            processEngine.getTaskService().complete(task.getId());
        }
        processEngineUtil.draw(processInstance);
    }
}

流程图:

 

排他网关_第1张图片

 

你可能感兴趣的:(工作流)