249 lines
8.1 KiB
XML
Raw Normal View History

2026-03-10 16:40:19 +08:00
<?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.univ3e.dao.UnivHearexamDao">
<select id= "getNextSeq" resultType="int">
SELECT NEXTVAL('seq_univhearexamid')
</select>
<select id= "getNextSeqHearAnswerId" resultType="int">
SELECT NEXTVAL('seq_univhearanswerid')
</select>
<insert id= "doSave" parameterType="com.univ3e.entity.UnivHearExam" >
INSERT INTO UnivHearExam(examid,examtype,isrecommend,title,description,hearpaperid,
created,starttime,endtime,isnetexam,teacherid)
VALUES (
<if test = "examid == 0">
(SELECT NEXTVAL('seq_univhearexamid')),
</if>
<if test = "examid != 0">
#{examid},
</if>
#{examtype},#{isrecommend},#{title},#{description},#{hearpaperid},#{created},
#{starttime},#{endtime},#{isnetexam},#{teacherid})
</insert>
<insert id= "doSaveHearAnswer" parameterType="com.univ3e.entity.UnivHearAnswer" >
INSERT INTO UnivHearAnswer(examanswerid,userid,examid,examtype,hearpaperid,
score,answerdetail,created,areaid,origiscore)
VALUES (
<if test="examanswerid == 0">
(SELECT NEXTVAL('seq_univhearanswerid')),
</if>
<if test="examanswerid != 0">
#{examanswerid},
</if>
#{userid},#{examid},#{examtype},#{hearpaperid},#{score},
#{answerdetail},#{created},#{areaid},#{origiscore})
</insert>
<select id= "findHearexam" parameterType="int" resultType="com.univ3e.entity.UnivHearExam" >
SELECT * FROM UnivHearExam WHERE examid = #{examId}
</select>
<select id= "findMockhearexam" parameterType="map" resultType="com._3e.dto.HearexamDto" >
select * from (
SELECT h.* FROM univhearexam h
inner join univclassownhear c
on c.examid = h.examid
inner join univstudentownclass s
on s.classesid = c.classesid and s.status = 1
WHERE s.studentId= #{uid}
AND h.examType = 'S'
and h.startTime &lt; now() and h.endTime &gt; now()
union
SELECT h.* FROM univhearexam h
inner join univclassownhear c
on c.examid = h.examid
inner join univclasses co
on c.classesid = co.classesid and co.status = 1
WHERE co.teacherId = #{uid}
AND h.examType = 'S'
and h.startTime &lt; now() and h.endTime &gt; now()
UNION
SELECT h.* FROM univhearexam h
WHERE isNetExam = 1 AND examType = 'S'
and startTime &lt; now() and endTime &gt; now()
) t
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id= "findFormalhearexam" parameterType="map" resultType="com._3e.dto.HearexamDto" >
SELECT h.* FROM univhearexam h
inner join univclassownhear c
on c.examid = h.examid
inner join univstudentownclass s
on s.classesid = c.classesid and s.status = 1
WHERE s.studentId = #{uid}
AND h.examType = 'O'
and h.startTime &lt; now() and h.endTime &gt; now()
union
SELECT h.* FROM univhearexam h
inner join univclassownhear c
on c.examid = h.examid
inner join univclasses co
on c.classesid = co.classesid and co.status = 1
WHERE co.teacherId = #{uid}
AND h.examType = 'O'
and h.startTime &lt; now() and h.endTime &gt; now()
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id= "findHearpaper" parameterType="map" resultType="com.univ3e.entity.VUnivHearPaper" >
SELECT distinct hearpaperid, teacherid, examlevel, title, subtitle, memo, '' as content,
status, areaid
FROM v_univhearpaper WHERE teacherid = #{teacherId} and status = 1
<if test="title != null">
and title like '%'||#{title}||'%'
</if>
order by hearPaperId desc
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id= "findHearAnswer" parameterType="map" resultType="com.univ3e.entity.UnivHearAnswer" >
select * from univhearanswer where userid = #{userId} and examid = #{examId}
<if test="examtype != null">
and examtype = #{examType}
</if>
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id= "findAssignHearexam" parameterType="map" resultType="com.univ3e.entity.UnivHearExam" >
SELECT b.*
FROM UnivClassOwnHear a
INNER join UnivHearExam b
ON a.classesId = #{classesId} and a.examId = b.examId
<if test="examType != null">
AND examtype = #{examType}
</if>
<if test="startTime != null">
AND starttime &gt;= #{startTime}
</if>
<if test="endTime != null">
AND endtime &lt;= #{endTime}
</if>
ORDER BY b.examId DESC
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id= "findClassHearexamMaxScore" parameterType="map" resultType="com._3e.dto.ExamScoreDto" >
WITH temp AS (
SELECT b.userId AS studentId, b.examAnswerId , b.examId , b.examType ,
b.hearPaperId as examPaperId , b.score , b.created ,
case when b.score >= 85 then 'A'
when b.score >= 73 then 'B'
when b.score >= 60 then 'C'
when b.score >= 45 then 'D'
else 'E' end as level
, e.title ,b.trueScore
FROM ( SELECT userId , examId ,
last_value( examAnswerId ) OVER (PARTITION BY userId order by score desc,created ASC ) as tempId ,
row_number() OVER (PARTITION BY userId order by score desc,created ASC ) as rn
FROM UnivStudentOwnClass m
inner join univstudent o on m.studentId=o.studentId and o.status=1 and m.status=1
INNER JOIN UnivHearAnswer n
ON m.classesId = #{classesId} AND m.studentId = n.userId AND m.status = 1 AND examId = #{examId}
) a
INNER JOIN UnivHearAnswer b
ON a.tempId = b.examAnswerId and a.rn = 1 and b.areaid = #{areaId}
inner join UnivHearExam e on e.examId = b.examId
ORDER BY b.score desc
)
SELECT t.studentId , COALESCE(t.examAnswerId,0) AS examAnswerId, COALESCE(t.examId,0) AS examId,
t.examType , COALESCE(t.examPaperId,0) AS examPaperId , COALESCE(t.score,0) AS score, t.created ,
t.level, t.title,s.truename, s.recognizecode,s.studentId AS userid
FROM temp t
RIGHT JOIN UnivStudentOwnClass o ON t.studentId = o.studentId
INNER JOIN Univstudent s ON s.studentId = o.studentId and s.status=1
WHERE o.classesId = #{classesId} AND o.status = 1
ORDER BY score DESC, t.created ASC nulls last, userId ASC
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id= "findClassHearexamAllScore" parameterType="map" resultType="com._3e.dto.ExamScoreDto" >
SELECT b.userId , b.examAnswerId , b.examId , b.examType ,
b.hearPaperId as examPaperId , b.score , b.created ,
case when b.score >= 85 then 'A'
when b.score >= 73 then 'B'
when b.score >= 60 then 'C'
when b.score >= 45 then 'D'
else 'E' end as level
, e.title
FROM UnivStudentOwnClass a
INNER JOIN UnivhearAnswer b
ON a.classesId = #{classesId} AND a.studentId = b.userId AND b.examId = #{examId}
inner join UnivhearExam e on e.examId = b.examId
ORDER BY b.examAnswerId desc
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id= "findHearexamPaperByID" parameterType="int" resultType="com.univ3e.entity.VUnivHearPaper" >
SELECT * FROM HearPaper WHERE hearpaperid = #{hearpaperid}
</select>
<select id= "findIsExamToClass" parameterType="map" resultType="boolean" >
SELECT CASE WHEN (COUNT(*) &gt; 0) THEN true ELSE false END AS isFlag
FROM UnivClassOwnHear
WHERE examid = #{examId} and classesid = #{classesId}
</select>
<insert id= "doExamToClasses" parameterType="com.univ3e.entity.UnivClassOwnHear">
INSERT INTO UnivClassOwnHear(classesid,examid,areaid)
VALUES (#{classesid},#{examid},#{areaid})
</insert>
<update id="doSaveUpdate" parameterType="com.univ3e.entity.UnivHearExam" >
UPDATE UnivHearexam
<set>
<if test="examtype != null">
examtype = #{examtype},
</if>
<if test="isrecommend != null">
isrecommend = #{isrecommend},
</if>
<if test="title != null">
title = #{title},
</if>
<if test="description != null">
description = #{description},
</if>
<if test="hearpaperid != null">
hearpaperid = #{hearpaperid},
</if>
<if test="created != null">
created = #{created},
</if>
<if test="starttime != null">
starttime = #{starttime},
</if>
<if test="endtime != null">
endtime = #{endtime},
</if>
<if test="isnetexam != null">
isnetexam = #{isnetexam},
</if>
<if test="teacherid != null">
teacherid = #{teacherid}
</if>
</set>
WHERE examid = #{examid}
</update>
</mapper>