跳转至

流程监控(FlowMonitorController)

流程监控(后台管理视角)接口:流程实例列表查询(分页+多条件过滤)、流程实例历史+当前节点合并查询、单个流程实例详情(含干预信息)。是流程监控页面的查询入口。

  • 接口类型:REST 资源(@Controller 继承 AbstractRuntimeController;类级无 produces 声明,但方法返回类型为 Resource / ResponseEntity<Resource>,由 Spring Jackson 序列化为 JSON,实际接口类型按返回类型判定为 REST 资源,而非 HTML 页面视图,据源码)
  • 基址${myapps.context-path.runtime:}/api/runtime/{applicationId}/monitors/workflows
  • 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()(继承自 AbstractRuntimeController)必须能取到非空 WebUser,否则在 DesUtil.decryptTextByUserId(applicationId, getUser().getId()) 时即抛 NPE。
  • 路径变量 {applicationId}:必填,经 DES 加密(按当前执行用户密钥),服务端在方法入口处 DesUtil.decryptTextByUserId(applicationId, getUser().getId()) 解密。
  • 响应结构:本控制器的响应**非**统一 Resource 直接返回——
  • #1 doList 返回 ResponseEntity<Resource>,但 body 由服务层 IFlowMonitorService.getFlowList(...) 提供(结构由服务层决定,通常为分页 JSON),失败走 new Resource(500,"server innernal error") + HTTP 500。
  • #2 getHistorys / #3 getInstanceInfo 返回 Resourcesuccess(...) / error(500, ...)),结构与统一 Resource 一致(见 ../index.md「统一响应结构」)。
  • HTTP 状态码:方法级 @ResponseStatus(HttpStatus.OK)#1 doList 失败时显式返回 HttpStatus.INTERNAL_SERVER_ERROR#2/#3 失败时业务错误码 errcode=500 由控制器内 try/catch 包装,HTTP 仍为 200(@ResponseStatus 生效)。AbstractRuntimeController 的全局异常处理亦覆盖本控制器。

1. 获取流程实例列表

按企业域、流程名、状态、发起人、首次处理时间区间、摘要、发起人部门、流程分类索引等多条件分页查询流程实例。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/instances(完整:{runtime-context}/api/runtime/{applicationId}/monitors/workflows/instances
  • 鉴权:是(需 accessToken,据源码)
  • Tag:流程监控模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 应用Id(DES 加密密文)
domainId query string 企业域Id
_currpage query string 当前页
_pagelines query string 每页显示条数
_orderby query string 排序字段,默认空
_flowName query string 流程名称,默认空
_status query string 流程状态
_flowIndex query string 流程分类索引
_initiator query string 发起人Id,默认空
_firstProcessTimeBegin query string 首次处理时间起(含),默认空
_firstProcessTimeEnd query string 首次处理时间止(含),默认空
_summary query string 摘要关键字,默认空
_initiatorDeptId query string 发起人部门Id,默认空

请求示例

GET /api/runtime/__APPID__/monitors/workflows/instances?domainId=__DOMAINID__&_currpage=1&_pagelines=20&_status=running&_flowIndex=0 HTTP/1.1
Cookie: accessToken=eyJhbGciOiJIUzI1NiJ9...

响应

结构ResponseEntity<Resource>body 由服务层 IFlowMonitorService.getFlowList(applicationId, json) 返回(结构由服务层决定,通常为分页 JSON:含 datas/pageCount/rowCount 等)。

成功示例

{
  "errcode": 0,
  "errmsg": "ok",
  "data": {
    "datas": [
      { "id": "__INSTANCEID__", "flowName": "请假流程", "status": "running", "initiatorName": "张三" }
    ],
    "pageCount": 5,
    "rowCount": 100
  },
  "errors": null
}

失败示例(HTTP 500):

{ "errcode": 500, "errmsg": "server innernal error", "data": null, "errors": null }

说明:源码文案为 "server innernal error"(含拼写错误),据源码如实记录。


2. 获取流程历史

按流程实例 Id 查询流程审批历史(合并历史节点 + 当前节点)。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/instances/{instanceId}/historys(完整:{runtime-context}/api/runtime/{applicationId}/monitors/workflows/instances/{instanceId}/historys
  • 鉴权:是(需 accessToken,据源码)
  • Tag:流程监控模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 应用Id(DES 加密密文)
instanceId path string 流程实例Id

请求示例

GET /api/runtime/__APPID__/monitors/workflows/instances/__INSTANCEID__/historys HTTP/1.1
Cookie: accessToken=eyJhbGciOiJIUzI1NiJ9...

响应

结构:统一 Resource(见 ../index.md「统一响应结构」)。 dataList<FlowHistoryVO>,历史节点与当前节点的合并集合(his.addAll(cur)),每条记录含 startNodeName/targetNodeName/auditorName/agentAuditorName/attitude 等。

成功示例

{
  "errcode": 0,
  "errmsg": "success",
  "data": [
    {
      "startNodeName": "发起",
      "targetNodeName": "部门经理审批",
      "auditorName": "张三",
      "agentAuditorName": null,
      "attitude": "同意"
    }
  ],
  "errors": null
}

失败示例

{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


3. 获取流程实例信息

按流程实例 Id 查询单个流程实例详情(含干预信息字段,供监控/干预页面渲染)。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/instances/{id}(完整:{runtime-context}/api/runtime/{applicationId}/monitors/workflows/instances/{id}
  • 鉴权:是(需 accessToken,据源码)
  • Tag:流程监控模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 应用Id(DES 加密密文)
id path string 流程实例Id

请求示例

GET /api/runtime/__APPID__/monitors/workflows/instances/__INSTANCEID__ HTTP/1.1
Cookie: accessToken=eyJhbGciOiJIUzI1NiJ9...

响应

结构:统一 ResourcedataFlowInterventionVO,流程实例干预视图对象(含实例基本信息、当前节点、审批人、可干预操作等,由 IFlowMonitorService.getInstance 返回)。

成功示例

{
  "errcode": 0,
  "errmsg": "success",
  "data": {
    "id": "__INSTANCEID__",
    "flowName": "请假流程",
    "status": "running",
    "currentNodeName": "部门经理审批",
    "auditorName": "张三"
  },
  "errors": null
}

失败示例

{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }