zhizhi wu 5 years ago
parent
commit
c48f313947
  1. 2
      cloudutil/src/main/resources/application-util-dev.yml
  2. 43
      game/src/main/java/com/ccsens/game/api/ClientController.java
  3. 2
      game/src/main/java/com/ccsens/game/bean/dto/ScreenDto.java
  4. 16
      game/src/main/java/com/ccsens/game/bean/vo/ScreenVo.java
  5. 8
      game/src/main/java/com/ccsens/game/persist/dao/GameUserJoinGroupDao.java
  6. 10
      game/src/main/java/com/ccsens/game/service/IScreenService.java
  7. 186
      game/src/main/java/com/ccsens/game/service/ScreenService.java
  8. 4
      game/src/main/resources/application.yml
  9. 2
      tall/src/main/java/com/ccsens/tall/bean/dto/TaskDto.java
  10. 1
      tall/src/main/java/com/ccsens/tall/config/TokenInterceptor.java
  11. 9
      tall/src/main/java/com/ccsens/tall/service/TaskSubTimeService.java
  12. 15
      tall/src/main/java/com/ccsens/tall/service/WbsSubSheetService.java
  13. 2
      tall/src/main/java/com/ccsens/tall/util/TaskUtil.java
  14. 4
      tall/src/main/resources/mapper_dao/TaskDetailDao.xml

2
cloudutil/src/main/resources/application-util-dev.yml

@ -20,7 +20,7 @@ eureka:
service-url:
# 指定eureka server通信地址,注意/eureka/小尾巴不能少
#defaultZone: http://admin:admin@peer1:8761/eureka/,http://admin:admin@peer2:8762/eureka/
defaultZone: http://admin:admin@49.233.89.188:7010/eureka/
defaultZone: http://admin:admin@127.0.0.1:7010/eureka/
instance:
# 是否注册IP到eureka server,如不指定或设为false,那就回注册主机名到eureka server
prefer-ip-address: true

43
game/src/main/java/com/ccsens/game/api/ClientController.java

