当前位置:网站首页>Activiti directory (III) deployment process and initiation process
Activiti directory (III) deployment process and initiation process
2022-07-06 16:59:00 【Motorcycle loving program ape】
hold Activiti Into your head , Through the drawing process 、 Deployment process 、 The way to initiate the process quickly enters
Catalog
Activiti( One ) Getting started
One 、BPMN technological process
Content explanation :
applyState:0 Students ask for leave 1 Approved by the teacher 2 The teacher leader approved 3 The president's approval ends 4 Leave rejection 6 Students reapply
applyExamine: Who does the student reapply to after rejection
Gareway: It's better to report an error if you have to meet one condition 
struApply.bpmn20.xml:
<?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:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/test" 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="m1651751051110" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema">
<process id="myProcess_1" isClosed="false" isExecutable="true" processType="None">
<startEvent activiti:formKey="LeaveShanghaiApply" id="_2" name="StartEvent"/>
<userTask activiti:assignee="${userName1}" activiti:async="false" activiti:candidateUsers="${userIds1}" activiti:exclusive="true" id="_3" name="teacher">
<documentation id="_3_D_1"/>
</userTask>
<userTask activiti:assignee="${userName2}" activiti:candidateUsers="${userIds2}" activiti:exclusive="true" id="_4" name="academy"/>
<userTask activiti:assignee="${userName3}" activiti:candidateUsers="${userIds3}" activiti:exclusive="true" id="_5" name="epidemicGroup"/>
<endEvent id="_17" name="EndEvent"/>
<exclusiveGateway gatewayDirection="Unspecified" id="_9" name="ExclusiveGateway1"/>
<sequenceFlow id="_10" name="success" sourceRef="_9" targetRef="_4">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${applyState==1}]]></conditionExpression>
</sequenceFlow>
<exclusiveGateway gatewayDirection="Unspecified" id="_13" name="ExclusiveGateway2"/>
<sequenceFlow id="_15" sourceRef="_4" targetRef="_13"/>
<sequenceFlow id="_16" name="success" sourceRef="_13" targetRef="_5">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${applyState==2}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="_27" sourceRef="_3" targetRef="_9"/>
<userTask activiti:assignee="${userId}" activiti:exclusive="true" id="_28" name="strudent"/>
<sequenceFlow id="_29" name="reject" sourceRef="_9" targetRef="_28">
<documentation id="_29_D_1"><![CDATA[1]]></documentation>
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${applyState==4}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="_30" name="reject" sourceRef="_13" targetRef="_28">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${applyState==4}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="_32" sourceRef="_2" targetRef="_28"/>
<exclusiveGateway gatewayDirection="Unspecified" id="_35" name="ExclusiveGateway3"/>
<sequenceFlow id="_36" sourceRef="_5" targetRef="_35"/>
<sequenceFlow id="_37" name="success" sourceRef="_35" targetRef="_17">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${applyState==3}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="_38" name="reject" sourceRef="_35" targetRef="_28">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${applyState==4}]]></conditionExpression>
</sequenceFlow>
<exclusiveGateway gatewayDirection="Unspecified" id="_45" name="ExclusiveGateway"/>
<sequenceFlow id="_46" sourceRef="_45" targetRef="_3">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${applyExamine==teacher}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="_48" sourceRef="_45" targetRef="_4">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${applyExamine==academy}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="_49" sourceRef="_45" targetRef="_5">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${applyExamine==epidemicGroup}]]></conditionExpression>
</sequenceFlow>
<exclusiveGateway gatewayDirection="Unspecified" id="_6" name="ExclusiveGateway"/>
<sequenceFlow id="_7" sourceRef="_28" targetRef="_6"/>
<sequenceFlow id="_8" sourceRef="_6" targetRef="_3">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${applyState==0}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="_11" sourceRef="_6" targetRef="_45">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${applyState==6}]]></conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram documentation="background=#FFFFFF;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="myProcess_1">
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
<omgdc:Bounds height="32.0" width="32.0" x="130.0" y="690.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3">
<omgdc:Bounds height="55.0" width="85.0" x="440.0" y="290.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_4" id="Shape-_4">
<omgdc:Bounds height="55.0" width="90.0" x="715.0" y="235.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="90.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_5" id="Shape-_5">
<omgdc:Bounds height="55.0" width="110.0" x="965.0" y="155.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="110.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_17" id="Shape-_17">
<omgdc:Bounds height="32.0" width="32.0" x="1005.0" y="715.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_9" id="Shape-_9" isMarkerVisible="false">
<omgdc:Bounds height="32.0" width="32.0" x="470.0" y="415.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_13" id="Shape-_13" isMarkerVisible="false">
<omgdc:Bounds height="32.0" width="32.0" x="740.0" y="460.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_28" id="Shape-_28">
<omgdc:Bounds height="55.0" width="85.0" x="75.0" y="545.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_35" id="Shape-_35" isMarkerVisible="false">
<omgdc:Bounds height="32.0" width="32.0" x="1000.0" y="545.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_45" id="Shape-_45" isMarkerVisible="false">
<omgdc:Bounds height="32.0" width="32.0" x="100.0" y="170.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_6" id="Shape-_6" isMarkerVisible="false">
<omgdc:Bounds height="32.0" width="32.0" x="100.0" y="325.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_15" id="BPMNEdge__15" sourceElement="_4" targetElement="_13">
<omgdi:waypoint x="756.0" y="290.0"/>
<omgdi:waypoint x="756.0" y="460.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_37" id="BPMNEdge__37" sourceElement="_35" targetElement="_17">
<omgdi:waypoint x="1018.5" y="574.5"/>
<omgdi:waypoint x="1018.5" y="715.1965193707209"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_36" id="BPMNEdge__36" sourceElement="_5" targetElement="_35">
<omgdi:waypoint x="1016.0" y="210.0"/>
<omgdi:waypoint x="1016.0" y="545.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_16" id="BPMNEdge__16" sourceElement="_13" targetElement="_5">
<omgdi:waypoint x="772.0" y="476.0"/>
<omgdi:waypoint x="965.0" y="182.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_38" id="BPMNEdge__38" sourceElement="_35" targetElement="_28">
<omgdi:waypoint x="1008.0" y="569.0"/>
<omgdi:waypoint x="681.0" y="569.0"/>
<omgdi:waypoint x="160.0" y="569.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="99.0" x="0.0" y="21.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_46" id="BPMNEdge__46" sourceElement="_45" targetElement="_3">
<omgdi:waypoint x="132.0" y="186.0"/>
<omgdi:waypoint x="440.0" y="317.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_48" id="BPMNEdge__48" sourceElement="_45" targetElement="_4">
<omgdi:waypoint x="132.0" y="186.0"/>
<omgdi:waypoint x="715.0" y="262.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="-2.0" width="0.0" x="0.0" y="2.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_27" id="BPMNEdge__27" sourceElement="_3" targetElement="_9">
<omgdi:waypoint x="486.0" y="345.0"/>
<omgdi:waypoint x="486.0" y="415.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_49" id="BPMNEdge__49" sourceElement="_45" targetElement="_5">
<omgdi:waypoint x="131.0" y="185.0"/>
<omgdi:waypoint x="565.0" y="185.0"/>
<omgdi:waypoint x="965.0" y="185.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="95.0" x="0.0" y="-10.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_29" id="BPMNEdge__29" sourceElement="_9" targetElement="_28">
<omgdi:waypoint x="470.0" y="431.0"/>
<omgdi:waypoint x="335.0" y="505.0"/>
<omgdi:waypoint x="160.0" y="572.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="69.0" width="-75.0" x="-1.0" y="-20.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_7" id="BPMNEdge__7" sourceElement="_28" targetElement="_6">
<omgdi:waypoint x="116.0" y="545.0"/>
<omgdi:waypoint x="116.0" y="357.0"/>
<bpmndi:BPMNLabel>
<omgdc: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="_6" targetElement="_3">
<omgdi:waypoint x="132.0" y="341.0"/>
<omgdi:waypoint x="440.0" y="317.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_30" id="BPMNEdge__30" sourceElement="_13" targetElement="_28">
<omgdi:waypoint x="740.0" y="476.0"/>
<omgdi:waypoint x="490.0" y="570.0"/>
<omgdi:waypoint x="160.0" y="570.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="-94.0" width="46.0" x="0.0" y="19.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_11" id="BPMNEdge__11" sourceElement="_6" targetElement="_45">
<omgdi:waypoint x="116.0" y="325.0"/>
<omgdi:waypoint x="116.0" y="202.0"/>
<bpmndi:BPMNLabel>
<omgdc: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="_9" targetElement="_4">
<omgdi:waypoint x="502.0" y="431.0"/>
<omgdi:waypoint x="715.0" y="262.5"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_32" id="BPMNEdge__32" sourceElement="_2" targetElement="_28">
<omgdi:waypoint x="145.0" y="690.0312805773287"/>
<omgdi:waypoint x="145.0" y="600.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>

