Browse Source

20201208mq广播测试

recovery
zy_Java 5 years ago
parent
commit
6e801ec203
  1. 69
      cloudutil/src/main/resources/application-util-prodsd.yml
  2. 22
      game/src/main/java/com/ccsens/game/api/DebugController.java
  3. 6
      game/src/main/java/com/ccsens/game/bean/vo/ScreenVo.java
  4. 49
      game/src/main/java/com/ccsens/game/netty/ChannelManager.java
  5. 6
      game/src/main/java/com/ccsens/game/service/RabbitMQListener.java
  6. 27
      game/src/main/java/com/ccsens/game/service/RabbitMQListenerGameTest.java
  7. 142
      game/src/main/java/com/ccsens/game/service/ScreenService.java
  8. 7
      game/src/main/java/com/ccsens/game/util/GameConstant.java
  9. 6
      game/src/main/resources/application-prod.yml
  10. 40
      game/src/main/resources/application-prodsd.yml
  11. 4
      game/src/main/resources/application.yml
  12. 33
      game/src/main/resources/druid-prodsd.yml
  13. 3
      health/src/main/resources/application-prod.yml
  14. 4
      health/src/main/resources/application.yml
  15. 10
      ht/src/main/resources/application-prod.yml
  16. 3
      mt/src/main/resources/application-prod.yml
  17. 4
      tall/src/main/resources/application-prod.yml
  18. 44
      tall/src/main/resources/application-prodsd.yml
  19. 33
      tall/src/main/resources/druid-prodsd.yml
  20. 2
      tall/src/main/resources/logback-spring.xml
  21. 26
      util/src/main/java/com/ccsens/util/RedisUtil.java
  22. 23
      util/src/main/java/com/ccsens/util/config/RabbitMQConfig.java
  23. 40
      util/src/test/java/com/ccsens/util/FileTest.java

69
cloudutil/src/main/resources/application-util-prodsd.yml

@ -0,0 +1,69 @@
#服务端点暴露
management:
endpoints:
web:
exposure:
# 暴露xxx端点,如需暴露多个,用,分隔;如需暴露所有端点,用'*'
include: auditevents,caches,conditions,flyway,health,heapdump,httptrace,info,integrationgraph,jolokia,logfile,loggers,liquibase,metrics,mappings,prometheus,scheduledtasks,sessions,shutdown,threaddump,hystrix.stream
# # 不暴露哪些端点
exclude: env,beans,configprops
endpoint:
health:
# 是否展示健康检查详情
show-details: always
health:
redis:
enabled: false
#eureka注册
eureka:
client:
service-url:
# 指定eureka server通信地址,注意/eureka/小尾巴不能少
#defaultZone: http://admin:admin@peer1:8761/eureka/,http://admin:admin@peer2:8762/eureka/
# defaultZone: http://admin:admin@81.70.54.64:7010/eureka/
defaultZone: http://admin:admin@192.144.182.42:7010/eureka/
instance:
# 是否注册IP到eureka server,如不指定或设为false,那就回注册主机名到eureka server
prefer-ip-address: true
metadata-map:
management:
context-path: ${server.servlet.context-path:}/actuator
home-page-url-path: ${server.servlet.context-path:}/
status-page-url-path: ${server.servlet.context-path:}/actuator/info
health-check-url-path: ${server.servlet.context-path:}/actuator/health
feign:
client:
config:
default:
connectTime: 5000
readTimeout: 5000
# NONE【性能最佳,适用于生产】:不记录任何日志(默认值)。
# BASIC【适用于生产环境追踪问题】:仅记录请求方法、URL、响应状态代码以及执行时间。
# HEADERS:记录BASIC级别的基础上,记录请求和响应的header。
# FULL【比较适用于开发及测试环境定位问题】:记录请求和响应的header、body和元数据
loggerLevel: basic
hystrix:
enabled: true
hystrix:
threadpool:
default:
coreSize: 200 #并发执行的最大线程数,默认10
maxQueueSize: 1000 #BlockingQueue的最大队列数,默认值-1
queueSizeRejectionThreshold: 800 #即使maxQueueSize没有达到,达到queueSizeRejectionThreshold该值后,请求也会被拒绝,默认值5
# sleuth
logging:
level:
root: info
org.springframework.cloud.sleuth: DEBUG
spring:
# zipkin:
# base-url: http://140.143.228.3:9411
# sleuth:
# sampler:
# # 采样率,模式0.1,也就是10%,为了便于观察效果,改为1.0,也就是100%。生产环境建议保持默认。
# probability: 0.1
cloud:
inetutils:
ignored-interfaces: ['VMware.*']

