| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | |
| | | import com.ruoyi.common.utils.MapUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.domain.ZInfoUser; |
| | | import com.ruoyi.domain.ZfEvent; |
| | | import com.ruoyi.domain.ZfRelation; |
| | | import com.ruoyi.domain.*; |
| | | import com.ruoyi.domain.dto.*; |
| | | import com.ruoyi.mapper.ZInfoUserMapper; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | | import com.ruoyi.service.ZfRelationService; |
| | | import com.ruoyi.service.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | |
| | | @Autowired |
| | | private ZInfoUserService zInfoUserService; |
| | | |
| | | @Resource |
| | | private ZfFamilyService zfFamilyService; |
| | | |
| | | |
| | | @Resource |
| | | private ZfRoleService zfRoleService; |
| | | |
| | | @Resource |
| | | private ZfClanService zfClanService; |
| | | |
| | | |
| | | @Override |
| | | public AjaxResult selectInfoList(ZInfoUser zInfoUser, Integer pageNum, Integer pageSize) { |
| | | |
| | | LambdaQueryWrapper<ZInfoUser> lqw = buildCondition(zInfoUser); |
| | | |
| | | Page<ZInfoUser> zInfoUserPage = new Page<>(pageNum,pageSize); |
| | | Page<ZInfoUser> zInfoUserPage = new Page<>(pageNum, pageSize); |
| | | Page<ZInfoUser> pageResult = page(zInfoUserPage, lqw); |
| | | |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult); |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public Boolean findByuid(Long uid, Long tfid) { |
| | | |
| | | |
| | | if(uid==null) |
| | | return false; |
| | | // System.out.println(tfid); |
| | | // System.out.println("00000000000---------------"); |
| | | ZInfoUser infu = this.getById(tfid); |
| | | if(infu==null) |
| | | return false; |
| | | if(infu.getFatherId()!=null && uid.equals(infu.getFatherId())) |
| | | return true; |
| | | if(infu.getMomId()!=null && uid.equals(infu.getMomId())) |
| | | return true; |
| | | return findByuid(uid, infu.getFatherId()) || findByuid(uid, infu.getMomId()); |
| | | } |
| | | |
| | | @Override |
| | | public List<ZInfoUser> findByUaidToFaid(String usid) { |
| | | if(usid!=null) { |
| | | ZInfoUser zInfoUser = new ZInfoUser(); |
| | | zInfoUser.setUaid(usid); |
| | | LambdaQueryWrapper<ZInfoUser> lqw = buildCondition(zInfoUser); |
| | | List<ZInfoUser> ls = list(lqw); |
| | | // System.out.println(ls.size()+":==========sdfs55dfsdf"); |
| | | return ls; |
| | | }else { |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<ZInfoUser> selectByClanId(Integer clanId) { |
| | | ZInfoUser zInfoUser = new ZInfoUser(); |
| | | zInfoUser.setClanId(clanId); |
| | | LambdaQueryWrapper<ZInfoUser> lqw = buildCondition(zInfoUser); |
| | | return list(lqw); |
| | | } |
| | | |
| | | |
| | | // public List<ZInfoUser> selectByNickName(String nickName){ |
| | | // ZInfoUser zInfoUser = new ZInfoUser(); |
| | | // zInfoUser.setNickName(nickName); |
| | | // LambdaQueryWrapper<ZInfoUser> lqw = buildCondition(zInfoUser); |
| | | // return list(lqw); |
| | | // } |
| | | |
| | | @Override |
| | | public AjaxResult findUserNameAClan(List<String> nickNames) |
| | | { |
| | | List<ZfShareOther> shareOtherClans = new ArrayList<>(); |
| | | for (String nickName:nickNames) { |
| | | ZInfoUser zInfoUser = new ZInfoUser(); |
| | | zInfoUser.setNickName(nickName); |
| | | |
| | | LambdaQueryWrapper<ZInfoUser> lqw = buildCondition(zInfoUser); |
| | | List<ZInfoUser> zInfoUsers = list(lqw); |
| | | |
| | | |
| | | for (ZInfoUser zInfoUser1: zInfoUsers) { |
| | | ZfShareOther shareOtherClan = new ZfShareOther(); |
| | | shareOtherClan.setUserName(zInfoUser1.getNickName()); |
| | | shareOtherClan.setUserId(zInfoUser1.getUserId().intValue()); |
| | | shareOtherClan.setClanId(zInfoUser1.getClanId()); |
| | | shareOtherClan.setClanName(zfClanService.getById(zInfoUser1.getClanId()).getClanName()); |
| | | shareOtherClans.add(shareOtherClan); |
| | | }} |
| | | return AjaxResult.success(shareOtherClans); |
| | | } |
| | | |
| | | @Override |
| | | public ZInfoUser getInfoBysysId(Long sysid) { |
| | | LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZInfoUser::getSysId, sysid); |
| | | List<ZInfoUser> list = list(lqw); |
| | | if(list.size()>0) |
| | | return list.get(0); |
| | | else |
| | | return null; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<ZInfoUser> getDataBySex(Integer sex, Integer clanId){ |
| | | LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZInfoUser::getSex, sex); |
| | | lqw.eq(ZInfoUser::getClanId, clanId); |
| | | List<ZInfoUser> list = list(lqw); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult getInfoByfid(Long fid) { |
| | | LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZInfoUser::getFamilyId, fid); |
| | | lqw.eq(ZInfoUser::getIsMyFamily, 1L); |
| | | lqw.isNull(ZInfoUser::getSpouseId); |
| | | List<ZInfoUser> list = list(lqw); |
| | | |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<ZInfoUser> buildCondition(ZInfoUser zInfoUser) { |
| | | |
| | | LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(zInfoUser.getUserId()!=null,ZInfoUser::getUserId,zInfoUser.getUserId()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getAlwaysAddress()),ZInfoUser::getAlwaysAddress,zInfoUser.getAlwaysAddress()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getAlwaysPolice()),ZInfoUser::getAlwaysPolice,zInfoUser.getAlwaysPolice()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getIdNum()),ZInfoUser::getIdNum,zInfoUser.getIdNum()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getLocationAddress()),ZInfoUser::getLocationAddress,zInfoUser.getLocationAddress()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getLocationPolice()),ZInfoUser::getLocationPolice,zInfoUser.getLocationPolice()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getNation()),ZInfoUser::getNation,zInfoUser.getNation()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getNationality()),ZInfoUser::getNationality,zInfoUser.getNationality()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getNickName()),ZInfoUser::getNickName,zInfoUser.getNickName()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getOldName()),ZInfoUser::getOldName,zInfoUser.getOldName()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getPhoneNumber()),ZInfoUser::getPhoneNumber,zInfoUser.getPhoneNumber()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getPoliticalOutlook()),ZInfoUser::getPoliticalOutlook,zInfoUser.getPoliticalOutlook()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getPosition()),ZInfoUser::getPosition,zInfoUser.getPosition()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getUnit()),ZInfoUser::getUnit,zInfoUser.getUnit()); |
| | | lqw.like(zInfoUser.getSex()!=null,ZInfoUser::getSex,zInfoUser.getSex()); |
| | | lqw.like(zInfoUser.getMaritalStatus()!=null,ZInfoUser::getMaritalStatus,zInfoUser.getMaritalStatus()); |
| | | lqw.like(zInfoUser.getBirth()!=null,ZInfoUser::getBirth,zInfoUser.getBirth()); |
| | | lqw.eq(zInfoUser.getUserId() != null, ZInfoUser::getUserId, zInfoUser.getUserId()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getAlwaysAddress()), ZInfoUser::getAlwaysAddress, zInfoUser.getAlwaysAddress()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getAlwaysPolice()), ZInfoUser::getAlwaysPolice, zInfoUser.getAlwaysPolice()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getIdNum()), ZInfoUser::getIdNum, zInfoUser.getIdNum()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getLocationAddress()), ZInfoUser::getLocationAddress, zInfoUser.getLocationAddress()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getLocationPolice()), ZInfoUser::getLocationPolice, zInfoUser.getLocationPolice()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getNation()), ZInfoUser::getNation, zInfoUser.getNation()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getNationality()), ZInfoUser::getNationality, zInfoUser.getNationality()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getNickName()), ZInfoUser::getNickName, zInfoUser.getNickName()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getOldName()), ZInfoUser::getOldName, zInfoUser.getOldName()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getPhoneNumber()), ZInfoUser::getPhoneNumber, zInfoUser.getPhoneNumber()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getPoliticalOutlook()), ZInfoUser::getPoliticalOutlook, zInfoUser.getPoliticalOutlook()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getPosition()), ZInfoUser::getPosition, zInfoUser.getPosition()); |
| | | lqw.like(StringUtils.isNotEmpty(zInfoUser.getUnit()), ZInfoUser::getUnit, zInfoUser.getUnit()); |
| | | lqw.like(zInfoUser.getSex() != null, ZInfoUser::getSex, zInfoUser.getSex()); |
| | | lqw.like(zInfoUser.getMaritalStatus() != null, ZInfoUser::getMaritalStatus, zInfoUser.getMaritalStatus()); |
| | | lqw.le(zInfoUser.getBirth() != null, ZInfoUser::getBirth, zInfoUser.getBirth()); |
| | | lqw.like(zInfoUser.getClanId() != null, ZInfoUser::getClanId, zInfoUser.getClanId()); |
| | | |
| | | lqw.eq(zInfoUser.getUaid() !=null, ZInfoUser::getUaid, zInfoUser.getUaid()); |
| | | return lqw; |
| | | |
| | | } |
| | |
| | | public List<ZInfoUser> selectByCondition(ZInfoUser zInfoUser) { |
| | | LambdaQueryWrapper<ZInfoUser> lambdaQueryWrapper = buildCondition(zInfoUser); |
| | | List<ZInfoUser> list = list(lambdaQueryWrapper); |
| | | log.info("返回的数据为:{}",list); |
| | | log.info("返回的数据为:{}", list); |
| | | |
| | | return list; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult removeByUserName(List<String> userName) { |
| | | LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.in(ZInfoUser::getNickName,String.valueOf(userName.get(0))); |
| | | System.out.println(userName.get(0)); |
| | | List<ZInfoUser> beanRecords = list(lqw); |
| | | System.out.println("555555555555555555"+beanRecords); |
| | | List<Long> ids = list(lqw).stream().map(ZInfoUser::getUserId).collect(Collectors.toList());; |
| | | removeByIds(ids); |
| | | return AjaxResult.success("删除成功"); |
| | | } |
| | | |
| | | @Override |
| | | public List<ZInfoUser> selectByFamId(long fid) { |
| | | LambdaQueryWrapper<ZfFamily> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZfFamily::getId, fid); |
| | | ZfFamily zfFamily = zfFamilyService.list(lqw).get(0); |
| | | LambdaQueryWrapper<ZInfoUser> lqws = new LambdaQueryWrapper<>(); |
| | | lqws.eq(ZInfoUser::getFatherId, zfFamily.getFid()); |
| | | // lqws.eq(ZInfoUser::getMomId, zfFamily.getMid()); |
| | | List<ZInfoUser> list = list(lqws); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | |
| | | Long userId = user.getUserId(); |
| | | |
| | | LambdaQueryWrapper<ZfRelation> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZfRelation::getMyId,userId); |
| | | lqw.eq(ZfRelation::getMyId, userId); |
| | | |
| | | List<ZfRelation> list = zfRelationService.list(lqw); |
| | | return AjaxResult.success(list); |
| | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 给用户授权的方法 |
| | | * @param empowerDto |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public AjaxResult empower(EmpowerDto empowerDto) { |
| | | // @Override |
| | | // public AjaxResult empower(EmpowerDto empowerDto) { |
| | | // return null; |
| | | // } |
| | | |
| | | //得到dto中的信息 |
| | | String otherUserId = empowerDto.getUserId(); |
| | | String destinationFamilyId = empowerDto.getFamilyId(); |
| | | List<String> authorityList = empowerDto.getAuthorityList(); |
| | | |
| | | String familyId = getMyFamilyId(); |
| | | checkAuthorization(familyId, destinationFamilyId,true); |
| | | |
| | | //授权 //3{2007 1988 1004} |
| | | String finalStr = getFinalStr(destinationFamilyId, authorityList); |
| | | |
| | | //更新被授权用户的权限 |
| | | LambdaQueryWrapper<ZInfoUser> lqw2 = new LambdaQueryWrapper<>(); |
| | | lqw2.eq(ZInfoUser::getUserId,otherUserId); |
| | | ZInfoUser otherUser = getOne(lqw2); |
| | | String secondFamilyId = otherUser.getSecondFamilyId(); |
| | | |
| | | String replaceFamilyId=null; |
| | | |
| | | boolean save=true; |
| | | |
| | | if (StringUtils.isNotEmpty(secondFamilyId)){ |
| | | //如果原来就已经有被赋予权限了,那么需要判断是不是跟这个家庭号有关的权限 |
| | | |
| | | //这个secondFamilyId是当前用户的完整权限字段 |
| | | if(secondFamilyId.contains(",")){ |
| | | String[] split = secondFamilyId.split(","); |
| | | for (int i = 0; i < split.length; i++) { |
| | | String fid = split[i].substring(0, split[i].indexOf("{"));//从权限块中拿到被授权的家庭号 |
| | | if(fid.equals(finalStr.substring(0,finalStr.indexOf("{")))){ |
| | | //如果匹配到了对应的家庭号,那么就替换掉对应的权限块就可以了,不需要追加 |
| | | save=false; |
| | | split[i]=finalStr; |
| | | break; |
| | | } |
| | | } |
| | | List<String> finalList = Arrays.asList(split); |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | for (String s : finalList) { |
| | | stringBuilder.append(s).append(","); |
| | | } |
| | | stringBuilder.deleteCharAt(stringBuilder.length()-1); |
| | | |
| | | replaceFamilyId = stringBuilder.toString(); |
| | | |
| | | }else { |
| | | String fid = secondFamilyId.substring(0, secondFamilyId.indexOf("{"));//从权限块中拿到被授权的家庭号 |
| | | if(fid.equals(finalStr.substring(0,finalStr.indexOf("{")))){ |
| | | //如果匹配到了对应的家庭号,那么就替换掉对应的权限块就可以了,不需要追加 |
| | | save=false; |
| | | replaceFamilyId=finalStr; |
| | | } |
| | | } |
| | | |
| | | if(save){ |
| | | //需要追加,没有匹配到对应的家庭号 |
| | | replaceFamilyId=secondFamilyId+","+finalStr; |
| | | }else { |
| | | //不需要追加 |
| | | } |
| | | |
| | | }else { |
| | | //原来就没有权限了 |
| | | replaceFamilyId=finalStr; |
| | | } |
| | | |
| | | LambdaUpdateWrapper<ZInfoUser> uw = new LambdaUpdateWrapper<>(); |
| | | uw.eq(ZInfoUser::getUserId,otherUserId).set(ZInfoUser::getSecondFamilyId,replaceFamilyId); |
| | | if (update(null,uw)) { |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | } |
| | | // /** |
| | | // * 给用户授权的方法 |
| | | // * @param empowerDto |
| | | // * @return |
| | | // */ |
| | | // @Override |
| | | // @Transactional |
| | | // public AjaxResult empower(EmpowerDto empowerDto) { |
| | | // |
| | | // //得到dto中的信息 |
| | | // String otherUserId = empowerDto.getUserId(); |
| | | // String destinationFamilyId = empowerDto.getFamilyId(); |
| | | // List<String> authorityList = empowerDto.getAuthorityList(); |
| | | // |
| | | // String familyId = getMyFamilyId(); |
| | | // checkAuthorization(familyId, destinationFamilyId,true); |
| | | // |
| | | // //授权 //3{2007 1988 1004} |
| | | // String finalStr = getFinalStr(destinationFamilyId, authorityList); |
| | | // |
| | | // //更新被授权用户的权限 |
| | | // LambdaQueryWrapper<ZInfoUser> lqw2 = new LambdaQueryWrapper<>(); |
| | | // lqw2.eq(ZInfoUser::getUserId,otherUserId); |
| | | // ZInfoUser otherUser = getOne(lqw2); |
| | | // String secondFamilyId = otherUser.getSecondFamilyId(); |
| | | // |
| | | // String replaceFamilyId=null; |
| | | // |
| | | // boolean save=true; |
| | | // |
| | | // if (StringUtils.isNotEmpty(secondFamilyId)){ |
| | | // //如果原来就已经有被赋予权限了,那么需要判断是不是跟这个家庭号有关的权限 |
| | | // |
| | | // //这个secondFamilyId是当前用户的完整权限字段 |
| | | // if(secondFamilyId.contains(",")){ |
| | | // String[] split = secondFamilyId.split(","); |
| | | // for (int i = 0; i < split.length; i++) { |
| | | // String fid = split[i].substring(0, split[i].indexOf("{"));//从权限块中拿到被授权的家庭号 |
| | | // if(fid.equals(finalStr.substring(0,finalStr.indexOf("{")))){ |
| | | // //如果匹配到了对应的家庭号,那么就替换掉对应的权限块就可以了,不需要追加 |
| | | // save=false; |
| | | // split[i]=finalStr; |
| | | // break; |
| | | // } |
| | | // } |
| | | // List<String> finalList = Arrays.asList(split); |
| | | // StringBuilder stringBuilder = new StringBuilder(); |
| | | // for (String s : finalList) { |
| | | // stringBuilder.append(s).append(","); |
| | | // } |
| | | // stringBuilder.deleteCharAt(stringBuilder.length()-1); |
| | | // |
| | | // replaceFamilyId = stringBuilder.toString(); |
| | | // |
| | | // }else { |
| | | // String fid = secondFamilyId.substring(0, secondFamilyId.indexOf("{"));//从权限块中拿到被授权的家庭号 |
| | | // if(fid.equals(finalStr.substring(0,finalStr.indexOf("{")))){ |
| | | // //如果匹配到了对应的家庭号,那么就替换掉对应的权限块就可以了,不需要追加 |
| | | // save=false; |
| | | // replaceFamilyId=finalStr; |
| | | // } |
| | | // } |
| | | // |
| | | // if(save){ |
| | | // //需要追加,没有匹配到对应的家庭号 |
| | | // replaceFamilyId=secondFamilyId+","+finalStr; |
| | | // }else { |
| | | // //不需要追加 |
| | | // } |
| | | // |
| | | // }else { |
| | | // //原来就没有权限了 |
| | | // replaceFamilyId=finalStr; |
| | | // } |
| | | // |
| | | // LambdaUpdateWrapper<ZInfoUser> uw = new LambdaUpdateWrapper<>(); |
| | | // uw.eq(ZInfoUser::getUserId,otherUserId).set(ZInfoUser::getSecondFamilyId,replaceFamilyId); |
| | | // if (update(null,uw)) { |
| | | // return AjaxResult.success(); |
| | | // }else { |
| | | // return AjaxResult.error(); |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | |
| | | private void checkAuthorization(String familyId, String destinationFamilyId,boolean flag) { |
| | | String text=null; |
| | | if(flag){ |
| | | text="授权"; |
| | | }else { |
| | | text="取消授权"; |
| | | private void checkAuthorization(String familyId, String destinationFamilyId, boolean flag) { |
| | | String text = null; |
| | | if (flag) { |
| | | text = "授权"; |
| | | } else { |
| | | text = "取消授权"; |
| | | } |
| | | |
| | | //对本人的家庭号进行处理 |
| | | if(familyId.contains(",")){ |
| | | if (familyId.contains(",")) { |
| | | String[] familyIds = familyId.split(","); |
| | | List<String> idList = Arrays.asList(familyIds); |
| | | if (!idList.contains(destinationFamilyId)) { |
| | | throw new RuntimeException("不能"+text+"不属于自己家庭的数据"); |
| | | throw new RuntimeException("不能" + text + "不属于自己家庭的数据"); |
| | | } |
| | | }else { |
| | | if (!familyId.equals(destinationFamilyId)){ |
| | | throw new RuntimeException("不能"+text+"不属于自己家庭的数据"); |
| | | } else { |
| | | if (!familyId.equals(destinationFamilyId)) { |
| | | throw new RuntimeException("不能" + text + "不属于自己家庭的数据"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private String getMyFamilyId() { |
| | | private Long getMyFamilyId() { |
| | | //得到自己的家庭id信息 |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long myUserId = user.getUserId(); |
| | | LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZInfoUser::getUserId,myUserId); |
| | | lqw.eq(ZInfoUser::getUserId, myUserId); |
| | | ZInfoUser zInfoUser = getOne(lqw); |
| | | String familyId = zInfoUser.getFamilyId(); |
| | | Long familyId = zInfoUser.getFamilyId(); |
| | | return familyId; |
| | | } |
| | | |
| | | private String getFinalStr(String destinationFamilyId, List<String> authorityList) { |
| | | String authorityListStr = authorityList.stream().collect(Collectors.joining(" ", "{", "}")); |
| | | String finalStr= destinationFamilyId +authorityListStr; //3{2007 1988 1004} |
| | | String finalStr = destinationFamilyId + authorityListStr; //3{2007 1988 1004} |
| | | return finalStr; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取家根网 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public AjaxResult listWithTree(Integer depth) { |
| | | |
| | | List<ZInfoUser> allPeopleList = list(); |
| | | public AjaxResult listWithTree(Integer depth, Integer clanId) { |
| | | LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(clanId!=null, ZInfoUser::getClanId, clanId); |
| | | // List<ZfEvent> list = list(lqw); |
| | | List<ZInfoUser> allPeopleList = list(lqw); |
| | | List<ZInfoUser> result = null; |
| | | try { |
| | | result = allPeopleList.stream().filter(people -> people.getUserId()!=1&&(people.getFatherId() == 0||people.getMomId()==0)) |
| | | // try { |
| | | // 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); |
| | | // spouse.setIdentity(1); |
| | | // people.setSpouse(spouse); |
| | | // people.setChildList(fillChildren(people, allPeopleList, depth-1)); |
| | | // } |
| | | // return people; |
| | | // }).collect(Collectors.toList()); |
| | | // } catch (NullPointerException e) { |
| | | // throw new RuntimeException("您在加入成员的时候没有指定该成员的父亲或者母亲"); |
| | | // } |
| | | |
| | | List<ZInfoUser> myFamilyPeopleList = allPeopleList.stream().filter(people -> people.getUserId() != 1 && people.getIsMyFamily() == 1).collect(Collectors.toList()); |
| | | |
| | | result = allPeopleList.stream().filter(people -> people!=null && people.getUserId() != 1 && ((people.getFatherId()!=null &&people.getFatherId() == 0 )|| (people.getMomId()!=null&&people.getMomId() == 0)) && people.getIsMyFamily() == 1) |
| | | .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)); |
| | | // System.out.println("======================================="); |
| | | // System.out.println(people); |
| | | if (depth > 1) { |
| | | if(people!=null) { |
| | | people.setIdentity(1); |
| | | //根据配偶id查询配偶的数据,封装好一起返回 |
| | | Long spouseId = people.getSpouseId(); |
| | | if (spouseId != null) { |
| | | ZInfoUser spouse = zInfoUserService.getById(spouseId); |
| | | spouse.setIdentity(1); |
| | | people.setSpouse(spouse); |
| | | } |
| | | people.setChildList(fillChildren(people, myFamilyPeopleList, depth - 1)); |
| | | } |
| | | } |
| | | // System.out.println("+++++++++++++++++++++++++++++"); |
| | | // System.out.println(people); |
| | | return people; |
| | | }).collect(Collectors.toList()); |
| | | } catch (NullPointerException e) { |
| | | throw new RuntimeException("您在加入成员的时候没有指定该成员的父亲或者母亲"); |
| | | } |
| | | |
| | | |
| | | // |
| | | //System.out.println("--------------++++++++++++++++--------------"); |
| | | //System.out.println(result); |
| | | return AjaxResult.success(result); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 条件获取家庭成员 |
| | | * |
| | | * @return |
| | | */ |
| | | public AjaxResult listWithTreeByCondition(Integer depth,Genealogy genealogy) { |
| | | public AjaxResult listWithTreeByCondition(Integer depth, Genealogy genealogy) { |
| | | |
| | | ZInfoUser zInfoUser = new ZInfoUser(); |
| | | BeanUtils.copyProperties(genealogy,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()); |
| | | |
| | | // lqw.eq(zInfoUser.getSex() != null, ZInfoUser::getSex, zInfoUser.getSex()); |
| | | // lqw.like(StringUtils.isNotEmpty(zInfoUser.getNickName()), ZInfoUser::getNickName, zInfoUser.getNickName()); |
| | | // lqw.between(zInfoUser.getBirth() != null, ZInfoUser::getBirth, zInfoUser.getBirth(),zInfoUser.getBirth()); |
| | | lqw.eq(zInfoUser.getClanId()!=null, ZInfoUser::getClanId,zInfoUser.getClanId()); |
| | | List<ZInfoUser> allPeopleList = list(lqw); |
| | | // System.out.println(allPeopleList); |
| | | //System.out.println("============z=============zzzzzzzzzzzzzzzzzzz"); |
| | | |
| | | // List<ZInfoUser> allPeopleList = list(); |
| | | List<ZInfoUser> result = null; |
| | | try { |
| | | result = allPeopleList.stream().filter(people -> people.getUserId()!=1&&(people.getFatherId() == 0||people.getMomId()==0)) |
| | | result = allPeopleList.stream().filter(people -> people.getUserId() != 1 && ((people.getFatherId()!=null&&people.getFatherId() == 0) || (people.getMomId()!=null&&people.getMomId() == 0))) |
| | | .map(people -> { |
| | | if(depth>1){ |
| | | 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("您在加入成员的时候没有指定该成员的父亲或者母亲"); |
| | | } |
| | | |
| | | // System.out.println(result); |
| | | |
| | | // 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){ |
| | | // |
| | | // } |
| | | // } |
| | | // ) |
| | | |
| | | |
| | | // if(genealogy.getIdentity()!=null){ |
| | | // result = result.stream().filter(data -> data.getIdentity() == genealogy.getIdentity()).collect(Collectors.toList()); |
| | | // } |
| | | |
| | | return AjaxResult.success(result); |
| | | |
| | | } |
| | |
| | | |
| | | /** |
| | | * 家谱信息 |
| | | * |
| | | * @param genealogy |
| | | * @return |
| | | */ |
| | | @Override |
| | | public AjaxResult listGenealogy(Genealogy genealogy,Integer pageNum,Integer pageSize) { |
| | | List<ZInfoUser> treeList= (List<ZInfoUser>) listWithTreeByCondition(100,genealogy).get("data"); |
| | | public AjaxResult listGenealogy(Genealogy genealogy, Integer pageNum, Integer pageSize) { |
| | | userList.clear(); |
| | | List<ZInfoUser> treeList = (List<ZInfoUser>) listWithTreeByCondition(100, genealogy).get("data"); |
| | | recursionFindUser(treeList); |
| | | |
| | | List<Genealogy> allData = userList.stream().map( |
| | | zInfoUser -> { |
| | | Genealogy newGenealogy = new Genealogy(); |
| | | BeanUtils.copyProperties(zInfoUser, newGenealogy); |
| | | List<Genealogy> allData = userList.stream().map( |
| | | zInfoUser -> { |
| | | Genealogy newGenealogy = new Genealogy(); |
| | | BeanUtils.copyProperties(zInfoUser, newGenealogy); |
| | | |
| | | if(zInfoUser.getSpouseId()!=null){ |
| | | ZInfoUser spouse = getById(zInfoUser.getSpouseId()); |
| | | newGenealogy.setSpouseName(spouse.getNickName()); |
| | | } |
| | | return newGenealogy; |
| | | } |
| | | if (zInfoUser.getSpouseId() != null) { |
| | | ZInfoUser spouse = getById(zInfoUser.getSpouseId()); |
| | | |
| | | Genealogy spouseInfo = new Genealogy(); |
| | | BeanUtils.copyProperties(spouse,spouseInfo); |
| | | newGenealogy.setSpouse(spouseInfo); |
| | | spouseInfo.setIdentity(newGenealogy.getIdentity()); |
| | | spouseInfo.setSpouseName(zInfoUser.getNickName()); |
| | | newGenealogy.setSpouseName(spouse.getNickName()); |
| | | } |
| | | System.out.println(newGenealogy); |
| | | return newGenealogy; |
| | | } |
| | | ).collect(Collectors.toList()); |
| | | List<Genealogy> collect = allData.stream() |
| | | .distinct() |
| | | .filter((data)-> data.getIsMyFamily() == 1) |
| | | .sorted(Comparator.comparing(Genealogy::getIdentity)) |
| | | .collect(Collectors.toList()); |
| | | List<Genealogy> resultData = new ArrayList<>(); |
| | | |
| | | List<Genealogy> collect = allData.stream().distinct().sorted(Comparator.comparing(Genealogy::getIdentity)).collect(Collectors.toList()); |
| | | List<Genealogy> resultData= new ArrayList<>(); |
| | | |
| | | for (int i = (pageNum-1)*pageSize; i <pageNum*pageSize+pageSize; i++) { |
| | | if(i>=collect.size()){ |
| | | // System.out.println(resultData); |
| | | // System.out.println("999999999988888888888++++++++++++++++++++++"); |
| | | // |
| | | // |
| | | //对result做一个条件筛选 |
| | | Iterator<Genealogy> it = collect.iterator(); |
| | | while(it.hasNext()){ |
| | | Genealogy data = it.next(); |
| | | |
| | | if(genealogy.getIdentity()!=null){ |
| | | if(data.getIdentity()!=genealogy.getIdentity()){ |
| | | it.remove(); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if(genealogy.getNickName()!=null){ |
| | | if(!data.getNickName().contains(genealogy.getNickName())){ |
| | | it.remove(); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if(genealogy.getSex()!=null){ |
| | | if(data.getSex()!=genealogy.getSex()){ |
| | | it.remove(); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if(genealogy.getPhoneNumber()!=null){ |
| | | if(data.getPhoneNumber()!=genealogy.getPhoneNumber()){ |
| | | it.remove(); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if(genealogy.getUnit()!=null){ |
| | | if(data.getUnit()!=genealogy.getUnit()){ |
| | | it.remove(); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if(genealogy.getBirth()!=null){ |
| | | if(data.getBirth()!=null) { |
| | | if (data.getBirth().compareTo(genealogy.getBirth()) != 0) { |
| | | it.remove(); |
| | | } |
| | | } |
| | | else it.remove(); |
| | | } |
| | | } |
| | | |
| | | // System.out.println(resultData); |
| | | |
| | | // System.out.println("================++++++++++++++66666666666666666999999999"); |
| | | |
| | | |
| | | // 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); |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | for (int i = (pageNum - 1) * pageSize; i < pageNum * pageSize; i++) { |
| | | if (i >= collect.size()) { |
| | | break; |
| | | } |
| | | System.out.println(i+"//////"+collect.get(i)); |
| | | resultData.add(collect.get(i)); |
| | | } |
| | | |
| | | HashMap<String, Object> resultMap = new HashMap<>(); |
| | | resultMap.put("data",resultData); |
| | | resultMap.put("total",collect.size()); |
| | | resultMap.put("pageNum",pageNum); |
| | | resultMap.put("pageSize",pageSize); |
| | | resultMap.put("data", resultData); |
| | | resultMap.put("total", collect.size()); |
| | | resultMap.put("pageNum", pageNum); |
| | | resultMap.put("pageSize", pageSize); |
| | | |
| | | return AjaxResult.success(resultMap); |
| | | } |
| | |
| | | ArrayList<Genealogy> result = new ArrayList<>(); |
| | | for (ZInfoUser zInfoUser : zInfoUsers) { |
| | | Genealogy genealogy = new Genealogy(); |
| | | BeanUtils.copyProperties(zInfoUser,genealogy); |
| | | if(zInfoUser.getSpouseId()!=null){ |
| | | BeanUtils.copyProperties(zInfoUser, genealogy); |
| | | if (zInfoUser.getSpouseId() != null) { |
| | | ZInfoUser spouse = getById(zInfoUser.getSpouseId()); |
| | | Genealogy spouseInfo = new Genealogy(); |
| | | BeanUtils.copyProperties(spouse,spouseInfo); |
| | | spouseInfo.setIdentity(genealogy.getIdentity()); |
| | | spouseInfo.setSpouseName(zInfoUser.getNickName()); |
| | | genealogy.setSpouse(spouseInfo); |
| | | genealogy.setSpouseName(spouse.getNickName()); |
| | | } |
| | | result.add(genealogy); |
| | | } |
| | | |
| | | System.out.println("导出的数据为:"+result); |
| | | System.out.println("导出的数据为:" + result); |
| | | return result; |
| | | |
| | | } |
| | |
| | | ArrayList<Genealogy> result = new ArrayList<>(); |
| | | for (int i = 0; i < zInfoUsers.size(); i++) { |
| | | Genealogy genealogy = new Genealogy(); |
| | | BeanUtils.copyProperties(zInfoUsers.get(i),genealogy); |
| | | BeanUtils.copyProperties(zInfoUsers.get(i), genealogy); |
| | | genealogy.setIdentity(params.get(i).getIdentity()); |
| | | if(zInfoUsers.get(i).getSpouseId()!=null){ |
| | | if (zInfoUsers.get(i).getSpouseId() != null) { |
| | | ZInfoUser spouse = getById(zInfoUsers.get(i).getSpouseId()); |
| | | Genealogy spouseInfo = new Genealogy(); |
| | | BeanUtils.copyProperties(spouse,spouseInfo); |
| | | spouseInfo.setIdentity(genealogy.getIdentity()); |
| | | genealogy.setSpouseName(spouse.getNickName()); |
| | | spouseInfo.setSpouseName(zInfoUsers.get(i).getNickName()); |
| | | genealogy.setSpouse(spouseInfo); |
| | | |
| | | } |
| | | result.add(genealogy); |
| | | |
| | | } |
| | | System.out.println("导出的数据为:"+result); |
| | | System.out.println("导出的数据为:" + result); |
| | | return result; |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public ZInfoUser getInfoById(Long userId) { |
| | | ZInfoUser user = getInfoBysysId(userId); |
| | | |
| | | private void recursionFindUser(List<ZInfoUser> treeList){ |
| | | if (treeList==null||treeList.isEmpty()){ |
| | | if(user==null) { |
| | | //利用userId查询 |
| | | LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZInfoUser::getUserId, userId); |
| | | List<ZInfoUser> list = list(lqw); |
| | | if(list.size()>0) |
| | | user = list.get(0); |
| | | else |
| | | return null; |
| | | |
| | | } |
| | | |
| | | Long familyId = user.getFamilyId(); |
| | | // System.out.println("dddddddddddddddddddd"); |
| | | if(user.getRoleId()==null) |
| | | user.setRoleId(3L); |
| | | String roleName = zfRoleService.getById(user.getRoleId()).getName(); |
| | | |
| | | user.setRoleName(roleName); |
| | | return user; |
| | | } |
| | | |
| | | // @Override |
| | | // public ZInfoUser getInfoById(Long userId) { |
| | | // |
| | | // ZInfoUser user = getById(userId); |
| | | // |
| | | // //用逗号隔开的家庭id |
| | | // String familyId = user.getFamilyId(); |
| | | // |
| | | // //在自己家庭中角色的id |
| | | // Long roleId = user.getRoleId(); |
| | | // |
| | | // ArrayList<String> familyList = new ArrayList<>(); |
| | | // |
| | | // //填充所属家庭 |
| | | // if(familyId.contains(",")){ |
| | | // String[] familyIds = familyId.split(","); |
| | | // for (String id : familyIds) { |
| | | // familyList.add(zfFamilyService.getById(id).getName()); |
| | | // } |
| | | // }else { |
| | | // familyList.add(zfFamilyService.getById(familyId).getName()); |
| | | // } |
| | | // |
| | | // user.setFamilyList(familyList); |
| | | // |
| | | // //填充所在家庭的角色 |
| | | // user.setRole(zfRoleService.getById(roleId).getName()); |
| | | // |
| | | // return user; |
| | | // } |
| | | |
| | | @Override |
| | | public ZInfoUser getMyself() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | // System.out.println(userId); |
| | | //System.out.println("-----------------++++++++9999++++++++++----------"); |
| | | ZInfoUser zInfoUser = new ZInfoUser(); |
| | | zInfoUser.setSysId(userId); |
| | | LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(zInfoUser.getSysId() != null, ZInfoUser::getSysId, zInfoUser.getSysId()); |
| | | List<ZInfoUser> list = list(lqw); |
| | | if(!list.isEmpty()) |
| | | return list.get(0); |
| | | else |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult listGenealogy2(Genealogy genealogy, Integer pageNum, Integer pageSize) { |
| | | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | private void recursionFindUser(List<ZInfoUser> treeList) { |
| | | if (treeList == null || treeList.isEmpty()) { |
| | | return; |
| | | } |
| | | for (ZInfoUser zInfoUser : treeList) { |
| | | userList.add(zInfoUser); |
| | | if (!zInfoUser.getChildList().isEmpty()){ |
| | | if (!zInfoUser.getChildList().isEmpty()) { |
| | | recursionFindUser(zInfoUser.getChildList()); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 为了家根网、新增或者修改父子关系 |
| | | * |
| | | * @param fatherId |
| | | * @param motherId |
| | | * @return |
| | |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId,userId); |
| | | zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getUserId, userId); |
| | | ZInfoUser zInfoUser = getOne(zInfoUserLambdaQueryWrapper); |
| | | |
| | | zInfoUser.setFatherId(fatherId); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult listAllFamilyPeople(Integer clanId) { |
| | | // List<ZInfoUser> lis = list(); |
| | | // for(ZInfoUser tm: lis) |
| | | // { |
| | | // System.out.println(tm.getRoleId()); |
| | | // } |
| | | LambdaQueryWrapper<ZInfoUser> zInfoUserLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | zInfoUserLambdaQueryWrapper.eq(ZInfoUser::getClanId, clanId); |
| | | List<ZInfoUser> lis = list(zInfoUserLambdaQueryWrapper); |
| | | List<ZInfoUser> collect = lis.stream().filter(zInfoUser -> zInfoUser!=null&&zInfoUser.getRoleId()!=null&&zInfoUser.getRoleId()== 3).collect(Collectors.toList()); |
| | | |
| | | |
| | | return AjaxResult.success(collect); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult listMySelfAndSpouse(Long id) { |
| | | LambdaQueryWrapper<ZInfoUser> lqw1 = new LambdaQueryWrapper<>(); |
| | | lqw1.eq(ZInfoUser::getUserId,id); |
| | | lqw1.eq(ZInfoUser::getUserId, id); |
| | | ZInfoUser myself = getOne(lqw1); |
| | | Long spouseId = myself.getSpouseId(); |
| | | |
| | | LambdaQueryWrapper<ZInfoUser> lqw2 = new LambdaQueryWrapper<>(); |
| | | lqw2.eq(ZInfoUser::getUserId,spouseId); |
| | | lqw2.eq(ZInfoUser::getUserId, spouseId); |
| | | ZInfoUser spouse = getOne(lqw2); |
| | | |
| | | ArrayList<ZInfoUser> zInfoUsers = new ArrayList<>(); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 递归算法 |
| | | * |
| | | * @param people |
| | | * @param allPeopleList |
| | | * @return |
| | |
| | | private List<ZInfoUser> fillChildren(ZInfoUser people, List<ZInfoUser> allPeopleList, Integer depth) { |
| | | |
| | | // TODO: 2023-05-05 控制递归的次数 |
| | | // if(depth==layer) |
| | | // if(depth==layer) |
| | | |
| | | // layer = layer + 1; |
| | | System.out.println(depth); |
| | | // layer = layer + 1; |
| | | // System.out.println(depth); |
| | | |
| | | // List<ZInfoUser> myFamilyPeopleList = allPeopleList.stream().filter( |
| | | // one -> (one.getFatherId() == people.getUserId() || one.getMomId() == people.getUserId()) && (people.getIsMyFamily() == 1) |
| | | // ).collect(Collectors.toList()); |
| | | |
| | | List<ZInfoUser> collect = allPeopleList.stream().filter( |
| | | one -> (one.getFatherId() == people.getUserId() || one.getMomId() == people.getUserId()) && (people.getIsMyFamily() == 1) |
| | | |
| | | one -> (((one.getFamilyId()!=null && Objects.equals(one.getFatherId(), people.getUserId())) || (one.getMomId()!=null&& one.getMomId().equals(people.getUserId()))) && (one.getIsMyFamily() == 1)) |
| | | ).map( |
| | | one -> { |
| | | if(depth==1) |
| | | return one; |
| | | else { |
| | | one.setIdentity(people.getIdentity()+1); |
| | | |
| | | // System.out.println("++++++++++----0009999"); |
| | | // System.out.println(one); |
| | | if (depth == 0) { |
| | | one.setIdentity(people.getIdentity() + 1); |
| | | //根据配偶id查询配偶的数据,封装好一起返回 |
| | | Long spouseId = one.getSpouseId(); |
| | | ZInfoUser spouse = zInfoUserService.getById(spouseId); |
| | | one.setSpouse(spouse); |
| | | 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); |
| | | // System.out.println(spouseId); |
| | | // System.out.println(spouse); |
| | | // System.out.println("0000))))))))))))))))"); |
| | | spouse.setIdentity(people.getIdentity() + 1); |
| | | one.setSpouse(spouse); |
| | | } |
| | | List<ZInfoUser> zinfo = fillChildren(one, allPeopleList, depth - 1); |
| | | one.setChildList(zinfo); |
| | | System.out.println(one); |
| | | // System.out.println(one); |
| | | return one; |
| | | } |
| | | |
| | | //return one; |
| | | } |
| | | ).collect(Collectors.toList()); |
| | | System.out.println(collect); |
| | | // 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 -> Objects.equals(one.getFatherId(), people.getUserId()) || Objects.equals(one.getMomId(),people.getUserId()) |
| | | ).map( |
| | | one -> { |
| | | if (depth == 1) |
| | | 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 = fillChildren2(one, allPeopleList, depth - 1); |
| | | one.setChildList(zinfo); |
| | | // System.out.println(one); |
| | | return one; |
| | | } |
| | | |
| | | //return one; |
| | | } |
| | | ).collect(Collectors.toList()); |
| | | // System.out.println(collect); |
| | | return collect; |
| | | |
| | | } |