From d5ca2168c46a12487103a823b3bbdef073027e62 Mon Sep 17 00:00:00 2001 From: junjun Date: Thu, 24 Mar 2022 17:01:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=94=AF=E6=8C=81ES=E5=B8=83?= =?UTF-8?q?=E5=B0=94=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../provider/query/es/EsQueryProvider.java | 48 +++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/io/dataease/provider/query/es/EsQueryProvider.java b/backend/src/main/java/io/dataease/provider/query/es/EsQueryProvider.java index d5d5138e77..5187b8429d 100644 --- a/backend/src/main/java/io/dataease/provider/query/es/EsQueryProvider.java +++ b/backend/src/main/java/io/dataease/provider/query/es/EsQueryProvider.java @@ -224,7 +224,11 @@ public class EsQueryProvider extends QueryProvider { } else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_TIME) { originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()); } else { - originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()); + if (x.getDeType() == 2 || x.getDeType() == 3) { + originField = String.format(EsSqlLConstants.CAST, String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()), "bigint"); + } else { + originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()); + } } String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i); // 处理横轴字段 @@ -253,7 +257,11 @@ public class EsQueryProvider extends QueryProvider { } else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_TIME) { originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); } else { - originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); + if (y.getDeType() == 2 || y.getDeType() == 3) { + originField = String.format(EsSqlLConstants.CAST, String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()), "bigint"); + } else { + originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); + } } String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i); // 处理纵轴字段 @@ -333,7 +341,11 @@ public class EsQueryProvider extends QueryProvider { } else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) { originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()); } else { - originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()); + if (x.getDeType() == 2 || x.getDeType() == 3) { + originField = String.format(EsSqlLConstants.CAST, String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()), "bigint"); + } else { + originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()); + } } String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i); // 处理横轴字段 @@ -409,7 +421,11 @@ public class EsQueryProvider extends QueryProvider { } else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_TIME) { originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()); } else { - originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()); + if (x.getDeType() == 2 || x.getDeType() == 3) { + originField = String.format(EsSqlLConstants.CAST, String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()), "bigint"); + } else { + originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()); + } } String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i); // 处理横轴字段 @@ -438,7 +454,11 @@ public class EsQueryProvider extends QueryProvider { } else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_TIME) { originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); } else { - originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); + if (y.getDeType() == 2 || y.getDeType() == 3) { + originField = String.format(EsSqlLConstants.CAST, String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()), "bigint"); + } else { + originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); + } } String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i); // 处理纵轴字段 @@ -517,7 +537,11 @@ public class EsQueryProvider extends QueryProvider { } else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) { originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()); } else { - originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()); + if (x.getDeType() == 2 || x.getDeType() == 3) { + originField = String.format(EsSqlLConstants.CAST, String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()), "bigint"); + } else { + originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()); + } } String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i); // 处理横轴字段 @@ -549,7 +573,11 @@ public class EsQueryProvider extends QueryProvider { } else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 1) { originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); } else { - originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); + if (y.getDeType() == 2 || y.getDeType() == 3) { + originField = String.format(EsSqlLConstants.CAST, String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()), "bigint"); + } else { + originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); + } } String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i); // 处理纵轴字段 @@ -635,7 +663,11 @@ public class EsQueryProvider extends QueryProvider { } else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 1) { originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); } else { - originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); + if (y.getDeType() == 2 || y.getDeType() == 3) { + originField = String.format(EsSqlLConstants.CAST, String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()), "bigint"); + } else { + originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); + } } String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i); // 处理纵轴字段