Browse Source

tuisong

master
zhizhi wu 5 years ago
parent
commit
6e331b5c9e
  1. 44
      game/src/main/java/com/ccsens/game/service/ScreenService.java

44
game/src/main/java/com/ccsens/game/service/ScreenService.java

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

Loading…
Cancel
Save