Browse Source

优化用户界面体验-首页重构(增加统计方法)

wenkai 2 weeks ago
parent
commit
5c1b682563
23 changed files with 348 additions and 49 deletions
  1. 2 2
      ruoyi-admin/src/main/resources/application-dev.yml
  2. 22 12
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/ArticleController.java
  3. 9 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/GameEventController.java
  4. 10 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/GameEventProjectController.java
  5. 11 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/GameRefereeController.java
  6. 10 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/GameTeamController.java
  7. 9 2
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/bo/GameEventProjectBo.java
  8. 8 3
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/bo/GameTeamBo.java
  9. 6 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/vo/GameEventProjectVo.java
  10. 6 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/vo/GameTeamVo.java
  11. 6 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IArticleService.java
  12. 2 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameEventProjectService.java
  13. 6 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameEventService.java
  14. 6 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameRefereeService.java
  15. 6 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameTeamService.java
  16. 11 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/ArticleServiceImpl.java
  17. 19 16
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameAthleteServiceImpl.java
  18. 14 11
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameEventGroupServiceImpl.java
  19. 46 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameEventProjectServiceImpl.java
  20. 12 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameEventServiceImpl.java
  21. 12 0
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameRefereeServiceImpl.java
  22. 88 3
      ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameTeamServiceImpl.java
  23. 27 0
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/monitor/SysUserOnlineController.java

+ 2 - 2
ruoyi-admin/src/main/resources/application-dev.yml

@@ -98,11 +98,11 @@ spring:
 spring.data:
   redis:
     # 地址
-    host: localhost
+    host: 192.168.1.146
     # 端口,默认为6379
     port: 6379
     # 数据库索引
-    database: 0
+    database: 1
     # redis 密码必须配置
 #    password: ruoyi123
     # 连接超时时间

+ 22 - 12
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/ArticleController.java

@@ -23,7 +23,7 @@ import org.dromara.system.service.IArticleService;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 
 /**
- * 文章(可用于活动预热)
+ * 文章
  *
  * @author Lion Li
  * @date 2025-08-08
@@ -37,7 +37,7 @@ public class ArticleController extends BaseController {
     private final IArticleService articleService;
 
     /**
-     * 查询文章(可用于活动预热)列表
+     * 查询文章列表
      */
     @SaCheckPermission("system:article:list")
     @GetMapping("/list")
@@ -46,18 +46,18 @@ public class ArticleController extends BaseController {
     }
 
     /**
-     * 导出文章(可用于活动预热)列表
+     * 导出文章列表
      */
     @SaCheckPermission("system:article:export")
