# workflow-api **Repository Path**: keiferXing/workflow-api ## Basic Information - **Project Name**: workflow-api - **Description**: No description available - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-01-04 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### 工作流平台接口文档 - **请求头** :所有请求的请求头中必须携带如下字段 - wf_reqmark: 传“tnt”,表示来源于租户的请求; - wf_tenantid: 租户号,由后台系统分配后告知业务调用方,主要是用于授权认证。 - **响应码** - 0000 成功 - -1 租户未授权 - 1001 请求参数不合法 #### V1.0.0版本 **1. 启动流程** 请求地址:POST a/open/workflow/startApply 请求体: ``` { "action": "动作类型:启动即第一次调用,传to_start, 审批中传to_do, 修改后重新提交传to_redo, 销毁申请传to_discard, 最后一个节点传to_end", "auditStatus": "流程状态:通过 1,不通过0,变更流转2", "procDefKey": "业务流程关键字,由后台分配后告知调用方", "handler":"处理人。格式:用户名(登录名),如张三(zhangsan)", "title": "流程的标题:调用接口的时候传递", "businessKey": "业务关键字:调用接口的时候传递", "content":"审批意见" } 如下面的示例: { "action": "to_start", "auditStatus": "1", "procDefKey": "process_alibaba_wk_1", "title": "测试流程", "comment": "同意:材料完整", "businessKey": "adfafaaaa12676", "handler": "王五(wangwu)" } ``` 响应体: ``` { "procInsId": "流程实例id,在审批中需要传递", "procDefId":"流程定义Id", "activityId":"当前活动节点id", "entryStatus":"进入活动节点传递的状态", "code": "响应码:0000表示成功", "message": "提示信息:异常的时候会有值,成功处理值为空" } 如下面的示例: { "procInsId": "8d39d68ae84e4ee5b104ec25a165c36c", "procDefId": "process_alibaba_wk_1:18:7a0f8c66201c4df6885e3ebf9bbeef84", "code": "0000", "activityId": "aduit1_123456", "entryStatus": "1" } ``` **2. 审批流程** 请求地址:POST a/open/workflow/doApply 请求体: ``` { "action": "动作类型:启动即第一次调用,传to_start, 审批中传to_do, 修改后重新提交传to_redo, 销毁申请传to_discard, 最后一个节点传to_end", "auditStatus": "流程状态:通过 1,不通过0,变更流转2", "activityId":"当前活动节点id", "handler":"处理人。格式:用户名(登录名),如张三(zhangsan)", "comment": "审批意见", "businessKey": "业务关键字:调用接口的时候传递", "procInsId": "上一接口返回的值,参考[启动流程接口]接口" } 如下面的示例: { "action": "to_do", "auditStatus": "1", "activityId": "aduit1_123456", "comment": "同意", "procInsId": "f0a16984113549168365b654d27f5362", "businessKey": "adfaaaa12666", "handler": "陈明(chenming)" } ``` 响应体: ``` { "procInsId": "流程实例id", "procDefId":"流程定义Id", "activityId":"当前活动节点id", "entryStatus":"进入活动节点传递的状态", "code": "响应码:0000表示成功", "message": "提示信息:异常的时候会有值,成功处理值为空" } 如下面的示例: { "procInsId": "8d39d68ae84e4ee5b104ec25a165c36c", "procDefId":"process_alibaba_wk_1:8:8d39d68ae84e4ee5b104ec25a165c36c", "code": "0000", "activityId": "aduit2_1235555", "entryStatus": "1" } ``` **3. 查询活动节点信息** 请求地址:GET a/open/workflow/getActivityNode/{procInsId} 其中procInsId是在地址中传递的流程实例id,如123,请求地址open/workflow/getActivityNode/123 即可。 请求体: ``` { 空 } ``` 响应体: ``` { "procInsId": "流程实例id", "datas":[{"id":"当前活动节点id","entryStatus":"进入该流程节点的状态:通过 1,不通过0,变更流转2"}], "code": "响应码:0000表示成功", "message": "提示信息:异常的时候会有值,成功处理值为空" } 如下面的示例: { "procInsId": "8d39d68ae84e4ee5b104ec25a165c36c", "code": "0000", "datas": [ { "id": "aduit2_1235555", "entryStatus": "1" } ] } ``` **4. 查询所有节点信息** 请求地址:GET a/open/workflow/getProcessFlowElements/{procDefId} 其中procDefId是在地址中传递的流程定义id,如123,请求地址open/workflow/getProcessFlowElements/123 即可。 请求体: ``` { 空 } ``` 响应体: ``` { "procDefId": "流程定义id", "datas": [ { "id": "节点id", "name": "节点名称", "assignee": "节点操作者", "incomingFlows": [ { "id": "流程id", "conditionExpression": "条件表达式:没有条件的时候,该字段会省略", "sourceRef": "来源节点id:表示从那个节点过来的id", "targetRef": "目标节点id:表示激活那个节点id" }, { "id": "流程id", "conditionExpression": "条件表达式:${pass==0}不通过,${pass==1}通过,${pass==2}变更", "sourceRef": "来源节点id", "targetRef": "目标节点id" } ,...//这里可能有多组 ] }, ...//这里还有多组一样结构化的json数据,这里省略 ], "code": "响应码:0000表示成功", "message": "提示信息:异常的时候会有值,成功处理值为空" } 如下面的示例: { "procDefId": "process_alibaba_wk_1:18:7a0f8c66201c4df6885e3ebf9bbeef84", "code": "0000", "datas": [ { "id": "aduit1_123456", "name": "一审", "assignee": "zhangshan", "incomingFlows": [ { "id": "sid-332B65FD-49C9-4D0C-B2F6-8CC47068E565", "sourceRef": "start", "targetRef": "aduit1_123456" }, { "id": "sid-1165D064-1D95-402A-A3B9-35F46E7C9DDB", "conditionExpression": "${pass==0}", "sourceRef": "sid-A0A35972-A8AA-4C5B-A960-53AA01FCD8F1", "targetRef": "aduit1_123456" } ] }, { "id": "aduit2_1235555", "name": "终审", "assignee": "zhangshan", "incomingFlows": [ { "id": "sid-3F81115B-EC6B-4ED6-96EA-1330B99DDFC2", "sourceRef": "aduit1_123456", "targetRef": "aduit2_1235555" } ] }, { "id": "aduit3_356790", "name": "结案", "assignee": "zhangshan", "incomingFlows": [ { "id": "sid-B2B3ED2B-892A-41BE-943A-BFE550088028", "conditionExpression": "${pass==1}", "sourceRef": "sid-A0A35972-A8AA-4C5B-A960-53AA01FCD8F1", "targetRef": "aduit3_356790" } ] } ] } ``` #### V1.0.1版本 - **字段说明** - id: 流程节点id,在配置流程图的时候指定,建议每个元素都指定有意义的id,方便使用和查找; - parentId: 父节点id; - conditionExpression: 条件表达式,表示用使用什么条件才能到达该节点; - description: 节点描述信息; - type: 节点类型:userTask任务类型节点;exclusiveGateway排他网关节点; - modelId: 模型id,有工作流平台统一提供。 **1. 查询所有节点信息** 请求地址:GET a/open/workflow/nodes/{modelId}/json 其中modelId是在地址中传递的模型id,如123,请求地址open/workflow/nodes/123/json 即可。 请求体: ``` { 空 } ``` 响应体: ``` { "procDefId": "proc_zhbx_wkf_1:11:5d4162353eaf4ca1a22525e2eb76496d", "modelId": "5bf53babb7ec4cfdbd2c6204afc7df48", "code": "0000", "datas": [{ "id": "create_aj_id", "name": "创建案件", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-baoxian-line-1", "sourceRef": "start", "targetRef": "create_aj_id" }] }, { "id": "assig_aj_id", "name": "分配案件", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-bx-line-2", "sourceRef": "create_aj_id", "targetRef": "assig_aj_id" }] }, { "id": "submit_yfxxq_id", "name": "提交预分析详情", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-bx-line-3", "sourceRef": "assig_aj_id", "targetRef": "submit_yfxxq_id" }] }, { "id": "comfirm_yfxxq_id", "name": "确认预分析详情", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-bx-line-4", "sourceRef": "submit_yfxxq_id", "targetRef": "comfirm_yfxxq_id" }] }, { "id": "delegate_ls_id", "name": "委托律师", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-bx-line-5", "sourceRef": "comfirm_yfxxq_id", "targetRef": "delegate_ls_id" }] }, { "id": "match_ls_id", "name": "匹配律师", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-bx-line-8_2", "conditionExpression": "${pass==2}", "sourceRef": "sid-058505B3-2395-4470-89C7-EAA478100D7C", "targetRef": "match_ls_id" }, { "id": "sid-bx-line-9_3", "conditionExpression": "${pass==2}", "sourceRef": "sid-1480C79E-C984-4403-A0A0-E699327333A6", "targetRef": "match_ls_id" }, { "id": "sid-bx-line-10_1", "conditionExpression": "${pass==2}", "sourceRef": "sid-EFD7CECB-8C0B-4097-8760-675D47E1CE49", "targetRef": "match_ls_id" }, { "id": "sid-bx-line-7_1", "conditionExpression": "${pass==1}", "documentation": "委托律师", "sourceRef": "sid-BB90FC8A-5024-4C65-9407-D5F018C7619B", "targetRef": "match_ls_id" }] }, { "id": "submit_tqzbxq_1_id", "name": "提交庭前准备详情(不委托律师)", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-bx-line-shtqzbcl-change", "conditionExpression": "${pass==2}", "sourceRef": "sid-C9C9B93E-D8C1-4A71-941F-A5F3EB107272", "targetRef": "submit_tqzbxq_1_id" }, { "id": "sid-bx-line-tjtqzbxq-change", "conditionExpression": "${pass==2}", "sourceRef": "sid-8FDA770D-2BE0-43D8-A448-EFEC007B84B9", "targetRef": "submit_tqzbxq_1_id" }, { "id": "sid-bx-line-7_2", "conditionExpression": "${pass==0}", "documentation": "非委托模式", "sourceRef": "sid-BB90FC8A-5024-4C65-9407-D5F018C7619B", "targetRef": "submit_tqzbxq_1_id" }, { "id": "sid-bx-line-9_1", "conditionExpression": "${pass==0}", "sourceRef": "sid-1480C79E-C984-4403-A0A0-E699327333A6", "targetRef": "submit_tqzbxq_1_id" }, { "id": "sid-bx-line-dkt-change", "conditionExpression": "${pass==2}", "sourceRef": "sid-CB4CAB5A-F193-431D-A8CD-5BDF8E01BB88", "targetRef": "submit_tqzbxq_1_id" }, { "id": "sid-bx-line-7_1_2", "conditionExpression": "${pass==2}", "sourceRef": "sid-2CD2D09C-31A8-4CBE-9CD9-94B93B248905", "targetRef": "submit_tqzbxq_1_id" }] }, { "id": "delegate_fabao_id", "name": "委托法宝(中支)", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-bx-line-ppls-no", "conditionExpression": "${pass==0}", "documentation": "律师匹配失败", "sourceRef": "sid-2CD2D09C-31A8-4CBE-9CD9-94B93B248905", "targetRef": "delegate_fabao_id" }] }, { "id": "audit_tqzbcl_1_id", "name": "审核庭前准备材料(不委托律师)", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-bx-line-81", "conditionExpression": "${pass==1}", "sourceRef": "sid-058505B3-2395-4470-89C7-EAA478100D7C", "targetRef": "audit_tqzbcl_1_id" }] }, { "id": "submit_jafx_id", "name": "提交结案分析", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-bx-line-10_2", "conditionExpression": "${pass==1}", "sourceRef": "sid-EFD7CECB-8C0B-4097-8760-675D47E1CE49", "targetRef": "submit_jafx_id" }, { "id": "sid-bx-line-dkt-yes", "conditionExpression": "${pass==1}", "sourceRef": "sid-CB4CAB5A-F193-431D-A8CD-5BDF8E01BB88", "targetRef": "submit_jafx_id" }, { "id": "sid-bx-line-13_1", "conditionExpression": "${pass==0}", "documentation": "结案分析审核不通过", "sourceRef": "sid-25BD122A-AA58-4073-87C5-10A3C5729888", "targetRef": "submit_jafx_id" }] }, { "id": "audit_jafx_id", "name": "审核结案分析", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-bx-line-11", "conditionExpression": "${pass==1}", "sourceRef": "submit_jafx_id", "targetRef": "audit_jafx_id" }] }, { "id": "finish_ja_id", "name": "结案", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-bx-line-13_2", "conditionExpression": "${pass==1}", "documentation": "结案分析审核通过", "sourceRef": "sid-25BD122A-AA58-4073-87C5-10A3C5729888", "targetRef": "finish_ja_id" }] }, { "id": "todo_kt_1_id", "name": "待开庭(不委托律师)", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-bx-line-9_2", "conditionExpression": "${pass==1}", "documentation": "庭前准备材料审核通过,进入开庭", "sourceRef": "sid-1480C79E-C984-4403-A0A0-E699327333A6", "targetRef": "todo_kt_1_id" }] }, { "id": "submit_tqzbxq_2_id", "name": "提交庭前准备详情(委托律师)", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-bx-line-shtqzbcl-no", "conditionExpression": "${pass==0}", "sourceRef": "sid-C9C9B93E-D8C1-4A71-941F-A5F3EB107272", "targetRef": "submit_tqzbxq_2_id" }, { "id": "sid-bx-line-ppls-yes", "conditionExpression": "${pass==1}", "documentation": "律师匹配成功", "sourceRef": "sid-2CD2D09C-31A8-4CBE-9CD9-94B93B248905", "targetRef": "submit_tqzbxq_2_id" }] }, { "id": "audit_tqzbcl_2_id", "name": "审核庭前准备材料(委托律师)", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-bx-line-tjtqzbxq-yes", "conditionExpression": "${pass==1}", "sourceRef": "sid-8FDA770D-2BE0-43D8-A448-EFEC007B84B9", "targetRef": "audit_tqzbcl_2_id" }] }, { "id": "todo_kt_2_id", "name": "待开庭(委托律师)", "assignee": "zhangsan", "incomingFlows": [{ "id": "sid-bx-line-shtqzbcl-yes", "conditionExpression": "${pass==1}", "sourceRef": "sid-C9C9B93E-D8C1-4A71-941F-A5F3EB107272", "targetRef": "todo_kt_2_id" }] }] } ``` **2. 查询所有节点简单信息** 请求地址:GET a/open/workflow/simple/nodes/{modelId}/json 其中modelId是在地址中传递的模型id,如123,请求地址open/workflow/nodes/123/json 即可。 请求体: ``` { 空 } ``` 响应体: ``` { "modelId": "5bf53babb7ec4cfdbd2c6204afc7df48", "code": "0000", "datas": [{ "id": "create_aj_id", "conditionExpression": "null", "description": "创建案件", "type": "userTask" }, { "id": "assig_aj_id", "conditionExpression": "null", "description": "分配案件", "type": "userTask" }, { "id": "submit_yfxxq_id", "conditionExpression": "null", "description": "提交预分析详情", "type": "userTask" }, { "id": "comfirm_yfxxq_id", "conditionExpression": "null", "description": "确认预分析详情", "type": "userTask" }, { "id": "delegate_ls_id", "conditionExpression": "null", "description": "委托律师", "type": "userTask" }, { "id": "sid-BB90FC8A-5024-4C65-9407-D5F018C7619B", "conditionExpression": "null", "description": "null", "type": "exclusiveGateway" }, { "id": "match_ls_id", "conditionExpression": "null", "description": "匹配律师", "type": "userTask" }, { "id": "submit_tqzbxq_1_id", "conditionExpression": "null", "description": "提交庭前准备详情(不委托律师)", "type": "userTask" }, { "id": "delegate_fabao_id", "conditionExpression": "null", "description": "委托法宝(中支)", "type": "userTask" }, { "id": "audit_tqzbcl_1_id", "conditionExpression": "null", "description": "审核庭前准备材料(不委托律师)", "type": "userTask" }, { "id": "sid-EFD7CECB-8C0B-4097-8760-675D47E1CE49", "conditionExpression": "null", "description": "null", "type": "exclusiveGateway" }, { "id": "submit_jafx_id", "conditionExpression": "null", "description": "提交结案分析", "type": "userTask" }, { "id": "audit_jafx_id", "conditionExpression": "null", "description": "审核结案分析", "type": "userTask" }, { "id": "sid-25BD122A-AA58-4073-87C5-10A3C5729888", "conditionExpression": "null", "description": "null", "type": "exclusiveGateway" }, { "id": "finish_ja_id", "conditionExpression": "null", "description": "结案", "type": "userTask" }, { "id": "todo_kt_1_id", "conditionExpression": "null", "description": "待开庭(不委托律师)", "type": "userTask" }, { "id": "submit_tqzbxq_2_id", "conditionExpression": "null", "description": "提交庭前准备详情(委托律师)", "type": "userTask" }, { "id": "audit_tqzbcl_2_id", "conditionExpression": "null", "description": "审核庭前准备材料(委托律师)", "type": "userTask" }, { "id": "todo_kt_2_id", "conditionExpression": "null", "description": "待开庭(委托律师)", "type": "userTask" }, { "id": "sid-8FDA770D-2BE0-43D8-A448-EFEC007B84B9", "conditionExpression": "null", "description": "null", "type": "exclusiveGateway" }, { "id": "sid-CB4CAB5A-F193-431D-A8CD-5BDF8E01BB88", "conditionExpression": "null", "description": "null", "type": "exclusiveGateway" }, { "id": "sid-058505B3-2395-4470-89C7-EAA478100D7C", "conditionExpression": "null", "description": "null", "type": "exclusiveGateway" }, { "id": "sid-1480C79E-C984-4403-A0A0-E699327333A6", "conditionExpression": "null", "description": "null", "type": "exclusiveGateway" }, { "id": "sid-C9C9B93E-D8C1-4A71-941F-A5F3EB107272", "conditionExpression": "null", "description": "null", "type": "exclusiveGateway" }, { "id": "sid-2CD2D09C-31A8-4CBE-9CD9-94B93B248905", "conditionExpression": "null", "description": "null", "type": "exclusiveGateway" }, { "id": "start", "conditionExpression": "null", "description": "开始", "type": "startEvent" }, { "id": "end", "conditionExpression": "null", "description": "结束", "type": "endEvent" }] } ``` **3. 查询某节点下子节点信息(一级userTask类型的子节点,如果是exclusiveGateway网关类型的会继续找下一节点,直到找到第一个userTask类型的为止)** 请求地址:GET a/open/workflow/nextNode/{modelId}/{nodeId}/json 其中modelId是在地址中传递的模型id,如m123;nodeId是当前节点id,如n456。请求地址a/open/workflow/nextNode/m123/n456/json 即可。 请求体: ``` { 空 } ``` 响应体: ``` { "modelId": "5bf53babb7ec4cfdbd2c6204afc7df48", "code": "0000", "datas": [{ "id": "match_ls_id", "parentId": "gateway1_id", "conditionExpression": "${pass==1}", "description": "匹配律师", "type": "userTask" }, { "id": "submit_tqzbxq_1_id", "parentId": "gateway1_id", "conditionExpression": "${pass==0}", "description": "提交庭前准备详情(不委托律师)", "type": "userTask" }] } ``` ### httpclientutil简单使用 1.构建请求头数据: Map headers = new HashMap(); headers.put("wf_reqmark", "tnt"); headers.put("wf_tenantid", "FB_WK_TID:zhangsan:141181800092557312"); 2.1 POST请求(带请求头和请求体): String bodyJson = "{\"action\":\"to_start\",\"auditStatus\":\"1\",\"comment\":\"同意\",\"procInsId\":\"11d5c0f902704dd5a656f5718a66e975\",\"comment\":\"同意\",\"businessKey\":\"adfaaaa12666\",\"handler\":\"刘雨(liuyu)\"}"; SimpleHttpClientUtil.hpost("http://localhost:8081/a/open/workflow/startApply", bodyJson, headers); 2.2 GET请求(带请求头,无请求体): SimpleHttpClientUtil.hget("http://localhost:8081/a/open/workflow/getActivityNode/123456789",headers);