|
|
@@ -3,8 +3,11 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.yingyangfly.common.dto.ResultResponse;
|
|
|
@@ -101,6 +104,7 @@ public class GameUserServiceImpl extends ServiceImpl<GameUserMapper, GameUser> i
|
|
|
}
|
|
|
queryWrapper.eq("play_class","C");
|
|
|
queryWrapper.ne("status","99");
|
|
|
+ queryWrapper.eq("is_show", "0");
|
|
|
queryWrapper.orderByDesc("order_num");
|
|
|
Page<GameUser> gameUserPage = gameUserMapper.selectPage(rowPage, queryWrapper);
|
|
|
List<GameUser> gameUsers = gameUserPage.getRecords();
|
|
|
@@ -323,4 +327,68 @@ public class GameUserServiceImpl extends ServiceImpl<GameUserMapper, GameUser> i
|
|
|
int updateCount = gameUserMapper.update(gameUser, queryWrapper);
|
|
|
log.info("<<<<<<<<<<<<<<定时任务更用户状态为历史,条数为:{}>>>>>>>>>>>>>",updateCount);
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void isShowGameUser() {
|
|
|
+ // 获取所以自由训练游戏
|
|
|
+ LambdaQueryWrapper<GameUser> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.ne(GameUser::getStatus,"99");
|
|
|
+ wrapper.eq(GameUser::getPlayClass, "C");
|
|
|
+ List<GameUser> gameUsers = gameUserMapper.selectList(wrapper);
|
|
|
+ // 根据 用户id 分组
|
|
|
+ Map<Long, List<GameUser>> gameUserMap = gameUsers.stream().collect(Collectors.groupingBy(GameUser::getUserId));
|
|
|
+ // 显示集合
|
|
|
+ List<Long> gameUserIsShowList = new ArrayList<>();
|
|
|
+ // 不显示集合
|
|
|
+ List<Long> gameUserNoneList = new ArrayList<>();
|
|
|
+ for (Map.Entry<Long, List<GameUser>> entry : gameUserMap.entrySet()) {
|
|
|
+ try {
|
|
|
+ List<GameUser> gameUserList = entry.getValue();
|
|
|
+ // 根据 认知域 分组
|
|
|
+ Map<String, List<GameUser>> gameUserGameTypeMap = gameUserList.stream().collect(Collectors.groupingBy(GameUser::getGameType));
|
|
|
+ for (Map.Entry<String, List<GameUser>> entryGameType : gameUserGameTypeMap.entrySet()) {
|
|
|
+ Map<String, List<Long>> collect = entryGameType.getValue().stream().collect(Collectors.groupingBy(GameUser::getIsShow,Collectors.mapping(GameUser::getId,Collectors.toList())));
|
|
|
+ // 显示
|
|
|
+ List<Long> gameUserIsShows = collect.get("0");
|
|
|
+ if (CollectionUtils.isEmpty(gameUserIsShows)) {
|
|
|
+ // 不显示
|
|
|
+ List<Long> gameUserNones = collect.get("1");
|
|
|
+ Collections.shuffle(gameUserNones);
|
|
|
+ // 将不显示中的 4个放入 显示列表中
|
|
|
+ gameUserIsShowList.addAll(gameUserNones.stream().limit(8).collect(Collectors.toList()));
|
|
|
+ }else {
|
|
|
+ // 不显示
|
|
|
+ List<Long> gameUserNones = collect.get("1");
|
|
|
+ Collections.shuffle(gameUserNones);
|
|
|
+ // 将不显示中的 4个放入 显示列表中
|
|
|
+ gameUserIsShowList.addAll(gameUserNones.stream().limit(4).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ if (gameUserNones.size()>=4) {
|
|
|
+ Collections.shuffle(gameUserIsShows);
|
|
|
+ // 将显示中 4个放入 不显示列表中
|
|
|
+ gameUserNoneList.addAll(gameUserIsShows.stream().limit(4).collect(Collectors.toList()));
|
|
|
+ } else {
|
|
|
+ Collections.shuffle(gameUserIsShows);
|
|
|
+ // 将显示中 4个放入 不显示列表中
|
|
|
+ gameUserNoneList.addAll(gameUserIsShows.stream().limit(gameUserNones.size()).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e){
|
|
|
+ log.error("更改自由训练游戏列表失败,用户id:{},错误信息:{}",entry.getKey(),e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(gameUserIsShowList)) {
|
|
|
+ UpdateWrapper<GameUser> updateIsShowWrapper = new UpdateWrapper<>();
|
|
|
+ updateIsShowWrapper.set("is_show",0).in("id",gameUserIsShowList);
|
|
|
+ gameUserMapper.update(null,updateIsShowWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(gameUserNoneList)) {
|
|
|
+ UpdateWrapper<GameUser> updateNoneWrapper = new UpdateWrapper<>();
|
|
|
+ updateNoneWrapper.set("is_show",1).in("id",gameUserNoneList);
|
|
|
+ gameUserMapper.update(null,updateNoneWrapper);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|