重写用户获取火点数据的接口

This commit is contained in:
liuchengqian 2023-03-01 16:58:46 +08:00
parent 7d5025b9ab
commit 6abeff1494

View File

@ -191,6 +191,8 @@ public class FirePointQueryManager {
List<Predicate> predicateList = new ArrayList<>();
//添加区划编码的过滤
predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), finalMNoRedundantUserCode + "%"));
List<Predicate> 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()]));
};