<?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="m1608990367912" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema">
<process id="HouXuanRen_claim" isClosed="false" isExecutable="true" name="houxuanrenliuchengrenwu" processType="None">
<startEvent id="_2" name="StartEvent"/>
<userTask activiti:assignee="bajie,wukong" activiti:candidateUsers="bajie,wukong" activiti:exclusive="true" id="_3" name="houxuanrenrenwu"/>
<endEvent id="_4" name="EndEvent"/>
<sequenceFlow id="_5" sourceRef="_2" targetRef="_3"/>
<sequenceFlow id="_6" sourceRef="_3" targetRef="_4"/>
</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="HouXuanRen_claim">
<bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
<omgdc:Bounds height="32.0" width="32.0" x="375.0" y="125.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="350.0" y="245.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="32.0" width="32.0" x="375.0" y="380.0"/>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_5" id="BPMNEdge__5" sourceElement="_2" targetElement="_3">
<omgdi:waypoint x="391.0" y="157.0"/>
<omgdi:waypoint x="391.0" y="245.0"/>
<bpmndi:BPMNLabel>
<omgdc: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="_3" targetElement="_4">
<omgdi:waypoint x="391.0" y="300.0"/>
<omgdi:waypoint x="391.0" y="380.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>
/**
* 通过bpmn部署流程
*/
@Test
void initDeploymentBPMN() {
String filename = "BPMN/Part4_Task_claim.bpmn";
// String pngname = "BPMN/Part4_Task.bpmn";
Deployment deployment = repositoryService.createDeployment()
.addClasspathResource(filename)
// .addClasspathResource(pngname)
.name("候选人流程部署001")
.deploy();
System.out.println(deployment.getName());
}
/**
* 初始化流程
*/
@Test
public void initProcessInstance(){
// 1、获取表单填报的内容:请假时间、请假事由,String fromData
// 2、写入业务表,返回业务表主键 ID
// 3、把业务数据与Activiti7流程数据关联
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("HouXuanRen_claim", "businessKey004");
System.out.println("流程实例ID:" + processInstance.getProcessDefinitionId());
}
// 任务查询
@Test
public void getTasks(){
List<Task> list = taskService.createTaskQuery()
.list();
list.forEach(task -> {
System.out.println("Id:" + task.getId());
System.out.println("Name:" + task.getName());
System.out.println("Assignee:" + task.getAssignee());
});
}
// 任务查询结果
Id:8c1490ec-4d81-11eb-861c-c23049e74a6b
Name:houxuanrenrenwu
Assignee:bajie,wukong
// 拾取任务
@Test
public void claimTask(){
Task task = taskService.createTaskQuery()
.taskId("8c1490ec-4d81-11eb-861c-c23049e74a6b")
.singleResult();
taskService.claim("8c1490ec-4d81-11eb-861c-c23049e74a6b", "wukong");
}
// 任务拾取报错
org.activiti.engine.ActivitiTaskAlreadyClaimedException: Task '8c1490ec-4d81-11eb-861c-c23049e74a6b' is already claimed by someone else.
从0打造黑马潜力项目作品,掌握新版Activiti7核心+工程化思维。
了解课程