| | |
| | | |
| | | /** |
| | | * 获取家根网 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 条件获取家庭成员 |
| | | * |
| | | * @return |
| | | */ |
| | | public AjaxResult listWithTreeByCondition(Integer depth,Genealogy genealogy) { |
| | | |
| | | ZInfoUser zInfoUser = new ZInfoUser(); |
| | | BeanUtils.copyProperties(genealogy,zInfoUser); |
| | | LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(zInfoUser.getIdentity()!=null,ZInfoUser::getIdentity,zInfoUser.getIdentity()); |
| | | lqw.eq(zInfoUser.getSex()!=null,ZInfoUser::getSex,zInfoUser.getSex()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getNickName()),ZInfoUser::getNickName,zInfoUser.getNickName()); |
| | | lqw.eq(zInfoUser.getBirth()!=null,ZInfoUser::getBirth,zInfoUser.getBirth()); |
| | | // ZInfoUser zInfoUser = new ZInfoUser(); |
| | | // BeanUtils.copyProperties(genealogy, zInfoUser); |
| | | // LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>(); |
| | | // lqw.eq(zInfoUser.getIdentity() != null, ZInfoUser::getIdentity, zInfoUser.getIdentity()); |
| | | // lqw.eq(zInfoUser.getSex() != null, ZInfoUser::getSex, zInfoUser.getSex()); |
| | | // lqw.like(StringUtils.isNotEmpty(zInfoUser.getNickName()), ZInfoUser::getNickName, zInfoUser.getNickName()); |
| | | // lqw.eq(zInfoUser.getBirth() != null, ZInfoUser::getBirth, zInfoUser.getBirth()); |
| | | |
| | | List<ZInfoUser> allPeopleList = list(lqw); |
| | | // List<ZInfoUser> allPeopleList = list(lqw); |
| | | 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)); |
| | | people.setChildList(fillChildren2(people, allPeopleList, depth - 1)); |
| | | } |
| | | return people; |
| | | }).collect(Collectors.toList()); |
| | | } catch (NullPointerException e) { |
| | | throw new RuntimeException("您在加入成员的时候没有指定该成员的父亲或者母亲"); |
| | | } |
| | | |
| | | |
| | | // result.stream().map( |
| | | // data->{ |
| | | // if(genealogy.getIdentity()!=null){ |
| | | // if(data.getIdentity()!=genealogy.getIdentity()){ |
| | | // result.remove(data); |
| | | // } |
| | | // } |
| | | // |
| | | // if(genealogy.getNickName()!=null){ |
| | | // |
| | | // } |
| | | // |
| | | // if(genealogy.getSex()!=null){ |
| | | // |
| | | // } |
| | | // |
| | | // if(genealogy.getBirth()!=null){ |
| | | // |
| | | // } |
| | | // } |
| | | // ) |
| | | |
| | | |
| | | |
| | | return AjaxResult.success(result); |
| | | |
| | | } |
| | |
| | | |
| | | /** |
| | | * 家谱信息 |
| | | * |
| | | * @param genealogy |
| | | * @return |
| | | */ |
| | |
| | | resultData.add(collect.get(i)); |
| | | } |
| | | |
| | | |
| | | //对result做一个条件筛选 |
| | | Iterator<Genealogy> it = resultData.iterator(); |
| | | while(it.hasNext()){ |
| | | Genealogy data = it.next(); |
| | | |
| | | if(genealogy.getIdentity()!=null){ |
| | | if(data.getIdentity()!=genealogy.getIdentity()){ |
| | | it.remove(); |
| | | } |
| | | } |
| | | |
| | | if(genealogy.getNickName()!=null){ |
| | | if(!data.getNickName().contains(genealogy.getNickName())){ |
| | | it.remove(); |
| | | } |
| | | } |
| | | |
| | | if(genealogy.getSex()!=null){ |
| | | if(data.getSex()!=genealogy.getSex()){ |
| | | it.remove(); |
| | | } |
| | | } |
| | | |
| | | if(genealogy.getBirth()!=null){ |
| | | if(data.getBirth()!=genealogy.getBirth()){ |
| | | it.remove(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | System.out.println(resultData); |
| | | |
| | | |
| | | |
| | | // for (Genealogy data : resultData) { |
| | | // |
| | | // if(genealogy.getIdentity()!=null){ |
| | | // if(data.getIdentity()!=genealogy.getIdentity()){ |
| | | // resultData.remove(data); |
| | | // } |
| | | // } |
| | | // |
| | | // if(genealogy.getNickName()!=null){ |
| | | // if(!data.getNickName().contains(genealogy.getNickName())){ |
| | | // resultData.remove(data); |
| | | // } |
| | | // } |
| | | // |
| | | // if(genealogy.getSex()!=null){ |
| | | // if(data.getSex()!=genealogy.getSex()){ |
| | | // resultData.remove(data); |
| | | // } |
| | | // } |
| | | // |
| | | // if(genealogy.getBirth()!=null){ |
| | | // if(data.getBirth()!=genealogy.getBirth()){ |
| | | // resultData.remove(data); |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | HashMap<String, Object> resultMap = new HashMap<>(); |
| | | resultMap.put("data",resultData); |
| | | resultMap.put("total",collect.size()); |
| | | resultMap.put("total", resultData.size()); |
| | | resultMap.put("pageNum",pageNum); |
| | | resultMap.put("pageSize",pageSize); |
| | | |
| | |
| | | return getById(userId); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult listGenealogy2(Genealogy genealogy, Integer pageNum, Integer pageSize) { |
| | | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | private void recursionFindUser(List<ZInfoUser> treeList){ |
| | | if (treeList==null||treeList.isEmpty()){ |
| | |
| | | |
| | | /** |
| | | * 为了家根网、新增或者修改父子关系 |
| | | * |
| | | * @param fatherId |
| | | * @param motherId |
| | | * @return |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 递归算法 |
| | | * |
| | | * @param people |
| | | * @param allPeopleList |
| | | * @return |
| | |
| | | one -> (one.getFatherId() == people.getUserId() || one.getMomId() == people.getUserId()) && (people.getIsMyFamily() == 1) |
| | | ).map( |
| | | one -> { |
| | | if (depth == 1) { |
| | | one.setIdentity(people.getIdentity() + 1); |
| | | //根据配偶id查询配偶的数据,封装好一起返回 |
| | | Long spouseId = one.getSpouseId(); |
| | | if (spouseId != null) { |
| | | ZInfoUser spouse = zInfoUserService.getById(spouseId); |
| | | spouse.setIdentity(people.getIdentity() + 1); |
| | | one.setSpouse(spouse); |
| | | } |
| | | return one; |
| | | } |
| | | else { |
| | | one.setIdentity(people.getIdentity() + 1); |
| | | //根据配偶id查询配偶的数据,封装好一起返回 |
| | | Long spouseId = one.getSpouseId(); |
| | | if (spouseId != null) { |
| | | ZInfoUser spouse = zInfoUserService.getById(spouseId); |
| | | spouse.setIdentity(people.getIdentity() + 1); |
| | | one.setSpouse(spouse); |
| | | } |
| | | List<ZInfoUser> zinfo = fillChildren(one, allPeopleList, depth - 1); |
| | | one.setChildList(zinfo); |
| | | System.out.println(one); |
| | | return one; |
| | | } |
| | | |
| | | //return one; |
| | | } |
| | | ).collect(Collectors.toList()); |
| | | System.out.println(collect); |
| | | return collect; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 递归算法家谱用 |
| | | * |
| | | * @param people |
| | | * @param allPeopleList |
| | | * @return |
| | | */ |
| | | private List<ZInfoUser> fillChildren2(ZInfoUser people, List<ZInfoUser> allPeopleList, Integer depth) { |
| | | |
| | | // TODO: 2023-05-05 控制递归的次数 |
| | | // if(depth==layer) |
| | | |
| | | // layer = layer + 1; |
| | | System.out.println(depth); |
| | | List<ZInfoUser> collect = allPeopleList.stream().filter( |
| | | one -> (one.getFatherId() == people.getUserId() || one.getMomId() == people.getUserId()) |
| | | ).map( |
| | | one -> { |
| | | if(depth==1) |
| | | return one; |
| | | else { |
| | |
| | | spouse.setIdentity(people.getIdentity()+1); |
| | | one.setSpouse(spouse); |
| | | } |
| | | List<ZInfoUser> zinfo = fillChildren(one, allPeopleList, depth - 1); |
| | | List<ZInfoUser> zinfo = fillChildren2(one, allPeopleList, depth - 1); |
| | | one.setChildList(zinfo); |
| | | System.out.println(one); |
| | | return one; |