|
|
@@ -3,7 +3,7 @@
|
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.ruoyi.learn.mapper.LearnStudentMapper">
|
|
|
-
|
|
|
+
|
|
|
<resultMap type="LearnStudent" id="LearnStudentResult">
|
|
|
<result property="studentId" column="student_id" />
|
|
|
<result property="classId" column="class_id" />
|
|
|
@@ -21,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
<select id="selectLearnStudentList" parameterType="LearnStudent" resultMap="LearnStudentResult">
|
|
|
<include refid="selectLearnStudentVo"/>
|
|
|
- <where>
|
|
|
+ <where>
|
|
|
<if test="directKey != null and directKey != ''"> and direct_key = #{directKey}</if>
|
|
|
</where>
|
|
|
</select>
|
|
|
@@ -102,7 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</delete>
|
|
|
|
|
|
<delete id="deleteLearnStudentByStudentIds" parameterType="String">
|
|
|
- delete from learn_student where student_id in
|
|
|
+ delete from learn_student where student_id in
|
|
|
<foreach item="studentId" collection="array" open="(" separator="," close=")">
|
|
|
#{studentId}
|
|
|
</foreach>
|
|
|
@@ -112,27 +112,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<select id="statisticStudyRecord" parameterType="com.ruoyi.learn.dto.StudyRecordStatisticsDTO" resultType="com.ruoyi.learn.dto.StudyRecordStatisticsDTO">
|
|
|
WITH T1 AS (
|
|
|
<!-- 定义查询 1 的聚合结果(做题统计)-->
|
|
|
- SELECT
|
|
|
+ SELECT
|
|
|
a.student_id,
|
|
|
- COUNT(*) AS num,
|
|
|
- SUM(IF(a.state = 1, 1, 0)) AS correct,
|
|
|
- ROUND(SUM(IF(a.state = 1, 1, 0)) * 100 / COUNT(*), 1) AS rate,
|
|
|
+ COUNT(*) AS num,
|
|
|
+ SUM(IF(a.state = 1, 1, 0)) AS correct,
|
|
|
+ ROUND(SUM(IF(a.state = 1, 1, 0)) * 100 / COUNT(*), 1) AS rate,
|
|
|
COUNT(DISTINCT le.paper_id) AS paperCount,
|
|
|
- ROUND(SUM(IF(a.`state` = 1 AND le.paper_type IN (20), 1, 0)) * 100 / SUM(IF(le.paper_type IN (20), 1, 0)), 1) paperRate
|
|
|
- FROM `sys_user` u
|
|
|
- JOIN `dz_cards` dc ON u.card_id = dc.card_id
|
|
|
- JOIN `learn_examinee` le ON le.student_id = u.user_id AND le.state >= 4
|
|
|
- JOIN `learn_answer` a ON u.user_id = a.student_id AND a.state > 0
|
|
|
- WHERE
|
|
|
- dc.school_id != 0 AND dc.class_id != 0 AND dc.campus_id != 0 AND dc.campus_class_id != 0
|
|
|
- AND (dc.agent_id != 0 OR dc.leaf_agent_id != 0) AND u.nick_name != '' AND dc.card_no != ''
|
|
|
+ ROUND(SUM(IF(a.`state` = 1 AND le.paper_type IN (20,30), 1, 0)) * 100 / SUM(IF(le.paper_type IN (20,30), 1, 0)), 1) paperRate
|
|
|
+ FROM `sys_user` u
|
|
|
+ JOIN `dz_cards` dc ON u.card_id = dc.card_id
|
|
|
+ JOIN `learn_examinee` le ON le.student_id = u.user_id AND le.state >= 4
|
|
|
+ JOIN `learn_answer` a ON u.user_id = a.student_id AND a.state > 0
|
|
|
+ WHERE
|
|
|
+ dc.school_id != 0 AND dc.class_id != 0 AND dc.campus_id != 0 AND dc.campus_class_id != 0
|
|
|
+ AND (dc.agent_id != 0 OR dc.leaf_agent_id != 0) AND u.nick_name != '' AND dc.card_no != ''
|
|
|
GROUP BY a.student_id
|
|
|
),
|
|
|
T2 AS (
|
|
|
<!-- 定义查询 2 的聚合结果(视频观看统计)-->
|
|
|
- SELECT
|
|
|
- ls.student_id,
|
|
|
- COUNT(DISTINCT vw.title) AS total,
|
|
|
+ SELECT
|
|
|
+ ls.student_id,
|
|
|
+ COUNT(DISTINCT vw.title) AS total,
|
|
|
ROUND(SUM(vw.duration * vw.percent / 100.0)) AS value
|
|
|
FROM `b_customer_video_watches` vw
|
|
|
JOIN `learn_student` ls ON vw.customerCode = ls.student_id
|
|
|
@@ -148,13 +148,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<!-- 获取所有涉及学生的基础信息-->
|
|
|
SELECT DISTINCT
|
|
|
asl.student_id,
|
|
|
- COALESCE(dc.school_id, NULL) AS school_id,
|
|
|
- COALESCE(dc.class_id, NULL) AS class_id,
|
|
|
- COALESCE(dc.campus_id, NULL) AS campus_id,
|
|
|
- COALESCE(dc.campus_class_id, NULL) AS campus_class_id,
|
|
|
- COALESCE(dc.agent_id, NULL) AS agent_id,
|
|
|
- COALESCE(dc.leaf_agent_id, NULL) AS leaf_agent_id,
|
|
|
- u.nick_name AS nick_name,
|
|
|
+ COALESCE(dc.school_id, NULL) AS school_id,
|
|
|
+ COALESCE(dc.class_id, NULL) AS class_id,
|
|
|
+ COALESCE(dc.campus_id, NULL) AS campus_id,
|
|
|
+ COALESCE(dc.campus_class_id, NULL) AS campus_class_id,
|
|
|
+ COALESCE(dc.agent_id, NULL) AS agent_id,
|
|
|
+ COALESCE(dc.leaf_agent_id, NULL) AS leaf_agent_id,
|
|
|
+ u.nick_name AS nick_name,
|
|
|
COALESCE(dc.card_no, NULL) AS card_no
|
|
|
FROM AllStudents asl
|
|
|
<!-- 基础信息主要从 sys_user 和 dz_cards 获取-->
|
|
|
@@ -164,21 +164,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<!-- 主查询:将统计数据 LEFT JOIN 到基础信息上-->
|
|
|
SELECT
|
|
|
<!-- 基础信息字段(已补齐,始终输出)-->
|
|
|
- SBI.school_id as schoolId,
|
|
|
- SBI.class_id as classId,
|
|
|
- SBI.campus_id as campusId,
|
|
|
- SBI.campus_class_id as campusClassId,
|
|
|
- SBI.agent_id as agentId,
|
|
|
- SBI.leaf_agent_id as leafAgentId,
|
|
|
- SBI.nick_name as nickName,
|
|
|
- SBI.card_no as cardNo,
|
|
|
+ SBI.school_id as schoolId,
|
|
|
+ SBI.class_id as classId,
|
|
|
+ SBI.campus_id as campusId,
|
|
|
+ SBI.campus_class_id as campusClassId,
|
|
|
+ SBI.agent_id as agentId,
|
|
|
+ SBI.leaf_agent_id as leafAgentId,
|
|
|
+ SBI.nick_name as nickName,
|
|
|
+ SBI.card_no as cardNo,
|
|
|
SBI.student_id as studentId,
|
|
|
-
|
|
|
+
|
|
|
<!-- T1 统计结果-->
|
|
|
COALESCE(T1.num, 0) AS num,
|
|
|
COALESCE(T1.correct, 0) AS correct,
|
|
|
<!-- RATE 字段处理:如果 T1.num 为 0 则 Rate 为 0-->
|
|
|
- CASE
|
|
|
+ CASE
|
|
|
WHEN COALESCE(T1.num, 0) = 0 THEN 0
|
|
|
ELSE T1.rate
|
|
|
END AS rate,
|
|
|
@@ -189,11 +189,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
COALESCE(T2.total, 0) AS videoTotalTitles,
|
|
|
COALESCE(T2.value, 0) AS videoDurationValue
|
|
|
|
|
|
- FROM
|
|
|
+ FROM
|
|
|
StudentBaseInfo AS SBI
|
|
|
- LEFT JOIN
|
|
|
+ LEFT JOIN
|
|
|
T1 ON SBI.student_id = T1.student_id
|
|
|
- LEFT JOIN
|
|
|
+ LEFT JOIN
|
|
|
T2 ON SBI.student_id = T2.student_id
|
|
|
<where>
|
|
|
<if test="schoolId != null"> AND SBI.school_id = #{schoolId}</if>
|
|
|
@@ -204,7 +204,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="nickName != null and nickName != ''"> AND SBI.nick_name LIKE CONCAT('%', #{nickName}, '%')</if>
|
|
|
<if test="cardNo != null and cardNo != ''"> AND SBI.card_no LIKE CONCAT('%', #{cardNo}, '%')</if>
|
|
|
</where>
|
|
|
- ORDER BY
|
|
|
+ ORDER BY
|
|
|
SBI.student_id
|
|
|
</select>
|
|
|
-</mapper>
|
|
|
+</mapper>
|