2026-03-10 14:30:24 +08:00

1056 lines
40 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="Assignment">
<resultMap id="BaseResultMap" type="Assignment">
<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="packageName" property="packageName"/>
<result column="assignType" property="assignType"/>
<result column="assigntime" property="assigntime"/>
<result property="pointcasetypes" column="pointcasetypes" jdbcType="ARRAY"
typeHandler="com.spoken.api.handlers.ArrayTypeHandlerPg"/>
</resultMap>
<resultMap id="BaseResultMapForDto" type="AssignmentDto">
<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="packageName" property="packageName"/>
<result column="assignType" property="assignType"/>
<result column="className" property="className"/>
<result column="classesId" property="classesId"/>
<result column="assigntime" property="assigntime"/>
<result property="pointcasetypes" column="pointcasetypes" jdbcType="ARRAY"
typeHandler="com.spoken.api.handlers.ArrayTypeHandlerPg"/>
</resultMap>
<resultMap id="BaseResultMap1" type="Assignment">
<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="packageName" property="packageName"/>
<result column="assignType" property="assignType"/>
<result column="assigntime" property="assigntime"/>
</resultMap>
<select id="findAssignByClassid" parameterType="java.util.Map"
resultType="ResAssignment">
SELECT b.assignmentid,b.content,b.description,b.starttime,
b.endtime,b.assigntype,l.classname,l.classesid,b.assigntime
FROM ASSIGNMENT b
inner JOIN assigntoclass C ON b.assignmentid = C.assignmentid
LEFT JOIN classes l ON c.classesid = l.classesid
WHERE b.status = 1 AND C.classesid = #{classid}
<if test="status == '1'.toString()">
and now() &lt;= b.endtime
</if>
<if test="status == '2'.toString()">
and now() &gt; b.endtime
</if>
<if test="assigntype!=null">
and b.assigntype=#{assigntype}
</if>
ORDER BY b.created DESC
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findAssignByClassidCount" parameterType="java.util.Map"
resultType="java.lang.Integer">
SELECT count(*)
FROM ASSIGNMENT b
inner JOIN assigntoclass C ON b.assignmentid = C.assignmentid
LEFT JOIN classes l ON c.classesid = l.classesid
WHERE b.status = 1 AND C.classesid = #{classid}
<if test="status == '1'.toString()">
and now() &lt;= b.endtime
</if>
<if test="status == '2'.toString()">
and now() &gt; b.endtime
</if>
<if test="assigntype!=null">
and b.assigntype=#{assigntype}
</if>
</select>
<select id="findUserVoice" parameterType="java.util.Map" resultType="ResClassUserVoices">
select row_number,created,voiceid,avatar,truename,studentid from(
SELECT row_number()over(PARTITION by d.uid ORDER BY d.likecount desc) as row_number ,
a.*,d.voiceid,b.studentid,b.avatar,b.truename,ata.unitid from assignment a,assigndetail ata,dubuservoice d,v_studentclass b
where a.assignmentid=ata.assignmentid and ata.unitid=d.videoid and d.uid=b.studentid and
a.assigntype=#{assigntype} and d.created &lt; a.endtime and d.created &gt; a.starttime and b.classesid=#{classesId}
and a.assignmentid=#{assignmentid}) r
where row_number=1
</select>
<select id="findUserVoiceOrederByCreated" parameterType="java.util.Map" resultType="ResClassUserVoices">
select row_number,created,voiceid,avatar,truename,studentid ,score,accuracy,fluent,integrity from(
SELECT row_number()over(PARTITION by d.uid ORDER BY d.created desc) as row_number ,
d.created,d.voiceid,b.studentid,b.avatar,b.truename,ata.unitid ,d.score,d.accuracy,d.fluent,d.integrity from assignment a,assigndetail ata,dubuservoice d,v_studentclass b
where a.assignmentid=ata.assignmentid and ata.unitid=d.videoid and d.uid=b.studentid and
a.assigntype=#{assigntype} and d.created &lt; a.endtime and d.created &gt; a.starttime and b.classesid=#{classesId}
and a.assignmentid=#{assignmentid}) r
where row_number=1
</select>
<select id="findAllAssignByAllClass" parameterType="java.util.Map"
resultType="ResAssignment">
SELECT b.assignmentid,b.content,b.description,b.starttime,b.created,
b.endtime,b.assigntype,l.className,l.classesid,b.assigntime
FROM ASSIGNMENT b
inner JOIN assigntoclass C ON b.assignmentid = C.assignmentid
LEFT JOIN classes l ON c.classesid = l.classesid
WHERE b.status = '1'
<if test="classesList != null">
AND C.classesid in
<foreach item="classes" index="index" collection="classesList"
open="(" separator="," close=")">
#{classes.classesId}
</foreach>
</if>
<if test="status == 1">
and now() &lt;= b.endtime
</if>
<if test="status == 2">
and now() &gt; b.endtime
</if>
<if test="assigntype!=null">
and b.assigntype=#{assigntype}
</if>
ORDER BY b.created DESC
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findAllAssignByAllClassForComplete" parameterType="java.util.Map"
resultType="ResAssignment">
SELECT b.assignmentid,b.content,b.description,b.starttime,b.created,
b.endtime,b.assigntype,l.className,l.classesid
FROM ASSIGNMENT b
inner JOIN assigntoclass C ON b.assignmentid = C.assignmentid
LEFT JOIN classes l ON c.classesid = l.classesid inner join finiassignstat as d on d.assignmentid = C.assignmentid and d.uid = #{studentId} and d.areaid= #{areaId}
WHERE b.status = '1'
<if test="classesList != null">
AND C.classesid in
<foreach item="classes" index="index" collection="classesList"
open="(" separator="," close=")">
#{classes.classesId}
</foreach>
</if>
<if test="status == 1">
and now() &lt;= b.endtime
</if>
<if test="status == 2">
and now() &gt; b.endtime
</if>
<if test="assigntype!=null">
and b.assigntype=#{assigntype}
</if>
ORDER BY b.created DESC
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findAllAssignByAllClassCount" parameterType="java.util.Map"
resultType="java.lang.Integer">
SELECT count(*)
FROM ASSIGNMENT b
inner JOIN assigntoclass C ON b.assignmentid = C.assignmentid
LEFT JOIN classes l ON c.classesid = l.classesid
WHERE b.assignmentid = C.assignmentid
AND b.status = '1'
<if test="classesList != null">
AND C.classesid in
<foreach item="classes" index="index" collection="classesList"
open="(" separator="," close=")">
#{classes.classesId}
</foreach>
</if>
<if test="status == 1">
and now() &lt;= b.endtime
</if>
<if test="status == 2">
and now() &gt; b.endtime
</if>
<if test="assigntype!=null">
and b.assigntype=#{assigntype}
</if>
</select>
<insert id="insertAssignment" parameterType="Assignment">
INSERT INTO Assignment ( assignmentId, teacherId, content, description, created, startTime, endTime, status , areaid
<if test="pointcasetypes != null">
,pointcasetypes
</if> , assignType, packageName,assigntime
)
Values ( #{assignmentId}, #{teacherId}, #{content}, #{description},current_timestamp, #{startTime}, #{endTime}, #{status} , #{areaid}
<if test="pointcasetypes != null">
,#{pointcasetypes,jdbcType=ARRAY, typeHandler=com.spoken.api.handlers.ArrayTypeHandlerPg}
</if>
,#{assignType} , #{packageName},#{assigntime})
</insert>
<update id="updateAssignment" parameterType="Assignment">
update 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>
<if test="packageName != null">
packageName = #{packageName},
</if>
<if test="assignType != null">
assignType = #{assignType},
</if>
<if test="assigntime != null">
assigntime = #{assigntime},
</if>
</set>
where assignmentId=#{assignmentId}
</update>
<!-- <select id="getAssignmentByKey" parameterType="java.lang.Integer" resultType="Assignment">-->
<select id="getAssignmentByKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
SELECT assignmentId , teacherId , content , description , created , startTime , endTime , status , areaid , packageName , assignType,pointcasetypes,assigntime
FROM Assignment WHERE assignmentId=#{assignmentId}
</select>
<select id="getSeqAssignment" resultType="Integer" useCache="false" flushCache="true">
SELECT nextval('seq_assignmentId') ;
</select>
<select id="getAssignmentDtosCountByTeacherId" parameterType="java.util.Map" resultType="Integer">
SELECT count( a.assignmentId ) as howmuch
FROM Assignment a
INNER JOIN AssignToClass b
on a.assignmentId = b.assignmentId
inner join classes c on b.classesid=c.classesid and c.status=1
<if test="classesId != null">AND
c.classesId = #{classesId}
</if>
WHERE a.status = 1
AND a.teacherId=#{teacherId}
<if test="areaid != null">AND
a.areaid = #{areaid}
</if>
<if test="nowTime != null">AND
a.endTime &gt; #{nowTime}
</if>
<if test="assignType != null">AND
a.assignType=#{assignType}
</if>
</select>
<select id="getAssignmentDtosByTeacherId" parameterType="java.util.Map" resultMap="BaseResultMapForDto">
SELECT distinct a.assignmentId , a.teacherId , a.content , a.description , a.created , a.startTime , a.endTime ,
a.status , a.areaid , a.packageName, a.assignType,c.classesId,c.className,a.pointcasetypes,a.assigntime
FROM Assignment a
INNER JOIN AssignToClass b
on a.assignmentId = b.assignmentId
inner join classes c on b.classesid=c.classesid and c.status=1
<if test="classesId != null">AND
c.classesId = #{classesId}
</if>
WHERE a.status = 1
AND a.teacherId=#{teacherId}
<if test="areaid != null">AND
a.areaid = #{areaid}
</if>
<if test="nowTime != null">AND
a.endTime &gt; #{nowTime}
</if>
<if test="assignType != null">AND
a.assignType=#{assignType}
</if>
and a.assignType != 'S'
ORDER BY a.assignmentId desc , c.classesId
<if test="pageSize != null">
LIMIT #{pageSize} OFFSET #{offset}
</if>
</select>
<select id="getAssignmentsCountByTeacherId" parameterType="java.util.Map" resultType="Integer">
SELECT count( a.assignmentId ) as howmuch
FROM Assignment a
WHERE a.status = 1
AND a.teacherId=#{teacherId}
<if test="areaid != null">AND
a.areaid = #{areaid}
</if>
<if test="nowTime != null">AND
a.endTime &gt; #{nowTime}
</if>
</select>
<select id="getAssignmentsCountByTeacherIds" parameterType="java.util.Map" resultType="Integer">
SELECT count( a.assignmentId ) as howmuch
FROM Assignment a
WHERE a.status = 1
AND a.teacherId in
<foreach collection="teacherIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
<if test="areaid != null">AND
a.areaid = #{areaid}
</if>
<if test="nowTime != null">AND
a.endTime &gt; #{nowTime}
</if>
</select>
<!-- <select id="getAssignmentsByTeacherId" parameterType="java.util.Map" resultType="Assignment">-->
<select id="getAssignmentsByTeacherId" parameterType="java.util.Map" resultMap="BaseResultMap">
SELECT a.assignmentId , a.teacherId , a.content , a.description , a.created , a.startTime , a.endTime , a.status , a.areaid , a.packageName, a.assignType,a.pointcasetypes,a.assigntime
FROM Assignment a
WHERE a.status = 1
AND a.teacherId=#{teacherId}
<if test="areaid != null">AND
a.areaid = #{areaid}
</if>
<if test="nowTime != null">AND
a.endTime &gt; #{nowTime}
</if>
and a.assignType != 'S' and a.assignType != 'D'
ORDER BY a.assignmentId desc
LIMIT #{pageSize} OFFSET #{offset}
</select>
<select id="getAssignmentsByTeacherIds" parameterType="java.util.Map" resultMap="BaseResultMap">
SELECT a.assignmentId , a.teacherId , a.content , a.description , a.created , a.startTime , a.endTime , a.status , a.areaid , a.packageName, a.assignType,a.pointcasetypes,a.assigntime
FROM Assignment a
WHERE a.status = 1
AND a.teacherId in
<foreach collection="teacherIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
<if test="areaid != null">AND
a.areaid = #{areaid}
</if>
<if test="nowTime != null">AND
a.endTime &gt; #{nowTime}
</if>
and a.assignType != 'S' and a.assignType != 'D'
ORDER BY a.assignmentId desc
LIMIT #{pageSize} OFFSET #{offset}
</select>
<select id="getAssignmentsCountByStudentId" parameterType="java.util.Map" resultType="Integer">
SELECT count(a.assignmentId) as howmuch
FROM Assignment a inner join AssignToClass b on a.assignmentId = b.assignmentId
inner join StudentOwnClass so on so.classesid = b.classesid and so.status = 1
inner join Classes c on c.classesid = so.classesid and c.status = 1
WHERE so.studentid =#{studentId} and a.status = 1 and so.areaId=#{areaid}
<if test="classesId != null">AND
b.classesId = #{classesId}
</if>
<if test="nowTime != null">AND
a.endTime &gt; #{nowTime}
</if>
<if test="assignType != null">AND
a.assignType=#{assignType}
</if>
</select>
<select id="getAssignmentsByStudentId" parameterType="java.util.Map" resultMap="BaseResultMapForDto">
SELECT a.assignmentId , a.teacherId , a.content , a.description , a.created , a.startTime ,
a.endTime , a.status , a.areaid , a.packageName, a.assignType,c.classesId,c.className,a.pointcasetypes,a.assigntime
FROM Assignment a inner join AssignToClass b on a.assignmentId = b.assignmentId
inner join StudentOwnClass so on so.classesid = b.classesid and so.status = 1
inner join Classes c on c.classesid = so.classesid and c.status = 1
WHERE so.studentid =#{studentId} and a.status = 1 and so.areaid=#{areaid}
<if test="classesId != null">
AND b.classesId = #{classesId}
</if>
<if test="nowTime != null">AND
a.endTime &gt; #{nowTime}
</if>
<if test="assignType != null">AND
a.assignType=#{assignType}
</if>
AND a.assignType != 'S'
ORDER BY a.assignmentId desc , c.classesId
<if test="pageSize != null">
LIMIT #{pageSize} OFFSET #{offset}
</if>
</select>
<update id="assignmentBatchUpdateByAssignmentId" parameterType="java.util.List">
UPDATE Assignment SET status = 0
WHERE assignmentId in
<foreach collection="list" index="index" item="item" separator="," close=")" open="(">
#{item}
</foreach>
</update>
<select id="getLastAssignment" parameterType="Long" resultType="Assignment">
SELECT b.assignmentId , b.teacherId , b.content , b.description , b.created , b.startTime , b.endTime , b.status , b.areaid , b.packageName , b.assignType
FROM AssignToClass a
INNER JOIN Assignment b
ON a.classesId = #{classesId} AND a.assignmentId = b.assignmentId
AND b.status = 1
ORDER BY b.assignmentId desc
LIMIT 1
</select>
<select id="getAssignmentsCountByClassesId" parameterType="java.lang.Long" resultType="Integer">
SELECT count(*) as howmuch
FROM AssignToClass a
INNER JOIN Assignment b
ON a.classesId = #{classesId}
AND a.assignmentId = b.assignmentId
AND b.status = 1 and b.assignType in ('W','L')
</select>
<select id="findDubVideoClassesByTeacherId" parameterType="java.util.Map" resultType="DubAssignDto">
select ad.unitid videoId,string_agg(c.classesid::text, ',') AS classesIds
from assignment a INNER JOIN assigntoclass ac on a.assignmentid = ac.assignmentid
INNER JOIN classes c on ac.classesid = c.classesid
INNER JOIN assigndetail ad on a.assignmentid = ad.assignmentid
where c.teacherId = #{teacherId} and a.status =1 and a.assigntype=#{assignType} and a.starttime > #{startTime} and a.endtime &lt; #{endTime}
GROUP BY ad.unitid
</select>
<!-- <select id="getAssignmentsByClassesId" parameterType="java.util.Map" resultType="Assignment"> ,b.pointcasetypes-->
<select id="getAssignmentsByClassesId" parameterType="java.util.Map" resultMap="BaseResultMap">
<!--<select id="getAssignmentsByClassesId" parameterType="java.util.Map" resultMap="BaseResultMap1">-->
SELECT b.assignmentId , b.teacherId , b.content , b.description , b.created ,
b.startTime , b.endTime , b.status , b.areaid ,b.packageName , b.assignType,b.pointcasetypes,b.assigntime
FROM AssignToClass a
INNER JOIN Assignment b
ON a.classesId = #{classesId}
AND a.assignmentId = b.assignmentId
AND b.status = 1 and b.assignType in ('W','L')
ORDER BY b.assignmentId desc
LIMIT #{pageSize} OFFSET #{offset}
</select>
<select id="getAssignmentsByClassesIdForPC" parameterType="java.util.Map" resultMap="BaseResultMap">
SELECT b.assignmentId , b.teacherId , b.content , b.description , b.created ,
b.startTime , b.endTime , b.status , b.areaid ,b.packageName , b.assignType,case when b.assignType ='W' then ARRAY[]::smallint[] else b.pointcasetypes end as pointcasetypes,b.assigntime
FROM AssignToClass a
INNER JOIN Assignment b
ON a.classesId = #{classesId}
AND a.assignmentId = b.assignmentId
AND b.status = 1 and b.assignType in ('W','L')
ORDER BY b.assignmentId desc
LIMIT #{pageSize} OFFSET #{offset}
</select>
<!-- <select id="getPreviousAssignByStudentId" parameterType="java.util.Map" resultType="AssignmentDto">-->
<select id="getPreviousAssignByStudentId" parameterType="java.util.Map" resultMap="BaseResultMapForDto">
with classesids as (select b.classesid ,c.className from student as a inner join studentownclass as b on a.studentid = b.studentid and b.status = 1 inner join classes as c on c.classesid = b.classesid where a.studentid =#{studentId} group by b.classesid,c.className),
exams as ( select a.examId,a.classesId ,b.className from classownsouth as a INNER JOIN classesids as b on a.classesid = b.classesid ),
Answers as (select examId,score,trueScore,avgScore,lastTime from finishSouthStat where uid = #{studentId}),
resdata as (select e.examid assignmentId,e.teacherId,title as content,e.description,isOral,e.created as finishTime,e.created,
starttime,endtime,1 as status,cs.areaId,null as packageName,'E' as assignType,cs.classesId,cs.className,e.examType,0.0 as score,0.0 as trueScore,0.0 as avgScore, null as exampapers,e.type,ARRAY[]::smallint[] as pointcasetypes from exam e
inner join
classownexam c on e.examid=c.examid and c.objecttype=1
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="expires==null">
and endtime&gt;=now()
</if>
<if test="expires!=null">
and endtime&lt;now()
</if>
inner join
studentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1 and s.areaid=#{areaId}
inner join
classes cs on cs.classesid=s.classesid and cs.status=1
union all
select e.examid assignmentId,e.teacherId ,title as content,e.description,-1 as isOral,e.created as finishTime,
e.created,startTime,endTime,1 as status,cs.areaId,null as packageName,'E' as assignType,cs.classesId,cs.className,e.examType,0.0 as score,0.0 as trueScore,0.0 as avgScore, null as exampapers,0 as type ,ARRAY[]::smallint[] as pointcasetypes from hearexam e
inner join
classownhear c on e.examid=c.examid and c.objecttype=1
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="expires==null">
and endtime&gt;=now()
</if>
<if test="expires!=null">
and endtime&lt;now()
</if>
inner join
studentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1 and s.areaId=#{areaId}
inner join
classes cs on cs.classesid=s.classesid and cs.status=1
union all
SELECT a.assignmentId , a.teacherId , a.content , a.description ,null as isOral,a.created as finishTime, a.created , a.startTime ,
a.endTime , a.status , a.areaid , a.packageName , a.assignType ,cs.classesId,cs.className,null as examType,0.0 as score,0.0 as trueScore,0.0 as avgScore, null as exampapers ,0 as type ,a.pointcasetypes from assignment a
inner join
assigntoclass b on a.assignmentid=b.assignmentid
and a.assignType in ('W','L')
<if test="expires==null">
and endtime&gt;=now()
</if>
<if test="expires!=null">
and endtime&lt;now()
</if> and a.status=1
inner join
studentownclass s on s.classesid=b.classesid and s.studentid=#{studentId} and s.status=1 and s.areaId=#{areaId}
inner join
classes cs on cs.classesid=s.classesid and cs.status=1
<if test="isAi != null">
union all
select a.examId as assignmentId, a.teacherId,a.title as content,a.description,null as isOral,c.lastTime as finishTime,a.created,a.startTime,a.endTime,a.status, 0 as areaId ,null as packageName,'A' as assignType,b.classesid, b.className,a.examType,c.score,c.trueScore,c.avgScore,a.exampapers,0 as type,ARRAY[]::smallint[] as pointcasetypes from SouthExam as a inner join exams as b on a.examId = b.examId left join Answers as c on a.examId = c.examId where (a.status = 1 and a.endTime &lt; current_timestamp) or a.status =0 group by a.examId,a.teacherId,a.title,a.description,a.isOral,a.created,a.startTime,a.endTime,a.status,areaId,packageName,assignType,b.classesid,b.className,a.examType,c.score,c.lastTime ,c.trueScore,c.avgScore,a.exampapers,type,pointcasetypes
</if>
)
select * from resdata
order by created desc,content desc,assignmentid desc,classesId LIMIT #{pageSize} OFFSET #{offset}
</select>
<select id="getPreviousAssignByStudentIdCount" parameterType="java.util.Map" resultType="java.lang.Integer">
with temp1 as ( select count (e.examid) howmuch from exam e
inner join
classownexam c on e.examid=c.examid and c.objecttype=1
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="expires==null">
and endtime&gt;=now()
</if>
<if test="expires!=null">
and endtime&lt;now()
</if>
inner join
studentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1 and s.areaId=#{areaId}
inner join
classes cs on cs.classesid=s.classesid and cs.status=1
),
temp2 as ( select count(e.examid) howmuch from hearexam e
inner join
classownhear c on e.examid=c.examid and c.objecttype=1
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="expires==null">
and endtime&gt;=now()
</if>
<if test="expires!=null">
and endtime&lt;now()
</if>
inner join
studentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1 and s.areaId=#{areaId}
inner join
classes cs on cs.classesid=s.classesid and cs.status=1
),
temp3 as (select count(a.assignmentid) howmuch from assignment a
inner join
assigntoclass b on a.assignmentid=b.assignmentid
and a.assignType in ('W','L')
<if test="expires==null">
and endtime&gt;=now()
</if>
<if test="expires!=null">
and endtime&lt;now()
</if> and a.status=1
inner join
studentownclass s on s.classesid=b.classesid and s.studentid=#{studentId} and s.status=1 and s.areaId=#{areaId}
inner join
classes cs on cs.classesid=s.classesid and cs.status=1 ),
classesids as (select b.classesid ,c.className from student as a inner join studentownclass as b on a.studentid = b.studentid and b.status = 1 inner join classes as c on c.classesid = b.classesid where a.studentid =#{studentId} group by b.classesid,c.className),
exams as ( select a.examId,a.classesId ,b.className from classownsouth as a INNER JOIN classesids as b on a.classesid = b.classesid )
<if test="isAi != null">
,temp4 as ( select count(*) as howmuch from SouthExam as a inner join exams as b on a.examId = b.examId where (a.status = 1 and a.endTime &lt; current_timestamp) or a.status =0 )
select temp1.howmuch+temp2.howmuch+temp3.howmuch+temp4.howmuch from temp1,temp2,temp3,temp4
</if>
<if test="isAi == null">
select temp1.howmuch+temp2.howmuch+temp3.howmuch from temp1,temp2,temp3
</if>
</select>
<select id="getAssignExamBystudentId" parameterType="java.util.Map" resultType="AssignmentDto">
select e.examid assignmentId,e.teacherId,title as content,e.description,isOral,e.created,starttime,endtime,
1 as status,cs.areaId,null as packageName,'E' as assignType,cs.classesId,cs.className,e.examType,e.exampapers ,e.assigntime from exam e
inner join
classownexam c on e.examid=c.examid and c.objecttype=1
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="type != null">
and e.type = #{type}
</if>
<if test="expires==null">
and endtime&gt;=now()
</if>
<if test="expires!=null">
and endtime&lt;now()
</if>
inner join
studentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1 and s.areaId=#{areaId}
inner join
classes cs on cs.classesid=s.classesid and cs.status=1
<!-- union all-->
<!-- select e.examid assignmentId,e.teacherId ,title as content,e.description,-1 as isOral,e.created,-->
<!-- startTime,endTime,1 as status,cs.areaId,null as packageName,'E' as assignType,cs.classesId,cs.className,e.examType ,e.hearpaperid as examPapers from hearexam e-->
<!-- inner join-->
<!-- classownhear c on e.examid=c.examid and c.objecttype=1-->
<!-- <if test="examType!=null">-->
<!-- and examtype=#{examType}-->
<!-- </if>-->
<!-- <if test="expires==null">-->
<!-- and endtime&gt;=now()-->
<!-- </if>-->
<!-- <if test="expires!=null">-->
<!-- and endtime&lt;now()-->
<!-- </if>-->
<!-- inner join-->
<!-- studentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1 and s.areaId=#{areaId}-->
<!-- inner join-->
<!-- classes cs on cs.classesid=s.classesid and cs.status=1-->
order by created desc,content desc,assignmentid desc,classesId
<if test="pageSize!=null">
LIMIT #{pageSize} OFFSET #{offset}
</if>
</select>
<select id="getAssignExamBystudentIdCount" parameterType="java.util.Map" resultType="java.lang.Integer">
with temp1 as ( select count (e.examid) howmuch from exam e
inner join
classownexam c on e.examid=c.examid and c.objecttype=1
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="expires==null">
and endtime&gt;=now()
</if>
<if test="type!=null">
and type = #{type}
</if>
<if test="expires!=null">
and endtime&lt;now()
</if>
inner join
studentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1 and s.areaId=#{areaId}
inner join
classes cs on cs.classesid=s.classesid and cs.status=1
),
temp2 as ( select count(e.examid) howmuch from hearexam e
inner join
classownhear c on e.examid=c.examid and c.objecttype=1
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="expires==null">
and endtime&gt;=now()
</if>
<if test="expires!=null">
and endtime&lt;now()
</if>
inner join
studentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1 and s.areaId=#{areaId}
inner join
classes cs on cs.classesid=s.classesid and cs.status=1
)
select temp1.howmuch+temp2.howmuch from temp1,temp2
</select>
<select id="getAssignExamByTeacherId" parameterType="java.util.Map" resultType="AssignmentDto">
select e.examid assignmentId,e.teacherId,e.title as content,e.description,e.isOral,
e.created,e.starttime,e.endtime,1 as status,null as packageName,'E' as assignType,cs.classesId,cs.className,e.examType,e.examPapers ,e.assigntime from exam e
inner join
classownexam c on e.examid=c.examid and c.objecttype=1
and teacherId = #{teacherId}
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="type != null">
and type = #{type}
</if>
<if test="expires==null">
and endtime&gt;=now()
</if>
<if test="expires!=null">
and endtime&lt;now()
</if>
inner join
classes cs on cs.classesid=c.classesid and cs.status=1
<if test="classesId!=null">
and cs.classesId=#{classesId}
</if>
<!-- union all-->
<!-- select e.examid assignmentId,e.teacherId ,e.title as content,e.description,-1 as isOral,-->
<!-- e.created,e.startTime,e.endTime,1 as status,null as packageName,'E' as assignType,cs.classesId,cs.className,e.examType,e.hearpaperid as examPapers from hearexam e-->
<!-- inner join-->
<!-- classownhear c on e.examid=c.examid and teacherId = #{teacherId} and c.objecttype=1-->
<!-- <if test="examType!=null">-->
<!-- and examtype=#{examType}-->
<!-- </if>-->
<!-- <if test="expires==null">-->
<!-- and endtime&gt;=now()-->
<!-- </if>-->
<!-- <if test="expires!=null">-->
<!-- and endtime&lt;now()-->
<!-- </if>-->
<!-- inner join-->
<!-- classes cs on cs.classesid=c.classesid and cs.status=1-->
<!-- <if test="classesId!=null">-->
<!-- and cs.classesId=#{classesId}-->
<!-- </if>-->
order by created desc,content desc,assignmentid desc,classesId
<if test="pageSize!=null">
LIMIT #{pageSize} OFFSET #{offset}
</if>
</select>
<select id="getAssignExamByTeacherIdCount" parameterType="java.util.Map" resultType="java.lang.Integer">
with temp1 as ( select count (e.examid) howmuch from exam e
inner join
classownexam c on e.examid=c.examid and c.objecttype=1
and teacherId = #{teacherId}
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="expires==null">
and endtime&gt;=now()
</if>
<if test="type != null">
and type = #{type}
</if>
<if test="expires!=null">
and endtime&lt;now()
</if>
<if test="classesId!=null">
and c.classesId=#{classesId}
</if>
inner join Classes cs on c.classesid = cs.classesid and cs.status = 1
),
temp2 as ( select count(e.examid) howmuch from hearexam e
inner join
classownhear c on e.examid=c.examid and c.objecttype=1
and teacherId = #{teacherId}
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="expires==null">
and endtime&gt;=now()
</if>
<if test="expires!=null">
and endtime&lt;now()
</if>
<if test="classesId!=null">
and c.classesId=#{classesId}
</if>
inner join Classes cs on c.classesid = cs.classesid and cs.status = 1
)
select temp1.howmuch+temp2.howmuch from temp1,temp2
</select>
<select id="getPreviousAssignByTeacherId" parameterType="java.util.Map" resultMap="BaseResultMapForDto">
with classesids as (select classesid,className from classes where teacherid = #{teacherId} and status =1),
exams as ( select a.examId,a.classesId ,b.className from classownsouth as a INNER JOIN classesids as b on a.classesid = b.classesid ),
Answers as (select examId,score,trueScore,avgScore,lastTime from finishSouthStat where uid = #{teacherId}),
resdata as ( select e.examid assignmentId,e.teacherId,title as content,e.description,isOral,e.created,starttime,endtime,e.created as finishTime,
1 as status,0 areaId,null as packageName,'E' as assignType,cs.classesId,cs.className,e.examType,0.0 as score,0.0 as trueScore,0.0 as avgScore, null as exampapers,e.type, ARRAY[]::smallint[] as pointcasetypes,e.assigntime
from exam e
inner join
classownexam c on e.examid=c.examid and c.objecttype=1
<if test="teacherId!=null">
and e.teacherId=#{teacherId}
</if>
<if test="examType!=null">
and examtype=#{examType}
</if>
<!-- <if test="expires==null">
and endtime&gt;=now()
</if> -->
<if test="expires!=null">
and endtime&lt;now()
</if>
inner join
classes cs on cs.classesid=c.classesid and cs.status=1
<if test="classesId!=null">
and cs.classesId=#{classesId}
</if>
union all
select distinct (e.examid) assignmentId,e.teacherId ,title as content,e.description,-1 as isOral,
e.created,startTime,endTime,e.created as finishTime,1 as status,0 areaId,null as packageName,'E' as assignType,cs.classesId,cs.className,e.examType,0.0 as score,0.0 as trueScore,0.0 as avgScore, null as exampapers ,0 as type, ARRAY[]::smallint[] as pointcasetypes,0 as assigntime
from hearexam e
inner join
classownhear c on e.examid=c.examid and c.objecttype=1
<if test="teacherId!=null">
and e.teacherId=#{teacherId}
</if>
<if test="examType!=null">
and examtype=#{examType}
</if>
<!-- <if test="expires==null">
and endtime&gt;=now()
</if> -->
<if test="expires!=null">
and endtime&lt;now()
</if>
inner join
classes cs on cs.classesid=c.classesid and cs.status=1
<if test="classesId!=null">
and cs.classesId=#{classesId}
</if>
union all
SELECT a.assignmentId , a.teacherId , a.content , a.description ,null as isOral,a.created , a.startTime , a.endTime ,a.created as finishTime,
a.status , a.areaid , a.packageName , a.assignType,cs.classesId,cs.className,null as examType,0.0 as score,0.0 as trueScore,0.0 as avgScore, null as exampapers ,0 as type , a.pointcasetypes,a.assigntime from assignment a
inner join assigntoclass c on a.assignmentid=c.assignmentid
<if test="teacherId!=null">
and teacherId=#{teacherId}
</if>
and a.assignType in ('W','L')
<!-- <if test="expires==null">
and endtime&gt;=now()
</if> -->
<if test="expires!=null">
and endtime&lt;now()
</if> and status=1
inner join
classes cs on cs.classesid=c.classesid and cs.status=1
<if test="classesId!=null">
and cs.classesId=#{classesId}
</if>
<if test="isAi != null">
union all
select a.examId as assignmentId, a.teacherId,a.title as content,a.description,null as isOral,a.created,a.startTime,a.endTime,c.lastTime as finishTime,a.status, 0 as areaId ,null as packageName,'A' as assignType,b.classesid, b.className,a.examType,c.score,c.trueScore,c.avgScore,a.exampapers,0 as type, ARRAY[]::smallint[] as pointcasetypes ,0 as assigntime from SouthExam as a inner join exams as b on a.examId = b.examId left join Answers as c on a.examId = c.examId where (a.status = 1 and a.endTime &lt; current_timestamp) or a.status =0 group by c.lastTime,a.examId,a.teacherId,a.title,a.description,a.isOral,a.created,a.startTime,a.endTime,c.lastTime,a.status,areaId,packageName,assignType,b.classesid,b.className,a.examType,c.score,c.trueScore,c.avgScore,a.exampapers,type,pointcasetypes,assigntime
</if>
)
select * from resdata order by created desc,content desc,assignmentid desc,classesId LIMIT #{pageSize} OFFSET #{offset}
</select>
<select id="getPreviousAssignByTeacherIdCount" parameterType="java.util.Map" resultType="java.lang.Integer">
with temp1 as ( select count (e.examid) howmuch from exam e
inner join
classownexam c on e.examid=c.examid and c.objecttype=1
<if test="teacherId!=null">
and e.teacherId=#{teacherId}
</if>
<if test="examType!=null">
and examtype=#{examType}
</if>
<!-- <if test="expires==null">
and endtime&gt;=now()
</if> -->
<if test="expires!=null">
and endtime&lt;now()
</if>
<if test="classesId!=null">
and c.classesId=#{classesId}
</if>
inner join Classes cs on c.classesid = cs.classesid and cs.status = 1
),
temp2 as ( select count(e.examid) howmuch from hearexam e
inner join
classownhear c on e.examid=c.examid and c.objecttype=1
<if test="teacherId!=null">
and teacherId=#{teacherId}
</if>
<if test="examType!=null">
and examtype=#{examType}
</if>
<!-- <if test="expires==null">
and endtime&gt;=now()
</if> -->
<if test="expires!=null">
and endtime&lt;now()
</if>
<if test="classesId!=null">
and c.classesId=#{classesId}
</if>
inner join Classes cs on c.classesid = cs.classesid and cs.status = 1
),
temp3 as ( select count(a.assignmentid) howmuch from assignment a
inner join
assigntoclass c on a.assignmentid=c.assignmentid
<if test="teacherId!=null">
and teacherId=#{teacherId}
</if>
and a.assignType in ('W','L')
<!-- <if test="expires==null">
and endtime&gt;=now()
</if> -->
<if test="expires!=null">
and endtime&lt;now()
</if> and a.status=1
<if test="classesId!=null">
and c.classesId=#{classesId}
</if>
inner join Classes cs on c.classesid = cs.classesid and cs.status = 1
),
classesids as (select classesid,className from classes where teacherid = #{teacherId} and status =1),
exams as ( select a.examId,a.classesId ,b.className from classownsouth as a INNER JOIN classesids as b on a.classesid = b.classesid )
<if test="isAi != null">
, temp4 as ( select count(*) as howmuch from SouthExam as a inner join exams as b on a.examId = b.examId where (a.status = 1 and a.endTime &lt; current_timestamp) or a.status =0 )
select temp1.howmuch+temp2.howmuch+temp3.howmuch+temp4.howmuch from temp1,temp2,temp3,temp4
</if>
<if test="isAi == null">
select temp1.howmuch+temp2.howmuch+temp3.howmuch from temp1,temp2,temp3
</if>
</select>
<select id="findLessonNumAndWordNumByTeacherId" parameterType="java.util.Map" resultType="java.util.Map">
SELECT count(a.assigntype='L' or null) achivementNum,
count(a.assigntype='W' or null) wordNum
from assignment a inner join assigntoclass ac on a.assignmentid=ac.assignmentid and ac.classesid=#{classesId}
and a.teacherid = #{teacherId} and a.created between #{startTime} and #{endTime}
</select>
<select id="findAssignmentNum" parameterType="java.util.Map" resultType="java.lang.Integer">
WITH temp as (
select soc.studentId from StudentOwnClass soc
inner join student s on s.areaid = #{areaId} and soc.studentid=s.studentid where
soc.classesId =#{classesId} and soc.areaid = #{areaId} and s.status=1
)
SELECT count(uid) from temp as a
INNER JOIN finishassignstat b ON b.areaid = #{areaId} and a.studentid = b.uid
inner join (select b.assignmentid,b.starttime,b.endtime from assigntoclass a INNER JOIN assignment b on a.assignmentid = b.assignmentid
and classesId =#{classesId}
) d on b.assignmentid =d.assignmentid
and b.created between #{startTime} and #{endTime}
and b.created &gt;d.starttime and b.created &lt; d.endtime
and lessoncount=completecount
</select>
</mapper>