Browse Source

Pull request #36: 1127插件代码合并

Merge in PG/plugin-report-doc-demo from release/10.0 to persist/10.0

* commit 'ebdca952ab67a810a7b0d63602b2f1c079120ba3':
  REPORT-42908 调用sap接口帆软上没执行
  REPORT-39385 导出API,日志报错,文件无法输出
  自定义函数设置下拉树默认值-https://help.finereport.com/doc-view-3637.html 文档中用到的自定义函数 TREENODEFINDER Java脚本代码 函数用途:通过「自定义函数」实现根据子节点的值找出叶子节点的完整路径,从而实现下拉树控件默认值的简单设置。
persist/10.0
Okcean 4 years ago
parent
commit
26e083a658
  1. 12
      src/main/java/com/fr/data/ParamSAPDataTest.java
  2. 2
      src/main/java/com/fr/demo/SaveReportToDatabase.java
  3. 2
      src/main/java/com/fr/function/ReportCheck.java
  4. 126
      src/main/java/com/fr/function/TREENODEFINDER.java
  5. 1
      src/main/java/com/fr/io/CreateGenericTemplate.java
  6. 1
      src/main/java/com/fr/io/ExcelToCpt.java
  7. 1
      src/main/java/com/fr/io/ExcuteDemo.java
  8. 11
      src/main/java/com/fr/io/ExportApi.java
  9. 1
      src/main/java/com/fr/io/ExportApi_frm.java
  10. 1
      src/main/java/com/fr/io/ExportBatch.java
  11. 1
      src/main/java/com/fr/io/ExportExcel.java
  12. 1
      src/main/java/com/fr/io/ExportReports.java
  13. 1
      src/main/java/com/fr/io/JavaPrint.java
  14. 1
      src/main/java/com/fr/io/SaveReportToDatabase.java
  15. 1
      src/main/java/com/fr/io/SetParameterWindow.java
  16. 1
      src/main/java/com/fr/io/SimpleDemo.java
  17. 1
      src/test/main/java/com/fr/demo/ExportApiTest.java
  18. 1
      src/test/main/java/com/fr/demo/ModuleStartTest.java

12
src/main/java/com/fr/data/ParamSAPDataTest.java

