From 566e7986291e73051d30ee252b0ebf852b1577a7 Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Tue, 02 Apr 2024 14:25:51 +0800
Subject: [PATCH] 娱乐场所标签新增180200
---
src/main/java/org/springblade/common/cache/SysCache.java | 119 ++++++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 88 insertions(+), 31 deletions(-)
diff --git a/src/main/java/org/springblade/common/cache/SysCache.java b/src/main/java/org/springblade/common/cache/SysCache.java
index d816792..d58137b 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;
@@ -156,25 +140,33 @@
/**
* 获取子部门ID集合
*
- * @param deptId 主键
+ * @param deptIds 主键
* @return 子部门ID
*/
- public static List<Long> getDeptChildIds(Long deptId) {
- if (deptId == null) {
+ public static List<Long> getDeptChildIds(String deptIds) {
+ if (Strings.isBlank(deptIds)) {
return null;
}
- List<Long> deptIdList = CacheUtil.get(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, List.class);
- if (deptIdList == null) {
- deptIdList = new ArrayList<>();
- List<Dept> deptChild = getDeptChild(deptId);
- if (deptChild != null) {
- List<Long> collect = deptChild.stream().map(Dept::getId).collect(Collectors.toList());
- deptIdList.addAll(collect);
+ List<Long> list = new ArrayList<>();
+ List<String> deptIdList = new ArrayList<>(Arrays.asList(deptIds.split(",")));
+ for (String deptId : deptIdList) {
+ List<Long> deptIdLists = CacheUtil.get(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, List.class);
+ if (deptIdLists == null) {
+ deptIdLists = new ArrayList<>();
+ List<Dept> deptChild = getDeptChild(Long.parseLong(deptId));
+ if (deptChild != null) {
+ List<Long> collect = deptChild.stream().map(Dept::getId).collect(Collectors.toList());
+ deptIdLists.addAll(collect);
+ }
+ deptIdLists.add(Long.parseLong(deptId));
+ CacheUtil.put(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, deptIdLists);
}
- deptIdList.add(deptId);
- CacheUtil.put(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, deptIdList);
+ list.addAll(deptIdLists);
}
- return deptIdList;
+ // 去重
+ List<Long> collect = list.stream().distinct().collect(Collectors.toList());
+ // 返回
+ return collect;
}
/**
@@ -333,13 +325,11 @@
//所有行政区划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 = getRegionChildCodes(dept.getRegionCode());
-
//行政区划不为空添加进集合
if (list.size()>0){
allRegionList.addAll(list);
@@ -350,6 +340,41 @@
// 去重
List<String> collect = allRegionList.stream().distinct().collect(Collectors.toList());
return collect;
+ }
+
+ /**
+ * 获取民警(公安)下级所有区域code
+ *
+ * @return regionCode
+ */
+ public static List<String> getPoliceRegionChildCodesByDeptId(String deptId) {
+ // 去重
+ 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());
+ //行政区划不为空添加进集合
+ if (list.size() > 0) {
+ allRegionList.addAll(list);
+ }
+ }
+ }
+ });
+ // 去重
+ regionCodeList = allRegionList.stream().distinct().collect(Collectors.toList());
+ }
+ return regionCodeList;
}
/**
@@ -376,6 +401,38 @@
}
/**
+ * 获取公安下级所有区域code
+ *
+ * @return regionCode
+ */
+ public static List<String> getPoliceRegionChildCodes(String regionCode) {
+ 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);
+ if (deptChild != null) {
+ List<String> collect = deptChild.stream().map(Region::getCode).collect(Collectors.toList());
+ regionCodeList.addAll(collect);
+ }
+ regionCodeList.add(regionCode);
+ CacheUtil.put(SYS_CACHE, REGION_CHILDCODES_CODE, regionCode, regionCodeList);
+ }
+ return regionCodeList;
+ }
+
+ /**
+ * 获取民警下级区域
+ * @param regionCode
+ * @return
+ */
+ private static List<Region> getPoliceRegionChild(String regionCode) {
+ return CacheUtil.get(SYS_CACHE, REGION_CHILD_CODE, regionCode, () -> regionService.getPoliceRegionChild(regionCode));
+ }
+
+ /**
* 获取下级区域
* @param regionCode
* @return
--
Gitblit v1.9.3