| | |
| | | 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.cache.SysCache; |
| | | import org.springblade.common.constant.DictConstant; |
| | | import org.springblade.common.node.TreeStringNode; |
| | | import org.springblade.common.param.CommonParamSet; |
| | | import org.springblade.common.utils.ComplexNumberStringComparator; |
| | | import org.springblade.common.utils.NodeTreeUtil; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | 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.backblast.entity.BackblastPubRecordEntity; |
| | | 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; |
| | |
| | | import org.springblade.modules.doorplateAddress.vo.DoorplateAddressVOTree; |
| | | import org.springblade.modules.doorplateAddress.vo.FuncNode; |
| | | import org.springblade.modules.grid.entity.GridEntity; |
| | | import org.springblade.modules.grid.entity.GridRangeEntity; |
| | | import org.springblade.modules.grid.entity.GridmanEntity; |
| | | import org.springblade.modules.grid.service.IGridRangeService; |
| | | import org.springblade.modules.grid.service.IGridService; |
| | | import org.springblade.modules.grid.service.IGridmanService; |
| | | import org.springblade.modules.grid.vo.GridVO; |
| | | import org.springblade.modules.house.entity.HouseEntity; |
| | | import org.springblade.modules.house.entity.UserHouseLabelEntity; |
| | | import org.springblade.modules.house.service.IHouseRentalService; |
| | | import org.springblade.modules.house.service.IHouseService; |
| | | import org.springblade.modules.house.service.IHouseholdService; |
| | | import org.springblade.modules.house.service.IUserHouseLabelService; |
| | | import org.springblade.modules.house.vo.HouseParam; |
| | | import org.springblade.modules.house.vo.HouseRentalVO; |
| | | import org.springblade.modules.house.vo.HouseholdVO; |
| | | import org.springblade.modules.place.entity.PlaceEntity; |
| | | import org.springblade.modules.place.entity.PlaceExtEntity; |
| | | import org.springblade.modules.place.service.IPlaceExtService; |
| | | import org.springblade.modules.place.service.IPlaceService; |
| | | import org.springblade.modules.place.vo.PlaceVO; |
| | | import org.springblade.modules.police.entity.PoliceAffairsGridEntity; |
| | | import org.springblade.modules.police.service.IPoliceAffairsGridService; |
| | | import org.springblade.modules.system.entity.Region; |
| | | import org.springblade.modules.system.service.IRegionService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private IPlaceService placeService; |
| | | |
| | | @Autowired |
| | | private IPlaceExtService placeExtService; |
| | | |
| | | @Autowired |
| | | private IHouseService houseService; |
| | |
| | | private IDistrictService districtService; |
| | | |
| | | @Autowired |
| | | private ICategoryLabelService iCategoryLabelService; |
| | | private ICategoryService iCategoryService; |
| | | |
| | | @Autowired |
| | | private ICommunityService communityService; |
| | | |
| | | @Autowired |
| | | private IPoliceAffairsGridService policeAffairsGridService; |
| | | |
| | | |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 根据角色获取功能集合数据 |
| | | * @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<>(); |
| | | if (null!=roleName && !roleName.equals("")){ |
| | | houseParam.setRoleName(roleName); |
| | | if (roleName.equals("网格员") && !userId.equals("1726859808689696770")){ |
| | | // 查询对应的房屋地址code |
| | | stringList = gridService.getAddressCodeListByUserId(AuthUtil.getUserId()); |
| | | } |
| | | } |
| | | List<String> communityList = new ArrayList<>(); |
| | | List<TreeStringNode> list = new ArrayList<>(); |
| | | if (null!=type) { |
| | | // 如果是网格管理员,系统管理员 |
| | | if (type==1){ |
| | | // 查询街道 |
| | | List<TreeStringNode> townList = baseMapper.getRegionListByGroupTwon(houseParam,stringList); |
| | | // 查询社区 |
| | | List<TreeStringNode> neiList = baseMapper.getRegionListByGroupNei(houseParam,stringList); |
| | | // 获取请求头中的角色别名 |
| | | 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.getGridRegionChildCodesByDeptId(AuthUtil.getDeptId(),null,roleName); |
| | | } |
| | | // 查询街道 |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * 获取居民角色对应的房屋,场所信息 |
| | | * |
| | | * @param list |
| | | * @return |
| | | */ |
| | |
| | | List<TreeStringNode> houseNodeList = householdService.selectHouseNodeList(AuthUtil.getUserId()); |
| | | for (TreeStringNode treeNode : houseNodeList) { |
| | | // 判断房屋类型类型 |
| | | if (DictConstant.SMALL_DOORPLATE.equals(treeNode.getDoorplateType()) || |
| | | if (DictConstant.SMALL_DOORPLATE.equals(treeNode.getDoorplateType()) || |
| | | (DictConstant.centre_DOORPLATE.equals(treeNode.getDoorplateType()) && |
| | | treeNode.getAddressLevel().equals(1))) { |
| | | treeNode.setAddressType(2); |
| | |
| | | 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.setName("经营场所"); |
| | | placeNode.setId("2"); |
| | | placeNode.setHasChildren(true); |
| | | placeNode.setChildren(placeNodeList); |
| | | |
| | | list.add(houseNode); |
| | | list.add(placeNode); |
| | | // 返回 |
| | | return list; |
| | | } |
| | | if (houseNodeList.size()>0){ |
| | | list = houseNodeList; |
| | | if (houseNodeList.size() > 0) { |
| | | TreeStringNode houseNode = new TreeStringNode(); |
| | | houseNode.setName("房屋"); |
| | | houseNode.setId("1"); |
| | | houseNode.setHasChildren(true); |
| | | houseNode.setChildren(houseNodeList); |
| | | list.add(houseNode); |
| | | } |
| | | if (placeNodeList.size()>0){ |
| | | list = placeNodeList; |
| | | if (placeNodeList.size() > 0) { |
| | | TreeStringNode placeNode = new TreeStringNode(); |
| | | placeNode.setName("经营场所"); |
| | | placeNode.setId("2"); |
| | | placeNode.setHasChildren(true); |
| | | placeNode.setChildren(placeNodeList); |
| | | list.add(placeNode); |
| | | } |
| | | // 返回 |
| | | return list; |
| | |
| | | |
| | | /** |
| | | * 获取楼盘相关集合数据 |
| | | * |
| | | * @param houseParam |
| | | * @return |
| | | */ |
| | |
| | | public Object getHousesList(HouseParam houseParam) { |
| | | List<TreeStringNode> list = new ArrayList<>(); |
| | | Map<String, Object> map = new HashMap<>(2); |
| | | String roleName = SpringUtils.getRequestParam("roleName"); |
| | | if (!Strings.isBlank(roleName)){ |
| | | houseParam.setRoleName(roleName); |
| | | } |
| | | // 获取网格员对应的地址编号集合 |
| | | List<String> stringList = getHouseCodeList(houseParam); |
| | | List<String> addressCodeList = getHouseCodeList(houseParam); |
| | | List<String> communityCodeList = getCommunityCodeList(houseParam); |
| | | // 获取网格员对应的网格信息 |
| | | getGridInfoByGridman(houseParam); |
| | | // 查小区,场所 |
| | | if (houseParam.getType()==1){ |
| | | if (houseParam.getType() == 1) { |
| | | // 根据社区名称查询小区集合 |
| | | list = baseMapper.getDistrictList(houseParam,stringList); |
| | | list = baseMapper.getDistrictList(houseParam, addressCodeList, communityCodeList); |
| | | } |
| | | // 查楼栋,街路巷 |
| | | if (houseParam.getType()==2){ |
| | | return getBuildLevelData(houseParam,map); |
| | | if (houseParam.getType() == 2) { |
| | | return getBuildLevelData(houseParam,addressCodeList, map); |
| | | } |
| | | // 查户室 |
| | | if (houseParam.getType()==3){ |
| | | return getHouseLevelData(houseParam, map); |
| | | if (houseParam.getType() == 3) { |
| | | return getHouseLevelData(houseParam,addressCodeList, map); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取网格员对应的网格信息 |
| | | * |
| | | * @param houseParam |
| | | */ |
| | | private void getGridInfoByGridman(HouseParam houseParam) { |
| | | if (houseParam.getRoleName().equals("网格员")) { |
| | | QueryWrapper<GridmanEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted", 0) |
| | | .eq("user_id", AuthUtil.getUserId()); |
| | | List<GridmanEntity> list = gridmanService.list(wrapper); |
| | | if (list.size() > 0) { |
| | | GridmanEntity gridmanEntity = list.get(0); |
| | | GridEntity gridEntity = gridService.getById(gridmanEntity.getGridId()); |
| | | // 查询居委会 |
| | | Region region = regionService.getById(gridEntity.getCommunityCode()); |
| | | if (null != region) { |
| | | houseParam.setCommunityName(region.getName()); |
| | | } |
| | | if (!Strings.isBlank(gridEntity.getGridName())) { |
| | | houseParam.setGridName(gridEntity.getGridName()); |
| | | } |
| | | if (houseParam.getRoleName().equals("wgy")) { |
| | | if (Strings.isBlank(houseParam.getRoleName())){ |
| | | houseParam.setRoleName(SpringUtils.getRequestParam("roleName")); |
| | | } |
| | | // 查询网格员的网格编号集合 |
| | | List<String> gridCodeList |
| | | = SysCache.getGridRegionChildCodesByDeptId(AuthUtil.getDeptId(), null, houseParam.getRoleName()); |
| | | String communityCode = SpringUtils.getRequestParam("communityCode"); |
| | | List<GridVO> list = gridService.getGridListByComAndList(communityCode,gridCodeList); |
| | | if (list.size()>0){ |
| | | GridVO grid = list.get(0); |
| | | houseParam.setCommunityName(grid.getCommunityName()); |
| | | houseParam.setGridName(grid.getGridName()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询户室级别数据 |
| | | * |
| | | * @param houseParam |
| | | * @param map |
| | | * @return |
| | | */ |
| | | private Map<String, Object> getHouseLevelData(HouseParam houseParam, Map<String, Object> map) { |
| | | List<String> stringList = getHouseCodeList(houseParam); |
| | | private Map<String, Object> getHouseLevelData(HouseParam houseParam, List<String> stringList,Map<String, Object> map) { |
| | | // 判断地址类型 |
| | | if (houseParam.getAddressType()==1) { |
| | | if (houseParam.getAddressType() == 1) { |
| | | List<FuncNode> aoiList = new ArrayList<>(); |
| | | List<FuncNode> shopList = new ArrayList<>(); |
| | | // 查询户室及住户相关信息,单元中包含住户,或者和单元平级的 商铺 |
| | | List<FuncNode> householdList = getUnitHouseholdList(houseParam,stringList); |
| | | List<FuncNode> householdList = getUnitHouseholdList(houseParam, stringList); |
| | | // 遍历 |
| | | if (householdList.size()>0){ |
| | | if (householdList.size() > 0) { |
| | | for (FuncNode funcNode : householdList) { |
| | | if (funcNode.getAddressType()==1){ |
| | | if (funcNode.getAddressType() == 1) { |
| | | aoiList.add(funcNode); |
| | | } |
| | | if (funcNode.getAddressType()==2){ |
| | | if (funcNode.getAddressType() == 2) { |
| | | shopList.add(funcNode); |
| | | } |
| | | } |
| | | } |
| | | map.put("aoiList",aoiList); |
| | | map.put("shopList",shopList); |
| | | map.put("aoiList", aoiList); |
| | | map.put("shopList", shopList); |
| | | // 返回 |
| | | return map; |
| | | } |
| | | if(houseParam.getAddressType()==3){ |
| | | if (houseParam.getAddressType() == 3) { |
| | | // 根据街路巷编号查询街路巷门牌名称集合 |
| | | List<FuncNode> doorplateNameList = baseMapper.getDoorplateNameList(houseParam,stringList); |
| | | map.put("aoiList",new ArrayList<>()); |
| | | map.put("shopList",doorplateNameList); |
| | | List<FuncNode> doorplateNameList = baseMapper.getDoorplateNameList(houseParam, stringList); |
| | | map.put("aoiList", new ArrayList<>()); |
| | | map.put("shopList", doorplateNameList); |
| | | // 返回 |
| | | return map; |
| | | } |
| | | if(houseParam.getAddressType()==4){ |
| | | if (houseParam.getAddressType() == 4) { |
| | | getGridInfoByGridman(houseParam); |
| | | // 查询商超 |
| | | List<FuncNode> doorplateNameList = baseMapper.getPlaceRelDetailList(houseParam); |
| | | map.put("aoiList",new ArrayList<>()); |
| | | map.put("shopList",doorplateNameList); |
| | | // 按单元(网格)分组 |
| | | 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", sortList); |
| | | // 返回 |
| | | return map; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 获取楼栋层级数据 |
| | | * |
| | | * @param houseParam |
| | | * @param map |
| | | * @return |
| | | */ |
| | | private Object getBuildLevelData(HouseParam houseParam,Map<String, Object> map) { |
| | | if (houseParam.getAddressType()==4){ |
| | | private Object getBuildLevelData(HouseParam houseParam,List<String> stringList, Map<String, Object> map) { |
| | | if (houseParam.getAddressType() == 4) { |
| | | // 获取网格员对应的网格信息 |
| | | getGridInfoByGridman(houseParam); |
| | | // 查询商超 |
| | |
| | | map.put("shopList", list); |
| | | // 返回 |
| | | return map; |
| | | }else { |
| | | List<String> stringList = getHouseCodeList(houseParam); |
| | | } else { |
| | | // 判断 code 长度,如果 code 长度大于 12 则为小区查楼栋/商铺,否则则按社区查街路巷 |
| | | if (houseParam.getCode().length() > 12) { |
| | | List<TreeStringNode> aoiList = new ArrayList<>(); |
| | |
| | | sorted(new Comparator<TreeStringNode>() { |
| | | @Override |
| | | public int compare(TreeStringNode o1, TreeStringNode o2) { |
| | | return ComplexNumberStringComparator.compare(o1.getName(),o2.getName()); |
| | | return ComplexNumberStringComparator.compare(o1.getName(), o2.getName()); |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | if (list.size() > 0) { |
| | |
| | | |
| | | /** |
| | | * 查询户室及住户相关信息,单元中包含住户 |
| | | * |
| | | * @param houseParam |
| | | * @param stringList |
| | | * @return |
| | | */ |
| | | private List<FuncNode> getUnitHouseholdList(HouseParam houseParam,List<String> stringList) { |
| | | private List<FuncNode> getUnitHouseholdList(HouseParam houseParam, List<String> stringList) { |
| | | List<FuncNode> list = new ArrayList<>(); |
| | | // 查询户室及住户相关信息,单元中包含住户 |
| | | List<FuncNode> funcNodes = baseMapper.getUnitHouseholdList(houseParam,stringList); |
| | | List<FuncNode> funcNodes = baseMapper.getUnitHouseholdList(houseParam, stringList); |
| | | // 遍历 |
| | | List<FuncNode> aoiNodes = new ArrayList<>(); |
| | | List<FuncNode> shopNodes = new ArrayList<>(); |
| | | List<FuncNode> aoiNodes = new ArrayList<>(); |
| | | List<FuncNode> shopNodes = new ArrayList<>(); |
| | | for (FuncNode funcNode : funcNodes) { |
| | | if (funcNode.getAddressType()==1){ |
| | | if (funcNode.getAddressType() == 1) { |
| | | aoiNodes.add(funcNode); |
| | | } |
| | | if (funcNode.getAddressType()==2){ |
| | | if (funcNode.getAddressType() == 2) { |
| | | shopNodes.add(funcNode); |
| | | } |
| | | } |
| | | // 处理,先按单元分组,再按楼层分组 |
| | | if (aoiNodes.size()>0){ |
| | | if (aoiNodes.size() > 0) { |
| | | // 按单元分组 |
| | | Map<String, List<FuncNode>> listMap = aoiNodes.stream().collect(Collectors.groupingBy(FuncNode::getUnitName)); |
| | | // 单个单元 |
| | |
| | | |
| | | /** |
| | | * 单个单元处理 |
| | | * |
| | | * @param list |
| | | * @param listMap |
| | | */ |
| | | private void oneUnitHandle(List<FuncNode> list, Map<String, List<FuncNode>> listMap) { |
| | | if (listMap.size()==1){ |
| | | if (listMap.size() == 1) { |
| | | Set<String> keySet = listMap.keySet(); |
| | | // 获取第一个key |
| | | String firstKey = null; |
| | |
| | | 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 list |
| | | * @param listMap |
| | | */ |
| | | private void moreUnitHandle(List<FuncNode> list, Map<String, List<FuncNode>> listMap) { |
| | | // 不止一个单元 |
| | | if (listMap.size()>1){ |
| | | if (listMap.size() > 1) { |
| | | List<FuncNode> tempList = new ArrayList<>(); |
| | | // 遍历 |
| | | listMap.forEach((s, temps) -> { |
| | |
| | | funcNode.setAddressType(1); |
| | | // 按楼层分组 |
| | | Map<String, List<FuncNode>> floorListMap = temps.stream().collect(Collectors.groupingBy(FuncNode::getFloor)); |
| | | List<FuncNode> floorNodeList = new ArrayList<>(); |
| | | List<FuncNode> floorNodeList = new ArrayList<>(); |
| | | floorListMap.forEach((floor, houseList) -> { |
| | | FuncNode floorNode = new FuncNode(); |
| | | floorNode.setFloor(floor); |
| | |
| | | tempList.add(funcNode); |
| | | }); |
| | | // 排序 |
| | | sortUnit(tempList,list); |
| | | // List<FuncNode> sortList = tempList.stream().sorted(Comparator.comparing(X -> X.getUnitName())).collect(Collectors.toList()); |
| | | // list.addAll(sortList); |
| | | sortUnit(tempList, list); |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 单元排序 |
| | | * |
| | | * @param tempList |
| | | * @param list |
| | | */ |
| | | private void sortUnit(List<FuncNode> tempList,List<FuncNode> list) { |
| | | private void sortUnit(List<FuncNode> tempList, List<FuncNode> list) { |
| | | // 遍历 |
| | | if(tempList.size()>1){ |
| | | if (tempList.size() > 1) { |
| | | for (FuncNode funcNode : tempList) { |
| | | if (funcNode.getUnitName().contains("一")){ |
| | | if (funcNode.getUnitName().contains("一")) { |
| | | funcNode.setSort(1); |
| | | } |
| | | if (funcNode.getUnitName().contains("二")){ |
| | | } else if (funcNode.getUnitName().contains("二")) { |
| | | funcNode.setSort(2); |
| | | } |
| | | if (funcNode.getUnitName().contains("三")){ |
| | | } else if (funcNode.getUnitName().contains("三")) { |
| | | funcNode.setSort(3); |
| | | } |
| | | if (funcNode.getUnitName().contains("四")){ |
| | | } else if (funcNode.getUnitName().contains("四")) { |
| | | funcNode.setSort(4); |
| | | } |
| | | if (funcNode.getUnitName().contains("五")){ |
| | | } else if (funcNode.getUnitName().contains("五")) { |
| | | funcNode.setSort(5); |
| | | } |
| | | if (funcNode.getUnitName().contains("六")){ |
| | | } else if (funcNode.getUnitName().contains("六")) { |
| | | funcNode.setSort(6); |
| | | } else { |
| | | if (!containsNumber(funcNode.getUnitName())) { |
| | | funcNode.setSort(1); |
| | | } else { |
| | | funcNode.setSort(getNumber(funcNode.getUnitName())); |
| | | } |
| | | } |
| | | } |
| | | // 排序 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 判断是否包含数字 |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static boolean containsNumber(String str) { |
| | | Pattern pattern = Pattern.compile(".*\\d+.*"); |
| | | Matcher matcher = pattern.matcher(str); |
| | | return matcher.matches(); |
| | | } |
| | | |
| | | /** |
| | | * 取出字符串中的数字 |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static int getNumber(String str) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (char c : str.toCharArray()) { |
| | | if (Character.isDigit(c)) { |
| | | sb.append(c); |
| | | } |
| | | } |
| | | return Integer.parseInt(sb.toString()); |
| | | } |
| | | |
| | | /** |
| | | * 查询房屋及出租详情信息 |
| | | * |
| | | * @param code 门牌地址编号 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object getHouseRentInfo(String code) { |
| | | // 先查询门牌信息 |
| | | DoorplateAddressVO doorplateAddressDetailVO = baseMapper.getDoorplateAddressDetailByCode(code); |
| | | if(null!= doorplateAddressDetailVO) { |
| | | public Object getHouseRentInfo(String code,Long houseId) { |
| | | DoorplateAddressVO doorplateAddressDetailVO = new DoorplateAddressVO(); |
| | | if (Strings.isBlank(code) && null!=houseId) { |
| | | // 先查询门牌信息 |
| | | doorplateAddressDetailVO = baseMapper.getDoorplateAddressDetailByHouseId(houseId); |
| | | }else { |
| | | // 先查询门牌信息 |
| | | doorplateAddressDetailVO = baseMapper.getDoorplateAddressDetailByCode(code); |
| | | } |
| | | if (null != doorplateAddressDetailVO) { |
| | | // 查询房屋出租情况 |
| | | List<HouseRentalVO> houseRentalVOS = houseRentalService.getHouseRentalListByCode(code); |
| | | // 查询房屋人员情况 |
| | |
| | | List<DoorplateAddressVOTree> list = new ArrayList<>(); |
| | | |
| | | |
| | | if (type.equals("townStreet")){ |
| | | if (type.equals("townStreet")) { |
| | | //获取所有街道街道 |
| | | list = baseMapper.getTownStreetVOTreeList(); |
| | | }else if (type.equals("nei")){ |
| | | list= baseMapper.getNeiVOTreeList(code); |
| | | }else if (type.equals("streetRu")){ |
| | | } else if (type.equals("nei")) { |
| | | list = baseMapper.getNeiVOTreeList(code); |
| | | } else if (type.equals("streetRu")) { |
| | | list = baseMapper.getStreetRuVOTreeList(code); |
| | | }else if (type.equals("district")){ |
| | | list=baseMapper.getDistrictVOTreeList(code); |
| | | }else if (type.equals("building")){ |
| | | } else if (type.equals("district")) { |
| | | list = baseMapper.getDistrictVOTreeList(code); |
| | | } else if (type.equals("building")) { |
| | | list = baseMapper.getBuildingVOTreeList(code); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 根据参数获取地址详情 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 查询社区信息 |
| | | * @param name |
| | | * |
| | | * @param doorplateAddressEntity |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DoorplateAddressEntity> getAllDoorplateAddress(String name) { |
| | | return baseMapper.getAllDoorplateAddress(name); |
| | | public List<DoorplateAddressEntity> getAllDoorplateAddress(DoorplateAddressEntity doorplateAddressEntity) { |
| | | return baseMapper.getAllDoorplateAddress(doorplateAddressEntity); |
| | | } |
| | | |
| | | /** |
| | | * 获取房屋树 |
| | | * |
| | | * @param houseParam |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DoorplateAddressVOTree> getHouseTree(HouseParam houseParam) { |
| | | String roleName = SpringUtils.getRequestParam("roleName"); |
| | | if (!Strings.isBlank(roleName)){ |
| | | houseParam.setRoleName(roleName); |
| | | } |
| | | List<String> stringList = getHouseCodeList(houseParam); |
| | | // 根据社区居委会编号获取对应的小区/楼栋/单元/户室 |
| | | return NodeTreeUtil.getAddressNodeTree(baseMapper.getHouseTree(houseParam,stringList)); |
| | | return NodeTreeUtil.getAddressNodeTree(baseMapper.getHouseTree(houseParam, stringList)); |
| | | } |
| | | |
| | | /** |
| | | * 根据角色获取地址编号集合 |
| | | * |
| | | * @param houseParam |
| | | * @return |
| | | */ |
| | | private List<String> getHouseCodeList(HouseParam houseParam) { |
| | | List<String> addressCodeList = new ArrayList<>(); |
| | | String userId = AuthUtil.getUserId().toString(); |
| | | houseParam.setUserId(userId); |
| | | if (null != houseParam.getRoleName() && !houseParam.getRoleName().equals("")) { |
| | | if ((houseParam.getRoleName().equals("wgy") || houseParam.getRoleName().equals("wzcj")) |
| | | && !userId.equals("1726859808689696770")) { |
| | | // 先取对应网格员对应的网格编号集合 |
| | | List<String> gridCodeList |
| | | = SysCache.getGridRegionChildCodesByDeptId(AuthUtil.getDeptId(), null, houseParam.getRoleName()); |
| | | // 查询对应的房屋地址code |
| | | // addressCodeList = gridService.getAddressCodeListByUserId(AuthUtil.getUserId(),null); |
| | | addressCodeList = |
| | | gridService.getAddressCodeListByGridCodeList(SpringUtils.getRequestParam("communityCode"),gridCodeList); |
| | | } |
| | | } |
| | | return addressCodeList; |
| | | } |
| | | |
| | | /** |
| | | * 根据角色获取社区编号集合 |
| | | * |
| | | * @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 = gridService.getAddressCodeListByUserId(AuthUtil.getUserId()); |
| | | if (houseParam.getRoleName().equals("mj") && !userId.equals("1726859808689696770")) { |
| | | // 查询对应社区编号集合 |
| | | stringList = SysCache.getGridRegionChildCodesByDeptId(AuthUtil.getDeptId(),null,houseParam.getRoleName()); |
| | | } |
| | | } |
| | | return stringList; |
| | |
| | | |
| | | /** |
| | | * 房屋数据处理 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object houseDataHandle() { |
| | | public Object houseDataHandle(String townName) { |
| | | // 处理房屋数据 |
| | | handleHouseData(); |
| | | handleHouseData(townName); |
| | | |
| | | return null; |
| | | } |
| | |
| | | /** |
| | | * 处理房屋数据 |
| | | */ |
| | | private void handleHouseData() { |
| | | // 查询所有户室数据(未入库的) |
| | | List<DoorplateAddressEntity> list = baseMapper.getHouseList(); |
| | | // 需要新增的房屋 list |
| | | List<HouseEntity> houseList = new ArrayList<>(); |
| | | // 处理户室数据 |
| | | for (DoorplateAddressEntity doorplateAddressEntity : list) { |
| | | // 查询是否已存在,存在就插入,不存在则插入 |
| | | QueryWrapper<HouseEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("house_code",doorplateAddressEntity.getAddressCode()) |
| | | .eq("is_deleted",0); |
| | | HouseEntity one = houseService.getOne(wrapper); |
| | | if (null==one){ |
| | | HouseEntity houseEntity = new HouseEntity(); |
| | | houseEntity.setHouseCode(doorplateAddressEntity.getAddressCode()); |
| | | houseEntity.setDistrictCode(doorplateAddressEntity.getAoiCode()); |
| | | houseEntity.setDistrictName(doorplateAddressEntity.getAoiName()); |
| | | houseEntity.setHouseName(doorplateAddressEntity.getAddressName()); |
| | | houseEntity.setFloor(doorplateAddressEntity.getFloor()); |
| | | houseEntity.setBuilding(doorplateAddressEntity.getBuildingName()); |
| | | houseEntity.setUnit(doorplateAddressEntity.getUnitName()); |
| | | houseEntity.setRoom(doorplateAddressEntity.getHouseName()); |
| | | houseEntity.setBuildingNo(doorplateAddressEntity.getBuildingCode()); |
| | | houseEntity.setCreateUser(AuthUtil.getUserId().toString()); |
| | | houseEntity.setCreateTime(new Date()); |
| | | houseEntity.setUpdateUser(AuthUtil.getUserId().toString()); |
| | | houseEntity.setUpdateTime(new Date()); |
| | | // 设置来源 1:地址总表 2:国控采集 |
| | | houseEntity.setSource(1); |
| | | // 加入集合 |
| | | houseList.add(houseEntity); |
| | | private void handleHouseData(String townName) { |
| | | // 查询总数 |
| | | Integer count = baseMapper.getNotHouseListCount(townName); |
| | | if (count > 0) { |
| | | int num = count / 1000; |
| | | for (int i = 0; i <= num + 1; i++) { |
| | | // 查询所有户室数据(未入库的) |
| | | List<DoorplateAddressEntity> list = baseMapper.getHouseList(townName); |
| | | // 需要新增的房屋 list |
| | | List<HouseEntity> houseList = new ArrayList<>(); |
| | | // 处理户室数据 |
| | | for (DoorplateAddressEntity doorplateAddressEntity : list) { |
| | | // 查询是否已存在,存在就插入,不存在则插入 |
| | | QueryWrapper<HouseEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("house_code", doorplateAddressEntity.getAddressCode()) |
| | | .eq("is_deleted", 0); |
| | | HouseEntity one = houseService.getOne(wrapper); |
| | | if (null == one) { |
| | | HouseEntity houseEntity = new HouseEntity(); |
| | | houseEntity.setHouseCode(doorplateAddressEntity.getAddressCode()); |
| | | houseEntity.setDistrictCode(doorplateAddressEntity.getAoiCode()); |
| | | houseEntity.setDistrictName(doorplateAddressEntity.getAoiName()); |
| | | houseEntity.setLng(doorplateAddressEntity.getX()); |
| | | houseEntity.setLat(doorplateAddressEntity.getY()); |
| | | houseEntity.setHouseName(doorplateAddressEntity.getAddressName()); |
| | | houseEntity.setAddress(doorplateAddressEntity.getAddressName()); |
| | | houseEntity.setFloor(doorplateAddressEntity.getFloor()); |
| | | houseEntity.setBuilding(doorplateAddressEntity.getBuildingName()); |
| | | houseEntity.setUnit(doorplateAddressEntity.getUnitName()); |
| | | houseEntity.setRoom(doorplateAddressEntity.getHouseName()); |
| | | houseEntity.setBuildingNo(doorplateAddressEntity.getBuildingCode()); |
| | | houseEntity.setCreateUser(AuthUtil.getUserId().toString()); |
| | | houseEntity.setCreateTime(new Date()); |
| | | houseEntity.setUpdateUser(AuthUtil.getUserId().toString()); |
| | | houseEntity.setUpdateTime(new Date()); |
| | | // 设置来源 1:地址总表 2:国控采集 |
| | | houseEntity.setSource(1); |
| | | // 根据位置设置网格,警格编号 |
| | | String point = "'POINT(" + doorplateAddressEntity.getX() + " " + doorplateAddressEntity.getY() + ")'"; |
| | | //点坐标解析网格 |
| | | List<GridEntity> gridEntityList = gridService.spatialAnalysis(point); |
| | | if (gridEntityList.size()>0){ |
| | | GridEntity gridEntity = gridEntityList.get(0); |
| | | houseEntity.setGridId(gridEntity.getId()); |
| | | houseEntity.setGridCode(gridEntity.getGridCode()); |
| | | } |
| | | //点坐标解析警格 |
| | | List<PoliceAffairsGridEntity> policeAffairsGridEntityList = policeAffairsGridService.spatialAnalysis(point); |
| | | if (policeAffairsGridEntityList.size()>0){ |
| | | PoliceAffairsGridEntity policeAffairsGridEntity = policeAffairsGridEntityList.get(0); |
| | | houseEntity.setJwGridCode(policeAffairsGridEntity.getJwGridCode()); |
| | | } |
| | | // 加入集合 |
| | | houseList.add(houseEntity); |
| | | } |
| | | } |
| | | // 批量插入 |
| | | houseService.saveBatch(houseList); |
| | | } |
| | | } |
| | | // 批量插入 |
| | | houseService.saveBatch(houseList); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 小区数据处理 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | for (DoorplateAddressEntity addressEntity : list) { |
| | | // 查询小区是否已存在,不存在则插入,否则不新增 |
| | | QueryWrapper<DistrictEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("aoi_code",addressEntity.getAoiCode()) |
| | | .eq("is_deleted",0); |
| | | wrapper.eq("aoi_code", addressEntity.getAoiCode()) |
| | | .eq("is_deleted", 0); |
| | | DistrictEntity one = districtService.getOne(wrapper); |
| | | if (null==one) { |
| | | if (null == one) { |
| | | DistrictEntity districtEntity = new DistrictEntity(); |
| | | districtEntity.setCommunityCode(addressEntity.getNeiCode()); |
| | | districtEntity.setAoiCode(addressEntity.getAoiCode()); |
| | |
| | | // 加入集合 |
| | | districtService.save(districtEntity); |
| | | // aoiList.add(districtEntity); |
| | | } else { |
| | | // 更新 |
| | | one.setCommunityCode(addressEntity.getNeiCode()); |
| | | one.setAoiCode(addressEntity.getAoiCode()); |
| | | one.setName(addressEntity.getAoiName()); |
| | | one.setAddress(addressEntity.getAddressName()); |
| | | one.setLng(addressEntity.getX()); |
| | | one.setLat(addressEntity.getY()); |
| | | // 加入集合 |
| | | districtService.updateById(one); |
| | | } |
| | | } |
| | | // 批量插入 |
| | |
| | | |
| | | /** |
| | | * 场所数据处理 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Object placeDataHandle() { |
| | | public Object placeDataHandle(String townName) { |
| | | // 查询所有的地址表和场所表差集集合 |
| | | List<DoorplateAddressEntity> list = baseMapper.getPlaceList(); |
| | | List<DoorplateAddressEntity> list = baseMapper.getNotInPlaceList(townName); |
| | | // 创建场所集合对象 |
| | | List<PlaceEntity> placeList = new ArrayList<>(); |
| | | if (list.size()>0) { |
| | | if (list.size() > 0) { |
| | | // 将场所数据保存到场所表中 |
| | | for (DoorplateAddressEntity addressEntity : list) { |
| | | // pio 名称不为空的进行插入操作 |
| | | // if (!Strings.isBlank(addressEntity.getPoi())) { |
| | | PlaceEntity placeEntity = new PlaceEntity(); |
| | | placeEntity.setHouseCode(addressEntity.getAddressCode()); |
| | | placeEntity.setPlaceName(addressEntity.getPoi()); |
| | | placeEntity.setLng(addressEntity.getX()); |
| | | placeEntity.setLat(addressEntity.getY()); |
| | | placeEntity.setLocaltion(addressEntity.getAddressName()); |
| | | // 设置来源( 1:地址总表 2:国控采集) |
| | | placeEntity.setLocation(addressEntity.getAddressName()); |
| | | // 设置来源( 1:地址总表 2:国控采集 3:商超) |
| | | placeEntity.setSource(1); |
| | | // 待完善 |
| | | placeEntity.setStatus(1); |
| | | // 默认为非九小场所 |
| | | placeEntity.setIsNine(2); |
| | | // 默认为现场采集 |
| | | placeEntity.setIsScene(1); |
| | | // 根据位置设置网格,警格编号 |
| | | String point = "'POINT(" + addressEntity.getX() + " " + addressEntity.getY() + ")'"; |
| | | //点坐标解析网格 |
| | | List<GridEntity> gridEntityList = gridService.spatialAnalysis(point); |
| | | if (gridEntityList.size()>0){ |
| | | GridEntity gridEntity = gridEntityList.get(0); |
| | | placeEntity.setGridId(gridEntity.getId()); |
| | | placeEntity.setGridCode(gridEntity.getGridCode()); |
| | | } |
| | | //点坐标解析警格 |
| | | List<PoliceAffairsGridEntity> policeAffairsGridEntityList = policeAffairsGridService.spatialAnalysis(point); |
| | | if (policeAffairsGridEntityList.size()>0){ |
| | | PoliceAffairsGridEntity policeAffairsGridEntity = policeAffairsGridEntityList.get(0); |
| | | placeEntity.setJwGridCode(policeAffairsGridEntity.getJwGridCode()); |
| | | } |
| | | // 加入集合 |
| | | placeList.add(placeEntity); |
| | | // placeList.add(placeEntity); |
| | | // 保存 |
| | | placeService.save(placeEntity); |
| | | // 新增场所详情 |
| | | savePlaceExtAndTaskInfo(placeEntity); |
| | | // } |
| | | } |
| | | // 批量插入 |
| | | placeService.saveBatch(placeList); |
| | | // savePlaceExtAndTaskInfo(placeList); |
| | | } |
| | | // 返回 |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 新增场所详情 |
| | | * |
| | | * @param placeEntity |
| | | */ |
| | | public void savePlaceExtAndTaskInfo(PlaceEntity placeEntity) { |
| | | PlaceExtEntity placeExtEntity = new PlaceExtEntity(); |
| | | placeExtEntity.setPlaceId(placeEntity.getId()); |
| | | // 判断是否已存在,已存在则不新增 |
| | | QueryWrapper<PlaceExtEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted", 0) |
| | | .eq("place_id", placeEntity.getId()); |
| | | PlaceExtEntity one = placeExtService.getOne(wrapper); |
| | | if (null == one) { |
| | | placeExtEntity.setPlaceId(placeEntity.getId()); |
| | | // 默认给待完善状态 |
| | | placeExtEntity.setConfirmFlag(4); |
| | | placeExtEntity.setCreateTime(new Date()); |
| | | placeExtEntity.setUpdateTime(new Date()); |
| | | placeExtEntity.setCreateUser(AuthUtil.getUserId()); |
| | | placeExtEntity.setUpdateUser(AuthUtil.getUserId()); |
| | | // 新增场所详情 |
| | | placeExtService.save(placeExtEntity); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | public Object getDetail(DoorplateAddressVO doorplateAddress) { |
| | | List<String> list = new ArrayList<>(); |
| | | // 扫码时调用,需判断是否有权限查看 |
| | | DoorplateAddressVO one = baseMapper.getDoorplateAddressVODetail(doorplateAddress); |
| | | if (null!=one){ |
| | | if (!Strings.isBlank(doorplateAddress.getRoleName())) { |
| | | DoorplateAddressVO doorplateAddressVO = baseMapper.getDoorplateAddressVODetail(doorplateAddress); |
| | | if (null != doorplateAddressVO) { |
| | | // 不限制 |
| | | doorplateAddressVO.setIsJur(1); |
| | | String roleName = SpringUtils.getRequestParam("roleName"); |
| | | if (!Strings.isBlank(roleName)) { |
| | | // 判断是否有权限 |
| | | 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); |
| | | if (roleName.equals("wgy") || roleName.equals("wzcj")) { |
| | | // 无权限 |
| | | doorplateAddressVO.setIsJur(2); |
| | | // list = gridService.getAddressCodeListByUserId(AuthUtil.getUserId(),doorplateAddress.getAddressCode()); |
| | | list = SysCache.getGridRegionChildCodesByDeptId(AuthUtil.getDeptId(),null,roleName); |
| | | if (null != list && list.size() > 0) { |
| | | List<String> arrayList = new ArrayList<>(); |
| | | for (String gridCode : list) { |
| | | if (gridCode.length()>12) { |
| | | arrayList.add(gridCode.substring(0, gridCode.length() - 2)); |
| | | }else { |
| | | arrayList.add(gridCode); |
| | | } |
| | | } |
| | | boolean contains = arrayList.contains(doorplateAddressVO.getNeiCode()); |
| | | if (contains) { |
| | | doorplateAddressVO.setIsJur(1); |
| | | } |
| | | } |
| | | }else { |
| | | }else if (roleName.equals("mj")) { |
| | | // 无权限 |
| | | doorplateAddressVO.setIsJur(2); |
| | | // 查询对应的社区code |
| | | list = SysCache.getGridRegionChildCodesByDeptId(AuthUtil.getDeptId(),null,roleName); |
| | | if (null != list && list.size() > 0) { |
| | | boolean contains = list.contains(doorplateAddressVO.getNeiCode()); |
| | | if (contains) { |
| | | doorplateAddressVO.setIsJur(1); |
| | | } |
| | | } |
| | | } else { |
| | | // 不限制 |
| | | one.setIsJur(1); |
| | | doorplateAddressVO.setIsJur(1); |
| | | } |
| | | } |
| | | return one; |
| | | if(doorplateAddressVO != null ){ |
| | | // 获取房屋标签 |
| | | IUserHouseLabelService userHouseLabelService = SpringUtils.getBean(IUserHouseLabelService.class); |
| | | List<UserHouseLabelEntity> houseLabelEntityList = userHouseLabelService.list(Wrappers.<UserHouseLabelEntity>lambdaQuery() |
| | | .eq(UserHouseLabelEntity::getHouseCode, doorplateAddressVO.getAddressCode()) |
| | | .eq(UserHouseLabelEntity::getLableType, 2)); |
| | | doorplateAddressVO.setUserHouseLabelVOList(houseLabelEntityList); |
| | | } |
| | | return doorplateAddressVO; |
| | | } |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * 查询场所标准地址数据 |
| | | * |
| | | * @param doorplateAddress |
| | | * @param size |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object getPlaceList(DoorplateAddressVO doorplateAddress, Integer size) { |
| | | // 公共参数设置 |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(DoorplateAddressVO.class, doorplateAddress); |
| | | return baseMapper.getPlaceList(doorplateAddress, |
| | | null == size ? 10 : size, |
| | | commonParamSet.getGridCodeList(), |
| | | commonParamSet.getRegionChildCodesList(), |
| | | commonParamSet.getIsAdministrator() |
| | | ); |
| | | } |
| | | |
| | | /** |
| | | * 通过小区id 查询楼栋编码 |
| | | * |
| | | * @param districtId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DoorplateAddressVO> getHouseBuildingCode(String districtId) { |
| | | return baseMapper.getHouseBuildingCode(districtId); |
| | | } |
| | | |
| | | /** |
| | | * 网格范围数据处理 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean gridRangeDataHandle(String townName,String communityName) { |
| | | // 查询未匹配的网格范围地址信息 |
| | | // 查询总数 |
| | | Integer count = baseMapper.getNotBindGridRangeDoorListCount(townName,communityName); |
| | | if (count > 0) { |
| | | IGridRangeService gridRangeService = SpringUtils.getBean(IGridRangeService.class); |
| | | int num = count / 1000; |
| | | for (int i = 0; i <= num + 1; i++) { |
| | | // 查询所有未匹配的网格范围地址数据 |
| | | List<DoorplateAddressEntity> list = baseMapper.getNotBindGridRangeDoorList(townName,communityName); |
| | | // 需要新增的网格范围 list |
| | | List<GridRangeEntity> gridRangeEntityList = new ArrayList<>(); |
| | | // 处理户室数据 |
| | | for (DoorplateAddressEntity doorplateAddressEntity : list) { |
| | | // 查询是否已存在,存在就插入,不存在则插入 |
| | | QueryWrapper<GridRangeEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("house_code", doorplateAddressEntity.getAddressCode()); |
| | | GridRangeEntity one = gridRangeService.getOne(wrapper); |
| | | if (null == one) { |
| | | // 设置网格 |
| | | String point = "'POINT(" + doorplateAddressEntity.getX() + " " + doorplateAddressEntity.getY() + ")'"; |
| | | //点坐标解析网格 |
| | | List<GridEntity> gridEntityList = gridService.spatialAnalysis(point); |
| | | if (gridEntityList.size()>0){ |
| | | GridRangeEntity gridRangeEntity = new GridRangeEntity(); |
| | | gridRangeEntity.setHouseCode(doorplateAddressEntity.getAddressCode()); |
| | | gridRangeEntity.setDistrictCode(doorplateAddressEntity.getAoiCode()); |
| | | gridRangeEntity.setBuilding(doorplateAddressEntity.getBuildingCode()); |
| | | GridEntity gridEntity = gridEntityList.get(0); |
| | | gridRangeEntity.setGridId(gridEntity.getId()); |
| | | gridRangeEntity.setGridCode(gridEntity.getGridCode()); |
| | | // 加入集合 |
| | | gridRangeEntityList.add(gridRangeEntity); |
| | | } |
| | | } |
| | | } |
| | | // 批量插入 |
| | | gridRangeService.saveBatch(gridRangeEntityList); |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 设置警格网格信息 |
| | | * @param doorplateAddressEntity |
| | | */ |
| | | public void setGridInfo(DoorplateAddressEntity doorplateAddressEntity,GridRangeEntity gridRangeEntity) { |
| | | // 根据位置设置网格,警格编号 |
| | | // IPoliceAffairsGridService policeAffairsGridService = SpringUtils.getBean(IPoliceAffairsGridService.class); |
| | | String point = "'POINT(" + doorplateAddressEntity.getX() + " " + doorplateAddressEntity.getY() + ")'"; |
| | | //点坐标解析网格 |
| | | List<GridEntity> gridEntityList = gridService.spatialAnalysis(point); |
| | | if (gridEntityList.size()>0){ |
| | | GridEntity gridEntity = gridEntityList.get(0); |
| | | gridRangeEntity.setGridId(gridEntity.getId()); |
| | | gridRangeEntity.setGridCode(gridEntity.getGridCode()); |
| | | } |
| | | // //点坐标解析警格 |
| | | // List<PoliceAffairsGridEntity> policeAffairsGridEntityList = policeAffairsGridService.spatialAnalysis(point); |
| | | // if (policeAffairsGridEntityList.size()>0){ |
| | | // PoliceAffairsGridEntity policeAffairsGridEntity = policeAffairsGridEntityList.get(0); |
| | | // backblastPubRecord.setJwGridCode(policeAffairsGridEntity.getJwGridCode()); |
| | | // } |
| | | } |
| | | } |