術(shù)語(yǔ)
Workflow:工作流灾部,即在計(jì)算機(jī)中自動(dòng)化運(yùn)行的業(yè)務(wù)流程
WfMS:Workflow Management System,工作流管理系統(tǒng)
BPM:Business Process Management别洪,業(yè)務(wù)流程管理
PVM:Process Virtual Machine母债,流程虛擬機(jī)
OMG:Object Management Group(對(duì)象管理組織)暇昂,一個(gè)致力于建立( 程序舶得、系統(tǒng)掰烟、業(yè)務(wù)流程)建模標(biāo)準(zhǔn)的國(guó)際協(xié)會(huì)
OASIS:Organizationfor the Advancement of Structured Information Standards,結(jié)構(gòu)化信息標(biāo)準(zhǔn)促進(jìn)組織
WfMC:Workflow Management Coalition沐批,工作流程管理聯(lián)盟
XPDL:XML Process Definition Language纫骑,WfMC提出的業(yè)務(wù)流程描述規(guī)范
JPDL:JBoss jBPM Process Definition Language,jBPM的業(yè)務(wù)流程描述標(biāo)準(zhǔn)
BPEL:Business Process Execution Language九孩,業(yè)務(wù)過(guò)程執(zhí)行語(yǔ)言先馆,用來(lái)描述業(yè)務(wù)過(guò)程的XML規(guī)范
WSBPEL(BPEL-WS):Web Services Business Process Execution Language,OASIS發(fā)布的Web服務(wù)形式的BPEL
BPDM:Business Process Definition Metamodel躺彬,業(yè)務(wù)流程定義元模型磨隘,OMG組織提出的用來(lái)解決BPMN存儲(chǔ)和交換問(wèn)題的規(guī)范
BPMN:Business Process Model and Notation缤底,OMG推出的業(yè)務(wù)流程圖標(biāo)準(zhǔn)
CMMN:Case Management Model and Notation,OMG發(fā)布的案例管理圖標(biāo)準(zhǔn)番捂,是對(duì)BPMN的擴(kuò)展;它用聲明式表示法來(lái)描述流程
DMN:Decision Modeling Notation江解,OMG發(fā)布的決策建模圖標(biāo)準(zhǔn)设预,用于封裝BPMN中的業(yè)務(wù)決策邏輯(業(yè)務(wù)規(guī)則)
OA:Office Automation,辦公自動(dòng)化系統(tǒng)
ERP:Enterprise Resource Planning犁河,企業(yè)資源管理系統(tǒng)
CRM:Customer Relationship Management鳖枕,客戶(hù)關(guān)系管理系統(tǒng)
各種工作流引擎
jBPM(java Business Process Management):Tom Baeyens(湯姆 貝恩斯)于2003年發(fā)布,于2004 年加入JBoss桨螺,jBPM4引入了PVM宾符;而后Tom Baeyens離開(kāi)了JBoss,jBPM5 放棄了 jBPM 4灭翔,基于Drools Flow重頭來(lái)過(guò)
Activiti:Tom Baeyens離開(kāi)了JBoss后加入了Alfresco魏烫,于2010年推出了Activiti 5,Activiti 6移除了PVM
Camunda BPM:2012年Activiti的貢獻(xiàn)者之一Camunda(卡蒙達(dá))肝箱,從Activiti 5項(xiàng)目fork出一個(gè)新項(xiàng)目哄褒,即Camunda BPM
Flowable:2016年Activiti的開(kāi)發(fā)者之一Tijs Rademakers,從Activiti 6項(xiàng)目fork出一個(gè)新項(xiàng)目煌张,即Flowable 6
Osworkflow:OpenSymphony組織開(kāi)發(fā)的工作流引擎
馳騁BPM(ccbpm呐赡、JFlow):濟(jì)南馳騁信息技術(shù)有限公司開(kāi)發(fā)的工作流引擎
其他:Bonitasoft、Enhydra Shark骏融、ProcessMaker链嘀、Apache ODE等
相關(guān)資源
Drools:JBoss出品規(guī)則引擎
Drools Flow:Drools 的工作流組件
選型
Camunda功能較多,F(xiàn)lowable更活躍
Flowable 知識(shí)
官網(wǎng):https://www.flowable.org
五個(gè)官方應(yīng)用(包含于Flowable下載包里的wars目錄)
flowable-modeler.war:流程定義管理
flowable-task.war:用戶(hù)任務(wù)管理
flowable-idm.war:用戶(hù)組權(quán)限管理
flowable-rest.war:流程引擎對(duì)外提供的API接口
flowable-admin.war:后臺(tái)管理
流程設(shè)計(jì)器:將 flowable-modeler.war 和 flowable-idm.war部署到tomcat档玻,即可得到網(wǎng)頁(yè)版流程設(shè)計(jì)器(訪問(wèn)路徑為 /flowable-modeler怀泊,默認(rèn)賬號(hào)為 admin/test )
Flowable五大引擎(包含于Flowable下載包里的libs目錄)
ProcessEngine(流程引擎)、DmnEngine(決策引擎)窃肠、IdmEngine(身份識(shí)別引擎)包个、ContentEngine(內(nèi)容引擎)、FormEngine(表單引擎)
應(yīng)用首次啟動(dòng)時(shí)冤留,F(xiàn)lowable會(huì)往數(shù)據(jù)庫(kù)里添加一些表
ACT_RE_ *:RE代表repository碧囊。具有此前綴的表包含靜態(tài)信息,例如流程定義和流程資源(圖像纤怒,規(guī)則等)糯而。
ACT_RU_ *:RU代表runtime。這些是包含運(yùn)行時(shí)的流程實(shí)例泊窘,用戶(hù)任務(wù)熄驼,變量像寒,作業(yè)等的運(yùn)行時(shí)數(shù)據(jù)的運(yùn)行時(shí)表。Flowable僅在流程實(shí)例執(zhí)行期間存儲(chǔ)運(yùn)行時(shí)數(shù)據(jù)瓜贾,并在流程實(shí)例結(jié)束時(shí)刪除記錄诺祸。這使運(yùn)行時(shí)表保持小而快。
ACT_HI_ *:HI代表history祭芦。這些是包含歷史數(shù)據(jù)的表筷笨,例如過(guò)去的流程實(shí)例,變量龟劲,任務(wù)等
ACT_GE_ :general數(shù)據(jù)胃夏,用于各種用例
ACT_ID_:Idm的用戶(hù)、組
Flowable應(yīng)用組成
1昌跌、創(chuàng)建 SpringBoot + Mybatis 項(xiàng)目
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 為后綴)答恶,可以由流程設(shè)計(jì)器導(dǎo)出
<?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="請(qǐng)假" flowable:assignee="${leaveTask}"/>
<userTask id="managerTask" name="經(jīng)理審核"/>
<exclusiveGateway id="managerJudgeTask"/>
<endEvent id="endLeave" name="結(jié)束"/>
<startEvent id="startLeave" name="開(kāi)始"/>
<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="通過(guò)" sourceRef="managerJudgeTask" targetRef="endLeave">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[${checkResult=='通過(guò)'}]]>
</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 = "實(shí)例化一個(gè)流程")
@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() + ";首個(gè)task的id:" + tasks.get(0).getId();
}
@ApiOperation(value = "結(jié)束一個(gè)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 "申請(qǐng)審核駁回";
}
}
已有系統(tǒng)整合 IdmEngine
方案一:將已有系統(tǒng)中的用戶(hù)權(quán)限數(shù)據(jù) 同步到 ACT_ID_*表中
方案二:保留一方的表审胸,另一方通過(guò)數(shù)據(jù)庫(kù)視圖來(lái)訪問(wèn)數(shù)據(jù)
阿里云
Serverless 工作流