Compare commits

..

21 Commits

Author SHA1 Message Date
Bruce.Deng-邓铖臻 10a7bacd48 Pull request #67: 合persist11 1 year ago
Bruce.Deng-邓铖臻 e47c617a34 Pull request #66: REPORT-109627 导出api使用maven引入jar版本问题 1 year ago
Bruce.Deng 7c9d423df1 REPORT-109627 导出api使用maven引入jar版本问题 1 year ago
kerry-王周勇 1393efc5f7 Pull request #62: REPORT-96002【来源客户BUG REPORT-94898】FR11程序网络报表的demo类,更新文档和demo代码 2 years ago
kerry ee67e4df63 REPORT-96002【来源客户BUG REPORT-94898】FR11程序网络报表的demo类,更新文档和demo代码 2 years ago
Bruce.Deng-邓铖臻 3c84822025 Pull request #61: 无jira任务,release/10.0合到persist/10.0 2 years ago
Icey.Zhang c974449e23 Pull request #52: 10.0.16-0526号版本插件代码合并 4 years ago
Lanlan c21ebed9f4 Pull request #45: 误删自定义函数,恢复 4 years ago
Okcean ce7482718d Pull request #40: 10.0.14-0311号版本插件代码合并 4 years ago
Okcean 26e083a658 Pull request #36: 1127插件代码合并 4 years ago
Bruce.Deng d1776fa526 Pull request #31: 无JIRA任务 插件发布,release合persist 4 years ago
Leo.Tsai ca629a1ff6 Pull request #27: Release/10.0 4 years ago
Leo.Cai 99ff96fea6 代码做了修改,而且要导入一个新的JAR包:slf4j-simple-1.7.25.jar,JAR包下载参见文档https://help.finereport.com/doc-view-735.html 的3.1节 4 years ago
Lanlan e1f402023f Pull request #25: 无JIRA任务 插件发布,release合persist 5 years ago
Lanlan 5a3d9301af Merge pull request #23 in PG/plugin-report-doc-demo from release/10.0 to persist/10.0 5 years ago
susie 34ec362f64 Merge pull request #21 in PG/plugin-report-doc-demo from ~HARRISON/plugin-report-doc-demo:persist/10.0 to persist/10.0 5 years ago
Harrison c81c49f7ad DEMO-3230 Release10 module无法引用 5 years ago
Lanlan 9a474478b3 Merge pull request #19 in PG/plugin-report-doc-demo from release/10.0 to persist/10.0 5 years ago
Lanlan 10e88848e4 Merge pull request #12 in PG/plugin-report-doc-demo from release/10.0 to persist/10.0 5 years ago
Lanlan d6274eea84 Merge pull request #10 in PG/plugin-report-doc-demo from release/10.0 to persist/10.0 5 years ago
Lanlan de51123131 Merge pull request #8 in PG/plugin-report-doc-demo from release/10.0 to persist/10.0 5 years ago
  1. 3
      plugin.xml
  2. 10
      pom.xml
  3. 7
      readme.md
  4. 91
      src/main/java/com/fr/data/WebServiceTableData.java
  5. 12
      src/main/java/com/fr/demo/SimpleReportletDemoFrm.java
  6. 27
      src/main/java/com/fr/io/ExportApi.java
  7. 30
      src/main/java/com/fr/io/ExportApi_frm.java

3
plugin.xml

@ -4,12 +4,13 @@
<name><![CDATA[文档demo代码集成]]></name> <name><![CDATA[文档demo代码集成]]></name>
<active>yes</active> <active>yes</active>
<hidden>no</hidden> <hidden>no</hidden>
<version>1.1.1</version> <version>1.1.2</version>
<env-version>10.0~</env-version> <env-version>10.0~</env-version>
<jartime>2018-08-02</jartime> <jartime>2018-08-02</jartime>
<vendor>finereport</vendor> <vendor>finereport</vendor>
<description><![CDATA[集成帮助文档中的demo代码]]></description> <description><![CDATA[集成帮助文档中的demo代码]]></description>
<change-notes><![CDATA[ <change-notes><![CDATA[
[2023-11-28] 插件适配11<br>
[2018-01-25] 发布。<br> [2018-01-25] 发布。<br>
[2018-08-02] 插件适配10 [2018-08-02] 插件适配10
]]></change-notes> ]]></change-notes>

10
pom.xml