Two 、 Deployment process
/** * Deployment process * TODO 1: Get configuration object * TODO 2: Create core engine * TODO 3: Get warehouse services * TODO 4: Deployment process ( Point to BPMN file 、BPMN Figure address ) * @author hjj */
public Result deploymentProcess() {
// Deploy
Deployment deployment = repositoryService // Get deployment related Service
.createDeployment() // Create deployment
.key("struApplyProcess") // Set the deployment process key
.addClasspathResource("bpmn/struApply.bpmn20.xml") // add to bpmn file
// .addClasspathResource("bpmn/struApply.png") // add to png file
.name(" Student leave process ") // Set the process name
.deploy(); // Deploy
return Result.success(" Process deployment ID:"+deployment.getId() + " - " + " Process deployment Name:"+deployment.getName()+ " - " + " Process deployment KEY:"+deployment.getKey());
}
3、 ... and 、 Initiate process
/** * Start a process * TODO 1: Query the user * TODO 2: Start the application process and set the process instance ID And auditors * TODO 3: According to the process example ID Get the process instance application task * TODO 4: Set the application task executor * TODO 5: Launch the application task * TODO 6: According to the process example ID Associate business information and add business information ( one-on-one ) * TODO 7: Return whether the application is successful * @param apply Application record information * @return * @author hjj */
public Task startProcess(Apply apply){
// Current login user information
if (null == apply.getApplyEmail()) return null;
String userId = apply.getApplyEmail();
// Query the process being executed
HistoricTaskInstanceQuery histTask = historyService.createHistoricTaskInstanceQuery().taskAssignee(userId).orderByHistoricTaskInstanceStartTime().desc();
List<HistoricTaskInstance> tasks = null != histTask && 0 < histTask.list().size() ?
histTask.list() : new ArrayList<>();
// Whether the process exists
Execution execution = 0 < tasks.size() ?
runtimeService.createExecutionQuery().parentId(tasks.get(0).getProcessInstanceId()).singleResult() : null;
if (Objects.isNull(execution)) {
// Process does not exist
// teacher Ids
String teacherIds = "130,134,124";
// Teacher leadership Ids
String academyIds = "133,145";
// dean Ids
String epidemicGroupIds = "160";
// Of process variables map Person in charge of setting the task
Map<String,Object> variablesMap = new HashMap<>();
variablesMap.put("userId",userId);
variablesMap.put("userName1","teacher");// Contact the teacher IDs
variablesMap.put("userIds1",teacherIds);
variablesMap.put("userName2","academy");// Teacher leadership ID
variablesMap.put("userIds2",academyIds);
variablesMap.put("userName3","epidemicGroup");// dean IDs
variablesMap.put("userIds3",epidemicGroupIds);
try {
// Start process instance key For deployment flowchart process-ID
ProcessInstance processInstance = this.runtimeService.startProcessInstanceByKey("myProcess_1", variablesMap);
// Process instance ID
String processInstanceId = processInstance.getId();
// After the process instance starts , The process will jump to the application node
Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
// Launch the application task
Map<String, Object> args = new HashMap<>();
args.put("applyState", "0");// Set process parameters
taskService.complete(task.getId(), args);
return task;
}catch (Exception e){
log.error(e.getMessage());
return null;
}
} else {
// Process already exists
String processInstanceId = execution.getProcessInstanceId();
// After the process instance starts , The process will jump to the application node
Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
if(task == null ) return null;
String msg=null != task ?" Process instance ID"+processInstanceId+
"\n Mission ID:"+task.getId()+" The name of the task :"+task.getName()+" Task leader :"+task.getAssignee()+" Mission start time :"+task.getCreateTime() : "";
return task;
}
}
边栏推荐
- 汇编语言段定义
- Install docker under windows10 (through Oracle VM VirtualBox)
- 「博士毕业一年,我拿下 ACL Best Paper」
- 7-7 ring the stupid bell
- Solr word segmentation analysis
- Yao BanZhi and his team came together, and the competition experts gathered together. What fairy programming competition is this?
- The daemon thread starts redis and modifies the configuration file
- 7-6 sum of combinatorial numbers
- 我走過最迷的路,是字節跳動程序員的腦回路
- ~69 other ways to use icon fonts
猜你喜欢

