From c8c8153808d3d606db3040c1dfbed081c7bf94ea Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 21 Mar 2022 15:32:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=86=E5=9B=BE=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E6=9D=A1=E4=BB=B6=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../provider/engine/mysql/MysqlConstants.java | 51 ------------------- .../engine/mysql/MysqlQueryProvider.java | 1 + .../service/chart/ChartViewService.java | 7 ++- .../chart/ViewPluginBaseServiceImpl.java | 5 +- 4 files changed, 9 insertions(+), 55 deletions(-) delete mode 100644 backend/src/main/java/io/dataease/provider/engine/mysql/MysqlConstants.java diff --git a/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlConstants.java b/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlConstants.java deleted file mode 100644 index 93ddac560c..0000000000 --- a/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlConstants.java +++ /dev/null @@ -1,51 +0,0 @@ -package io.dataease.provider.engine.mysql; - - -import io.dataease.plugins.common.constants.SQLConstants; - -import static io.dataease.plugins.common.constants.DatasourceTypes.engine_mysql; -import static io.dataease.plugins.common.constants.DatasourceTypes.engine_mysql; - -/** - * @Author gin - * @Date 2021/7/8 7:22 下午 - */ -public class MysqlConstants extends SQLConstants { - public static final String KEYWORD_TABLE = engine_mysql.getKeywordPrefix() + "%s" + engine_mysql.getKeywordSuffix(); - - public static final String KEYWORD_FIX = "%s." + engine_mysql.getKeywordPrefix() + "%s" + engine_mysql.getKeywordSuffix(); - - public static final String UNIX_TIMESTAMP = "UNIX_TIMESTAMP(%s)"; - - public static final String DATE_FORMAT = "DATE_FORMAT(%s,'%s')"; - - public static final String FROM_UNIXTIME = "FROM_UNIXTIME(%s,'%s')"; - - public static final String STR_TO_DATE = "STR_TO_DATE(%s,'%s')"; - - public static final String CAST = "CAST(%s AS %s)"; - - public static final String DEFAULT_DATE_FORMAT = "%Y-%m-%d %H:%i:%S"; - - public static final String DEFAULT_INT_FORMAT = "DECIMAL(20,0)"; - - public static final String DEFAULT_FLOAT_FORMAT = "DECIMAL(20,2)"; - - public static final String WHERE_VALUE_NULL = "(NULL,'')"; - - public static final String WHERE_VALUE_VALUE = "'%s'"; - - public static final String WHERE_NUMBER_VALUE = "%s"; - - public static final String AGG_COUNT = "COUNT(*)"; - - public static final String AGG_FIELD = "%s(%s)"; - - public static final String WHERE_BETWEEN = "'%s' AND '%s'"; - - public static final String BRACKETS = "(%s)"; - - public static final String ROUND = "ROUND(%s,%s)"; - - public static final String VARCHAR = "VARCHAR"; -} diff --git a/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlQueryProvider.java b/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlQueryProvider.java index 3d4d3b85f0..eeeef6fac3 100644 --- a/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlQueryProvider.java @@ -10,6 +10,7 @@ import io.dataease.dto.chart.ChartCustomFilterItemDTO; import io.dataease.dto.chart.ChartFieldCustomFilterDTO; import io.dataease.dto.chart.ChartViewFieldDTO; import io.dataease.dto.sqlObj.SQLObj; +import io.dataease.plugins.common.constants.engine.MysqlConstants; import io.dataease.provider.QueryProvider; import io.dataease.plugins.common.constants.SQLConstants; import org.apache.commons.collections4.CollectionUtils; diff --git a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index 6e85c9d04c..6aea786d27 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -775,8 +775,11 @@ public class ChartViewService { pluginViewSet.setDsType(ds.getType()); PluginViewLimit pluginViewLimit = BeanUtils.copyBean(new PluginViewLimit(), view); - List fieldFilters = customFilters.stream().map(filter -> BeanUtils.copyBean(new PluginChartFieldCustomFilter(), filter)).collect(Collectors.toList()); - List panelFilters = extFilters.stream().map(filter -> BeanUtils.copyBean(new PluginChartExtFilter(), filter)).collect(Collectors.toList()); + + + + List fieldFilters = customFilters.stream().map(filter -> gson.fromJson(gson.toJson(filter), PluginChartFieldCustomFilter.class)).collect(Collectors.toList()); + List panelFilters = extFilters.stream().map(filter -> gson.fromJson(gson.toJson(filter), PluginChartExtFilter.class)).collect(Collectors.toList()); List pluginViewFields = fieldMap.entrySet().stream().flatMap(entry -> entry.getValue().stream().map(field -> { PluginViewField pluginViewField = BeanUtils.copyBean(new PluginViewField(), field); diff --git a/backend/src/main/java/io/dataease/service/chart/ViewPluginBaseServiceImpl.java b/backend/src/main/java/io/dataease/service/chart/ViewPluginBaseServiceImpl.java index 35d4e5a12f..f86de14af9 100644 --- a/backend/src/main/java/io/dataease/service/chart/ViewPluginBaseServiceImpl.java +++ b/backend/src/main/java/io/dataease/service/chart/ViewPluginBaseServiceImpl.java @@ -32,6 +32,7 @@ import static io.dataease.plugins.common.constants.SQLConstants.TABLE_ALIAS_PREF @Service public class ViewPluginBaseServiceImpl implements ViewPluginBaseService { + private static Gson gson = new Gson(); @Resource private DataSetTableUnionService dataSetTableUnionService; @@ -67,7 +68,7 @@ public class ViewPluginBaseServiceImpl implements ViewPluginBaseService { QueryProvider queryProvider = ProviderFactory.getQueryProvider(dsType); String methodName = "transCustomFilterList"; SQLObj sqlObj = BeanUtils.copyBean(SQLObj.builder().build(), pluginViewSQL); - List filters = list.stream().map(item -> BeanUtils.copyBean(new ChartFieldCustomFilterDTO(), item)).collect(Collectors.toList()); + List filters = list.stream().map(item -> gson.fromJson(gson.toJson(item), ChartFieldCustomFilterDTO.class)).collect(Collectors.toList()); Object o ; if ((o = execProviderMethod(queryProvider, methodName, sqlObj, filters)) != null) { return (String)o; @@ -80,7 +81,7 @@ public class ViewPluginBaseServiceImpl implements ViewPluginBaseService { QueryProvider queryProvider = ProviderFactory.getQueryProvider(dsType); String methodName = "transExtFilterList"; SQLObj sqlObj = BeanUtils.copyBean(SQLObj.builder().build(), pluginViewSQL); - List filters = list.stream().map(item -> BeanUtils.copyBean(new ChartExtFilterRequest(), item)).collect(Collectors.toList()); + List filters = list.stream().map(item -> gson.fromJson(gson.toJson(item), ChartExtFilterRequest.class)).collect(Collectors.toList()); Object o; if ((o = execProviderMethod(queryProvider, methodName, sqlObj, filters)) != null) { return (String)o;