From 8fea9cfe3b7215b63207a99dcc04fbb6ba2bd325 Mon Sep 17 00:00:00 2001 From: junjun Date: Fri, 14 Jun 2024 10:16:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=95=B0=E6=8D=AE=E9=9B=86):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=A1=E7=AE=97=E5=AD=97=E6=AE=B5=E4=B8=AD?= =?UTF-8?q?=E8=81=9A=E5=90=88=E5=87=BD=E6=95=B0=E5=8C=B9=E9=85=8D=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/engine/utils/Utils.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/engine/utils/Utils.java b/core/core-backend/src/main/java/io/dataease/engine/utils/Utils.java index 42d9975fd5..ad6ea420d9 100644 --- a/core/core-backend/src/main/java/io/dataease/engine/utils/Utils.java +++ b/core/core-backend/src/main/java/io/dataease/engine/utils/Utils.java @@ -1,13 +1,13 @@ package io.dataease.engine.utils; -import io.dataease.extensions.view.model.SQLObj; import io.dataease.api.ds.vo.DatasourceConfiguration; import io.dataease.dataset.dto.DatasourceSchemaDTO; -import io.dataease.extensions.view.dto.DatasetTableFieldDTO; import io.dataease.engine.constant.ExtFieldConstant; import io.dataease.engine.constant.SQLConstants; import io.dataease.engine.constant.SqlPlaceholderConstants; import io.dataease.exception.DEException; +import io.dataease.extensions.view.dto.DatasetTableFieldDTO; +import io.dataease.extensions.view.model.SQLObj; import io.dataease.i18n.Translator; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -40,8 +40,7 @@ public class Utils { return null; } - public static String calcSimpleFieldRegex(String originField, SQLObj tableObj, List originFields, - boolean isCross, Map dsTypeMap) { + public static String calcSimpleFieldRegex(String originField, SQLObj tableObj, List originFields, boolean isCross, Map dsTypeMap) { try { int i = 0; DatasourceConfiguration.DatasourceType datasourceType = null; @@ -80,12 +79,9 @@ public class Utils { // 计算字段允许二次引用,这里递归查询完整引用链 if (Objects.equals(ele.getExtField(), ExtFieldConstant.EXT_NORMAL)) { if (isCross) { - originField = originField.replaceAll("\\[" + ele.getId() + "]", - String.format(SQLConstants.FIELD_NAME, tableObj.getTableAlias(), ele.getDataeaseName())); + originField = originField.replaceAll("\\[" + ele.getId() + "]", String.format(SQLConstants.FIELD_NAME, tableObj.getTableAlias(), ele.getDataeaseName())); } else { - originField = originField.replaceAll("\\[" + ele.getId() + "]", - datasourceType.getPrefix() + tableObj.getTableAlias() + datasourceType.getSuffix() + - "." + datasourceType.getPrefix() + ele.getDataeaseName() + datasourceType.getSuffix()); + originField = originField.replaceAll("\\[" + ele.getId() + "]", datasourceType.getPrefix() + tableObj.getTableAlias() + datasourceType.getSuffix() + "." + datasourceType.getPrefix() + ele.getDataeaseName() + datasourceType.getSuffix()); } } else { originField = originField.replaceAll("\\[" + ele.getId() + "]", "(" + ele.getOriginName() + ")"); @@ -235,7 +231,7 @@ public class Utils { public static boolean matchFunction(String func, String originField) { String pattern = func + "\\s*\\((.*?)\\)"; Pattern r = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE); - Matcher m = r.matcher(originField); + Matcher m = r.matcher(originField.replaceAll("[\\t\\n\\r]", "")); while (m.find()) { return true; }