@ -3,10 +3,10 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.fr.plugin</groupId> <groupId>com.fr.plugin</groupId>
<artifactId>starter</artifactId> <artifactId>starter</artifactId>
<version>10.0</version> <version>11.0</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<properties> <properties>
<common-version>10.0-RELEASE-SNAPSHOT</common-version> <common-version>11.0-RELEASE-SNAPSHOT</common-version>
<web-inf-bucket>${project.basedir}/webroot/WEB-INF</web-inf-bucket> <web-inf-bucket>${project.basedir}/webroot/WEB-INF</web-inf-bucket>
</properties> </properties>
<dependencies> <dependencies>
@ -28,6 +28,12 @@
<version>${common-version}</version> <version>${common-version}</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.fr.cbb</groupId>
<artifactId>fine-cbb</artifactId>
<version>${common-version}</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>com.fr.webui</groupId> <groupId>com.fr.webui</groupId>
<artifactId>fine-webui</artifactId> <artifactId>fine-webui</artifactId>

7
readme.md

@ -20,7 +20,6 @@
只需要更改pom.xml中的common-version属性即可。 只需要更改pom.xml中的common-version属性即可。
| common-version | 含义 | | common-version | 含义 |
|--------------|----| |-----------------------|-------------|
|10.0-RELEASE-SNAPSHOT|10.0的测试版本快照| | 11.0-RELEASE-SNAPSHOT | 11.0的测试版本快照 |
|10.0-SNAPSHOT|10.0的正式版本快照| | 11.0-PERSIST-SNAPSHOT | 11.0的正式版本快照 |
|10.0|10.0的正式版本|

91
src/main/java/com/fr/data/WebServiceTableData.java

