创建企业审核流程模板
GitHub地址:https://github.com/gishys/Hx.Workflow
名词解释
流程模板:ProcessModel、ProcessDefinition,上述的流程模板称为流程定义。
流程步骤:每个流程定义都包含若干个流程节点(步骤)ProcessNode、ProcessStep,节点包含一个StartStep、包含一个StopStep和若干个ExecuteStep执行节点。
模板变量:流程整个生命周期中流转的变量,在流程定义中可以成为全局变量,流程创建时定义并传入,在流程定义中有些流程变量为必须有的字段,如果没有则流程实例创建,流程流转中会报错。
流程实例:ProcessInstance,通过流程定义创建的实例叫做流程实例。
步骤体定义
步骤结构
DisplayName为显示名称,Name步骤体名称,一般作为查询条件(唯一标识),TypeFullName、AssemblyFullName为预先定义好的步骤执行类(编写执行逻辑代码)的类型名与程序集名称,Inputs为步骤体参数;步骤体参数用于定义步骤参数(节点参数),Key为参数名称,Value为参数值(可以为变量、固定值、函数,变量如:data.Key、step.Key其中data代表流程参数,step代表步骤参数;函数如:DateTime.Now(),固定值如:"固定值"、1等),DisplayName为参数描述,StepBodyParaType为参数类型,分为输入参数与输出参数,输入为外部输入赋值给模板参数,输出为步骤参数赋值给模板参数。
通过Id、Version、Titile等属性来定义流程模板(定义),其中Id作为模板的唯一标识,Version可以设置不同的版本,Titile为流程标题,Color、ICon来用户显示流程模板(如果通过配置文件不使用界面流程图来定义则不需要),Description为流程的描述及适用场景,Nodes为流程步骤(节点)。
流程步骤在流程模板中为数组,一个流程模板可以包含多个流程步骤,Id为唯一标识,Version控制版本,Name为流程名称(通常为英文或字母),DisplayName显示名称,StepNodeType分为三中类型开始节点、执行节点、结束节点,Position存储位置信息(界面流程图中屏幕位置),StepBodyId为流程步骤的定义(体),NextNodes为转移条件集合。
DisplayName为显示名称,Name步骤体名称,一般作为查询条件(唯一标识),TypeFullName、AssemblyFullName为预先定义好的步骤执行类(编写执行逻辑代码)的类型名与程序集名称,Inputs为步骤体参数;步骤体参数用于定义步骤参数(节点参数),Key为参数名称,Value为参数值(可以为变量、固定值、函数,变量如:data.Key、step.Key其中data代表流程参数,step代表步骤参数;函数如:DateTime.Now(),固定值如:"固定值"、1等),DisplayName为参数描述,StepBodyParaType为参数类型,分为输入参数与输出参数,输入为外部输入赋值给模板参数,输出为步骤参数赋值给模板参数。
NextNodes(转换链接),NextNodeName为(同一个流程模板内)下一步骤(节点)的Name,通过NextNodeName来查找下一步骤(节点),如果为空则流程结束;WkConNodeConditions为转移条件集合,Field为条件左参数,Operator为操作操作符如果值类型为String则表达式只能为==或者!=,Value为表达式值。
Position为使用流程图设计器设计流程时记录流程步骤的屏幕位置信息。
创建流程模板
请求参数
流程模板(流程定义)介绍查看上一篇博文的(流程结构设计-基于workflow core、创建流程模板(定义)章节)。
1 {
2 "version": 1,
3 "title": "企业用户注册",
4 "icon": "icon.jpg",
5 "color": "red",
6 "discription": "用于互联网+企业用户注册",
7 "nodes": [
8 {
9 "name": "Start",
10 "displayName": "开始",
11 "stepNodeType": 1,
12 "version": 1,
13 "sortNumber": 0,
14 "wkStepBodyId": "",
15 "position": [
16 {
17 "left": 10,
18 "right": 30,
19 "top": 10,
20 "bottom": 30
21 }
22 ],
23 "nodeFormType": 1,
24 "nextNodes": [
25 {
26 "nextNodeName": "Receive"
27 }
28 ]
29 },
30 {
31 "name": "Receive",
32 "displayName": "收件受理",
33 "stepNodeType": 2,
34 "version": 1,
35 "sortNumber": 2,
36 "wkStepBodyId": "917ac78c-83f5-a8e2-5f85-39fc6cb17d64",
37 "position": [
38 {
39 "left": 10,
40 "right": 30,
41 "top": 10,
42 "bottom": 30
43 }
44 ],
45 "nodeFormType": 1,
46 "nextNodes": [
47 {
48 "nextNodeName": "PrimaryAudit"
49 }
50 ]
51 },
52 {
53 "name": "PrimaryAudit",
54 "displayName": "审核",
55 "stepNodeType": 2,
56 "version": 1,
57 "sortNumber": 4,
58 "wkStepBodyId": "917ac78c-83f5-a8e2-5f85-39fc6cb17d64",
59 "position": [
60 {
61 "left": 10,
62 "right": 30,
63 "top": 10,
64 "bottom": 30
65 }
66 ],
67 "nodeFormType": 1,
68 "nextNodes": [
69 {
70 "nextNodeName": "Receive",
71 "wkConNodeConditions": [
72 {
73 "field": "DecideBranching",
74 "operator": "==",
75 "value": "Receive"
76 }
77 ]
78 },
79 {
80 "nextNodeName": "End",
81 "wkConNodeConditions": [
82 {
83 "field": "DecideBranching",
84 "operator": "==",
85 "value": "End"
86 }
87 ]
88 }
89 ]
90 },
91 {
92 "name": "End",
93 "displayName": "结束",
94 "stepNodeType": 3,
95 "version": 1,
96 "sortNumber": 4,
97 "wkStepBodyId": "",
98 "position": [
99 {
100 "left": 10,
101 "right": 30,
102 "top": 10,
103 "bottom": 30
104 }
105 ],
106 "nodeFormType": 1
107 }
108 ]
109 }
View Code
此流程分为开始、企业用户申请、管理员审核、结束四个节点。
接口描述
返回参数
返回状态204,返回值null。
查询流程模板
请求参数
通过流程模板的Title属性来查询流程模板。
接口描述
返回参数
1 {
2 "version": 1,
3 "title": "企业用户注册",
4 "limitTime": null,
5 "wkDefinitionState": 1,
6 "icon": "icon.jpg",
7 "color": "red",
8 "groupId": null,
9 "discription": "用于互联网+企业用户注册",
10 "sortNumber": 0,
11 "tenantId": null,
12 "nodes": [
13 {
14 "wkStepBodyId": null,
15 "wkDefinitionId": "56d854a6-ff19-0c5c-e432-39fc6cc056f5",
16 "name": "Start",
17 "displayName": "开始",
18 "stepNodeType": 1,
19 "version": 1,
20 "limitTime": null,
21 "stepBody": null,
22 "position": [],
23 "nodeFormType": 1,
24 "applicationForms": [],
25 "nextNodes": [
26 {
27 "label": "",
28 "nextNodeName": "Receive",
29 "wkConNodeConditions": []
30 }
31 ]
32 },
33 {
34 "wkStepBodyId": "917ac78c-83f5-a8e2-5f85-39fc6cb17d64",
35 "wkDefinitionId": "56d854a6-ff19-0c5c-e432-39fc6cc056f5",
36 "name": "Receive",
37 "displayName": "收件受理",
38 "stepNodeType": 2,
39 "version": 1,
40 "limitTime": null,
41 "stepBody": {
42 "name": "FixedUserAudit",
43 "displayName": "指定用户审核",
44 "inputs": [
45 {
46 "wkNodeId": "917ac78c-83f5-a8e2-5f85-39fc6cb17d64",
47 "key": "DecideBranching",
48 "stepBodyParaType": 1,
49 "name": "DecideBranching",
50 "displayName": "审核人",
51 "value": "step.DecideBranching"
52 },
53 {
54 "wkNodeId": "917ac78c-83f5-a8e2-5f85-39fc6cb17d64",
55 "key": "UserId",
56 "stepBodyParaType": 0,
57 "name": "UserId",
58 "displayName": "审核人",
59 "value": "data.UserId"
60 }
61 ],
62 "typeFullName": "Hx.Workflow.Application.StepBodys.GeneralAuditingStepBody",
63 "assemblyFullName": "Hx.Workflow.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
64 },
65 "position": [],
66 "nodeFormType": 1,
67 "applicationForms": [],
68 "nextNodes": [
69 {
70 "label": "",
71 "nextNodeName": "PrimaryAudit",
72 "wkConNodeConditions": []
73 }
74 ]
75 },
76 {
77 "wkStepBodyId": "917ac78c-83f5-a8e2-5f85-39fc6cb17d64",
78 "wkDefinitionId": "56d854a6-ff19-0c5c-e432-39fc6cc056f5",
79 "name": "PrimaryAudit",
80 "displayName": "审核",
81 "stepNodeType": 2,
82 "version": 1,
83 "limitTime": null,
84 "stepBody": {
85 "name": "FixedUserAudit",
86 "displayName": "指定用户审核",
87 "inputs": [
88 {
89 "wkNodeId": "917ac78c-83f5-a8e2-5f85-39fc6cb17d64",
90 "key": "DecideBranching",
91 "stepBodyParaType": 1,
92 "name": "DecideBranching",
93 "displayName": "审核人",
94 "value": "step.DecideBranching"
95 },
96 {
97 "wkNodeId": "917ac78c-83f5-a8e2-5f85-39fc6cb17d64",
98 "key": "UserId",
99 "stepBodyParaType": 0,
100 "name": "UserId",
101 "displayName": "审核人",
102 "value": "data.UserId"
103 }
104 ],
105 "typeFullName": "Hx.Workflow.Application.StepBodys.GeneralAuditingStepBody",
106 "assemblyFullName": "Hx.Workflow.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
107 },
108 "position": [],
109 "nodeFormType": 1,
110 "applicationForms": [],
111 "nextNodes": [
112 {
113 "label": "",
114 "nextNodeName": "Receive",
115 "wkConNodeConditions": [
116 {
117 "field": "DecideBranching",
118 "operator": "==",
119 "value": "Receive"
120 }
121 ]
122 },
123 {
124 "label": "",
125 "nextNodeName": "End",
126 "wkConNodeConditions": [
127 {
128 "field": "DecideBranching",
129 "operator": "==",
130 "value": "End"
131 }
132 ]
133 }
134 ]
135 },
136 {
137 "wkStepBodyId": null,
138 "wkDefinitionId": "56d854a6-ff19-0c5c-e432-39fc6cc056f5",
139 "name": "End",
140 "displayName": "结束",
141 "stepNodeType": 3,
142 "version": 1,
143 "limitTime": null,
144 "stepBody": null,
145 "position": [],
146 "nodeFormType": 1,
147 "applicationForms": [],
148 "nextNodes": []
149 }
150 ]
151 }
View Code