1.声明
当前内容主要为本人学习和测试Activiti6这个工作流的基本操作,模拟钉钉上面的请假流程(简单版)
当前内容主要有:
- 使用官方的web-app方式画图
- 将当前流程图导出为xml配置
- 将xml配置导入项目,并使用java方式加载并实现流程执行
2.画出请假执行流程图
其中都是使用最简单的元素
重要点:
1.启动当前流程需要三个:员工名称,请假时间,请假类型
例如下面参数:
此时发起流程就必须这些参数,注意required设置为true
流程发起后,通过审核人,此时审核人需要一个参数来执行后面是否允许请假通过,同样的设置为approve,设置为boolean类型
之后流程到了条件判断,这里其实就是判断当前的定义的变量approve==true或者approve==false
然后后面的审核人和判断就和这个一样即可完成条件判断(所以这里省略后面的userTask和条件判断)
之后到达抄送人
此时流程执行结束
保存后(上面的请假类型是枚举所以需要在生成的xml中修改)
3.将画出的图导出为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/processdef">
<process id="OffWork" name="OffWork" isExecutable="true">
<documentation>钉钉上的请假流程</documentation>
<startEvent id="offWorkStart" name="发起请求">
<extensionElements>
<activiti:formProperty id="username" name="员工名称" type="string" required="true"></activiti:formProperty>
<activiti:formProperty id="offwork_type" name="请假类型" type="enum" required="true"></activiti:formProperty>
<activiti:formProperty id="offwork_day" name="请假天数" type="long" required="true"></activiti:formProperty>
</extensionElements>
</startEvent>
<userTask id="sp_1" name="审批人:人事部" activiti:candidateGroups="management">
<extensionElements>
<activiti:formProperty id="approve" name="是否同意" type="boolean" required="true"></activiti:formProperty>
</extensionElements>
</userTask>
<userTask id="sp_2" name="审批人:人事部主管" activiti:candidateGroups="management">
<extensionElements>
<activiti:formProperty id="approve" name="是否同意" type="boolean" required="true"></activiti:formProperty>
</extensionElements>
</userTask>
<endEvent id="offWorkEnd" name="结束"></endEvent>
<exclusiveGateway id="sp_1_check" name="判断"></exclusiveGateway>
<exclusiveGateway id="sp_2_check" name="判断"></exclusiveGateway>
<userTask id="send_person" name="抄送人" activiti:candidateGroups="system"></userTask>
<sequenceFlow id="sd_boss" name="抄送给总经理" sourceRef="send_person" targetRef="mail_to_boss"></sequenceFlow>
<sequenceFlow id="diapatcher_to_csr" name="转发" sourceRef="sp_2" targetRef="sp_2_check"></sequenceFlow>
<sequenceFlow id="cs_ms_end" name="抄送结束"<