-    @Log(title = "文章(可用于活动预热)", businessType = BusinessType.EXPORT)
+    @Log(title = "文章", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(ArticleBo bo, HttpServletResponse response) {
         List<ArticleVo> list = articleService.queryList(bo);
-        ExcelUtil.exportExcel(list, "文章(可用于活动预热)", ArticleVo.class, response);
+        ExcelUtil.exportExcel(list, "文章", ArticleVo.class, response);
     }
 
     /**
-     * 获取文章(可用于活动预热)详细信息
+     * 获取文章详细信息
      *
      * @param id 主键
      */
@@ -69,10 +69,10 @@ public class ArticleController extends BaseController {
     }
 
     /**
-     * 新增文章(可用于活动预热)
+     * 新增文章
      */
     @SaCheckPermission("system:article:add")
-    @Log(title = "文章(可用于活动预热)", businessType = BusinessType.INSERT)
+    @Log(title = "文章", businessType = BusinessType.INSERT)
     @RepeatSubmit()
     @PostMapping()
     public R<Void> add(@Validated(AddGroup.class) @RequestBody ArticleBo bo) {
@@ -80,10 +80,10 @@ public class ArticleController extends BaseController {
     }
 
     /**
-     * 修改文章(可用于活动预热)
+     * 修改文章
      */
     @SaCheckPermission("system:article:edit")
-    @Log(title = "文章(可用于活动预热)", businessType = BusinessType.UPDATE)
+    @Log(title = "文章", businessType = BusinessType.UPDATE)
     @RepeatSubmit()
     @PutMapping()
     public R<Void> edit(@Validated(EditGroup.class) @RequestBody ArticleBo bo) {
@@ -91,15 +91,25 @@ public class ArticleController extends BaseController {
     }
 
     /**
-     * 删除文章(可用于活动预热)
+     * 删除文章
      *
      * @param ids 主键串
      */
     @SaCheckPermission("system:article:remove")
-    @Log(title = "文章(可用于活动预热)", businessType = BusinessType.DELETE)
+    @Log(title = "文章", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     public R<Void> remove(@NotEmpty(message = "主键不能为空")
                           @PathVariable Long[] ids) {
         return toAjax(articleService.deleteWithValidByIds(List.of(ids), true));
     }
+
+
+    /**
+     * 查询文章数量
+     * @return
+     */
+    @GetMapping("/count")
+    public R<Long> count() {
+        return R.ok(articleService.countArticle());
+    }
 }

+ 9 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/GameEventController.java

@@ -111,4 +111,13 @@ public class GameEventController extends BaseController {
     public R<Map<String, Long>> getEventIdNameMap() {
         return R.ok(gameEventService.getEventIdNameMap());
     }
+
+    /**
+     * 查询赛事数量
+     * @return
+     */
+    @GetMapping("/count")
+    public R<Long> count() {
+        return R.ok(gameEventService.countGameEvent());
+    }
 }

+ 10 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/GameEventProjectController.java

@@ -102,4 +102,14 @@ public class GameEventProjectController extends BaseController {
                           @PathVariable Long[] projectIds) {
         return toAjax(gameEventProjectService.deleteWithValidByIds(List.of(projectIds), true));
     }
+
+
+    /**
+     * 查询赛事项目数量
+     * @return
+     */
+    @GetMapping("/count")
+    public R<Long> count() {
+        return R.ok(gameEventProjectService.countEventProject());
+    }
 }

+ 11 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/GameRefereeController.java

@@ -102,4 +102,15 @@ public class GameRefereeController extends BaseController {
                           @PathVariable Long[] refereeIds) {
         return toAjax(gameRefereeService.deleteWithValidByIds(List.of(refereeIds), true));
     }
+
+
+    /**
+     * 查询裁判数量
+     * @return
+     */
+    @GetMapping("/count")
+    public R<Long> count() {
+        return R.ok(gameRefereeService.countReferee());
+    }
+
 }

+ 10 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/controller/GameTeamController.java

@@ -137,4 +137,14 @@ public class GameTeamController extends BaseController {
                           @PathVariable Long[] teamIds) {
         return toAjax(gameTeamService.deleteWithValidByIds(List.of(teamIds), true));
     }
+
+
+    /**
+     * 查询参赛队伍数量
+     * @return
+     */
+    @GetMapping("/count")
+    public R<Long> count() {
+        return R.ok(gameTeamService.countTeam());
+    }
 }

+ 9 - 2
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/bo/GameEventProjectBo.java

@@ -9,7 +9,9 @@ import io.github.linpeilie.annotations.AutoMapper;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import jakarta.validation.constraints.*;
+
 import java.util.Date;
+
 import com.fasterxml.jackson.annotation.JsonFormat;
 
 /**
@@ -31,9 +33,14 @@ public class GameEventProjectBo extends BaseEntity {
     /**
      * 赛事ID
      */
-    @NotNull(message = "赛事ID不能为空", groups = { AddGroup.class, EditGroup.class })
+    @NotNull(message = "赛事ID不能为空", groups = {AddGroup.class, EditGroup.class})
     private Long eventId;
 
+    /**
+     * 赛事名称
+     */
+    private String eventName;
+
     /**
      * 项目名称
      */
