跳转至

大屏运行时(BigScreenRuntimeController)

大屏(页面)运行时接口:获取大屏页面详情与页面内指定组件的数据(图表 / 视图 / 脚本 / 接口四种数据模式)。

  • 接口类型:REST 资源(@Component 继承 AbstractRuntimeController;类级 produces = MediaType.APPLICATION_JSON_VALUE,方法返回类型为 Resource,由 Spring Jackson 序列化为 JSON,据源码)
  • 基址${myapps.context-path.runtime:}/api/runtime/{applicationId}
  • Tag:runtime

公共说明

  • 鉴权(据源码):类级基址位于 /api/runtime/**,在 RestSecurityHandlerInterceptor 覆盖范围内,且不在豁免名单(豁免仅覆盖 /api/runtime/login.*/api/runtime/dingding/authlogin/api/runtime/synchronization.*、URI 以 /showjrxml 结尾、含 /getCustomColumnsInfos、含 /accessToken、含 /macro、以 /clear 结尾、含 /pages/ 等,详见 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(见 ../index.md「统一响应结构」)。#2 getPageChartData 在配置/解析异常时显式返回 error(4001, "配置错误!", null),错误码 4001

1. 获取页面详情

bigscreenId 加载并返回大屏页面定义(BigScreenDesignTimeService.findById)。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/bigscreen/{bigscreenId}(完整:{runtime-context}/api/runtime/{applicationId}/bigscreen/{bigscreenId}
  • 鉴权:是(需 accessToken,据源码)
  • Tag:runtime

请求参数

参数名 位置 类型 必填 说明
applicationId path string 软件id(DES 加密密文)
bigscreenId path string 大屏页面id(DES 加密密文)

请求示例

GET /api/runtime/__APPID__/bigscreen/__BIGSCREENID__ HTTP/1.1
Cookie: accessToken=eyJhbGciOiJIUzI1NiJ9...

响应

结构:统一 Resource(见 ../index.md「统一响应结构」)。 dataBigScreen,大屏页面定义实体(含 templateContext 模板上下文 JSON、uri/name 等)。

成功示例

{
  "errcode": 0,
  "errmsg": "ok",
  "data": {
    "id": "__BIGSCREENID__",
    "name": "销售驾驶舱",
    "uri": "sales-dashboard",
    "templateContext": "{\"components\":[...]}"
  },
  "errors": null
}

失败示例

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


2. 获取页面图表数据

componentId 在大屏页面的 templateContext.components 中定位组件,按 dataProps.dataMode 分派数据源模式生成图表数据:

  • type=custom + advanceProps.options 脚本:在页面脚本上下文中执行 JSON.stringify(<options>) 并返回解析结果。
  • dataMode=viewData:按 dataProps.viewValue(视图Id)查询视图数据,按 columnsData/columnsName 列定义组装 {data:[{name,values}], legends}
  • dataMode=scriptData:执行 dataProps.dataSource 脚本,返回 JSON.stringify(<dataSource>) 的解析结果。
  • dataMode=interfaceData:按 requestUrl/requestType/requestBody 发起 HTTP 请求,按 dataExpression(JsonPath)从响应中提取数据。

任一步骤异常返回 error(4001, "配置错误!", null);未命中组件返回 success("ok", null)

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/bigscreen/{bigscreenId}/components/{componentId}/data(完整:{runtime-context}/api/runtime/{applicationId}/bigscreen/{bigscreenId}/components/{componentId}/data
  • 鉴权:是(需 accessToken,据源码)
  • Tag:runtime

请求参数

参数名 位置 类型 必填 说明
applicationId path string 软件id(DES 加密密文)
bigscreenId path string 大屏页面id(DES 加密密文)
componentId path string 组件id(明文,源码未对该变量做 DES 解密)
domainId query string 企业域Id;当 getUser()null 时用于构造临时 WebUser(正常调用时被忽略)

请求示例

GET /api/runtime/__APPID__/bigscreen/__BIGSCREENID__/components/__COMPONENTID__/data?domainId=__DOMAINID__ HTTP/1.1
Cookie: accessToken=eyJhbGciOiJIUzI1NiJ9...

响应

结构:统一 Resource(见 ../index.md「统一响应结构」)。 dataObject(视数据模式而定): - custom / scriptData / interfaceData 模式:JSONObject(脚本或接口返回的数据); - viewData 模式:JSONObject,含 data: JSONArray[{name, values}]legends: List<String>; - 未命中组件:null

成功示例(viewData 模式):

{
  "errcode": 0,
  "errmsg": "ok",
  "data": {
    "data": [
      { "name": "一月", "values": ["100", "80"] }
    ],
    "legends": ["销售额", "成本"]
  },
  "errors": null
}

失败示例(配置/解析错误,errcode=4001):

{ "errcode": 4001, "errmsg": "配置错误!", "data": null, "errors": null }