328 lines
11 KiB
XML
328 lines
11 KiB
XML
<?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._3e.dao.HearexamDao">
|
|
<select id= "getNextSeq" resultType="int">
|
|
SELECT NEXTVAL('seq_hearexamid')
|
|
</select>
|
|
|
|
<select id= "getNextSeqHearAnswerId" resultType="long">
|
|
SELECT NEXTVAL('seq_hearanswerid')
|
|
</select>
|
|
|
|
<insert id= "doSave" parameterType="com._3e.entity.Hearexam" >
|
|
INSERT INTO Hearexam(examid,examtype,isrecommend,title,description,hearpaperid,created,starttime,endtime,isnetexam,teacherid)
|
|
VALUES (
|
|
<if test="examid == 0">
|
|
(SELECT NEXTVAL('seq_hearexamid')),
|
|
</if>
|
|
<if test="examid != 0">
|
|
#{examid},
|
|
</if>
|
|
#{examtype},#{isrecommend},#{title},#{description},#{hearpaperid},#{created},#{starttime},#{endtime},#{isnetexam},#{teacherid})
|
|
</insert>
|
|
|
|
|
|
<update id="doSaveUpdate" parameterType="com._3e.entity.Hearexam" >
|
|
UPDATE Hearexam
|
|
<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>
|
|
|
|
<insert id= "doSaveHearAnswer" parameterType="com._3e.entity.HearAnswer" >
|
|
INSERT INTO HearAnswer(examanswerid,userid,examid,examtype,hearpaperid,score,answerdetail,created,areaid,origiscore,truescore)
|
|
VALUES (
|
|
<if test="examanswerid == 0">
|
|
(SELECT NEXTVAL('seq_hearanswerid')),
|
|
</if>
|
|
<if test="examanswerid != 0">
|
|
#{examanswerid},
|
|
</if>
|
|
#{userid},#{examid},#{examtype},#{hearpaperid},#{score},#{answerdetail},#{created},#{areaid},#{origiscore},#{truescore})
|
|
</insert>
|
|
|
|
<select id= "findMockhearexam" parameterType="map" resultType="com._3e.dto.HearexamDto" >
|
|
select * from (
|
|
SELECT h.* FROM hearexam h
|
|
inner join classownhear c
|
|
on c.examid = h.examid
|
|
inner join studentownclass s
|
|
on s.classesid = c.classesid
|
|
and s.areaid = #{areaid}
|
|
and s.status = 1
|
|
WHERE s.studentId= #{uid}
|
|
AND h.examType = 'S'
|
|
and h.startTime < now() and h.endTime > now()
|
|
union
|
|
SELECT h.* FROM hearexam h
|
|
inner join classownhear c
|
|
on c.examid = h.examid
|
|
inner join classes co
|
|
on c.classesid = co.classesid and co.status = 1
|
|
WHERE co.teacherId = #{uid}
|
|
AND h.examType = 'S'
|
|
and h.startTime < now() and h.endTime > now()
|
|
UNION
|
|
SELECT h.* FROM hearexam h
|
|
WHERE isNetExam = 1 AND examType = 'S'
|
|
and startTime < now() and endTime > now()
|
|
) t
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id= "findHearexam" parameterType="int" resultType="com._3e.entity.Hearexam" >
|
|
SELECT * FROM hearexam WHERE examid = #{examid}
|
|
</select>
|
|
|
|
<select id= "findFormalhearexam" parameterType="map" resultType="com._3e.dto.HearexamDto" >
|
|
SELECT h.* FROM hearexam h
|
|
inner join classownhear c
|
|
on c.examid = h.examid
|
|
inner join studentownclass s
|
|
on s.classesid = c.classesid
|
|
and s.areaid = #{areaid}
|
|
and s.status = 1
|
|
WHERE s.studentId = #{uid}
|
|
AND h.examType = 'O'
|
|
and h.startTime < now() and h.endTime > now()
|
|
union
|
|
SELECT h.* FROM hearexam h
|
|
inner join classownhear c
|
|
on c.examid = h.examid
|
|
inner join classes co
|
|
on c.classesid = co.classesid and co.status = 1
|
|
WHERE co.teacherId = #{uid}
|
|
AND h.examType = 'O'
|
|
and h.startTime < now() and h.endTime > now()
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id= "findHearpaper" parameterType="map" resultType="com._3e.entity.Hearpaper" >
|
|
SELECT distinct hearpaperid, teacherid, examlevel, title, subtitle, memo, '' as content,
|
|
status, areaid
|
|
FROM V_HearPaper WHERE teacherid = #{teacherId} and status = 1 and isoral = -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._3e.entity.HearAnswer" >
|
|
select * from hearanswer where userid = #{userId} and examid = #{examId} and areaid = #{areaid}
|
|
<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._3e.entity.Hearexam" >
|
|
SELECT b.*
|
|
FROM ClassOwnHear a
|
|
INNER join HearExam b
|
|
ON a.classesId = #{classesId} and a.examId = b.examId
|
|
<if test="examType != null">
|
|
AND examtype = #{examType}
|
|
</if>
|
|
<if test="startTime != null">
|
|
AND starttime >= #{startTime}
|
|
</if>
|
|
<if test="endTime != null">
|
|
AND endtime <= #{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 >= 80 then 'B'
|
|
when b.score >= 70 then 'C'
|
|
when b.score >= 60 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 StudentOwnClass m
|
|
INNER JOIN HearAnswer n
|
|
ON m.classesId = #{classesId} AND m.studentId = n.userId
|
|
and m.areaid = #{areaId} and n.areaid = #{areaId}
|
|
AND m.status = 1 AND examId = #{examId}
|
|
) a
|
|
INNER JOIN HearAnswer b
|
|
ON a.tempId = b.examAnswerId and a.rn = 1 and b.areaid = #{areaId}
|
|
inner join HearExam 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.code,s.studentId AS userId , COALESCE(t.truescore,0) AS truescore
|
|
FROM temp t
|
|
RIGHT JOIN StudentOwnClass o ON t.studentId = o.studentId
|
|
INNER JOIN student s ON s.studentId = o.studentId
|
|
WHERE o.classesId = #{classesId}
|
|
and o.areaid = #{areaId}
|
|
and s.areaid = #{areaId}
|
|
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 >= 80 then 'B'
|
|
when b.score >= 70 then 'C'
|
|
when b.score >= 60 then 'D'
|
|
else 'E' end as level
|
|
, e.title
|
|
FROM StudentOwnClass a
|
|
INNER JOIN hearAnswer b
|
|
ON a.classesId = #{classesid} AND a.studentId = b.userId AND b.examId = #{examid}
|
|
inner join hearExam 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._3e.entity.Hearpaper" >
|
|
SELECT * FROM hearpaper WHERE hearpaperid = #{hearpaperid}
|
|
</select>
|
|
|
|
<select id= "findHearexamPaperByIDV2" parameterType="map" resultType="com._3e.entity.Hearpaper" >
|
|
SELECT hearpaperid, teacherid, examlevel, title, subtitle, memo, content,
|
|
status, isoral, totalscore, machinescore, humanscore, paperfile, md5code
|
|
FROM v_hearpaperall
|
|
WHERE hearpaperid = #{hearPaperId} AND isoral = #{isOral}
|
|
</select>
|
|
|
|
<select id= "findHearexamPaperByIDV3" parameterType="map" resultType="com._3e.entity.Hearpaper" >
|
|
SELECT exampaperid hearpaperid, teacherid, examlevel, title, content,
|
|
status, isoral, totalscore, machinescore, humanscore, paperfile, md5code
|
|
FROM exampaper
|
|
WHERE exampaperid = #{hearPaperId} AND isoral = #{isOral}
|
|
</select>
|
|
|
|
<select id= "findIsExamToClass" parameterType="map" resultType="boolean" >
|
|
SELECT CASE WHEN (COUNT(*) > 0) THEN true ELSE false END AS isFlag
|
|
FROM classOwnHear
|
|
WHERE examid = #{examId} and classesid = #{classesId}
|
|
</select>
|
|
|
|
<insert id= "doExamToClasses" parameterType="com._3e.entity.ClassOwnHear">
|
|
INSERT INTO classownhear(classesid,examid,areaid,objecttype)
|
|
VALUES (#{classesid},#{examid},#{areaid},#{objecttype})
|
|
</insert>
|
|
|
|
<select id= "findHearIsNetExam" parameterType="map" resultType="com._3e.entity.Hearexam" >
|
|
<bind name="examType" value="_3eReqExamInfo.examType"/>
|
|
SELECT * FROM Hearexam
|
|
WHERE isNetExam=1 AND examType = #{examType} AND startTime < now() AND endTime > now()
|
|
ORDER BY examid DESC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id= "findHearExams" parameterType="map" resultType="com._3e.entity.Hearexam" >
|
|
<bind name="examType" value="_3eReqExamInfo.examType"/>
|
|
<bind name="objectType" value="_3eReqExamInfo.objType"/>
|
|
SELECT e.examid, e.examtype, e.isrecommend, e.title, e.description,
|
|
e.created, e.starttime, e.endtime, e.isnetexam, e.hearpaperid, e.teacherid
|
|
FROM HearExam e
|
|
RIGHT JOIN ClassOwnHear c ON c.examid = e.examid
|
|
WHERE e.examType = #{examType}
|
|
AND e.startTime < now() AND e.endTime > now()
|
|
AND c.areaid = #{areaid} AND objectType = #{objectType}
|
|
ORDER BY e.examid DESC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id= "findSchoolHearExam" parameterType="map" resultType="com._3e.entity.Hearexam" >
|
|
<bind name="examType" value="_3eReqExamInfo.examType"/>
|
|
<bind name="objecteType" value="_3eReqExamInfo.objType"/>
|
|
SELECT e.examid, e.examtype, e.isrecommend, e.title, e.description,
|
|
e.created, e.starttime, e.endtime, e.isnetexam, e.hearpaperid, e.teacherid
|
|
FROM HearExam e
|
|
RIGHT JOIN ClassOwnHear c ON c.examid = e.examid AND c.objecttype = #{objecteType}
|
|
<if test="objecteType == 2">
|
|
INNER JOIN Classes s ON s.classesid = c.classesid
|
|
WHERE e.examType = #{examType}
|
|
AND e.startTime < now() AND e.endTime > now()
|
|
AND s.schoolid = #{objid}
|
|
</if>
|
|
<if test="objecteType != 2">
|
|
INNER JOIN studentownclass s on s.classesid = c.classesid
|
|
and s.areaid = #{areaid}
|
|
and s.status = 1
|
|
WHERE e.examType = #{examType}
|
|
AND e.startTime < now() AND e.endTime > now()
|
|
AND s.studentid = #{objid}
|
|
UNION
|
|
SELECT e.examid, e.examtype, e.isrecommend, e.title, e.description,
|
|
e.created, e.starttime, e.endtime, e.isnetexam, e.hearpaperid, e.teacherid
|
|
FROM HearExam e
|
|
RIGHT JOIN ClassOwnHear c ON c.examid = e.examid AND c.objecttype = #{objecteType}
|
|
WHERE e.examType = #{examType}
|
|
AND e.startTime < now() AND e.endTime > now()
|
|
AND e.teacherid = #{objid}
|
|
</if>
|
|
ORDER BY examid DESC
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
</mapper> |