fix:【仪表板】sqlserver数据集时间过滤date类型过滤不出来结果

This commit is contained in:
fit2cloud-chenyw 2023-03-10 12:05:13 +08:00 committed by taojinlong
parent 5f60347adc
commit 782487db50
3 changed files with 61 additions and 17 deletions

View File

@ -917,7 +917,7 @@ public class OracleQueryProvider extends QueryProvider {
continue; continue;
} }
String originField = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()); String originField = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
if(xAxis.get(i).getType().equals("DATE")){ if (xAxis.get(i).getType().equals("DATE")) {
originField = String.format(OracleConstants.TO_CHAR, originField, OracleConstants.DEFAULT_DATE_FORMAT); originField = String.format(OracleConstants.TO_CHAR, originField, OracleConstants.DEFAULT_DATE_FORMAT);
} }
String fieldAlias = String.format(OracleConstants.KEYWORD_TABLE, x.getOriginName()); String fieldAlias = String.format(OracleConstants.KEYWORD_TABLE, x.getOriginName());
@ -1205,18 +1205,31 @@ public class OracleQueryProvider extends QueryProvider {
} else { } else {
originName = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName()); originName = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
} }
String format = transDateFormat(request.getDateStyle(), request.getDatePattern()); String format = transDateFormat(request.getDateStyle(), request.getDatePattern());
if (field.getDeType() == 1) { if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) { if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = String.format(OracleConstants.TO_DATE, originName, format); if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereName = String.format(OracleConstants.TO_CHAR, String.format(OracleConstants.TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : OracleConstants.DEFAULT_DATE_FORMAT, format));
} else {
whereName = String.format(OracleConstants.TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : OracleConstants.DEFAULT_DATE_FORMAT);
}
} }
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) { if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(OracleConstants.CAST, originName, OracleConstants.DEFAULT_INT_FORMAT) + "/1000"; if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereName = String.format(OracleConstants.FROM_UNIXTIME, cast, format); String cast = String.format(OracleConstants.CAST, originName, OracleConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(OracleConstants.FROM_UNIXTIME, cast, format);
} else {
String cast = String.format(OracleConstants.CAST, originName, OracleConstants.DEFAULT_INT_FORMAT) + "/1000";
whereName = String.format(OracleConstants.FROM_UNIXTIME, cast, OracleConstants.DEFAULT_DATE_FORMAT);
}
} }
if (field.getDeExtractType() == 1) { if (field.getDeExtractType() == 1) {
whereName = originName; if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
// whereName = String.format(OracleConstants.TO_CHAR, originName, format); whereName = String.format(OracleConstants.TO_CHAR, originName, format);
} else {
whereName = originName;
}
} }
} 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) {

View File

@ -1073,17 +1073,31 @@ public class PgQueryProvider extends QueryProvider {
if (field.getDeType() == 1) { if (field.getDeType() == 1) {
String format = transDateFormat(request.getDateStyle(), request.getDatePattern()); String format = transDateFormat(request.getDateStyle(), request.getDatePattern());
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5 || field.getDeExtractType() == 1) { if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
String timestamp = String.format(PgConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : PgConstants.DEFAULT_DATE_FORMAT); if(StringUtils.containsIgnoreCase(request.getOperator(), "in")){
whereName = String.format(PgConstants.DATE_FORMAT, timestamp, format); String timestamp = String.format(PgConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : PgConstants.DEFAULT_DATE_FORMAT);
whereName = String.format(PgConstants.DATE_FORMAT, timestamp, format);
}else {
whereName = String.format(PgConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : PgConstants.DEFAULT_DATE_FORMAT);
}
} }
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) { if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(PgConstants.CAST, originName, "bigint"); if(StringUtils.containsIgnoreCase(request.getOperator(), "in")){
String timestamp = String.format(PgConstants.FROM_UNIXTIME, cast); String cast = String.format(PgConstants.CAST, originName, "bigint");
whereName = String.format(PgConstants.DATE_FORMAT, timestamp, format); String timestamp = String.format(PgConstants.FROM_UNIXTIME, cast);
whereName = String.format(PgConstants.DATE_FORMAT, timestamp, format);
}else {
String cast = String.format(PgConstants.CAST, originName, "bigint");
whereName = String.format(PgConstants.FROM_UNIXTIME, cast);
}
} }
if (field.getDeExtractType() == 1) { if (field.getDeExtractType() == 1) {
whereName = String.format(PgConstants.DATE_FORMAT, originName, format); if(StringUtils.containsIgnoreCase(request.getOperator(), "in")){
whereName = String.format(PgConstants.DATE_FORMAT, originName, format);
}else {
whereName = originName;
}
} }
} 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) {

View File

@ -1080,12 +1080,29 @@ public class SqlserverQueryProvider extends QueryProvider {
} }
if (field.getDeType() == 1) { if (field.getDeType() == 1) {
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5 || field.getDeExtractType() == 1) { if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
whereName = transDateFormat(request.getDateStyle(), request.getDatePattern(), originName); if(StringUtils.containsIgnoreCase(request.getOperator(), "in")){
String date = String.format(SqlServerSQLConstants.STRING_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : SqlServerSQLConstants.DEFAULT_DATE_FORMAT);
whereName = transDateFormat(request.getDateStyle(), request.getDatePattern(), date);
}else {
whereName = String.format(SqlServerSQLConstants.STRING_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : SqlServerSQLConstants.DEFAULT_DATE_FORMAT);
}
} }
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) { if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
String cast = String.format(SqlServerSQLConstants.LONG_TO_DATE, originName + "/1000"); if(StringUtils.containsIgnoreCase(request.getOperator(), "in")){
whereName = transDateFormat(request.getDateStyle(), request.getDatePattern(), cast);; String cast = String.format(SqlServerSQLConstants.LONG_TO_DATE, originName + "/1000");
whereName = transDateFormat(request.getDateStyle(), request.getDatePattern(), String.format(SqlServerSQLConstants.FROM_UNIXTIME, cast));
}else {
String cast = String.format(SqlServerSQLConstants.LONG_TO_DATE, originName + "/1000");
whereName = String.format(SqlServerSQLConstants.FROM_UNIXTIME, cast);
}
}
if (field.getDeExtractType() == 1) {
if(StringUtils.containsIgnoreCase(request.getOperator(), "in")){
whereName = transDateFormat(request.getDateStyle(), request.getDatePattern(), originName);
}else {
whereName = originName;
}
} }
} 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) {