[14]深入浅出工作开源框架Camunda:多实例串行用户任务

在《[13]深入浅出工作开源框架Camunda:多实例并行用户任务》 我们提到了多实例并行任务,那么对于多实例串行任务,那么Camunda的内部流程和数据库的数据是如何变化的呢?
下面笔者带大家一起来看看。

1.前提条件

  1. 需要用到的查看数据库的SQL语句
select ID_,NAME_, REV_, TASK_DEF_KEY_,ASSIGNEE_ , SUSPENSION_STATE_ from ACT_RU_TASK art where PROC_DEF_ID_ ='流程定义ID';

select ID_, REV_,ACT_ID_ , ACT_INST_ID_ , IS_ACTIVE_, BUSINESS_KEY_, IS_SCOPE_ ,SEQUENCE_COUNTER_,SUSPENSION_STATE_ from ACT_RU_EXECUTION 
where PROC_DEF_ID_ ='流程定义ID';

select ID_, ACT_ID_ ,ASSIGNEE_,ACT_NAME_ ,ACT_TYPE_ , ACT_INST_STATE_ ,SEQUENCE_COUNTER_ ,START_TIME_ ,END_TIME_ 
from ACT_HI_ACTINST  where PROC_DEF_ID_ ='流程定义ID' order by END_TIME_ , START_TIME_  asc;
  1. 需要用到Process文件的定义
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1rskuqm" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.11.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
  <bpmn:process id="Process_Sequential-Multiple-Instance-0001" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1" name="开始">
      <bpmn:extensionElements>
        <camunda:executionListener event="start">
          <camunda:script scriptFormat="groovy">def userList = ['user1', 'user2', 'user3'];execution.setVariable("assigneeList", userList);</camunda:script>
        </camunda:executionListener>
      </bpmn:extensionElements>
      <bpmn:outgoing>Flow_1fj43ru</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="Flow_1fj43ru" sourceRef="StartEvent_1" targetRef="Activity_0uu8kyc" />
    <bpmn:userTask id="Activity_0uu8kyc" name="申请" camunda:candidateUsers="demo">
      <bpmn:incoming>Flow_1fj43ru</bpmn:incoming>
      <bpmn:outgoing>Flow_13f07ki</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:sequenceFlow id="Flow_13f07ki" sourceRef="Activity_0uu8kyc" targetRef="Activity_1i74f13" />
    <bpmn:task id="Activity_1fl042q" name="CEO审批">
      <bpmn:incoming>Flow_053ejj3</bpmn:incoming>
      <bpmn:outgoing>Flow_1kn1y96</bpmn:outgoing>
    </bpmn:task>
    <bpmn:sequenceFlow id="Flow_053ejj3" sourceRef="Activity_1i74f13" targetRef="Activity_1fl042q" />
    <bpmn:endEvent id="Event_03g5bdn" name="结束">
      <bpmn:incoming>Flow_1kn1y96</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_1kn1y96" sourceRef="Activity_1fl042q" targetRef="Event_03g5bdn" />
    <bpmn:userTask id="Activity_1i74f13" name="串行会签预审" camunda:assignee="${assignee}">
      <bpmn:incoming>Flow_13f07ki</bpmn:incoming>
      <bpmn:outgoing>Flow_053ejj3</bpmn:outgoing>
      <bpmn:multiInstanceLoopCharacteristics isSequential="true" camunda:collection="assigneeList" camunda:elementVariable="assignee" />
    </bpmn:userTask>
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_Sequential-Multiple-Instance-0001">
      <bpmndi:BPMNEdge id="Flow_1fj43ru_di" bpmnElement="Flow_1fj43ru">
        <di:waypoint x="215" y="117" />
        <di:waypoint x="270" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_13f07ki_di" bpmnElement="Flow_13f07ki">
        <di:waypoint x="370" y="117" />
        <di:waypoint x="430" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_053ejj3_di" bpmnElement="Flow_053ejj3">
        <di:waypoint x="530" y="117" />
        <di:waypoint x="590" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1kn1y96_di" bpmnElement="Flow_1kn1y96">
        <di:waypoint x="690" y="117" />
        <di:waypoint x="752" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="179" y="99" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="186" y="142" width="23" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_07e0cyd_di" bpmnElement="Activity_0uu8kyc">
        <dc:Bounds x="270" y="77" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1fl042q_di" bpmnElement="Activity_1fl042q">
        <dc:Bounds x="590" y="77" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_03g5bdn_di" bpmnElement="Event_03g5bdn">
        <dc:Bounds x="752" y="99" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="759" y="142" width="23" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0qatbc4_di" bpmnElement="Activity_1i74f13">
        <dc:Bounds x="430" y="77" width="100" height="80" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

3.流程中涉及到的用户
管理员:demo
用户: user1,user2,user3

4.流程图
在这里插入图片描述

2.查看数据

2.1 启动流程后

  • 运行中的任务表(ACT_RU_TASK)
    在这里插入图片描述
  • 运行中的执行表(ACT_RU_EXECUTION)
    在这里插入图片描述
  • 历史表(ACT_HI_ACTINST)
    在这里插入图片描述

2.2 第一个用户任务“申请”审批通过后

demo用户点击完成“申请”用户任务
在这里插入图片描述

  • 运行中的任务表(ACT_RU_TASK)
    在这里插入图片描述

  • 运行中的执行表(ACT_RU_EXECUTION)
    在这里插入图片描述

  • 历史表(ACT_HI_ACTINST)
    在这里插入图片描述

2.3 进入串行审批用户任务,user1 审批通过

用户user1登录,并点击完成~
在这里插入图片描述

  • 运行中的任务表(ACT_RU_TASK)
    路由到user2 审批了
    在这里插入图片描述

  • 运行中的执行表(ACT_RU_EXECUTION)
    在这里插入图片描述

  • 历史表(ACT_HI_ACTINST)
    在这里插入图片描述

2.4 进入串行审批用户任务,user2 审批通过

在这里插入图片描述

  • 运行中的任务表(ACT_RU_TASK)
    在这里插入图片描述
  • 运行中的执行表(ACT_RU_EXECUTION)

在这里插入图片描述

  • 历史表(ACT_HI_ACTINST)
    在这里插入图片描述

2.5 进入串行审批用户任务,user3 审批通过

在这里插入图片描述

  • 运行中的任务表(ACT_RU_TASK)

在这里插入图片描述

  • 运行中的执行表(ACT_RU_EXECUTION)

在这里插入图片描述

  • 历史表(ACT_HI_ACTINST)
    在这里插入图片描述
    这个时候读者就会奇怪,上面的图里面明明还有一个任务“CEO审批”。
    在这里插入图片描述
    那为什么在下面的两个表中却没有数据了呢?
  • 运行中的任务表(ACT_RU_TASK)
  • 运行中的执行表(ACT_RU_EXECUTION)

其实这是笔者故意设置的一个场景,大家发现CEO审批不是一个用户任务,而是一个普通的任务;其是没有执行人的;所以其在上面的两个表里面就不产生执行的记录;但是在历史表中还是会被记录下来的~

到此,整个数据记录流程结束~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值