From a6372ce1d78e262815994110a6f33edb9e4cbbc8 Mon Sep 17 00:00:00 2001 From: Rosie <3392418386@qq.com> Date: Tue, 8 Sep 2020 10:32:59 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E8=AE=BE=E7=BD=AE=E4=B8=8B=E6=8B=89=E6=A0=91=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC-https://help.finereport.com/doc-view-3637.ht?= =?UTF-8?q?ml=20=E6=96=87=E6=A1=A3=E4=B8=AD=E7=94=A8=E5=88=B0=E7=9A=84?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=87=BD=E6=95=B0=20TREENODEFINDER?= =?UTF-8?q?=20Java=E8=84=9A=E6=9C=AC=E4=BB=A3=E7=A0=81=20=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E7=94=A8=E9=80=94=EF=BC=9A=E9=80=9A=E8=BF=87=E3=80=8C?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=87=BD=E6=95=B0=E3=80=8D=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E6=A0=B9=E6=8D=AE=E5=AD=90=E8=8A=82=E7=82=B9=E7=9A=84?= =?UTF-8?q?=E5=80=BC=E6=89=BE=E5=87=BA=E5=8F=B6=E5=AD=90=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E7=9A=84=E5=AE=8C=E6=95=B4=E8=B7=AF=E5=BE=84=EF=BC=8C=E4=BB=8E?= =?UTF-8?q?=E8=80=8C=E5=AE=9E=E7=8E=B0=E4=B8=8B=E6=8B=89=E6=A0=91=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E9=BB=98=E8=AE=A4=E5=80=BC=E7=9A=84=E7=AE=80=E5=8D=95?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 注:此方法只能用于构建方式为「自动构建」的下拉树控件。 函数简介: 函数:TREENODEFINDER(param1,param2) 释义 : 1)param1 为叶子节点的值,可以是显示值,也可以是实际值。 传入单个值时,以 value 格式传入。 传入单个值时,以数组格式 ARRAY(value1,value2,.....) 传入。 value 为字符串时需要加 "" 。 2)param2 为构建下拉树控件的树数据集名称,值格式为“TreeName”。 示例: 单值:TREENODEFINDER("部长","Tree1") 多值:TREENODEFINDER(ARRAY("部长","会计"), "Tree1") --- .../java/com/fr/function/TREENODEFINDER.java | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 src/main/java/com/fr/function/TREENODEFINDER.java diff --git a/src/main/java/com/fr/function/TREENODEFINDER.java b/src/main/java/com/fr/function/TREENODEFINDER.java new file mode 100644 index 0000000..96abe94 --- /dev/null +++ b/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; + } +} From ff722491446fcb21259c5107afb0552566fa25c7 Mon Sep 17 00:00:00 2001 From: "Bruce.Deng" Date: Fri, 25 Sep 2020 13:41:25 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-39385=20=E5=AF=BC=E5=87=BAAPI?= =?UTF-8?q?=EF=BC=8C=E6=97=A5=E5=BF=97=E6=8A=A5=E9=94=99=EF=BC=8C=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=97=A0=E6=B3=95=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fr/demo/SaveReportToDatabase.java | 2 ++ src/main/java/com/fr/function/ReportCheck.java | 2 ++ src/main/java/com/fr/io/CreateGenericTemplate.java | 1 + src/main/java/com/fr/io/ExcelToCpt.java | 1 + src/main/java/com/fr/io/ExcuteDemo.java | 1 + src/main/java/com/fr/io/ExportApi.java | 11 +++++++++-- src/main/java/com/fr/io/ExportApi_frm.java | 1 + src/main/java/com/fr/io/ExportBatch.java | 1 + src/main/java/com/fr/io/ExportExcel.java | 1 + src/main/java/com/fr/io/ExportReports.java | 1 + src/main/java/com/fr/io/JavaPrint.java | 1 + src/main/java/com/fr/io/SaveReportToDatabase.java | 1 + src/main/java/com/fr/io/SetParameterWindow.java | 1 + src/main/java/com/fr/io/SimpleDemo.java | 1 + src/test/main/java/com/fr/demo/ExportApiTest.java | 1 + src/test/main/java/com/fr/demo/ModuleStartTest.java | 1 + 16 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/fr/demo/SaveReportToDatabase.java b/src/main/java/com/fr/demo/SaveReportToDatabase.java index 4905df5..c468aba 100644 --- a/src/main/java/com/fr/demo/SaveReportToDatabase.java +++ b/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(), diff --git a/src/main/java/com/fr/function/ReportCheck.java b/src/main/java/com/fr/function/ReportCheck.java index 907da1b..5035536 100644 --- a/src/main/java/com/fr/function/ReportCheck.java +++ b/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(), diff --git a/src/main/java/com/fr/io/CreateGenericTemplate.java b/src/main/java/com/fr/io/CreateGenericTemplate.java index 55a8558..fbcbd7c 100644 --- a/src/main/java/com/fr/io/CreateGenericTemplate.java +++ b/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(), diff --git a/src/main/java/com/fr/io/ExcelToCpt.java b/src/main/java/com/fr/io/ExcelToCpt.java index 0ab1d9b..4c3c570 100644 --- a/src/main/java/com/fr/io/ExcelToCpt.java +++ b/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(), diff --git a/src/main/java/com/fr/io/ExcuteDemo.java b/src/main/java/com/fr/io/ExcuteDemo.java index 91124de..5c4d5c0 100644 --- a/src/main/java/com/fr/io/ExcuteDemo.java +++ b/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(), diff --git a/src/main/java/com/fr/io/ExportApi.java b/src/main/java/com/fr/io/ExportApi.java index 0d70ac1..f6cad8c 100644 --- a/src/main/java/com/fr/io/ExportApi.java +++ b/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() diff --git a/src/main/java/com/fr/io/ExportApi_frm.java b/src/main/java/com/fr/io/ExportApi_frm.java index 0674938..4a037cf 100644 --- a/src/main/java/com/fr/io/ExportApi_frm.java +++ b/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(), diff --git a/src/main/java/com/fr/io/ExportBatch.java b/src/main/java/com/fr/io/ExportBatch.java index 392bb66..9a97a03 100644 --- a/src/main/java/com/fr/io/ExportBatch.java +++ b/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(), diff --git a/src/main/java/com/fr/io/ExportExcel.java b/src/main/java/com/fr/io/ExportExcel.java index 39d6d4e..5d5b949 100644 --- a/src/main/java/com/fr/io/ExportExcel.java +++ b/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(), diff --git a/src/main/java/com/fr/io/ExportReports.java b/src/main/java/com/fr/io/ExportReports.java index ded0225..75a40f9 100644 --- a/src/main/java/com/fr/io/ExportReports.java +++ b/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(), diff --git a/src/main/java/com/fr/io/JavaPrint.java b/src/main/java/com/fr/io/JavaPrint.java index f9b65ba..797ebc8 100644 --- a/src/main/java/com/fr/io/JavaPrint.java +++ b/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(), diff --git a/src/main/java/com/fr/io/SaveReportToDatabase.java b/src/main/java/com/fr/io/SaveReportToDatabase.java index 161f6ba..1608a48 100644 --- a/src/main/java/com/fr/io/SaveReportToDatabase.java +++ b/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(), diff --git a/src/main/java/com/fr/io/SetParameterWindow.java b/src/main/java/com/fr/io/SetParameterWindow.java index 5ec569f..4878298 100644 --- a/src/main/java/com/fr/io/SetParameterWindow.java +++ b/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(), diff --git a/src/main/java/com/fr/io/SimpleDemo.java b/src/main/java/com/fr/io/SimpleDemo.java index 669f291..0d9b943 100644 --- a/src/main/java/com/fr/io/SimpleDemo.java +++ b/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(), diff --git a/src/test/main/java/com/fr/demo/ExportApiTest.java b/src/test/main/java/com/fr/demo/ExportApiTest.java index b73b508..061a20f 100644 --- a/src/test/main/java/com/fr/demo/ExportApiTest.java +++ b/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(), diff --git a/src/test/main/java/com/fr/demo/ModuleStartTest.java b/src/test/main/java/com/fr/demo/ModuleStartTest.java index cf376c1..63c6f4b 100644 --- a/src/test/main/java/com/fr/demo/ModuleStartTest.java +++ b/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(), From ae0260ea55d825a7b303da5d3440cf6fb9d833e8 Mon Sep 17 00:00:00 2001 From: zack Date: Fri, 6 Nov 2020 15:59:12 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-42908=20=E8=B0=83=E7=94=A8sap?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=B8=86=E8=BD=AF=E4=B8=8A=E6=B2=A1=E6=89=A7?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fr/data/ParamSAPDataTest.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/fr/data/ParamSAPDataTest.java b/src/main/java/com/fr/data/ParamSAPDataTest.java index 9b06dba..72af385 100644 --- a/src/main/java/com/fr/data/ParamSAPDataTest.java +++ b/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 arrayList = new ArrayList(); - arrayList.add("LIFNR"); - arrayList.add("NAME1"); - - - this.parameters = new XmlColConf>(arrayList, ParameterProvider.class); + ArrayList 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] = "供应商编码";