創建企業審核流程模板
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 }
此流程分為開始、企業用戶申請、管理員審核、結束四個節點。
接口描述
返回參數
返回狀態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 }