From c6e07423f9e3529790cf58be1f81841a2b83a07f Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 21 Nov 2024 16:45:47 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-141247=20=E3=80=90FVS=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E6=9B=BF=E6=8D=A2=E3=80=91=E5=85=AC=E5=BC=8Fds1.selec?= =?UTF-8?q?t=E3=80=81group=E3=80=81find=E5=AD=97=E6=AE=B5=E5=90=8D?= =?UTF-8?q?=E4=B8=8D=E4=BC=9A=E8=A2=AB=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tabledata/TableDataFormulaUtils.java | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/tabledata/TableDataFormulaUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/tabledata/TableDataFormulaUtils.java index ffeabb95a2..955a44005e 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/tabledata/TableDataFormulaUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/tabledata/TableDataFormulaUtils.java @@ -3,9 +3,11 @@ package com.fr.design.actions.replace.action.content.tabledata; import com.fr.data.TableReplacementEntity; import com.fr.invoke.Reflect; import com.fr.log.FineLoggerFactory; +import com.fr.parser.Ambiguity; import com.fr.parser.BinaryExpression; import com.fr.parser.DatasetFunctionCall; import com.fr.parser.FunctionCall; +import com.fr.parser.RelationExpression; import com.fr.parser.StringLiteral; import com.fr.script.Calculator; import com.fr.stable.StringUtils; @@ -107,18 +109,7 @@ public class TableDataFormulaUtils { // 数据集名称 StringBuilder parent = new StringBuilder(datasetFunctionCall.getSourceName()); for (Node subNode : subNodes) { - // 嵌套普通公式 - if (subNode instanceof FunctionCall) { - replaceArgument4FunctionCall((FunctionCall) subNode, entities); - } else if (subNode instanceof StringLiteral) { - // 无嵌套,可以根据传进来的datasetFunctionCall进行替换 - StringLiteral stringLiteral = (StringLiteral) subNode; - replaceDatasetFunctionCall0(stringLiteral, datasetFunctionCall, entities, parent); - } else if (subNode instanceof DatasetFunctionCall) { - // 嵌套datasetFunctionCall,递归回来该方法继续往下 - DatasetFunctionCall datasetFunctionCall1 = (DatasetFunctionCall) subNode; - replaceArgument4DatasetFunctionCall(datasetFunctionCall1, entities); - } + replaceNode4DatasetFunctionCall(subNode, datasetFunctionCall, entities, parent); } for (TableReplacementEntity entity : entities) { if (StringUtils.equals(parent.toString(), entity.getOldName())) { @@ -130,17 +121,38 @@ public class TableDataFormulaUtils { } } - private static void replaceDatasetFunctionCall0(StringLiteral stringLiteral, DatasetFunctionCall datasetFunctionCall, List entities, StringBuilder parent) { + private static void replaceNode4DatasetFunctionCall(Node subNode, DatasetFunctionCall datasetFunctionCall, List entities, StringBuilder parent) { + // 嵌套普通公式 + if (subNode instanceof FunctionCall) { + replaceArgument4FunctionCall((FunctionCall) subNode, entities); + } else if (subNode instanceof Ambiguity) { + // 无嵌套,可以根据传进来的datasetFunctionCall进行替换 + // 这边产品确认只能替换无双引号的字段,因此是ambiguity而不是StringLiteral + Ambiguity ambiguity = (Ambiguity) subNode; + replaceDatasetFunctionCall0(ambiguity, datasetFunctionCall, entities, parent); + } else if (subNode instanceof DatasetFunctionCall) { + // 嵌套datasetFunctionCall,递归回来该方法继续往下 + DatasetFunctionCall datasetFunctionCall1 = (DatasetFunctionCall) subNode; + replaceArgument4DatasetFunctionCall(datasetFunctionCall1, entities); + } else if (subNode instanceof RelationExpression) { + Node left = ((RelationExpression) subNode).getLeft(); + Node right = ((RelationExpression) subNode).getRight(); + replaceNode4DatasetFunctionCall(left, datasetFunctionCall, entities, parent); + replaceNode4DatasetFunctionCall(right, datasetFunctionCall, entities, parent); + } + } + + private static void replaceDatasetFunctionCall0(Ambiguity ambiguity, DatasetFunctionCall datasetFunctionCall, List entities, StringBuilder parent) { try { TableDataFormulaType type = TableDataFormulaType.get(datasetFunctionCall.getFnName()); if (type != null) { - String name = stringLiteral.eval(Calculator.createCalculator()).toString(); + String name = ambiguity.toString(); for (TableReplacementEntity entity : entities) { if (StringUtils.equals(parent.toString(), entity.getOldName())) { // 如果是要替换的数据集 String field = entity.getTargetField(name); // 替换成匹配后的字段 - Reflect.on(stringLiteral).set(STATEMENT, field); + Reflect.on(ambiguity).set(STATEMENT, field); break; } }