流程
<?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:xsd="http://www.w3.org/2001/XMLSchema" 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" exporter="Flowable Open Source Modeler" exporterVersion="6.7.2">
<process id="shenpi1" name="审批1" isExecutable="true">
<startEvent id="startEvent1" flowable:formFieldValidation="true"></startEvent>
<userTask id="sid-B0A762DE-D600-4998-96D6-49F7BE676159" name="创建审批单" flowable:candidateUsers="${canditate1},${canditate2}" flowable:formFieldValidation="true"></userTask>
<sequenceFlow id="sid-0129BF6A-C57C-4383-A14C-879FD48EED4E" sourceRef="startEvent1" targetRef="sid-B0A762DE-D600-4998-96D6-49F7BE676159"></sequenceFlow>
<userTask id="sid-3808E689-1750-4D10-BFDE-18F41AAF3CB5" name="风控审批" flowable:assignee="三井寿" flowable:formFieldValidation="true">
<extensionElements>
<modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
</extensionElements>
</userTask>
<sequenceFlow id="sid-3349C437-5FF2-4565-B2CD-75CCA54FAF03" sourceRef="sid-B0A762DE-D600-4998-96D6-49F7BE676159" targetRef="sid-3808E689-1750-4D10-BFDE-18F41AAF3CB5"></sequenceFlow>
<endEvent id="sid-80CB6AF8-5DD5-4AC1-A1B2-05A5569B402D"></endEvent>
<sequenceFlow id="sid-AD80B163-B8F0-4472-80D0-C9074FB69CC4" sourceRef="sid-3808E689-1750-4D10-BFDE-18F41AAF3CB5" targetRef="sid-80CB6AF8-5DD5-4AC1-A1B2-05A5569B402D"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_shenpi1">
<bpmndi:BPMNPlane bpmnElement="shenpi1" id="BPMNPlane_shenpi1">
<bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
<omgdc:Bounds height="30.0" width="30.0" x="100.0" y="163.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-B0A762DE-D600-4998-96D6-49F7BE676159" id="BPMNShape_sid-B0A762DE-D600-4998-96D6-49F7BE676159">
<omgdc:Bounds height="80.0" width="100.0" x="225.0" y="135.00000216744158"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-3808E689-1750-4D10-BFDE-18F41AAF3CB5" id="BPMNShape_sid-3808E689-1750-4D10-BFDE-18F41AAF3CB5">
<omgdc:Bounds height="80.0" width="100.00000000000006" x="423.00000899488253" y="135.00000216744158"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-80CB6AF8-5DD5-4AC1-A1B2-05A5569B402D" id="BPMNShape_sid-80CB6AF8-5DD5-4AC1-A1B2-05A5569B402D">
<omgdc:Bounds height="28.0" width="28.0" x="568.0000089948826" y="161.00000216744158"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sid-3349C437-5FF2-4565-B2CD-75CCA54FAF03" id="BPMNEdge_sid-3349C437-5FF2-4565-B2CD-75CCA54FAF03" flowable:sourceDockerX="50.0" flowable:sourceDockerY="40.0" flowable:targetDockerX="50.000000000000036" flowable:targetDockerY="40.0">
<omgdi:waypoint x="324.95000000000005" y="175.00000216744158"></omgdi:waypoint>
<omgdi:waypoint x="423.00000899488253" y="175.00000216744158"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-AD80B163-B8F0-4472-80D0-C9074FB69CC4" id="BPMNEdge_sid-AD80B163-B8F0-4472-80D0-C9074FB69CC4" flowable:sourceDockerX="50.000000000000036" flowable:sourceDockerY="40.0" flowable:targetDockerX="14.0" flowable:targetDockerY="14.0">
<omgdi:waypoint x="522.9500089948785" y="175.00000216744158"></omgdi:waypoint>
<omgdi:waypoint x="568.0000089948826" y="175.00000216744158"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-0129BF6A-C57C-4383-A14C-879FD48EED4E" id="BPMNEdge_sid-0129BF6A-C57C-4383-A14C-879FD48EED4E" flowable:sourceDockerX="15.0" flowable:sourceDockerY="15.0" flowable:targetDockerX="50.0" flowable:targetDockerY="40.0">
<omgdi:waypoint x="129.94742557455893" y="177.71879863507866"></omgdi:waypoint>
<omgdi:waypoint x="225.0" y="175.9365639907934"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
部分测试代码
//领取任务,act_ru_task表中ASSIGNEE_字段之前为空,谁领取就变成谁。
@Transactional
public void claimTask() {
Task task = taskService.createTaskQuery().processInstanceId("9359e78a-ae72-11ec-978f-3c9c0f202230").taskCandidateUser("jack").singleResult();
if (task != null){
taskService.claim(task.getId(),"jack");
System.out.println(task.getAssignee());
}
}
// 完成任务
@Transactional
public void completeTask() {
Task task = taskService.createTaskQuery().processInstanceId("9359e78a-ae72-11ec-978f-3c9c0f202230").taskAssignee("rose").singleResult();
if (task != null){
taskService.complete(task.getId());
}
}
//归还任务,act_ru_task表中ASSIGNEE_字段置为空。
@Transactional
public void unClaimTask() {
Task task = taskService.createTaskQuery().processInstanceId("9359e78a-ae72-11ec-978f-3c9c0f202230").taskAssignee("jack").singleResult();
if (task != null){
taskService.unclaim(task.getId());
System.out.println(task.getAssignee());
}
}
//移交任务,其实就是设置处理人,act_ru_task表中ASSIGNEE_字段交给被移交的人。
@Transactional
public void transTask() {
Task task = taskService.createTaskQuery().processInstanceId("9359e78a-ae72-11ec-978f-3c9c0f202230").taskAssignee("jack").singleResult();
if (task != null){
taskService.setAssignee(task.getId(),"rose");
System.out.println(task.getAssignee());
}
}
机制思考
其实候选人机制在数据库表中的核心表现就是act_ru_task表中ASSIGNEE_字段之前为空,被候选人领取后ASSIGNEE_就变为这个处理人,归还任务就将ASSIGNEE_置空,已交任务就是设置ASSIGNEE_的值。
老百姓看到一只在12或14美元时无人问津的股票突然涨到30美元,他们认为已经到顶了,结果又上涨到了50美元。在他们看来这绝对是上涨的终点了,但随后又一路从60美元涨到了75美元。然后他们认定这样一只几周之前价格还不超过15美元的股票不可能再有上涨的空间了,然而又涨到了85美元。