From 6dc4f3ba963f9030759fbf0c1233eaa68dac53c3 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 14 Sep 2022 15:00:02 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-75998=20=E6=90=9C=E7=B4=A2=E5=85=AC?= =?UTF-8?q?=E5=BC=8F=E2=80=94=E2=80=94=E6=95=B0=E6=8D=AE=E9=9B=86=E3=80=81?= =?UTF-8?q?=E6=82=AC=E6=B5=AE=E5=85=83=E7=B4=A0=E3=80=81=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/AbstractSearchDataFormulaAction.java | 31 +++++ .../action/content/formula/data/DataType.java | 124 ++++++++++++++++++ .../formula/data/SearchDataFormulaAction.java | 75 +++++++++++ .../AbstractSearchFloatFormula.java | 26 ++++ .../SearchFloatFormulaAction.java | 111 ++++++++++++++++ .../AbstractSearchTemplateFormula.java | 27 ++++ .../template/SearchTemplateFormulaAction.java | 65 +++++++++ 7 files changed, 459 insertions(+) create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/AbstractSearchDataFormulaAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/DataType.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/SearchDataFormulaAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/AbstractSearchFloatFormula.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/SearchFloatFormulaAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/AbstractSearchTemplateFormula.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/AbstractSearchDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/AbstractSearchDataFormulaAction.java new file mode 100644 index 0000000000..108b1b66d2 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/AbstractSearchDataFormulaAction.java @@ -0,0 +1,31 @@ +package com.fr.design.actions.replace.action.content.formula.data; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.mainframe.JTemplate; + +import java.util.ArrayList; + +/** + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-26 + */ +public abstract class AbstractSearchDataFormulaAction implements SearchDataFormula{ + + @Override + public void searchFormulaFromData(JTemplate jTemplate,ArrayList fomulaInfos) { + + } + + @Override + public void searchFormula(ArrayList formulaInfos, ITContent content) { + + } + + @Override + public ArrayList search4Infos(JTemplate jTemplate) { + return null; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/DataType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/DataType.java new file mode 100644 index 0000000000..3ed0b432dd --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/DataType.java @@ -0,0 +1,124 @@ +package com.fr.design.actions.replace.action.content.formula.data; + +import com.fr.base.Formula; +import com.fr.base.TableData; +import com.fr.data.impl.*; +import com.fr.data.impl.storeproc.StoreProcedure; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.stable.ParameterProvider; +import com.fr.stable.StringUtils; + +import java.util.ArrayList; + +/** + * + * 分别对不同类型的数据集进行获取公式处理 + * 暂不支持ClassTableData(用户自定义数据集)、FileTableData(用户自定义数据集),EmbeddedTableData(无公式) + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-26 + */ +public enum DataType { + /** + * 数据库查询 + */ + DB_TABLE_DATA("DBTableData"){ + @Override + public void searchFormula(TableData tableData, ITContent content, ArrayList fomulaInfos) { + if (((DBTableData)tableData).getParameters() != null){ + for (ParameterProvider provider : ((DBTableData)tableData).getParameters()){ + dealProvider(provider,content,fomulaInfos); + } + } + } + + }, + /** + * 存储过程 + */ + STORE_PROCEDURE("StoreProcedure"){ + @Override + public void searchFormula(TableData tableData, ITContent content, ArrayList fomulaInfos) { + if (((StoreProcedure)tableData).getParameters() != null){ + for (ParameterProvider provider : ((StoreProcedure)tableData).getParameters()){ + dealProvider(provider,content,fomulaInfos); + + } + } + } + }, + /** + * 关联数据集 + */ + CONDITION_TABLE_DATA("ConditionTableData"){ + @Override + public void searchFormula(TableData tableData, ITContent content, ArrayList fomulaInfos) { + if (((ConditionTableData)tableData).getDefineParameters() != null){ + for (ParameterProvider provider : ((ConditionTableData)tableData).getDefineParameters()){ + dealProvider(provider,content,fomulaInfos); + } + } + } + }, + /** + * 树数据集 + */ + RECURSION_TABLE_DATA("RecursionTableData"){ + @Override + public void searchFormula(TableData tableData, ITContent content, ArrayList fomulaInfos) { + if (((RecursionTableData)tableData).getParameters() != null){ + for (ParameterProvider provider : ((RecursionTableData)tableData).getParameters()){ + dealProvider(provider,content,fomulaInfos); + } + } + } + }; + + + String name; + DataType(String name) { + this.name = name; + } + + /** + * 处理参数 + * @param provider + * @param content + * @param formulaInfos + */ + public void dealProvider(ParameterProvider provider, ITContent content, ArrayList formulaInfos) { + if (provider .getValue()instanceof Formula && !StringUtils.isEmpty((((Formula) provider.getValue())).getContent() )){ + ITContent newContent = content.copy(); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Parameter")); + newContent.setReplaceObject(provider); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + + /** + * 匹配 + * @param name + * @return + */ + public static DataType match(String name){ + DataType[] values = DataType.values(); + for (DataType value : values) { + if(value.name.equals(name)){ + return value; + } + } + return null; + } + + /** + * 从数据集中获取公式 + * @param tableData + * @param content + * @param fomulaInfos + */ + void searchFormula(TableData tableData, ITContent content , ArrayList fomulaInfos){} + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/SearchDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/SearchDataFormulaAction.java new file mode 100644 index 0000000000..31f04705e1 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/SearchDataFormulaAction.java @@ -0,0 +1,75 @@ +package com.fr.design.actions.replace.action.content.formula.data; + +import com.fr.data.TableDataSource; +import com.fr.data.impl.DBTableData; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.SQLInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.data.tabledata.wrapper.TableDataFactory; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.file.TableDataConfig; +import com.fr.main.impl.WorkBook; + +import java.util.ArrayList; +import java.util.Iterator; + +/** + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-26 + */ +public class SearchDataFormulaAction extends AbstractSearchDataFormulaAction{ + + public SearchDataFormulaAction(JTemplate jTemplate, ArrayList fomulaInfos){ + searchFormulaFromData(jTemplate,fomulaInfos); + } + @Override + public void searchFormulaFromData(JTemplate jTemplate, ArrayList fomulaInfos) { + + //模板数据集 + dealTemplateData(jTemplate,fomulaInfos); + + //服务器数据集 + dealServerData(fomulaInfos); + + } + + private void dealServerData(ArrayList fomulaInfos) { + TableDataConfig tableDataConfig = TableDataConfig.getInstance(); + String[] nameArray = TableDataFactory.getSortOfChineseNameOfServerData(tableDataConfig); + for (String dataName : nameArray) { + ITContent content = new ITContent(); + content.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_DS_Server_TableData"), + dataName + ); + content.setShowObject(Toolkit.i18nText("Fine-Design_Basic_DS_Server_TableData")); + DataType dataType = DataType.match(tableDataConfig.getTableData(dataName).getClass().getSimpleName()); + if (dataType != null){ + dataType.searchFormula(tableDataConfig.getTableData(dataName),content,fomulaInfos); + } + } + } + + private void dealTemplateData(JTemplate jTemplate, ArrayList fomulaInfos) { + if (jTemplate.getTarget() instanceof TableDataSource){ + TableDataSource source = (TableDataSource) jTemplate.getTarget(); + Iterator dataIterator = source.getTableDataNameIterator(); + while (dataIterator.hasNext()){ + String dataName = (String) dataIterator.next(); + ITContent content = new ITContent(); + content.setTemplateName(jTemplate.getTemplateName()); + content.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_DS_Report_TableData"), + dataName + ); + content.setShowObject(Toolkit.i18nText("Fine-Design_Basic_DS_Report_TableData")); + DataType dataType = DataType.match(source.getTableData(dataName).getClass().getSimpleName()); + if (dataType != null){ + dataType.searchFormula(source.getTableData(dataName),content,fomulaInfos); + } + } + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/AbstractSearchFloatFormula.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/AbstractSearchFloatFormula.java new file mode 100644 index 0000000000..f4dff53627 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/AbstractSearchFloatFormula.java @@ -0,0 +1,26 @@ +package com.fr.design.actions.replace.action.content.formula.floatelement; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.mainframe.JTemplate; + +import java.util.ArrayList; + +/** + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-12 + */ +public abstract class AbstractSearchFloatFormula implements SearchFloatFormula{ + @Override + public void searchFormula(ArrayList formulaInfos, ITContent content) { + } + + @Override + public ArrayList search4Infos(JTemplate jTemplate) { + return new ArrayList<>(); + } + + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/SearchFloatFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/SearchFloatFormulaAction.java new file mode 100644 index 0000000000..331da754a4 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/SearchFloatFormulaAction.java @@ -0,0 +1,111 @@ +package com.fr.design.actions.replace.action.content.formula.floatelement; + +import com.fr.base.Formula; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.actions.replace.action.content.floatelement.SearchFloatAction; +import com.fr.design.actions.replace.action.content.formula.FormulaReplaceObject; +import com.fr.design.actions.replace.action.content.formula.chart.SearchChartCollectionFormulaAction; +import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction; +import com.fr.design.actions.replace.info.FloatInfo; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.js.NameJavaScriptGroup; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.FloatElement; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; + +/** + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-12 + */ +public class SearchFloatFormulaAction extends AbstractSearchFloatFormula { + + public SearchFloatFormulaAction(JTemplate jTemplate, ArrayList formulaInfos) { + SearchFloatAction searchFloatAction = new SearchFloatAction(jTemplate); + for (FloatInfo floatInfo : searchFloatAction.getFloatInfos()) { + searchFormulaFromFloat(formulaInfos, floatInfo); + searchFormulaFromFloatType(formulaInfos, floatInfo); + } + } + + @Override + public void searchFormulaFromFloat(ArrayList formulaInfos, FloatInfo floatInfo) { + NameJavaScriptGroup nameJavaScriptGroup = ((FloatElement) floatInfo.getContent().getReplaceObject()).getNameHyperlinkGroup(); + if (nameJavaScriptGroup != null) { + for (int i = 0; i < nameJavaScriptGroup.size(); i++) { + SearchJSHighlightAction action = new SearchJSHighlightAction(); + action.searchJSFormulaFromOther(formulaInfos, floatInfo.getContent(), nameJavaScriptGroup.getNameHyperlink(i).getJavaScript()); + } + } + } + + + @Override + public void searchFormulaFromFloatType(ArrayList formulaInfos, FloatInfo floatInfo) { + Object value = ((FloatElement) floatInfo.getContent().getReplaceObject()).getValue(); + FloatFormulaType floatFormulaType = FloatFormulaType.match(value.getClass().getSimpleName()); + if (floatFormulaType != null) { + floatFormulaType.searchFormulaFromFloatElementType(formulaInfos, floatInfo); + } + } + + /** + * 悬浮元素的类型 + */ + public enum FloatFormulaType { + /** + * 公式 + */ + FORMULA("Formula") { + @Override + public void searchFormulaFromFloatElementType(ArrayList formulaInfos, FloatInfo floatInfo) { + ITContent content = floatInfo.getContent().copy(); + Formula value = (Formula) ((FloatElement) floatInfo.getContent().getReplaceObject()).getValue(); + content.setReplaceObject(value); + formulaInfos.add(new FormulaInfo(content)); + } + }, + /** + * 图表 + */ + CHART_COLLECTION("ChartCollection") { + @Override + public void searchFormulaFromFloatElementType(ArrayList formulaInfos, FloatInfo floatInfo) { + ITContent content = floatInfo.getContent().copy(); + ChartCollection chartCollection = (ChartCollection) ((FloatElement) floatInfo.getContent().getReplaceObject()).getValue(); + content.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Chart")); + new SearchChartCollectionFormulaAction(formulaInfos, content, chartCollection); + } + }; + String name; + + FloatFormulaType(String name) { + this.name = name; + } + + /** + * 匹配 + * + * @param name + * @return + */ + @Nullable + public static FloatFormulaType match(String name) { + FloatFormulaType[] values = FloatFormulaType.values(); + for (FloatFormulaType value : values) { + if (value.name.equals(name)) { + return value; + } + } + return null; + } + + public void searchFormulaFromFloatElementType(ArrayList formulaInfos, FloatInfo floatInfo) { + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/AbstractSearchTemplateFormula.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/AbstractSearchTemplateFormula.java new file mode 100644 index 0000000000..4de0fccc0f --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/AbstractSearchTemplateFormula.java @@ -0,0 +1,27 @@ +package com.fr.design.actions.replace.action.content.formula.template; + + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.mainframe.JTemplate; + +import java.util.ArrayList; + +/** + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-12 + */ +public abstract class AbstractSearchTemplateFormula implements SearchTemplateFormula{ + + @Override + public void searchFormula(ArrayList formulaInfos, ITContent content) { + + } + + @Override + public ArrayList search4Infos(JTemplate jTemplate) { + return null; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java new file mode 100644 index 0000000000..bc89d2d6cf --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java @@ -0,0 +1,65 @@ +package com.fr.design.actions.replace.action.content.formula.template; + +import com.fr.base.Formula; +import com.fr.base.Parameter; +import com.fr.base.ParameterConfig; +import com.fr.base.io.AttrMark; +import com.fr.base.iofile.attr.WatermarkAttr; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.main.impl.WorkBook; +import com.fr.report.core.ReportUtils; +import com.fr.report.core.watermark.WaterMarkFactory; + +import java.util.ArrayList; + +/** + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-12 + */ +public class SearchTemplateFormulaAction extends AbstractSearchTemplateFormula { + + public SearchTemplateFormulaAction(JTemplate jTemplate, ArrayList formulaInfos) { + ITContent content = new ITContent(); + content.setTemplateName(jTemplate.getTemplateName()); + searchTemplateParaFormula(jTemplate, formulaInfos, content); + searchTemplateWaterMarkFormula(jTemplate, formulaInfos, content); + } + + @Override + public void searchTemplateWaterMarkFormula(JTemplate jTemplate, ArrayList formulaInfos, ITContent content) { + WatermarkAttr watermarkAttr = ReportUtils.getWatermarkAttrFromTemplateAndGlobal((AttrMark) jTemplate.getTarget()); + if (watermarkAttr != null) { + ITContent waterMarkContent = content.copy(); + waterMarkContent.addOtherPos(Toolkit.i18nText("Fine-Design_Form_WaterMark")); + waterMarkContent.setReplaceObject(watermarkAttr); + formulaInfos.add(new FormulaInfo(waterMarkContent)); + } + } + + @Override + public void searchTemplateParaFormula(JTemplate jTemplate, ArrayList formulaInfos, ITContent content) { + Parameter[] parameters = jTemplate.getJTemplateParameters(); + for (Parameter parameter : parameters) { + if (parameter.getValue() instanceof Formula) { + ITContent paraContent = content.copy(); + paraContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Template_Parameter")); + paraContent.setReplaceObject(parameter.getValue()); + formulaInfos.add(new FormulaInfo(paraContent)); + } + } + + Parameter[] globalParameters = ParameterConfig.getInstance().getGlobalParameters(); + for (Parameter parameter : globalParameters) { + if (parameter.getValue() instanceof Formula) { + ITContent paraContent = content.copy(); + paraContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Parameter_Source_Type_Server")); + paraContent.setReplaceObject(parameter.getValue()); + formulaInfos.add(new FormulaInfo(paraContent)); + } + } + } +}