diff --git a/src/main/java/com/xkrs/straw/utils/FirePointQueryManager.java b/src/main/java/com/xkrs/straw/utils/FirePointQueryManager.java index 05f97cc..6d6c159 100644 --- a/src/main/java/com/xkrs/straw/utils/FirePointQueryManager.java +++ b/src/main/java/com/xkrs/straw/utils/FirePointQueryManager.java @@ -191,6 +191,8 @@ public class FirePointQueryManager { List predicateList = new ArrayList<>(); //添加区划编码的过滤 predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), finalMNoRedundantUserCode + "%")); + + List subPredicateList = new ArrayList<>(); for (VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItem : mVipTimeRangeItemList) { String userStartTime = vipTimeRangeItem.getStartTime(); String userEndTime = vipTimeRangeItem.getEndTime(); @@ -198,7 +200,21 @@ public class FirePointQueryManager { Predicate beforeStartTimePredicate = criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), userStartTime); //早于(包含)VIP结束时间 Predicate afterEndTimePredicate = criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), userEndTime); - predicateList.add(criteriaBuilder.and(beforeStartTimePredicate, afterEndTimePredicate)); + subPredicateList.add(criteriaBuilder.and(beforeStartTimePredicate, afterEndTimePredicate)); + } + if (subPredicateList.size() == 0) { + } else if (subPredicateList.size() == 1) { + predicateList.add(subPredicateList.get(0)); + } else { + Predicate orPredicate = null; + for (int i = 1; i < subPredicateList.size(); i++) { + if (i == 1) { + orPredicate = criteriaBuilder.or(subPredicateList.get(0), subPredicateList.get(1)); + } else { + orPredicate = criteriaBuilder.or(orPredicate, subPredicateList.get(i)); + } + } + predicateList.add(orPredicate); } return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); };