fix: 视图插件过滤条件无效

This commit is contained in:
fit2cloud-chenyw 2022-03-21 15:32:54 +08:00
parent c42931e5cf
commit c8c8153808
4 changed files with 9 additions and 55 deletions

View File

@ -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";
}

View File

@ -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;

View File

@ -775,8 +775,11 @@ public class ChartViewService {
pluginViewSet.setDsType(ds.getType());
PluginViewLimit pluginViewLimit = BeanUtils.copyBean(new PluginViewLimit(), view);
List<PluginChartFieldCustomFilter> fieldFilters = customFilters.stream().map(filter -> BeanUtils.copyBean(new PluginChartFieldCustomFilter(), filter)).collect(Collectors.toList());
List<PluginChartExtFilter> panelFilters = extFilters.stream().map(filter -> BeanUtils.copyBean(new PluginChartExtFilter(), filter)).collect(Collectors.toList());
List<PluginChartFieldCustomFilter> fieldFilters = customFilters.stream().map(filter -> gson.fromJson(gson.toJson(filter), PluginChartFieldCustomFilter.class)).collect(Collectors.toList());
List<PluginChartExtFilter> panelFilters = extFilters.stream().map(filter -> gson.fromJson(gson.toJson(filter), PluginChartExtFilter.class)).collect(Collectors.toList());
List<PluginViewField> pluginViewFields = fieldMap.entrySet().stream().flatMap(entry -> entry.getValue().stream().map(field -> {
PluginViewField pluginViewField = BeanUtils.copyBean(new PluginViewField(), field);

View File

@ -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<ChartFieldCustomFilterDTO> filters = list.stream().map(item -> BeanUtils.copyBean(new ChartFieldCustomFilterDTO(), item)).collect(Collectors.toList());
List<ChartFieldCustomFilterDTO> 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<ChartExtFilterRequest> filters = list.stream().map(item -> BeanUtils.copyBean(new ChartExtFilterRequest(), item)).collect(Collectors.toList());
List<ChartExtFilterRequest> 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;