@ -5,6 +5,7 @@ import com.ccsens.game.bean.dto.ClientDto;
import com.ccsens.game.bean.dto.ScreenDto;
import com.ccsens.game.bean.vo.ClientVo;
import com.ccsens.game.service.IClientService;
import com.ccsens.game.service.IScreenService;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.bean.dto.QueryDto;
import io.swagger.annotations.Api;
@ -14,10 +15,10 @@ import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Slf4j
@Api(tags = "客户端相关api" , description = "ClientController")
@RestController
@ -25,6 +26,8 @@ import org.springframework.web.bind.annotation.RestController;
public class ClientController {
@Autowired
private IClientService clientService;
@Autowired
private IScreenService screenService;
@ApiOperation(value = "查看全部排行榜", notes = "")
@ApiImplicitParams({
@ -46,4 +49,36 @@ public class ClientController {
ClientVo.Join join = clientService.join(params.getParam(), params.getUserId());
return JsonResponse.newInstance().ok(join);
}
@ApiOperation(value = "查询游戏规则", notes = "")
@ApiImplicitParams({
})
@RequestMapping(value = "activityRule", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<String>> getGameActivityRule(@ApiParam @RequestParam Long recordId) throws Exception {
log.info("获取游戏规则:{}",recordId);
List<String> gameActivityRule = screenService.getGameActivityRule(screenService.getGameTypeId(recordId));
return JsonResponse.newInstance().ok(gameActivityRule);
}
@ApiOperation(value = "查询游戏奖品", notes = "")
@ApiImplicitParams({
})
@RequestMapping(value = "activityPrize", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<String>> getGameActivityPrize(@ApiParam @RequestParam Long recordId) throws Exception {
log.info("获取游戏规则:{}",recordId);
List<String> gameActivityRule = screenService.getGameActivityPrize(screenService.getGameTypeId(recordId));
return JsonResponse.newInstance().ok(gameActivityRule);
}
@ApiOperation(value = "查询奖券使用说明", notes = "")
@ApiImplicitParams({
})
@RequestMapping(value = "prizeInstructions", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<String>> getGamePrizeInstructions(@ApiParam @RequestParam Long recordId) throws Exception {
log.info("获取游戏规则:{}",recordId);
List<String> gameActivityRule = screenService.getGamePrizeInstructions(screenService.getGameTypeId(recordId));
return JsonResponse.newInstance().ok(gameActivityRule);
}
}

2
game/src/main/java/com/ccsens/game/bean/dto/ScreenDto.java

@ -54,4 +54,6 @@ public class ScreenDto {
@ApiModelProperty("是否为单独的再来一次 1:再玩一次")
private Byte startStatus;
}
}

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

@ -111,7 +111,7 @@ public class ScreenVo {
@ApiModelProperty("准备中")
private PreparingData preparingData;
@ApiModelProperty("进行中")
private ProcessingData processingData;
private Object processingData;
@ApiModelProperty("已结束")
private CompletedData completedData;
@ -138,4 +138,18 @@ public class ScreenVo {
@ApiModelProperty("本地开始时间")
private Long startLocalTime;
}
@Data
@ApiModel("分组的信息")
public static class GroupVo{
@ApiModelProperty("分组的id")
private Long groupId;
@ApiModelProperty("分组的名称")
private String groupName;
@ApiModelProperty("该组的总分")
private int score;
@ApiModelProperty("该组总人数")
private int totalMembers;
}
}

8
game/src/main/java/com/ccsens/game/persist/dao/GameUserJoinGroupDao.java

@ -0,0 +1,8 @@
package com.ccsens.game.persist.dao;
import com.ccsens.game.persist.mapper.GameUserJoinGroupMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface GameUserJoinGroupDao extends GameUserJoinGroupMapper {
}

10
game/src/main/java/com/ccsens/game/service/IScreenService.java

@ -5,6 +5,8 @@ import com.ccsens.game.bean.po.GameRecord;
import com.ccsens.game.bean.vo.ScreenVo;
import com.ccsens.util.bean.dto.QueryDto;
import java.util.List;
public interface IScreenService {
ScreenVo.UrlVo getScreenUrl(QueryDto<ScreenDto.MemberGame> params) throws Exception;
@ -27,4 +29,12 @@ public interface IScreenService {
* @return
*/
GameRecord getGameRecord(long gameRecordId);
List<String> getGameActivityRule(Long gameTypeId);
List<String> getGameActivityPrize(Long gameTypeId);
List<String> getGamePrizeInstructions(Long gameTypeId);
Long getGameTypeId(Long recordId);
}

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

@ -30,6 +30,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.websocket.OnClose;
import java.io.File;
import java.util.*;
import java.util.concurrent.*;
@ -50,6 +51,8 @@ public class ScreenService implements IScreenService{
@Autowired
private GameGroupDao gameGroupDao;
@Autowired
private GameUserJoinGroupDao gameUserJoinGroupDao;
@Autowired
private GameActivityRuleDao activityRuleDao;
@Autowired
private GameActivityPrizeDao activityPrizeDao;
@ -232,7 +235,14 @@ public class ScreenService implements IScreenService{
case 2:
break;
case 3:
ScreenVo.CompletedData completedData = getCompletedData(memberRecord.getMemberRecord());
//查询游戏是否有分组
GameType gameType = gameTypeDao.selectByPrimaryKey(gameUserPay.getGameTypeId());
ScreenVo.CompletedData completedData = null;
if(gameType.getIsGroup() == 0) {
completedData = getCompletedData(memberRecord.getMemberRecord());
}else {
completedData = getCompletedDataByWin(memberRecord.getMemberRecord());
}
gameInfoVo.setCompletedData(completedData);
break;
default:
@ -253,6 +263,9 @@ public class ScreenService implements IScreenService{
long gameRecordId = memberRecord.getMemberRecord();
GameRecord gameRecord = getGameRecord(gameRecordId);
//获取游戏的购买记录和类型
GameUserPay gameUserPay = gameUserPayDao.selectByPrimaryKey(gameRecord.getUserPayId());
GameType gameType = gameTypeDao.selectByPrimaryKey(gameUserPay.getGameTypeId());
gameStatusVo.setGameStatus(gameRecord.getGameStatus());
@ -283,14 +296,27 @@ public class ScreenService implements IScreenService{
gameStatusVo.setPreparingData(preparingData);
break;
case 2:
ScreenVo.ProcessingData processingData = new ScreenVo.ProcessingData();
// 查询前十名(列表顺序即前十名顺序)
List<ScreenVo.TopUsers> tops = getTopUsers(gameRecordId);
processingData.setTopMembers(tops);
gameStatusVo.setProcessingData(processingData);
//查询游戏是否有分组
if(gameType.getIsGroup() == 0) {
//普通游戏返回前十名的信息
ScreenVo.ProcessingData processingData = new ScreenVo.ProcessingData();
// 查询前十名(列表顺序即前十名顺序)
List<ScreenVo.TopUsers> tops = getTopUsers(gameRecordId);
processingData.setTopMembers(tops);
gameStatusVo.setProcessingData(processingData);
}else {
//分组游戏则返回每个分组的信息
List<ScreenVo.GroupVo> groupVoList = getGroupScore(gameRecordId);
gameStatusVo.setProcessingData(groupVoList);
}
break;
case 3:
ScreenVo.CompletedData completedData = getCompletedData(gameRecordId);
ScreenVo.CompletedData completedData = null;
if(gameType.getIsGroup() == 0) {
completedData = getCompletedData(memberRecord.getMemberRecord());
}else {
completedData = getCompletedDataByWin(memberRecord.getMemberRecord());
}
gameStatusVo.setCompletedData(completedData);
break;
default:
@ -299,11 +325,36 @@ public class ScreenService implements IScreenService{
return gameStatusVo;
}
/**
* 进行中查询每个组的信息
*/
private List<ScreenVo.GroupVo> getGroupScore(Long gameRecordId){
List<ScreenVo.GroupVo> groupVoList = new ArrayList<>();
//查询分组信息
GameGroupExample gameGroupExample = new GameGroupExample();
gameGroupExample.createCriteria().andRecordIdEqualTo(gameRecordId);
List<GameGroup> gameGroupList = gameGroupDao.selectByExample(gameGroupExample);
if(CollectionUtil.isNotEmpty(gameGroupList)){
for(GameGroup gameGroup : gameGroupList){
Map<String,Object> group = getGroupTotalScore(gameGroup.getId());
List<GameUserJoin> userJoinList = (List<GameUserJoin>) group.get("userJoinList");
ScreenVo.GroupVo groupVo = new ScreenVo.GroupVo();
groupVo.setGroupId(gameGroup.getId());
groupVo.setGroupName(gameGroup.getName());
groupVo.setScore((Integer) group.get("totalScore"));
groupVo.setTotalMembers(userJoinList.size());
groupVoList.add(groupVo);
}
}
return groupVoList;
}
/**
* 结束时查询胜利组的信息总分数总次数平均以及前十名
*/
private ScreenVo.CompletedData getCompletedDataByWin(Long gameRecordId) {
//1、分别查询redis内每个队伍的总分,
ScreenVo.CompletedData completedData = new ScreenVo.CompletedData();
//TODO 1、分别查询redis内每个队伍的总分,
//2、查询获胜队伍的信息
//3、redis内没有则查询数据库
@ -312,15 +363,50 @@ public class ScreenService implements IScreenService{
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) group1.get("totalScore");
if(score1 > score2){
userJoinList = (List<GameUserJoin>) group1.get("userJoinList");
}else {
userJoinList = (List<GameUserJoin>) group2.get("userJoinList");
}
}
//5、获取获胜队伍的信息
completedData = getCompletedData(userJoinList);
}
//4、分别查询每个队伍的总分
//5、获取获胜队伍的信息
return null;
return completedData;
}
/**
* 获取队伍的总分
*/
private Map<String,Object> getGroupTotalScore(Long groupId){
Map<String,Object> groupMap = null;
//查找队伍的参赛人
GameUserJoinGroupExample joinGroupExample = new GameUserJoinGroupExample();
joinGroupExample.createCriteria().andGameGroupIdEqualTo(groupId);
List<GameUserJoinGroup> userJoinGroupList = gameUserJoinGroupDao.selectByExample(joinGroupExample);
if(CollectionUtil.isNotEmpty(userJoinGroupList)){
groupMap = new HashMap<>();
int totalScore = 0;
List<GameUserJoin> userJoinList = new ArrayList<>();
for (GameUserJoinGroup userJoinGroup : userJoinGroupList){
GameUserJoin userJoin = gameUserJoinDao.selectByPrimaryKey(userJoinGroup.getUserJoinId());
totalScore += userJoin.getScore();
userJoinList.add(userJoin);
}
groupMap.put("totalScore",totalScore);
groupMap.put("userJoinList",userJoinList);
}
return groupMap;
}
/**
* 查询总分数总次数平均以及前十名
* @param gameRecordId
@ -492,14 +578,18 @@ public class ScreenService implements IScreenService{
/**
* 查找活动规则
*/
private List<String> getGameActivityRule(Long gameTypeId){
@Override
public List<String> getGameActivityRule(Long gameTypeId){
List<String> ruleList = new ArrayList<>();
GameActivityRuleExample activityRuleExample = new GameActivityRuleExample();
activityRuleExample.createCriteria().andGameIdEqualTo(gameTypeId);
List<GameActivityRule> gameActivityRuleList = activityRuleDao.selectByExample(activityRuleExample);
if(CollectionUtil.isNotEmpty(gameActivityRuleList)){
for(GameActivityRule rule : gameActivityRuleList){
ruleList.add(rule.getDescription());
if(ObjectUtil.isNotNull(gameTypeId)) {
GameActivityRuleExample activityRuleExample = new GameActivityRuleExample();
activityRuleExample.createCriteria().andGameIdEqualTo(gameTypeId);
List<GameActivityRule> gameActivityRuleList = activityRuleDao.selectByExample(activityRuleExample);
if (CollectionUtil.isNotEmpty(gameActivityRuleList)) {
for (GameActivityRule rule : gameActivityRuleList) {
ruleList.add(rule.getDescription());
}
}
}
return ruleList;
@ -507,14 +597,18 @@ public class ScreenService implements IScreenService{
/**
* 查询活动奖品
*/
private List<String> getGameActivityPrize(Long gameTypeId){
@Override
public List<String> getGameActivityPrize(Long gameTypeId){
List<String> prizeList = new ArrayList<>();
GameActivityPrizeExample activityPrizeExample = new GameActivityPrizeExample();
activityPrizeExample.createCriteria().andGameIdEqualTo(gameTypeId);
List<GameActivityPrize> gameActivityPrizeList = activityPrizeDao.selectByExample(activityPrizeExample);
if(CollectionUtil.isNotEmpty(gameActivityPrizeList)){
for(GameActivityPrize prize : gameActivityPrizeList){
prizeList.add(prize.getDescription());
if(ObjectUtil.isNotNull(gameTypeId)) {
GameActivityPrizeExample activityPrizeExample = new GameActivityPrizeExample();
activityPrizeExample.createCriteria().andGameIdEqualTo(gameTypeId);
List<GameActivityPrize> gameActivityPrizeList = activityPrizeDao.selectByExample(activityPrizeExample);
if (CollectionUtil.isNotEmpty(gameActivityPrizeList)) {
for (GameActivityPrize prize : gameActivityPrizeList) {
prizeList.add(prize.getDescription());
}
}
}
return prizeList;
@ -522,14 +616,18 @@ public class ScreenService implements IScreenService{
/**
* 奖券使用说明表
*/
private List<String> getGamePrizeInstructions(Long gameTypeId){
@Override
public List<String> getGamePrizeInstructions(Long gameTypeId){
List<String> instructionsList = new ArrayList<>();
GamePrizeInstructionsExample prizeInstructionsExample = new GamePrizeInstructionsExample();
prizeInstructionsExample.createCriteria().andGameIdEqualTo(gameTypeId);
List<GamePrizeInstructions> gamePrizeInstructionsList = prizeInstructionsDao.selectByExample(prizeInstructionsExample);
if(CollectionUtil.isNotEmpty(gamePrizeInstructionsList)){
for(GamePrizeInstructions prizeInstructions : gamePrizeInstructionsList){
instructionsList.add(prizeInstructions.getDescription());
if(ObjectUtil.isNotNull(gameTypeId)) {
GamePrizeInstructionsExample prizeInstructionsExample = new GamePrizeInstructionsExample();
prizeInstructionsExample.createCriteria().andGameIdEqualTo(gameTypeId);
List<GamePrizeInstructions> gamePrizeInstructionsList = prizeInstructionsDao.selectByExample(prizeInstructionsExample);
if (CollectionUtil.isNotEmpty(gamePrizeInstructionsList)) {
for (GamePrizeInstructions prizeInstructions : gamePrizeInstructionsList) {
instructionsList.add(prizeInstructions.getDescription());
}
}
}
return instructionsList;
@ -704,5 +802,23 @@ public class ScreenService implements IScreenService{
}
/**
* 查询游戏类型id
*/
@Override
public Long getGameTypeId(Long recordId){
Long gameTypeId = null;
GameRecord gameRecord = gameRecordDao.selectByPrimaryKey(recordId);
if(ObjectUtil.isNotNull(gameRecord)){
//获取游戏的购买记录和类型
GameUserPay gameUserPay = gameUserPayDao.selectByPrimaryKey(gameRecord.getUserPayId());
if(ObjectUtil.isNotNull(gameUserPay)) {
GameType gameType = gameTypeDao.selectByPrimaryKey(gameUserPay.getGameTypeId());
if(ObjectUtil.isNotNull(gameType)){
gameTypeId = gameType.getId();
}
}
}
return gameTypeId;
}
}

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

2
tall/src/main/java/com/ccsens/tall/bean/dto/TaskDto.java

@ -172,7 +172,7 @@ public class TaskDto {
@ApiModelProperty("任务id")
private Long id;
@ApiModelProperty("任务完成状态0未完成 1进行中 2已完成")
private int completedStatus;
private Integer completedStatus;
}
}

1
tall/src/main/java/com/ccsens/tall/config/TokenInterceptor.java

@ -53,6 +53,7 @@ public class TokenInterceptor implements HandlerInterceptor {
return false;
}
//验证用户是否禁用
SysUser user = userService.getUserById(Long.valueOf(claims.getSubject()));
if(user.getRecStatus() == WebConstant.REC_STATUS.Disabled.value){

9
tall/src/main/java/com/ccsens/tall/service/TaskSubTimeService.java

@ -75,6 +75,7 @@ public class TaskSubTimeService implements ITaskSubTimeService {
*/
@Override
public TaskVo.NormalTask finishTask(Long currentUserId, TaskDto.TaskSubTimeId subTimeId) throws Exception {
int completedStatus = subTimeId.getCompletedStatus() == null ? 2 : subTimeId.getCompletedStatus();
//查找taskSubTime
ProTaskSubTime taskSubTime = taskSubTimeDao.selectByPrimaryKey(subTimeId.getId());
if(ObjectUtil.isNull(taskSubTime)){
@ -133,26 +134,26 @@ public class TaskSubTimeService implements ITaskSubTimeService {
if(ObjectUtil.isNull(subTimeMember)){
subTimeMember = new ProSubTimeMember();
subTimeMember.setId(snowflake.nextId());
subTimeMember.setComplatedStatus((byte) subTimeId.getCompletedStatus());
subTimeMember.setComplatedStatus((byte) completedStatus);
subTimeMember.setMemberId(member.getId());
subTimeMember.setTaskSubTimeId(subTimeId.getId());
subTimeMember.setRealFinishTime(System.currentTimeMillis());
proSubTimeMemberDao.insertSelective(subTimeMember);
}else {
subTimeMember.setComplatedStatus((byte) subTimeId.getCompletedStatus());
subTimeMember.setComplatedStatus((byte) completedStatus);
subTimeMember.setRealFinishTime(System.currentTimeMillis());
proSubTimeMemberDao.updateByPrimaryKeySelective(subTimeMember);
}
}else {
ProSubTimeMember subTimeMember = isFinishTask(member.getId(),subTimeId.getId());
if(ObjectUtil.isNotNull(subTimeMember)){
subTimeMember.setComplatedStatus((byte) subTimeId.getCompletedStatus());
subTimeMember.setComplatedStatus((byte) completedStatus);
subTimeMember.setRealFinishTime(System.currentTimeMillis());
proSubTimeMemberDao.updateByPrimaryKeySelective(subTimeMember);
}else {
subTimeMember = new ProSubTimeMember();
subTimeMember.setId(snowflake.nextId());
subTimeMember.setComplatedStatus((byte) subTimeId.getCompletedStatus());
subTimeMember.setComplatedStatus((byte) completedStatus);
subTimeMember.setTaskSubTimeId(subTimeId.getId());
subTimeMember.setMemberId(member.getId());
subTimeMember.setRealFinishTime(System.currentTimeMillis());

15
tall/src/main/java/com/ccsens/tall/service/WbsSubSheetService.java

@ -167,12 +167,17 @@ public class WbsSubSheetService implements IWbsSubSheetService {
subTask.setId(snowflake.nextId());
subTask.setName(nameCell);
subTask.setDescription(descriptionCell);
if (StrUtil.isNotEmpty(beginCell)) {
subTask.setBeginTime(Long.valueOf(beginCell));
}
if (StrUtil.isNotEmpty(endCell)) {
subTask.setEndTime(Long.valueOf(endCell));
if (StrUtil.isNotEmpty(repeatCell)) {
subTask.setCycle(repeatCell);
}else {
if (StrUtil.isNotEmpty(beginCell)) {
subTask.setBeginTime(Long.valueOf(beginCell));
}
if (StrUtil.isNotEmpty(endCell)) {
subTask.setEndTime(Long.valueOf(endCell));
}
}
subTask.setLevel((byte) 2);
subTask.setHasGroup((byte) 0);
if (StrUtil.isNotEmpty(memberCell)) {

2
tall/src/main/java/com/ccsens/tall/util/TaskUtil.java

@ -56,7 +56,7 @@ public class TaskUtil {
detail.setBeginTime(subTask.getBeginTime());
detail.setEndTime(subTask.getEndTime());
}
if (detail.getBeginTime() < start && detail.getEndTime() > end) {
if (detail.getBeginTime() <= start && detail.getEndTime() > end) {
globalTask.add(detail);
} else if (detail.getBeginTime() == start && detail.getEndTime() == end){
globalTask.add(detail);

4
tall/src/main/resources/mapper_dao/TaskDetailDao.xml

@ -87,7 +87,7 @@
</if>
<if test="endTime != null">
AND
s.end_time &gt;= #{startTime}
s.end_time &gt; #{startTime}
</if>
AND
@ -138,7 +138,7 @@
AND
s.begin_time &lt; #{endTime}
AND
s.end_time &gt;= #{startTime}
s.end_time &gt; #{startTime}
AND
d.Level in (2,3)

Loading…
Cancel
Save