commit
2e54af1df0
@ -1,6 +1,7 @@
|
||||
package io.dataease.provider.engine.mysql;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
@ -30,6 +31,8 @@ import io.dataease.plugins.datasource.query.Utils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.stringtemplate.v4.ST;
|
||||
import org.stringtemplate.v4.STGroup;
|
||||
@ -54,6 +57,10 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
@Resource
|
||||
private DatasetTableFieldMapper datasetTableFieldMapper;
|
||||
|
||||
private static Gson gson = new Gson();
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MysqlQueryProvider.class);
|
||||
|
||||
@Override
|
||||
public Integer transFieldType(String field) {
|
||||
switch (field) {
|
||||
@ -1042,6 +1049,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
|
||||
@Override
|
||||
public String transTreeItem(SQLObj tableObj, FilterTreeItem item) {
|
||||
logger.info("trans item:" + gson.toJson(item));
|
||||
String res = null;
|
||||
DatasetTableField field = item.getField();
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
@ -1112,6 +1120,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
.build();
|
||||
res = build.getWhereField() + " " + build.getWhereTermAndValue();
|
||||
}
|
||||
logger.info("trans item result:" + res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@ -1080,7 +1080,6 @@ public class ChartViewService {
|
||||
fieldMap.put("xAxis", xAxis);
|
||||
fieldMap.put("yAxis", yAxis);
|
||||
PluginViewParam pluginViewParam = buildPluginParam(fieldMap, fieldCustomFilter, extFilterList, ds, table, view, rowPermissionsTree, chartExtRequest);
|
||||
logger.info("PluginViewParam:" + gson.toJson(pluginViewParam));
|
||||
String sql = pluginViewSql(pluginViewParam, view);
|
||||
if (StringUtils.isBlank(sql)) {
|
||||
return emptyChartViewDTO(view);
|
||||
@ -1612,7 +1611,6 @@ public class ChartViewService {
|
||||
|
||||
|
||||
PluginFilterTreeObj fieldFilters = gson.fromJson(gson.toJson(customFilters), PluginFilterTreeObj.class);
|
||||
logger.info("PluginFilterTreeObj:" + gson.toJson(fieldFilters));
|
||||
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 -> {
|
||||
|
||||
@ -89,6 +89,9 @@ public class ViewPluginBaseServiceImpl implements ViewPluginBaseService {
|
||||
String methodName = "transChartFilterTrees";
|
||||
SQLObj sqlObj = BeanUtils.copyBean(SQLObj.builder().build(), pluginViewSQL);
|
||||
FilterTreeObj filters = gson.fromJson(gson.toJson(obj), FilterTreeObj.class);
|
||||
logger.info("filters:" + gson.toJson(filters));
|
||||
Object o1 = execProviderMethod(queryProvider, methodName, sqlObj, filters);
|
||||
logger.info("o1:" + (String) o1);
|
||||
Object o;
|
||||
if ((o = execProviderMethod(queryProvider, methodName, sqlObj, filters)) != null) {
|
||||
logger.info("customWhereString:" + o);
|
||||
|
||||
@ -21,6 +21,8 @@ import io.dataease.plugins.datasource.entity.PageInfo;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@ -33,6 +35,9 @@ import java.util.stream.Collectors;
|
||||
* @Date 2021/5/17 2:42 下午
|
||||
*/
|
||||
public abstract class QueryProvider {
|
||||
private static final Logger logger = LoggerFactory.getLogger(QueryProvider.class);
|
||||
|
||||
private static Gson gson = new Gson();
|
||||
|
||||
public abstract Integer transFieldType(String field);
|
||||
|
||||
@ -171,6 +176,7 @@ public abstract class QueryProvider {
|
||||
}
|
||||
|
||||
public String transChartFilterTrees(SQLObj tableObj, FilterTreeObj tree) {
|
||||
logger.info("trans begin:" + tree);
|
||||
List<String> res = new ArrayList<>();
|
||||
// permission trees
|
||||
// 解析每个tree,然后多个tree之间用and拼接
|
||||
@ -182,6 +188,7 @@ public abstract class QueryProvider {
|
||||
if (StringUtils.isNotEmpty(treeExp)) {
|
||||
res.add(treeExp);
|
||||
}
|
||||
logger.info("trans end:" + gson.toJson(res));
|
||||
return CollectionUtils.isNotEmpty(res) ? "(" + String.join(" AND ", res) + ")" : null;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user