可以看所有網(wǎng)站的瀏覽器線在成都網(wǎng)站推廣公司
springCloud集成activiti5.22.0流程引擎
點(diǎn)關(guān)注不迷路,歡迎再訪!
精簡(jiǎn)博客內(nèi)容,盡量已行業(yè)術(shù)語(yǔ)來(lái)分享。
努力做到對(duì)每一位認(rèn)可自己的讀者負(fù)責(zé)。
幫助別人的同時(shí)更是豐富自己的良機(jī)。
文章目錄
- springCloud集成activiti5.22.0流程引擎
- 一.Spring boot2.x與Activiti 5.22.0整合
- 1.POM文件中添加依賴
- 二.制作bpmn流程文件
- 創(chuàng)建bpmn文件
- 三.流程演示
- 分支審批
一.Spring boot2.x與Activiti 5.22.0整合
1.POM文件中添加依賴
<dependency><groupId>org.activiti</groupId><artifactId>activiti-spring-boot-starter-basic</artifactId><version>5.22.0</version><exclusions><!-- 排除activiti的mybatis,避免和外面的mybatis-plus沖突 --><exclusion><artifactId>mybatis</artifactId><groupId>org.mybatis</groupId></exclusion></exclusions>
</dependency>
二.制作bpmn流程文件
創(chuàng)建bpmn文件
右鍵該文件夾New–>BPMN File 創(chuàng)建名為leave_flow的流程文件
文件名"xxx.bpmn" 更改為 “xxx.bpmn.xml”
注: 因?yàn)閍ctiviti的默認(rèn)流程圖格式是bpmn, 但是idea必須xml格式才能生成圖片, 所以改為這樣, 后面部署流程的時(shí)候才可以部署上去, 否則是存不進(jìn)數(shù)據(jù)庫(kù).
<?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/testm1723732311976" 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="m1723732311976" name="" targetNamespace="http://www.activiti.org/testm1723732311976" typeLanguage="http://www.w3.org/2001/XMLSchema"><process id="leaveProcess" isClosed="false" isExecutable="true" name="請(qǐng)假審批流程" processType="None"><startEvent id="STEP1" name="開(kāi)始"/><userTask activiti:assignee="${userId}" activiti:exclusive="true" id="STEP2" name="員工"/><userTask activiti:assignee="${userId}" activiti:exclusive="true" id="STEP3" name="經(jīng)理"/><endEvent id="STEP4" name="結(jié)束"/><sequenceFlow id="_6" sourceRef="STEP1" targetRef="STEP2"/><sequenceFlow id="_7" sourceRef="STEP2" targetRef="STEP3"/><exclusiveGateway gatewayDirection="Unspecified" id="_8" name="ExclusiveGateway"/><sequenceFlow id="_2" name="同意" sourceRef="_8" targetRef="STEP4"><conditionExpression xsi:type="tFormalExpression"><![CDATA[${accept==”同意”}]]></conditionExpression></sequenceFlow><sequenceFlow id="_3" sourceRef="STEP3" targetRef="_8"/><sequenceFlow id="_4" name="駁回" sourceRef="_8" targetRef="STEP2"><conditionExpression xsi:type="tFormalExpression"><![CDATA[${accept==”駁回”}]]></conditionExpression></sequenceFlow></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="leaveProcess"><bpmndi:BPMNShape bpmnElement="STEP1" id="Shape-STEP1"><dc:Bounds height="32.0" width="32.0" x="160.0" y="40.0"/><bpmndi:BPMNLabel><dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="STEP2" id="Shape-STEP2"><dc:Bounds height="55.0" width="85.0" x="130.0" y="145.0"/><bpmndi:BPMNLabel><dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="STEP3" id="Shape-STEP3"><dc:Bounds height="55.0" width="85.0" x="135.0" y="275.0"/><bpmndi:BPMNLabel><dc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="STEP4" id="Shape-STEP4"><dc:Bounds height="32.0" width="32.0" x="325.0" y="525.0"/><bpmndi:BPMNLabel><dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNShape><bpmndi:BPMNShape bpmnElement="_8" id="Shape-_8" isMarkerVisible="false"><dc:Bounds height="32.0" width="32.0" x="325.0" y="400.0"/><bpmndi:BPMNLabel><dc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNShape><bpmndi:BPMNEdge bpmnElement="_2" id="BPMNEdge__2" sourceElement="_8" targetElement="STEP4"><di:waypoint x="341.0" y="432.0"/><di:waypoint x="341.0" y="525.0"/><bpmndi:BPMNLabel><dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="_3" id="BPMNEdge__3" sourceElement="STEP3" targetElement="_8"><di:waypoint x="175.0" y="330.0"/><di:waypoint x="175.0" y="410.0"/><di:waypoint x="331.0" y="410.0"/><bpmndi:BPMNLabel><dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="_4" id="BPMNEdge__4" sourceElement="_8" targetElement="STEP2"><di:waypoint x="340.0" y="401.0"/><di:waypoint x="340.0" y="285.0"/><di:waypoint x="215.0" y="172.5"/><bpmndi:BPMNLabel><dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="_6" id="BPMNEdge__6" sourceElement="STEP1" targetElement="STEP2"><di:waypoint x="176.0" y="72.0"/><di:waypoint x="176.0" y="145.0"/><bpmndi:BPMNLabel><dc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/></bpmndi:BPMNLabel></bpmndi:BPMNEdge><bpmndi:BPMNEdge bpmnElement="_7" id="BPMNEdge__7" sourceElement="STEP2" targetElement="STEP3"><di:waypoint x="175.0" y="200.0"/><di:waypoint x="175.0" y="275.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>
三.流程演示
分支審批
@Overridepublic void assginLeaveWorkFlow(String processInstanceId,int isAccept,String userId) {Map<String,Object> map = new HashMap<>();//得到當(dāng)前實(shí)例下的taskTask task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();taskService.addComment(task.getId(), processInstanceId, "審核人是否同意該請(qǐng)假流程");if(isAccept == 0){map.put("accept","同意");task.setAssignee(userId);map.put("userId", userId);}else{map.put("accept","駁回");//審核駁回后task.setAssignee("發(fā)起人");map.put("auditor","發(fā)起人");}task.setDescription("請(qǐng)假的描述信息");//執(zhí)行當(dāng)前這個(gè)工作流任務(wù)taskService.saveTask(task);taskService.complete(task.getId(), map);}