流程统计(FlowStatisticsController)¶
流程统计接口:当前流程实例列表、流程实例图片(base64)、实例分布、流程时间、节点时间、完成状态分布、回流实例、回退节点。为流程监控页面提供统计图表所需数据。
- 接口类型:REST 资源(
@Controller,未继承AbstractRuntimeController——控制器自带getUser()与request;方法返回ResponseEntity<?>,body为Resource(由ResponseUtils.setResource(...)构造),由 Spring Jackson 序列化为 JSON。实际接口类型按返回类型判定为 REST 资源,而非 HTML 页面视图,据源码) - 基址:
${myapps.context-path.runtime:}/api/runtime/{applicationId}/monitors/workflows/statistics - Tag:流程统计模块
公共说明¶
- 鉴权(据源码):类级基址位于
/api/runtime/**,在RestSecurityHandlerInterceptor覆盖范围内,且不在豁免名单(豁免仅覆盖/api/runtime/login.*、/api/runtime/dingding/authlogin、/api/runtime/synchronization.*等,详见 login.md「公共说明 · 鉴权」)。拦截器走Security.getUserIdFromToken(request),未取到再尝试Security.getDebugUserIdFromToken(request),两者皆无则拒绝。故需 accessToken(或 debugToken),可通过 Cookie / 请求头 / query 参数任一方式传递。控制器内getUser()(通过AuthTimeServiceManager.getWebUser(request)获取)必须能取到非空WebUser,否则在DesUtil.decryptTextByUserId(applicationId, getUser().getId())时即抛 NPE。 - 路径变量
{applicationId}:除#2 flowInstancePhoto外的所有端点均含此变量,必填,经 DES 加密(按当前执行用户密钥),服务端在方法入口处DesUtil.decryptTextByUserId(applicationId, getUser().getId())解密。#2 flowInstancePhoto路径不含{applicationId},仅以 query 参数instanceId标识流程实例。 - 响应结构:所有端点返回
ResponseEntity<?>,body为Resource(由ResponseUtils.setResource(0, "ok", data)构造),结构与统一Resource一致(见 ../index.md「统一响应结构」)。失败统一返回new Resource(500,"server innernal error")+HttpStatus.INTERNAL_SERVER_ERROR。 - HTTP 状态码:方法级
@ResponseStatus(HttpStatus.OK)。失败时显式返回HttpStatus.INTERNAL_SERVER_ERROR。 - 空数据特殊处理:
#1 currentView在服务层返回空列表时,将data替换为空JSONObject({})而非空数组。
1. 获取当前流程实例列表¶
按企业域与时间区间查询当前流程实例列表(统计视角)。
- 接口类型:REST 资源
- 请求方式:
GET - 请求路径:
/instances(完整:{runtime-context}/api/runtime/{applicationId}/monitors/workflows/statistics/instances) - 鉴权:是(需 accessToken,据源码)
- Tag:流程统计模块
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
| applicationId | path | string | 是 | 应用Id(DES 加密密文) |
| domainId | query | string | 是 | 企业域Id |
| startTime | query | string | 否 | 起始时间 |
| endTime | query | string | 否 | 截止时间 |
请求示例¶
GET /api/runtime/__APPID__/monitors/workflows/statistics/instances?domainId=__DOMAINID__&startTime=2026-01-01&endTime=2026-08-01 HTTP/1.1
Cookie: accessToken=eyJhbGciOiJIUzI1NiJ9...
响应¶
结构:统一 Resource。
data:List<Map<String, Object>>;当结果为空列表时 data 为空 JSONObject({})(据源码,服务端在 datas.isEmpty() 时返回 new JSONObject())。
成功示例:
{
"errcode": 0,
"errmsg": "ok",
"data": [
{ "id": "__INSTANCEID__", "flowName": "请假流程", "initiatorName": "张三" }
],
"errors": null
}
失败示例(HTTP 500):
说明:源码文案为
"server innernal error"(含拼写错误),据源码如实记录。
2. 获取流程实例图片¶
按流程实例 Id 渲染流程图,并以 base64 字符串形式返回。
- 接口类型:REST 资源
- 请求方式:
GET - 请求路径:
/photo(完整:{runtime-context}/api/runtime/{applicationId}/monitors/workflows/statistics/photo) - 鉴权:是(需 accessToken,据源码)
- Tag:流程统计模块
说明:本端点路径无
{applicationId}段,但类级@RequestMapping仍含{applicationId}占位——实际调用时 URL 仍需在/api/runtime/{applicationId}/monitors/workflows/statistics/photo处填入应用Id(Spring 路径变量绑定要求)。applicationId在方法内**未使用**,故源码未对其做 DES 解密;调用方传入任意合法 DES 密文或路径占位符即可通过路径绑定。
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
| applicationId | path | string | 是 | 应用Id(仅用于路径绑定,服务端不解析) |
| instanceId | query | string | 是 | 流程实例Id |
请求示例¶
GET /api/runtime/__APPID__/monitors/workflows/statistics/photo?instanceId=__INSTANCEID__ HTTP/1.1
Cookie: accessToken=eyJhbGciOiJIUzI1NiJ9...
响应¶
结构:统一 Resource。
data:String,流程图片的 base64 编码字符串(由 IFlowStatisticsService.photoToBase64(instanceId) 生成)。
成功示例:
{
"errcode": 0,
"errmsg": "ok",
"data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"errors": null
}
失败示例(HTTP 500):
3. 获取实例分布¶
按企业域与时间区间统计流程实例的分布情况(按流程定义/状态等维度分组计数)。
- 接口类型:REST 资源
- 请求方式:
GET - 请求路径:
/instance_distributions(完整:{runtime-context}/api/runtime/{applicationId}/monitors/workflows/statistics/instance_distributions) - 鉴权:是(需 accessToken,据源码)
- Tag:流程统计模块
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
| applicationId | path | string | 是 | 应用Id(DES 加密密文) |
| domainId | query | string | 是 | 企业域Id |
| startTime | query | string | 否 | 起始时间 |
| endTime | query | string | 否 | 截止时间 |
请求示例¶
GET /api/runtime/__APPID__/monitors/workflows/statistics/instance_distributions?domainId=__DOMAINID__ HTTP/1.1
Cookie: accessToken=eyJhbGciOiJIUzI1NiJ9...
响应¶
结构:统一 Resource。
data:由 IFlowStatisticsService.flowDistribution(applicationId, domainId, startTime, endTime) 返回(结构由服务层决定,通常为分组统计数组)。
成功示例:
{
"errcode": 0,
"errmsg": "ok",
"data": [
{ "flowName": "请假流程", "count": 25 },
{ "flowName": "报销流程", "count": 12 }
],
"errors": null
}
失败示例(HTTP 500):
4. 获取流程时间¶
按企业域与时间区间统计流程实例的时间维度数据(如平均处理时长、各流程耗时等)。
- 接口类型:REST 资源
- 请求方式:
GET - 请求路径:
/instance_times(完整:{runtime-context}/api/runtime/{applicationId}/monitors/workflows/statistics/instance_times) - 鉴权:是(需 accessToken,据源码)
- Tag:流程统计模块
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
| applicationId | path | string | 是 | 应用Id(DES 加密密文) |
| domainId | query | string | 是 | 企业域Id |
| startTime | query | string | 否 | 起始时间 |
| endTime | query | string | 否 | 截止时间 |
请求示例¶
GET /api/runtime/__APPID__/monitors/workflows/statistics/instance_times?domainId=__DOMAINID__&startTime=2026-01-01&endTime=2026-08-01 HTTP/1.1
Cookie: accessToken=eyJhbGciOiJIUzI1NiJ9...
响应¶
结构:统一 Resource。
data:由 IFlowStatisticsService.flowTimes(applicationId, domainId, startTime, endTime) 返回(结构由服务层决定)。
成功示例:
{
"errcode": 0,
"errmsg": "ok",
"data": [
{ "flowName": "请假流程", "avgDuration": 86400000 }
],
"errors": null
}
失败示例(HTTP 500):
5. 获取节点时间¶
按企业域与流程名统计节点的时间维度数据(如各节点平均处理时长)。
- 接口类型:REST 资源
- 请求方式:
GET - 请求路径:
/node_times(完整:{runtime-context}/api/runtime/{applicationId}/monitors/workflows/statistics/node_times) - 鉴权:是(需 accessToken,据源码)
- Tag:流程统计模块
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
| applicationId | path | string | 是 | 应用Id(DES 加密密文) |
| domainId | query | string | 是 | 企业域Id |
| flowName | query | string | 是 | 流程名称 |
请求示例¶
GET /api/runtime/__APPID__/monitors/workflows/statistics/node_times?domainId=__DOMAINID__&flowName=请假流程 HTTP/1.1
Cookie: accessToken=eyJhbGciOiJIUzI1NiJ9...
响应¶
结构:统一 Resource。
data:由 IFlowStatisticsService.NodeTimes(applicationId, domainId, flowName) 返回(结构由服务层决定)。
成功示例:
{
"errcode": 0,
"errmsg": "ok",
"data": [
{ "nodeName": "部门经理审批", "avgDuration": 43200000 }
],
"errors": null
}
失败示例(HTTP 500):
6. 获取完成状态¶
按企业域与时间区间统计流程实例的完成状态分布(已办结/进行中/被终止等)。
- 接口类型:REST 资源
- 请求方式:
GET - 请求路径:
/complete_types(完整:{runtime-context}/api/runtime/{applicationId}/monitors/workflows/statistics/complete_types) - 鉴权:是(需 accessToken,据源码)
- Tag:流程统计模块
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
| applicationId | path | string | 是 | 应用Id(DES 加密密文) |
| domainId | query | string | 是 | 企业域Id |
| startTime | query | string | 否 | 起始时间 |
| endTime | query | string | 否 | 截止时间 |
请求示例¶
GET /api/runtime/__APPID__/monitors/workflows/statistics/complete_types?domainId=__DOMAINID__ HTTP/1.1
Cookie: accessToken=eyJhbGciOiJIUzI1NiJ9...
响应¶
结构:统一 Resource。
data:由 IFlowStatisticsService.completeStatus(applicationId, domainId, startTime, endTime) 返回(结构由服务层决定)。
成功示例:
{
"errcode": 0,
"errmsg": "ok",
"data": [
{ "status": "completed", "count": 80 },
{ "status": "running", "count": 15 }
],
"errors": null
}
失败示例(HTTP 500):
7. 获取回流实例¶
按企业域与时间区间统计回流(被回退后再次流转)的流程实例。
- 接口类型:REST 资源
- 请求方式:
GET - 请求路径:
/back_instances(完整:{runtime-context}/api/runtime/{applicationId}/monitors/workflows/statistics/back_instances) - 鉴权:是(需 accessToken,据源码)
- Tag:流程统计模块
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
| applicationId | path | string | 是 | 应用Id(DES 加密密文) |
| domainId | query | string | 是 | 企业域Id |
| startTime | query | string | 否 | 起始时间 |
| endTime | query | string | 否 | 截止时间 |
请求示例¶
GET /api/runtime/__APPID__/monitors/workflows/statistics/back_instances?domainId=__DOMAINID__ HTTP/1.1
Cookie: accessToken=eyJhbGciOiJIUzI1NiJ9...
响应¶
结构:统一 Resource。
data:由 IFlowStatisticsService.flowBack(applicationId, domainId, startTime, endTime) 返回(结构由服务层决定)。
成功示例:
{
"errcode": 0,
"errmsg": "ok",
"data": [
{ "instanceId": "__INSTANCEID__", "flowName": "请假流程", "backCount": 2 }
],
"errors": null
}
失败示例(HTTP 500):
8. 获取回退节点¶
按企业域与流程名统计回退节点的分布。
- 接口类型:REST 资源
- 请求方式:
GET - 请求路径:
/back_nodes(完整:{runtime-context}/api/runtime/{applicationId}/monitors/workflows/statistics/back_nodes) - 鉴权:是(需 accessToken,据源码)
- Tag:流程统计模块
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
| applicationId | path | string | 是 | 应用Id(DES 加密密文) |
| domainId | query | string | 是 | 企业域Id |
| flowName | query | string | 是 | 流程名称 |
请求示例¶
GET /api/runtime/__APPID__/monitors/workflows/statistics/back_nodes?domainId=__DOMAINID__&flowName=请假流程 HTTP/1.1
Cookie: accessToken=eyJhbGciOiJIUzI1NiJ9...
响应¶
结构:统一 Resource。
data:由 IFlowStatisticsService.nodeBack(applicationId, domainId, flowName) 返回(结构由服务层决定)。
成功示例:
{
"errcode": 0,
"errmsg": "ok",
"data": [
{ "nodeName": "部门经理审批", "backCount": 7 }
],
"errors": null
}
失败示例(HTTP 500):