請假流程描述
流程圖:
假設:公司有兩級領導,一級為主管(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元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
