Camunda 使用restapi

参考:http://camunda-cn.shaochenfeng.com/reference/rest/task/get-query/

这里我就举一个流程的例子:

以下接口,除了端口和参数,其他无需改动

Camunda 使用restapi_第1张图片

POM:

rest 就是接口

webapp 是网页


            org.camunda.bpm.springboot
            camunda-bpm-spring-boot-starter-rest
        

        
            org.camunda.bpm.springboot
            camunda-bpm-spring-boot-starter-webapp
        

1 发布流程

http://localhost:9020/engine-rest/deployment/create

传递你的bpmn名称,通过file类型选择bpmn文件

Camunda 使用restapi_第2张图片

2 获取进程定义

http://localhost:9020/engine-rest/process-definition

返回:

[
    {
        "id": "Process_1xebez9:1:7929ac88-64ac-11ed-946f-0892043f3120",
        "key": "Process_1xebez9",
        "category": "http://bpmn.io/schema/bpmn",
        "description": null,
        "name": "customerAudit",
        "version": 1,
        "resource": "customerAudit.bpmn",
        "deploymentId": "7924f196-64ac-11ed-946f-0892043f3120",
        "diagram": null,
        "suspended": false,
        "tenantId": null,
        "versionTag": null,
        "historyTimeToLive": null,
        "startableInTasklist": true
    },
    {
        "id": "audit_process:1:57b07816-63fa-11ed-ae19-0892043f3120",
        "key": "audit_process",
        "category": "http://bpmn.io/schema/bpmn",
        "description": null,
        "name": "Audit Process",
        "version": 1,
        "resource": "audit.bpmn",
        "deploymentId": "579a30f3-63fa-11ed-ae19-0892043f3120",
        "diagram": null,
        "suspended": false,
        "tenantId": null,
        "versionTag": null,
        "historyTimeToLive": null,
        "startableInTasklist": true
    }
]

3 启动流程

http://localhost:9020/engine-rest/process-definition/Process_1xebez9:1:7929ac88-64ac-11ed-946f-0892043f3120/start

上面的Id就是来自步骤2的id

参数:

这里我传递了审批人(流程界面中,设置了${adminList} ${mpmList})

并且设置了businessKey

{
  "variables": {
    "adminList" : {
        "value":"[\"admin\"]",
            "type":"Object",
            "valueInfo":{
                "objectTypeName":"java.util.ArrayList",
                "serializationDataFormat":"application/json"
            }
    },
    "mpmList": {
        "value":"[\"mpm1\"]",
            "type":"Object",
            "valueInfo":{
                "objectTypeName":"java.util.ArrayList",
                "serializationDataFormat":"application/json"
            }
    }
  },
 "businessKey" : 40
}

4 获取进程实例

http://localhost:9020/engine-rest/process-instance/1cef6cfa-64b3-11ed-946f-0892043f3120

上面的id,就是步骤3返回的id

5.1 获取待办任务 (某人&进程ID)

http://localhost:9020/engine-rest/task?assignee=mpm1&processInstanceId=1cef6cfa-64b3-11ed-946f-0892043f3120

5.2 获取待办任务 (某人)

http://localhost:9020/engine-rest/task?assignee=admin

5.3 获取待办任务 (BusinessKey)

http://localhost:9020/engine-rest/task?processInstanceBusinessKey=40

6 审批

http://localhost:9020/engine-rest/task/ae952619-64bd-11ed-946f-0892043f3120/complete

传参:

由于taskid已经在url中传递了,所以审批人是可以确定的。

{"variables":
    {
        "approve": {"value": true},
        "comment": {"value": "hello world112"}
    },
 "withVariablesInReturn": true
}

你可能感兴趣的:(Camunda,java,spring,boot,spring)