Merge pull request #13363 from dataease/pr@dev-v2@fix_filter

fix(仪表板): 修复date类型时间范围不包含边界的问题
This commit is contained in:
fit2cloud-chenyw 2024-11-15 17:12:38 +08:00 committed by GitHub
commit 58aaeb7a61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -212,7 +212,11 @@ public class ExtWhere2Str {
whereName = String.format(SQLConstants.UNIX_TIMESTAMP, whereName);
whereValue = String.format(SQLConstants.WHERE_BETWEEN, Long.parseLong(value.get(0)), Long.parseLong(value.get(1)));
} else {
whereValue = String.format(SQLConstants.WHERE_BETWEEN, Utils.transLong2Str(Long.parseLong(value.get(0))), Utils.transLong2Str(Long.parseLong(value.get(1))));
if (StringUtils.equalsIgnoreCase(request.getDatasetTableField().getType(), "date")) {
whereValue = String.format(SQLConstants.WHERE_BETWEEN, Utils.transLong2StrShort(Long.parseLong(value.get(0))), Utils.transLong2StrShort(Long.parseLong(value.get(1))));
} else {
whereValue = String.format(SQLConstants.WHERE_BETWEEN, Utils.transLong2Str(Long.parseLong(value.get(0))), Utils.transLong2Str(Long.parseLong(value.get(1))));
}
}
}
} else if (request.getDatasetTableField().getDeType() == 2

View File

@ -425,6 +425,12 @@ public class Utils {
return simpleDateFormat.format(date);
}
public static String transLong2StrShort(Long ts) {
Date date = new Date(ts);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
return simpleDateFormat.format(date);
}
public static List<CalParam> getParams(List<DatasetTableFieldDTO> list) {
if (ObjectUtils.isEmpty(list)) return Collections.emptyList();
List<CalParam> param = new ArrayList<>();