Browse Source

Pull request #5664: REPORT-58124 公式编辑器优化:不支持实时计算的功能提示处理

Merge in DESIGN/design from ~HOKY.HE/design-hoky:release/11.0 to release/11.0

* commit '4b8eda69e0870e24e5678de3682751f1c3a1015c':
  REPORT-58579【回归测试】rank的带参模拟计算值不正确 1.数字类型转换
  REPORT-58124 公式编辑器优化:不支持实时计算的功能提示处理 1.添加ds1.select类型的识别
fix-lag
Hoky.He 3 years ago
parent
commit
30bbf7db50
  1. 27
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  2. 5
      designer-base/src/main/java/com/fr/design/formula/UnsupportedFormulaScanner.java

27
designer-base/src/main/java/com/fr/design/formula/FormulaPane.java

@ -5,6 +5,7 @@ import com.fr.base.BaseUtils;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.ParameterMapNameSpace; import com.fr.base.ParameterMapNameSpace;
import com.fr.base.TableDataNameSpace; import com.fr.base.TableDataNameSpace;
import com.fr.base.Utils;
import com.fr.base.io.IOFile; import com.fr.base.io.IOFile;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
@ -39,6 +40,7 @@ import com.fr.parser.BlockIntervalLiteral;
import com.fr.parser.ColumnRowRangeInPage; import com.fr.parser.ColumnRowRangeInPage;
import com.fr.parser.FRLexer; import com.fr.parser.FRLexer;
import com.fr.parser.FRParser; import com.fr.parser.FRParser;
import com.fr.parser.NumberLiteral;
import com.fr.parser.SheetIntervalLiteral; import com.fr.parser.SheetIntervalLiteral;
import com.fr.report.core.namespace.SimpleCellValueNameSpace; import com.fr.report.core.namespace.SimpleCellValueNameSpace;
import com.fr.script.Calculator; import com.fr.script.Calculator;
@ -98,6 +100,7 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.io.StringReader; import java.io.StringReader;
import java.text.NumberFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
@ -817,8 +820,24 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
if (entry.getValue().toString().startsWith("[") && entry.getValue().toString().endsWith("]")) { if (entry.getValue().toString().startsWith("[") && entry.getValue().toString().endsWith("]")) {
Expression parse = calculator.parse(entry.getValue()); Expression parse = calculator.parse(entry.getValue());
ArrayExpression arrayExpression = (ArrayExpression) parse.getConditionalExpression(); ArrayExpression arrayExpression = (ArrayExpression) parse.getConditionalExpression();
FArray<Node> fArray = new FArray<>(arrayExpression.getArrays()); Node[] arrays = arrayExpression.getArrays();
List<Object> arrayList = new ArrayList<>();
for (Node array : arrays) {
if (array instanceof NumberLiteral) {
arrayList.add(NumberFormat.getInstance().parse(array.toString()));
} else {
arrayList.add(array);
}
}
FArray<Object> fArray = new FArray<>(arrayList);
parameterMap.put(entry.getKey(), fArray); parameterMap.put(entry.getKey(), fArray);
} else if (Utils.isNumeric(entry.getValue().toString())) {
try {
Number number = NumberFormat.getInstance().parse(entry.getValue().toString());
parameterMap.put(entry.getKey(), number);
} catch (Exception e) {
FineLoggerFactory.getLogger().warn("", e);
}
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -838,7 +857,11 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
public void hunter4Tiny(Tiny tiny) { public void hunter4Tiny(Tiny tiny) {
String statement = tiny.getStatement(); String statement = tiny.getStatement();
if (StringUtils.isNotBlank(statement) && statement.startsWith(ScriptConstants.DETAIL_TAG)) { if (StringUtils.isNotBlank(statement) && statement.startsWith(ScriptConstants.DETAIL_TAG)) {
parameterList.add(new Parameter(statement.substring(1))); if (statement.startsWith(ScriptConstants.SUMMARY_TAG)) {
parameterList.add(new Parameter(statement));
} else {
parameterList.add(new Parameter(statement.substring(1)));
}
} else if (tiny.getClass() == ColumnRowRange.class || } else if (tiny.getClass() == ColumnRowRange.class ||
tiny.getClass() == SheetIntervalLiteral.class || tiny.getClass() == BlockIntervalLiteral.class) { tiny.getClass() == SheetIntervalLiteral.class || tiny.getClass() == BlockIntervalLiteral.class) {
parameterList.add(new Parameter(tiny.toString())); parameterList.add(new Parameter(tiny.toString()));

5
designer-base/src/main/java/com/fr/design/formula/UnsupportedFormulaScanner.java

@ -1,6 +1,7 @@
package com.fr.design.formula; package com.fr.design.formula;
import com.fr.parser.BinaryExpression; import com.fr.parser.BinaryExpression;
import com.fr.parser.DatasetFunctionCall;
import com.fr.parser.FunctionCall; import com.fr.parser.FunctionCall;
import com.fr.stable.script.Node; import com.fr.stable.script.Node;
@ -35,6 +36,10 @@ public class UnsupportedFormulaScanner {
return false; return false;
} }
} }
} else if (node instanceof DatasetFunctionCall) {
DatasetFunctionCall datasetFunctionCall = (DatasetFunctionCall) node;
unSupportFormula = datasetFunctionCall.getSourceName() + "." + datasetFunctionCall.getFnName() + "()";
return false;
} }
return true; return true;
} }

Loading…
Cancel
Save