From 722300950d0fa18c72419f103d2daad439ad08cf Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Tue, 7 Mar 2023 09:20:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xkrs/straw/utils/FirePointQueryManager.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/xkrs/straw/utils/FirePointQueryManager.java b/src/main/java/com/xkrs/straw/utils/FirePointQueryManager.java index f2ba742..f146c7a 100644 --- a/src/main/java/com/xkrs/straw/utils/FirePointQueryManager.java +++ b/src/main/java/com/xkrs/straw/utils/FirePointQueryManager.java @@ -141,7 +141,10 @@ public class FirePointQueryManager { Specification specificationOrdinary = (root, criteriaQuery, criteriaBuilder) -> { List predicateList = new ArrayList<>(); //添加区划编码的过滤 - predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), noRedundantUserCode + "%")); + if (!TextUtils.isEmpty(noRedundantUserCode)) { + predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), noRedundantUserCode + "%")); + } + //添加子区域区划编码的过滤(比如查询火点的系统用户所属的区划是山东省,但是该用户目前只想查询青岛市的火点,那么noRedundantUserCode=山东省区划,userSubAreaCutCountyCode=青岛市区划) if (!TextUtils.isEmpty(userSubAreaCutCountyCode)) { predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), userSubAreaCutCountyCode + "%")); } @@ -186,7 +189,13 @@ public class FirePointQueryManager { Specification specificationPrecise = (root, criteriaQuery, criteriaBuilder) -> { List predicateList = new ArrayList<>(); //添加区划编码的过滤 - predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), noRedundantUserCode + "%")); + if (!TextUtils.isEmpty(noRedundantUserCode)) { + predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), noRedundantUserCode + "%")); + } + //添加子区域区划编码的过滤(比如查询火点的系统用户所属的区划是山东省,但是该用户目前只想查询青岛市的火点,那么noRedundantUserCode=山东省区划,userSubAreaCutCountyCode=青岛市区划) + if (!TextUtils.isEmpty(userSubAreaCutCountyCode)) { + predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), userSubAreaCutCountyCode + "%")); + } //开始时间查询条件 if (!TextUtils.isEmpty(startTime)) { LocalDateTime startTime1 = DateTimeUtils.stringToLocalDateTime(startTime);