forked from github/dataease
refactor: 优化calcite SQL
This commit is contained in:
parent
ab135f0497
commit
59b16702d1
@ -47,11 +47,18 @@ public class CustomWhere2Str {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
// 此处获取标准格式的日期
|
||||
whereName = String.format(SQLConstants.DE_STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : SQLConstants.DEFAULT_DATE_FORMAT);
|
||||
whereName = String.format(SQLConstants.DATE_FORMAT, whereName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : SQLConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(SQLConstants.CAST, originName, SQLConstants.DEFAULT_INT_FORMAT);
|
||||
// 此处获取标准格式的日期
|
||||
whereName = String.format(SQLConstants.FROM_UNIXTIME, cast, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : SQLConstants.DEFAULT_DATE_FORMAT);
|
||||
whereName = String.format(SQLConstants.DATE_FORMAT, whereName, 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) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
@ -83,7 +90,10 @@ public class CustomWhere2Str {
|
||||
|
||||
String whereNameReal;
|
||||
if (field.getDeType() == 1) {
|
||||
whereNameReal = String.format(SQLConstants.UNIX_TIMESTAMP, whereName);
|
||||
// 规定几种日期格式,一一匹配,匹配到就是该格式
|
||||
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 {
|
||||
whereNameReal = whereName;
|
||||
}
|
||||
|
@ -92,10 +92,16 @@ public class WhereTree2Str {
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(SQLConstants.DE_STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : SQLConstants.DEFAULT_DATE_FORMAT);
|
||||
whereName = String.format(SQLConstants.DATE_FORMAT, whereName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : SQLConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
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.DATE_FORMAT, whereName, 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) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
@ -124,7 +130,16 @@ public class WhereTree2Str {
|
||||
String whereValue = "";
|
||||
|
||||
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")) {
|
||||
|
Loading…
Reference in New Issue
Block a user