forked from github/dataease
refactor: 优化calcite SQL
This commit is contained in:
parent
c0ee88f41f
commit
00079f6ec5
@ -53,11 +53,6 @@ public class CustomWhere2Str {
|
|||||||
// 此处获取标准格式的日期
|
// 此处获取标准格式的日期
|
||||||
whereName = String.format(SQLConstants.FROM_UNIXTIME, cast, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : SQLConstants.DEFAULT_DATE_FORMAT);
|
whereName = String.format(SQLConstants.FROM_UNIXTIME, cast, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : SQLConstants.DEFAULT_DATE_FORMAT);
|
||||||
}
|
}
|
||||||
if (field.getDeExtractType() == 1) {
|
|
||||||
// 此处获取标准格式的日期
|
|
||||||
String f = DateUtils.get_date_format(originName);
|
|
||||||
whereName = String.format(SQLConstants.DATE_FORMAT, originName, f);
|
|
||||||
}
|
|
||||||
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
||||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||||
whereName = String.format(SQLConstants.CAST, originName, SQLConstants.DEFAULT_FLOAT_FORMAT);
|
whereName = String.format(SQLConstants.CAST, originName, SQLConstants.DEFAULT_FLOAT_FORMAT);
|
||||||
@ -88,16 +83,7 @@ public class CustomWhere2Str {
|
|||||||
|
|
||||||
String whereNameReal;
|
String whereNameReal;
|
||||||
if (field.getDeType() == 1) {
|
if (field.getDeType() == 1) {
|
||||||
// 规定几种日期格式,一一匹配,匹配到就是该格式
|
whereNameReal = String.format(SQLConstants.UNIX_TIMESTAMP, whereName);
|
||||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
|
||||||
String f = DateUtils.get_date_format(filterItemDTO.getValue());
|
|
||||||
String n = String.format(SQLConstants.DE_STR_TO_DATE, whereName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : SQLConstants.DEFAULT_DATE_FORMAT, f);
|
|
||||||
whereNameReal = String.format(SQLConstants.UNIX_TIMESTAMP, n);
|
|
||||||
} else {
|
|
||||||
String f = DateUtils.get_date_format(filterItemDTO.getValue());
|
|
||||||
String n = String.format(SQLConstants.DE_STR_TO_DATE, whereName, f);
|
|
||||||
whereNameReal = String.format(SQLConstants.UNIX_TIMESTAMP, n);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
whereNameReal = whereName;
|
whereNameReal = whereName;
|
||||||
}
|
}
|
||||||
|
@ -97,10 +97,6 @@ public class WhereTree2Str {
|
|||||||
String cast = String.format(SQLConstants.CAST, originName, SQLConstants.DEFAULT_INT_FORMAT);
|
String cast = String.format(SQLConstants.CAST, originName, SQLConstants.DEFAULT_INT_FORMAT);
|
||||||
whereName = String.format(SQLConstants.FROM_UNIXTIME, cast, SQLConstants.DEFAULT_DATE_FORMAT);
|
whereName = String.format(SQLConstants.FROM_UNIXTIME, cast, SQLConstants.DEFAULT_DATE_FORMAT);
|
||||||
}
|
}
|
||||||
if (field.getDeExtractType() == 1) {
|
|
||||||
String f = DateUtils.get_date_format(originName);
|
|
||||||
whereName = String.format(SQLConstants.DATE_FORMAT, originName, f);
|
|
||||||
}
|
|
||||||
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
||||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||||
whereName = String.format(SQLConstants.CAST, originName, SQLConstants.DEFAULT_FLOAT_FORMAT);
|
whereName = String.format(SQLConstants.CAST, originName, SQLConstants.DEFAULT_FLOAT_FORMAT);
|
||||||
@ -128,16 +124,7 @@ public class WhereTree2Str {
|
|||||||
String whereValue = "";
|
String whereValue = "";
|
||||||
|
|
||||||
if (field.getDeType() == 1) {
|
if (field.getDeType() == 1) {
|
||||||
// 规定几种日期格式,一一匹配,匹配到就是该格式
|
whereName = String.format(SQLConstants.UNIX_TIMESTAMP, whereName);
|
||||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
|
||||||
String f = DateUtils.get_date_format(item.getValue());
|
|
||||||
whereName = String.format(SQLConstants.DE_STR_TO_DATE, whereName, f);
|
|
||||||
whereName = String.format(SQLConstants.UNIX_TIMESTAMP, whereName);
|
|
||||||
} else {
|
|
||||||
String f = DateUtils.get_date_format(item.getValue());
|
|
||||||
whereName = String.format(SQLConstants.DE_STR_TO_DATE, whereName, f);
|
|
||||||
whereName = String.format(SQLConstants.UNIX_TIMESTAMP, whereName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
if (StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user