跳转至

设计时报表管理(ReportsController)

报表设计时资源管理:报表的增删改查、新建空白 UReport 报表,按数据集/视图/SQL/存储过程/自定义脚本解析结果集列信息,jrxml 字符串与 jasper 文件路径读取,报表预览(Feign 调用 runtime),报表示例 iscript 脚本与图片上传,以及企业域列表查询。

  • 接口类型:REST 资源
  • 基址${myapps.context-path.designer:}/api/designtime/applications(类级 @RequestMappingproduces = APPLICATION_JSON_VALUE@Component 继承 AbstractDesignTimeController
  • Tag:设计时-报表模块

公共说明

  • 鉴权:是(需 designerToken)。所有端点继承自 AbstractDesignTimeController,通过 Security.getDesignerIdFromToken(request) 从 designerToken JWT 中解析设计器用户。鉴权机制详见 index.md「鉴权说明」。
  • 路径变量{applicationId}{moduleId}{reportId}{id} 均为**明文设计时 ID**(与 designer 其他控制器一致,非 runtime 的 DES 加密密文)。{id}{reportId} 在不同端点均指报表Id。
  • 响应:统一 Resource(见 ../index.md「统一响应结构」)。成功 errcode=0;异常默认 errcode=500errmsg 为异常信息。本控制器重名校验抛 OBPMValidateException(消息形如 {*[report.name.exist]*}),但被 catch (Exception e) 统一捕获后返回 errcode=500(与其他控制器返回 40001 不同)。
  • HTTP 方法:受 CommonSecurityFilter 限制,仅允许 GET/POST/HEAD/OPTIONS
  • 请求体约定:多数 POST/PUT/DELETE 接收原始 JSON 字符串(@RequestBody String content)或 JSON 字符串数组(@RequestBody String[]),由服务端用 JSONObject.fromObject 解析。
  • 报表类型常量(来自 Report,用于 templateType/isPrint 等字段):TYPE_UREPORT=UReport 模板;isPrint=1 表示打印模板。

1. 获取报表列表

分页获取指定模块下的报表列表,可按名称/备注关键字查询;isPrint=1 时仅返回打印模板。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/{applicationId}/modules/{moduleId}/reports(完整:{designer-context}/api/designtime/applications/{applicationId}/modules/{moduleId}/reports
  • 鉴权:是(需 designerToken)
  • Tag:设计时-报表模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 软件Id
moduleId path string 模块Id
isPrint query string 1=仅返回打印模板(先按名称/备注分页查询再内存过滤 isPrint==1 的项);缺省=不过滤
searchword query string 名称/备注关键字
pageNo query string 页码(缺省 1
linesPerPage query string 每页条数(缺省 10

说明:上述形参未标注 @RequestParam,由 Spring MVC 按请求参数绑定,故均可缺省。

请求示例

GET /api/designtime/applications/{applicationId}/modules/{moduleId}/reports?searchword=&pageNo=1&linesPerPage=10 HTTP/1.1

响应

结构:统一 Resource(见 ../index.md「统一响应结构」)。 dataDataPackage<Report>(含分页字段 rowCount/linesPerPage/pageNo/pageCountdatas)。isPrint=1rowCount/datas 被替换为过滤后的结果集。

成功示例

{
  "errcode": 0,
  "errmsg": "ok",
  "data": {
    "rowCount": 3,
    "linesPerPage": 10,
    "pageNo": 1,
    "pageCount": 1,
    "datas": [
      { "id": "...", "name": "销售报表", "isPrint": 0, "...": "..." }
    ]
  },
  "errors": null
}
失败示例
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


2. 获取报表详情

按报表Id获取完整报表对象。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/{applicationId}/reports/{reportId}
  • 鉴权:是(需 designerToken)
  • Tag:设计时-报表模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 软件Id
reportId path string 报表Id

响应

dataReport 完整对象(含名称、类型、flow/jrxmlStringuReportTemplateisPrintformId 等)。

{ "errcode": 0, "errmsg": "ok", "data": { "id": "...", "name": "销售报表", "isPrint": 0, "...": "..." }, "errors": null }
失败示例
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


3. 新建报表

在指定模块下新建报表。请求体反序列化为 Report 后做重名校验(validate),通过则保存并返回报表Id与 jrxml 文件相对路径。

  • 接口类型:REST 资源
  • 请求方式POST
  • 请求路径/{applicationId}/modules/{moduleId}/reports
  • 鉴权:是(需 designerToken)
  • Tag:设计时-报表模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 软件Id
moduleId path string 模块Id
content body string(JSON) 报表对象 JSON

请求体

对应 Report 对象 JSON(nametemplateTypejrxmlString/uReportTemplateisPrint 等)。服务端会强制覆盖 applicationidparentId 为路径变量值。

响应

dataJSONObject,含 id(新建报表Id)与 jrxmlFilePath(jrxml 配置文件相对路径)。重名时 errcode=500errmsg{*[report.name.exist]*}(重名异常被 catch(Exception) 统一为 500)。

{ "errcode": 0, "errmsg": "ok", "data": { "id": "<报表Id>", "jrxmlFilePath": "<jrxml 相对路径>" }, "errors": null }
失败示例(重名):
{ "errcode": 500, "errmsg": "{*[report.name.exist]*}", "data": null, "errors": null }


4. 新建空白 UReport 报表

在指定模块下新建一份空白 UReport 报表(模板类型 TYPE_UREPORT),内置 3 行 4 列空白单元格与 A4 纸张默认 paper 配置。

  • 接口类型:REST 资源
  • 请求方式POST
  • 请求路径/{applicationId}/modules/{moduleId}/reports/ureports/create_blank
  • 鉴权:是(需 designerToken)
  • Tag:设计时-报表模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 软件Id
moduleId path string 模块Id
name query string 报表名称(@RequestParam 默认必填)

请求示例

POST /api/designtime/applications/{applicationId}/modules/{moduleId}/reports/ureports/create_blank?name=<报表名称> HTTP/1.1

响应

dataJSONObject,含 idname。重名时 errcode=500errmsg{*[report.name.exist]*}

{ "errcode": 0, "errmsg": "ok", "data": { "id": "<报表Id>", "name": "<报表名称>" }, "errors": null }
失败示例
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


5. 更新报表

按报表Id更新报表。当 jrxmlString 非空时先删除旧 jrxml 文件,再写入新内容;为空时置 isDefaultStyle=1saveOrUpdate

  • 接口类型:REST 资源
  • 请求方式PUT
  • 请求路径/{applicationId}/reports/{reportId}
  • 鉴权:是(需 designerToken)
  • Tag:设计时-报表模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 软件Id
reportId path string 报表Id
content body string(JSON) 报表对象 JSON

请求体

对应 Report 对象 JSON。服务端强制 id=reportIdapplicationid=applicationId,其余字段(namejrxmlStringuReportTemplateisPrint 等)按请求体。

响应

datanull(成功)。

{ "errcode": 0, "errmsg": "ok", "data": null, "errors": null }
失败示例
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


6. 删除报表(可批量)

按报表Id数组批量删除报表。

  • 接口类型:REST 资源
  • 请求方式DELETE
  • 请求路径/{applicationId}/reports
  • 鉴权:是(需 designerToken)
  • Tag:设计时-报表模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 软件Id
ids body string 报表Id数组(JSON 数组反序列化为 String[]

请求体

["<reportId1>", "<reportId2>"]

响应

dataString,成功时为 "删除成功"

{ "errcode": 0, "errmsg": "ok", "data": "删除成功", "errors": null }
失败示例
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


7. 通过数据源获取返回结果集的列信息

type 指定的数据源类型,解析报表结果集列信息。type=view 时按是否打印模板分别取表单/视图列;type=sql/procedure 走数据源执行;type=custom 通过 Feign 调 runtime 解析自定义脚本。

  • 接口类型:REST 资源
  • 请求方式POST
  • 请求路径/{applicationId}/reports/{reportId}/columninfos
  • 鉴权:是(需 designerToken)
  • Tag:设计时-报表模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 软件Id
reportId path string 报表Id(reportDesignTimeService.findById 加载报表;为空时使用空 Report 对象)
content body string(JSON) 至少含 scriptString(SQL/存储过程/自定义脚本内容)
type query string 数据源类型(@RequestParam 默认必填):DATASOURCE_TYPE_VIEW/DATASOURCE_TYPE_SQL/DATASOURCE_TYPE_PROCEDURE/DATASOURCE_TYPE_CUSTOM
dataSourceName query string 数据源名称(SQL/存储过程类型使用)
viewId query string 视图Id(DATASOURCE_TYPE_VIEW 且非打印模板时使用)
isForm query string 是否为表单(仅 @Parameter 声明,实现未直接使用)

请求体

{ "scriptString": "select * from tlk_xxx" }

响应

dataList<QueryColumnInfo>,每项含 columnName 等字段。服务端会对联查字段重名做去重(在列名后追加 1)。

{
  "errcode": 0,
  "errmsg": "ok",
  "data": [ { "columnName": "FIELD1", "...": "..." } ],
  "errors": null
}
失败示例
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


8. 获取 jrxml 字符串

按报表Id读取该报表 jrxml 配置文件的文本内容(UTF-8)。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/{applicationId}/reports/{id}/jrxmlstring
  • 鉴权:是(需 designerToken)
  • Tag:设计时-报表模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 软件Id
id path string 报表Id

请求示例

GET /api/designtime/applications/{applicationId}/reports/{id}/jrxmlstring HTTP/1.1

响应

dataString,jrxml 文件文本内容。

{ "errcode": 0, "errmsg": "ok", "data": "<?xml version=\"1.0\" ...>", "errors": null }
失败示例
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


9. 获取报表示例 iscript 脚本

按示例名称返回 ReportExamples 的 iscript 脚本文本。该端点路径下不含 {applicationId} 段。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/reports/exampleiscript(完整:{designer-context}/api/designtime/applications/reports/exampleiscript
  • 鉴权:是(需 designerToken)
  • Tag:设计时-报表模块

请求参数

参数名 位置 类型 必填 说明
exampleName query string 示例名称(@RequestParam 默认必填)

请求示例

GET /api/designtime/applications/reports/exampleiscript?exampleName=<示例名> HTTP/1.1

响应

dataString,示例 iscript 脚本文本。

{ "errcode": 0, "errmsg": "ok", "data": "<iscript 脚本>", "errors": null }
失败示例
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


10. 上传报表图片

接收前端上传的图片二进制流,写入工作空间 /uploads/reports/images/<原始文件名>,返回真实存放路径。

  • 接口类型:REST 资源
  • 请求方式POST
  • 请求路径/reports/uploadImageFile(完整:{designer-context}/api/designtime/applications/reports/uploadImageFile
  • 鉴权:是(需 designerToken)
  • Tag:设计时-报表模块
  • Content-Typemultipart/form-data

请求参数

参数名 位置 类型 必填 说明
file body(form) file(MultipartFile) 上传的图片文件(form-data 部件名 file

请求示例

POST /api/designtime/applications/reports/uploadImageFile HTTP/1.1
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary

响应

dataString,写入后的真实文件路径。

{ "errcode": 0, "errmsg": "ok", "data": "<真实路径>/uploads/reports/images/<文件名>", "errors": null }
失败示例
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


11. 返回报表的 jasper 文件路径

按报表Id返回该报表 jasper 编译产物的真实存放路径。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/{applicationId}/reports/{id}/reportjasperpath
  • 鉴权:是(需 designerToken)
  • Tag:设计时-报表模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 软件Id
id path string 报表Id

请求示例

GET /api/designtime/applications/{applicationId}/reports/{id}/reportjasperpath HTTP/1.1

响应

dataString,jasper 文件真实路径。

{ "errcode": 0, "errmsg": "ok", "data": "<真实路径>/<报表>.jasper", "errors": null }
失败示例
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


12. 报表预览返回 HTML 路径

按报表Id通过 Feign 调用 runtime 接口生成预览 HTML,返回 HTML 路径。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/{applicationId}/reports/{id}/showjrxml
  • 鉴权:是(需 designerToken)
  • Tag:设计时-报表模块

请求参数

参数名 位置 类型 必填 说明
applicationId path string 软件Id
id path string 报表Id
domainId query string 企业域Id(required=false,作为预览上下文参数透传给 runtime)

请求示例

GET /api/designtime/applications/{applicationId}/reports/{id}/showjrxml?domainId=<域Id> HTTP/1.1

响应

dataString,预览 HTML 路径。id 为空时返回 errcode=500errmsg="请指定报表!";runtime 返回内容包含「系统异常」时 errcode=500errmsg 为该 htmlPath;Feign 调用抛异常时 errcode=500errmsg="系统错误,请联系管理员!"

{ "errcode": 0, "errmsg": "ok", "data": "<html 路径>", "errors": null }
失败示例
{ "errcode": 500, "errmsg": "请指定报表!", "data": null, "errors": null }


13. 返回企业域列表

通过 Feign 调用 runtime 获取全部企业域列表。该端点路径下不含 {applicationId} 段。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/reports/domains(完整:{designer-context}/api/designtime/applications/reports/domains
  • 鉴权:是(需 designerToken)
  • Tag:设计时-报表模块

请求参数

无。

请求示例

GET /api/designtime/applications/reports/domains HTTP/1.1

响应

dataJSONArray,每项为企业域对象(由 runtime 返回的 data 字段直接透传)。Feign 调用抛 RuntimeExceptionerrcode=500errmsg="系统错误,请联系管理员!"

{
  "errcode": 0,
  "errmsg": "ok",
  "data": [ { "id": "...", "name": "...", "...": "..." } ],
  "errors": null
}
失败示例
{ "errcode": 500, "errmsg": "系统错误,请联系管理员!", "data": null, "errors": null }