| | |
| | | * @return regionCode |
| | | */ |
| | | public static List<String> getPoliceRegionChildCodesByDeptId(String deptId,String communityCode) { |
| | | // 去重 |
| | | List<String> regionCodeList = new ArrayList<>(); |
| | | if (!Strings.isBlank(deptId)) { |
| | | //多个部门按逗号分割 |
| | |
| | | } |
| | | 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 (dept.getDeptNature() == 2) { |
| | | if (null != dept && !Strings.isBlank(dept.getRegionCode()) && !AuthUtil.isAdministrator()) { |
| | | // list = getGridRegionChildCodes(dept.getRegionCode(),communityCode,roleName); |
| | | 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); |
| | | } |
| | | // finalRegionCodeList.add(dept.getRegionCode()); |
| | | } |
| | | |
| | | //行政区划不为空添加进集合 |
| | | 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 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取综治下级区域 |
| | | * @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 |
| | |
| | | private static List<Region> getRegionChild(String regionCode,String communityCode) { |
| | | return CacheUtil.get(SYS_CACHE, REGION_CHILD_CODE, regionCode, () -> regionService.getRegionChild(regionCode,communityCode)); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | <!--过滤网格数据--> |
| | | <sql id="filterHouseGridByTownOrCommunity"> |
| | | <if test="houseParam.roleName!=null and houseParam.roleName!='' and houseParam.roleName!='系统管理员'"> |
| | | <if test="houseParam.roleName!=null and houseParam.roleName!='' and houseParam.roleName!='admin'"> |
| | | <choose> |
| | | <when test="houseParam.roleName=='网格员' and houseParam.userId!='1726859808689696770'"> |
| | | <when test="(houseParam.roleName=='wgy' or houseParam.roleName=='wzcj') and houseParam.userId!='1726859808689696770'"> |
| | | <choose> |
| | | <when test="list != null and list.size()>0"> |
| | | and jg.grid_code in |
| | |
| | | and br.name = '万达社区居民委员会' |
| | | </if> |
| | | <include refid="filterHouseGridByTownOrCommunity"/> |
| | | group by br.town_code,br.town_name |
| | | union |
| | | select br.town_code as id,br.town_name as name from jczz_police_affairs_grid jpag |
| | | left join blade_region br on jpag.community_code = br.code |
| | | where jpag.is_deleted = 0 |
| | | where jpag.is_deleted = 0 and br.town_code is not null |
| | | <include refid="filterCommunityByTownOrCommunity"/> |
| | | group by br.town_code,br.town_name |
| | | </select> |
| | | |
| | | <!--过滤社区数据--> |
| | | <sql id="filterCommunityByTownOrCommunity"> |
| | | <if test="houseParam.roleName!=null and houseParam.roleName!=''"> |
| | | <choose> |
| | | <when test="houseParam.roleName=='民警' and houseParam.userId!='1726859808689696770'"> |
| | | <when test="houseParam.roleName=='mj'"> |
| | | <choose> |
| | | <when test="communityList != null and communityList.size()>0"> |
| | | and jpag.jw_grid_code in |
| | |
| | | union |
| | | select br.village_code as id,br.village_name as name,br.town_code as parentId from jczz_police_affairs_grid jpag |
| | | left join blade_region br on jpag.community_code = br.code |
| | | where jpag.is_deleted = 0 |
| | | where jpag.is_deleted = 0 and br.village_code is not null |
| | | <include refid="filterCommunityByTownOrCommunity"/> |
| | | </select> |
| | | |
| | |
| | | /** |
| | | * 根据角色获取功能集合数据 |
| | | * |
| | | * @param type 1:查社区 2:查房屋和场所(居民角色) |
| | | * @param roleName |
| | | * @param type 1:查社区 2:查房屋和场所(居民角色)--2024/04/10 弃用 |
| | | * @param roleNames --2024/04/10 弃用 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object getFuncList(Integer type, String roleName) { |
| | | public Object getFuncList(Integer type, String roleNames) { |
| | | HouseParam houseParam = new HouseParam(); |
| | | String userId = AuthUtil.getUserId().toString(); |
| | | houseParam.setUserId(userId); |
| | | List<String> stringList = new ArrayList<>(); |
| | | List<String> communityList = new ArrayList<>(); |
| | | List<TreeStringNode> list = new ArrayList<>(); |
| | | if (null != type) { |
| | | // 如果是网格管理员,系统管理员,民警 |
| | | if (type == 1) { |
| | | if (null != roleName && !roleName.equals("")) { |
| | | houseParam.setRoleName(roleName); |
| | | if (roleName.equals("网格员") && !userId.equals("1726859808689696770")) { |
| | | // 查询对应的网格code |
| | | stringList = gridService.getGridListByUserId(AuthUtil.getUserId()); |
| | | } |
| | | if (roleName.equals("民警")) { |
| | | // 查询对应的社区编号 |
| | | communityList = SysCache.getPoliceRegionChildCodesByDeptId(AuthUtil.getDeptId(),null); |
| | | } |
| | | } |
| | | // 查询街道 |
| | | List<TreeStringNode> townList = baseMapper.getRegionListByGroupTwon(houseParam, stringList, communityList); |
| | | // 查询社区 |
| | | List<TreeStringNode> neiList = baseMapper.getRegionListByGroupNei(houseParam, stringList, communityList); |
| | | // 获取请求头中的角色别名 |
| | | String roleName = SpringUtils.getRequestParam("roleName"); |
| | | // 如果是网格管理员,系统管理员,民警,无诈场所采集 |
| | | if (roleName.equals("admin") || |
| | | roleName.equals("wzcj") || |
| | | roleName.equals("wgy") || |
| | | roleName.equals("mj")) |
| | | { |
| | | houseParam.setRoleName(roleName); |
| | | if ((roleName.equals("wgy") || roleName.equals("wzcj")) |
| | | && !userId.equals("1726859808689696770")) { |
| | | // 查询对应的网格code |
| | | // stringList = gridService.getGridListByUserId(AuthUtil.getUserId()); |
| | | stringList = SysCache.getGridRegionChildCodesByDeptId(AuthUtil.getDeptId(),null,roleName); |
| | | } |
| | | if (roleName.equals("mj")) { |
| | | // 查询对应的社区编号 |
| | | communityList = SysCache.getPoliceRegionChildCodesByDeptId(AuthUtil.getDeptId(),null); |
| | | } |
| | | // 查询街道 |
| | | List<TreeStringNode> townList = baseMapper.getRegionListByGroupTwon(houseParam, stringList, communityList); |
| | | // 查询社区 |
| | | List<TreeStringNode> neiList = baseMapper.getRegionListByGroupNei(houseParam, stringList, communityList); |
| | | // 遍历 |
| | | for (TreeStringNode treeNode : townList) { |
| | | // 遍历 |
| | | for (TreeStringNode treeNode : townList) { |
| | | // 遍历 |
| | | for (TreeStringNode node : neiList) { |
| | | if (treeNode.getId().equals(node.getParentId())) { |
| | | node.setHasChildren(false); |
| | | treeNode.getChildren().add(node); |
| | | } |
| | | for (TreeStringNode node : neiList) { |
| | | if (treeNode.getId().equals(node.getParentId())) { |
| | | node.setHasChildren(false); |
| | | treeNode.getChildren().add(node); |
| | | } |
| | | } |
| | | // 查询区域数据 |
| | | return townList; |
| | | } |
| | | // 如果是居民 |
| | | if (type == 2 || type == 3) { |
| | | return getInhabitantInfo(list); |
| | | } |
| | | // 查询区域数据 |
| | | return townList; |
| | | } |
| | | // 如果是居民 |
| | | if (roleName.equals("inhabitant")) { |
| | | return getInhabitantInfo(list); |
| | | } |
| | | return list; |
| | | } |
| | |
| | | private Integer deptCategory; |
| | | |
| | | /** |
| | | * 机构性质 1:公安 2:非公安 |
| | | * 机构性质 1:公安 2:综治 |
| | | */ |
| | | @ApiModelProperty(value = "机构性质 1:公安 2:非公安") |
| | | @ApiModelProperty(value = "机构性质 1:公安 2:综治") |
| | | private Integer deptNature; |
| | | |
| | | /** |
| | |
| | | * @param regionCode |
| | | * @return |
| | | */ |
| | | List<Region> getRegionChildList(@Param("regionCode") String regionCode); |
| | | List<Region> getRegionChildList(@Param("regionCode") String regionCode, |
| | | @Param("communityCode") String communityCode, |
| | | @Param("roleName") String roleName); |
| | | |
| | | /** |
| | | * 查询公安对应的辖区树 |
| | |
| | | * @return |
| | | */ |
| | | List<Region> getPoliceList(@Param("communityCode") String communityCode); |
| | | |
| | | /** |
| | | * 查询网格员对应的网格 |
| | | * @param regionCode |
| | | * @return |
| | | */ |
| | | List<Region> getGridRegionChildList(@Param("regionCode") String regionCode); |
| | | } |
| | |
| | | jg.sort |
| | | FROM blade_region br |
| | | right join jczz_grid jg on jg.community_code = br.village_code and jg.is_deleted = 0 |
| | | where (br.ancestors like concat('%',#{regionCode},'%') or br.code = #{regionCode}) |
| | | where (br.ancestors like concat('%',#{regionCode},'%') or br.code = #{regionCode} or jg.grid_code = '36110200302701') |
| | | ) |
| | | </select> |
| | | |
| | | <!--查询网格员对应的网格区域--> |
| | | <select id="getGridRegionChildList" resultType="org.springblade.modules.system.entity.Region"> |
| | | SELECT |
| | | jg.grid_code as code, |
| | | jg.community_code as parent_code, |
| | | jg.grid_name as name, |
| | | '' as ancestors, |
| | | 6 as region_level, |
| | | jg.sort |
| | | FROM blade_region br |
| | | right join jczz_grid jg on jg.community_code = br.village_code and jg.is_deleted = 0 |
| | | where jg.grid_code = #{regionCode} |
| | | </select> |
| | | |
| | | <!--查询公安相关的区域数据--> |
| | | <select id="getPoliceList" resultType="org.springblade.modules.system.entity.Region"> |
| | | SELECT id as code,parentId as parent_code,name,'' as ancestors,null as region_level,1 as sort FROM police_region |
| | |
| | | * @return |
| | | */ |
| | | List<Region> getPoliceRegionChild(String regionCode,String communityCode); |
| | | |
| | | /** |
| | | * 获取综治下级区域 |
| | | * @param regionCode |
| | | * @return |
| | | */ |
| | | List<Region> getGridRegionChild(String regionCode, String communityCode, String roleName); |
| | | } |
| | |
| | | list.addAll(policeList); |
| | | } |
| | | // 查询综治区域集合 |
| | | List<Region> regionChildList = baseMapper.getRegionChildList(regionCode); |
| | | List<Region> regionChildList = baseMapper.getRegionChildList(regionCode,null,null); |
| | | list.addAll(regionChildList); |
| | | // 返回 |
| | | return list; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取综治下级区域 |
| | | * @param regionCode |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Region> getGridRegionChild(String regionCode, String communityCode, String roleName) { |
| | | // 创建区域对象 |
| | | List<Region> list = new ArrayList<>(); |
| | | if (!Strings.isBlank(roleName) && roleName.equals("wgy")){ |
| | | // 查询综治区域集合 |
| | | List<Region> regionChildList = baseMapper.getGridRegionChildList(regionCode); |
| | | list.addAll(regionChildList); |
| | | }else { |
| | | // 查询综治区域集合 |
| | | List<Region> regionChildList = baseMapper.getRegionChildList(regionCode, communityCode, roleName); |
| | | list.addAll(regionChildList); |
| | | } |
| | | // 返回 |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取某个父节点下面的所有子节点 |
| | | * @param regionList |
| | | * @param parentCode |