diff --git a/core/core-backend/src/main/java/io/dataease/engine/trans/CustomWhere2Str.java b/core/core-backend/src/main/java/io/dataease/engine/trans/CustomWhere2Str.java index 33be7705fa..7b4bbb1929 100644 --- a/core/core-backend/src/main/java/io/dataease/engine/trans/CustomWhere2Str.java +++ b/core/core-backend/src/main/java/io/dataease/engine/trans/CustomWhere2Str.java @@ -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; } diff --git a/core/core-backend/src/main/java/io/dataease/engine/trans/WhereTree2Str.java b/core/core-backend/src/main/java/io/dataease/engine/trans/WhereTree2Str.java index b9b1f296e3..5ae06c268c 100644 --- a/core/core-backend/src/main/java/io/dataease/engine/trans/WhereTree2Str.java +++ b/core/core-backend/src/main/java/io/dataease/engine/trans/WhereTree2Str.java @@ -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")) {