From 8b7258c9427882bb1798f1502eaa35184c6e374e Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Fri, 09 Aug 2024 14:29:18 +0800
Subject: [PATCH] 短信指定楼栋发送
---
src/main/java/org/springblade/common/cache/SysCache.java | 75 +++++++++++++++++++++++++++++++++++++
1 files changed, 74 insertions(+), 1 deletions(-)
diff --git a/src/main/java/org/springblade/common/cache/SysCache.java b/src/main/java/org/springblade/common/cache/SysCache.java
index 9f6c384..792babf 100644
--- a/src/main/java/org/springblade/common/cache/SysCache.java
+++ b/src/main/java/org/springblade/common/cache/SysCache.java
@@ -13,6 +13,7 @@
import java.util.List;
import java.util.stream.Collectors;
+import static org.springblade.common.cache.CacheNames.ARTICLE_KEY;
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
/**
@@ -348,7 +349,6 @@
* @return regionCode
*/
public static List<String> getPoliceRegionChildCodesByDeptId(String deptId,String communityCode) {
- // 去重
List<String> regionCodeList = new ArrayList<>();
if (!Strings.isBlank(deptId)) {
//多个部门按逗号分割
@@ -376,6 +376,61 @@
}
return regionCodeList;
}
+
+
+ /**
+ * 查询综治网格/公安相关的网格,社区编号集合
+ * @param deptId
+ * @param communityCode
+ * @param roleName
+ * @return
+ */
+ public static List<String> getGridRegionChildCodesByDeptId(String deptId, String communityCode,String roleName) {
+ List<String> regionCodeList = new ArrayList<>();
+ if (!Strings.isBlank(deptId)) {
+ //多个部门按逗号分割
+ List<String> deptIdList = Arrays.asList(deptId.split(","));
+ List<String> finalRegionCodeList = regionCodeList;
+ String key = AuthUtil.getUserId().toString();
+ if (!Strings.isBlank(roleName)){
+ key = key + ":" + roleName;
+ }
+ String finalKey = key;
+ deptIdList.forEach(id -> {
+ List<String> list = new ArrayList<>();
+ // 查询对应的区域编号code
+ Dept dept = deptService.getById(id);
+ if (null != dept) {
+ if ((roleName.equals("mj") && dept.getDeptNature() == 1) ||
+ ((roleName.equals("wgy") || roleName.equals("wzcj")) && dept.getDeptNature() == 2)) {
+ if (!AuthUtil.isAdministrator()) {
+ if (dept.getRegionCode() == null) {
+ return;
+ }
+ list = CacheUtil.get(SYS_CACHE, REGION_CHILDCODES_CODE, finalKey, List.class);
+ if (list == null || list.size() == 0) {
+ list = new ArrayList<>();
+ List<Region> deptChild = getGridRegionChild(dept.getRegionCode(), communityCode, roleName);
+ if (deptChild != null) {
+ List<String> collect = deptChild.stream().map(Region::getCode).collect(Collectors.toList());
+ list.addAll(collect);
+ }
+ }
+ //行政区划不为空添加进集合
+ if (list.size() > 0) {
+ finalRegionCodeList.addAll(list);
+ }
+ }
+ }
+ }
+ });
+ // 去重
+ regionCodeList = finalRegionCodeList.stream().distinct().collect(Collectors.toList());
+ CacheUtil.put(SYS_CACHE, REGION_CHILDCODES_CODE, key, regionCodeList);
+ }
+ return regionCodeList;
+ }
+
/**
* 获取下级所有区域code
@@ -424,6 +479,15 @@
}
/**
+ * 获取综治下级区域
+ * @param regionCode
+ * @return
+ */
+ private static List<Region> getGridRegionChild(String regionCode, String communityCode,String roleName) {
+ return CacheUtil.get(SYS_CACHE, REGION_CHILD_CODE, regionCode, () -> regionService.getGridRegionChild(regionCode,communityCode,roleName));
+ }
+
+ /**
* 获取民警下级区域
* @param regionCode
* @return
@@ -440,4 +504,13 @@
private static List<Region> getRegionChild(String regionCode,String communityCode) {
return CacheUtil.get(SYS_CACHE, REGION_CHILD_CODE, regionCode, () -> regionService.getRegionChild(regionCode,communityCode));
}
+
+ /**
+ * 查询当前文章范围对应的社区编号字符串集合
+ * @param articleRange
+ * @return
+ */
+ public static String getAllCommunityNameListString(String articleRange,String id) {
+ return CacheUtil.get(ARTICLE_KEY, "id", id ,() -> regionService.getAllCommunityNameListString(articleRange));
+ }
}
--
Gitblit v1.9.3