失效链接处理 |
Activiti实现会签功能程序Demo PDF 下载
本站整理下载:
提取码:ikii
相关截图:
主要内容:
1、会签是什么?
会签功能指多个人员针对同一个事务进行协商处理,共同签署决定一件事情。
在工作流中会签,是指多个人员在同一个环节进行处理,同一环节的有多个处理人并行处理,按照配置规则,固定比例的人员办理完成后即可继续流转至下一环节。
2、会签的种类
a) 按数量通过:达到一定数量的通过表决后,会签通过。
b) 按比例通过:达到一定比例的通过表决后,会签通过。
c) 一票否决:只要有一个表决时否定的,会签通过。
d) 一票通过:只要有一个表决通过的,会签通过。
3、Activiti实现会签
Activiti实现会签是基于多实例任务,将节点设置成多实例,主要通过在UserTask节点的属性上配置
4、完整代码
4.1流程图xml代码
<?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: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" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="applyHoliday2" name="请假申请" isExecutable="true">
<startEvent id="startevent1" name="Start"></startEvent>
<userTask id="usertask1" name="申请"></userTask>
<sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
<userTask id="usertask2" name="会签" activiti:assignee="${signer}">
<extensionElements>
<activiti:taskListener event="complete" class="cn.com.xu.applyHoliday.SignListener"></activiti:taskListener>
</extensionElements>
<multiInstanceLoopCharacteristics isSequential="false" activiti:collection="${signList}" activiti:elementVariable="signer">
<completionCondition>${pass == false}</completionCondition>
</multiInstanceLoopCharacteristics>
</userTask>
<sequenceFlow id="flow2" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
<userTask id="usertask3" name="记录"></userTask>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow4" sourceRef="usertask3" targetRef="endevent1"></sequenceFlow>
<exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
<sequenceFlow id="flow7" sourceRef="usertask2" targetRef="exclusivegateway1"></sequenceFlow>
<sequenceFlow id="flow8" name="通过" sourceRef="exclusivegateway1" targetRef="usertask3">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${result == "Y"}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow9" name="拒绝" sourceRef="exclusivegateway1" targetRef="usertask1">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${result == "N"}]]></conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_applyHoliday2">
<bpmndi:BPMNPlane bpmnElement="applyHoliday2" id="BPMNPlane_applyHoliday2">
<bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
<omgdc:Bounds height="35.0" width="35.0" x="250.0" y="210.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
<omgdc:Bounds height="55.0" width="105.0" x="330.0" y="200.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
<omgdc:Bounds height="55.0" width="105.0" x="500.0" y="200.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3">
<omgdc:Bounds height="55.0" width="105.0" x="860.0" y="200.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
<omgdc:Bounds height="35.0" width="35.0" x="1080.0" y="210.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
<omgdc:Bounds height="40.0" width="40.0" x="710.0" y="207.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="285.0" y="227.0"></omgdi:waypoint>
<omgdi:waypoint x="330.0" y="227.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="435.0" y="227.0"></omgdi:waypoint>
<omgdi:waypoint x="500.0" y="227.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
<omgdi:waypoint x="965.0" y="227.0"></omgdi:waypoint>
<omgdi:waypoint x="1080.0" y="227.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
<omgdi:waypoint x="605.0" y="227.0"></omgdi:waypoint>
<omgdi:waypoint x="710.0" y="227.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
<omgdi:waypoint x="750.0" y="227.0"></omgdi:waypoint>
<omgdi:waypoint x="860.0" y="227.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="100.0" x="750.0" y="227.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
<omgdi:waypoint x="730.0" y="247.0"></omgdi:waypoint>
<omgdi:waypoint x="729.0" y="354.0"></omgdi:waypoint>
<omgdi:waypoint x="382.0" y="354.0"></omgdi:waypoint>
<omgdi:waypoint x="382.0" y="255.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="100.0" x="730.0" y="247.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
(如需项目DEMO源码同学可发送主题“springboot-activiti”至1829003685@qq.com)
4.2会签监听代码
package cn.com.xu.applyHoliday;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.activiti.engine.task.Task;
/**
* 会签监听
* @author 1829003685@qq.com 2019年5月7日 上午11:12:42
*
*/
public class SignListener implements TaskListener {
private static final long serialVersionUID = 1L;
@Override
public void notify(DelegateTask delegateTask) {
System.out.println("会签监听");
//获取流程id
String exId = delegateTask.getExecutionId();
//获取流程参数pass,会签人员完成自己的审批任务时会添加流程参数pass,false为拒绝,true为同意
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
RuntimeService runtimeService = engine.getRuntimeService();
TaskService taskService = engine.getTaskService();
boolean pass = (Boolean) runtimeService.getVariable(exId, "pass");
/*
* false:有一个人拒绝,整个流程就结束了,
* 因为Complete condition的值为pass == false,即,当流程参数为pass时会签就结束开始下一个任务
* 所以,当pass == false时,直接设置下一个流程跳转需要的参数
* true:审批人同意,同时要判断是不是所有的人都已经完成了,而不是由一个人同意该会签就结束
* 值得注意的是如果一个审批人完成了审批进入到该监听时
|