| | |
| | | List<ZInfoUser> allPeopleList = list(); |
| | | List<ZInfoUser> result = null; |
| | | try { |
| | | result = allPeopleList.stream().filter(people -> people.getUserId()!=1&&(people.getFatherId() == 0||people.getMomId()==0)) |
| | | .map(people -> { |
| | | if(depth>1){ |
| | | people.setIdentity(1); |
| | | people.setChildList(fillChildren(people, allPeopleList, depth-1)); |
| | | } |
| | | return people; |
| | | }).collect(Collectors.toList()); |
| | | result = allPeopleList.stream().filter(people -> people.getUserId()!=1&&(people.getFatherId() == 0||people.getMomId()==0)) |
| | | .map(people -> { |
| | | if(depth>1){ |
| | | people.setIdentity(1); |
| | | //根据配偶id查询配偶的数据,封装好一起返回 |
| | | Long spouseId = people.getSpouseId(); |
| | | ZInfoUser spouse = zInfoUserService.getById(spouseId); |
| | | people.setSpouse(spouse); |
| | | people.setChildList(fillChildren(people, allPeopleList, depth-1)); |
| | | } |
| | | return people; |
| | | }).collect(Collectors.toList()); |
| | | } catch (NullPointerException e) { |
| | | throw new RuntimeException("您在加入成员的时候没有指定该成员的父亲或者母亲"); |
| | | } |
| | | |
| | | |
| | | return AjaxResult.success(result); |
| | | |
| | | } |
| | |
| | | // layer = layer + 1; |
| | | System.out.println(depth); |
| | | List<ZInfoUser> collect = allPeopleList.stream().filter( |
| | | one -> one.getFatherId() == people.getUserId() || one.getMomId() == people.getUserId() |
| | | one -> (one.getFatherId() == people.getUserId() || one.getMomId() == people.getUserId()) && (people.getIsMyFamily() == 1) |
| | | ).map( |
| | | one -> { |
| | | if(depth==1) |
| | | return one; |
| | | else { |
| | | one.setIdentity(people.getIdentity()+1); |
| | | |
| | | //根据配偶id查询配偶的数据,封装好一起返回 |
| | | Long spouseId = one.getSpouseId(); |
| | | ZInfoUser spouse = zInfoUserService.getById(spouseId); |
| | | one.setSpouse(spouse); |
| | | List<ZInfoUser> zinfo = fillChildren(one, allPeopleList, depth - 1); |
| | | one.setChildList(zinfo); |
| | | System.out.println(one); |