From 5a0d12a7d7ce133ea7bb0d777f28c984a3a85e55 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Thu, 21 Dec 2023 15:30:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=80=90=E6=9F=A5=E8=AF=A2=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E3=80=91-=E6=97=B6=E9=97=B4=E8=8C=83=E5=9B=B4?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E5=8F=82=E6=95=B0=EF=BC=8C=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=8F=AF=E7=BB=91=E5=AE=9A=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/chart/manage/ChartDataManage.java | 5 ++++- .../java/io/dataease/commons/utils/SqlparserUtils.java | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java index a99cde6dcf..7faaa1e829 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java +++ b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java @@ -67,6 +67,8 @@ public class ChartDataManage { @Resource private CorePermissionManage corePermissionManage; + public static final String START_END_SEPARATOR = "_START_END_SPLIT"; + private static Logger logger = LoggerFactory.getLogger(ChartDataManage.class); public ChartViewDTO calcData(ChartViewDTO view) throws Exception { @@ -246,7 +248,8 @@ public class ChartDataManage { List sqlVariables = datasetGroupManage.getSqlParams(Arrays.asList(view.getTableId())); if (CollectionUtil.isNotEmpty(sqlVariables)) { for (SqlVariableDetails parameter : Optional.ofNullable(request.getParameters()).orElse(new ArrayList<>())) { - if (sqlVariables.stream().map(SqlVariableDetails::getId).collect(Collectors.toList()).contains(parameter.getId())) { + String parameterId = StringUtils.endsWith(parameter.getId(), START_END_SEPARATOR) ? parameter.getId().split(START_END_SEPARATOR)[0] : parameter.getId(); + if (sqlVariables.stream().map(SqlVariableDetails::getId).collect(Collectors.toList()).contains(parameterId)) { hasParameters = true; } } diff --git a/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java b/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java index c4648d2eb4..eacb52d182 100644 --- a/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java +++ b/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static io.dataease.chart.manage.ChartDataManage.START_END_SEPARATOR; import static org.apache.calcite.sql.SqlKind.*; public class SqlparserUtils { @@ -166,7 +167,11 @@ public class SqlparserUtils { return "'" + String.join("','", sqlVariableDetails.getValue()) + "'"; } else if (sqlVariableDetails.getOperator().equals("between")) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(sqlVariableDetails.getType().size() > 1 ? (String) sqlVariableDetails.getType().get(1).replace("DD", "dd") : "YYYY"); - return simpleDateFormat.format(new Date(Long.parseLong((String) sqlVariableDetails.getValue().get(0)))); + if (StringUtils.endsWith(sqlVariableDetails.getId(), START_END_SEPARATOR)) { + return simpleDateFormat.format(new Date(Long.parseLong((String) sqlVariableDetails.getValue().get(1)))); + } else { + return simpleDateFormat.format(new Date(Long.parseLong((String) sqlVariableDetails.getValue().get(0)))); + } } else { return (String) sqlVariableDetails.getValue().get(0); }