@@ -61,7 +68,7 @@ public class GameEventProjectBo extends BaseEntity {
     /**
      * 比赛场地
      */
-    @NotBlank(message = "比赛场地不能为空", groups = { AddGroup.class, EditGroup.class })
+    @NotBlank(message = "比赛场地不能为空", groups = {AddGroup.class, EditGroup.class})
     private String location;
 
     /**

+ 8 - 3
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/bo/GameTeamBo.java

@@ -22,19 +22,24 @@ public class GameTeamBo extends BaseEntity {
     /**
      * 主键
      */
-    @NotNull(message = "主键不能为空", groups = { EditGroup.class })
+    @NotNull(message = "主键不能为空", groups = {EditGroup.class})
     private Long teamId;
 
     /**
      * 赛事ID
      */
-    @NotNull(message = "赛事ID不能为空", groups = { AddGroup.class, EditGroup.class })
+    @NotNull(message = "赛事ID不能为空", groups = {AddGroup.class, EditGroup.class})
     private Long eventId;
 
+    /**
+     * 赛事名称
+     */
+    private String eventName;
+
     /**
      * 队伍名称
      */
-    @NotBlank(message = "队伍名称不能为空", groups = { AddGroup.class, EditGroup.class })
+    @NotBlank(message = "队伍名称不能为空", groups = {AddGroup.class, EditGroup.class})
     private String teamName;
 
     /**

+ 6 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/vo/GameEventProjectVo.java

@@ -39,6 +39,12 @@ public class GameEventProjectVo implements Serializable {
     @ExcelProperty(value = "赛事ID")
     private Long eventId;
 
+    /**
+     * 赛事ID
+     */
+    @ExcelProperty(value = "赛事名称")
+    private String eventName;
+
     /**
      * 项目名称
      */

+ 6 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/domain/vo/GameTeamVo.java

@@ -37,6 +37,12 @@ public class GameTeamVo implements Serializable {
     @ExcelProperty(value = "赛事ID")
     private Long eventId;
 
+    /**
+     * 赛事ID
+     */
+    @ExcelProperty(value = "赛事名称")
+    private String eventName;
+
     /**
      * 队伍名称
      */

+ 6 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IArticleService.java

@@ -65,4 +65,10 @@ public interface IArticleService {
      * @return 是否删除成功
      */
     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
+    /**
+     * 查询文章数量
+     * @return
+     */
+    Long countArticle();
 }

+ 2 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameEventProjectService.java

@@ -67,4 +67,6 @@ public interface IGameEventProjectService {
     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
 
     List<GameEventProjectVo> listProjectsByEventIdAndProjectIndex(Long eventId, String[] projectIds);
+
+    Long countEventProject();
 }

+ 6 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameEventService.java

@@ -74,4 +74,10 @@ public interface IGameEventService {
      * @return 赛事ID与名称的映射关系
      */
     Map<String, Long> getEventIdNameMap();
+
+    /**
+     * 统计赛事个数
+     * @return
+     */
+    Long countGameEvent();
 }

+ 6 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameRefereeService.java

@@ -65,4 +65,10 @@ public interface IGameRefereeService {
      * @return 是否删除成功
      */
     Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
+    /**
+     * 获取裁判数量
+     * @return
+     */
+    Long countReferee();
 }

+ 6 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/IGameTeamService.java

@@ -74,4 +74,10 @@ public interface IGameTeamService {
      */
 
     Boolean saveBatch(List<GameTeam> list);
+
+    /**
+     * 获取参赛队伍数量
+     * @return
+     */
+    Long countTeam();
 }

+ 11 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/ArticleServiceImpl.java

@@ -171,4 +171,15 @@ public class ArticleServiceImpl implements IArticleService {
         return baseMapper.deleteByIds(ids) > 0;
     }
 
+    /**
+     * 查询文章数量
+     *
+     * @return
+     */
+    @Override
+    public Long countArticle() {
+        return this.baseMapper.selectCount(
+            Wrappers.lambdaQuery(Article.class)
+        );
+    }
 }

+ 19 - 16
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameAthleteServiceImpl.java

@@ -153,22 +153,25 @@ public class GameAthleteServiceImpl implements IGameAthleteService {
         Page<GameAthleteVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
         result.getRecords().stream()
             .map(vo -> {
-                if(StringUtils.isNotBlank(vo.getProjectValue())) {
-                    String[] projectIds = vo.getProjectValue().split(",");
-                    List<GameEventProjectVo> projects =
-                        gameEventProjectService.listProjectsByEventIdAndProjectIndex(
-                            vo.getEventId(),
-                            projectIds);
-                    String projectNames = projects.stream()
-                        .map(GameEventProjectVo::getProjectName)
-                        .filter(StringUtils::isNotBlank)  // 过滤项目名为空的情况
-                        .collect(Collectors.joining(","));
-                    vo.setProjectValue(projectNames);
-                }
-                if(ObjectUtil.isNotEmpty(vo.getEventId())){
-                    GameEventVo gameEventVo = gameEventService.queryById(vo.getEventId());
-                    vo.setEventName(gameEventVo.getEventName());
-                }
+                Optional.ofNullable(vo.getProjectValue())
+                    .filter(StringUtils::isNotBlank)
+                    .ifPresent(projectValue -> {
+                        String[] projectIds = projectValue.split(",");
+                        List<GameEventProjectVo> projects =
+                            gameEventProjectService.listProjectsByEventIdAndProjectIndex(
+                                vo.getEventId(),
+                                projectIds);
+                        vo.setProjectValue(projects.stream()
+                            .map(GameEventProjectVo::getProjectName)
+                            .filter(StringUtils::isNotBlank)  // 过滤项目名为空的情况
+                            .collect(Collectors.joining(",")));
+                    });
+                Optional.ofNullable(vo.getEventId())
+                    .filter(ObjectUtil::isNotEmpty)
+                    .ifPresent(projectValue -> {
+                        GameEventVo gameEventVo = gameEventService.queryById(vo.getEventId());
+                        vo.setEventName(gameEventVo.getEventName());
+                    });
                 return vo;
             })
             .collect(Collectors.toList());  // 收集结果

+ 14 - 11
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameEventGroupServiceImpl.java

@@ -21,6 +21,7 @@ import org.dromara.system.service.IGameEventGroupService;
 import java.util.List;
 import java.util.Map;
 import java.util.Collection;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 /**
@@ -61,18 +62,20 @@ public class GameEventGroupServiceImpl implements IGameEventGroupService {
         LambdaQueryWrapper<GameEventGroup> lqw = buildQueryWrapper(bo);
         Page<GameEventGroupVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
         result.getRecords().stream()
-            .filter(vo -> StringUtils.isNotBlank(vo.getProjectList()))  // 过滤null和空字符串
             .map(vo -> {
-                String[] projectIds = vo.getProjectList().split(",");
-                List<GameEventProjectVo> projects =
-                    gameEventProjectService.listProjectsByEventIdAndProjectIndex(
-                        vo.getEventId(),
-                        projectIds);
-                String projectNames = projects.stream()
-                    .map(GameEventProjectVo::getProjectName)
-                    .filter(StringUtils::isNotBlank)  // 过滤项目名为空的情况
-                    .collect(Collectors.joining(","));
-                vo.setProjectList(projectNames);
+                Optional.ofNullable(vo.getProjectList())
+                    .filter(StringUtils::isNotBlank)
+                    .ifPresent(projectValue -> {
+                        String[] projectIds = projectValue.split(",");
+                        List<GameEventProjectVo> projects =
+                            gameEventProjectService.listProjectsByEventIdAndProjectIndex(
+                                vo.getEventId(),
+                                projectIds);
+                        vo.setProjectList(projects.stream()
+                            .map(GameEventProjectVo::getProjectName)
+                            .filter(StringUtils::isNotBlank)
+                            .collect(Collectors.joining(",")));
+                    });
                 return vo;
             })
             .collect(Collectors.toList());  // 收集结果

+ 46 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameEventProjectServiceImpl.java

@@ -1,5 +1,7 @@
 package org.dromara.system.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -9,6 +11,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.dromara.system.domain.GameAthlete;
+import org.dromara.system.domain.GameEvent;
+import org.dromara.system.domain.bo.GameEventBo;
+import org.dromara.system.domain.vo.GameEventVo;
+import org.dromara.system.mapper.GameEventMapper;
+import org.dromara.system.service.IGameEventService;
 import org.springframework.stereotype.Service;
 import org.dromara.system.domain.bo.GameEventProjectBo;
 import org.dromara.system.domain.vo.GameEventProjectVo;
@@ -19,6 +27,8 @@ import org.dromara.system.service.IGameEventProjectService;
 import java.util.List;
 import java.util.Map;
 import java.util.Collection;
+import java.util.Optional;
+import java.util.stream.Collectors;
 
 /**
  * 赛事项目Service业务层处理
@@ -32,6 +42,7 @@ import java.util.Collection;
 public class GameEventProjectServiceImpl implements IGameEventProjectService {
 
     private final GameEventProjectMapper baseMapper;
+    private final GameEventMapper gameEventMapper;
 
     /**
      * 查询赛事项目
@@ -55,6 +66,17 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
     public TableDataInfo<GameEventProjectVo> queryPageList(GameEventProjectBo bo, PageQuery pageQuery) {
         LambdaQueryWrapper<GameEventProject> lqw = buildQueryWrapper(bo);
         Page<GameEventProjectVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
+        result.getRecords().stream()
+            .map(vo -> {
+                Optional.ofNullable(vo.getEventId())
+                    .filter(ObjectUtil::isNotEmpty)
+                    .ifPresent(projectValue -> {
+                        GameEvent gameEvent = gameEventMapper.selectById(vo.getEventId());
+                        vo.setEventName(gameEvent.getEventName());
+                    });
+                return vo;
+            })
+            .collect(Collectors.toList());  // 收集结果
         return TableDataInfo.build(result);
     }
 
@@ -75,6 +97,23 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
         LambdaQueryWrapper<GameEventProject> lqw = Wrappers.lambdaQuery();
         lqw.orderByAsc(GameEventProject::getProjectId);
         lqw.eq(bo.getEventId() != null, GameEventProject::getEventId, bo.getEventId());
+        // 通过名称模糊查询
+        Optional.ofNullable(bo.getEventName())
+            .ifPresent(eventName->{
+                List<GameEvent> gameEvents = gameEventMapper.selectList(
+                    Wrappers.lambdaQuery(GameEvent.class)
+                        .like(GameEvent::getEventName, bo.getEventName())
+                        .select(GameEvent::getEventId)
+                );
+                if(CollectionUtils.isNotEmpty(gameEvents)){
+                    List<Long> ids = gameEvents.stream()
+                        .map(GameEvent::getEventId)
+                        .collect(Collectors.toList());
+                    lqw.in(GameEventProject::getEventId, ids);
+                }else{
+                    lqw.apply("1=0");
+                }
+            });
         lqw.like(StringUtils.isNotBlank(bo.getProjectName()), GameEventProject::getProjectName, bo.getProjectName());
         lqw.eq(StringUtils.isNotBlank(bo.getProjectType()), GameEventProject::getProjectType, bo.getProjectType());
         lqw.eq(StringUtils.isNotBlank(bo.getGroupType()), GameEventProject::getGroupType, bo.getGroupType());
@@ -144,4 +183,11 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
                 .in(GameEventProject::getProjectId, projectIds)
         );
     }
+
+    @Override
+    public Long countEventProject() {
+        return this.baseMapper.selectCount(
+            Wrappers.lambdaQuery(GameEventProject.class)
+        );
+    }
 }

+ 12 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameEventServiceImpl.java

@@ -153,4 +153,16 @@ public class GameEventServiceImpl implements IGameEventService {
             .collect(Collectors.toMap(GameEvent::getEventName, GameEvent::getEventId));
         return idNameMap;
     }
+
+    /**
+     * 统计赛事个数
+     *
+     * @return
+     */
+    @Override
+    public Long countGameEvent() {
+        return this.baseMapper.selectCount(
+            Wrappers.lambdaQuery(GameEvent.class)
+        );
+    }
 }

+ 12 - 0
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameRefereeServiceImpl.java

@@ -131,4 +131,16 @@ public class GameRefereeServiceImpl implements IGameRefereeService {
         }
         return baseMapper.deleteByIds(ids) > 0;
     }
