overview统计

This commit is contained in:
2025-11-14 18:31:39 +08:00
parent 6be3cc6abd
commit 9adc0c2058
24 changed files with 723 additions and 178 deletions

View File

@@ -550,14 +550,14 @@ public class SCCourseServiceImpl implements SCCourseService {
@Override
public ResultDomain<CourseItemVO> getCourseProgress(String courseID) {
ResultDomain<CourseItemVO> resultDomain = new ResultDomain<>();
// 获取当前用户
TbSysUser user = LoginUtil.getCurrentUser();
if (user == null) {
resultDomain.fail("用户未登录");
return resultDomain;
}
// 查询课程
TbCourse course = courseMapper.selectByCourseId(courseID);
if (course == null) {
@@ -572,25 +572,25 @@ public class SCCourseServiceImpl implements SCCourseService {
TbCourseChapter filter = new TbCourseChapter();
filter.setCourseID(courseID);
List<TbCourseChapter> chapters = courseChapterMapper.selectCourseChapters(filter);
// 查询并构建章节及节点结构(带进度)
if (!chapters.isEmpty()) {
List<String> chapterIDs = chapters.stream()
.map(TbCourseChapter::getChapterID)
.collect(Collectors.toList());
// 查询带进度的节点传入用户ID
List<CourseItemVO> nodesWithProgress = courseNodeMapper.selectNodesProgress(chapterIDs, user.getID());
// 转换章节为CourseItemVO列表
List<CourseItemVO> chapterVOs = chapters.stream()
.map(CourseItemVO::fromChapter)
.collect(Collectors.toList());
// 按章节ID分组节点
Map<String, List<CourseItemVO>> nodesMap = nodesWithProgress.stream()
.collect(Collectors.groupingBy(CourseItemVO::getChapterID));
// 设置章节列表和章节节点映射
courseItemVO.setChapters(chapterVOs);
courseItemVO.setChapterNodes(nodesMap);
@@ -599,4 +599,19 @@ public class SCCourseServiceImpl implements SCCourseService {
resultDomain.success("获取课程进度成功", courseItemVO);
return resultDomain;
}
@Override
public ResultDomain<Integer> getCourseCount(TbCourse filter) {
ResultDomain<Integer> resultDomain = new ResultDomain<>();
try {
// 获取当前用户的部门角色
List<UserDeptRoleVO> userDeptRoles = LoginUtil.getCurrentDeptRole();
long count = courseMapper.countCourses(filter, userDeptRoles);
resultDomain.success("获取课程数量成功", (int) count);
} catch (Exception e) {
logger.error("获取课程数量失败", e);
resultDomain.fail("获取课程数量失败: " + e.getMessage());
}
return resultDomain;
}
}

View File

@@ -796,15 +796,15 @@ public class SCLearningTaskServiceImpl implements LearningTaskService {
ResultDomain<Map<String, Object>> resultDomain = new ResultDomain<>();
try {
Map<String, Object> rankingsData = new HashMap<>();
// 获取完成时间排行榜前10名
List<Map<String, Object>> completionTimeRanking = taskUserMapper.getCompletionTimeRanking(taskID);
rankingsData.put("completionTimeRanking", completionTimeRanking);
// 获取学习时长排行榜前10名
List<Map<String, Object>> durationRanking = taskUserMapper.getStudyDurationRanking(taskID);
rankingsData.put("durationRanking", durationRanking);
resultDomain.success("获取任务排行榜数据成功", rankingsData);
} catch (Exception e) {
logger.error("获取任务排行榜数据失败", e);
@@ -812,4 +812,19 @@ public class SCLearningTaskServiceImpl implements LearningTaskService {
}
return resultDomain;
}
@Override
public ResultDomain<Integer> getLearningTaskCount(TbLearningTask filter) {
ResultDomain<Integer> resultDomain = new ResultDomain<>();
try {
// 获取当前用户的部门角色
List<UserDeptRoleVO> userDeptRoles = LoginUtil.getCurrentDeptRole();
long count = learningTaskMapper.countLearningTasks(filter, userDeptRoles);
resultDomain.success("获取学习任务数量成功", (int) count);
} catch (Exception e) {
logger.error("获取学习任务数量失败", e);
resultDomain.fail("获取学习任务数量失败: " + e.getMessage());
}
return resultDomain;
}
}