简介
通用流程可以用于一些基本的申请,例如请假、加班。
大致过程是:
比较简单,唯一的难点就是动态设置审批人或者审批组,下面开始代码部分。
demo地址:https://github.com/xwbz2017/flowable-demo
bpmn20文件
...id="standardRequest" name="标准申请流程" isExecutable="true">
id="startEvent" name="创建申请"/>
sourceRef="startEvent" targetRef="assignToAuditor"/>
id="assignToAuditor" name="分配审批人" flowable:class="me.xwbz.flowable.delegate.AssignToAuditorDelegate"/>
sourceRef="assignToAuditor" targetRef="auditorExist"/>
id="auditorExist" name="审批人是否存在" default="auditorNotExistFlow"/>
sourceRef="auditorExist" targetRef="approveTask">
xsi:type="tFormalExpression">
${auditMethod.existAuditor(execution)}
]]>
id="auditorNotExistFlow" sourceRef="auditorExist" targetRef="agreeDelegate" />
id="approveTask" name="等待审批"
flowable:candidateGroups="${auditMethod.getCandidateGroups(execution)}"
flowable:candidateUsers="${auditMethod.getCandidateUsers(execution)}"/>
sourceRef="approveTask" targetRef="decision"/>
id="decision" default="rejectFlow"/>
sourceRef="decision" targetRef="assignToAuditor">
xsi:type="tFormalExpression">
${auditMethod.isApproved(execution)}
]]>
id="rejectFlow" sourceRef="decision" targetRef="rejectDelegate" />
id="agreeDelegate" name="数据存储"
flowable:class="me.xwbz.flowable.delegate.StandardRequestAgreeDelegate"/>
sourceRef="agreeDelegate" targetRef="approveEnd"/>
id="rejectDelegate" name="回复拒绝消息"
flowable:class="me.xwbz.flowable.delegate.BaseRejectDelegate"/>
sourceRef="rejectDelegate" targetRef="rejectEnd"/>
id="approveEnd" name="已同意"/>
id="rejectEnd" name="已驳回"/>
...
常量部分
这次没有另外存储数据,所以变量都是直接存储到flowable自带的变量表里强烈建议大家另外存储,自带的查询起来非常麻烦!
审批人列表:
AUDITOR_LIST_KEY = "AUDITOR_LIST";
当前审批人:
AUDITOR_KEY = "AUDITOR";
当前审批人下标:
AUDITOR_IDX_KEY = "AUDITOR_IDX";
是否已审批:
APPROVED_KEY = "AUDIT_APPROVED";
申请类型:
AUDIT_TYPE_KEY = "AUDIT_TYPE";
申请状态:
AUDIT_STATUS_KEY = "AUDIT_STATUS";
其他参数:
AUDIT_PARAMS_KEY = "AUDIT_PARAMS";
申请状态
申请人类型