+
+    /**
+     * 获取裁判数量
+     *
+     * @return
+     */
+    @Override
+    public Long countReferee() {
+        return this.baseMapper.selectCount(
+            Wrappers.lambdaQuery(GameReferee.class)
+        );
+    }
 }

+ 88 - 3
ruoyi-modules/ruoyi-game-event/src/main/java/org/dromara/system/service/impl/GameTeamServiceImpl.java

@@ -1,5 +1,7 @@
 package org.dromara.system.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -9,6 +11,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.dromara.system.domain.GameAthlete;
+import org.dromara.system.domain.GameEvent;
+import org.dromara.system.domain.vo.GameEventProjectVo;
+import org.dromara.system.mapper.GameAthleteMapper;
+import org.dromara.system.mapper.GameEventMapper;
 import org.springframework.stereotype.Service;
 import org.dromara.system.domain.bo.GameTeamBo;
 import org.dromara.system.domain.vo.GameTeamVo;
@@ -16,9 +23,9 @@ import org.dromara.system.domain.GameTeam;
 import org.dromara.system.mapper.GameTeamMapper;
 import org.dromara.system.service.IGameTeamService;
 
-import java.util.List;
-import java.util.Map;
-import java.util.Collection;
+import javax.swing.text.html.Option;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 参赛队伍Service业务层处理
@@ -33,6 +40,10 @@ public class GameTeamServiceImpl implements IGameTeamService {
 
     private final GameTeamMapper baseMapper;
 
+    private final GameAthleteMapper gameAthleteMapper;
+
+    private final GameEventMapper gameEventMapper;
+
     /**
      * 查询参赛队伍
      *
@@ -55,6 +66,51 @@ public class GameTeamServiceImpl implements IGameTeamService {
     public TableDataInfo<GameTeamVo> queryPageList(GameTeamBo bo, PageQuery pageQuery) {
         LambdaQueryWrapper<GameTeam> lqw = buildQueryWrapper(bo);
         Page<GameTeamVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
+        // 查询领队和队员列表
+        result.getRecords().stream()
+            .map(vo -> {
+                // 处理运动员列表
+                Optional.ofNullable(vo.getAthleteValue())
+                    .filter(StringUtils::isNotBlank)
+                    .ifPresent(athleteValue -> {
+                        String[] projectIds = athleteValue.split(",");
+                        List<GameAthlete> athletes = gameAthleteMapper.selectList(
+                            Wrappers.<GameAthlete>lambdaQuery()
+                                .in(GameAthlete::getAthleteId, projectIds)
+                                .select(GameAthlete::getName));
+
+                        vo.setAthleteValue(athletes.stream()
+                            .map(GameAthlete::getName)
+                            .filter(StringUtils::isNotBlank)
+                            .collect(Collectors.joining(",")));
+                    });
+                // 处理领队
+                Optional.ofNullable(vo.getLeader())
+                    .filter(StringUtils::isNotBlank)
+                    .ifPresent(leaderId -> {
+                        GameAthlete athlete = gameAthleteMapper.selectOne(
+                            Wrappers.<GameAthlete>lambdaQuery()
+                                .eq(GameAthlete::getAthleteId, leaderId)
+                                .select(GameAthlete::getName));
+                        Optional.ofNullable(athlete)
+                            .map(GameAthlete::getName)
+                            .ifPresent(vo::setLeader);
+                    });
+                //处理赛事名称
+                Optional.ofNullable(vo.getEventId())
+                    .filter(ObjectUtil::isNotEmpty)
+                    .ifPresent(eventId -> {
+                        GameEvent gameEvent = gameEventMapper.selectOne(
+                            Wrappers.<GameEvent>lambdaQuery()
+                                .eq(GameEvent::getEventId, eventId)
+                                .select(GameEvent::getEventName));
+                        Optional.ofNullable(gameEvent)
+                            .map(GameEvent::getEventName)
+                            .ifPresent(vo::setEventName);
+                    });
+                return vo;
+            })
+            .collect(Collectors.toList());  // 收集结果
         return TableDataInfo.build(result);
     }
 
@@ -75,6 +131,25 @@ public class GameTeamServiceImpl implements IGameTeamService {
         LambdaQueryWrapper<GameTeam> lqw = Wrappers.lambdaQuery();
         lqw.orderByAsc(GameTeam::getTeamId);
         lqw.eq(bo.getEventId() != null, GameTeam::getEventId, bo.getEventId());
+
+        Optional.ofNullable(bo.getEventName())
+            .filter(StringUtils::isNotBlank)
+            .ifPresent(eventName -> {
+                List<GameEvent> gameEvents = gameEventMapper.selectList(
+                    Wrappers.<GameEvent>lambdaQuery()
+                        .like(GameEvent::getEventName, eventName)
+                        .select(GameEvent::getEventId)
+                );
+                if (CollectionUtils.isNotEmpty(gameEvents)) {
+                    Set<Long> set = gameEvents.stream()
+                        .map(GameEvent::getEventId)
+                        .collect(Collectors.toSet());
+                    lqw.in(GameTeam::getEventId, set);
+                } else {
+                    lqw.apply("1=0");
+                }
+            });
+
         lqw.like(StringUtils.isNotBlank(bo.getTeamName()), GameTeam::getTeamName, bo.getTeamName());
         lqw.eq(StringUtils.isNotBlank(bo.getTeamCode()), GameTeam::getTeamCode, bo.getTeamCode());
         lqw.eq(StringUtils.isNotBlank(bo.getLeader()), GameTeam::getLeader, bo.getLeader());
@@ -148,4 +223,14 @@ public class GameTeamServiceImpl implements IGameTeamService {
     public Boolean saveBatch(List<GameTeam> list) {
         return baseMapper.insertBatch(list);
     }
+
+    /**
+     * 获取参赛队伍数量
+     *
+     * @return
+     */
+    @Override
+    public Long countTeam() {
+        return this.baseMapper.selectCount(Wrappers.lambdaQuery(GameTeam.class));
+    }
 }

+ 27 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/monitor/SysUserOnlineController.java

@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.stream.Collectors;
 
 /**
@@ -128,4 +129,30 @@ public class SysUserOnlineController extends BaseController {
         return R.ok();
     }
 
+    /**
+     * 获取在线用户数量
+     *
+     * @return 在线用户数量
+     */
+    @GetMapping("/count")
+    public R<Long> getOnlineUserCount() {
+        // 获取所有未过期的 token
+        Collection<String> keys = RedisUtils.keys(CacheConstants.ONLINE_TOKEN_KEY + "*");
+        AtomicLong count = new AtomicLong(0);
+
+        for (String key : keys) {
+            String token = StringUtils.substringAfterLast(key, ":");
+            // 如果已经过期则跳过
+            if (StpUtil.stpLogic.getTokenActiveTimeoutByToken(token) < -1) {
+                continue;
+            }
+            UserOnlineDTO userOnlineDTO = RedisUtils.getCacheObject(CacheConstants.ONLINE_TOKEN_KEY + token);
+            if (userOnlineDTO != null) {
+                count.addAndGet(1);
+            }
+        }
+        // 返回在线用户数量
+        return R.ok(count.getAcquire());
+    }
+
 }