315 lines
13 KiB
XML
315 lines
13 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.XKWAssignmentDao">
|
|
<!-- 通用查询映射结果 -->
|
|
<resultMap id="BaseResultMap" type="com._3e.http.practice.dto.XKWAssignment">
|
|
<id column="assignmentid" property="assignmentId"/>
|
|
<result column="teacherid" property="teacherId"/>
|
|
<result column="content" property="content"/>
|
|
<result column="description" property="description"/>
|
|
<result column="created" property="created"/>
|
|
<result column="starttime" property="startTime"/>
|
|
<result column="endtime" property="endTime"/>
|
|
<result column="status" property="status"/>
|
|
<result column="areaid" property="areaId"/>
|
|
<result column="assigntime" property="assignTime"/>
|
|
</resultMap>
|
|
<insert id="doSave">
|
|
INSERT INTO xkw_assignment(
|
|
assignmentId, teacherId, content, description, created, startTime,
|
|
endTime, status, areaId, assignTime)
|
|
VALUES (
|
|
<if test="assignmentId == 0">
|
|
(SELECT NEXTVAL('seq_xkw_assignmentid')),
|
|
</if>
|
|
<if test="assignmentId != 0">
|
|
#{assignmentId},
|
|
</if>
|
|
#{teacherId}, #{content}, #{description}, #{created}, #{startTime},
|
|
#{endTime}, #{status}, #{areaId},#{assignTime});
|
|
</insert>
|
|
<insert id="doSaveXKWAssignToClasses">
|
|
INSERT INTO xkw_assigntoclass(
|
|
classesId, assignmentId, areaId)
|
|
VALUES (#{classesId}, #{assignmentId}, #{areaId})
|
|
</insert>
|
|
<insert id="doSaveXKWAssignDetail">
|
|
INSERT INTO xkw_assigndetail(
|
|
assignDetailId, assignmentId, questionId,areaId,orderId,bookId,unitId,lessonId)
|
|
VALUES (
|
|
<if test="assignDetailId == 0">
|
|
(SELECT NEXTVAL('seq_xkw_assigndetailid')),
|
|
</if>
|
|
<if test="assignDetailId != 0">
|
|
#{assignDetailId},
|
|
</if>
|
|
#{assignmentId}, #{questionId},#{areaId},#{orderId},#{bookId},#{unitId},#{lessonId})
|
|
</insert>
|
|
<insert id="insertOrUpdateFinishXKWAssignStat">
|
|
INSERT INTO finishxkw_assignstat (uid,assignmentId,content,questionCount,completeCount,created,howMuch,areaId,rightCount,wrongCount)
|
|
VALUES (#{uid},#{assignmentId},#{content},#{questionCount},#{completeCount},#{created},#{howMuch},#{areaId},#{rightCount},#{wrongCount})
|
|
ON CONFLICT (uid, assignmentId, areaId) DO UPDATE SET
|
|
content = EXCLUDED.content,
|
|
questionCount = EXCLUDED.questionCount,
|
|
completeCount = EXCLUDED.completeCount,
|
|
created = EXCLUDED.created,
|
|
howMuch = EXCLUDED.howMuch,
|
|
rightCount = EXCLUDED.rightCount,
|
|
wrongCount = EXCLUDED.wrongCount;
|
|
</insert>
|
|
<update id="doSaveUpdate">
|
|
UPDATE xkw_assignment
|
|
<set>
|
|
<if test="teacherId != null">
|
|
teacherId = #{teacherId},
|
|
</if>
|
|
<if test="content != null">
|
|
content = #{content},
|
|
</if>
|
|
<if test="description != null">
|
|
description = #{description},
|
|
</if>
|
|
<if test="created != null">
|
|
created = #{created},
|
|
</if>
|
|
<if test="startTime != null">
|
|
startTime = #{startTime},
|
|
</if>
|
|
<if test="endTime != null">
|
|
endtime = #{endTime},
|
|
</if>
|
|
<if test="status != null">
|
|
status = #{status},
|
|
</if>
|
|
<if test="areaId != null">
|
|
areaid = #{areaId},
|
|
</if>
|
|
</set>
|
|
WHERE assignmentId = #{assignmentId}
|
|
</update>
|
|
<update id="doUpdateXKWAssignment">
|
|
UPDATE xkw_assignment
|
|
<set>
|
|
<if test="teacherId != null">
|
|
teacherId = #{teacherId},
|
|
</if>
|
|
<if test="content != null">
|
|
content = #{content},
|
|
</if>
|
|
<if test="description != null">
|
|
description = #{description},
|
|
</if>
|
|
<if test="created != null">
|
|
created = #{created},
|
|
</if>
|
|
<if test="startTime != null">
|
|
startTime = #{startTime},
|
|
</if>
|
|
<if test="endTime != null">
|
|
endTime = #{endTime},
|
|
</if>
|
|
<if test="status != null">
|
|
status = #{status},
|
|
</if>
|
|
<if test="areaId != null">
|
|
areaId = #{areaId}
|
|
</if>
|
|
</set>
|
|
WHERE assignmentId = #{assignmentId}
|
|
</update>
|
|
|
|
|
|
<select id= "getNextSeq" resultType="int">
|
|
SELECT NEXTVAL('seq_xkw_assignmentid')
|
|
</select>
|
|
<select id="findAllPracticeAssignByClassId" resultType="com._3e.http.practice.dto.XKWAssignment">
|
|
SELECT b.assignmentId , b.teacherId , b.content , b.description ,
|
|
b.created ,b.assignTime,
|
|
b.startTime , b.endTime , b.status , b.areaId,c.className,c.classesId
|
|
FROM xkw_AssignToClass a
|
|
inner join classes c on a.classesId = c.classesId
|
|
INNER JOIN xkw_Assignment b ON a.assignmentId = b.assignmentId
|
|
and a.classesId = #{classesId} AND b.status = 1
|
|
<if test="status== '2'.toString()">
|
|
and b.endtime < NOW()
|
|
</if>
|
|
<if test="status== '1'.toString()">
|
|
and b.endtime > NOW()
|
|
</if>
|
|
ORDER BY b.assignmentId desc
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
<select id="findAllPracticeAssignByClassIdPC" resultType="com._3e.http.practice.dto.XKWAssignment">
|
|
SELECT b.assignmentId , b.teacherId , b.content , b.description ,
|
|
b.created ,b.assignTime,
|
|
b.startTime , b.endTime , b.status , b.areaId,c.className,c.classesId
|
|
FROM xkw_AssignToClass a
|
|
inner join classes c on a.classesId = c.classesId
|
|
INNER JOIN xkw_Assignment b ON a.assignmentId = b.assignmentId
|
|
and a.classesId = #{classesId} AND b.status = 1
|
|
<if test="status== '2'.toString()">
|
|
and b.endtime < NOW()
|
|
</if>
|
|
<if test="status== '1'.toString()">
|
|
and b.endtime > NOW()
|
|
</if>
|
|
ORDER BY b.assignmentId desc
|
|
<if test="page != null">
|
|
LIMIT #{limit} OFFSET #{offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="findAllPracticeAssignByClassIds" resultType="com._3e.http.practice.dto.XKWAssignment">
|
|
SELECT b.assignmentId , b.teacherId , b.content , b.description ,
|
|
b.created ,b.assignTime,
|
|
b.startTime , b.endTime , b.status , b.areaId,c.className,c.classesId
|
|
FROM xkw_AssignToClass a
|
|
inner join classes c on a.classesId = c.classesId
|
|
INNER JOIN xkw_Assignment b ON a.assignmentId = b.assignmentId
|
|
and a.classesId in
|
|
<foreach item="classesId" index="index" collection="classesIds"
|
|
open="(" separator="," close=")">
|
|
#{classesId}
|
|
</foreach>
|
|
AND b.status = 1
|
|
<if test="status== '2'.toString()">
|
|
and b.endtime < NOW()
|
|
</if>
|
|
<if test="status== '1'.toString()">
|
|
and b.endtime > NOW()
|
|
</if>
|
|
ORDER BY b.assignmentId desc
|
|
<if test="page != null">
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
|
</if>
|
|
</select>
|
|
<select id="findXKWAssignment" resultType="com._3e.http.practice.dto.XKWAssignment">
|
|
SELECT * FROM xkw_assignment WHERE assignmentId =#{assignmentId} and status = 1
|
|
</select>
|
|
<select id="findXKWAssignToClass" resultType="com._3e.entity.XKWAssignToClass">
|
|
select classesid AS classesId,
|
|
assignmentid AS assignmentId,
|
|
areaid AS areaId
|
|
from xkw_assigntoclass where assignmentId = #{assignmentId}
|
|
</select>
|
|
<select id="getFinishXKWAssignStatByUidAndAssignmentId" resultType="com._3e.entity.FinishXKWAssignStat">
|
|
select uid,assignmentId,content,questionCount,completeCount,created,howMuch,areaId,rightCount,wrongCount
|
|
from finishxkw_assignstat where uid = #{uid} and assignmentId = #{assignmentId}
|
|
</select>
|
|
<select id="findXKWAssignDetailByAssignmentId" resultType="com._3e.entity.XKWAssignDetail">
|
|
select assignDetailId,assignmentId,questionId,areaId,orderId,bookId,unitId,lessonId from xkw_assigndetail where assignmentId = #{assignmentId} order by orderId
|
|
</select>
|
|
<select id="findXKWDoQuestionsByAssignmentIdAndUid" resultType="com._3e.http.practice.dto.ResQuestionAnswer">
|
|
select l.questionId,l.isRight,d.orderId from xkw_assigndetail d inner join xkw_assignanswer l on d.assignmentId = l.assignmentId
|
|
where d.assignmentId = #{assignmentId} and l.uid = #{uid} and l.created > #{startTime} and l.created < #{endTime}
|
|
</select>
|
|
<select id="findXKWQuestionDetailAndAnswer" resultType="com._3e.http.practice.dto.ResXKWQuestion">
|
|
select q.*,l.answer AS userAnswer from xkw_question q left join xkw_assignanswer l on q.id = l.questionId
|
|
and l.uid = #{uid} and l.assignmentId = #{assignmentId} and l.created > #{startTime} and l.created < #{endTime}
|
|
where q.id = #{questionId}
|
|
</select>
|
|
<select id="findXKWAssignmentTaskStatusV1" resultType="com._3e.http.practice.dto.ResClassXKWAssignmentStatus">
|
|
WITH temp1 as ( select soc.studentId
|
|
from StudentOwnClass soc inner join student s on soc.studentid=s.studentid
|
|
<if test="areaId != null and areaId != 0">
|
|
and s.areaid = #{areaId}
|
|
</if>
|
|
and s.status=1
|
|
where
|
|
<if test="areaId != null and areaId != 0">
|
|
soc.areaId = #{areaId}
|
|
</if>
|
|
and soc.classesId = #{classesId} and soc.status = 1 )
|
|
SELECT a.studentId ,b.completeCount,b.rightCount,b.wrongCount,b.howMuch as total, b.created as lastTime
|
|
FROM temp1 as a
|
|
LEFT JOIN Finishxkw_AssignStat as b
|
|
ON a.studentId = b.uid
|
|
<if test="areaId != null and areaId != 0">
|
|
and b.areaId = #{areaId}
|
|
</if>
|
|
AND b.assignmentId =#{assignmentId}
|
|
ORDER BY b.completeCount desc nulls last,b.howMuch desc nulls last,a.studentId
|
|
</select>
|
|
<select id="findXKWAssignmentTaskStatusPCV1" resultType="com._3e.http.practice.dto.ResClassXKWAssignmentStatus">
|
|
WITH temp1 as ( select soc.studentId
|
|
from StudentOwnClass soc inner join student s on soc.studentid=s.studentid
|
|
<if test="areaId != null and areaId != 0">
|
|
and s.areaid = #{areaId}
|
|
</if>
|
|
and s.status=1
|
|
where
|
|
<if test="areaId != null and areaId != 0">
|
|
soc.areaId = #{areaId}
|
|
</if>
|
|
and soc.classesId = #{classesId} and soc.status = 1 )
|
|
SELECT a.studentId ,b.completeCount,b.rightCount,b.wrongCount,b.howMuch as total, b.created as lastTime
|
|
FROM temp1 as a
|
|
LEFT JOIN Finishxkw_AssignStat as b
|
|
ON a.studentId = b.uid
|
|
<if test="areaId != null and areaId != 0">
|
|
and b.areaId = #{areaId}
|
|
</if>
|
|
AND b.assignmentId =#{assignmentId}
|
|
ORDER BY b.completeCount desc nulls last,b.howMuch desc nulls last,a.studentId
|
|
</select>
|
|
<select id="getFinishXKWAssignStatByAssignmentIdAndUid" resultType="com._3e.entity.FinishXKWAssignStat">
|
|
select la.uid,la.assignmentId,count(distinct la.questionId) as completeCount,la.areaId,
|
|
SUM(CASE WHEN la.isRight = 1 THEN 1 ELSE 0 END) AS rightCount,
|
|
SUM(CASE WHEN la.isRight = 0 THEN 1 ELSE 0 END) AS wrongCount
|
|
from xkw_assignanswer la
|
|
where la.assignmentId = #{assignmentId} and la.uid = #{uid} and la.areaId=#{areaId} and la.created <= #{endTime} and la.created >= #{startTime}
|
|
group by la.uid , la.assignmentId , la.areaid
|
|
</select>
|
|
<select id="getQuestionHowMuch" resultType="java.lang.Integer">
|
|
select count(1)
|
|
from xkw_assigndetail at INNER JOIN xkw_answer la on at.questionId = la.questionId
|
|
where at.assignmentId = #{assignmentId} and la.uid = #{uid} and la.areaId=#{areaId} and la.created <= #{endTime} and la.created >= #{startTime}
|
|
</select>
|
|
<select id="findXKWLastAssignByTeacherId" resultType="com._3e.http.practice.dto.XKWAssignment">
|
|
select * from xkw_assignment where teacherId = #{teacherId} and created between #{startTime} and #{endTime} order by created desc limit 1
|
|
</select>
|
|
<select id="findXKWLastAssignByTeacherIdAndClassesId" resultType="com._3e.http.practice.dto.XKWAssignment">
|
|
select * from xkw_assigntoclass atc inner join
|
|
xkw_assignment a on act.assignmentId = a.assignmentId
|
|
where a.teacherId = #{teacherId} and a.created between #{startTime} and #{endTime}
|
|
and atc.classesid in
|
|
<foreach item="classesId" collection="classesList" separator="," open="(" close=")">
|
|
#{classesId}
|
|
</foreach>
|
|
order by created desc limit 1
|
|
</select>
|
|
<select id="getAssignedByClassesIds" resultType="java.lang.Long">
|
|
select DISTINCT(atc.classesId) from xkw_assigntoclass atc inner join
|
|
xkw_assigndetail ad on atc.assignmentId = ad.assignmentId and ad.questionId = #{questionId}
|
|
where atc.classesId in
|
|
<foreach item="classesId" index="index" collection="classesIds" open="(" separator="," close=")">
|
|
#{classesId}
|
|
</foreach>
|
|
</select>
|
|
<select id="findXKWAssignmentBookUnitLesson" resultType="com._3e.http.practice.dto.XKWAssignmentBookUnitLesson">
|
|
with temp as (select assignmentId,bookId,unitId,lessonId from xkw_assigndetail where assignmentId = #{assignmentId} limit 1)
|
|
select b.id AS bookId,b.name AS bookName,u.id AS unitId,u.name AS unitName,
|
|
COALESCE(l.id, 0) AS lessonId,
|
|
COALESCE(l.name, '') AS lessonName,d.assignmentId from temp d INNER JOIN xkw_parameter b on d.bookId = b.id and b.paraType = 'textbooks'
|
|
INNER JOIN xkw_parameter u on d.unitId = u.id and u.paratype = 'catalog'
|
|
left JOIN xkw_parameter l on d.lessonId = l.id and l.paratype = 'catalog'
|
|
|
|
</select>
|
|
<select id="getLastuserAnswer" resultType="java.lang.String">
|
|
select answer from xkw_answer
|
|
where uid = #{uid} and questionId = #{questionId} and bookId = #{bookId} and unitId = #{unitId} and lessonId = #{lessonId}
|
|
<if test="areaId != null">
|
|
and areaId=#{areaId}
|
|
</if>
|
|
order by created desc limit 1
|
|
</select>
|
|
<select id="getXKWQuestionAnswer" resultType="com._3e.http.practice.dto.XKWAssignAnswer">
|
|
select * from xkw_assignanswer where questionId = #{questionId} and uid = #{uid} order by created desc limit 1
|
|
</select>
|
|
|
|
|
|
</mapper> |