Browse Source

Merge branch 'pt' of https://gitee.com/ccsens_s/ccsenscloud into pt

master
zhizhi wu 5 years ago
parent
commit
4cd1d25cd7
  1. 2
      game/src/main/java/com/ccsens/game/bean/vo/ScreenVo.java
  2. 3
      game/src/main/java/com/ccsens/game/mq/GameScoreListener.java
  3. 11
      game/src/main/java/com/ccsens/game/netty/wsserver/WebSocketHandler.java
  4. 38
      game/src/main/java/com/ccsens/game/service/ScreenService.java
  5. 3
      game/src/main/resources/application-dev.yml
  6. 3
      game/src/main/resources/application-prod.yml
  7. 3
      game/src/main/resources/application-test.yml
  8. 4
      tall/src/main/resources/application.yml

2
game/src/main/java/com/ccsens/game/bean/vo/ScreenVo.java

@ -159,7 +159,7 @@ public class ScreenVo {
@ApiModelProperty("头像")
private String headPortraitUrl;
@ApiModelProperty("该组的总分/均分")
private int score;
private Integer score;
@ApiModelProperty("该组总人数")
private int totalMembers;
@ApiModelProperty("code")

3
game/src/main/java/com/ccsens/game/mq/GameScoreListener.java

@ -99,9 +99,8 @@ public class GameScoreListener {
gameMessageCountOut.getData().setTotalTimes(score/100);
return gameMessageCountOut;
}
};
}
return gameMessageCountOut;
}
}

11
game/src/main/java/com/ccsens/game/netty/wsserver/WebSocketHandler.java

@ -4,8 +4,10 @@ package com.ccsens.game.netty.wsserver;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.game.bean.dto.ClientDto;
import com.ccsens.game.bean.dto.message.*;
import com.ccsens.game.bean.po.GameGroup;
import com.ccsens.game.netty.ChannelManager;
import com.ccsens.game.service.IClientService;
import com.ccsens.game.service.IMessageService;
@ -171,6 +173,15 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<BaseMessageDto
}
score += 100;
redisUtil.zsSet(gameUserKey, JSON.toJSONString(user), score);
String groupKey = recordId + "_group";
Set<Object> objectSet = redisUtil.zsGet(groupKey, 0, -1);
objectSet.forEach(o -> {
GameGroup gameGroup = JSONObject.parseObject((String) o, GameGroup.class);
if(gameGroup.getId().longValue() == user.getGroupId().longValue()){
Double o1 = (Double)redisUtil.zsGetScore(groupKey, o);
redisUtil.zsSet(groupKey, o, o1 + 100,600);
}
});
gameMessageCountOut.getData().setTotalScore(score);
gameMessageCountOut.getData().setTotalTimes(score/100);
return gameMessageCountOut;

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

