forked from github/dataease
fix: sql根据类型修复
This commit is contained in:
parent
38487c5b58
commit
161dd394b4
16
backend/src/main/java/io/dataease/provider/SQLConstants.java
Normal file
16
backend/src/main/java/io/dataease/provider/SQLConstants.java
Normal 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);// 地理位置
|
||||||
|
}};
|
||||||
|
}
|
@ -5,6 +5,7 @@ import io.dataease.controller.request.chart.ChartExtFilterRequest;
|
|||||||
import io.dataease.dto.chart.ChartCustomFilterDTO;
|
import io.dataease.dto.chart.ChartCustomFilterDTO;
|
||||||
import io.dataease.dto.chart.ChartViewFieldDTO;
|
import io.dataease.dto.chart.ChartViewFieldDTO;
|
||||||
import io.dataease.provider.QueryProvider;
|
import io.dataease.provider.QueryProvider;
|
||||||
|
import io.dataease.provider.SQLConstants;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -138,6 +139,8 @@ public class DorisQueryProvider extends QueryProvider {
|
|||||||
StringBuilder f = new StringBuilder();
|
StringBuilder f = new StringBuilder();
|
||||||
if (StringUtils.equalsIgnoreCase(y.getDataeaseName(), "*")) {
|
if (StringUtils.equalsIgnoreCase(y.getDataeaseName(), "*")) {
|
||||||
f.append(y.getSummary()).append("(").append(y.getDataeaseName()).append(")");
|
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 {
|
} else {
|
||||||
f.append("ROUND(")
|
f.append("ROUND(")
|
||||||
.append(y.getSummary()).append("(")
|
.append(y.getSummary()).append("(")
|
||||||
@ -277,6 +280,8 @@ public class DorisQueryProvider extends QueryProvider {
|
|||||||
StringBuilder f = new StringBuilder();
|
StringBuilder f = new StringBuilder();
|
||||||
if (StringUtils.equalsIgnoreCase(y.getDataeaseName(), "*")) {
|
if (StringUtils.equalsIgnoreCase(y.getDataeaseName(), "*")) {
|
||||||
f.append(y.getSummary()).append("(").append(y.getDataeaseName()).append(")");
|
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 {
|
} else {
|
||||||
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
|
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
|
||||||
f.append("CAST(")
|
f.append("CAST(")
|
||||||
|
@ -5,6 +5,7 @@ import io.dataease.controller.request.chart.ChartExtFilterRequest;
|
|||||||
import io.dataease.dto.chart.ChartCustomFilterDTO;
|
import io.dataease.dto.chart.ChartCustomFilterDTO;
|
||||||
import io.dataease.dto.chart.ChartViewFieldDTO;
|
import io.dataease.dto.chart.ChartViewFieldDTO;
|
||||||
import io.dataease.provider.QueryProvider;
|
import io.dataease.provider.QueryProvider;
|
||||||
|
import io.dataease.provider.SQLConstants;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -137,6 +138,8 @@ public class MysqlQueryProvider extends QueryProvider {
|
|||||||
StringBuilder f = new StringBuilder();
|
StringBuilder f = new StringBuilder();
|
||||||
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
|
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
|
||||||
f.append(y.getSummary()).append("(").append(y.getOriginName()).append(")");
|
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 {
|
} else {
|
||||||
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
|
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
|
||||||
f.append("CAST(")
|
f.append("CAST(")
|
||||||
@ -283,6 +286,8 @@ public class MysqlQueryProvider extends QueryProvider {
|
|||||||
StringBuilder f = new StringBuilder();
|
StringBuilder f = new StringBuilder();
|
||||||
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
|
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
|
||||||
f.append(y.getSummary()).append("(").append(y.getOriginName()).append(")");
|
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 {
|
} else {
|
||||||
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
|
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
|
||||||
f.append("CAST(")
|
f.append("CAST(")
|
||||||
|
@ -5,6 +5,7 @@ import io.dataease.controller.request.chart.ChartExtFilterRequest;
|
|||||||
import io.dataease.dto.chart.ChartCustomFilterDTO;
|
import io.dataease.dto.chart.ChartCustomFilterDTO;
|
||||||
import io.dataease.dto.chart.ChartViewFieldDTO;
|
import io.dataease.dto.chart.ChartViewFieldDTO;
|
||||||
import io.dataease.provider.QueryProvider;
|
import io.dataease.provider.QueryProvider;
|
||||||
|
import io.dataease.provider.SQLConstants;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -162,6 +163,8 @@ public class OracleQueryProvider extends QueryProvider {
|
|||||||
StringBuilder f = new StringBuilder();
|
StringBuilder f = new StringBuilder();
|
||||||
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
|
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
|
||||||
f.append(y.getSummary()).append("(").append(y.getOriginName()).append(")");
|
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 {
|
} else {
|
||||||
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
|
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
|
||||||
f.append("CAST(")
|
f.append("CAST(")
|
||||||
@ -317,6 +320,8 @@ public class OracleQueryProvider extends QueryProvider {
|
|||||||
StringBuilder f = new StringBuilder();
|
StringBuilder f = new StringBuilder();
|
||||||
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
|
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
|
||||||
f.append(y.getSummary()).append("(").append(y.getOriginName()).append(")");
|
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 {
|
} else {
|
||||||
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
|
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
|
||||||
f.append("CAST(")
|
f.append("CAST(")
|
||||||
|
Loading…
Reference in New Issue
Block a user