SubjectSemesterMapper.xml
4.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.meishu.mapper.SubjectSemesterMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.meishu.model.SubjectSemesterDO">
<id column="id" property="id" />
<result column="create_date" property="createDate" />
<result column="update_date" property="updateDate" />
<result column="delete_date" property="deleteDate" />
<result column="subject_id" property="subjectId" />
<result column="semester" property="semester" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
create_date,
update_date,
delete_date,
id, subject_id, semester
</sql>
<select id="getSemesterScore" resultType="com.meishu.vo.semester.GetSemesterScoreVO">
SELECT
t3.id,
t5.id as userId,
t5.user_name,
t6.study_code,
t2.`subject`,
t4.score
FROM
subject_dict t2
LEFT JOIN subject_semester t3 ON t2.id = t3.subject_id
LEFT JOIN pt_student_score t4 ON t3.id = t4.semester_id
LEFT JOIN user_role t5 ON t4.student_id = t5.id
LEFT JOIN user_studycode t6 ON t5.id = t6.user_role_id
where
t2.grade = #{grade}
and t3.delete_date is null
and t2.delete_date is null
and t2.classes = #{classes}
and t2.session = #{session}
and t3.delete_date is null
and t2.delete_date is null
<if test="semester != null and semester !=''">
and t3.semester = #{semester}
</if>
<if test="userName != null and userName !=''">
and t5.user_name like concat('%',#{userName} ,'%')
</if>
<if test="subject != null and subject !=''">
and t2.subject = #{subject}
</if>
</select>
<select id="exportScore" resultType="com.meishu.vo.semester.GetSemesterScoreVO">
SELECT
t3.id,
t5.user_name,
t6.study_code,
t2.`subject`,
t4.score
FROM
subject_dict t2
LEFT JOIN subject_semester t3 ON t2.id = t3.subject_id
LEFT JOIN pt_student_score t4 ON t3.id = t4.semester_id
LEFT JOIN user_role t5 ON t4.student_id = t5.id
LEFT JOIN user_studycode t6 ON t5.id = t6.user_role_id
where
t2.grade = #{grade}
and t2.classes = #{classes}
and t2.session = #{session}
<if test="semester != null and semester != '' ">
and t3.semester = #{semester}
</if>
<if test="userName != null and userName !=''">
and t5.user_name = #{userName}
</if>
<if test="subject != null and subject !=''">
and t2.subject = #{subject}
</if>
</select>
<select id="getStudentDetail" resultType="com.meishu.vo.semester.GetStudentDetailVO">
SELECT
t3.user_name as teacherName,
t2.item_desc,
t2.score,
t2.item_type,
t.create_date
FROM
pt_student_score_record t
LEFT JOIN pt_score_item_dict t2 ON t.score_item_id = t2.id
LEFT JOIN administer t3 ON t.create_by = t3.id
WHERE
t.semester_id = #{id}
AND t.student_id = #{userId}
</select>
<select id="getStudentRecord" parameterType="com.meishu.dto.semester.GetStudentRecordDTO" resultType="com.meishu.vo.semester.GetStudentRecordVO">
SELECT
t5.class_name,
t3.user_name,
t2.item_desc,
t2.score,
t6.user_name AS teacherName,
t8.`subject`,
t.create_date
FROM
pt_student_score_record t
LEFT JOIN pt_score_item_dict t2 ON t.score_item_id = t2.id
LEFT JOIN user_role t3 ON t.student_id = t3.id
LEFT JOIN classes_user_mapping t4 ON t3.id = t4.user_id
LEFT JOIN classes_dict t5 ON t4.classes_id = t5.id
LEFT JOIN administer t6 ON t.create_by = t6.id
left join subject_semester t7 on t.semester_id = t7.id
left join subject_dict t8 on t7.subject_id = t8.id
WHERE
t2.item_type = 0
and t4.delete_date is null
<if test="startDate != null and startDate != ''">
and DATE_FORMAT(t.create_date, '%Y-%m-%d') >= DATE_FORMAT(#{startDate}, '%Y-%m-%d')
</if>
<if test="endDate != null and endDate !=''">
and DATE_FORMAT(t.create_date, '%Y-%m-%d') <= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
</if>
</select>
</mapper>