| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import liquibase.repackaged.org.apache.commons.lang3.StringUtils; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.constant.DictConstant; |
| | | import org.springblade.common.node.TreeStringNode; |
| | | import org.springblade.common.utils.ComplexNumberStringComparator; |
| | | import org.springblade.common.utils.NodeTreeUtil; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.modules.category.dto.CategoryLabelDTO; |
| | | import org.springblade.modules.category.service.ICategoryLabelService; |
| | | import org.springblade.modules.category.dto.CategoryDTO; |
| | | import org.springblade.modules.category.service.ICategoryService; |
| | | import org.springblade.modules.community.entity.CommunityEntity; |
| | | import org.springblade.modules.community.service.ICommunityService; |
| | | import org.springblade.modules.district.entity.DistrictEntity; |
| | | import org.springblade.modules.district.service.IDistrictService; |
| | | import org.springblade.modules.doorplateAddress.entity.DoorplateAddressEntity; |
| | |
| | | private IDistrictService districtService; |
| | | |
| | | @Autowired |
| | | private ICategoryLabelService iCategoryLabelService; |
| | | private ICategoryService iCategoryService; |
| | | |
| | | @Autowired |
| | | private ICommunityService communityService; |
| | | |
| | | |
| | | @Override |
| | |
| | | String userId = AuthUtil.getUserId().toString(); |
| | | houseParam.setUserId(userId); |
| | | List<String> stringList = new ArrayList<>(); |
| | | List<String> communityList = new ArrayList<>(); |
| | | if (null!=roleName && !roleName.equals("")){ |
| | | houseParam.setRoleName(roleName); |
| | | if (roleName.equals("网格员") && !userId.equals("1726859808689696770")){ |
| | | // 查询对应的房屋地址code |
| | | stringList = gridService.getAddressCodeListByUserId(AuthUtil.getUserId()); |
| | | } |
| | | if (roleName.equals("民警")){ |
| | | // 查询对应的社区编号 |
| | | communityList = communityService.getCommunityCodeListByUserId(AuthUtil.getUserId()); |
| | | } |
| | | } |
| | | List<TreeStringNode> list = new ArrayList<>(); |
| | | if (null!=type) { |
| | | // 如果是网格管理员,系统管理员 |
| | | // 如果是网格管理员,系统管理员,民警 |
| | | if (type==1){ |
| | | // 查询街道 |
| | | List<TreeStringNode> townList = baseMapper.getRegionListByGroupTwon(houseParam,stringList); |
| | | List<TreeStringNode> townList = baseMapper.getRegionListByGroupTwon(houseParam,stringList,communityList); |
| | | // 查询社区 |
| | | List<TreeStringNode> neiList = baseMapper.getRegionListByGroupNei(houseParam,stringList); |
| | | List<TreeStringNode> neiList = baseMapper.getRegionListByGroupNei(houseParam,stringList,communityList); |
| | | // 遍历 |
| | | for (TreeStringNode treeNode : townList) { |
| | | // 遍历 |
| | |
| | | List<TreeStringNode> placeNodeList = placeService.selectPlaceNodeList(AuthUtil.getUserId()); |
| | | for (TreeStringNode treeNode : placeNodeList) { |
| | | treeNode.setAddressType(2); |
| | | CategoryLabelDTO categoryLabelDTO = new CategoryLabelDTO(); |
| | | categoryLabelDTO.setPlaceId(treeNode.getId()); |
| | | List<CategoryLabelDTO> categoryLabelDTOS = iCategoryLabelService.selectCategoryLabelList(categoryLabelDTO); |
| | | treeNode.setCategoryLabelList(categoryLabelDTOS); |
| | | CategoryDTO categoryDTO = new CategoryDTO(); |
| | | categoryDTO.setPlaceId(treeNode.getId()); |
| | | List<CategoryDTO> categoryDTOS = iCategoryService.selectCategoryLabelList(categoryDTO); |
| | | treeNode.setCategoryList(categoryDTOS); |
| | | // if (DictConstant.SMALL_DOORPLATE.equals(treeNode.getDoorplateType()) || |
| | | // (DictConstant.centre_DOORPLATE.equals(treeNode.getDoorplateType()) && |
| | | // treeNode.getAddressLevel().equals(1))) { |
| | |
| | | houseNode.setId("1"); |
| | | houseNode.setHasChildren(true); |
| | | houseNode.setChildren(houseNodeList); |
| | | list.add(houseNode); |
| | | |
| | | TreeStringNode placeNode = new TreeStringNode(); |
| | | placeNode.setName("场所"); |
| | | placeNode.setId("2"); |
| | | placeNode.setHasChildren(true); |
| | | placeNode.setChildren(placeNodeList); |
| | | |
| | | list.add(houseNode); |
| | | list.add(placeNode); |
| | | // 返回 |
| | | return list; |
| | | } |
| | | if (houseNodeList.size()>0){ |
| | | list = houseNodeList; |
| | | TreeStringNode houseNode = new TreeStringNode(); |
| | | houseNode.setName("房屋"); |
| | | houseNode.setId("1"); |
| | | houseNode.setHasChildren(true); |
| | | houseNode.setChildren(houseNodeList); |
| | | list.add(houseNode); |
| | | } |
| | | if (placeNodeList.size()>0){ |
| | | list = placeNodeList; |
| | | TreeStringNode placeNode = new TreeStringNode(); |
| | | placeNode.setName("场所"); |
| | | placeNode.setId("2"); |
| | | placeNode.setHasChildren(true); |
| | | placeNode.setChildren(placeNodeList); |
| | | list.add(placeNode); |
| | | } |
| | | // 返回 |
| | | return list; |
| | |
| | | Map<String, Object> map = new HashMap<>(2); |
| | | // 获取网格员对应的地址编号集合 |
| | | List<String> stringList = getHouseCodeList(houseParam); |
| | | List<String> communityCodeList = getCommunityCodeList(houseParam); |
| | | // 获取网格员对应的网格信息 |
| | | getGridInfoByGridman(houseParam); |
| | | // 查小区,场所 |
| | | if (houseParam.getType()==1){ |
| | | // 根据社区名称查询小区集合 |
| | | list = baseMapper.getDistrictList(houseParam,stringList); |
| | | list = baseMapper.getDistrictList(houseParam,stringList,communityCodeList); |
| | | } |
| | | // 查楼栋,街路巷 |
| | | if (houseParam.getType()==2){ |
| | |
| | | getGridInfoByGridman(houseParam); |
| | | // 查询商超 |
| | | List<FuncNode> doorplateNameList = baseMapper.getPlaceRelDetailList(houseParam); |
| | | // 按单元(网格)分组 |
| | | Map<String, List<FuncNode>> listMap = doorplateNameList.stream().collect(Collectors.groupingBy(FuncNode::getUnitName)); |
| | | // |
| | | List<FuncNode> tempList = new ArrayList<>(); |
| | | // 遍历 |
| | | listMap.forEach((s, temps) -> { |
| | | FuncNode funcNode = new FuncNode(); |
| | | funcNode.setUnitName(s); |
| | | funcNode.setAddressType(4); |
| | | funcNode.setUnitCode(temps.get(0).getUnitCode()); |
| | | funcNode.setChildren(temps); |
| | | // 查询网格对应的排序 |
| | | QueryWrapper<GridEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("community_code",funcNode.getUnitCode()).eq("grid_name",funcNode.getUnitName()); |
| | | // 查询网格 |
| | | GridEntity one = gridService.getOne(wrapper); |
| | | if (null!=one){ |
| | | funcNode.setSort(one.getSort()); |
| | | } |
| | | tempList.add(funcNode); |
| | | }); |
| | | // 排序 |
| | | List<FuncNode> sortList = tempList.stream().sorted(Comparator.comparing(X -> X.getSort())).collect(Collectors.toList()); |
| | | map.put("aoiList",new ArrayList<>()); |
| | | map.put("shopList",doorplateNameList); |
| | | map.put("shopList",sortList); |
| | | // 返回 |
| | | return map; |
| | | } |
| | |
| | | firstKey = key; |
| | | break; |
| | | } |
| | | if (firstKey.equals("未知单元")){ |
| | | // 取出数据按楼层分组 |
| | | List<FuncNode> unitList = listMap.get(firstKey); |
| | | Map<String, List<FuncNode>> floorListMap = unitList.stream().collect(Collectors.groupingBy(FuncNode::getFloor)); |
| | | List<FuncNode> funcNodeList = new ArrayList<>(); |
| | | floorListMap.forEach((s, temps) -> { |
| | | FuncNode funcNode = new FuncNode(); |
| | | funcNode.setFloor(s); |
| | | funcNode.setChildren(temps); |
| | | funcNode.setAddressType(1); |
| | | funcNodeList.add(funcNode); |
| | | }); |
| | | // 取出数据按楼层分组 |
| | | List<FuncNode> unitList = listMap.get(firstKey); |
| | | Map<String, List<FuncNode>> floorListMap = unitList.stream().collect(Collectors.groupingBy(FuncNode::getFloor)); |
| | | List<FuncNode> funcNodeList = new ArrayList<>(); |
| | | floorListMap.forEach((s, temps) -> { |
| | | FuncNode funcNode = new FuncNode(); |
| | | funcNode.setUnitName("一单元"); |
| | | funcNode.setChildren(funcNodeList); |
| | | funcNode.setFloor(s); |
| | | funcNode.setChildren(temps); |
| | | funcNode.setAddressType(1); |
| | | list.add(funcNode); |
| | | funcNodeList.add(funcNode); |
| | | }); |
| | | FuncNode funcNode = new FuncNode(); |
| | | if (firstKey.equals("未知单元")) { |
| | | funcNode.setUnitName("一单元"); |
| | | }else { |
| | | funcNode.setUnitName(firstKey); |
| | | } |
| | | funcNode.setChildren(funcNodeList); |
| | | funcNode.setAddressType(1); |
| | | list.add(funcNode); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据角色获取社区编号集合 |
| | | * @param houseParam |
| | | * @return |
| | | */ |
| | | private List<String> getCommunityCodeList(HouseParam houseParam) { |
| | | List<String> stringList = new ArrayList<>(); |
| | | String userId = AuthUtil.getUserId().toString(); |
| | | houseParam.setUserId(userId); |
| | | if (null != houseParam.getRoleName() && !houseParam.getRoleName().equals("")) { |
| | | if (houseParam.getRoleName().equals("民警") && !userId.equals("1726859808689696770")) { |
| | | // 查询对应的房屋地址code |
| | | stringList = communityService.getCommunityCodeListByUserId(AuthUtil.getUserId()); |
| | | } |
| | | } |
| | | return stringList; |
| | | } |
| | | |
| | | /** |
| | | * 房屋数据处理 |
| | | * @return |
| | | */ |
| | |
| | | placeEntity.setPlaceName(addressEntity.getPoi()); |
| | | placeEntity.setLng(addressEntity.getX()); |
| | | placeEntity.setLat(addressEntity.getY()); |
| | | placeEntity.setLocaltion(addressEntity.getAddressName()); |
| | | placeEntity.setLocation(addressEntity.getAddressName()); |
| | | // 设置来源( 1:地址总表 2:国控采集) |
| | | placeEntity.setSource(1); |
| | | // 加入集合 |
| | |
| | | // 扫码时调用,需判断是否有权限查看 |
| | | DoorplateAddressVO one = baseMapper.getDoorplateAddressVODetail(doorplateAddress); |
| | | if (null!=one){ |
| | | // 不限制 |
| | | one.setIsJur(1); |
| | | if (!Strings.isBlank(doorplateAddress.getRoleName())) { |
| | | // 判断是否有权限 |
| | | if (doorplateAddress.getRoleName().equals("网格员")) { |
| | | list = gridService.getAddressCodeListByUserId(AuthUtil.getUserId()); |
| | | boolean contains = list.contains(doorplateAddress.getAddressCode()); |
| | | if (list.size()==0 || !contains){ |
| | | // 无权限 |
| | | one.setIsJur(2); |
| | | }else { |
| | | one.setIsJur(1); |
| | | } |
| | | }else if (doorplateAddress.getRoleName().equals("民警")){ |
| | | // 查询对应的社区code |
| | | list = communityService.getCommunityCodeListByUserId(AuthUtil.getUserId()); |
| | | boolean contains = list.contains(doorplateAddress.getNeiCode().replaceAll("0+$", "")); |
| | | if (list.size()==0 || !contains){ |
| | | // 无权限 |
| | | one.setIsJur(2); |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 社区数据处理 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object communityDataHandle() { |
| | | // 查询所有的社区差值 |
| | | List<DoorplateAddressEntity> doorplateAddressEntities = baseMapper.getAllCommunityList(); |
| | | // 遍历,插入库 |
| | | for (DoorplateAddressEntity doorplateAddressEntity : doorplateAddressEntities) { |
| | | QueryWrapper<CommunityEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("name",doorplateAddressEntity.getNeiName()) |
| | | .eq("code",doorplateAddressEntity.getNeiCode()) |
| | | .eq("is_deleted",0); |
| | | CommunityEntity one = communityService.getOne(queryWrapper); |
| | | if (null==one){ |
| | | // 插入 |
| | | CommunityEntity communityEntity = new CommunityEntity(); |
| | | communityEntity.setCode(doorplateAddressEntity.getNeiCode()); |
| | | communityEntity.setName(doorplateAddressEntity.getNeiName()); |
| | | communityEntity.setStreetCode(doorplateAddressEntity.getTownStreetCode().replaceAll("0+$", "")); |
| | | //新增操作 |
| | | communityService.save(communityEntity); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |