fix: sql根据类型修复

This commit is contained in:
junjie 2021-07-08 15:47:06 +08:00
parent 38487c5b58
commit 161dd394b4
4 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package io.dataease.provider;
import java.util.ArrayList;
import java.util.List;
/**
* @Author gin
* @Date 2021/7/8 3:12 下午
*/
public class SQLConstants {
public static final List<Integer> DIMENSION_TYPE = new ArrayList<Integer>() {{
add(0);// 文本
add(1);// 时间
add(5);// 地理位置
}};
}

View File

@ -5,6 +5,7 @@ import io.dataease.controller.request.chart.ChartExtFilterRequest;
import io.dataease.dto.chart.ChartCustomFilterDTO;
import io.dataease.dto.chart.ChartViewFieldDTO;
import io.dataease.provider.QueryProvider;
import io.dataease.provider.SQLConstants;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
@ -138,6 +139,8 @@ public class DorisQueryProvider extends QueryProvider {
StringBuilder f = new StringBuilder();
if (StringUtils.equalsIgnoreCase(y.getDataeaseName(), "*")) {
f.append(y.getSummary()).append("(").append(y.getDataeaseName()).append(")");
} else if (SQLConstants.DIMENSION_TYPE.contains(y.getDeType())) {
f.append(y.getSummary()).append("(").append(y.getDataeaseName()).append(")");
} else {
f.append("ROUND(")
.append(y.getSummary()).append("(")
@ -277,6 +280,8 @@ public class DorisQueryProvider extends QueryProvider {
StringBuilder f = new StringBuilder();
if (StringUtils.equalsIgnoreCase(y.getDataeaseName(), "*")) {
f.append(y.getSummary()).append("(").append(y.getDataeaseName()).append(")");
} else if (SQLConstants.DIMENSION_TYPE.contains(y.getDeType())) {
f.append(y.getSummary()).append("(").append(y.getOriginName()).append(")");
} else {
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
f.append("CAST(")

View File

@ -5,6 +5,7 @@ import io.dataease.controller.request.chart.ChartExtFilterRequest;
import io.dataease.dto.chart.ChartCustomFilterDTO;
import io.dataease.dto.chart.ChartViewFieldDTO;
import io.dataease.provider.QueryProvider;
import io.dataease.provider.SQLConstants;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
@ -137,6 +138,8 @@ public class MysqlQueryProvider extends QueryProvider {
StringBuilder f = new StringBuilder();
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
f.append(y.getSummary()).append("(").append(y.getOriginName()).append(")");
} else if (SQLConstants.DIMENSION_TYPE.contains(y.getDeType())) {
f.append(y.getSummary()).append("(`").append(y.getOriginName()).append("`)");
} else {
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
f.append("CAST(")
@ -283,6 +286,8 @@ public class MysqlQueryProvider extends QueryProvider {
StringBuilder f = new StringBuilder();
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
f.append(y.getSummary()).append("(").append(y.getOriginName()).append(")");
} else if (SQLConstants.DIMENSION_TYPE.contains(y.getDeType())) {
f.append(y.getSummary()).append("(`").append(y.getOriginName()).append("`)");
} else {
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
f.append("CAST(")

View File

@ -5,6 +5,7 @@ import io.dataease.controller.request.chart.ChartExtFilterRequest;
import io.dataease.dto.chart.ChartCustomFilterDTO;
import io.dataease.dto.chart.ChartViewFieldDTO;
import io.dataease.provider.QueryProvider;
import io.dataease.provider.SQLConstants;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
@ -162,6 +163,8 @@ public class OracleQueryProvider extends QueryProvider {
StringBuilder f = new StringBuilder();
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
f.append(y.getSummary()).append("(").append(y.getOriginName()).append(")");
} else if (SQLConstants.DIMENSION_TYPE.contains(y.getDeType())) {
f.append(y.getSummary()).append("(").append(y.getOriginName()).append(")");
} else {
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
f.append("CAST(")
@ -317,6 +320,8 @@ public class OracleQueryProvider extends QueryProvider {
StringBuilder f = new StringBuilder();
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
f.append(y.getSummary()).append("(").append(y.getOriginName()).append(")");
} else if (SQLConstants.DIMENSION_TYPE.contains(y.getDeType())) {
f.append(y.getSummary()).append("(").append(y.getOriginName()).append(")");
} else {
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
f.append("CAST(")