| | |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | Integer winIntegral = Integer.valueOf(null == map.get("winIntegral") ? "0" : map.get("winIntegral").toString()); |
| | | Integer drawIntegral = Integer.valueOf(null == map.get("drawIntegral") ? "0" : map.get("drawIntegral").toString()); |
| | | Integer loseIntegral = Integer.valueOf(null == map.get("loseIntegral") ? "0" : map.get("loseIntegral").toString()); |
| | | Integer participationIntegral = Integer.valueOf(null == map.get("participationIntegral") ? "0" : map.get("participationIntegral").toString()); |
| | | //学员 |
| | | if(participantType == 1){ |
| | | TStudent tStudent = studentClient.queryById(participantId.intValue()); |
| | |
| | | } |
| | | } |
| | | map.put("totalSession", num); |
| | | map.put("totalIntegral", winIntegral+drawIntegral+loseIntegral); |
| | | map.put("totalIntegral", winIntegral+drawIntegral+loseIntegral+participationIntegral); |
| | | map.put("winRate", "0"); |
| | | for (Map<String, Object> objectMap : lists1) { |
| | | Integer participantType1 = Integer.valueOf(objectMap.get("participantType").toString()); |
| | |
| | | // } |
| | | // }); |
| | | // } |
| | | |
| | | |
| | | List<WorldCupRankVo> list = new ArrayList<>(); |
| | | for (int i = 0; i < mapList.size(); i++) { |
| | |
| | | if(i == 19 && b){ |
| | | break; |
| | | } |
| | | |
| | | //排名前20的数据添加完成后且包含自己,需要将自己找出来后添加到21位 |
| | | if(i > 19 && !b){ |
| | | if(worldCupRank.getIsStudent().compareTo(participantType) == 0 && worldCupRank.getId().compareTo(participantId) == 0){ |
| | |
| | | } |
| | | // 排序 |
| | | list= list.stream().sorted(Comparator.comparing(WorldCupRankVo::getIntegral).reversed().thenComparing(WorldCupRankVo::getTotalSession).reversed().thenComparing(WorldCupRankVo::getWinRate).reversed()).collect(Collectors.toList()); |
| | | int a=1; |
| | | for (WorldCupRankVo worldCupRankVo : list) { |
| | | worldCupRankVo.setRank(a); |
| | | a++; |
| | | } |
| | | return list; |
| | | } |
| | | |
| | |
| | | } |
| | | map.put("startTime", sdf.format(cupCompetitor.getStartTime())); |
| | | map.put("score", cupCompetitor.getOurScore() + ":" + cupCompetitor.getOpponentScore()); |
| | | map.put("matchResult", cupCompetitor.getMatchResult() == 1 ? "胜" : cupCompetitor.getMatchResult() == 0 ? "平" : "负"); |
| | | map.put("matchResult", cupCompetitor.getMatchResult() == 1 ? "胜" : (cupCompetitor.getMatchResult() == 0 ? "平" : "负")); |
| | | map.put("blue", cupCompetitor.getParticipant() == 1 ? cupCompetitor.getOurScore() : cupCompetitor.getOpponentScore()); |
| | | map.put("red", cupCompetitor.getParticipant() == 2 ? cupCompetitor.getOurScore() : cupCompetitor.getOpponentScore()); |
| | | mapList.add(map); |
| | |
| | | cupCompetitor.setLoseIntegral(worldCup.getLoseIntegral()); |
| | | } |
| | | //如果之前平了,现在赢了,需要扣减积分 |
| | | if(cupCompetitor.getMatchResult() == 0 && blue.compareTo(red) >0){ |
| | | if(cupCompetitor.getMatchResult() == 0 && blue>red){ |
| | | //先扣除 |
| | | SaveUserIntegralChangesVo vo1 = new SaveUserIntegralChangesVo(); |
| | | vo1.setAppUserId(cupCompetitor.getAppUserId()); |
| | |
| | | @Override |
| | | public List<WorldCupCodeListVo> getWorldCupCodeListId(Integer worldCupId) { |
| | | List<WorldCupCompetitor> worldCupCompetitors = this.baseMapper.selectList(new LambdaQueryWrapper<WorldCupCompetitor>().eq(WorldCupCompetitor::getWorldCupId, worldCupId) |
| | | .ge(WorldCupCompetitor::getStartTime, new Date()).lt(WorldCupCompetitor::getEndTime, new Date())); |
| | | .and(w->w.isNull(WorldCupCompetitor::getEndTime).or(s->s.le(WorldCupCompetitor::getStartTime, new Date()).ge(WorldCupCompetitor::getEndTime, new Date())))) |
| | | ; |
| | | List<WorldCupCodeListVo> worldCupCodeListVos = new ArrayList<>(); |
| | | |
| | | // 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(); |
| | | TStudent tStudent = studentClient.queryById(competitor.getParticipantId().intValue()); |
| | | userVo.setUserName(tStudent.getName()); |
| | | userVo.setAvatar(tStudent.getHeadImg()); |
| | | // 当前日期和生日计算年龄 |
| | | Date birthday = tStudent.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(); |
| | | TStudent tStudent = studentClient.queryById(competitor.getParticipantId().intValue()); |
| | | userVo.setUserName(tStudent.getName()); |
| | | userVo.setAvatar(tStudent.getHeadImg()); |
| | | // 当前日期和生日计算年龄 |
| | | Date birthday = tStudent.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); |