请假流程描述
流程图:
假设:公司有两级领导,一级为主管(Chief),一级为老板(Boss),我们这里只是一个模拟,当然现实生活中情况比这个更加复杂;-)
描述:
- 在某公司中,部门员工休假需要主管(Chief)的批准。
- 如果休假天数大于10天,则 在部门主管同意后,还必须老板(Boss)批准。
- 如果是部门主管请假则直接提交老板批准。
- 在休假被批准之前,申请人可以撤销休假申请。
- 申请批准后,对休假天数进行修改(也可以是其他业务数据处理)。 每次休假申请结束之后,不管通过未通过或是否取消,都必须记录下来。
- 流程结束时,系统要把请假的结果信息Email给申请人。
- 对于大于10天的申请,如果部门主管已批准同意而上级主管还未批准,这时申请人撤销申请后,系统应发Email通知部门主管申请已撤销。
流程定义之processdefinition.xml
processdefinition.xml
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->
1
<?
xmlversion="1.0"
?>
2
<!--
NOTE:在定义流程时,建议先画出流程图,然后再来定义,这样思维清晰,也不易于出错
3
关于processdefiniton.xml如何定义,请严格按照nPdl规定
-->
4
<
process-definition
>
5
6
<!--
===================================
-->
7
<!--
==PROCESSDEFINITIONPROPERTIES==
-->
8
<!--
===================================
-->
9
<
name
>
请假DEMO
</
name
>
10
<
description
>
该流程模拟公司的请假流程,MadeByLuBen
</
description
>
11
<
responsible
>
ae
</
responsible
>
12
13
<!--
======================
-->
14
<!--
==START&ENDSTATE==
-->
15
<!--
======================
-->
16
<
start-state
name
="startleaverequest"
>
17
<
description
>
提交请假单
</
description
>
18
<!--
定义了role,引擎在该start-state节点执行时,就会把执行者信息赋值给角色对应的属性“requester”
-->
19
<
role
>
requester
</
role
>
20
<!--
在这里定义start-state的field,它表示该filed相关联的属性,并且在该state,它对属性的访问权利。
21
如果需要定义其在web表单上的操作界面,如何进行web表单显示等,需要在webinterface.xml文件对应节点补充该field
-->
22
<
field
attribute
="startdate"
access
="write-only-required"
/>
23
<
field
attribute
="enddate"
access
="write-only-required"
/>
24
<
field
attribute
="leavedays"
access
="write-only-required"
/>
25
<
field
attribute
="comment"
access
="write-only"
/>
26
<
transition
to
="IsCancelFork"
/>
27
</
start-state
>
28
29
<!--
结束节点除名称外不要定义其他
-->
30
<
end-state
name
="end"
/>
31
32
33
<!--
======================
-->
34
<!--
==Actions==
-->
35
<!--
======================
-->
36
<!--
解释:这里定义process-definition节点的action,有效的事件类型为:process-instance-start,process-instance-endandprocess-instance-cancel
-->
37
38
<!--
此处具体为:在流程结束的时候,发送E-Mail消息给申请者,记录请假日志
-->
39
<
action
event
="process-instance-end"
40
handler
="NetBpm.Example.LeaveOfAbsence.EmailAction,NetBpm.Example.LeaveOfAbsence"
on-exception
="log"
>
41
<!--
定义action参数,供委托类实例化类调用方法时获取使用。如这里的EmailAction的run方法发送邮件,需要知道发给谁,邮件标题等等,那么
42
参数可以提供辅助
-->
43
<
parameter
name
="to"
>
previousActor
</
parameter
>
44
<
parameter
name
="subject"
>
您提交了请假申请
</
parameter
>
45
<
parameter
name
="message"
>
yourequestedaholidayfrom${startdate}to${enddate}withcomment${comment}
</
parameter
>
46
</
action
>
47
<!--
此处具体为:在流程结束的时候记录请假日志,此处Log模拟注意:每个节点可以定义多个action
-->
48
<
action
event
="process-instance-end"
49
handler
="NetBpm.Example.LeaveOfAbsence.LogLeaveInfoAction,NetBpm.Example.LeaveOfAbsence"
on-exception
="log"
>
50
<
parameter
name
="LogInfo"
>
记录请假日志?:)
</
parameter
>
51
</
action
>
52
53
<!--
================
-->
54
<!--
==ATTRIBUTES==
-->
55
<!--
================
-->
56
<!--
解释:定义属性值及其序列化方式。属性值一般包括3类
-->
57
<!--
one:角色对应的属性
-->
58
<
attribute
name
="requester"
type
="actor"
/>
59
<
attribute
name
="chief"
type
="actor"
/>
60
<
attribute
name
="boss"
type
="actor"
/>
61
62
<!--
two:所有acitivity-state(包括start-state)处需要更新的属性,和用户表单内容对应
-->
63
<
attribute
name
="startdate"
type
="date"
/>
64
<
attribute
name
="enddate"
type
="date"
/>
65
<
attribute
name
="leavedays"
type
="integer"
/>
66
<
attribute
name
="comment"
type
="text"
initial-value
="请假理由或者备注"
/>
67
<
attribute
name
="Chiefevaluationresult"
type
="evaluation"
/>
68
<
attribute
name
="Bossevaluationresult"
type
="evaluation"
/>
69
70
<!--
three:标识属性,该属性不会在web界面上体现,主来用来存储流程标识信息,供后面的逻辑处理使用
-->
71
<!--
该属性不会在界面上呈现,在具体流程路径中被设置以决定DecideWhichAction如何走
-->
72
<
attribute
name
="RunTrace"
type
="text"
/>
73
<!--
该属性不会在界面上呈现,该属性被用来设置流程结束将要发送给用户的邮件信息(邮件标题,如果需要邮件内容可扩展)
-->
74
<
attribute
name
="ToUserEmailSubject"
type
="text"
/>
75
76
<!--
===========
-->
77
<!--
==NODES==
-->
78
<!--
===========
-->
79
<!--
定义流程包含的所有节点
-->
80
81
<!--
定义decision节点,从decision可以流出多条边(transition),这些边可以目的地相同,也可以不同。
82
如下面,虽然decision分出了3条供选择的边,但是边的目的地都是end节点,只是边的名称不同
-->
83
<
decision
name
="DecideWhichAction"
84
handler
="NetBpm.Example.LeaveOfAbsence.WhichWayDecision,NetBpm.Example.LeaveOfAbsence"
>
85
<
parameter
name
="attribute"
>
RunTrace
</
parameter
>
86
<
transition
name
="approve"
to
="end"
>
87
<
action
event
="transition"
handler
="NetBpm.Example.LeaveOfAbsence.AutoSetAttributesAction,NetBpm.Example.LeaveOfAbsence"
on-exception
="log"
>
88
<
parameter
name
="attribute"
>
ToUserEmailSubject
</
parameter
>
89
<
parameter
name
="setValue"
>
您的请假申请已经被批准holidayfrom${startdate}to${enddate}withcomment${comment}
</
parameter
>
90
</
action
>
91
</
transition
>
92
93
<
transition
name
="disapprove"
to
="end"
>
94
<
action
event
="transition"
handler
="NetBpm.Example.LeaveOfAbsence.AutoSetAttributesAction,NetBpm.Example.LeaveOfAbsence"
on-exception
="log"
>
95
<
parameter
name
="attribute"
>
ToUserEmailSubject
</
parameter
>
96
<
parameter
name
="setValue"
>
您的请假申请没有获得批准,holidayfrom${startdate}to${enddate}withcomment${comment}
</
parameter
>
97
</
action
>
98
</
transition
>
99
100
<
transition
name
="requestercancel"
to
="end"
>
101
<
action
event
="transition"
handler
="NetBpm.Example.LeaveOfAbsence.AutoSetAttributesAction,NetBpm.Example.LeaveOfAbsence"
on-exception
="log"
>
102
<
parameter
name
="attribute"
>
ToUserEmailSubject
</
parameter
>
103
<
parameter
name
="setValue"
>
您取消了请假申请,holidayfrom${startdate}to${enddate}withcomment${comment}
</
parameter
>
104
</
action
>
105
<!--
请假人取消请假的时,如果主管已经审批了,则需要发邮件通知他
-->
106
<
action
event
="transition"
handler
="NetBpm.Example.LeaveOfAbsence.EmailChiefAction,NetBpm.Example.LeaveOfAbsence"
on-exception
="log"
>
107
<!--
-action的参数只能有3个,切记切记,调试的时候搞晕了
-->
108
<
parameter
name
="to"
>
role(chief)
</
parameter
>
109
<!--
<parametername="cancelMan">previousActor</parameter>
-->
110
<
parameter
name
="subject"
>
请假申请被取消啦
</
parameter
>
111
<
parameter
name
="message"
>
requestedaholidayfrom${startdate}to${enddate}withcomment${comment}
</
parameter
>
112
</
action
>
113
</
transition
>
114
</
decision
>
115
116
117
<!--
======================
-->
118
<!--
==CONCURRENTBLOCK==
-->
119
<!--
======================
-->
120
<!--
解释:定义并发块,concurrent-block一定包括一个fork,一个join,且边不可越出其界。concurrent-block是可以嵌套的
-->
121
<
concurrent-block
>
122
<!--
定义fork,若没有定义forkhandler,那么其在forkflow时将按照默认行为执行
-->
123
<
fork
name
="IsCancelFork"
>
124
<
transition
name
="CancelLeaveRequest"
to
="RequestCancel"
/>
125
<
transition
name
="evaluation"
to
="IsChiefDecision"
/>
126
</
fork
>
127
128
<!--
定义join,此处定义了joinhandler,则当有forkedflow到达join时,将根据该委托判断是否要激活父flow,
129
若没有定义joinhandler,那么将按照默认行为(AndJoin委托类,也就是所有forkedflow都汇聚到达Join才激活父flow)执行
-->
130
<
join
name
="joinbeforedecided"
handler
="NetBpm.Example.LeaveOfAbsence.AnyOneJoin,NetBpm.Example.LeaveOfAbsence"
>
131
<
transition
to
="DecideWhichAction"
/>
132
</
join
>
133
134
<
activity-state
name
="RequestCancel"
>
135
<
description
>
在请假申请被最终审批前,您可以在这里取消申请.
</
description
>
136
<
role
>
requester
</
role
>
137
<!--
fieldsareoptional.theylimittheaccesstoattributesinanactivity
-->
138
<
field
attribute
="startdate"
access
="read-only"
/>
139
<
field
attribute
="enddate"
access
="read-only"
/>
140
141
<!--
eg。请假理由备注先不被看到
142
<fieldattribute="leavedays"access="read-only"/>
143
<fieldattribute="comment"access="read-only"/>
144
-->
145
<
action
event
="perform-of-activity"
handler
="NetBpm.Example.LeaveOfAbsence.AutoSetAttributesAction,NetBpm.Example.LeaveOfAbsence"
on-exception
="log"
>
146
<
parameter
name
="attribute"
>
RunTrace
</
parameter
>
147
<
parameter
name
="setValue"
>
requestercancel
</
parameter
>
148
</
action
>
149
<
transition
to
="joinbeforedecided"
/>
150
</
activity-state
>
<span style=


<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> 1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

评论
更多文章、技术交流、商务合作、联系博主
微信扫码或搜索:z360901061

微信扫一扫加我为好友
QQ号联系: 360901061
您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。
【本文对您有帮助就好】元
