【13】Camunda7-第一个BPMN流程

在前一篇博文里,我们介绍了Camunda Modeler,那么接下来,我们就使用这个设计器工具绘制我们的第一个BPMN流程。


1. 场景概述

关于第一个流程,这里计划以我们最常见的请假审批流程为例,它涉及到表单设计、人工审批任务等典型节点。下面将详述设计过程。

2.模型设计

2.1 建立模型工程

首先,新建一个Camunda7 BPMN的空白画布。

2.2 添加图元,构建完整流程

在创建空白画布后,可以看到,默认情况下只有一个默认图元存在,即开始事件。这里我们安装请假流程所需的各个环节,把相应的图元拖拽至设计区域,初步构建完整流程:

  • 开始事件:标志流程开始,申请人填写表单
  • 用户任务1:模拟一级审批,例如组长审批等
  • 用户任务2:模拟二级审批,例如经理审批等
  • 结束事件:标志流程结束

2.3 图元选择与属性配置

2.3.1 流程全局配置

填写流程名称:请假流程示例,并勾选Executable,其他使用默认配置即可。

2.3.2 创建表单

众所周知,一般请假的场景下,申请人是需要填写一个请假申请表的,基本涵盖申请人、申请天数等信息,这里我们就设计一个简单的请假申请表单。 我们使用Camunda开始事件的From属性来实现表单相关需求,具体如下。

选择Generated Task Forms并创建两个fields:name-申请人,day-请假天数,均不设置默认值。

2.3.3 配置人工审批任务

在案例场景中,我们有2个用户任务,分别模拟组长、经理审批。因此,修改Task图元为具体的UserTask用户任务图元。

完成图元类型修改后,我们进一步对2个用户任务进行配置,这里我们假定组长是张三,经理是李四,进而配置用户任务指定的处理人分别为zhangsan, lisi。

2.3.4 完成流程建模

在第一个流程案例中,结束事件无需其他位置。至此,第一个流程案例的建模已经完成,具体流程如下。

2.4 保存流程定义/模型

点击file-save file保存已完成建模的流程定义;同时也可以导出流程定义的xml形式。

<?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_0vpu411" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.19.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.20.0">
  <bpmn:process id="Process_1p8hbtn" name="请假流程示例" isExecutable="true" camunda:historyTimeToLive="180">
    <bpmn:startEvent id="StartEvent_1" name="开始">
      <bpmn:extensionElements>
        <camunda:formData>
          <camunda:formField id="name" label="申请人" type="string" />
          <camunda:formField id="day" label="请假天数" type="long" />
        </camunda:formData>
      </bpmn:extensionElements>
      <bpmn:outgoing>Flow_1xnw69x</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="Flow_1xnw69x" sourceRef="StartEvent_1" targetRef="Activity_1i9x3bn" />
    <bpmn:sequenceFlow id="Flow_1pxf9yp" sourceRef="Activity_1i9x3bn" targetRef="Activity_080lqdu" />
    <bpmn:endEvent id="Event_0ea6i5r">
      <bpmn:incoming>Flow_006sco1</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_006sco1" sourceRef="Activity_080lqdu" targetRef="Event_0ea6i5r" />
    <bpmn:userTask id="Activity_1i9x3bn" name="组长审批" camunda:assignee="zhangsan">
      <bpmn:incoming>Flow_1xnw69x</bpmn:incoming>
      <bpmn:outgoing>Flow_1pxf9yp</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:userTask id="Activity_080lqdu" name="经理审批" camunda:assignee="lisi">
      <bpmn:incoming>Flow_1pxf9yp</bpmn:incoming>
      <bpmn:outgoing>Flow_006sco1</bpmn:outgoing>
    </bpmn:userTask>
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1p8hbtn">
      <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="Event_0ea6i5r_di" bpmnElement="Event_0ea6i5r">
        <dc:Bounds x="592" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1dc59bl_di" bpmnElement="Activity_1i9x3bn">
        <dc:Bounds x="270" y="77" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1b471g9_di" bpmnElement="Activity_080lqdu">
        <dc:Bounds x="430" y="77" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_1xnw69x_di" bpmnElement="Flow_1xnw69x">
        <di:waypoint x="215" y="117" />
        <di:waypoint x="270" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_006sco1_di" bpmnElement="Flow_006sco1">
        <di:waypoint x="530" y="117" />
        <di:waypoint x="592" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1pxf9yp_di" bpmnElement="Flow_1pxf9yp">
        <di:waypoint x="370" y="117" />
        <di:waypoint x="430" y="117" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

  • 16
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值