@ -1,87 +1,38 @@
package com.fr.data; package com.fr.data;
import com.fr.general.data.TableDataException; import javax.xml.namespace.QName;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ParameterProvider;
import org.apache.axis.client.Call; import org.apache.axis.client.Call;
import org.apache.axis.client.Service; import org.apache.axis.client.Service;
import com.fr.data.AbstractTableData;
import com.fr.general.data.TableDataException;
import javax.xml.namespace.QName; public class WebServiceTableData extends AbstractTableData{
import java.util.ArrayList; private String[][] data;
import java.util.List;
/**
* WebService程序数据集
*
* @author Roger
* @since 11.0
* Created on 2024/1/8
*/
public class WebServiceTableData extends SimpleTableData {
private static final int COLUMN_COUNT = 10;
/** public WebServiceTableData() {
* 初始化列名数组 this.data = this.createData();
*
* @return {col1,col2,col3...}
* @throws TableDataException
*/
@Override
public String[] initColumnNames() {
String[] columnNames = new String[COLUMN_COUNT];
for (int i = 0; i < COLUMN_COUNT; i++) {
columnNames[i] = "column#" + i;
} }
return columnNames;
}
/**
* 加载数据
*
* @return 行列数据
*/
@Override
public List<Object[]> loadData() {
String tableName = ((ParameterProvider) (parameters.get().toArray())[0]).getValue().toString();
FineLoggerFactory.getLogger().info("Query SQL of ParamTableDataDemo: {}", tableName);
// 保存得到的结果集 //获取列数
ArrayList<Object[]> valueList = new ArrayList(); public int getColumnCount() throws TableDataException {
return data[0].length;
try {
// 调用 Web 服务获取数据
String[][] data = createData();
// 如果数据为空,直接返回空列表
if (data == null || data.length == 0) {
return valueList;
} }
// 获得总列数 //获取列的名称为数组中第一行的值
int colNum = data[0].length; public String getColumnName(int columnIndex) throws TableDataException {
return data[0][columnIndex];
// 用对象保存数据
Object[] objArray = null;
for (int rowIndex = 1; rowIndex < data.length; rowIndex++) {
objArray = new Object[colNum];
for (int i = 0; i < colNum; i++) {
objArray[i] = data[rowIndex][i];
} }
// 在valueList中加入这一行数据
valueList.add(objArray); //获取行数为数据的长度-1
} public int getRowCount() throws TableDataException {
} catch (Exception e) { return data.length - 1;
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
return valueList;
//获取值
public Object getValueAt(int rowIndex, int columnIndex) {
return data[rowIndex + 1][columnIndex];
} }
/**
* 调用 Web 服务获取数据
*
* @return
*/
public String[][] createData() { public String[][] createData() {
try { try {
String endpoint = "http://localhost:8080/axis/TestWS2TDClient.jws"; String endpoint = "http://localhost:8080/axis/TestWS2TDClient.jws";

12
src/main/java/com/fr/demo/SimpleReportletDemoFrm.java

@ -1,16 +1,15 @@
package com.fr.demo; package com.fr.demo;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.fr.form.main.DashboardTemplate;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.form.main.FormIO; import com.fr.form.main.FormIO;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.web.weblet.Formlet; import com.fr.web.weblet.Formlet;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
public class SimpleReportletDemoFrm extends Formlet { public class SimpleReportletDemoFrm extends Formlet {
@Override @Override
public void setParameterMap(Map arg0) { public void setParameterMap(Map arg0) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -18,17 +17,20 @@ public class SimpleReportletDemoFrm extends Formlet {
} }
@Override @Override
protected Form createForm(HttpServletRequest request) throws Exception { protected DashboardTemplate createDashboard(HttpServletRequest req) throws Exception {
Form form = null; Form form = null;
//模板的相对路径 //模板的相对路径
String tplPath = "//doc//frm//决策报表入门.frm"; String tplPath = "//doc//frm//决策报表入门.frm";
this.setTplPath(tplPath); this.setTplPath(tplPath);
try { try {
form = FormIO.readForm(tplPath); form = FormIO.readForm(tplPath);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
return form; return form;
} }
} }

27
src/main/java/com/fr/io/ExportApi.java

@ -18,11 +18,12 @@ import com.fr.io.exporter.TextExporter;
import com.fr.io.exporter.WordExporter; import com.fr.io.exporter.WordExporter;
import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter; import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.module.ModuleRole;
import com.fr.module.tool.ActivatorToolBox; import com.fr.module.tool.ActivatorToolBox;
import com.fr.report.ReportActivator; import com.fr.report.ReportActivator;
import com.fr.report.RestrictionActivator; import com.fr.report.RestrictionActivator;
import com.fr.report.module.ReportBaseActivator; import com.fr.report.module.ReportBaseActivator;
import com.fr.report.write.WriteActivator;
import com.fr.scheduler.SchedulerActivator;
import com.fr.stable.WriteActor; import com.fr.stable.WriteActor;
import com.fr.store.StateServiceActivator; import com.fr.store.StateServiceActivator;
import com.fr.workspace.simple.SimpleWork; import com.fr.workspace.simple.SimpleWork;
@ -31,39 +32,32 @@ import java.io.FileOutputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class ExportApi { public class ExportApi {
public static void main(String[] args) { public static void main(String[] args) {
/**
* 以下这段if判断仅在main函数测试时使用
* 实际生产环境中一般使用web容器集成帆软后帆软服务会自动启动不再需要下面的if判断直接写导出的业务逻辑即可
* web集成注意事项
* 1集成环境需要依赖当前使用jdk对应版本的tools.jar一般从jdk中直接复制即可;
* 2帆软服务自动启动成功后使用的工作目录自动识别为集成应用下的WEB-INF目录所以需要把下面代码中envpath指向的工作目录拷贝到集成环境下web应用的WEB-INF目录
* 正式发布时需要拷贝生产环境的帆软WEB-INF如果有的话这样才能沿用原先帆软的配置及模板如果是集群环境会自动使用文件服务器的模板本地测试时envpath需要指向单机非集群的帆软工程
* 3可以访问集成环境的地址 ip:port/应用名/decision 如果能成功访问且不需要初始化配置则代表帆软服务启动成功
*/
if (!ModuleRole.Root.isPresent()) {
/**定义报表运行环境,用于执行报表*/ /**定义报表运行环境,用于执行报表*/
com.fr.module.Module module = ActivatorToolBox.simpleLink( com.fr.module.Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new BaseDBActivator(),
new ConfigurationActivator(), new ConfigurationActivator(),
new ResourceRepositoryActivator(), new ResourceRepositoryActivator(),
new StandaloneModeActivator(), new StandaloneModeActivator(),
new ModuleHealActivator(), new ModuleHealActivator(),
//2020.4.26jar包之前的版本,替换成StateServerActivator() //2020.4.26jar包之前的版本,替换成StateServerActivator()
new StateServiceActivator(), new StateServiceActivator(),
new SchedulerActivator(),
new ReportBaseActivator(), new ReportBaseActivator(),
new RestrictionActivator(), new RestrictionActivator(),
new ReportActivator(), new ReportActivator(),
new WriteActivator(),
new ChartBaseActivator()); new ChartBaseActivator());
SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl());
//定义工程路径 //定义工程路径
String envpath = "D:\\FineReport_11.0\\webapps\\webroot\\WEB-INF\\"; String envpath = "D:\\javatools\\FineReport_10.0\\webapps\\webroot\\WEB-INF\\";
SimpleWork.checkIn(envpath); SimpleWork.checkIn(envpath);
I18nResource.getInstance(); I18nResource.getInstance();
module.start(); module.start();
}
/**输出模板*/ /**输出模板*/
try { try {
// 定义输出的模板路径,以reportlets为根目录 // 定义输出的模板路径,以reportlets为根目录
@ -127,8 +121,11 @@ public class ExportApi {
ImageExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); ImageExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
outputStream.close(); outputStream.close();
module.stop();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
SimpleWork.checkOut();
} }
} }

30
src/main/java/com/fr/io/ExportApi_frm.java

@ -13,11 +13,13 @@ import com.fr.io.exporter.ImageExporter;
import com.fr.io.exporter.PDFExporter; import com.fr.io.exporter.PDFExporter;
import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter; import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter;
import com.fr.main.workbook.ResultWorkBook; import com.fr.main.workbook.ResultWorkBook;
import com.fr.module.ModuleRole; import com.fr.module.Module;
import com.fr.module.tool.ActivatorToolBox; import com.fr.module.tool.ActivatorToolBox;
import com.fr.report.ReportActivator; import com.fr.report.ReportActivator;
import com.fr.report.RestrictionActivator; import com.fr.report.RestrictionActivator;
import com.fr.report.module.ReportBaseActivator; import com.fr.report.module.ReportBaseActivator;
import com.fr.report.write.WriteActivator;
import com.fr.scheduler.SchedulerActivator;
import com.fr.store.StateServiceActivator; import com.fr.store.StateServiceActivator;
import com.fr.workspace.simple.SimpleWork; import com.fr.workspace.simple.SimpleWork;
@ -25,38 +27,25 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
public class ExportApi_frm { public class ExportApi_frm {
public static void main(String[] args) { public static void main(String[] args) {
/** // 定义报表运行环境,用于执行报表
* 以下这段if判断仅在main函数测试时使用 Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
* 实际生产环境中一般使用web容器集成帆软后帆软服务会自动启动不再需要下面的if判断直接写导出的业务逻辑即可
* web集成注意事项
* 1集成环境需要依赖当前使用jdk对应版本的tools.jar一般从jdk中直接复制即可;
* 2帆软服务自动启动成功后使用的工作目录自动识别为集成应用下的WEB-INF目录所以需要把下面代码中envpath指向的工作目录拷贝到集成环境下web应用的WEB-INF目录
* 正式发布时需要拷贝生产环境的帆软WEB-INF如果有的话这样才能沿用原先帆软的配置及模板如果是集群环境会自动使用文件服务器的模板本地测试时envpath需要指向单机非集群的帆软工程
* 3可以访问集成环境的地址 ip:port/应用名/decision 如果能成功访问且不需要初始化配置则代表帆软服务启动成功
*/
if (!ModuleRole.Root.isPresent()) {
/**定义报表运行环境,用于执行报表*/
com.fr.module.Module module = ActivatorToolBox.simpleLink(
new BaseDBActivator(),
new ConfigurationActivator(), new ConfigurationActivator(),
new ResourceRepositoryActivator(), new ResourceRepositoryActivator(),
new StandaloneModeActivator(), new StandaloneModeActivator(),
new ModuleHealActivator(), new ModuleHealActivator(),
//2020.4.26jar包之前的版本,替换成StateServerActivator()
new StateServiceActivator(), new StateServiceActivator(),
new SchedulerActivator(),
new ReportBaseActivator(), new ReportBaseActivator(),
new RestrictionActivator(), new RestrictionActivator(),
new ReportActivator(), new ReportActivator(),
new WriteActivator(),
new ChartBaseActivator()); new ChartBaseActivator());
SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl());
//定义工程路径 String envpath = "C:\\Users\\hipsh\\Desktop\\apache-tomcat-8.5.38-10.0\\webapps\\webroot\\WEB-INF\\";//工程路径
String envpath = "D:\\FineReport_11.0\\webapps\\webroot\\WEB-INF\\";
SimpleWork.checkIn(envpath); SimpleWork.checkIn(envpath);
I18nResource.getInstance(); I18nResource.getInstance();
module.start(); module.start();
}
try { try {
java.util.Map parameterMap = new java.util.HashMap(); java.util.Map parameterMap = new java.util.HashMap();
@ -77,8 +66,11 @@ public class ExportApi_frm {
ImageExporter ImageExport = new ImageExporter(); ImageExporter ImageExport = new ImageExporter();
ImageExport.export(outputStream, re); ImageExport.export(outputStream, re);
outputStream.close(); outputStream.close();
module.stop();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
SimpleWork.checkOut();
} }
} }
} }
Loading…
Cancel
Save