术语
Workflow:工作流,即在计算机中自动化运行的业务流程
WfMS:Workflow Management System,工作流管理系统
BPM:Business Process Management,业务流程管理
PVM:Process Virtual Machine,流程虚拟机
OMG:Object Management Group(对象管理组织),一个致力于建立( 程序、系统、业务流程)建模标准的国际协会
OASIS:Organizationfor the Advancement of Structured Information Standards,结构化信息标准促进组织
WfMC:Workflow Management Coalition,工作流程管理联盟
XPDL:XML Process Definition Language,WfMC提出的业务流程描述规范
JPDL:JBoss jBPM Process Definition Language,jBPM的业务流程描述标准
BPEL:Business Process Execution Language,业务过程执行语言,用来描述业务过程的XML规范
WSBPEL(BPEL-WS):Web Services Business Process Execution Language,OASIS发布的Web服务形式的BPEL
BPDM:Business Process Definition Metamodel,业务流程定义元模型,OMG组织提出的用来解决BPMN存储和交换问题的规范
BPMN:Business Process Model and Notation,OMG推出的业务流程图标准
CMMN:Case Management Model and Notation,OMG发布的案例管理图标准,是对BPMN的扩展;它用声明式表示法来描述流程
DMN:Decision Modeling Notation,OMG发布的决策建模图标准,用于封装BPMN中的业务决策逻辑(业务规则)
OA:Office Automation,办公自动化系统
ERP:Enterprise Resource Planning,企业资源管理系统
CRM:Customer Relationship Management,客户关系管理系统
各种工作流引擎
jBPM(java Business Process Management):Tom Baeyens(汤姆 贝恩斯)于2003年发布,于2004 年加入JBoss,jBPM4引入了PVM;而后Tom Baeyens离开了JBoss,jBPM5 放弃了 jBPM 4,基于Drools Flow重头来过
Activiti:Tom Baeyens离开了JBoss后加入了Alfresco,于2010年推出了Activiti 5,Activiti 6移除了PVM
Camunda BPM:2012年Activiti的贡献者之一Camunda(卡蒙达),从Activiti 5项目fork出一个新项目,即Camunda BPM
Flowable:2016年Activiti的开发者之一Tijs Rademakers,从Activiti 6项目fork出一个新项目,即Flowable 6
Osworkflow:OpenSymphony组织开发的工作流引擎
驰骋BPM(ccbpm、JFlow):济南驰骋信息技术有限公司开发的工作流引擎
其他:Bonitasoft、Enhydra Shark、ProcessMaker、Apache ODE等
相关资源
Drools:JBoss出品规则引擎
Drools Flow:Drools 的工作流组件
选型
Camunda功能较多,Flowable更活跃
Flowable 知识
五个官方应用(包含于Flowable下载包里的wars目录)
flowable-modeler.war:流程定义管理
flowable-task.war:用户任务管理
flowable-idm.war:用户组权限管理
flowable-rest.war:流程引擎对外提供的API接口
flowable-admin.war:后台管理
流程设计器:将 flowable-modeler.war 和 flowable-idm.war部署到tomcat,即可得到网页版流程设计器(访问路径为 /flowable-modeler,默认账号为 admin/test )
Flowable五大引擎(包含于Flowable下载包里的libs目录)
ProcessEngine(流程引擎)、DmnEngine(决策引擎)、IdmEngine(身份识别引擎)、ContentEngine(内容引擎)、FormEngine(表单引擎)
应用首次启动时,Flowable会往数据库里添加一些表
ACT_RE_ *:RE代表repository。具有此前缀的表包含静态信息,例如流程定义和流程资源(图像,规则等)。
ACT_RU_ *:RU代表runtime。这些是包含运行时的流程实例,用户任务,变量,作业等的运行时数据的运行时表。Flowable仅在流程实例执行期间存储运行时数据,并在流程实例结束时删除记录。这使运行时表保持小而快。
ACT_HI_ *:HI代表history。这些是包含历史数据的表,例如过去的流程实例,变量,任务等
ACT_GE_ :general数据,用于各种用例
ACT_ID_:Idm的用户、组
Flowable应用组成
1、创建 SpringBoot + Mybatis 项目
2、pom.xml
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter</artifactId>
<version>6.5.0</version>
</dependency>
3、流程配置xml(放在/resources/processes下,以 .bpmn2.xml 为后缀),可以由流程设计器导出
<?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: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">
<process id="Leave" name="LeaveProcess" isExecutable="true">
<userTask id="leaveTask" name="请假" flowable:assignee="${leaveTask}"/>
<userTask id="managerTask" name="经理审核"/>
<exclusiveGateway id="managerJudgeTask"/>
<endEvent id="endLeave" name="结束"/>
<startEvent id="startLeave" name="开始"/>
<sequenceFlow id="modeFlow" sourceRef="leaveTask" targetRef="managerTask"/>
<sequenceFlow id="flowStart" sourceRef="startLeave" targetRef="leaveTask"/>
<sequenceFlow id="jugdeFlow" sourceRef="managerTask" targetRef="managerJudgeTask"/>
<endEvent id="endLeave2"/>
<sequenceFlow id="flowEnd" name="通过" sourceRef="managerJudgeTask" targetRef="endLeave">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[${checkResult=='通过'}]]>
</conditionExpression>
</sequenceFlow>
<sequenceFlow id="rejectFlow" name="驳回" sourceRef="managerJudgeTask"
targetRef="endLeave2">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[${checkResult=='驳回'}]]>
</conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_process">
<bpmndi:BPMNPlane bpmnElement="Leave" id="BPMNPlane_process">
<bpmndi:BPMNShape bpmnElement="leaveTask" id="BPMNShape_leaveTask">
<omgdc:Bounds height="79.99999999999999" width="100.0" x="304.60807973558974" y="122.00000000000001"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="managerTask" id="BPMNShape_managerTask">
<omgdc:Bounds height="80.0" width="100.0" x="465.0" y="122.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="managerJudgeTask" id="BPMNShape_managerJudgeTask">
<omgdc:Bounds height="40.0" width="40.0" x="611.5" y="142.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endLeave" id="BPMNShape_endLeave">
<omgdc:Bounds height="28.0" width="28.0" x="696.5" y="148.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="startLeave" id="BPMNShape_startLeave">
<omgdc:Bounds height="30.0" width="30.0" x="213.2256558149128" y="147.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endLeave2"
id="BPMNShape_endLeave2">
<omgdc:Bounds height="28.0" width="28.0" x="617.5" y="73.32098285753572"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flowEnd" id="BPMNEdge_flowEnd">
<omgdi:waypoint x="651.1217948717949" y="162.37820512820514"/>
<omgdi:waypoint x="696.5002839785394" y="162.0891701657418"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="rejectFlow" id="BPMNEdge_rejectFlow">
<omgdi:waypoint x="631.866093577786" y="142.36609357778607" />
<omgdi:waypoint x="631.5931090276993" y="101.32067323657485" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="modeFlow" id="BPMNEdge_modeFlow">
<omgdi:waypoint x="404.60807973558974" y="162.0" />
<omgdi:waypoint x="465.0" y="162.0" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flowStart" id="BPMNEdge_flowStart">
<omgdi:waypoint x="243.2256558149128" y="162.0" />
<omgdi:waypoint x="304.60807973558974" y="162.0" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="jugdeFlow" id="BPMNEdge_jugdeFlow">
<omgdi:waypoint x="565.0" y="162.21367521367523" />
<omgdi:waypoint x="611.9141630901288" y="162.41416309012877" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
4、Controller
@RestController
@RequestMapping(value = "/flow")
public class FlowController {
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
@ApiOperation(value = "实例化一个流程")
@RequestMapping(value = "/start", method = RequestMethod.POST)
public String startLeaveProcess(@RequestParam String staffId) {
HashMap<String, Object> map = new HashMap<>();
map.put("leaveTask", staffId);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Leave", map);
List<Task> tasks = taskService.createTaskQuery().taskAssignee(staffId).orderByTaskCreateTime().desc().list();
return "processId:" + processInstance.getId() + ";首个task的id:" + tasks.get(0).getId();
}
@ApiOperation(value = "结束一个task")
@RequestMapping(value = "/reject", method = RequestMethod.PUT)
public String rejectTask(@RequestParam String taskId) {
HashMap<String, Object> map = new HashMap<>();
map.put("checkResult", "驳回");
taskService.complete(taskId, map);
return "申请审核驳回";
}
}
已有系统整合 IdmEngine
方案一:将已有系统中的用户权限数据 同步到 ACT_ID_*表中
方案二:保留一方的表,另一方通过数据库视图来访问数据
阿里云
Serverless 工作流