引言
UserTask用户任务,是需要人处理后才能流转的任务。
本文将构建一个简单的串行流程带大家快速入门camunda工作流。
BPMN在线建模
如需亲自体验文章案例,请访问如下网址。
JeecgFlow演示站点
需求
我们以三国为背景, 假设系统中拥有将军,军师,主公三种角色。
现在作为将军的关羽需要发动一个出征流程。在填写好出兵人数和攻占城市后。
流程流转到军事诸葛亮进行评审, 此时军事可以给出锦囊妙计。
军事同意后,由主公角色刘备进行最后裁断,并赐予战甲等物资。
建模
<?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_1g84ud8" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.10.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.19.0">
<bpmn:process id="Process_0c2xy49" name="出征流程" isExecutable="true">
<bpmn:startEvent id="StartEvent_1" camunda:initiator="start">
<bpmn:outgoing>Flow_0fq95hn</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_0fq95hn" sourceRef="StartEvent_1" targetRef="Activity_0rbn70i" />
<bpmn:userTask id="Activity_0rbn70i" name="出征申请" camunda:assignee="${general}">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="number" label="出兵人数" type="long" defaultValue="1000" />
<camunda:formField id="city" label="攻取城市" type="string" defaultValue="许昌" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>Flow_0fq95hn</bpmn:incoming>
<bpmn:outgoing>Flow_01kvxy5</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="Flow_01kvxy5" sourceRef="Activity_0rbn70i" targetRef="Activity_1rht9n2" />
<bpmn:userTask id="Activity_1rht9n2" name="军师评审" camunda:assignee="${guide}">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="comment" label="评论" type="string" defaultValue="good" />
<camunda:formField id="imageUrl" label="图片" type="string" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>Flow_01kvxy5</bpmn:incoming>
<bpmn:outgoing>Flow_1whul4k</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="Flow_1whul4k" sourceRef="Activity_1rht9n2" targetRef="Activity_0n2qyol" />
<bpmn:userTask id="Activity_0n2qyol" name="主公决断" camunda:assignee="${leader}">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="comment" label="评论" type="string" defaultValue="ok" />
<camunda:formField id="pass" label="通过" type="boolean" defaultValue="true" />
<camunda:formField id="imageUrl" label="图片" type="string" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1whul4k</bpmn:incoming>
<bpmn:outgoing>Flow_0f4i22k</bpmn:outgoing>
</bpmn:userTask>
<bpmn:endEvent id="Event_1i65d7z">
<bpmn:incoming>Flow_0f4i22k</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_0f4i22k" sourceRef="Activity_0n2qyol" targetRef="Event_1i65d7z" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0c2xy49">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1nusb4n_di" bpmnElement="Activity_0rbn70i">
<dc:Bounds x="270" y="77" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1svhkoi_di" bpmnElement="Activity_1rht9n2">
<dc:Bounds x="430" y="77" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_08bfhfu_di" bpmnElement="Activity_0n2qyol">
<dc:Bounds x="590" y="77" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1i65d7z_di" bpmnElement="Event_1i65d7z">
<dc:Bounds x="752" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_0fq95hn_di" bpmnElement="Flow_0fq95hn">
<di:waypoint x="215" y="117" />
<di:waypoint x="270" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_01kvxy5_di" bpmnElement="Flow_01kvxy5">
<di:waypoint x="370" y="117" />
<di:waypoint x="430" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1whul4k_di" bpmnElement="Flow_1whul4k">
<di:waypoint x="530" y="117" />
<di:waypoint x="590" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0f4i22k_di" bpmnElement="Flow_0f4i22k">
<di:waypoint x="690" y="117" />
<di:waypoint x="752" y="117" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
角色扮演环节
接下来就是各个角色登录系统。完成各自的规定动作。促使整个流程平稳健康的运转。
将军-关羽
- 关羽登录系统在测试流程菜单下发起一个出征流程。
- 关羽可以通过我发起的菜单看到自己的发起记录。
将军-诸葛亮
- 诸葛亮登录系统找到待办任务菜单,查询待办任务。
- 诸葛亮找到已办任务菜单查询自己刚处理过的任务。
主公-刘备
- 刘备登录系统找到待办任务菜单,查询待办任务。
- 刘备找到已办任务菜单查询自己刚处理过的任务。