@ -7,6 +7,7 @@ import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.cloudutil.bean.tall.dto.WpsDto;
import com.ccsens.cloudutil.feign.TallFeignClient;
import com.ccsens.game.bean.dto.ClientDto;
@ -253,13 +254,13 @@ public class ScreenService implements IScreenService {
if(ObjectUtil.isNotNull(groupRow)){
String groupName = ExcelUtil.getCellValue(groupRow.getCell(0));
String groupUrl = ExcelUtil.getCellValue(groupRow.getCell(1));
if(ObjectUtil.isNotNull(groupName)){
if(StrUtil.isNotEmpty(groupName)){
GameGroup gameGroup = new GameGroup();
gameGroup.setId(snowflake.nextId());
gameGroup.setRecordId(gameRecord.getId());
gameGroup.setName(groupName);
// gameGroup.setCode(GameConstant.FIRST_GROUP);
if(ObjectUtil.isNotNull(groupUrl)){
if(StrUtil.isNotEmpty(groupUrl)){
gameGroup.setHeadPortraitUrl(groupUrl);
}
gameGroupDao.insertSelective(gameGroup);
@ -280,14 +281,16 @@ public class ScreenService implements IScreenService {
recordExample.setOrderByClause("created_at DESC");
List<GameRecord> recordList = gameRecordDao.selectByExample(recordExample);
if (CollectionUtil.isNotEmpty(recordList)) {
GameRecord record1 = new GameRecord();
GameRecord record = recordList.get(0);
if(record.getGameStatus() == GameConstant.GAME_PREPARATION ||
record.getGameStatus() == GameConstant.GAME_PROCESSING){
throw new BaseException(CodeEnum.GAME_NO_END);
}
if(record.getGameStatus() == GameConstant.GAME_PENDING){
record.setGameStatus(GameConstant.GAME_COMPLETED);
gameRecordDao.updateByPrimaryKeySelective(record);
record1.setId(record.getId());
record1.setGameStatus(GameConstant.GAME_COMPLETED);
gameRecordDao.updateByPrimaryKeySelective(record1);
}
}
}
@ -590,6 +593,22 @@ public class ScreenService implements IScreenService {
* 进行中查询每个组的信息
*/
private List<ScreenVo.GroupVo> getGroupScore2(GameRecord gameRecord) {
String groupKey = gameRecord.getId() + "_group";
Set<ZSetOperations.TypedTuple<Object>> typedTuples = redisUtil.zsRevGetWithScore(groupKey, 0, -1);
if(CollectionUtil.isNotEmpty(typedTuples)){
List<ScreenVo.GroupVo> vos = new ArrayList<>();
typedTuples.forEach(type -> {
GameGroup gameGroup = JSON.parseObject((String)type.getValue(), GameGroup.class);
int score = type.getScore().intValue();
ScreenVo.GroupVo groupVo = new ScreenVo.GroupVo();
groupVo.setGroupId(gameGroup.getId());
groupVo.setGroupName(gameGroup.getName());
groupVo.setScore(score);
groupVo.setHeadPortraitUrl(gameGroup.getHeadPortraitUrl());
vos.add(groupVo);
});
return vos;
}
List<ScreenVo.GroupVo> vos = gameGroupDao.queryGroups(gameRecord.getId());
if (CollectionUtil.isEmpty(vos) || gameRecord.getRankRule() == GameConstant.RANK_RULE_TOTAL) {
return vos;
@ -1028,6 +1047,15 @@ public class ScreenService implements IScreenService {
gameRecordDao.updateByPrimaryKeySelective(gameRecord);
//设置redis 游戏状态 准备中
redisUtil.set(GameConstant.generateGameStatusKey(gameRecord.getId()), JSON.toJSONString(gameRecord), GameConstant.REDIS_TIME);
String groupKey = gameRecord.getId() + "_group";
GameGroupExample groupExample = new GameGroupExample();
groupExample.createCriteria().andRecordIdEqualTo(gameRecord.getId());
List<GameGroup> gameGroupList = gameGroupDao.selectByExample(groupExample);
if(CollectionUtil.isNotEmpty(gameGroupList)){
gameGroupList.forEach(gameGroup -> {
redisUtil.zsSet(groupKey, JSONObject.toJSONString(gameGroup),0,600);
});
}
//再玩一次
if (start.getStartStatus() != null && start.getStartStatus().byteValue() == GameConstant.GAME_RESTART_STATUS) {
//再玩一次,设置参见的用户为无效用户
@ -1200,7 +1228,7 @@ public class ScreenService implements IScreenService {
GameRecordExample recordExample = new GameRecordExample();
recordExample.createCriteria().andTaskIdEqualTo(taskId);
recordExample.setOrderByClause("created_at DESC");
recordExample.setOrderByClause("id DESC");
List<GameRecord> gameRecordList = gameRecordDao.selectByExample(recordExample);
if (CollectionUtil.isNotEmpty(gameRecordList)) {
if (StrUtil.isNotEmpty(gameType)) {

3
game/src/main/resources/application-dev.yml

@ -8,7 +8,7 @@ spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
rabbitmq:
host: 192.168.0.99
host: 81.70.54.64
password: 111111
port: 5672
username: admin
@ -29,4 +29,5 @@ swagger:
gatewayUrl: https://test.tall.wiki/gateway/
notGatewayUrl: https://test.tall.wiki/
file:
qrCode: https://test.tall.wiki/gateway/tall/uploads/

3
game/src/main/resources/application-prod.yml

@ -32,4 +32,5 @@ eureka:
gatewayUrl: https://www.tall.wiki/gateway/
notGatewayUrl: https://www.tall.wiki/
qrCode: https://www.tall.wiki/gateway/tall/uploads/
file:
qrCode: https://www.tall.wiki/gateway/tall/v1.0/uploads/

3
game/src/main/resources/application-test.yml

@ -32,4 +32,5 @@ eureka:
gatewayUrl: https://test.tall.wiki/gateway/
notGatewayUrl: https://test.tall.wiki/
qrCode: https://test.tall.wiki/gateway/tall/uploads/
file:
qrCode: https://test.tall.wiki/gateway/tall/v1.0/uploads/

4
tall/src/main/resources/application.yml

@ -1,4 +1,4 @@
spring:
profiles:
active: test
include: util-test,common
active: dev
include: util-dev,common

Loading…
Cancel
Save