This commit is contained in:
Lihx 2025-06-08 15:57:00 +08:00
parent 5a8b8e92c3
commit 691c3f3220
4 changed files with 49 additions and 2 deletions

View File

@ -457,6 +457,45 @@ public class DataViewServiceImpl implements DataViewService {
List<DlDriveSchoolStaffVO> list = studentMapper.selectStudentListCount();
Map<String, Object> rtnMap = new HashMap<>();
rtnMap.put("all", list.size());
// courseType 分组
Map<String, List<DlDriveSchoolStaffVO>> courseTypeMap = list.stream()
.filter(item -> item.getCourseType() != null)
.collect(Collectors.groupingBy(DlDriveSchoolStaffVO::getCourseType));
// 统计各 courseType 的总人数
for (String courseType : courseTypeMap.keySet()) {
rtnMap.put(courseType, courseTypeMap.get(courseType).size());
}
// 按毕业状态分组gradTime 是否为空
Map<String, List<DlDriveSchoolStaffVO>> graduatedMap = list.stream()
.filter(item -> item.getCourseType() != null)
.collect(Collectors.groupingBy(
item -> item.getGradTime() != null ? "graduated" : "notGraduated"
));
// 统计总毕业/未毕业人数
rtnMap.put("graduated", graduatedMap.getOrDefault("graduated", Collections.emptyList()).size());
rtnMap.put("notGraduated", graduatedMap.getOrDefault("notGraduated", Collections.emptyList()).size());
// courseType + 毕业状态分组例如C1_graduated, C2_notGraduated
Map<String, Long> courseTypeGraduatedCount = list.stream()
.filter(item -> item.getCourseType() != null)
.collect(Collectors.groupingBy(
item -> item.getCourseType() + "_" + (item.getGradTime() != null ? "graduated" : "notGraduated"),
Collectors.counting()
));
// courseType + 毕业状态的统计结果放入 rtnMap
courseTypeGraduatedCount.forEach((key, count) -> rtnMap.put(key, count));
return rtnMap;
}
/*public Map<String, Object> getStudentCount() {
List<DlDriveSchoolStaffVO> list = studentMapper.selectStudentListCount();
Map<String, Object> rtnMap = new HashMap<>();
rtnMap.put("all", list.size());
//按courseType分组
Map<String, List<DlDriveSchoolStaffVO>> map = list.stream()
.filter(item -> item.getCourseType() != null) // 过滤掉 courseType null 的元素
@ -487,5 +526,5 @@ public class DataViewServiceImpl implements DataViewService {
rtnMap.put("graduated", graduatedCount);
rtnMap.put("notGraduated", notGraduatedCount);
return rtnMap;
}
}*/
}

View File

@ -64,4 +64,8 @@ public class DlDriveSchoolStaffVO {
private List<String> age;
/**拿证天数*/
private Integer passDays;
/**毕业时间*/
private Date gradTime;
/**拿证时间*/
private Date passTime;
}

View File

@ -476,7 +476,9 @@
<select id="selectStudentListCount" resultType="cn.iocoder.yudao.module.base.vo.DlDriveSchoolStaffVO">
SELECT
main.id AS id,
dsco.course_type
dsco.course_type,
dsco.grad_time,
dsco.pass_time
FROM
drive_school_student main
LEFT JOIN drive_school_course_order dsco ON main.user_id = dsco.user_id

View File

@ -58,6 +58,8 @@
<if test="entity.courseName != null and entity.courseName != '' "> and dsp.name like concat('%', #{entity.courseName}, '%')</if>
<if test="entity.userId != null "> and dsp.user_id = #{entity.userId}</if>
<if test="entity.courseId != null and entity.courseId != '' "> and dsp.course_id = #{entity.courseId}</if>
<if test="entity.subject != null "> and dsp.subject = #{entity.subject}</if>
<if test="entity.examStatus != null and entity.examStatus != '' "> and dsp.exam_status = #{entity.examStatus}</if>
<!--<if test="entity.studentIdCard != null and entity.studentIdCard != '' "> AND RIGHT(dss.id_card, 4) = RIGHT(#{entity.studentIdCard}, 4) </if>-->
<if test="entity.studentIdCard != null and entity.studentIdCard != '' ">
<choose>