1. Flowable 簡介
Flowable
是一個(gè)用 Java
編寫的輕量級(jí)業(yè)務(wù)流程引擎。Flowable
流程引擎允許您部署 BPMN 2.0
流程定義(用于定義流程的行業(yè) XML
標(biāo)準(zhǔn))、創(chuàng)建這些流程定義的流程實(shí)例、運(yùn)行查詢、訪問活動(dòng)或歷史流程實(shí)例和相關(guān)數(shù)據(jù)
Flowable
在將其添加到應(yīng)用程序、服務(wù)、體系結(jié)構(gòu)時(shí)非常靈活。您可以將引擎嵌入到您的應(yīng)用程序或服務(wù)中,方法是包含 Flowable
庫,該庫作為 JAR
提供。因?yàn)樗且粋€(gè) JAR
,所以可以很容易地將它添加到任何 Java
環(huán)境中:javase;servlet
容器,如 Tomcat
或 Jetty、Spring;javaee
服務(wù)器,如 JBoss
或 WebSphere
等。或者,您可以使用可流動(dòng)的 restapi
通過 HTTP
進(jìn)行通信。還有一些可流動(dòng)的應(yīng)用程序(Flowable Modeler、Flowable Admin、Flowable IDM 和 Flowable Task
),它們提供了用于處理流程和任務(wù)的現(xiàn)成示例 UI
Flowable
的 GitHub
官網(wǎng):https://github.com/flowable/flowable-engine
Flowable
中文用戶書冊:https://tkjohn.github.io/flowable-userguide/#_advanced
現(xiàn)在市面上主流的流程引擎就一共有三個(gè):
Activiti
Flowable
Camunda
這三個(gè)各有特點(diǎn):
-
Activiti
目前是側(cè)重云,他目前的設(shè)計(jì)會(huì)向Spring Cloud
、Docker
這些去靠攏 -
Flowable
核心思想還是在做一個(gè)功能豐富的流程引擎工具,除了最最基礎(chǔ)的工作流,他還提供了很多其他的擴(kuò)展點(diǎn),我們可以基于Flowable
實(shí)現(xiàn)出許多我們想要的功能(當(dāng)然這也是小伙伴們覺得Flowable
使用復(fù)雜的原因之一) -
Camunda
相對于前兩個(gè)而言比較輕量級(jí),Camunda
有一個(gè)比較有特色的功能就是他提供了一個(gè)小巧的編輯器,基于bpmn.io
來實(shí)現(xiàn)的。如果你的項(xiàng)目需求是做一個(gè)輕巧的、靈活的、定制性強(qiáng)的編輯器,工作流是嵌入式的,那么可以選擇Camunda
工作流程圖這塊其實(shí)有一個(gè)統(tǒng)一的標(biāo)準(zhǔn),那就是 BPMN
。BPMN
全稱是 Business Process Model and Notation,中文譯作業(yè)務(wù)流程模型和標(biāo)記法,這個(gè)中文太繞口了,還是簡稱 BPMN
吧
這是一套圖形化表示法,用圖形來表示業(yè)務(wù)流程模型。BPMN
最初由業(yè)務(wù)流程管理倡議組織(BPMI, Business Process Management Initiative
)開發(fā),BPMI
于 2005
年與對象管理組織(OMG, Object Management Group
)合并,并于 2011
年 1
月 OMG
發(fā)布 2.0
版本,同時(shí)改為現(xiàn)在的名稱
一句話,就是流程圖這塊有一個(gè)特別古老的規(guī)范,那就是 BPMN
,而我們前面所說的無論是 Activiti、Flowable
還是 Camunda
,都是支持這個(gè)規(guī)范的,所以呢,無論你使用哪一個(gè)流程引擎,都可以使用同一套流程圖
2. 繪制工作流程圖
2.1. Flowable UI 的安裝部署
首先下載文件 Flowable
相關(guān)的資源,進(jìn)入 https://github.com/flowable/flowable-engine/releases,選擇版本下載,下載下來是一個(gè) ZIP
壓縮包,解壓壓縮會(huì)看到如下目錄結(jié)構(gòu)
2.2. 啟動(dòng)服務(wù)
進(jìn)入 wars
目錄,會(huì)看到 flowable-rest.war
和 flowable-ui.war
兩個(gè) war
文件,然后 cmd
執(zhí)行如下命令
java -jar flowable-ui.war
如果一閃而過則檢查 jdk
的環(huán)境變量配置。啟動(dòng)成功后,在瀏覽器中訪問 http://localhost:8080/flowable-ui/#/
,默認(rèn)的賬號(hào)密碼是:admin/test
2.3. 用戶管理
我們先在 身份管理應(yīng)用程序
中創(chuàng)建用戶并授權(quán)
創(chuàng)建用戶
填寫詳細(xì)信息
授權(quán)管理
2.4. 工作流程效果圖
最后完成的工作流程圖如下
2.5. 繪制工作流程圖
點(diǎn)擊創(chuàng)建流程,填寫相關(guān)的信息
進(jìn)入流程圖繪制界面
2.5.1. 添加開始事件
2.5.2. 添加用戶活動(dòng)(用戶審批)
2.5.3. 添加網(wǎng)關(guān)
2.5.4. 添加結(jié)束事件
2.5.5. 設(shè)置【主管審批】的相關(guān)屬性
- 主鍵
ID
:可以結(jié)合業(yè)務(wù)需求,業(yè)務(wù)可以根據(jù)不同步驟執(zhí)行不同的業(yè)務(wù)操作 - 分配用戶:這里為了方便,直接選擇了固定值,這里的候選組是具體的業(yè)務(wù)系統(tǒng)的角色
ID
從而實(shí)現(xiàn)不同角色審批不同流程的效果
2.5.6. 設(shè)置【網(wǎng)關(guān)】的流條件
2.5.6.1. 同意的條件
- 連線條件的輸入框是支持
EL
表達(dá)式,因此可以使用${}
- 【同意的條件】:這里填寫了
${executeType=='YES'}
的意思是主管審批的時(shí)候傳遞一個(gè)executeType
變量,并且executeType
變量的值為YES
的時(shí)候,則走到下一步(經(jīng)理審批)
2.5.6.2. 拒絕的條件
- 這里填寫了
${executeType=='YES'}
的意思是主管審批的時(shí)候傳遞一個(gè)executeType
變量,并且executeType
變量的值為NO
的時(shí)候,則結(jié)束流程
文章來源:http://www.zghlxwxcb.cn/news/detail-788911.html
2.6. 下載工作流程圖
文章來源地址http://www.zghlxwxcb.cn/news/detail-788911.html
<?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:flowable="http://flowable.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.flowable.org/processdef" exporter="Flowable Open Source Modeler"
exporterVersion="6.7.2">
<process id="MyLeave" name="MyLeave" isExecutable="true">
<documentation>員工請假流程</documentation>
<startEvent id="sid-159DD77D-9878-4288-AC29-B898E08DC216" flowable:formFieldValidation="true"></startEvent>
<userTask id="zgID" name="主管審批" flowable:assignee="張主管" flowable:formFieldValidation="true">
<extensionElements>
<modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler">
<![CDATA[false]]></modeler:initiator-can-complete>
</extensionElements>
</userTask>
<sequenceFlow id="sid-1E8F84D7-6C11-4D88-84C9-B818474F880E" sourceRef="sid-159DD77D-9878-4288-AC29-B898E08DC216"
targetRef="zgID"></sequenceFlow>
<exclusiveGateway id="sid-A6E285DA-5C65-4BA7-8BB4-5F4D97AC12E0"></exclusiveGateway>
<sequenceFlow id="sid-08020782-2DDE-4C56-BFC0-224DC99FB50E" sourceRef="zgID"
targetRef="sid-A6E285DA-5C65-4BA7-8BB4-5F4D97AC12E0"></sequenceFlow>
<endEvent id="sid-5BFB0FC6-B2A5-4F6E-9BDB-8785F2883AEB"></endEvent>
<userTask id="jlID" name="經(jīng)理審批" flowable:assignee="李經(jīng)理" flowable:formFieldValidation="true">
<extensionElements>
<modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler">
<![CDATA[false]]></modeler:initiator-can-complete>
</extensionElements>
</userTask>
<exclusiveGateway id="sid-0DA07C30-2930-40F5-A887-FA1C5BF307EF"></exclusiveGateway>
<sequenceFlow id="sid-833DAA1C-F1C2-41A1-8455-3FAB79893C14" sourceRef="jlID"
targetRef="sid-0DA07C30-2930-40F5-A887-FA1C5BF307EF"></sequenceFlow>
<endEvent id="sid-8941849E-B17F-4848-BFC8-C6B05CC21A9F"></endEvent>
<endEvent id="sid-3596170A-0E0F-4C07-BD32-F04AFB375EB1"></endEvent>
<sequenceFlow id="sid-A74937CE-02B1-493B-8033-08CA2D652771" name="同意"
sourceRef="sid-A6E285DA-5C65-4BA7-8BB4-5F4D97AC12E0" targetRef="jlID">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${executeType=='YES'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="sid-BE2005E1-26F7-4E42-8AC2-7C4F25274F1A" name="同意"
sourceRef="sid-0DA07C30-2930-40F5-A887-FA1C5BF307EF"
targetRef="sid-3596170A-0E0F-4C07-BD32-F04AFB375EB1">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${executeType=='YES'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="sid-67F146AA-C9F5-4A21-AF26-A77A349D80B7" name="拒絕"
sourceRef="sid-A6E285DA-5C65-4BA7-8BB4-5F4D97AC12E0"
targetRef="sid-5BFB0FC6-B2A5-4F6E-9BDB-8785F2883AEB">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${executeType=='NO'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="sid-4CC613DD-7789-408B-AFA0-1241261A4E79" name="拒絕"
sourceRef="sid-0DA07C30-2930-40F5-A887-FA1C5BF307EF"
targetRef="sid-8941849E-B17F-4848-BFC8-C6B05CC21A9F">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${executeType=='NO'}]]></conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_MyLeave">
<bpmndi:BPMNPlane bpmnElement="MyLeave" id="BPMNPlane_MyLeave">
<bpmndi:BPMNShape bpmnElement="sid-159DD77D-9878-4288-AC29-B898E08DC216"
id="BPMNShape_sid-159DD77D-9878-4288-AC29-B898E08DC216">
<omgdc:Bounds height="30.0" width="30.0" x="45.0" y="105.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="zgID" id="BPMNShape_zgID">
<omgdc:Bounds height="80.0" width="100.0" x="165.0" y="80.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-A6E285DA-5C65-4BA7-8BB4-5F4D97AC12E0"
id="BPMNShape_sid-A6E285DA-5C65-4BA7-8BB4-5F4D97AC12E0">
<omgdc:Bounds height="40.0" width="40.0" x="360.0" y="100.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-5BFB0FC6-B2A5-4F6E-9BDB-8785F2883AEB"
id="BPMNShape_sid-5BFB0FC6-B2A5-4F6E-9BDB-8785F2883AEB">
<omgdc:Bounds height="28.0" width="28.0" x="366.0" y="225.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="jlID" id="BPMNShape_jlID">
<omgdc:Bounds height="80.0" width="100.0" x="495.0" y="80.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-0DA07C30-2930-40F5-A887-FA1C5BF307EF"
id="BPMNShape_sid-0DA07C30-2930-40F5-A887-FA1C5BF307EF">
<omgdc:Bounds height="40.0" width="40.0" x="690.0" y="100.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-8941849E-B17F-4848-BFC8-C6B05CC21A9F"
id="BPMNShape_sid-8941849E-B17F-4848-BFC8-C6B05CC21A9F">
<omgdc:Bounds height="28.0" width="28.0" x="696.0" y="225.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-3596170A-0E0F-4C07-BD32-F04AFB375EB1"
id="BPMNShape_sid-3596170A-0E0F-4C07-BD32-F04AFB375EB1">
<omgdc:Bounds height="28.0" width="28.0" x="825.0" y="106.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sid-1E8F84D7-6C11-4D88-84C9-B818474F880E"
id="BPMNEdge_sid-1E8F84D7-6C11-4D88-84C9-B818474F880E" flowable:sourceDockerX="15.0"
flowable:sourceDockerY="15.0" flowable:targetDockerX="50.0" flowable:targetDockerY="40.0">
<omgdi:waypoint x="74.94999923927439" y="120.0"></omgdi:waypoint>
<omgdi:waypoint x="164.99999999991007" y="120.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-08020782-2DDE-4C56-BFC0-224DC99FB50E"
id="BPMNEdge_sid-08020782-2DDE-4C56-BFC0-224DC99FB50E" flowable:sourceDockerX="50.0"
flowable:sourceDockerY="40.0" flowable:targetDockerX="20.5" flowable:targetDockerY="20.5">
<omgdi:waypoint x="264.9499999999992" y="120.1509063444109"></omgdi:waypoint>
<omgdi:waypoint x="360.43939393938865" y="120.43939393939392"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-4CC613DD-7789-408B-AFA0-1241261A4E79"
id="BPMNEdge_sid-4CC613DD-7789-408B-AFA0-1241261A4E79" flowable:sourceDockerX="20.5"
flowable:sourceDockerY="20.5" flowable:targetDockerX="14.0" flowable:targetDockerY="14.0">
<omgdi:waypoint x="710.4194915254237" y="139.52220575783235"></omgdi:waypoint>
<omgdi:waypoint x="710.0588602435497" y="225.00012270930887"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-833DAA1C-F1C2-41A1-8455-3FAB79893C14"
id="BPMNEdge_sid-833DAA1C-F1C2-41A1-8455-3FAB79893C14" flowable:sourceDockerX="50.0"
flowable:sourceDockerY="40.0" flowable:targetDockerX="20.5" flowable:targetDockerY="20.5">
<omgdi:waypoint x="594.9499999999981" y="120.15090634441087"></omgdi:waypoint>
<omgdi:waypoint x="690.4393939393933" y="120.43939393939394"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-BE2005E1-26F7-4E42-8AC2-7C4F25274F1A"
id="BPMNEdge_sid-BE2005E1-26F7-4E42-8AC2-7C4F25274F1A" flowable:sourceDockerX="20.5"
flowable:sourceDockerY="20.5" flowable:targetDockerX="14.0" flowable:targetDockerY="14.0">
<omgdi:waypoint x="729.516569086651" y="120.42578125"></omgdi:waypoint>
<omgdi:waypoint x="825.0001009915921" y="120.054279921789"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-67F146AA-C9F5-4A21-AF26-A77A349D80B7"
id="BPMNEdge_sid-67F146AA-C9F5-4A21-AF26-A77A349D80B7" flowable:sourceDockerX="20.5"
flowable:sourceDockerY="20.5" flowable:targetDockerX="14.0" flowable:targetDockerY="14.0">
<omgdi:waypoint x="380.4194915254237" y="139.52220575783235"></omgdi:waypoint>
<omgdi:waypoint x="380.05886024354976" y="225.00012270930887"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-A74937CE-02B1-493B-8033-08CA2D652771"
id="BPMNEdge_sid-A74937CE-02B1-493B-8033-08CA2D652771" flowable:sourceDockerX="20.5"
flowable:sourceDockerY="20.5" flowable:targetDockerX="50.0" flowable:targetDockerY="40.0">
<omgdi:waypoint x="399.50196526507943" y="120.44207317073172"></omgdi:waypoint>
<omgdi:waypoint x="494.9999999999935" y="120.15182370820669"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
到了這里,關(guān)于Flowable工作流之Flowable UI畫工作流程圖的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!