activiti中inclusiveGateway使用过程中出现的问题

yianmomo 发布于 2014/11/26 11:08
阅读 1K+
收藏 0

@咖啡兔 你好,想跟你请教个问题:

当第一个网关的两个条件都成立时,生成任务1和任务3(用红色圆圈标注的),将任务1和任务3完成后,接着当第二个网关的两个条件都成立时,应该生成任务1和任务4,以及任务2,但是现在只生成了任务2,请问这是什么原因导致的呢?是流程图画的有问题吗?
附上我的测试文件和流程文件:

package com.bizprocess;


import java.util.HashMap;
import java.util.List;
import java.util.Map;


import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;


public class LCTest {
@org.junit.Test
public void test() {
ProcessEngine engine = ProcessEngineConfiguration
.createProcessEngineConfigurationFromResource(
"temp/activiti.cfg.xml").buildProcessEngine();
RepositoryService repositoryService = engine.getRepositoryService();
repositoryService.createDeployment()
.addClasspathResource("diagrams/LC-01-01-01_Test.bpmn")
.deploy();
TaskService taskService = engine.getTaskService();
RuntimeService runtimeService = engine.getRuntimeService();
// 开启流程
ProcessInstance pi1 = runtimeService
.startProcessInstanceByKey("testLc");


Task task = taskService.createTaskQuery()
.processInstanceId(pi1.getId()).singleResult();
System.out.println(task.getName());
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("before", "manager");
// 完成“计划主管填写业务信息任务”
taskService.complete(task.getId(), vars);
// 完成经营业务经理审查
task = taskService.createTaskQuery().processInstanceId(pi1.getId())
.singleResult();
System.out.println(task.getName());
vars = new HashMap<String, Object>();
vars.put("managerPass", "pass");
vars.put("managerUnPass", "pass");
taskService.complete(task.getId(), vars);

List<Task> taskList = taskService.createTaskQuery()
.processInstanceId(pi1.getId()).list();
for (Task task2 : taskList) {
// System.out.println(task2.getTaskDefinitionKey());
if (task2.getTaskDefinitionKey().equals("viceManager")) {
vars.put("fuzhongPass", "pass");
vars.put("fuzhongUnPass", "pass");
taskService.complete(task2.getId(), vars);
}
if (task2.getTaskDefinitionKey().equals("planOfficer")) {
vars.put("before", "manager");
taskService.complete(task2.getId(), vars);
}
}
taskList = taskService.createTaskQuery().processInstanceId(pi1.getId())
.list();
for (Task task2 : taskList) {
// System.out.println(task2.getName());
if (task2.getTaskDefinitionKey().equals("planOfficer")) {
vars.put("before", "fuzhong");
taskService.complete(task2.getId(), vars);
}
if (task2.getTaskDefinitionKey().equals("businessManager")) {
vars.put("managerPass", "pass");
vars.put("managerUnPass", "pass");
taskService.complete(task2.getId(), vars);
}
}
taskList = taskService.createTaskQuery().processInstanceId(pi1.getId())
.list();
for (Task task2 : taskList) {
System.out.println(task2.getName());
}
}


}


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="testLc" name="businessinfo" isExecutable="true">
    <startEvent id="startevent1" name="Start" activiti:initiator="admin"></startEvent>
    <userTask id="businessManager" name="经营业务经理审查" activiti:candidateGroups="manager"></userTask>
    <userTask id="viceManager" name="经营副总审批" activiti:assignee="admin"></userTask>
    <userTask id="planOfficer" name="计划主管填写业务信息" activiti:assignee="${admin}"></userTask>
    <sequenceFlow id="flow12" sourceRef="startevent1" targetRef="planOfficer"></sequenceFlow>
    <sequenceFlow id="flow16" sourceRef="businessManager" targetRef="inclusivegateway2"></sequenceFlow>
    <sequenceFlow id="flow17" name="managerPass=='pass'" sourceRef="inclusivegateway2" targetRef="viceManager">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${managerPass=='pass'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow18" name="managerUnPass=='pass'" sourceRef="inclusivegateway2" targetRef="planOfficer">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${managerUnPass=='pass'}]]></conditionExpression>
    </sequenceFlow>
    <endEvent id="endevent2" name="End"></endEvent>
    <sequenceFlow id="flow29" sourceRef="servicetask1" targetRef="endevent2"></sequenceFlow>
    <inclusiveGateway id="inclusivegateway2" name="Inclusive Gateway"></inclusiveGateway>
    <inclusiveGateway id="inclusivegateway3" name="Inclusive Gateway"></inclusiveGateway>
    <sequenceFlow id="flow34" sourceRef="viceManager" targetRef="inclusivegateway3"></sequenceFlow>
    <sequenceFlow id="flow35" name="fuzhongPass=='pass'" sourceRef="inclusivegateway3" targetRef="servicetask1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${fuzhongPass=='pass'}]]></conditionExpression>
    </sequenceFlow>
    <serviceTask id="servicetask1" name="Service Task" activiti:class="com.listener.LC01Listener"></serviceTask>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_testLc">
    <bpmndi:BPMNPlane bpmnElement="testLc" id="BPMNPlane_testLc">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="50.0" y="210.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="businessManager" id="BPMNShape_businessManager">
        <omgdc:Bounds height="55.0" width="105.0" x="350.0" y="200.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="viceManager" id="BPMNShape_viceManager">
        <omgdc:Bounds height="55.0" width="105.0" x="541.0" y="110.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="planOfficer" id="BPMNShape_planOfficer">
        <omgdc:Bounds height="65.0" width="105.0" x="120.0" y="195.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
        <omgdc:Bounds height="35.0" width="35.0" x="980.0" y="120.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="inclusivegateway2" id="BPMNShape_inclusivegateway2">
        <omgdc:Bounds height="40.0" width="40.0" x="490.0" y="208.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="inclusivegateway3" id="BPMNShape_inclusivegateway3">
        <omgdc:Bounds height="40.0" width="40.0" x="700.0" y="117.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask1" id="BPMNShape_servicetask1">
        <omgdc:Bounds height="55.0" width="105.0" x="850.0" y="110.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12">
        <omgdi:waypoint x="85.0" y="227.0"></omgdi:waypoint>
        <omgdi:waypoint x="120.0" y="227.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow16" id="BPMNEdge_flow16">
        <omgdi:waypoint x="455.0" y="227.0"></omgdi:waypoint>
        <omgdi:waypoint x="490.0" y="228.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow17" id="BPMNEdge_flow17">
        <omgdi:waypoint x="510.0" y="208.0"></omgdi:waypoint>
        <omgdi:waypoint x="509.0" y="138.0"></omgdi:waypoint>
        <omgdi:waypoint x="541.0" y="137.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="42.0" width="100.0" x="511.0" y="165.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow18" id="BPMNEdge_flow18">
        <omgdi:waypoint x="510.0" y="248.0"></omgdi:waypoint>
        <omgdi:waypoint x="510.0" y="317.0"></omgdi:waypoint>
        <omgdi:waypoint x="171.0" y="317.0"></omgdi:waypoint>
        <omgdi:waypoint x="172.0" y="260.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="42.0" width="100.0" x="510.0" y="258.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow29" id="BPMNEdge_flow29">
        <omgdi:waypoint x="955.0" y="137.0"></omgdi:waypoint>
        <omgdi:waypoint x="980.0" y="137.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow34" id="BPMNEdge_flow34">
        <omgdi:waypoint x="646.0" y="137.0"></omgdi:waypoint>
        <omgdi:waypoint x="700.0" y="137.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow35" id="BPMNEdge_flow35">
        <omgdi:waypoint x="740.0" y="137.0"></omgdi:waypoint>
        <omgdi:waypoint x="850.0" y="137.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="42.0" width="100.0" x="739.0" y="136.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>


加载中
返回顶部
顶部