22
game/src/main/java/com/ccsens/game/api/DebugController.java

@ -1,9 +1,16 @@
package com.ccsens.game.api;
import com.ccsens.util.JacksonUtil;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.bean.message.common.InMessage;
import com.ccsens.util.bean.message.common.MessageConstant;
import com.ccsens.util.bean.message.common.ServerMessage;
import com.ccsens.util.config.RabbitMQConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@ -14,6 +21,8 @@ import javax.servlet.http.HttpServletRequest;
@RestController
@RequestMapping("/debug")
public class DebugController {
@Autowired
private AmqpTemplate rabbitTemplate;
@ApiOperation(value = "/测试",notes = "")
@ApiImplicitParams({
@ -24,5 +33,18 @@ public class DebugController {
return JsonResponse.newInstance().ok("测试");
}
@ApiOperation(value = "/测试",notes = "")
@ApiImplicitParams({
})
@RequestMapping(value="/game",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"})
public JsonResponse testGameMq(HttpServletRequest request) throws Exception {
ServerMessage serverMessage = new ServerMessage();
serverMessage.setType("Ping");
InMessage inMessage = InMessage.newToServerMessage(MessageConstant.DomainType.Server,serverMessage);
String j = JacksonUtil.beanToJson(inMessage);
//FixMe 发送到消息队列
rabbitTemplate.convertAndSend("fanoutExchange","",j);
return JsonResponse.newInstance().ok("测试");
}
}

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

@ -115,6 +115,12 @@ public class ScreenVo {
private Byte gameStatus;
@ApiModelProperty("总人数")
private int totalMembers;
@ApiModelProperty("时长")
private int duration;
@ApiModelProperty("本地开始时间")
private Long startLocalTime;
@ApiModelProperty("本地结束时间")
private Long endLocalTime;
@ApiModelProperty("分组信息")
private List<GroupVo> groups ;

49
game/src/main/java/com/ccsens/game/netty/ChannelManager.java

@ -1,10 +1,15 @@
package com.ccsens.game.netty;
import cn.hutool.core.collection.CollectionUtil;
import com.ccsens.game.util.GameConstant;
import com.ccsens.util.RedisUtil;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@ -12,8 +17,12 @@ import java.util.concurrent.ConcurrentHashMap;
* @author wei
*/
@Slf4j
@Component
public class ChannelManager {
private static ThreadLocal<Channel> threadLocal = new ThreadLocal<>();
static ChannelManager channelManager;
// @Resource
// private RedisUtil redisUtil;
/**
* UserId,WrappedChannel authed channels;
@ -28,6 +37,30 @@ public class ChannelManager {
authedChannels = new ConcurrentHashMap<>();
rawChannels = new ConcurrentHashMap<>();
}
// @PostConstruct
// public void init(){
// channelManager = this;
// channelManager.redisUtil = this.redisUtil;
// log.info("redis:{}",this.redisUtil);
// }
//
// private static Map<String,Set<WrapperedChannel>> getAuthedChannels(){
// String key = GameConstant.GAME_WS_AUTHED_CHANNELS;
// Map<?, ?> hmget = channelManager.redisUtil.hmget(key);
// if(CollectionUtil.isEmpty(hmget)){
// return new HashMap<>();
// }
// return (Map<String,Set<WrapperedChannel>>)hmget;
// }
//
// private static Map<Channel,WrapperedChannel> getRawChannels(){
// String key = GameConstant.GAME_WS_RAW_CHANNELS;
// Map<?, ?> hmget = channelManager.redisUtil.hmget(key);
// if(CollectionUtil.isEmpty(hmget)){
// return new HashMap<>();
// }
// return (Map<Channel,WrapperedChannel>)hmget;
// }
/**
* 私有构造,不允许生成该类对象
@ -65,6 +98,7 @@ public class ChannelManager {
public static synchronized void addChannel(Channel channel,String serverType){
log.info("Invoke addChannel({},{})",channel,serverType);
if(null != channel) {
// channelManager.redisUtil.hset(GameConstant.GAME_WS_RAW_CHANNELS,channel, new WrapperedChannel(channel, serverType),GameConstant.WS_CHANNELS);
rawChannels.put(channel, new WrapperedChannel(channel, serverType));
log.info("Add a new channel: {},{}",channel.id().asLongText(),serverType);
}else{
@ -85,9 +119,15 @@ public class ChannelManager {
minor = minor != null ? minor : 0;
WrapperedChannel wrapperedChannel = rawChannels.get(channel);
// WrapperedChannel wrapperedChannel = getRawChannels().get(channel);
if(wrapperedChannel != null){
wrapperedChannel.whenAuthed(userId,major,minor);
Set<WrapperedChannel> authedWchannelSet = authedChannels.computeIfAbsent(userId, k -> new HashSet<>());
// Set<WrapperedChannel> wrapperedChannels = getAuthedChannels().get(userId);
// if(CollectionUtil.isEmpty(wrapperedChannels)){
// wrapperedChannels = new HashSet<>();
// }
// Set<WrapperedChannel> authedWchannelSet = wrapperedChannels;
authedWchannelSet.add(wrapperedChannel);
log.info("Authed channel {} with user {}", channel.id().asLongText(), userId);
}else{
@ -112,6 +152,11 @@ public class ChannelManager {
if(wrapperedChannel != null){
wrapperedChannel.whenAuthed(userId,major,minor,recordId);
Set<WrapperedChannel> authedWchannelSet = authedChannels.computeIfAbsent(userId, k -> new HashSet<>());
// Set<WrapperedChannel> wrapperedChannels = getAuthedChannels().get(userId);
// if(CollectionUtil.isEmpty(wrapperedChannels)){
// wrapperedChannels = new HashSet<>();
// }
// Set<WrapperedChannel> authedWchannelSet = wrapperedChannels;
authedWchannelSet.add(wrapperedChannel);
log.info("Authed channel {} with user {}", channel.id().asLongText(), userId);
}else{
@ -129,6 +174,7 @@ public class ChannelManager {
if(wrapperedChannel != null){
//从rawChannels集合中删除
rawChannels.remove(channel);
// channelManager.redisUtil.hdel(GameConstant.GAME_WS_RAW_CHANNELS,channel);
log.info("Remove a channel from rawChannels: {}",channel.id().asLongText());
if(wrapperedChannel.isAuthed()){
Set<WrapperedChannel> authedChannelSet = authedChannels.get(wrapperedChannel.getUserId());
@ -140,6 +186,7 @@ public class ChannelManager {
//从authedChannel中删除,此处不用else,因为if中语句执行完毕之后,authedChannelSet也可能变成空集合
if(CollectionUtil.isEmpty(authedChannelSet)){
authedChannels.remove(wrapperedChannel.getUserId());
// channelManager.redisUtil.hdel(GameConstant.GAME_WS_AUTHED_CHANNELS,wrapperedChannel.getUserId());
log.info("Remove a user from authedChannels: {}",wrapperedChannel.getUserId());
}
}
@ -163,11 +210,13 @@ public class ChannelManager {
for(WrapperedChannel wChannel : wChannelSet){
//从rawChannel中依次删除
rawChannels.remove(wChannel.getChannel());
// channelManager.redisUtil.hdel(GameConstant.GAME_WS_RAW_CHANNELS,wChannel.getChannel());
log.info("Remove a channel from rawChannels: {}",wChannel.getChannel().id().asLongText());
}
}
//从authedChannel中删除
authedChannels.remove(userId);
// channelManager.redisUtil.hdel(GameConstant.GAME_WS_AUTHED_CHANNELS,userId);
log.info("Remove a user from authedChannels: {}",userId);
}

6
game/src/main/java/com/ccsens/game/service/RabbitMQListener.java

@ -1,10 +1,8 @@
package com.ccsens.game.service;
import cn.hutool.core.collection.CollectionUtil;
import com.ccsens.game.bean.dto.message.GameMessageWithChangeStatusOut;
import com.ccsens.util.JacksonUtil;
import com.ccsens.util.WebConstant;
import com.ccsens.util.config.RabbitMQConfig;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
@ -15,8 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.List;
import java.util.TreeMap;
@Slf4j
@Component
@ -35,4 +31,6 @@ public class RabbitMQListener {
messageService.doChangeStatusMessage(JacksonUtil.jsonToBean(messageJson,
GameMessageWithChangeStatusOut.class, true));
}
}

27
game/src/main/java/com/ccsens/game/service/RabbitMQListenerGameTest.java

@ -0,0 +1,27 @@
package com.ccsens.game.service;
import com.ccsens.util.config.RabbitMQConfig;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import java.io.IOException;
@Slf4j
@Component
@RabbitListener(queues = RabbitMQConfig.GAME_MQ_A)
public class RabbitMQListenerGameTest {
private Logger logger = LoggerFactory.getLogger(RabbitMQListener.class);
@RabbitHandler
public void gameTest(String gameTest) throws IOException {
System.out.println("============================="+gameTest);
// List<GameMessageWithChangeStatusOut> gameMessageList = JacksonUtil.jsonToBean(messageJson,
// GameMessageWithChangeStatusOut.class, true);
log.info("测试游戏MQ消息 {}",gameTest);
}
}

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

@ -24,6 +24,7 @@ import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.util.exception.BaseException;
import com.ccsens.util.wx.WxXcxUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.util.concurrent.AtomicDouble;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFRow;
@ -39,6 +40,7 @@ import java.io.*;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author zy
@ -144,7 +146,7 @@ public class ScreenService implements IScreenService {
} else {
log.info("测试环境,不调用生成二维码");
//给一个默认测试的
gameRecord.setQrCodeUrl(PropUtil.qrCode + "/gameQrCode/2020-08-19/1597822577181.png");
gameRecord.setQrCodeUrl(PropUtil.qrCode + "gameQrCode/2020-08-19/1597822577181.png");
}
//查找此任务下的游戏配置表
@ -160,12 +162,13 @@ public class ScreenService implements IScreenService {
//添加配置信息
saveGameRecord(wpsFilePath,gameRecord);
}
//将游戏记录添加数据库
gameRecordDao.insertSelective(gameRecord);
//如果是分组游戏
log.info("添加游戏记录:{}",gameRecord);
//配置表不存在,而且游戏类型默认为分组游戏,默认添加两个分组
if(StrUtil.isEmpty(wpsFilePath) && gameType.getIsGroup() == 1){
if (gameType.getIsGroup() == 1) {
gameRecord.setGameGroup((byte) 1);
GameGroup gameGroupRed = new GameGroup();
gameGroupRed.setId(snowflake.nextId());
gameGroupRed.setRecordId(gameRecord.getId());
@ -179,8 +182,8 @@ public class ScreenService implements IScreenService {
gameGroupBlue.setCode(GameConstant.SECOND_GROUP);
gameGroupDao.insertSelective(gameGroupBlue);
}
}
//将游戏记录添加数据库
gameRecordDao.insertSelective(gameRecord);
//5、查询该游戏的规则
List<String> ruleList = getGameActivityRule(gameType.getId());
//6、返回
@ -222,6 +225,9 @@ public class ScreenService implements IScreenService {
*/
private void saveGameRecord(String wpsFilePath,GameRecord gameRecord) throws Exception{
InputStream is = new FileInputStream(new File(wpsFilePath));
//读取excel
XSSFWorkbook wb = new XSSFWorkbook(is);
if(ObjectUtil.isNull(wb)){ throw new BaseException(CodeEnum.NOT_CONFIG_OR_ERR); }
@ -550,8 +556,13 @@ public class ScreenService implements IScreenService {
//获取游戏的购买记录和类型
GameUserPay gameUserPay = gameUserPayDao.selectByPrimaryKey(gameRecord.getUserPayId());
GameType gameType = gameTypeDao.selectByPrimaryKey(gameUserPay.getGameTypeId());
gameStatusVo.setGameStatus(gameRecord.getGameStatus());
//返回开始结束时间和时长
gameStatusVo.setStartLocalTime(gameRecord.getStartTime() + gameRecord.getTimeDifference());
gameStatusVo.setEndLocalTime(gameRecord.getEndTime() + gameRecord.getTimeDifference());
gameStatusVo.setDuration(gameRecord.getDuration());
//获取分组的信息
List<ScreenVo.GroupVo> groupVo = getGroupScore2(gameRecord);
gameStatusVo.setGroups(groupVo);
@ -701,9 +712,6 @@ public class ScreenService implements IScreenService {
/**
* 结束时查询胜利组的信息总分数总次数平均以及前十名
*/
private ScreenVo.CompletedData getCompletedDataByWin(GameRecord gameRecord, int totalMember) {
String groupKey = gameRecord.getId() + "_group";
Set<ZSetOperations.TypedTuple<Object>> typedTuples = redisUtil.zsRevGetWithScore(groupKey, 0, -1);
@ -711,31 +719,32 @@ public class ScreenService implements IScreenService {
ScreenVo.CompletedData completedData = new ScreenVo.CompletedData();
List<ScreenVo.CompletedData> list = new ArrayList<>();
Double maxSore = 0d;
String winGroupName = null;
if (CollectionUtil.isNotEmpty(typedTuples)) {
typedTuples.forEach(type -> {
for(ZSetOperations.TypedTuple<Object> type : typedTuples) {
completedData.setTotalScore(completedData.getTotalScore() + type.getScore().intValue());
GameGroup gameGroup = JSON.parseObject((String) type.getValue(), GameGroup.class);
if (gameRecord.getRankRule() == GameConstant.RANK_RULE_AVA) {
Object o = redisUtil.get(gameGroup.getId() + GameConstant.GAME_GROUP_NUM);
if (o == null || (Integer) o == 0) {
continue;
}
Integer a = (Integer) o;
if (maxSore <= type.getScore() / a) {
maxSore = type.getScore() / a;
winGroupName = gameGroup.getName();
}
} else {
if (maxSore <= type.getScore()) {
maxSore = type.getScore();
winGroupName = gameGroup.getName();
}
}
}
// ScreenVo.CompletedData completedData = new ScreenVo.CompletedData();
//// GameGroup gameGroup = JSON.parseObject((String) type.getValue(), GameGroup.class);
//// int score = type.getScore().intValue();
//// Object o = redisUtil.get(gameGroup.getId() + GameConstant.GAME_GROUP_NUM);
//// if (o==null) {
//// o = 0;
//// }
//// completedData.setTotalMember((int)o);
//// completedData.setTotalScore(score);
//// completedData.setAverageScore((int)o == 0 ? 0 : completedData.getTotalScore()/(int)o);
//// completedData.setTotalTimes(score/100);
//// completedData.setAverageTimes((int)o == 0 ? 0 : completedData.getTotalTimes()/(int)o);
//// completedData.setWinGroup(gameGroup.getName());
//// GameUserJoinExample joinExample = new GameUserJoinExample();
//// joinExample.createCriteria().andRecordIdEqualTo(gameRecord.getId()).andScoreGreaterThan(completedData.getAverageTimes());
//// long l = gameUserJoinDao.countByExample(joinExample);
//// completedData.setOver(totalMember == 0 ? 0 : (int) (l * 100 / totalMember));
//// list.add(completedData);
});
} else {
List<ScreenVo.GroupVo> groupVos = gameGroupDao.queryGroups(gameRecord.getId());
@ -744,70 +753,37 @@ public class ScreenService implements IScreenService {
return new ScreenVo.CompletedData();
}
groupVos.forEach(groupVo -> {
completedData.setTotalScore((groupVo.getScore() == null ? 0 : groupVo.getScore()) + completedData.getTotalScore());
// groupVo.setScore(groupVo.getTotalMembers() == null || groupVo.getTotalMembers() == 0 ? 0 : groupVo.getScore()/groupVo.getTotalMembers());
// ScreenVo.CompletedData completedData = new ScreenVo.CompletedData();
//
// int members = groupVo.getTotalMembers() == null ? 0 : groupVo.getTotalMembers();
// completedData.setTotalMember(members);
// completedData.setTotalScore(groupVo.getScore());
// completedData.setAverageScore(members == 0 ? 0 : completedData.getTotalScore()/members);
// completedData.setTotalTimes(groupVo.getScore() == null ? 0 : groupVo.getScore()/100);
// completedData.setAverageTimes(members == 0 ? 0 : completedData.getTotalTimes()/members);
// completedData.setWinGroup(groupVo.getGroupName());
// GameUserJoinExample joinExample = new GameUserJoinExample();
// joinExample.createCriteria().andRecordIdEqualTo(gameRecord.getId()).andScoreGreaterThan(completedData.getAverageTimes());
// long l = gameUserJoinDao.countByExample(joinExample);
// completedData.setOver(totalMember == 0 ? 0 : (int) (l * 100 /totalMember));
// list.add(completedData);
});
for(ScreenVo.GroupVo groupVo : groupVos) {
if (gameRecord.getRankRule() == GameConstant.RANK_RULE_AVA) {
if (groupVo.getTotalMembers() == null || groupVo.getTotalMembers() == 0) {
continue;
}
if (maxSore <= groupVo.getTotalScore() / groupVo.getTotalMembers()) {
maxSore = (double)groupVo.getTotalScore() / groupVo.getTotalMembers();
winGroupName = groupVo.getGroupName();
}
} else {
if (maxSore <= groupVo.getTotalScore()) {
maxSore = (double)groupVo.getTotalScore();
winGroupName = groupVo.getGroupName();
}
}
}
}
completedData.setAverageScore(totalMember == 0 ? 0 : completedData.getTotalScore() / totalMember);
completedData.setTotalTimes(completedData.getTotalScore() / 100);
completedData.setAverageTimes(totalMember == 0 ? 0 : completedData.getTotalTimes() / totalMember);
completedData.setTotalMember(totalMember);
completedData.setWinGroup(winGroupName);
GameUserJoinExample joinExample = new GameUserJoinExample();
joinExample.createCriteria().andRecordIdEqualTo(gameRecord.getId()).andScoreGreaterThan(completedData.getAverageScore());
long l = gameUserJoinDao.countByExample(joinExample);
completedData.setOver(totalMember == 0 ? 0 : (int) (l * 100 / totalMember));
// if (gameRecord.getRankRule() == GameConstant.RANK_RULE_AVA) {
// CollectionUtil.sort(list, (t1,t2)-> t2.getAverageScore() - t1.getAverageScore());
// }
//TODO 1、分别查询redis内每个队伍的总分,
//2、查询获胜队伍的信息
//3、redis内没有则查询数据库
//查询分组信息
// GameGroupExample gameGroupExample = new GameGroupExample();
// gameGroupExample.createCriteria().andRecordIdEqualTo(gameRecordId);
// List<GameGroup> gameGroupList = gameGroupDao.selectByExample(gameGroupExample);
// if (CollectionUtil.isNotEmpty(gameGroupList)) {
// List<GameUserJoin> userJoinList = null;
// //分别查找两个队伍的总分
// Map<String, Object> group1 = getGroupTotalScore(gameGroupList.get(0).getId());
// Map<String, Object> group2 = getGroupTotalScore(gameGroupList.get(1).getId());
// if (CollectionUtil.isNotEmpty(group1) && CollectionUtil.isNotEmpty(group2)) {
// int score1 = (int) group1.get("totalScore");
// int score2 = (int) group2.get("totalScore");
// if (score1 > score2) {
// userJoinList = (List<GameUserJoin>) group1.get("userJoinList");
// completedData.setTotalMember(userJoinList.size());
// completedData.setWinGroup(gameGroupList.get(0).getName());
// } else {
// userJoinList = (List<GameUserJoin>) group2.get("userJoinList");
// completedData.setTotalMember(userJoinList.size());
// completedData.setWinGroup(gameGroupList.get(1).getName());
// }
// }
// //5、获取获胜队伍的信息
// completedData = getCompletedData(userJoinList);
// }
//前十名
// ScreenVo.CompletedData completedData = list.get(0);
List<ScreenVo.TopUsers> top2 = getTopUsers(gameRecord.getId());
completedData.setMembers(top2);
return completedData;

7
game/src/main/java/com/ccsens/game/util/GameConstant.java

@ -58,7 +58,12 @@ public class GameConstant {
public static final byte GAME_GROUP = 1;
/**游戏:单人*/
public static final byte GAME_SINGLE = 0;
/**ws已授权的连接*/
public static final String GAME_WS_AUTHED_CHANNELS = "authedChannels";
/**ws全部的连接*/
public static final String GAME_WS_RAW_CHANNELS = "rawChannels";
/**ws连接时间*/
public static final long WS_CHANNELS = 24 * 60 * 60L;
/**
* 生成游戏key
* @param recordId

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

@ -3,6 +3,9 @@ server:
servlet:
context-path:
spring:
snowflake:
datacenterId: 1
workerId: 1
application:
name: game
datasource:
@ -21,7 +24,8 @@ spring:
max-idle: 10
max-wait: -1ms
min-idle: 0
password: ''
# password: ''
password: 'areowqr!@43ef'
port: 6379
timeout: 1000ms
swagger:

40
game/src/main/resources/application-prodsd.yml

@ -0,0 +1,40 @@
server:
port: 7050
servlet:
context-path:
spring:
snowflake:
datacenterId: 2
workerId: 2
application:
name: game
datasource:
type: com.alibaba.druid.pool.DruidDataSource
rabbitmq:
host: www.tall.wiki
password: 111111
port: 5672
username: admin
redis:
database: 0
host: www.tall.wiki
jedis:
pool:
max-active: 200
max-idle: 10
max-wait: -1ms
min-idle: 0
password: 'areowqr!@43ef'
port: 6379
timeout: 1000ms
swagger:
enable: true
eureka:
instance:
ip-address: 81.70.54.64
gatewayUrl: https://www.tall.wiki/gateway/
notGatewayUrl: https://www.tall.wiki/
file:
qrCode: https://www.tall.wiki/gateway/tall/v1.0/uploads/
openWX: 1

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

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

33
game/src/main/resources/druid-prodsd.yml

@ -0,0 +1,33 @@
spring:
datasource:
druid:
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
driverClassName: com.mysql.cj.jdbc.Driver
dynamicUrl: jdbc:mysql://localhost:3306/${schema}
filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*'
filterName: druidFilter
filterProfileEnable: true
filterUrlPattern: /*
filters: stat,wall
initialSize: 5
maxActive: 20
maxPoolPreparedStatementPerConnectionSize: 20
maxWait: 60000
minEvictableIdleTimeMillis: 300000
minIdle: 5
password: 37080c1f223685592316b02dad8816c019290a476e54ebb638f9aa3ba8b6bdb9
poolPreparedStatements: true
servletLogSlowSql: true
servletLoginPassword: 111111
servletLoginUsername: druid
servletName: druidServlet
servletResetEnable: true
servletUrlMapping: /druid/*
testOnBorrow: false
testOnReturn: false
testWhileIdle: true
timeBetweenEvictionRunsMillis: 60000
url: jdbc:mysql://www.tall.wiki/game?useUnicode=true&characterEncoding=UTF-8
username: root
validationQuery: SELECT 1 FROM DUAL
env: CCSENS_GAME

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

@ -24,7 +24,8 @@ spring:
max-idle: 10
max-wait: -1ms
min-idle: 0
password: ''
# password: ''
password: 'areowqr!@43ef'
port: 6379
timeout: 1000ms
swagger:

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

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

10
ht/src/main/resources/application-prod.yml

@ -21,11 +21,8 @@ spring:
max-idle: 10
max-wait: -1ms
min-idle: 0
<<<<<<< HEAD
password: ''
=======
password: 'areowqr!@43ef'
>>>>>>> pt
port: 6379
timeout: 1000ms
@ -42,8 +39,5 @@ ht:
name: 认知功能评测云平台系统
eureka:
instance:
<<<<<<< HEAD
ip-address: 81.70.54.64
=======
ip-address: 71.80.54.64
>>>>>>> pt

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

@ -21,7 +21,8 @@ spring:
max-idle: 10
max-wait: -1ms
min-idle: 0
password: ''
# password: ''
password: 'areowqr!@43ef'
port: 6379
timeout: 1000ms
swagger:

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

@ -24,8 +24,8 @@ spring:
max-idle: 10
max-wait: -1ms
min-idle: 0
password: ''
# password:
# password: ''
password: 'areowqr!@43ef'
port: 6379
timeout: 1000ms
swagger:

44
tall/src/main/resources/application-prodsd.yml

@ -0,0 +1,44 @@
server:
port: 7031
servlet:
context-path: /v1.0
spring:
snowflake:
datacenterId: 2
workerId: 2
application:
name: tall
datasource:
type: com.alibaba.druid.pool.DruidDataSource
rabbitmq:
host: www.tall.wiki
password: 111111
port: 5672
username: admin
redis:
database: 0
host: www.tall.wiki
jedis:
pool:
max-active: 200
max-idle: 10
max-wait: -1ms
min-idle: 0
password: 'areowqr!@43ef'
port: 6379
timeout: 1000ms
swagger:
enable: false
eureka:
instance:
ip-address: 81.70.54.64
gatewayUrl: https://www.tall.wiki/gateway/
notGatewayUrl: https://www.tall.wiki/
smsCode: 1
wx:
prefixUrl: https://www.tall.wiki/wxconfigurer-api/
file:
path: /home/cloud/tall/uploads/
domain: https://www.tall.wiki/gateway/tall/v1.0/
imgDomain: https://www.tall.wiki/gateway/tall/v1.0/uploads

33
tall/src/main/resources/druid-prodsd.yml

@ -0,0 +1,33 @@
spring:
datasource:
druid:
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
driverClassName: com.mysql.cj.jdbc.Driver
dynamicUrl: jdbc:mysql://127.0.0.1:3306/${schema}
filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*'
filterName: druidFilter
filterProfileEnable: true
filterUrlPattern: /*
filters: stat,wall
initialSize: 5
maxActive: 20
maxPoolPreparedStatementPerConnectionSize: 20
maxWait: 60000
minEvictableIdleTimeMillis: 300000
minIdle: 5
password: 37080c1f223685592316b02dad8816c019290a476e54ebb638f9aa3ba8b6bdb9
poolPreparedStatements: true
servletLogSlowSql: true
servletLoginPassword: 111111
servletLoginUsername: druid
servletName: druidServlet
servletResetEnable: true
servletUrlMapping: /druid/*
testOnBorrow: false
testOnReturn: false
testWhileIdle: true
timeBetweenEvictionRunsMillis: 60000
url: jdbc:mysql://www.tall.wiki/tall?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true
username: root
validationQuery: SELECT 1 FROM DUAL
env: CCSENS_GAME

2
tall/src/main/resources/logback-spring.xml

@ -9,7 +9,7 @@
<contextName>logback</contextName>
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
<property name="log.path" value="/home/cloud/tall/log/" />
<property name="log.path" value="/home/cloud/game/log/" />
<!-- 彩色日志 -->
<!-- 彩色日志依赖的渲染类 -->

26
util/src/main/java/com/ccsens/util/RedisUtil.java

@ -1,20 +1,21 @@
package com.ccsens.util;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component
public class RedisUtil {
@Autowired
private RedisTemplate<String, Object> redisTemplate;
@Resource
private RedisTemplate<Object, Object> redisTemplate;
/**
* 指定缓存失效时间
@ -175,7 +176,7 @@ public class RedisUtil {
* @param key
* @return 对应的多个键值
*/
public Map<Object, Object> hmget(String key) {
public Map<? extends Object, ? extends Object> hmget(String key) {
return redisTemplate.opsForHash().entries(key);
}
@ -244,14 +245,17 @@ public class RedisUtil {
* @param time 时间() 注意:如果已存在的hash表有时间,这里将会替换原有的时间
* @return true 成功 false失败
*/
public boolean hset(String key, String item, Object value, long time) {
public boolean hset(String key, Object item, Object value, long time) {
log.info("存hash:{}:{}:{}:{}",key,item,value,time);
try {
redisTemplate.opsForHash().put(key, item, value);
if (time > 0) {
expire(key, time);
}
log.info("存hash成功:{}:{}:{}:{}",key,item,value,time);
return true;
} catch (Exception e) {
log.error("存hash异常",e);
e.printStackTrace();
return false;
}
@ -456,7 +460,6 @@ public class RedisUtil {
*
* @param key
* @param value
* @param time 时间()
* @return
*/
public boolean lSet(String key, Object value) {
@ -480,7 +483,9 @@ public class RedisUtil {
public boolean lSet(String key, Object value, long time) {
try {
redisTemplate.opsForList().rightPush(key, value);
if (time > 0) expire(key, time);
if (time > 0) {
expire(key, time);
}
return true;
} catch (Exception e) {
e.printStackTrace();
@ -493,7 +498,6 @@ public class RedisUtil {
*
* @param key
* @param value
* @param time 时间()
* @return
*/
public boolean lSet(String key, List<? extends Object> value) {
@ -517,7 +521,9 @@ public class RedisUtil {
public boolean lSet(String key, List<? extends Object> value, long time) {
try {
redisTemplate.opsForList().rightPushAll(key, value);
if (time > 0) expire(key, time);
if (time > 0) {
expire(key, time);
}
return true;
} catch (Exception e) {
e.printStackTrace();

23
util/src/main/java/com/ccsens/util/config/RabbitMQConfig.java

@ -1,6 +1,10 @@
package com.ccsens.util.config;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -14,6 +18,8 @@ public class RabbitMQConfig {
private static final String GAME_STATUS_DELAY_SEND_EXCHANGE = "gameStatusDelaySendExchange";
private static final String GAME_STATUS_DELAY_SEND_ROUTING_KEY = "gameStatusDelaySendRoutingKey";
public static final String GAME_MQ_A = "gameMqA";
/**消息队列发送*/
public static final String MESSAGE_QUEUE_NAME = "tall_message_1";
@ -44,6 +50,11 @@ public class RabbitMQConfig {
return new Queue(GAME_SCORE);
}
@Bean
public Queue queueGame(){
return new Queue(GAME_MQ_A);
}
// /**
// * 延时发送队列
// * @return
@ -74,4 +85,16 @@ public class RabbitMQConfig {
// }
//创建Fanout交换器
@Bean
FanoutExchange fanoutExchange() {
return new FanoutExchange("fanoutExchange");
}
//将对列绑定到Fanout交换器
@Bean
Binding bindingExchangeA(Queue queueGame, FanoutExchange fanoutExchange) {
return BindingBuilder.bind(queueGame).to(fanoutExchange);
}
}

40
util/src/test/java/com/ccsens/util/FileTest.java

@ -0,0 +1,40 @@
package com.ccsens.util;
import cn.hutool.core.util.ObjectUtil;
import com.ccsens.util.exception.BaseException;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
public class FileTest {
/**加密*/
@Test
public void fileToString () throws Exception {
InputStream in = null;
BufferedInputStream bin = null;
ByteArrayOutputStream baos = null;
BufferedOutputStream bout = null;
try {
URL url = new URL("http://192.144.182.42:7030/v1.0/file/download/数钱游戏配置表1.xlsx?path=wps/202012071/f93826c0e81e499f9c749d7a9d0da5d1.xlsx");
URLConnection conn = url.openConnection();
in = conn.getInputStream();
System.out.println(in.available());
//读取excel
XSSFWorkbook wb = new XSSFWorkbook(in);
if(ObjectUtil.isNull(wb)){ throw new BaseException(CodeEnum.NOT_CONFIG_OR_ERR); }
//读取sheet
XSSFSheet sheet = wb.getSheet("游戏配置表");
System.out.println(sheet.getSheetName());
} finally {
in.close();
}
}
}
Loading…
Cancel
Save