| | |
| | | package org.springblade.modules.doorplateAddress.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.common.node.TreeNode; |
| | | 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.mp.base.BaseServiceImpl; |
| | | 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.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.mapper.DoorplateAddressMapper; |
| | | import org.springblade.modules.doorplateAddress.service.IDoorplateAddressService; |
| | | import org.springblade.modules.doorplateAddress.vo.DoorplateAddressVO; |
| | | 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.GridmanEntity; |
| | | import org.springblade.modules.grid.service.IGridService; |
| | | import org.springblade.modules.grid.service.IGridmanService; |
| | | import org.springblade.modules.house.entity.HouseEntity; |
| | | import org.springblade.modules.house.service.IHouseRentalService; |
| | | import org.springblade.modules.house.service.IHouseholdLabelService; |
| | | import org.springblade.modules.house.service.IHouseService; |
| | | import org.springblade.modules.house.service.IHouseholdService; |
| | | 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.service.IPlaceService; |
| | | import org.springblade.modules.system.entity.Region; |
| | | import org.springblade.modules.system.service.IRegionService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private IPlaceService placeService; |
| | | |
| | | @Autowired |
| | | private IHouseService houseService; |
| | | |
| | | @Autowired |
| | | private IHouseholdService householdService; |
| | | |
| | | @Autowired |
| | | private IHouseRentalService houseRentalService; |
| | | |
| | | @Autowired |
| | | private IGridService gridService; |
| | | |
| | | @Autowired |
| | | private IGridmanService gridmanService; |
| | | |
| | | @Autowired |
| | | private IRegionService regionService; |
| | | |
| | | @Autowired |
| | | private IDistrictService districtService; |
| | | |
| | | @Autowired |
| | | private ICategoryLabelService iCategoryLabelService; |
| | | |
| | | @Autowired |
| | | private ICommunityService communityService; |
| | | |
| | | |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 根据角色获取功能集合数据 |
| | | * @param type 1:查区域 2:查场所 3:查房屋 |
| | | * @param type 1:查社区 2:查房屋和场所(居民角色) |
| | | * @param roleName |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object getFuncList(Integer type,String roleName) { |
| | | List<TreeNode> list = new ArrayList<>(); |
| | | if (null!=type) { |
| | | // 如果是网格管理员,系统管理员 |
| | | if (type==1){ |
| | | // 查询街道 |
| | | List<TreeNode> townList = baseMapper.getRegionListByGrouyTwon(); |
| | | // 查询社区 |
| | | List<TreeNode> neiList = baseMapper.getRegionListByGrouyNei(); |
| | | TreeNode node = townList.get(0); |
| | | node.setHasChildren(true); |
| | | // 遍历 |
| | | for (TreeNode treeNode : neiList) { |
| | | treeNode.setHasChildren(false); |
| | | node.getChildren().add(treeNode); |
| | | } |
| | | // 查询区域数据,当前只有西市街道数据 |
| | | return townList; |
| | | HouseParam houseParam = new HouseParam(); |
| | | 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 (type==2){ |
| | | // 查询场所集合信息 |
| | | list = placeService.selectPlaceNodeList(AuthUtil.getUserId()); |
| | | // 返回 |
| | | return list; |
| | | } |
| | | // 如果是居民 |
| | | if (type==3){ |
| | | // 查询房屋集合信息 |
| | | list = householdService.selectHouseNodeList(AuthUtil.getUserId()); |
| | | // 返回 |
| | | return list; |
| | | 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,communityList); |
| | | // 查询社区 |
| | | List<TreeStringNode> neiList = baseMapper.getRegionListByGroupNei(houseParam,stringList,communityList); |
| | | // 遍历 |
| | | for (TreeStringNode treeNode : townList) { |
| | | // 遍历 |
| | | 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 list; |
| | | } |
| | | |
| | | /** |
| | | * 获取居民角色对应的房屋,场所信息 |
| | | * @param list |
| | | * @return |
| | | */ |
| | | private Object getInhabitantInfo(List<TreeStringNode> list) { |
| | | // 查询房屋集合信息 |
| | | List<TreeStringNode> houseNodeList = householdService.selectHouseNodeList(AuthUtil.getUserId()); |
| | | for (TreeStringNode treeNode : houseNodeList) { |
| | | // 判断房屋类型类型 |
| | | if (DictConstant.SMALL_DOORPLATE.equals(treeNode.getDoorplateType()) || |
| | | (DictConstant.centre_DOORPLATE.equals(treeNode.getDoorplateType()) && |
| | | treeNode.getAddressLevel().equals(1))) { |
| | | treeNode.setAddressType(2); |
| | | } else { |
| | | treeNode.setAddressType(1); |
| | | } |
| | | } |
| | | // 查询场所集合信息 |
| | | 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); |
| | | // if (DictConstant.SMALL_DOORPLATE.equals(treeNode.getDoorplateType()) || |
| | | // (DictConstant.centre_DOORPLATE.equals(treeNode.getDoorplateType()) && |
| | | // treeNode.getAddressLevel().equals(1))) { |
| | | // treeNode.setAddressType(2); |
| | | // } else { |
| | | // treeNode.setAddressType(3); |
| | | // } |
| | | } |
| | | if (houseNodeList.size() > 0 && placeNodeList.size() > 0) { |
| | | // 合并 |
| | | TreeStringNode houseNode = new TreeStringNode(); |
| | | houseNode.setName("房屋"); |
| | | houseNode.setId("1"); |
| | | houseNode.setHasChildren(true); |
| | | houseNode.setChildren(houseNodeList); |
| | | |
| | | 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; |
| | | } |
| | | if (placeNodeList.size()>0){ |
| | | list = placeNodeList; |
| | | } |
| | | // 返回 |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取楼盘相关集合数据 |
| | | * @param name 名称 |
| | | * @param code 编号 |
| | | * @param type 类型 1:社区 2:小区 3:楼栋 4:户室 |
| | | * @param houseParam |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object getHousesList(String name, String code, Integer type) { |
| | | List<TreeNode> list = new ArrayList<>(); |
| | | public Object getHousesList(HouseParam houseParam) { |
| | | List<TreeStringNode> list = new ArrayList<>(); |
| | | Map<String, Object> map = new HashMap<>(2); |
| | | // 获取网格员对应的地址编号集合 |
| | | List<String> stringList = getHouseCodeList(houseParam); |
| | | List<String> communityCodeList = getCommunityCodeList(houseParam); |
| | | // 获取网格员对应的网格信息 |
| | | getGridInfoByGridman(houseParam); |
| | | // 查小区,场所 |
| | | if (type==1){ |
| | | if (houseParam.getType()==1){ |
| | | // 根据社区名称查询小区集合 |
| | | list = baseMapper.getDistrictList(name,code); |
| | | list = baseMapper.getDistrictList(houseParam,stringList,communityCodeList); |
| | | } |
| | | // 查楼栋,场所 |
| | | if (type==2){ |
| | | // 根据社区名称查询楼栋集合 |
| | | list = baseMapper.getBuildingList(name,code); |
| | | // 查楼栋,街路巷 |
| | | if (houseParam.getType()==2){ |
| | | return getBuildLevelData(houseParam,map); |
| | | } |
| | | // 查户室 |
| | | if (type==3){ |
| | | // 查询户室及住户相关信息,单元中包含住户 |
| | | return getUnitHouseholdList(name,code); |
| | | if (houseParam.getType()==3){ |
| | | return getHouseLevelData(houseParam, map); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 查询户室及住户相关信息,单元中包含住户 |
| | | * @param name |
| | | * @param code |
| | | * 获取网格员对应的网格信息 |
| | | * @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()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询户室级别数据 |
| | | * @param houseParam |
| | | * @param map |
| | | * @return |
| | | */ |
| | | private List<FuncNode> getUnitHouseholdList(String name, String code) { |
| | | private Map<String, Object> getHouseLevelData(HouseParam houseParam, Map<String, Object> map) { |
| | | List<String> stringList = getHouseCodeList(houseParam); |
| | | // 判断地址类型 |
| | | if (houseParam.getAddressType()==1) { |
| | | List<FuncNode> aoiList = new ArrayList<>(); |
| | | List<FuncNode> shopList = new ArrayList<>(); |
| | | // 查询户室及住户相关信息,单元中包含住户,或者和单元平级的 商铺 |
| | | List<FuncNode> householdList = getUnitHouseholdList(houseParam,stringList); |
| | | // 遍历 |
| | | if (householdList.size()>0){ |
| | | for (FuncNode funcNode : householdList) { |
| | | if (funcNode.getAddressType()==1){ |
| | | aoiList.add(funcNode); |
| | | } |
| | | if (funcNode.getAddressType()==2){ |
| | | shopList.add(funcNode); |
| | | } |
| | | } |
| | | } |
| | | map.put("aoiList",aoiList); |
| | | map.put("shopList",shopList); |
| | | // 返回 |
| | | return map; |
| | | } |
| | | if(houseParam.getAddressType()==3){ |
| | | // 根据街路巷编号查询街路巷门牌名称集合 |
| | | List<FuncNode> doorplateNameList = baseMapper.getDoorplateNameList(houseParam,stringList); |
| | | map.put("aoiList",new ArrayList<>()); |
| | | map.put("shopList",doorplateNameList); |
| | | // 返回 |
| | | return map; |
| | | } |
| | | if(houseParam.getAddressType()==4){ |
| | | getGridInfoByGridman(houseParam); |
| | | // 查询商超 |
| | | List<FuncNode> doorplateNameList = baseMapper.getPlaceRelDetailList(houseParam); |
| | | map.put("aoiList",new ArrayList<>()); |
| | | map.put("shopList",doorplateNameList); |
| | | // 返回 |
| | | return map; |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 获取楼栋层级数据 |
| | | * @param houseParam |
| | | * @param map |
| | | * @return |
| | | */ |
| | | private Object getBuildLevelData(HouseParam houseParam,Map<String, Object> map) { |
| | | if (houseParam.getAddressType()==4){ |
| | | // 获取网格员对应的网格信息 |
| | | getGridInfoByGridman(houseParam); |
| | | // 查询商超 |
| | | List<TreeStringNode> list = baseMapper.getPlaceRelList(houseParam); |
| | | map.put("aoiList", new ArrayList<>()); |
| | | map.put("shopList", list); |
| | | // 返回 |
| | | return map; |
| | | }else { |
| | | List<String> stringList = getHouseCodeList(houseParam); |
| | | // 判断 code 长度,如果 code 长度大于 12 则为小区查楼栋/商铺,否则则按社区查街路巷 |
| | | if (houseParam.getCode().length() > 12) { |
| | | List<TreeStringNode> aoiList = new ArrayList<>(); |
| | | List<TreeStringNode> shopList = new ArrayList<>(); |
| | | // 根据社区名称查询楼栋或者商铺的集合 |
| | | List<TreeStringNode> list = baseMapper.getBuildingList(houseParam, stringList); |
| | | // 排序 StringUtils.getDigits(X.getName()) 取出数字排序 |
| | | List<TreeStringNode> sortList = list.stream(). |
| | | sorted(new Comparator<TreeStringNode>() { |
| | | @Override |
| | | public int compare(TreeStringNode o1, TreeStringNode o2) { |
| | | return ComplexNumberStringComparator.compare(o1.getName(),o2.getName()); |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | if (list.size() > 0) { |
| | | for (TreeStringNode treeNode : sortList) { |
| | | if (treeNode.getAddressType() == 1) { |
| | | aoiList.add(treeNode); |
| | | } |
| | | if (treeNode.getAddressType() == 2) { |
| | | shopList.add(treeNode); |
| | | } |
| | | } |
| | | } |
| | | map.put("aoiList", aoiList); |
| | | map.put("shopList", shopList); |
| | | // 返回 |
| | | return map; |
| | | } else { |
| | | // 查询街路巷 |
| | | List<TreeStringNode> list = baseMapper.getStreetRuList(houseParam, stringList); |
| | | map.put("aoiList", new ArrayList<>()); |
| | | map.put("shopList", list); |
| | | // 返回 |
| | | return map; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询户室及住户相关信息,单元中包含住户 |
| | | * @param houseParam |
| | | * @param stringList |
| | | * @return |
| | | */ |
| | | private List<FuncNode> getUnitHouseholdList(HouseParam houseParam,List<String> stringList) { |
| | | List<FuncNode> list = new ArrayList<>(); |
| | | // 查询户室及住户相关信息,单元中包含住户 |
| | | List<FuncNode> funcNodes = baseMapper.getUnitHouseholdList(name,code); |
| | | // 处理,先按单元分组,再按楼层分组 |
| | | if (funcNodes.size()>0){ |
| | | Map<String, List<FuncNode>> listMap = funcNodes.stream().collect(Collectors.groupingBy(FuncNode::getFloor)); |
| | | List<FuncNode> funcNodeList = new ArrayList<>(); |
| | | listMap.forEach((s, temps) -> { |
| | | FuncNode funcNode = new FuncNode(); |
| | | funcNode.setFloor(s); |
| | | funcNode.setChildren(temps); |
| | | funcNodeList.add(funcNode); |
| | | }); |
| | | FuncNode funcNode = new FuncNode(); |
| | | funcNode.setUnitName("一单元"); |
| | | funcNode.setChildren(funcNodeList); |
| | | list.add(funcNode); |
| | | List<FuncNode> funcNodes = baseMapper.getUnitHouseholdList(houseParam,stringList); |
| | | // 遍历 |
| | | List<FuncNode> aoiNodes = new ArrayList<>(); |
| | | List<FuncNode> shopNodes = new ArrayList<>(); |
| | | for (FuncNode funcNode : funcNodes) { |
| | | if (funcNode.getAddressType()==1){ |
| | | aoiNodes.add(funcNode); |
| | | } |
| | | if (funcNode.getAddressType()==2){ |
| | | shopNodes.add(funcNode); |
| | | } |
| | | } |
| | | // 处理,先按单元分组,再按楼层分组 |
| | | if (aoiNodes.size()>0){ |
| | | // 按单元分组 |
| | | Map<String, List<FuncNode>> listMap = aoiNodes.stream().collect(Collectors.groupingBy(FuncNode::getUnitName)); |
| | | // 单个单元 |
| | | oneUnitHandle(list, listMap); |
| | | // 多个单元 |
| | | moreUnitHandle(list, listMap); |
| | | } |
| | | list.addAll(shopNodes); |
| | | // 返回 |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 单个单元处理 |
| | | * @param list |
| | | * @param listMap |
| | | */ |
| | | private void oneUnitHandle(List<FuncNode> list, Map<String, List<FuncNode>> listMap) { |
| | | if (listMap.size()==1){ |
| | | Set<String> keySet = listMap.keySet(); |
| | | // 获取第一个key |
| | | String firstKey = null; |
| | | for (String key : keySet) { |
| | | 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); |
| | | }); |
| | | FuncNode funcNode = new FuncNode(); |
| | | funcNode.setUnitName("一单元"); |
| | | 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){ |
| | | List<FuncNode> tempList = new ArrayList<>(); |
| | | // 遍历 |
| | | listMap.forEach((s, temps) -> { |
| | | FuncNode funcNode = new FuncNode(); |
| | | funcNode.setUnitName(s); |
| | | funcNode.setAddressType(1); |
| | | // 按楼层分组 |
| | | Map<String, List<FuncNode>> floorListMap = temps.stream().collect(Collectors.groupingBy(FuncNode::getFloor)); |
| | | List<FuncNode> floorNodeList = new ArrayList<>(); |
| | | floorListMap.forEach((floor, houseList) -> { |
| | | FuncNode floorNode = new FuncNode(); |
| | | floorNode.setFloor(floor); |
| | | floorNode.setChildren(houseList); |
| | | floorNode.setAddressType(1); |
| | | floorNodeList.add(floorNode); |
| | | }); |
| | | funcNode.setChildren(floorNodeList); |
| | | tempList.add(funcNode); |
| | | }); |
| | | // 排序 |
| | | sortUnit(tempList,list); |
| | | // List<FuncNode> sortList = tempList.stream().sorted(Comparator.comparing(X -> X.getUnitName())).collect(Collectors.toList()); |
| | | // list.addAll(sortList); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 单元排序 |
| | | * @param tempList |
| | | * @param list |
| | | */ |
| | | private void sortUnit(List<FuncNode> tempList,List<FuncNode> list) { |
| | | // 遍历 |
| | | if(tempList.size()>1){ |
| | | for (FuncNode funcNode : tempList) { |
| | | if (funcNode.getUnitName().contains("一")){ |
| | | funcNode.setSort(1); |
| | | } |
| | | if (funcNode.getUnitName().contains("二")){ |
| | | funcNode.setSort(2); |
| | | } |
| | | if (funcNode.getUnitName().contains("三")){ |
| | | funcNode.setSort(3); |
| | | } |
| | | if (funcNode.getUnitName().contains("四")){ |
| | | funcNode.setSort(4); |
| | | } |
| | | if (funcNode.getUnitName().contains("五")){ |
| | | funcNode.setSort(5); |
| | | } |
| | | if (funcNode.getUnitName().contains("六")){ |
| | | funcNode.setSort(6); |
| | | } |
| | | } |
| | | // 排序 |
| | | List<FuncNode> sortList = tempList.stream().sorted(Comparator.comparing(X -> X.getSort())).collect(Collectors.toList()); |
| | | list.addAll(sortList); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | public Object getHouseRentInfo(String code) { |
| | | // 先查询门牌信息 |
| | | DoorplateAddressVO doorplateAddressDetailVO = baseMapper.getDoorplateAddressDetailByCode(code); |
| | | // 查询房屋出租情况 |
| | | List<HouseRentalVO> houseRentalVOS = houseRentalService.getHouseRentalListByCode(code); |
| | | // 设置数据 |
| | | doorplateAddressDetailVO.setHouseRentalList(houseRentalVOS); |
| | | if(null!= doorplateAddressDetailVO) { |
| | | // 查询房屋出租情况 |
| | | List<HouseRentalVO> houseRentalVOS = houseRentalService.getHouseRentalListByCode(code); |
| | | // 查询房屋人员情况 |
| | | List<HouseholdVO> householdVOS = householdService.getHouseholdListByCode(code); |
| | | // 设置数据 |
| | | doorplateAddressDetailVO.setHouseRentalList(houseRentalVOS); |
| | | doorplateAddressDetailVO.setHouseholdList(householdVOS); |
| | | } |
| | | // 返回 |
| | | return doorplateAddressDetailVO; |
| | | } |
| | | |
| | | @Override |
| | | public List<DoorplateAddressVOTree> getDoorplateAddressList(String code, String type) { |
| | | |
| | | //西市街道 万达社区 滨江西路66号 万达华府 26栋 |
| | | List<DoorplateAddressVOTree> list = new ArrayList<>(); |
| | | |
| | | |
| | | if (type.equals("townStreet")){ |
| | | //获取所有街道街道 |
| | | list = baseMapper.getTownStreetVOTreeList(); |
| | | }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")){ |
| | | list = baseMapper.getBuildingVOTreeList(code); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 根据参数获取地址详情 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public DoorplateAddressVO getDoorplateAddressDetail(DoorplateAddressVO doorplateAddressVO) { |
| | | //根据参数获取地址详情 |
| | | DoorplateAddressVO doorplateAddress = baseMapper.getDoorplateAddressDetail(doorplateAddressVO); |
| | | // 返回 |
| | | return doorplateAddress; |
| | | } |
| | | |
| | | @Override |
| | | public Object getHouseType(String code) { |
| | | DoorplateAddressEntity doorplateAddressEntity = baseMapper.selectOne(Wrappers.<DoorplateAddressEntity>lambdaQuery().eq(DoorplateAddressEntity::getAddressCode, code)); |
| | | // 判断房屋信息是否住宅 |
| | | if (doorplateAddressEntity.getDoorplateType().equals(DictConstant.SMALL_DOORPLATE) || |
| | | (doorplateAddressEntity.getDoorplateType().equals(DictConstant.centre_DOORPLATE) && |
| | | doorplateAddressEntity.getAddressLevel().equals(1))) { |
| | | return 1; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * 查询社区信息 |
| | | * @param name |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DoorplateAddressEntity> getAllDoorplateAddress(String name) { |
| | | return baseMapper.getAllDoorplateAddress(name); |
| | | } |
| | | |
| | | /** |
| | | * 获取房屋树 |
| | | * @param houseParam |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DoorplateAddressVOTree> getHouseTree(HouseParam houseParam) { |
| | | List<String> stringList = getHouseCodeList(houseParam); |
| | | // 根据社区居委会编号获取对应的小区/楼栋/单元/户室 |
| | | return NodeTreeUtil.getAddressNodeTree(baseMapper.getHouseTree(houseParam,stringList)); |
| | | } |
| | | |
| | | /** |
| | | * 根据角色获取地址编号集合 |
| | | * @param houseParam |
| | | * @return |
| | | */ |
| | | private List<String> getHouseCodeList(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()); |
| | | } |
| | | } |
| | | return stringList; |
| | | } |
| | | |
| | | /** |
| | | * 根据角色获取社区编号集合 |
| | | * @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 |
| | | */ |
| | | @Override |
| | | public Object houseDataHandle() { |
| | | // 处理房屋数据 |
| | | handleHouseData(); |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | // 批量插入 |
| | | houseService.saveBatch(houseList); |
| | | } |
| | | |
| | | /** |
| | | * 小区数据处理 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object aoiDataHandle() { |
| | | // 查询所有的地址表id集合 |
| | | List<Long> aoiCodeList = baseMapper.getAoiCodeList(); |
| | | // 查询小区集合 |
| | | List<DoorplateAddressEntity> list = baseMapper.getAoiList(aoiCodeList); |
| | | // 创建小区集合对象 |
| | | List<DistrictEntity> aoiList = new ArrayList<>(); |
| | | // 将小区数据保存到小区表中 |
| | | for (DoorplateAddressEntity addressEntity : list) { |
| | | // 查询小区是否已存在,不存在则插入,否则不新增 |
| | | QueryWrapper<DistrictEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("aoi_code",addressEntity.getAoiCode()) |
| | | .eq("is_deleted",0); |
| | | DistrictEntity one = districtService.getOne(wrapper); |
| | | if (null==one) { |
| | | DistrictEntity districtEntity = new DistrictEntity(); |
| | | districtEntity.setCommunityCode(addressEntity.getNeiCode()); |
| | | districtEntity.setAoiCode(addressEntity.getAoiCode()); |
| | | districtEntity.setName(addressEntity.getAoiName()); |
| | | districtEntity.setAddress(addressEntity.getAddressName()); |
| | | districtEntity.setLng(addressEntity.getX()); |
| | | districtEntity.setLat(addressEntity.getY()); |
| | | // 加入集合 |
| | | districtService.save(districtEntity); |
| | | // aoiList.add(districtEntity); |
| | | } |
| | | } |
| | | // 批量插入 |
| | | // districtService.saveBatch(aoiList); |
| | | // 返回 |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 场所数据处理 |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Object placeDataHandle() { |
| | | // 查询所有的地址表和场所表差集集合 |
| | | List<DoorplateAddressEntity> list = baseMapper.getPlaceList(); |
| | | // 创建场所集合对象 |
| | | List<PlaceEntity> placeList = new ArrayList<>(); |
| | | 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.setSource(1); |
| | | // 加入集合 |
| | | placeList.add(placeEntity); |
| | | } |
| | | } |
| | | // 批量插入 |
| | | placeService.saveBatch(placeList); |
| | | } |
| | | // 返回 |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 门牌地址表(总台账数据) 自定义详情 |
| | | */ |
| | | @Override |
| | | public Object getDetail(DoorplateAddressVO doorplateAddress) { |
| | | List<String> list = new ArrayList<>(); |
| | | // 扫码时调用,需判断是否有权限查看 |
| | | DoorplateAddressVO one = baseMapper.getDoorplateAddressVODetail(doorplateAddress); |
| | | if (null!=one){ |
| | | 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); |
| | | }else { |
| | | one.setIsJur(1); |
| | | } |
| | | }else { |
| | | // 不限制 |
| | | one.setIsJur(1); |
| | | } |
| | | } |
| | | return one; |
| | | } |
| | | 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; |
| | | } |
| | | } |