|
|
@ -685,25 +685,35 @@ public class ScreenService implements IScreenService { |
|
|
|
ScreenVo.CompletedData completedData = new ScreenVo.CompletedData(); |
|
|
|
String groupKey = gameRecordId + "_group"; |
|
|
|
Set<ZSetOperations.TypedTuple<Object>> typedTuples = redisUtil.zsRevGetWithScore(groupKey, 0, -1); |
|
|
|
Iterator<ZSetOperations.TypedTuple<Object>> iterator = typedTuples.iterator(); |
|
|
|
ZSetOperations.TypedTuple<Object> next = iterator.next(); |
|
|
|
GameGroup gameGroup = JSON.parseObject((String) next.getValue(), GameGroup.class); |
|
|
|
int score = next.getScore().intValue(); |
|
|
|
completedData.setTotalScore(score); |
|
|
|
completedData.setTotalTimes(score/100); |
|
|
|
Object o = redisUtil.get(gameGroup.getId() + GameConstant.GAME_GROUP_NUM); |
|
|
|
if (o==null) { |
|
|
|
o = 0; |
|
|
|
} |
|
|
|
completedData.setTotalMember((int)o); |
|
|
|
completedData.setAverageTimes((int)o == 0 ? 0 : completedData.getTotalTimes()/(int)o); |
|
|
|
completedData.setWinGroup(gameGroup.getName()); |
|
|
|
log.info("查询成绩:{}", typedTuples); |
|
|
|
if (CollectionUtil.isNotEmpty(typedTuples)) { |
|
|
|
Iterator<ZSetOperations.TypedTuple<Object>> iterator = typedTuples.iterator(); |
|
|
|
if (!iterator.hasNext()) { |
|
|
|
log.info("没有成绩"); |
|
|
|
return completedData; |
|
|
|
} |
|
|
|
ZSetOperations.TypedTuple<Object> next = iterator.next(); |
|
|
|
GameGroup gameGroup = JSON.parseObject((String) next.getValue(), GameGroup.class); |
|
|
|
int score = next.getScore().intValue(); |
|
|
|
completedData.setTotalScore(score); |
|
|
|
completedData.setTotalTimes(score/100); |
|
|
|
Object o = redisUtil.get(gameGroup.getId() + GameConstant.GAME_GROUP_NUM); |
|
|
|
if (o==null) { |
|
|
|
o = 0; |
|
|
|
} |
|
|
|
completedData.setTotalMember((int)o); |
|
|
|
completedData.setAverageTimes((int)o == 0 ? 0 : completedData.getTotalTimes()/(int)o); |
|
|
|
completedData.setWinGroup(gameGroup.getName()); |
|
|
|
|
|
|
|
|
|
|
|
GameUserJoinExample joinExample = new GameUserJoinExample(); |
|
|
|
joinExample.createCriteria().andRecordIdEqualTo(gameRecordId).andScoreGreaterThan(completedData.getAverageTimes()); |
|
|
|
long l = gameUserJoinDao.countByExample(joinExample); |
|
|
|
completedData.setOver((int)o == 0 ? 0 : (int) (l * 100 / (int) o)); |
|
|
|
GameUserJoinExample joinExample = new GameUserJoinExample(); |
|
|
|
joinExample.createCriteria().andRecordIdEqualTo(gameRecordId).andScoreGreaterThan(completedData.getAverageTimes()); |
|
|
|
long l = gameUserJoinDao.countByExample(joinExample); |
|
|
|
completedData.setOver((int)o == 0 ? 0 : (int) (l * 100 / (int) o)); |
|
|
|
} else { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//TODO 1、分别查询redis内每个队伍的总分,
|
|
|
|
//2、查询获胜队伍的信息
|
|
|
|
|
|
|
|