// PO日期 范围
if(map.get("poDate1") != null && map.get("poDate2") != null) {
Date start = DateUtil.formatString(map.get("poDate1").toString(), "yyyy-MM-dd");
Date end = DateUtil.formatString(map.get("poDate2").toString(), "yyyy-MM-dd");
predicate.getExpressions().add(cb.between(root.get("poDate"),start,end));
} 假如 poDate1 2020-01-01 poDate2 2020-01-29
搜索的范围包含了 01-01 也包含了 01-29
日期用的是 2020-08-02 19:55:38
搜索用的是 yyyy-MM-dd 格式
搜索 2020-08-02 - 2020-08-02 搜索不到东西的。
搜索 2020-08-01 - 2020-08-02 只会展示08-01的数据。

解决方法是 自动加手加上。 时分秒
if (StringUtil.isNotEmpty(date1))
map.put("date1", date1+" 00:00:00");
if (StringUtil.isNotEmpty(date2))
map.put("date2", date2+" 23:59:00");
===================
// 创建日期 范围
if(map.get("date1") != null && map.get("date2") != null) {
Date start = DateUtil.formatString(map.get("date1").toString(), "yyyy-MM-dd HH:mm:ss");
Date end = DateUtil.formatString(map.get("date2").toString(), "yyyy-MM-dd HH:mm:ss");
predicate.getExpressions().add(cb.between(root.get("createDateTime"),start,end));
}
站长微信:xiaomao0055
站长QQ:14496453