Notes on how the network is connected

Activiti目录(四)查询代办/已办、审核

MySQL数字函数

LeetCode 1552. Magnetic force between two balls

Full record of ByteDance technology newcomer training: a guide to the new growth of school recruitment

算数运算指令

Shell_ 06_ Judgment and circulation

Shell_ 05_ operator
![[graduation project] QT from introduction to practice: realize imitation of QQ communication, which is also the last blog post in school.](/img/ef/2072aac5f85c7daf39174784dec7ee.jpg)
[graduation project] QT from introduction to practice: realize imitation of QQ communication, which is also the last blog post in school.

Shell_ 04_ Shell script
随机推荐
汇编语言段定义
One hundred questions of image processing (11-20)
LeetCode 1637. The widest vertical area between two points without any point
Usage of insert() in vector
[unsolved]7-14 calculation diagram
Eight part essay that everyone likes
Mongodb在node中的使用
Data config problem: the reference to entity 'useunicode' must end with ';' delimiter.
TypeScript基本操作
MySQL optimization notes
Many papers on ByteDance have been selected into CVPR 2021, and the selected dry goods are here
ByteDance technical Interviewer: what kind of candidate do I want to pick most
~74 JD top navigation bar exercise
Fdog series (VI): use QT to communicate between the client and the client through the server (less information, recommended Collection)
LeetCode 1584. Minimum cost of connecting all points
LeetCode 1020. Number of enclaves
string. How to choose h and string and CString
Activit零零碎碎要人命的坑
LeetCode1556. Thousand separated number
Error: case label `15 'not within a switch statement