| | |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | // worldCupCompetitors 通过code分组 |
| | | Map<String, List<WorldCupCompetitor>> map = worldCupCompetitors.stream().collect(Collectors.groupingBy(WorldCupCompetitor::getCode)); |
| | | |
| | | LocalDate now = LocalDate.now(); |
| | | for (Map.Entry<String, List<WorldCupCompetitor>> entry : map.entrySet()) { |
| | | WorldCupCodeListVo worldCupCodeListVo = new WorldCupCodeListVo(); |
| | | String code = entry.getKey(); |
| | | List<WorldCupCompetitor> value = entry.getValue(); |
| | | // 蓝队 |
| | | List<WorldCupCompetitor> collect1 = value.stream().filter(item -> item.getParticipant() == 1).collect(Collectors.toList()); |
| | | ArrayList<UserVo> objects = new ArrayList<>(); |
| | | for (WorldCupCompetitor competitor : collect1) { |
| | | UserVo userVo = new UserVo(); |
| | | AppUser appUser = appUserClient.getAppUser(competitor.getAppUserId()); |
| | | userVo.setUserName(appUser.getName()); |
| | | userVo.setAvatar(appUser.getHeadImg()); |
| | | // 当前日期和生日计算年龄 |
| | | Date birthday = appUser.getBirthday(); |
| | | |
| | | if(birthday!=null){ |
| | | int age = now.getYear() - birthday.getYear(); |
| | | userVo.setAge(age); |
| | | } |
| | | objects.add(userVo); |
| | | } |
| | | worldCupCodeListVo.setBlue(objects); |
| | | // 红队 |
| | | List<WorldCupCompetitor> collect2 = value.stream().filter(item -> item.getParticipant() == 2).collect(Collectors.toList()); |
| | | ArrayList<UserVo> objects1 = new ArrayList<>(); |
| | | for (WorldCupCompetitor competitor : collect2) { |
| | | UserVo userVo = new UserVo(); |
| | | AppUser appUser = appUserClient.getAppUser(competitor.getAppUserId()); |
| | | userVo.setUserName(appUser.getName()); |
| | | userVo.setAvatar(appUser.getHeadImg()); |
| | | // 当前日期和生日计算年龄 |
| | | Date birthday = appUser.getBirthday(); |
| | | |
| | | if(birthday!=null){ |
| | | int age = now.getYear() - birthday.getYear(); |
| | | userVo.setAge(age); |
| | | } |
| | | objects1.add(userVo); |
| | | } |
| | | worldCupCodeListVo.setRed(objects1); |
| | | |
| | | worldCupCodeListVo.setCode(code); |
| | | worldCupCodeListVo.setStartTime(value.get(0).getStartTime()); |
| | | worldCupCodeListVo.setWorldCupId(value.get(0).getWorldCupId()); |
| | | Integer worldCupId1 = value.get(0).getWorldCupId(); |
| | | WorldCup byId = worldCupService.getById(worldCupId1); |
| | | worldCupCodeListVo.setWorldCupId(worldCupId1); |
| | | if(byId!=null){ |
| | | worldCupCodeListVo.setName(byId.getName()); |
| | | } |
| | | List<Long> collect = value.stream().map(WorldCupCompetitor::getId).collect(Collectors.toList()); |
| | | worldCupCodeListVo.setCustoms(collect); |
| | | worldCupCodeListVos.add(worldCupCodeListVo); |