上一篇我们学习了BPMN2.0规范 链接 ,知道了BPMN2.0规范是为了帮助我们规范的画流程图的,那么到底应该怎么画呢?这里给大家介绍一些遵循BPMN2.0规范的画图工具。
说明:业务流程图是用来定义具体的业务流程的,这里的业务流程图是依据BPMN2.0规范画的图,即.bpmn或.bpmn20.文件。
一、画业务流程图的工具
这种方式的好处就是上手简单,能实现业务流程的可视化图形建模,使业务流程变得清晰明了,即使不太专业的人员在了解了bpmn标记符号后,也能快速的画出标准的业务流程图。
可用的工具有:
1、activiti-app(activiti6官方demo,主要用他的流程设计器)
获取方式:从activiti官网下载activiti6的资源包,资源包里有个activiti-app.war文件,将这个war包放到tomcat下运行即可,默认的登录账号密码:admin/test。(要用tomcat7.0来运行,tomcat8会登录不上去)
具体方式可参照:SpringBoot Activiti6系列教程(一)-activiti-app部署
ps:可以看看他的代码,将这个流程设计器作为模块集成到项目里面,也是个不错的选择。
2、集成开发环境的bpmn插件
》》》先介绍idea的插件actiBPM
步骤:
1、打开idea的插件浏览器,搜索 actiBPM ,安装并重启idea。
2、右键菜单-》New,就会发现多了Bpmn File 选项,新建一个bpmn file,如果出现以下界面,就说明安装成功了
上面每个符号什么意思都标注出来了,大家可以参照上一章 BPMN2.0规范 画出以下这个请假的业务流程图,接下来的helloworld将会以此流程图来讲解。
ps:刚开始可能不太熟练,多去尝试几次就好了,加油!
解决两个小问题:
1、生成的bpmn文件内容中文乱码
解决:根据电脑版本,修改idea安装目录bin/idea64.exe.vmoptions文件,添加一行内容,重启idea即可。
2、如何生成bpmn文件对应的图片?
解决:idea中修改创建的.bpmn文件后缀为.xml,然后xml文件上右键Diagrams->show BPMN2.0 Designer->export to file即可
》》》再介绍eclipse的插件 Activiti Designer(推荐)
idea的actiBPM插件,当idea版本超过2019版时会有些小问题,所以还是推荐eclipse的插件Activiti Designer相对来说好用些。
我的是5.18版的,选择离线安装的方式。
具体安装方式百度吧
3、网上在线的流程设计器
例如:https://bpmn.52itstyle.vip/ (能导出bpmn文件,但bpmn文件能不能用没试过)
ProcessOn - 免费在线作图,思维导图,流程图,实时协作 (不能生成.bpmn文件,只能画好看的图)
4、其他画图软件,只要支持BPMN2.0规范都可以。
ps:目前我只找到了以上工具,没有找到特别顺手的工具,有好的推荐工具的小伙伴,请在评论区留言,好东西要分享。
值得注意的是,我们画的业务流程图,最终也是要转化成了.bpmn或.bpmn20.xml文件,才能被工作流引擎部署执行。1、2工具画的图虽然丑了点,但是能直接生成bpmn文件,省的再去编写了。3、4虽然画的图好看,但是不能生成bpmn文件,还用自己手动转换成bpmn文件。
方式二:手写xml文件
.bpmn或.bpmn20.xml本质上也是具有bpmn规范的xml文件,有特定的语法格式。学会了该语法就可以像写html加css一样,以标记语言的方式画业务流程图了,只需要找到能解析该语法的工具或环境,就能看到我们写的“代码”的效果。能看懂并手写.bpmn文件对我们学习bpmn规范和acticiti7的工作原理还是很有帮助的。
二、bpmn文件内容解析
以下是上一步在idea中画好的holiday.bpmn文件内容:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/testm1618019760798" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1618019760798" name="" targetNamespace="http://www.activiti.org/testm1618019760798" typeLanguage="http://www.w3.org/2001/XMLSchema">
<!--业务流程定义-->
<process id="holiday" isClosed="false" isExecutable="true" name="请假流程" processType="None">
<startEvent id="_2" name="开始">
<documentation id="_2_D_1"><![CDATA[开始事件的描述]]></documentation>
</startEvent>
<userTask activiti:assignee="zhangsan" activiti:exclusive="true" id="_3" name="填写请假单">
<documentation id="_3_D_1"><![CDATA[填写请假单描述]]></documentation>
</userTask>
<userTask activiti:assignee="lisi" activiti:exclusive="true" id="_4" name="部门经理">
<documentation id="_4_D_1"><![CDATA[部门经理审批描述]]></documentation>
</userTask>
<userTask activiti:assignee="wangwu" activiti:exclusive="true" id="_5" name="总经理">
<documentation id="_5_D_1"><![CDATA[总经理审批描述]]></documentation>
</userTask>
<endEvent id="_6" name="结束"/>
<sequenceFlow id="_7" sourceRef="_2" targetRef="_3"/>
<sequenceFlow id="_8" sourceRef="_3" targetRef="_4"/>
<sequenceFlow id="_9" sourceRef="_4" targetRef="_5"/>
<sequenceFlow id="_10" sourceRef="_5" targetRef="_6"/>
</process>
<!--对业务流程图的定义,大小、坐标、符号类型、互相引用等信息-->
<bpmndi:BPMNDiagram documentation="background=#3C3F41;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">
<bpmndi:BPMNPlane bpmnElement="holiday">
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
<dc:Bounds height="32.0" width="32.0" x="240.0" y="45.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3">
<dc:Bounds height="55.0" width="85.0" x="215.0" y="140.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_4" id="Shape-_4">
<dc:Bounds height="55.0" width="85.0" x="215.0" y="240.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_5" id="Shape-_5">
<dc:Bounds height="55.0" width="85.0" x="215.0" y="335.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_6" id="Shape-_6">
<dc:Bounds height="32.0" width="32.0" x="240.0" y="460.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_7" id="BPMNEdge__7" sourceElement="_2" targetElement="_3">
<di:waypoint x="256.0" y="77.0"/>
<di:waypoint x="256.0" y="140.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_8" id="BPMNEdge__8" sourceElement="_3" targetElement="_4">
<di:waypoint x="257.5" y="195.0"/>
<di:waypoint x="257.5" y="240.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_9" id="BPMNEdge__9" sourceElement="_4" targetElement="_5">
<di:waypoint x="257.5" y="295.0"/>
<di:waypoint x="257.5" y="335.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_10" id="BPMNEdge__10" sourceElement="_5" targetElement="_6">
<di:waypoint x="256.0" y="390.0"/>
<di:waypoint x="256.0" y="460.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
解析:
1、可以看出这是一个xml文件,有个根元素definitions用于包含多个流程定义,但一般建议一个.bpmn文件是一个流程定义。
2、分为两大块,process块和bpmndi块。
3、process块的内容符合第一章讲的BPMN2.0规范,根据第一章讲的你会发现整个process块的内容你都能看懂。该process块的主要作用是定义业务流程信息,最终被工作流引擎解析并读取里面的内容,至于他是怎么读取并解析的,会在 acitivit7 Helloworld的activiti7工作原理中说明。
4、bpmndi块定义业务流程图形的信息,主要用于展示,不会对流程执行产生任何影响。
三、后记
ok,以上画图工具也有了,基本的业务流程图也画出来了,可谓万事俱备只欠东风啊!
接下来就要把画好的holiday.bpmn交给activiti解析和执行了,具体怎么样去执行?我会在接下来的activiti7 helloworld一文中说明,一起来看看吧!