上一篇文中我们实现了顺序的工作流,对于多分支的工作流如下,该如何实现呢?
小明提交了一个申请单,然后经过经理审批,如果通过,发邮件通知,不通过,则打回重新填写申请单,直到通过为止
1、分析
- 需要引入一种分支节点,可以进行简单的二选一流转
- 节点的入边、出边不只一条
- 需要一种逻辑表达式语义,可以配置分支节点
2、设计
- 节点要支持多入边、多出边
- 节点算子来决定从哪个出边出
- 使用一种简单的规则引擎,支持简单的逻辑表达式的解析
- 简单分支节点的XML定义
3、实现
XML定义如下:
<definitions>
<process id="process_2" name="简单审批例子">
<startEvent id="startEvent_1">
<outgoing>flow_1</outgoing>
</startEvent>
<sequenceFlow id="flow_1" sourceRef="startEvent_1" targetRef="approvalApply_1"/>
<approvalApply id="approvalApply_1" name="提交申请单">
<incoming>flow_1</incoming>
<incoming>flow_5</incoming>
<outgoing>flow_2</outgoing>
</approvalApply>
<sequenceFlow id="flow_2" sourceRef="approvalApply_1" targetRef="approval_1"/>
<approval id="approval_1" name="审批">
<incoming>flow_2</incoming>
<outgoing>flow_3</outgoing>
</approval>
<sequenceFlow id="flow_3" sourceRef="approval_1" targetRef="simpleGateway_1"/>
<simpleGateway id="simpleGateway_1" name="简单是非判断">
<trueOutGoing>flow_4</trueOutGoing>
<expr>approvalResult</expr>
<incoming>flow_3</incoming>
<outgoing>flow_4</outgoing>
<outgoing>flow_5</outgoing>
</simpleGateway>
<sequenceFlow id="flow_5" sourceRef="simpleGateway_1" targetRef="approvalApply_1"/>
<sequenceFlow id="flow_4" sourceRef="simpleGateway_1" targetRef="notify_1&