@ -1,6 +1,7 @@
package com.fr.data;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.config.holder.impl.xml.XmlColConf;
import com.fr.function.ConnectSAPServer;
import com.fr.stable.ParameterProvider;
@ -10,7 +11,6 @@ import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoTable;
import java.util.ArrayList;
import java.util.Collection;
public class ParamSAPDataTest extends AbstractTableData {
private String[] columnNames = null;
@ -22,12 +22,10 @@ public class ParamSAPDataTest extends AbstractTableData {
private static JCoDestination jCoDestination;
public ParamSAPDataTest() {
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add("LIFNR");
arrayList.add("NAME1");
this.parameters = new XmlColConf<Collection<ParameterProvider>>(arrayList, ParameterProvider.class);
ArrayList<ParameterProvider> arrayList = new ArrayList<>();
arrayList.add(new Parameter("LIFNR"));
arrayList.add(new Parameter("NAME1"));
this.parameters = new XmlColConf<>(arrayList, ParameterProvider.class);
this.columnNames = new String[this.columnNum];
this.columnNames[0] = "供应商编码";

2
src/main/java/com/fr/demo/SaveReportToDatabase.java

@ -8,6 +8,7 @@ import com.fr.config.activator.ConfigurationActivator;
import com.fr.env.operator.CommonOperatorImpl;
import com.fr.general.I18nResource;
import com.fr.health.activator.ModuleHealActivator;
import com.fr.io.ResourceRepositoryActivator;
import com.fr.module.Module;
import com.fr.module.tool.ActivatorToolBox;
import com.fr.report.ReportActivator;
@ -35,6 +36,7 @@ public class SaveReportToDatabase {
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),

2
src/main/java/com/fr/function/ReportCheck.java

@ -10,6 +10,7 @@ import com.fr.config.activator.ConfigurationActivator;
import com.fr.env.operator.CommonOperatorImpl;
import com.fr.general.I18nResource;
import com.fr.health.activator.ModuleHealActivator;
import com.fr.io.ResourceRepositoryActivator;
import com.fr.io.TemplateWorkBookIO;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
@ -45,6 +46,7 @@ public class ReportCheck extends AbstractFunction {
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),

126
src/main/java/com/fr/function/TREENODEFINDER.java

@ -0,0 +1,126 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.fr.function;
import com.fr.base.BaseUtils;
import com.fr.base.SynchronizedLiveDataModelUtils;
import com.fr.data.impl.RecursionDataModel;
import com.fr.general.FArray;
import com.fr.general.GeneralUtils;
import com.fr.general.data.DataModel;
import com.fr.invoke.Reflect;
import com.fr.script.AbstractFunction;
import com.fr.script.Calculator;
import com.fr.security.function.RestrictScript;
import com.fr.stable.Primitive;
import com.fr.stable.StringUtils;
import com.fr.stable.exception.FormulaException;
import java.util.Map;
@RestrictScript
public class TREENODEFINDER extends AbstractFunction {
public TREENODEFINDER() {
}
public Object run(Object[] args) throws FormulaException {
if (!this.validateArgs(args)) {
return Primitive.ERROR_NAME;
} else {
boolean noLiveDataModel = !this.liveDataModel4ShareExists();
DataModel dataModel = this.generateDataModel(args);
try {
if (args.length != 2) {
return Primitive.NULL;
}
if (args[0] instanceof FArray) {
FArray nodeArray = (FArray) args[0];
FArray result = new FArray();
for (int i = 0; i < nodeArray.length(); i++) {
result.simpleAdd(this.run(GeneralUtils.objectToString(nodeArray.elementAt(i)), dataModel));
}
return result;
} else {
return this.run(GeneralUtils.objectToString(args[0]), dataModel);
}
} finally {
if (noLiveDataModel && dataModel != null) {
try {
dataModel.release();
} catch (Exception var11) {
this.log(var11.getMessage(), var11);
}
}
}
}
}
private boolean liveDataModel4ShareExists() {
Calculator calculatorProvider = this.getCalculator();
if (calculatorProvider == null) {
return false;
} else {
Map var1 = (Map) calculatorProvider.getAttribute(SynchronizedLiveDataModelUtils.CUR_LIVE_RS);
return var1 != null && !var1.isEmpty();
}
}
public Object run(String nodeValue, DataModel dataModel) {
try {
RecursionDataModel rdm = Reflect.on(dataModel).get("dataModel");
int treeStart = 0;
int m;
for (m = 0; m < rdm.getColumnCount(); ++m) {
String colName = rdm.getColumnName(m);
if (colName.startsWith("FR_GEN_")) {
treeStart = m;
break;
}
}
m = 0;
for (int len = rdm.getRowCount(); m < len; ++m) {
int i = 0;
for (int colCount = rdm.getColumnCount(); i < colCount; ++i) {
String value = GeneralUtils.objectToString(rdm.getValueAt(m, i));
if (StringUtils.equals(nodeValue, value)) {
FArray array = new FArray();
for (int j = treeStart; j < colCount; ++j) {
String val = GeneralUtils.objectToString(rdm.getValueAt(m, j));
if (StringUtils.isNotEmpty(val)) {
array.add(val);
}
}
return array;
}
}
}
} catch (Exception var13) {
this.log(var13.getMessage(), var13);
}
return Primitive.NULL;
}
public boolean validateArgs(Object[] args) {
return args != null && args.length >= 1;
}
public DataModel generateDataModel(Object[] args) {
return BaseUtils.getDataModelFromTableDataName(this.getCalculator(), args[1].toString());
}
public Type getType() {
return REPORT;
}
}

1
src/main/java/com/fr/io/CreateGenericTemplate.java

@ -37,6 +37,7 @@ public class CreateGenericTemplate {
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),

1
src/main/java/com/fr/io/ExcelToCpt.java

@ -32,6 +32,7 @@ public class ExcelToCpt {
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),

1
src/main/java/com/fr/io/ExcuteDemo.java

@ -33,6 +33,7 @@ public class ExcuteDemo {
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),

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

@ -10,8 +10,14 @@ import com.fr.general.I18nResource;
import com.fr.general.log.Log4jConfig;
import com.fr.general.log.parser.ExtraPatternParserManager;
import com.fr.health.activator.ModuleHealActivator;
import com.fr.io.TemplateWorkBookIO;
import com.fr.io.exporter.*;
import com.fr.io.exporter.CSVExporter;
import com.fr.io.exporter.EmbeddedTableDataExporter;
import com.fr.io.exporter.ExcelExporter;
import com.fr.io.exporter.ImageExporter;
import com.fr.io.exporter.PDFExporter;
import com.fr.io.exporter.SVGExporter;
import com.fr.io.exporter.TextExporter;
import com.fr.io.exporter.WordExporter;
import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter;
import com.fr.main.impl.WorkBook;
import com.fr.module.tool.ActivatorToolBox;
@ -43,6 +49,7 @@ public class ExportApi {
/**定义报表运行环境,用于执行报表*/
com.fr.module.Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
//2020.4.26jar包之前的版本,替换成StateServerActivator()

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

@ -31,6 +31,7 @@ public class ExportApi_frm {
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),

1
src/main/java/com/fr/io/ExportBatch.java

@ -38,6 +38,7 @@ public class ExportBatch {
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),

1
src/main/java/com/fr/io/ExportExcel.java

@ -40,6 +40,7 @@ public class ExportExcel {
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),

1
src/main/java/com/fr/io/ExportReports.java

@ -35,6 +35,7 @@ public class ExportReports {
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),

1
src/main/java/com/fr/io/JavaPrint.java

@ -29,6 +29,7 @@ public class JavaPrint {
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),

1
src/main/java/com/fr/io/SaveReportToDatabase.java

@ -45,6 +45,7 @@ public class SaveReportToDatabase {
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),

1
src/main/java/com/fr/io/SetParameterWindow.java

@ -33,6 +33,7 @@ public class SetParameterWindow {
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),

1
src/main/java/com/fr/io/SimpleDemo.java

@ -33,6 +33,7 @@ public class SimpleDemo {
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),

1
src/test/main/java/com/fr/demo/ExportApiTest.java

@ -42,6 +42,7 @@ public class ExportApiTest extends TestCase {
public void testExport() {
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),

1
src/test/main/java/com/fr/demo/ModuleStartTest.java

@ -64,6 +64,7 @@ public class ModuleStartTest extends TestCase {
private Module initModule() {
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),

Loading…
Cancel
Save