高级自定义 > 业务逻辑自定义 > Windchill 中的 Jasper 报告自定义 > 使用 Windchill REST Services 端点 (GET 方法) 创作 Jasper 报告
使用 Windchill REST Services 端点 (GET 方法) 创作 Jasper 报告
配置 Jasper Studio
在开始设计 Jasper 报告之前,请确保创作 Jasper 报告时所采用的计算机已添加为 Windchill 中的受信任主机。将下列条目添加到 <WT_HOME>/codebase/wt.properties 文件中。
Windchill shell 执行以下命令:
windchill com.ptc.util.wbr.export.ExportDataSource wrs
此命令会在 $(wt.temp)/DataSources/WRS 下创建 DataSource JAR。
将此 JAR 添加到 Jasper Studio 的插件目录下。如果要使用 Eclipse 的 JasperSoft Studio 插件,则需将此 JAR 添加到 Eclipse 的插件目录下。
cp $(wt.temp)/DataSources/WRS/wrsDataSource*.jar <PluginDirectory>
重新启动 Jasper Studio/Eclipse。
创作报告
1. 创建新的 JasperReports 项目。
2. 单击 Jasper Report 选项。为 Jasper 文件提供一个名称。单击 Next
3. New Report Wizard 中,选择父文件夹。选择带有 .jrxml 扩展名的报告文件名。单击 Finish
4. New Report WizardData Source 面板上,选择 One Empty Record - Empty rows 选项,然后单击 Finish
5. 验证项目 Outline 在此阶段是否没有 Fields
6. Design 编辑器的详细信息区域中拖动 Basic Elements > Table 元素。
7. Table WizardDataset 面板上,可以选择从选定源创建数据集,然后选择 Create new dataset from a connection or Data Source 来指定数据集名称。单击 Next
8. Table WizardConnection 面板上,选择 Use a JRDataSource expression。单击 Finish。 JRDataExpression 格式如下:
com.ptc.wbr.datasource.WRSJsonDataSource.getJsonDataSource(<WRS Endpoint>,<selectExpression>)
WRS 端点 - 表示 JSON 数据源的字符串。WRS 端点会返回 JSON 响应。
selectExpression - 表示选定表达式的字符串。
选定表达式是可选的。您可以提供任何选定的筛选器作为 getJsonDataSource 方法的第二个参数。
9. Table 创建字段。
10. 将这些字段拖动到表格中。
11. 生成报告。
这对您有帮助吗?