|
@ -1,10 +1,12 @@ |
|
|
package com.ccsens.game.service; |
|
|
package com.ccsens.game.service; |
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
import com.ccsens.cloudutil.bean.tall.dto.WpsDto; |
|
|
import com.ccsens.cloudutil.feign.TallFeignClient; |
|
|
import com.ccsens.cloudutil.feign.TallFeignClient; |
|
|
import com.ccsens.game.bean.dto.ClientDto; |
|
|
import com.ccsens.game.bean.dto.ClientDto; |
|
|
import com.ccsens.game.bean.dto.ScreenDto; |
|
|
import com.ccsens.game.bean.dto.ScreenDto; |
|
@ -16,22 +18,27 @@ import com.ccsens.game.persist.dao.*; |
|
|
import com.ccsens.game.util.GameConstant; |
|
|
import com.ccsens.game.util.GameConstant; |
|
|
import com.ccsens.game.util.SendMsg; |
|
|
import com.ccsens.game.util.SendMsg; |
|
|
import com.ccsens.util.CodeEnum; |
|
|
import com.ccsens.util.CodeEnum; |
|
|
|
|
|
import com.ccsens.util.ExcelUtil; |
|
|
import com.ccsens.util.RedisUtil; |
|
|
import com.ccsens.util.RedisUtil; |
|
|
import com.ccsens.util.WebConstant; |
|
|
import com.ccsens.util.WebConstant; |
|
|
import com.ccsens.util.bean.dto.QueryDto; |
|
|
import com.ccsens.util.bean.dto.QueryDto; |
|
|
import com.ccsens.util.exception.BaseException; |
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow; |
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
import org.springframework.data.redis.core.ZSetOperations; |
|
|
import org.springframework.data.redis.core.ZSetOperations; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
import javax.annotation.Resource; |
|
|
|
|
|
import java.io.*; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.concurrent.*; |
|
|
import java.util.concurrent.Executors; |
|
|
|
|
|
import java.util.concurrent.ScheduledExecutorService; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @author zy |
|
|
* @author zy |
|
@ -40,92 +47,57 @@ import java.util.concurrent.*; |
|
|
@Service |
|
|
@Service |
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
public class ScreenService implements IScreenService { |
|
|
public class ScreenService implements IScreenService { |
|
|
@Autowired |
|
|
@Resource |
|
|
private ClientService clientService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private GameUserPayDao gameUserPayDao; |
|
|
private GameUserPayDao gameUserPayDao; |
|
|
@Autowired |
|
|
@Resource |
|
|
private GameTypeDao gameTypeDao; |
|
|
private GameTypeDao gameTypeDao; |
|
|
@Autowired |
|
|
@Resource |
|
|
private GameRecordDao gameRecordDao; |
|
|
private GameRecordDao gameRecordDao; |
|
|
@Autowired |
|
|
@Resource |
|
|
private GameGroupDao gameGroupDao; |
|
|
private GameGroupDao gameGroupDao; |
|
|
@Autowired |
|
|
@Resource |
|
|
private GameUserJoinGroupDao gameUserJoinGroupDao; |
|
|
private GameUserJoinGroupDao gameUserJoinGroupDao; |
|
|
@Autowired |
|
|
@Resource |
|
|
private GameActivityRuleDao activityRuleDao; |
|
|
private GameActivityRuleDao activityRuleDao; |
|
|
@Autowired |
|
|
@Resource |
|
|
private GameActivityPrizeDao activityPrizeDao; |
|
|
private GameActivityPrizeDao activityPrizeDao; |
|
|
@Autowired |
|
|
@Resource |
|
|
private GamePrizeInstructionsDao prizeInstructionsDao; |
|
|
private GamePrizeInstructionsDao prizeInstructionsDao; |
|
|
@Autowired |
|
|
@Resource |
|
|
private GameUserJoinDao gameUserJoinDao; |
|
|
private GameUserJoinDao gameUserJoinDao; |
|
|
@Autowired |
|
|
@Resource |
|
|
private TallFeignClient tallFeignClient; |
|
|
private TallFeignClient tallFeignClient; |
|
|
@Autowired |
|
|
@Resource |
|
|
private IMessageService messageService; |
|
|
private IMessageService messageService; |
|
|
|
|
|
@Resource |
|
|
@Autowired |
|
|
|
|
|
private Snowflake snowflake; |
|
|
private Snowflake snowflake; |
|
|
@Autowired |
|
|
@Resource |
|
|
private SendMsg sendMsg; |
|
|
private SendMsg sendMsg; |
|
|
@Autowired |
|
|
@Resource |
|
|
private RedisUtil redisUtil; |
|
|
private RedisUtil redisUtil; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 传入用户信息,返回游戏大屏路径 |
|
|
* 创建游戏 |
|
|
* |
|
|
* |
|
|
* @return |
|
|
* @return 返回游戏数据 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public ScreenVo.UrlVo getScreenUrl(QueryDto<ScreenDto.MemberGame> params) throws Exception { |
|
|
public ScreenVo.UrlVo getScreenUrl(QueryDto<ScreenDto.MemberGame> params) throws Exception { |
|
|
ScreenDto.MemberGame memberGame = params.getParam(); |
|
|
ScreenDto.MemberGame memberGame = params.getParam(); |
|
|
|
|
|
Long userId = params.getUserId(); |
|
|
//查找游戏
|
|
|
//查找游戏
|
|
|
GameType gameType = null; |
|
|
|
|
|
GameTypeExample gameTypeExample = new GameTypeExample(); |
|
|
GameTypeExample gameTypeExample = new GameTypeExample(); |
|
|
gameTypeExample.createCriteria().andCodeEqualTo(memberGame.getGameType()); |
|
|
gameTypeExample.createCriteria().andCodeEqualTo(memberGame.getGameType()); |
|
|
List<GameType> gameTypeList = gameTypeDao.selectByExample(gameTypeExample); |
|
|
List<GameType> gameTypeList = gameTypeDao.selectByExample(gameTypeExample); |
|
|
if (CollectionUtil.isNotEmpty(gameTypeList)) { |
|
|
if (CollectionUtil.isEmpty(gameTypeList)) { |
|
|
gameType = gameTypeList.get(0); |
|
|
|
|
|
} |
|
|
|
|
|
if (ObjectUtil.isNull(gameType)) { |
|
|
|
|
|
throw new BaseException(CodeEnum.NOT_GAME_TYPE); |
|
|
throw new BaseException(CodeEnum.NOT_GAME_TYPE); |
|
|
} |
|
|
} |
|
|
|
|
|
GameType gameType = gameTypeList.get(0); |
|
|
//2、查找此用户购买的此游戏的信息,若没有则添加一条记录,默认已付款,结束时间为添加后的一个月,默认次数为10次
|
|
|
//2、查找此用户购买的此游戏的信息,若没有则添加一条记录,默认已付款,结束时间为添加后的一个月,默认次数为10次
|
|
|
GameUserPay gameUserPay = null; |
|
|
GameUserPay gameUserPay = getGameUserPay(userId, gameType); |
|
|
GameUserPayExample gameUserPayExample = new GameUserPayExample(); |
|
|
//查询该任务下的游戏记录信息 如果还有其他未结束的游戏则返回提示信息
|
|
|
gameUserPayExample.createCriteria().andUserIdEqualTo(params.getUserId()).andGameTypeIdEqualTo(gameType.getId()); |
|
|
|
|
|
List<GameUserPay> gameUserPayList = gameUserPayDao.selectByExample(gameUserPayExample); |
|
|
|
|
|
if (CollectionUtil.isNotEmpty(gameUserPayList)) { |
|
|
|
|
|
gameUserPay = gameUserPayList.get(0); |
|
|
|
|
|
} else { |
|
|
|
|
|
gameUserPay = new GameUserPay(); |
|
|
|
|
|
gameUserPay.setId(snowflake.nextId()); |
|
|
|
|
|
gameUserPay.setUserId(params.getUserId()); |
|
|
|
|
|
gameUserPay.setGameTypeId(gameType.getId()); |
|
|
|
|
|
gameUserPay.setTotalCount(10); |
|
|
|
|
|
gameUserPay.setUsedCount(0); |
|
|
|
|
|
gameUserPay.setCreatedTime(System.currentTimeMillis()); |
|
|
|
|
|
gameUserPay.setDueTime(gameUserPay.getCreatedTime() + (3600 * 24 * 30)); |
|
|
|
|
|
gameUserPayDao.insertSelective(gameUserPay); |
|
|
|
|
|
} |
|
|
|
|
|
//查询该任务下的游戏记录信息
|
|
|
|
|
|
if (ObjectUtil.isNotNull(memberGame.getTaskId())) { |
|
|
if (ObjectUtil.isNotNull(memberGame.getTaskId())) { |
|
|
GameRecordExample recordExample = new GameRecordExample(); |
|
|
selectOldRecord(memberGame.getTaskId()); |
|
|
recordExample.createCriteria().andTaskIdEqualTo(memberGame.getTaskId()); |
|
|
|
|
|
recordExample.setOrderByClause("created_at DESC"); |
|
|
|
|
|
List<GameRecord> recordList = gameRecordDao.selectByExample(recordExample); |
|
|
|
|
|
if (CollectionUtil.isNotEmpty(recordList)) { |
|
|
|
|
|
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); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//3、根据用户购买的记录,添加一场新的游戏记录
|
|
|
//3、根据用户购买的记录,添加一场新的游戏记录
|
|
@ -143,21 +115,36 @@ public class ScreenService implements IScreenService { |
|
|
} |
|
|
} |
|
|
gameRecord.setUrl(gameUrl + gameType.getScreenUrl() + "?id=" + gameRecord.getId()); |
|
|
gameRecord.setUrl(gameUrl + gameType.getScreenUrl() + "?id=" + gameRecord.getId()); |
|
|
gameRecord.setQrCodeUrl(gameUrl + gameRecord.getId() + File.separator + gameType.getClientUrl()); |
|
|
gameRecord.setQrCodeUrl(gameUrl + gameRecord.getId() + File.separator + gameType.getClientUrl()); |
|
|
|
|
|
//查找此任务下的游戏配置表
|
|
|
|
|
|
byte businessType = 8; |
|
|
|
|
|
if( GameConstant.GAME_TYPE_SQ.equalsIgnoreCase(memberGame.getGameType())){ |
|
|
|
|
|
businessType = 9; |
|
|
|
|
|
}else if( GameConstant.GAME_TYPE_BH.equalsIgnoreCase(memberGame.getGameType())){ |
|
|
|
|
|
businessType = 10; |
|
|
|
|
|
} |
|
|
|
|
|
String wpsFilePath = tallFeignClient.getWpsFilePath(memberGame.getTaskId(),businessType); |
|
|
|
|
|
if(StrUtil.isNotEmpty(wpsFilePath)){ |
|
|
|
|
|
//添加配置信息
|
|
|
|
|
|
saveGameRecord(wpsFilePath,gameRecord); |
|
|
|
|
|
} |
|
|
|
|
|
//将游戏记录添加数据库
|
|
|
gameRecordDao.insertSelective(gameRecord); |
|
|
gameRecordDao.insertSelective(gameRecord); |
|
|
//4、 判断是否有分组,如果是分组游戏,添加两条分组信息
|
|
|
//配置表不存在,而且游戏类型默认为分组游戏,默认添加两个分组
|
|
|
if (gameType.getIsGroup() == 1) { |
|
|
if(StrUtil.isEmpty(wpsFilePath) && gameType.getIsGroup() == 1){ |
|
|
GameGroup gameGroupRed = new GameGroup(); |
|
|
if (gameType.getIsGroup() == 1) { |
|
|
gameGroupRed.setId(snowflake.nextId()); |
|
|
GameGroup gameGroupRed = new GameGroup(); |
|
|
gameGroupRed.setRecordId(gameRecord.getId()); |
|
|
gameGroupRed.setId(snowflake.nextId()); |
|
|
gameGroupRed.setName(memberGame.getFirstTeam()); |
|
|
gameGroupRed.setRecordId(gameRecord.getId()); |
|
|
gameGroupRed.setCode(GameConstant.FIRST_GROUP); |
|
|
gameGroupRed.setName(memberGame.getFirstTeam()); |
|
|
gameGroupDao.insertSelective(gameGroupRed); |
|
|
gameGroupRed.setCode(GameConstant.FIRST_GROUP); |
|
|
GameGroup gameGroupBlue = new GameGroup(); |
|
|
gameGroupDao.insertSelective(gameGroupRed); |
|
|
gameGroupBlue.setId(snowflake.nextId()); |
|
|
GameGroup gameGroupBlue = new GameGroup(); |
|
|
gameGroupBlue.setRecordId(gameRecord.getId()); |
|
|
gameGroupBlue.setId(snowflake.nextId()); |
|
|
gameGroupBlue.setName(memberGame.getSecondTeam()); |
|
|
gameGroupBlue.setRecordId(gameRecord.getId()); |
|
|
gameGroupBlue.setCode(GameConstant.SECOND_GROUP); |
|
|
gameGroupBlue.setName(memberGame.getSecondTeam()); |
|
|
gameGroupDao.insertSelective(gameGroupBlue); |
|
|
gameGroupBlue.setCode(GameConstant.SECOND_GROUP); |
|
|
|
|
|
gameGroupDao.insertSelective(gameGroupBlue); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//5、查询该游戏的规则
|
|
|
//5、查询该游戏的规则
|
|
@ -172,7 +159,7 @@ public class ScreenService implements IScreenService { |
|
|
String url = gameRecord.getUrl() + "&projectId=" + memberGame.getProjectId(); |
|
|
String url = gameRecord.getUrl() + "&projectId=" + memberGame.getProjectId(); |
|
|
//给所有人发送消息发送消息
|
|
|
//给所有人发送消息发送消息
|
|
|
ChromeMessageDto chromeMessageDto = new ChromeMessageDto(url, gameRecord.getId(), memberGame.getProjectId(),gameType.getCode()); |
|
|
ChromeMessageDto chromeMessageDto = new ChromeMessageDto(url, gameRecord.getId(), memberGame.getProjectId(),gameType.getCode()); |
|
|
BaseMessageDto.MessageUser messageUser = null; |
|
|
BaseMessageDto.MessageUser messageUser; |
|
|
List<BaseMessageDto.MessageUser> messageUserList = new ArrayList<>(); |
|
|
List<BaseMessageDto.MessageUser> messageUserList = new ArrayList<>(); |
|
|
//获取项目下所有成员
|
|
|
//获取项目下所有成员
|
|
|
List<Long> memberIdList = tallFeignClient.getMemberIdListByProject(memberGame.getProjectId()); |
|
|
List<Long> memberIdList = tallFeignClient.getMemberIdListByProject(memberGame.getProjectId()); |
|
@ -185,14 +172,237 @@ public class ScreenService implements IScreenService { |
|
|
} |
|
|
} |
|
|
chromeMessageDto.setReceivers(messageUserList); |
|
|
chromeMessageDto.setReceivers(messageUserList); |
|
|
messageService.sendGameMessageWithGetUrl(chromeMessageDto); |
|
|
messageService.sendGameMessageWithGetUrl(chromeMessageDto); |
|
|
|
|
|
|
|
|
return urlVo; |
|
|
return urlVo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 根据配置信息创建游戏 |
|
|
|
|
|
* @param wpsFilePath 配置文件的路径 |
|
|
|
|
|
* @param gameRecord 新建的游戏记录信息 |
|
|
|
|
|
*/ |
|
|
|
|
|
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); } |
|
|
|
|
|
//读取sheet
|
|
|
|
|
|
XSSFSheet sheet = wb.getSheet("游戏配置表"); |
|
|
|
|
|
if(ObjectUtil.isNull(sheet)){ throw new BaseException(CodeEnum.NOT_CONFIG_OR_ERR); } |
|
|
|
|
|
//比赛模式
|
|
|
|
|
|
XSSFRow gamePatternRow = sheet.getRow(1); |
|
|
|
|
|
if(ObjectUtil.isNotNull(gamePatternRow)){ |
|
|
|
|
|
String gamePattern = ExcelUtil.getCellValue(gamePatternRow.getCell(1)); |
|
|
|
|
|
if(gamePattern.equalsIgnoreCase(GameConstant.GAME_GROUP)){ |
|
|
|
|
|
gameRecord.setGroup((byte) 1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//比赛时长
|
|
|
|
|
|
XSSFRow durationRow = sheet.getRow(2); |
|
|
|
|
|
if(ObjectUtil.isNotNull(durationRow)){ |
|
|
|
|
|
int duration = Integer.parseInt(ExcelUtil.getCellValue(durationRow.getCell(1))); |
|
|
|
|
|
gameRecord.setDuration(duration); |
|
|
|
|
|
} |
|
|
|
|
|
//人数上限
|
|
|
|
|
|
XSSFRow memberLimitRow = sheet.getRow(3); |
|
|
|
|
|
if(ObjectUtil.isNotNull(memberLimitRow)){ |
|
|
|
|
|
int memberLimit = Integer.parseInt(ExcelUtil.getCellValue(durationRow.getCell(1))); |
|
|
|
|
|
gameRecord.setMemberLimit(memberLimit); |
|
|
|
|
|
} |
|
|
|
|
|
//排名计算方式
|
|
|
|
|
|
XSSFRow rankRuleRow = sheet.getRow(4); |
|
|
|
|
|
if(ObjectUtil.isNotNull(rankRuleRow)){ |
|
|
|
|
|
String rankRule = ExcelUtil.getCellValue(rankRuleRow.getCell(1)); |
|
|
|
|
|
if(rankRule.equalsIgnoreCase(GameConstant.GAME_RANK_AVE)) { |
|
|
|
|
|
gameRecord.setRankRule((byte) 1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//添加分组信息
|
|
|
|
|
|
if(gameRecord.getGroup() == 1){ |
|
|
|
|
|
for (int i = 8; i < sheet.getLastRowNum(); i++){ |
|
|
|
|
|
XSSFRow groupRow = sheet.getRow(1); |
|
|
|
|
|
if(ObjectUtil.isNotNull(groupRow)){ |
|
|
|
|
|
String groupName = ExcelUtil.getCellValue(groupRow.getCell(0)); |
|
|
|
|
|
String groupUrl = ExcelUtil.getCellValue(groupRow.getCell(0)); |
|
|
|
|
|
if(ObjectUtil.isNotNull(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)){ |
|
|
|
|
|
gameGroup.setHeadPortraitUrl(groupUrl); |
|
|
|
|
|
} |
|
|
|
|
|
gameGroupDao.insertSelective(gameGroup); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 查询该任务下的游戏记录信息 如果还有其他未结束的游戏则返回提示信息 |
|
|
|
|
|
* @param taskId 任务id |
|
|
|
|
|
*/ |
|
|
|
|
|
private void selectOldRecord(Long taskId) { |
|
|
|
|
|
GameRecordExample recordExample = new GameRecordExample(); |
|
|
|
|
|
recordExample.createCriteria().andTaskIdEqualTo(taskId); |
|
|
|
|
|
recordExample.setOrderByClause("created_at DESC"); |
|
|
|
|
|
List<GameRecord> recordList = gameRecordDao.selectByExample(recordExample); |
|
|
|
|
|
if (CollectionUtil.isNotEmpty(recordList)) { |
|
|
|
|
|
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); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 查找此用户购买的此游戏的信息 |
|
|
|
|
|
* @param userId userId |
|
|
|
|
|
* @param gameType 游戏类型 |
|
|
|
|
|
* @return 返回购买记录 |
|
|
|
|
|
*/ |
|
|
|
|
|
private GameUserPay getGameUserPay(Long userId, GameType gameType) { |
|
|
|
|
|
GameUserPay gameUserPay; |
|
|
|
|
|
GameUserPayExample gameUserPayExample = new GameUserPayExample(); |
|
|
|
|
|
gameUserPayExample.createCriteria().andUserIdEqualTo(userId).andGameTypeIdEqualTo(gameType.getId()); |
|
|
|
|
|
List<GameUserPay> gameUserPayList = gameUserPayDao.selectByExample(gameUserPayExample); |
|
|
|
|
|
if (CollectionUtil.isNotEmpty(gameUserPayList)) { |
|
|
|
|
|
gameUserPay = gameUserPayList.get(0); |
|
|
|
|
|
} else { |
|
|
|
|
|
gameUserPay = new GameUserPay(); |
|
|
|
|
|
gameUserPay.setId(snowflake.nextId()); |
|
|
|
|
|
gameUserPay.setUserId(userId); |
|
|
|
|
|
gameUserPay.setGameTypeId(gameType.getId()); |
|
|
|
|
|
gameUserPay.setTotalCount(10); |
|
|
|
|
|
gameUserPay.setUsedCount(0); |
|
|
|
|
|
gameUserPay.setCreatedTime(System.currentTimeMillis()); |
|
|
|
|
|
gameUserPay.setDueTime(gameUserPay.getCreatedTime() + (3600 * 24 * 30)); |
|
|
|
|
|
gameUserPayDao.insertSelective(gameUserPay); |
|
|
|
|
|
} |
|
|
|
|
|
return gameUserPay; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
// public ScreenVo.UrlVo getScreenUrl(QueryDto<ScreenDto.MemberGame> params) throws Exception {
|
|
|
|
|
|
// ScreenDto.MemberGame memberGame = params.getParam();
|
|
|
|
|
|
// //查找游戏
|
|
|
|
|
|
// GameType gameType = null;
|
|
|
|
|
|
// GameTypeExample gameTypeExample = new GameTypeExample();
|
|
|
|
|
|
// gameTypeExample.createCriteria().andCodeEqualTo(memberGame.getGameType());
|
|
|
|
|
|
// List<GameType> gameTypeList = gameTypeDao.selectByExample(gameTypeExample);
|
|
|
|
|
|
// if (CollectionUtil.isNotEmpty(gameTypeList)) {
|
|
|
|
|
|
// gameType = gameTypeList.get(0);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (ObjectUtil.isNull(gameType)) {
|
|
|
|
|
|
// throw new BaseException(CodeEnum.NOT_GAME_TYPE);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// //2、查找此用户购买的此游戏的信息,若没有则添加一条记录,默认已付款,结束时间为添加后的一个月,默认次数为10次
|
|
|
|
|
|
// GameUserPay gameUserPay = null;
|
|
|
|
|
|
// GameUserPayExample gameUserPayExample = new GameUserPayExample();
|
|
|
|
|
|
// gameUserPayExample.createCriteria().andUserIdEqualTo(params.getUserId()).andGameTypeIdEqualTo(gameType.getId());
|
|
|
|
|
|
// List<GameUserPay> gameUserPayList = gameUserPayDao.selectByExample(gameUserPayExample);
|
|
|
|
|
|
// if (CollectionUtil.isNotEmpty(gameUserPayList)) {
|
|
|
|
|
|
// gameUserPay = gameUserPayList.get(0);
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// gameUserPay = new GameUserPay();
|
|
|
|
|
|
// gameUserPay.setId(snowflake.nextId());
|
|
|
|
|
|
// gameUserPay.setUserId(params.getUserId());
|
|
|
|
|
|
// gameUserPay.setGameTypeId(gameType.getId());
|
|
|
|
|
|
// gameUserPay.setTotalCount(10);
|
|
|
|
|
|
// gameUserPay.setUsedCount(0);
|
|
|
|
|
|
// gameUserPay.setCreatedTime(System.currentTimeMillis());
|
|
|
|
|
|
// gameUserPay.setDueTime(gameUserPay.getCreatedTime() + (3600 * 24 * 30));
|
|
|
|
|
|
// gameUserPayDao.insertSelective(gameUserPay);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// //查询该任务下的游戏记录信息
|
|
|
|
|
|
// if (ObjectUtil.isNotNull(memberGame.getTaskId())) {
|
|
|
|
|
|
// GameRecordExample recordExample = new GameRecordExample();
|
|
|
|
|
|
// recordExample.createCriteria().andTaskIdEqualTo(memberGame.getTaskId());
|
|
|
|
|
|
// recordExample.setOrderByClause("created_at DESC");
|
|
|
|
|
|
// List<GameRecord> recordList = gameRecordDao.selectByExample(recordExample);
|
|
|
|
|
|
// if (CollectionUtil.isNotEmpty(recordList)) {
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// //3、根据用户购买的记录,添加一场新的游戏记录
|
|
|
|
|
|
// GameRecord gameRecord = new GameRecord();
|
|
|
|
|
|
// gameRecord.setId(snowflake.nextId());
|
|
|
|
|
|
// gameRecord.setUserPayId(gameUserPay.getId());
|
|
|
|
|
|
// gameRecord.setTaskId(memberGame.getTaskId());
|
|
|
|
|
|
// //添加路径
|
|
|
|
|
|
// String gameUrl = WebConstant.TEST_URL_GAME_SQ;
|
|
|
|
|
|
// switch (gameType.getCode()){
|
|
|
|
|
|
// case GameConstant.GAME_TYPE_SQ: break;
|
|
|
|
|
|
// case GameConstant.GAME_TYPE_SP: gameUrl = WebConstant.TEST_URL_GAME_SP; break;
|
|
|
|
|
|
// case GameConstant.GAME_TYPE_BH: gameUrl = WebConstant.TEST_URL_GAME_BH; break;
|
|
|
|
|
|
// default:break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// gameRecord.setUrl(gameUrl + gameType.getScreenUrl() + "?id=" + gameRecord.getId());
|
|
|
|
|
|
// gameRecord.setQrCodeUrl(gameUrl + gameRecord.getId() + File.separator + gameType.getClientUrl());
|
|
|
|
|
|
// gameRecordDao.insertSelective(gameRecord);
|
|
|
|
|
|
// //4、 判断是否有分组,如果是分组游戏,添加两条分组信息
|
|
|
|
|
|
// if (gameType.getIsGroup() == 1) {
|
|
|
|
|
|
// GameGroup gameGroupRed = new GameGroup();
|
|
|
|
|
|
// gameGroupRed.setId(snowflake.nextId());
|
|
|
|
|
|
// gameGroupRed.setRecordId(gameRecord.getId());
|
|
|
|
|
|
// gameGroupRed.setName(memberGame.getFirstTeam());
|
|
|
|
|
|
// gameGroupRed.setCode(GameConstant.FIRST_GROUP);
|
|
|
|
|
|
// gameGroupDao.insertSelective(gameGroupRed);
|
|
|
|
|
|
// GameGroup gameGroupBlue = new GameGroup();
|
|
|
|
|
|
// gameGroupBlue.setId(snowflake.nextId());
|
|
|
|
|
|
// gameGroupBlue.setRecordId(gameRecord.getId());
|
|
|
|
|
|
// gameGroupBlue.setName(memberGame.getSecondTeam());
|
|
|
|
|
|
// gameGroupBlue.setCode(GameConstant.SECOND_GROUP);
|
|
|
|
|
|
// gameGroupDao.insertSelective(gameGroupBlue);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// //5、查询该游戏的规则
|
|
|
|
|
|
// List<String> ruleList = getGameActivityRule(gameType.getId());
|
|
|
|
|
|
// //6、返回
|
|
|
|
|
|
// ScreenVo.UrlVo urlVo = new ScreenVo.UrlVo();
|
|
|
|
|
|
// urlVo.setId(gameRecord.getId());
|
|
|
|
|
|
// urlVo.setUrl(gameRecord.getUrl());
|
|
|
|
|
|
// urlVo.setRuleList(ruleList);
|
|
|
|
|
|
//
|
|
|
|
|
|
// //路径(添加项目id)
|
|
|
|
|
|
// String url = gameRecord.getUrl() + "&projectId=" + memberGame.getProjectId();
|
|
|
|
|
|
// //给所有人发送消息发送消息
|
|
|
|
|
|
// ChromeMessageDto chromeMessageDto = new ChromeMessageDto(url, gameRecord.getId(), memberGame.getProjectId(),gameType.getCode());
|
|
|
|
|
|
// BaseMessageDto.MessageUser messageUser = null;
|
|
|
|
|
|
// List<BaseMessageDto.MessageUser> messageUserList = new ArrayList<>();
|
|
|
|
|
|
// //获取项目下所有成员
|
|
|
|
|
|
// List<Long> memberIdList = tallFeignClient.getMemberIdListByProject(memberGame.getProjectId());
|
|
|
|
|
|
// if (CollectionUtil.isNotEmpty(memberIdList)) {
|
|
|
|
|
|
// for (Long memberId : memberIdList) {
|
|
|
|
|
|
// messageUser = new BaseMessageDto.MessageUser();
|
|
|
|
|
|
// messageUser.setUserId(memberId);
|
|
|
|
|
|
// messageUserList.add(messageUser);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// chromeMessageDto.setReceivers(messageUserList);
|
|
|
|
|
|
// messageService.sendGameMessageWithGetUrl(chromeMessageDto);
|
|
|
|
|
|
//
|
|
|
|
|
|
// return urlVo;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取游戏基本信息 |
|
|
* 获取游戏基本信息 |
|
|
* |
|
|
* @return 返回游戏基本信息 |
|
|
* @return |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public ScreenVo.GameInfoVo getGameInformation(QueryDto<ScreenDto.MemberRecord> params) { |
|
|
public ScreenVo.GameInfoVo getGameInformation(QueryDto<ScreenDto.MemberRecord> params) { |
|
@ -252,12 +462,10 @@ public class ScreenService implements IScreenService { |
|
|
} |
|
|
} |
|
|
gameInfoVo.setPreparingData(preparingData); |
|
|
gameInfoVo.setPreparingData(preparingData); |
|
|
break; |
|
|
break; |
|
|
case 2: |
|
|
|
|
|
break; |
|
|
|
|
|
case 3: |
|
|
case 3: |
|
|
//查询游戏是否有分组
|
|
|
//查询游戏是否有分组
|
|
|
GameType gameType = gameTypeDao.selectByPrimaryKey(gameUserPay.getGameTypeId()); |
|
|
GameType gameType = gameTypeDao.selectByPrimaryKey(gameUserPay.getGameTypeId()); |
|
|
ScreenVo.CompletedData completedData = null; |
|
|
ScreenVo.CompletedData completedData; |
|
|
if (gameType.getIsGroup() == 0) { |
|
|
if (gameType.getIsGroup() == 0) { |
|
|
completedData = getCompletedData(memberRecord.getMemberRecord()); |
|
|
completedData = getCompletedData(memberRecord.getMemberRecord()); |
|
|
} else { |
|
|
} else { |
|
@ -271,7 +479,6 @@ public class ScreenService implements IScreenService { |
|
|
return gameInfoVo; |
|
|
return gameInfoVo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取游戏状态 |
|
|
* 获取游戏状态 |
|
|
*/ |
|
|
*/ |
|
@ -332,7 +539,7 @@ public class ScreenService implements IScreenService { |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case GameConstant.GAME_COMPLETED: |
|
|
case GameConstant.GAME_COMPLETED: |
|
|
ScreenVo.CompletedData completedData = null; |
|
|
ScreenVo.CompletedData completedData; |
|
|
if (gameType.getIsGroup() == 0) { |
|
|
if (gameType.getIsGroup() == 0) { |
|
|
completedData = getCompletedData(memberRecord.getMemberRecord()); |
|
|
completedData = getCompletedData(memberRecord.getMemberRecord()); |
|
|
} else { |
|
|
} else { |
|
@ -440,12 +647,10 @@ public class ScreenService implements IScreenService { |
|
|
return groupMap; |
|
|
return groupMap; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询总分数,总次数,平均以及前十名 |
|
|
* 查询总分数,总次数,平均以及前十名 |
|
|
* |
|
|
* |
|
|
* @param gameRecordId |
|
|
* @param gameRecordId 游戏id |
|
|
* @return |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
private ScreenVo.CompletedData getCompletedData(long gameRecordId) { |
|
|
private ScreenVo.CompletedData getCompletedData(long gameRecordId) { |
|
|
ScreenVo.CompletedData completedData = new ScreenVo.CompletedData(); |
|
|
ScreenVo.CompletedData completedData = new ScreenVo.CompletedData(); |
|
@ -488,9 +693,9 @@ public class ScreenService implements IScreenService { |
|
|
/** |
|
|
/** |
|
|
* 查询参加游戏的用户信息 |
|
|
* 查询参加游戏的用户信息 |
|
|
* |
|
|
* |
|
|
* @param userId |
|
|
* @param userId userID |
|
|
* @param gameRecordId |
|
|
* @param gameRecordId 游戏id |
|
|
* @return |
|
|
* @return 返回参加游戏的用户 |
|
|
*/ |
|
|
*/ |
|
|
private GameUserJoin getGameUserJoin(Long userId, Long gameRecordId) { |
|
|
private GameUserJoin getGameUserJoin(Long userId, Long gameRecordId) { |
|
|
GameUserJoinExample joinExample = new GameUserJoinExample(); |
|
|
GameUserJoinExample joinExample = new GameUserJoinExample(); |
|
@ -506,13 +711,13 @@ public class ScreenService implements IScreenService { |
|
|
/** |
|
|
/** |
|
|
* 查询游戏信息 |
|
|
* 查询游戏信息 |
|
|
* |
|
|
* |
|
|
* @param gameRecordId |
|
|
* @param gameRecordId 游戏记录id |
|
|
* @return |
|
|
* @return 返回游戏信息 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public GameRecord getGameRecord(long gameRecordId) { |
|
|
public GameRecord getGameRecord(long gameRecordId) { |
|
|
String gameRecordStr = (String) redisUtil.get(GameConstant.generateGameStatusKey(gameRecordId)); |
|
|
String gameRecordStr = (String) redisUtil.get(GameConstant.generateGameStatusKey(gameRecordId)); |
|
|
GameRecord gameRecord = null; |
|
|
GameRecord gameRecord; |
|
|
if (StrUtil.isBlank(gameRecordStr)) { |
|
|
if (StrUtil.isBlank(gameRecordStr)) { |
|
|
gameRecord = gameRecordDao.selectByPrimaryKey(gameRecordId); |
|
|
gameRecord = gameRecordDao.selectByPrimaryKey(gameRecordId); |
|
|
if (ObjectUtil.isNull(gameRecord)) { |
|
|
if (ObjectUtil.isNull(gameRecord)) { |
|
@ -527,8 +732,8 @@ public class ScreenService implements IScreenService { |
|
|
/** |
|
|
/** |
|
|
* 查询前十名 |
|
|
* 查询前十名 |
|
|
* |
|
|
* |
|
|
* @param gameRecordId |
|
|
* @param gameRecordId 游戏记录id |
|
|
* @return |
|
|
* @return 返回前十名信息 |
|
|
*/ |
|
|
*/ |
|
|
private List<ScreenVo.TopUsers> getTopUsers(Long gameRecordId) { |
|
|
private List<ScreenVo.TopUsers> getTopUsers(Long gameRecordId) { |
|
|
List<ScreenVo.TopUsers> tops; |
|
|
List<ScreenVo.TopUsers> tops; |
|
@ -573,51 +778,57 @@ public class ScreenService implements IScreenService { |
|
|
throw new BaseException(CodeEnum.NOT_GAME_TYPE); |
|
|
throw new BaseException(CodeEnum.NOT_GAME_TYPE); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (gameUserPay.getUsedCount() >= gameUserPay.getTotalCount()) { |
|
|
// if (gameUserPay.getUsedCount() >= gameUserPay.getTotalCount()) {
|
|
|
throw new BaseException(CodeEnum.GAME_NOT_TIMES); |
|
|
// throw new BaseException(CodeEnum.GAME_NOT_TIMES);
|
|
|
} |
|
|
// }
|
|
|
GameRecord gameRecordNew = null; |
|
|
//之前的游戏若是准备中或进行中,则返回提示
|
|
|
if (gameRecord.getGameStatus() == 3) { |
|
|
if(gameRecord.getGameStatus() == GameConstant.GAME_PREPARATION || |
|
|
//添加一场新的游戏记录
|
|
|
gameRecord.getGameStatus() == GameConstant.GAME_PROCESSING){ |
|
|
gameRecordNew = new GameRecord(); |
|
|
|
|
|
gameRecordNew.setId(snowflake.nextId()); |
|
|
|
|
|
gameRecordNew.setUserPayId(gameUserPay.getId()); |
|
|
|
|
|
//添加路径
|
|
|
|
|
|
String gameUrl = WebConstant.TEST_URL_GAME_SQ; |
|
|
|
|
|
switch (gameType.getCode()){ |
|
|
|
|
|
case GameConstant.GAME_TYPE_SQ: break; |
|
|
|
|
|
case GameConstant.GAME_TYPE_SP: gameUrl = WebConstant.TEST_URL_GAME_SP ; break; |
|
|
|
|
|
case GameConstant.GAME_TYPE_BH: gameUrl = WebConstant.TEST_URL_GAME_BH; break; |
|
|
|
|
|
default:break; |
|
|
|
|
|
} |
|
|
|
|
|
gameRecordNew.setUrl(gameUrl + gameType.getScreenUrl() + "?id=" + gameRecordNew.getId()); |
|
|
|
|
|
gameRecordNew.setQrCodeUrl(gameUrl+ gameRecordNew.getId() + File.separator + gameType.getClientUrl()); |
|
|
|
|
|
gameRecordDao.insertSelective(gameRecordNew); |
|
|
|
|
|
//修改购买的游戏的使用次数
|
|
|
|
|
|
gameUserPay.setUsedCount(gameUserPay.getUsedCount() + 1); |
|
|
|
|
|
gameUserPayDao.updateByPrimaryKeySelective(gameUserPay); |
|
|
|
|
|
|
|
|
|
|
|
//路径(添加项目id)
|
|
|
|
|
|
String url = gameRecord.getUrl() + "&projectId=" + memberRecord.getProjectId(); |
|
|
|
|
|
//给所有人发送消息发送消息
|
|
|
|
|
|
ChromeMessageDto chromeMessageDto = new ChromeMessageDto(url, gameRecord.getId(), memberRecord.getProjectId(),gameType.getCode()); |
|
|
|
|
|
BaseMessageDto.MessageUser messageUser = null; |
|
|
|
|
|
List<BaseMessageDto.MessageUser> messageUserList = new ArrayList<>(); |
|
|
|
|
|
//获取项目下所有成员
|
|
|
|
|
|
List<Long> memberIdList = tallFeignClient.getMemberIdListByProject(memberRecord.getProjectId()); |
|
|
|
|
|
if (CollectionUtil.isNotEmpty(memberIdList)) { |
|
|
|
|
|
for (Long memberId : memberIdList) { |
|
|
|
|
|
messageUser = new BaseMessageDto.MessageUser(); |
|
|
|
|
|
messageUser.setUserId(memberId); |
|
|
|
|
|
messageUserList.add(messageUser); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
chromeMessageDto.setReceivers(messageUserList); |
|
|
|
|
|
messageService.sendGameMessageWithGetUrl(chromeMessageDto); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
throw new BaseException(CodeEnum.GAME_NO_END); |
|
|
throw new BaseException(CodeEnum.GAME_NO_END); |
|
|
} |
|
|
} |
|
|
|
|
|
//若是未开始,则将之前的游戏状态改成已结束
|
|
|
|
|
|
if(gameRecord.getGameStatus() == GameConstant.GAME_PENDING){ |
|
|
|
|
|
gameRecord.setGameStatus(GameConstant.GAME_COMPLETED); |
|
|
|
|
|
gameRecordDao.updateByPrimaryKeySelective(gameRecord); |
|
|
|
|
|
} |
|
|
|
|
|
GameRecord gameRecordNew; |
|
|
|
|
|
//添加一场新的游戏记录
|
|
|
|
|
|
gameRecordNew = new GameRecord(); |
|
|
|
|
|
gameRecordNew.setId(snowflake.nextId()); |
|
|
|
|
|
gameRecordNew.setUserPayId(gameUserPay.getId()); |
|
|
|
|
|
//添加路径
|
|
|
|
|
|
String gameUrl = WebConstant.TEST_URL_GAME_SQ; |
|
|
|
|
|
switch (gameType.getCode()){ |
|
|
|
|
|
case GameConstant.GAME_TYPE_SQ: break; |
|
|
|
|
|
case GameConstant.GAME_TYPE_SP: gameUrl = WebConstant.TEST_URL_GAME_SP ; break; |
|
|
|
|
|
case GameConstant.GAME_TYPE_BH: gameUrl = WebConstant.TEST_URL_GAME_BH; break; |
|
|
|
|
|
default:break; |
|
|
|
|
|
} |
|
|
|
|
|
gameRecordNew.setUrl(gameUrl + gameType.getScreenUrl() + "?id=" + gameRecordNew.getId()); |
|
|
|
|
|
gameRecordNew.setQrCodeUrl(gameUrl+ gameRecordNew.getId() + File.separator + gameType.getClientUrl()); |
|
|
|
|
|
gameRecordDao.insertSelective(gameRecordNew); |
|
|
|
|
|
//修改购买的游戏的使用次数
|
|
|
|
|
|
gameUserPay.setUsedCount(gameUserPay.getUsedCount() + 1); |
|
|
|
|
|
gameUserPayDao.updateByPrimaryKeySelective(gameUserPay); |
|
|
|
|
|
|
|
|
|
|
|
//路径(添加项目id)
|
|
|
|
|
|
String url = gameRecord.getUrl() + "&projectId=" + memberRecord.getProjectId(); |
|
|
|
|
|
//给所有人发送消息发送消息
|
|
|
|
|
|
ChromeMessageDto chromeMessageDto = new ChromeMessageDto(url, gameRecord.getId(), memberRecord.getProjectId(),gameType.getCode()); |
|
|
|
|
|
BaseMessageDto.MessageUser messageUser; |
|
|
|
|
|
List<BaseMessageDto.MessageUser> messageUserList = new ArrayList<>(); |
|
|
|
|
|
//获取项目下所有成员
|
|
|
|
|
|
List<Long> memberIdList = tallFeignClient.getMemberIdListByProject(memberRecord.getProjectId()); |
|
|
|
|
|
if (CollectionUtil.isNotEmpty(memberIdList)) { |
|
|
|
|
|
for (Long memberId : memberIdList) { |
|
|
|
|
|
messageUser = new BaseMessageDto.MessageUser(); |
|
|
|
|
|
messageUser.setUserId(memberId); |
|
|
|
|
|
messageUserList.add(messageUser); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
chromeMessageDto.setReceivers(messageUserList); |
|
|
|
|
|
messageService.sendGameMessageWithGetUrl(chromeMessageDto); |
|
|
|
|
|
|
|
|
return gameRecordNew.getUrl(); |
|
|
return gameRecordNew.getUrl(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -715,8 +926,8 @@ public class ScreenService implements IScreenService { |
|
|
/** |
|
|
/** |
|
|
* 开始游戏 |
|
|
* 开始游戏 |
|
|
* |
|
|
* |
|
|
* @param start |
|
|
* @param start 游戏记录,开始时间 |
|
|
* @return |
|
|
* @return 返回本地开始和结束时间 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public ScreenVo.StartGame startGame(ScreenDto.Start start) { |
|
|
public ScreenVo.StartGame startGame(ScreenDto.Start start) { |
|
@ -830,8 +1041,7 @@ public class ScreenService implements IScreenService { |
|
|
/** |
|
|
/** |
|
|
* 推送客户端状态 |
|
|
* 推送客户端状态 |
|
|
* |
|
|
* |
|
|
* @param gameRecord |
|
|
* @param gameRecord 游戏记录 |
|
|
* @param executor |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
private void pushClient(GameRecord gameRecord, ScheduledExecutorService executor) { |
|
|
private void pushClient(GameRecord gameRecord, ScheduledExecutorService executor) { |
|
|
|
|
|
|
|
@ -943,4 +1153,66 @@ public class ScreenService implements IScreenService { |
|
|
} |
|
|
} |
|
|
return recordInfo; |
|
|
return recordInfo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<String> getConfig(QueryDto<ScreenDto.GetConfig> params)throws Exception { |
|
|
|
|
|
ScreenDto.GetConfig getConfig = params.getParam(); |
|
|
|
|
|
//根据游戏类型获取文件类型
|
|
|
|
|
|
byte businessType = 8; |
|
|
|
|
|
if( GameConstant.GAME_TYPE_SQ.equalsIgnoreCase(getConfig.getGameType())){ |
|
|
|
|
|
businessType = 9; |
|
|
|
|
|
}else if( GameConstant.GAME_TYPE_BH.equalsIgnoreCase(getConfig.getGameType())){ |
|
|
|
|
|
businessType = 10; |
|
|
|
|
|
} |
|
|
|
|
|
//查询该任务是否已有创建的游戏配置
|
|
|
|
|
|
List<String> wpsPath; |
|
|
|
|
|
WpsDto.VisitWpsUrl visitWpsUrl = new WpsDto.VisitWpsUrl(); |
|
|
|
|
|
visitWpsUrl.setBusinessId(getConfig.getTaskId()); |
|
|
|
|
|
visitWpsUrl.setBusinessType(businessType); |
|
|
|
|
|
visitWpsUrl.setUserId(params.getUserId()); |
|
|
|
|
|
wpsPath = tallFeignClient.queryVisitUrls(visitWpsUrl); |
|
|
|
|
|
//有配置直接返回
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(wpsPath)) { |
|
|
|
|
|
return wpsPath; |
|
|
|
|
|
} |
|
|
|
|
|
//没有则生成默认模板并返回,
|
|
|
|
|
|
//查找游戏
|
|
|
|
|
|
GameTypeExample gameTypeExample = new GameTypeExample(); |
|
|
|
|
|
gameTypeExample.createCriteria().andCodeEqualTo(getConfig.getGameType()); |
|
|
|
|
|
List<GameType> gameTypeList = gameTypeDao.selectByExample(gameTypeExample); |
|
|
|
|
|
if (CollectionUtil.isEmpty(gameTypeList)) { |
|
|
|
|
|
throw new BaseException(CodeEnum.NOT_GAME_TYPE); |
|
|
|
|
|
} |
|
|
|
|
|
GameType gameType = gameTypeList.get(0); |
|
|
|
|
|
|
|
|
|
|
|
//生成excel写入的数据
|
|
|
|
|
|
String templatePath = WebConstant.HOME_STATICREC + "GameConfig.xlsx"; |
|
|
|
|
|
InputStream is = new FileInputStream(new File(templatePath)); |
|
|
|
|
|
Workbook wb = new XSSFWorkbook(is); |
|
|
|
|
|
//生成文件
|
|
|
|
|
|
String name = gameType.getName() + "游戏配置表.xlsx"; |
|
|
|
|
|
String fileName = "game/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx"; |
|
|
|
|
|
String path = WebConstant.UPLOAD_PATH_BASE + File.separator + fileName; |
|
|
|
|
|
File tmpFile = new File(path); |
|
|
|
|
|
if (!tmpFile.getParentFile().exists()) { |
|
|
|
|
|
tmpFile.getParentFile().mkdirs(); |
|
|
|
|
|
} |
|
|
|
|
|
OutputStream stream = new FileOutputStream(tmpFile); |
|
|
|
|
|
wb.write(stream); |
|
|
|
|
|
stream.close(); |
|
|
|
|
|
//关联wps
|
|
|
|
|
|
WpsDto.Business business = new WpsDto.Business(); |
|
|
|
|
|
business.setBusinessId(getConfig.getTaskId()); |
|
|
|
|
|
business.setBusinessType(businessType); |
|
|
|
|
|
business.setUserId(params.getUserId()); |
|
|
|
|
|
business.setFileName(name); |
|
|
|
|
|
business.setFilePath(fileName); |
|
|
|
|
|
business.setFileSize(tmpFile.length()); |
|
|
|
|
|
business.setOperation(WebConstant.Wps.USER_OPERATION_NEW); |
|
|
|
|
|
business.setPrivilege(WebConstant.Wps.PROJECT_PRIVILEGE_WRITE); |
|
|
|
|
|
tallFeignClient.saveWpsFile(business); |
|
|
|
|
|
|
|
|
|
|
|
return tallFeignClient.queryVisitUrls(visitWpsUrl); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|