Merge pull request #4904 from dataease/pr@dev@fix_date_filter

fix(视图): 修复日期不能过滤的问题
This commit is contained in:
Junjun 2023-03-28 09:57:53 +08:00 committed by GitHub
commit 2c59ecc19a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 26 deletions

View File

@ -1098,26 +1098,21 @@ public class MysqlQueryProvider extends QueryProvider {
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
whereValue = "'%" + value.get(0) + "%'";
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
if (request.getDatasetTableField().getDeType() == 1
&& (request.getDatasetTableField().getDeExtractType() == 2
|| request.getDatasetTableField().getDeExtractType() == 3
|| request.getDatasetTableField().getDeExtractType() == 4)) {
whereValue = String.format(MysqlConstants.WHERE_BETWEEN, value.get(0), value.get(1));
} else if (request.getDatasetTableField().getDeType() == 1) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(0))));
String endTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(1))));
whereValue = String.format(MysqlConstants.WHERE_BETWEEN, startTime, endTime);
if (request.getDatasetTableField().getDeType() == 1) {
if (request.getDatasetTableField().getDeExtractType() == 2
|| request.getDatasetTableField().getDeExtractType() == 3
|| request.getDatasetTableField().getDeExtractType() == 4) {
whereValue = String.format(MysqlConstants.WHERE_BETWEEN, value.get(0), value.get(1));
} else {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(0))));
String endTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(1))));
whereValue = String.format(MysqlConstants.WHERE_BETWEEN, startTime, endTime);
}
} else {
whereValue = String.format(MysqlConstants.WHERE_BETWEEN, value.get(0), value.get(1));
}
} else {
// doris field type test
/*if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
whereValue = String.format(MysqlConstants.WHERE_NUMBER_VALUE, value.get(0));
} else {
whereValue = String.format(MysqlConstants.WHERE_VALUE_VALUE, value.get(0));
}*/
whereValue = String.format(MysqlConstants.WHERE_VALUE_VALUE, value.get(0));
}
list.add(SQLObj.builder()

View File

@ -1105,16 +1105,17 @@ public class MysqlQueryProvider extends QueryProvider {
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
whereValue = "'%" + value.get(0) + "%'";
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
if (request.getDatasetTableField().getDeType() == 1
&& (request.getDatasetTableField().getDeExtractType() == 2
|| request.getDatasetTableField().getDeExtractType() == 3
|| request.getDatasetTableField().getDeExtractType() == 4)) {
whereValue = String.format(MysqlConstants.WHERE_BETWEEN, value.get(0), value.get(1));
} else if (request.getDatasetTableField().getDeType() == 1) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
String startTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(0))));
String endTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(1))));
whereValue = String.format(MySQLConstants.WHERE_BETWEEN, startTime, endTime);
if (request.getDatasetTableField().getDeType() == 1) {
if (request.getDatasetTableField().getDeExtractType() == 2
|| request.getDatasetTableField().getDeExtractType() == 3
|| request.getDatasetTableField().getDeExtractType() == 4) {
whereValue = String.format(MysqlConstants.WHERE_BETWEEN, value.get(0), value.get(1));
} else {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(0))));
String endTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(1))));
whereValue = String.format(MySQLConstants.WHERE_BETWEEN, startTime, endTime);
}
} else {
whereValue = String.format(MySQLConstants.WHERE_BETWEEN, value.get(0), value.get(1));
}