| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | 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.poi.hssf.record.DVALRecord; |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springblade.common.node.TreeNode; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | List<TreeNode> shopList = new ArrayList<>(); |
| | | // 根据社区名称查询楼栋或者商铺的集合 |
| | | List<TreeNode> list = baseMapper.getBuildingList(houseParam.getName(),houseParam.getCode()); |
| | | // 排序 StringUtils.getDigits(X.getName()) 取出数字排序 |
| | | List<TreeNode> sortList = list.stream().sorted(Comparator.comparing(X -> StringUtils.getDigits(X.getName()))).collect(Collectors.toList()); |
| | | if (list.size()>0){ |
| | | for (TreeNode treeNode : list) { |
| | | for (TreeNode treeNode : sortList) { |
| | | if (treeNode.getAddressType()==1){ |
| | | aoiList.add(treeNode); |
| | | } |
| | |
| | | } |
| | | // 处理,先按单元分组,再按楼层分组 |
| | | if (aoiNodes.size()>0){ |
| | | Map<String, List<FuncNode>> listMap = aoiNodes.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); |
| | | funcNode.setAddressType(1); |
| | | funcNodeList.add(funcNode); |
| | | }); |
| | | FuncNode funcNode = new FuncNode(); |
| | | funcNode.setUnitName("一单元"); |
| | | funcNode.setChildren(funcNodeList); |
| | | funcNode.setAddressType(1); |
| | | list.add(funcNode); |
| | | // 按单元分组 |
| | | Map<String, List<FuncNode>> listMap = aoiNodes.stream().collect(Collectors.groupingBy(FuncNode::getUnitName)); |
| | | // 单个单元 |
| | | oneUnitHandle(list, listMap); |
| | | // 多个单元 |
| | | moreUnitHandle(list, listMap); |
| | | } |
| | | list.addAll(shopNodes); |
| | | // 返回 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 单个单元处理 |
| | | * @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); |
| | | }); |
| | | // 排序 |
| | | List<FuncNode> sortList = tempList.stream().sorted(Comparator.comparing(X -> X.getUnitName())).collect(Collectors.toList()); |
| | | list.addAll(sortList); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询房屋及出租详情信息 |
| | | * @param code 门牌地址编号 |
| | | * @return |