From 2d37fa5cf4ebf8bdcae40c5a9f63d561f307e2af Mon Sep 17 00:00:00 2001
From: lin <sbla5888@163.com>
Date: Wed, 10 Apr 2024 10:22:48 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/main/java/org/springblade/common/cache/SysCache.java |   84 ++++++++++++++++++-----------------------
 1 files changed, 37 insertions(+), 47 deletions(-)

diff --git a/src/main/java/org/springblade/common/cache/SysCache.java b/src/main/java/org/springblade/common/cache/SysCache.java
index a9a2e64..9f6c384 100644
--- a/src/main/java/org/springblade/common/cache/SysCache.java
+++ b/src/main/java/org/springblade/common/cache/SysCache.java
@@ -1,19 +1,3 @@
-/*
- *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
- *
- *  Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions are met:
- *
- *  Redistributions of source code must retain the above copyright notice,
- *  this list of conditions and the following disclaimer.
- *  Redistributions in binary form must reproduce the above copyright
- *  notice, this list of conditions and the following disclaimer in the
- *  documentation and/or other materials provided with the distribution.
- *  Neither the name of the dreamlu.net developer nor the names of its
- *  contributors may be used to endorse or promote products derived from
- *  this software without specific prior written permission.
- *  Author: Chill 庄骞 (smallchill@163.com)
- */
 package org.springblade.common.cache;
 
 import org.apache.logging.log4j.util.Strings;
@@ -334,7 +318,7 @@
 	 *
 	 * @return regionCode
 	 */
-	public static List<String> getRegionChildCodesByDeptId(String deptId) {
+	public static List<String> getRegionChildCodesByDeptId(String deptId,String communityCode) {
 		//多个部门按逗号分割
 		List<String> deptIdList = Arrays.asList(deptId.split(","));
 
@@ -345,7 +329,7 @@
 			// 查询对应的区域编号code
 			Dept dept = deptService.getById(id);
 			if (null!=dept && !Strings.isBlank(dept.getRegionCode()) && !AuthUtil.isAdministrator()){
-				list = getRegionChildCodes(dept.getRegionCode());
+				list = getRegionChildCodes(dept.getRegionCode(),communityCode);
 				//行政区划不为空添加进集合
 				if (list.size()>0){
 					allRegionList.addAll(list);
@@ -363,28 +347,34 @@
 	 *
 	 * @return regionCode
 	 */
-	public static List<String> getPoliceRegionChildCodesByDeptId(String deptId) {
-		//多个部门按逗号分割
-		List<String> deptIdList = Arrays.asList(deptId.split(","));
-
-		//所有行政区划code
-		List<String> allRegionList = new ArrayList<>();
-		deptIdList.forEach(id->{
-			List<String> list = new ArrayList<>();
-			// 查询对应的区域编号code
-			Dept dept = deptService.getById(id);
-			if (null!=dept && !Strings.isBlank(dept.getRegionCode()) && !AuthUtil.isAdministrator()){
-				list = getPoliceRegionChildCodes(dept.getRegionCode());
-				//行政区划不为空添加进集合
-				if (list.size()>0){
-					allRegionList.addAll(list);
-				}
-			}
-		});
-
+	public static List<String> getPoliceRegionChildCodesByDeptId(String deptId,String communityCode) {
 		// 去重
-		List<String> collect = allRegionList.stream().distinct().collect(Collectors.toList());
-		return collect;
+		List<String> regionCodeList = new ArrayList<>();
+		if (!Strings.isBlank(deptId)) {
+			//多个部门按逗号分割
+			List<String> deptIdList = Arrays.asList(deptId.split(","));
+
+			//所有行政区划code
+			List<String> allRegionList = new ArrayList<>();
+			deptIdList.forEach(id -> {
+				List<String> list = new ArrayList<>();
+				// 查询对应的区域编号code
+				Dept dept = deptService.getById(id);
+				// 只取公安的
+				if (dept.getDeptNature() == 1) {
+					if (null != dept && !Strings.isBlank(dept.getRegionCode()) && !AuthUtil.isAdministrator()) {
+						list = getPoliceRegionChildCodes(dept.getRegionCode(),communityCode);
+						//行政区划不为空添加进集合
+						if (list.size() > 0) {
+							allRegionList.addAll(list);
+						}
+					}
+				}
+			});
+			// 去重
+			regionCodeList = allRegionList.stream().distinct().collect(Collectors.toList());
+		}
+		return regionCodeList;
 	}
 
 	/**
@@ -392,14 +382,14 @@
 	 *
 	 * @return regionCode
 	 */
-	public static List<String> getRegionChildCodes(String regionCode) {
+	public static List<String> getRegionChildCodes(String regionCode,String communityCode) {
 		if (regionCode == null) {
 			return null;
 		}
 		List<String> regionCodeList = CacheUtil.get(SYS_CACHE, REGION_CHILDCODES_CODE, regionCode, List.class);
 		if (regionCodeList == null || regionCodeList.size()==0) {
 			regionCodeList = new ArrayList<>();
-			List<Region> deptChild = getRegionChild(regionCode);
+			List<Region> deptChild = getRegionChild(regionCode,communityCode);
 			if (deptChild != null) {
 				List<String> collect = deptChild.stream().map(Region::getCode).collect(Collectors.toList());
 				regionCodeList.addAll(collect);
@@ -415,14 +405,14 @@
 	 *
 	 * @return regionCode
 	 */
-	public static List<String> getPoliceRegionChildCodes(String regionCode) {
+	public static List<String> getPoliceRegionChildCodes(String regionCode,String communityCode) {
 		if (regionCode == null) {
 			return null;
 		}
 		List<String> regionCodeList = CacheUtil.get(SYS_CACHE, REGION_CHILDCODES_CODE, regionCode, List.class);
 		if (regionCodeList == null || regionCodeList.size()==0) {
 			regionCodeList = new ArrayList<>();
-			List<Region> deptChild = getPoliceRegionChild(regionCode);
+			List<Region> deptChild = getPoliceRegionChild(regionCode,communityCode);
 			if (deptChild != null) {
 				List<String> collect = deptChild.stream().map(Region::getCode).collect(Collectors.toList());
 				regionCodeList.addAll(collect);
@@ -438,8 +428,8 @@
 	 * @param regionCode
 	 * @return
 	 */
-	private static List<Region> getPoliceRegionChild(String regionCode) {
-		return CacheUtil.get(SYS_CACHE, REGION_CHILD_CODE, regionCode, () -> regionService.getPoliceRegionChild(regionCode));
+	private static List<Region> getPoliceRegionChild(String regionCode,String communityCode) {
+		return CacheUtil.get(SYS_CACHE, REGION_CHILD_CODE, regionCode, () -> regionService.getPoliceRegionChild(regionCode,communityCode));
 	}
 
 	/**
@@ -447,7 +437,7 @@
 	 * @param regionCode
 	 * @return
 	 */
-	private static List<Region> getRegionChild(String regionCode) {
-		return CacheUtil.get(SYS_CACHE, REGION_CHILD_CODE, regionCode, () -> regionService.getRegionChild(regionCode));
+	private static List<Region> getRegionChild(String regionCode,String communityCode) {
+		return CacheUtil.get(SYS_CACHE, REGION_CHILD_CODE, regionCode, () -> regionService.getRegionChild(regionCode,communityCode));
 	}
 }

--
Gitblit v1.9.3