877 lines
34 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._3e.dao.AssignDao">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com._3e.entity.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="pointcasetypes" property="pointCaseTypes" jdbcType="ARRAY" typeHandler="com._3e.http.wrongbook.typehandler.SmallIntArrayTypeHandler"/>
</resultMap>
<select id="findAssignment" parameterType="int"
resultMap="BaseResultMap">
SELECT * FROM assignment
WHERE assignmentid =
#{assignmentid} and status = 1
</select>
<update id="doUpdateAssignment" parameterType="com._3e.entity.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>
</set>
WHERE assignmentid = #{assignmentid}
</update>
<update id="doUpdateCustomizeAssignAnswer">
update assignanswer
<set>
<if test="content != null">
content = #{content},
</if>
<if test="created != null">
created = #{created},
</if>
<if test="medias != null">
medias = #{medias,typeHandler=com._3e.http.wrongbook.typehandler.JSONTypeHandlerPg}
</if>
</set>
WHERE uid = #{uid} and assignmentid = #{assignmentId}
</update>
<insert id="doSaveCustomizeAssignAnswer">
INSERT INTO assignanswer(
uid, assignmentid, content, created,medias)
VALUES (
#{uid},#{assignmentId}, #{content}, #{created},
#{medias,typeHandler=com._3e.http.wrongbook.typehandler.JSONTypeHandlerPg})
</insert>
<select id="findAssignByClassids" parameterType="list"
resultType="com._3e.entity.Assignment">
SELECT b.* FROM ASSIGNMENT b, assigntoclass C
WHERE b.assignmentid = C.assignmentid AND b.status = 1
AND C .classesid in
<foreach item="classes" index="index" collection="classesList"
open="(" separator="," close=")">
#{classes.classesid}
</foreach>
and now() &lt;= endtime
ORDER BY b.created DESC
</select>
<select id="findAssignByClassid" parameterType="map"
resultType="com._3e.http.myhome.dto._3EResAssignment">
SELECT b.assignmentid,b.content,b.description,b.starttime,
b.endtime,b.assigntype,l.classname,l.classesid,b.created,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="findAssignByClassid_1" parameterType="map"
resultType="com._3e.http.myhome.dto._3EResAssignment">
SELECT DISTINCT b.assignmentid,b.content,b.description,b.starttime,b.created,
b.endtime,b.assigntype,l.classname,l.classesid,dv.playCount
FROM ASSIGNMENT b
INNER JOIN assigntoclass C ON b.assignmentid = C.assignmentid
inner JOIN classes l ON c.classesid = l.classesid
inner JOIN assigndetail adt on b.assignmentid=adt.assignmentid
LEFT JOIN dubvideodynamic dv on adt.unitid=dv.videoid
WHERE b.status = 1 AND C.classesid = #{classid}
<if test="status == '1'.toString()">
and now() &lt;= b.endtime
</if>
<if test="assigntype!=null">
and b.assigntype=#{assigntype}
</if>
<if test="status == '2'.toString()">
and now() &gt; b.endtime
</if>
ORDER BY b.created DESC
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findAssignByClassid_2" parameterType="map"
resultType="com._3e.http.myhome.dto._3EResAssignment">
with temp1 as(
SELECT classesid,assignmentid,areaid from assigntoclass
where classesid=#{classid}
)
SELECT b.assignmentid,b.content,b.description,b.starttime,b.created,b.assignTime,b.endtime,b.assigntype,l.classname,a.classesid,b.pointCaseTypes::text
from temp1 a
inner join assignment b
on a.assignmentid=b.assignmentid
and b.status=1
<if test="status == '1'.toString()">
and now() &lt;= b.endtime
</if>
<if test="assigntype!=null">
and b.assigntype=#{assigntype}
</if>
inner join classes l
on a.classesid=l.classesid
ORDER BY b.created desc
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findAssignByClassid_3" parameterType="map"
resultType="com._3e.http.myhome.dto._3EResAssignment">
with temp1 as(
SELECT classesid,assignmentid,areaid from assigntoclass
where classesid=#{classid}
)
SELECT b.assignmentid,b.content,b.description,b.starttime,b.created,b.assignTime,b.endtime,b.assigntype,l.classname,a.classesid,b.pointCaseTypes::text
from temp1 a
inner join assignment b
on a.assignmentid=b.assignmentid
and b.status=1
and now() &lt;= b.endtime
inner join classes l
on a.classesid=l.classesid
ORDER BY b.created desc
</select>
<select id="findAllAssignByAllClass" parameterType="map"
resultType="com._3e.http.myhome.dto._3EResAssignment">
SELECT b.assignmentid,b.content,b.description,b.starttime,b.created,b.assignTime,
b.endtime,b.assigntype,l.className,l.classesid,b.pointCaseTypes::text
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' AND C.classesid in
<foreach item="classes" index="index" collection="classesList"
open="(" separator="," close=")">
#{classes.classesid}
</foreach>
<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="findAllAssignByClassid" parameterType="map"
resultType="com._3e.entity.Assignment">
SELECT b.assignmentId , b.teacherId , b.content , b.description ,
b.created ,b.assignTime,
b.startTime , b.endTime , b.status , b.areaid
,b.packageName ,
b.packageName,b.assigntype,b.pointCaseTypes::text as pointCaseTypesStr
FROM AssignToClass a
INNER JOIN Assignment b ON a.classesId = #{classesid}
AND a.assignmentId =
b.assignmentId AND b.status = 1
and b.assigntype in('L','W')
ORDER BY b.assignmentId desc
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findAllCustomizeAssignByClassid" parameterType="map"
resultType="com._3e.entity.Assignment">
SELECT b.assignmentId , b.teacherId , b.content , b.description ,
b.created ,b.assignTime,
b.startTime , b.endTime , b.status , b.areaid
,b.packageName ,
b.packageName,b.assigntype,b.pointCaseTypes::text as pointCaseTypesStr
FROM AssignToClass a
INNER JOIN Assignment b ON a.classesId = #{classesid}
AND a.assignmentId =
b.assignmentId AND b.status = 1
and b.assigntype ='S'
ORDER BY b.assignmentId desc
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findAssignDetailByAssignmentid" parameterType="int"
resultType="com._3e.entity.Assigndetail">
SELECT * FROM assigndetail
WHERE assignmentid = #{assignmentid}
ORDER BY unitid ASC,lessonid ASC
</select>
<resultMap id="AssignDetailBookMap" type="com._3e.http.teachercenter.dto.achivement.AssignDetailBookVO">
<id column="bookId" property="bookId"/>
<result column="bookName" property="bookName"/>
<collection property="units" ofType="com._3e.http.teachercenter.dto.achivement.AssignDetailUnitVO" resultMap="AssignDetailUnitMap"/>
</resultMap>
<resultMap id="AssignDetailUnitMap" type="com._3e.http.teachercenter.dto.achivement.AssignDetailUnitVO">
<id column="unitId" property="unitId"/>
<result column="unitName" property="unitName"/>
<result column="unitOrderId" property="unitOrderId"/>
<collection property="lessons" ofType="com._3e.http.teachercenter.dto.achivement.AssignDetailLessonVO" resultMap="AssignDetailLessonMap"/>
</resultMap>
<resultMap id="AssignDetailLessonMap" type="com._3e.http.teachercenter.dto.achivement.AssignDetailLessonVO">
<id column="assignDetailId" property="assignDetailId"/>
<result column="assignmentId" property="assignmentId"/>
<result column="assignType" property="assignType"/>
<result column="areaId" property="areaId"/>
<result column="lessonId" property="lessonId"/>
<result column="lessonName" property="lessonName"/>
<result column="lessonOrderId" property="lessonOrderId"/>
<result column="number" property="number"/>
</resultMap>
<select id="findAssignDetailByAssignmentidV2" parameterType="int"
resultMap="AssignDetailBookMap">
SELECT ad.assignDetailId,ad.assignmentId,ad.assignType,ad.areaId,ad.number,
b.lessonid bookId,b.lessonName bookName,
u.lessonid unitId,u.lessonName unitName,u.orderId unitOrderId,
l.lessonid lessonId,l.lessonName lessonName,l.orderId lessonOrderId
FROM assigndetail ad inner join lesson l on ad.lessonid = l.lessonid and l.status=1
inner join lesson u on ad.unitid = u.lessonid
inner join lesson b on u.parentid = b.lessonid
WHERE assignmentid = #{assignmentId} and assigntype in ('L','U')
ORDER BY u.orderid ASC,l.orderid ASC
</select>
<select id="findAssignDetailByAssignmentid_L" parameterType="int"
resultType="com._3e.entity.Assigndetail">
SELECT al.* FROM assigndetail al INNER JOIN lesson l on al.lessonid = l.lessonid and l.status=1
WHERE assignmentid = #{assignmentid}
ORDER BY al.unitid ASC,al.lessonid ASC
</select>
<select id="findAssigned" parameterType="map"
resultType="com._3e.entity.Assignment">
SELECT distinct a.assignmentId , a.teacherId , a.content
,a.description ,
a.created , a.startTime , a.endTime , a.status, a.areaid ,
a.packageName,a.assigntype
FROM Assignment a
INNER JOIN AssignToClass b on a.assignmentId = b.assignmentId
WHERE a.status = 1 AND a.teacherId = #{teacherid}
<if test="areaid != null and areaid != 0">
and a.areaid = #{areaid}
</if>
<if test="nowtime != null">
and a.endTime &gt; #{nowtime}
</if>
ORDER BY a.assignmentId desc
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findAssignmentTaskStatus" parameterType="map"
resultType="com._3e.dto.AssignmentTaskStatus">
WITH temp1 as (
<!--select studentId
from StudentOwnClass
where
classesId = #{classesId}
<if test="areaid != null and areaid != 0">
and areaid = #{areaid}
</if>
and status = 1 -->
select stu.studentid from studentownClass stu inner join student s
on stu.studentid=s.studentid
<if test="areaid != null and areaid != 0">
and s.areaid = #{areaid}
</if>
and s.status=1
where
stu.classesid = #{classesId}
<if test="areaid != null and areaid != 0">
and stu.areaid = #{areaid}
</if>
and stu.status = 1
) ,
temp2 as (
select n.uid ,score , n.objectId , n.created , n.achiveType ,
n.pointCaseType
from temp1 m
inner join Achivement n
ON m.studentId = n.uid
<if test="areaid != null and areaid != 0">
and n.areaid = #{areaid}
</if>
<if test="startTime != null">
and n.created &gt;= #{startTime}
</if>
<if test="endTime != null">
and n.created &lt; #{endTime}
</if>
),
temp3 as ( select uid ,score , objectId , created
from temp2 n
where n.achiveType in ('L','W') AND n.pointCaseType in (3,4, 5,
6 , 7 ,8 )
<if test="lessonIds != null">
AND n.objectId in
<foreach item="lessonId" index="index" collection="lessonIds"
open="(" separator="," close=")">
#{lessonId}
</foreach>
</if>
)
SELECT a.studentId , avg(b.score) as avgScore ,
count( distinct b.objectId ) as howmuch ,
count(b.objectId) as total ,
max(b.score) as maxScore,
max( b.created ) as lastTime
FROM temp1 as a
LEFT JOIN temp3 as b
ON a.studentId = b.uid
GROUP BY a.studentId
ORDER BY maxScore desc nulls last,avgScore desc nulls last,a.studentId
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findAssignmentTaskStatusOfWord" parameterType="map"
resultType="com._3e.dto.AssignmentTaskStatus">
with base as(
select studentid,lessonid,count(distinct(wordsid)) as wordsCount
from studentownclass s ,words w
where
<if test="areaid != null and areaid != 0">
s.areaid = #{areaid}
</if>
and classesid=#{classesId}
and s.status = 1 and lessonid in
<foreach item="lessonId" index="index" collection="lessonIds"
open="(" separator="," close=")">
#{lessonId}
</foreach>
group by studentid,lessonid ),
temp as(
SELECT bs.studentid,bs.lessonid,avg(w.score) as
avgScore,count(distinct(w.wordsid)) as finishCount ,
case when count(distinct(w.wordsid))>0 then 1 else 0 end as howmuch ,
count(w.wordsid) as total,max(w.score) as maxScore,max(w.created) as
lastTime
FROM base bs
inner join wordachive w on bs.studentid=w.uid
<if test="areaid != null and areaid != 0">
w.areaid = #{areaid}
</if>
<if test="startTime != null">
and w.created &gt;= #{startTime}
</if>
<if test="endTime != null">
and w.created &lt; #{endTime}
</if>
inner join words w1 on w1.wordsid= w.wordsid and
w1.lessonid=bs.lessonid
group by bs.studentid,bs.lessonid)
SELECT bs.studentid,avg(avgScore) as avgScore,
sum(howmuch) as howmuch,sum(total)as total,max(maxScore) as maxScore,max(lastTime)
as lastTime,
(case when sum(finishCount) is null then 0 else sum(finishCount) end
)||'/'||sum(wordsCount) as finishWords
from base bs left join temp t
on bs.studentid=t.studentid and bs.lessonid=t.lessonid
group by bs.studentid order by maxScore desc nulls last,avgScore desc nulls
last,bs.studentid ASC
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findAssignmentGoodVoice" parameterType="map"
resultType="com._3e.dto.AssignmentTaskStatus">
WITH temp1 AS ( SELECT studentId FROM StudentOwnClass WHERE
classesId = #{classesId} and status = 1 ),
temp2 AS ( SELECT DISTINCT lessonid FROM AssignDetail WHERE
assignmentId = #{assignmentId} ),
temp3 AS ( SELECT b.achivementid , b.uid , b.uuid , b.score ,
b.objectId , b.created,
b.achiveType , b.pointCaseType
FROM temp1 a
INNER JOIN Achivement b ON a.studentId = b.uid
),
temp4 AS ( SELECT c.achivementid , ROW_NUMBER() OVER (PARTITION
BY c.uid ORDER BY c.score DESC , c.created ASC ) AS rn ,
c.uid , c.uuid , c.score , c.objectId , c.created
FROM temp3 c
WHERE c.created &gt;= #{startTime} AND c.created &lt; #{endTime}
AND c.achiveType IN ('L') AND c.pointCaseType IN ( 5, 6 , 7 ,8
)
AND c.objectId IN ( SELECT lessonid FROM temp2 )
AND LENGTH( TRIM( c.uuid )) > 0 )
SELECT n.uid AS studentId , '' as truename , 0 as schoolId , '' as
schoolName , n.uuid as goodVoice ,
n.created
FROM temp4 as n
WHERE n.rn = 1
</select>
<select id="findAssignWordsCount" parameterType="int"
resultType="int">
select count( distinct b.wordsid ) as wordscount
from AssignDetail a
inner join Words b
on a.assignmentid = #{assignmentId} and a.unitid = b.lessonid and b.status = 1
</select>
<select id="findAssignmentTaskStatusOfWordV2" parameterType="map"
resultType="com._3e.dto.AssignmentTaskStatus">
with temp as ( select stu.studentid from studentownClass stu inner join student s
on stu.studentid=s.studentid
<if test="areaid != null and areaid != 0">
and s.areaid = #{areaid}
</if>
and s.status=1
where
stu.classesid = #{classesId}
<if test="areaid != null and areaid != 0">
and stu.areaid = #{areaid}
</if>
and stu.status = 1 )
select stu.studentId,t.avgScore,t.howmuch as total,t.issign,t.completecount as howmuch,t.maxScore,created as lastTime,
(case when completecount is null then 0 else completecount end )||'/'||cast( #{wordsCount} as char(20)) as finishWords
from temp stu
left join finishAssignStat t
on stu.studentId = t.uid
<if test="areaid != null and areaid != 0">
and t.areaid = #{areaid}
</if>
and assignmentid = #{assignmentId}
order by maxScore desc nulls last,avgScore desc nulls last,stu.studentid
</select>
<select id="findCustomizeAssignmentTaskStatus" parameterType="map"
resultType="com._3e.dto.AssignmentTaskStatus">
with temp as ( select stu.studentid from studentownClass stu inner join student s
on stu.studentid=s.studentid
<if test="areaid != null and areaid != 0">
and s.areaid = #{areaid}
</if>
and s.status=1
where
stu.classesid = #{classesId}
<if test="areaid != null and areaid != 0">
and stu.areaid = #{areaid}
</if>
and stu.status = 1 ),
temp1 as ( select * from (
select *,row_number() OVER (PARTITION BY objectid order by created desc ) rn from assigncomm where assignmentid = #{assignmentId} ) a where a.rn = 1)
select stu.studentId,aa.created as lastTime,aa.medias,aa.content,
case when ac.tier is null then 0 else ac.tier end as tier,
case when ac.badge is null then 0 else ac.badge end as badge,
case when ac.created is null then 0 else 1 end as isSign
from temp stu
left join assignAnswer aa on stu.studentId = aa.uid and aa.assignmentid = #{assignmentId}
left join temp1 ac on stu.studentid = ac.objectid
order by aa.created desc nulls last,stu.studentid
</select>
<select id="findAssignmentTaskStatusV2" parameterType="map"
resultType="com._3e.dto.AssignmentTaskStatus">
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.avgScore ,b.issign,b.completecount as howmuch,
b.howmuch as total, b.maxScore, b.created as lastTime , b.uuid AS goodVoice,
b.avgAccuracy,b.avgFluent,b.avgIntegrity,b.jContent
FROM temp1 as a
LEFT JOIN FinishAssignStat 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 maxScore desc nulls last,avgScore desc nulls last,a.studentId
</select>
<select id= "findOverdueAssignment" parameterType="map" resultType="com._3e.http.myhome.dto._3EResAssignment_1" >
SELECT assignmentid,content ,description,starttime,endtime,assigntype,created,classname,
0 as examid,'' as examtype,'' as title,'' as exampapers,-1 as isnetexam,0 as teacherid,-1 as isoral
from (SELECT b.assignmentid,b.content ,b.description,b.starttime,b.endtime,b.assigntype,b.created,l.classname,l.classesid,
0 as examid,'' as examtype,'' as title,'' as exampapers,-1 as isnetexam,0 as teacherid,-1 as isoral
from assignment b inner JOIN assigntoclass C ON b.assignmentid = C.assignmentid
LEFT JOIN classes l ON c.classesid = l.classesid
WHERE C.classesid in
<foreach item="classesid" index="index" collection="classeslist"
open="(" separator="," close=")">
#{classesid}
</foreach>
and b.assigntype!='D'
) t
where now() &gt; endtime
union all
SELECT 0 as assignmentid,'' as content ,description,starttime,endtime,'' as assigntype,created,classname,
examid,examtype,title,exampapers,isnetexam,teacherid,isoral
from (SELECT DISTINCT e.description,e.starttime,e.endtime,e.created,sd.classname,
e.examid,e.examtype,e.title,e.exampapers,e.isnetexam,e.teacherid,e.isoral from exam e
LEFT JOIN v_studentclass sd on e.teacherid=sd.teacherid and e.teacherid in
<foreach item="teacherid" index="index" collection="teacherlist"
open="(" separator="," close=")">
#{teacherid}
</foreach>
and sd.classesid in
<foreach item="classesid" index="index" collection="classeslist"
open="(" separator="," close=")">
#{classesid}
</foreach>
) t1
where now() &gt; endtime
ORDER BY created DESC
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id= "findOverdueAssignment_1" parameterType="map" resultType="com._3e.http.myhome.dto._3EResAssignment_1" >
<!-- with temp1 as ( select distinct a.assignmentid , a.classesid
from AssignToClass a
where a.classesid in
<foreach item="item" index="index" collection="classeslists"
open="(" separator="," close=")">
#{item}
</foreach>
),
temp2 as ( select c.assignmentid , c.classesid , d.classname
from temp1 c
inner join Classes d
on c.classesid = d.classesid )
SELECT b.assignmentid, b.content , b.description, b.starttime, b.endtime, b.assigntype, b.created, a.classname,
0 as examid,'' as examtype,'' as title,'' as exampapers,-1 as isnetexam,0 as teacherid,-100 as isoral,a.classesid
from temp2 a
inner join assignment b
on a.assignmentid = b.assignmentid
where now() &gt; b.endtime and b.assigntype in ( 'L' , 'W' )
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if> -->
with temp1 as ( select distinct a.assignmentid , a.classesid
from AssignToClass a
where a.classesid in
<foreach item="item" index="index" collection="classeslists"
open="(" separator="," close=")">
#{item}
</foreach>
),
temp2 as ( select c.assignmentid , c.classesid , d.classname
from temp1 c
inner join Classes d
on c.classesid = d.classesid )
SELECT b.assignmentid, b.content , b.description, b.starttime, b.endtime, b.assigntype, b.created, a.classname,b.pointCaseTypes::text,
0 as examid,1 as type,'' as examtype,'' as title,'' as exampapers,-1 as isnetexam,0 as teacherid,-100 as isoral,a.classesid,-1 as isAi
from temp2 a
inner join assignment b
on a.assignmentid = b.assignmentid
where now() &gt; b.endtime and b.assigntype in ( 'L' , 'W' ) and b.status = 1
union all
SELECT a.examid as assignmentid,'' as content , b.description, b.starttime, b.endtime,'' as assigntype, b.created, c.classname ,'' as pointCaseTypes,
b.examid,b.type,b.examtype,b.title,b.exampapers,b.isnetexam, b.teacherid, b.isoral,a.classesid,-1 as isAi
from ClassOwnExam a
inner join Classes c on a.classesid=c.classesid and a.classesid in
<foreach item="item1" index="index" collection="classeslists"
open="(" separator="," close=")">
#{item1}
</foreach>
inner join Exam b
on a.examid = b.examid <!--and b.examType='S'-->
where now() &gt;b.endtime
<if test="source == 11">
union all
SELECT a.examid as assignmentid,'' as content , b.description, b.starttime, b.endtime,'' as assigntype, b.created, c.classname ,'' as pointCaseTypes,
b.examid,1 as type,b.examtype,b.title,b.exampapers,b.isnetexam, b.teacherid, b.isoral,a.classesid,1 as isAi
from ClassOwnSouth a
inner join Classes c on a.classesid=c.classesid and a.classesid in
<foreach item="item1" index="index" collection="classeslists"
open="(" separator="," close=")">
#{item1}
</foreach>
inner join SouthExam b
on a.examid = b.examid <!--and b.examType='S'-->
where now() &gt;b.endtime
</if>
union all
SELECT a.examid as assignmentid,'' as content , b.description, b.starttime, b.endtime,'' as assigntype, b.created, c.classname ,'' as pointCaseTypes,
b.examid,1 as type,b.examtype,b.title,'' as exampapers,b.isnetexam, b.teacherid, -1 as isoral,a.classesid,-1 as isAi
from ClassOwnhear a
inner join Classes c on a.classesid=c.classesid and a.classesid in
<foreach item="item2" index="index" collection="classeslists"
open="(" separator="," close=")">
#{item2}
</foreach>
inner join hearexam b
on a.examid = b.examid <!--and b.examType='S'-->
where now()&gt;b.endtime
order by created desc,assignmentid desc
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id= "findOverdueEAssignment" parameterType="map" resultType="com._3e.http.myhome.dto._3EResAssignment_1" >
with temp1 as ( select distinct a.classesid , a.examid
from ClassOwnExam a
where a.classesid in
<foreach item="item" index="index" collection="classeslists"
open="(" separator="," close=")">
#{item}
</foreach> ),
temp2 as ( select c.examid , c.classesid , d.classname
from temp1 c
inner join Classes d
on c.classesid = d.classesid )
SELECT a.examid as assignmentid,'' as content , b.description, b.starttime, b.endtime,'' as assigntype, b.created, a.classname ,
b.examid,b.examtype,b.title,b.exampapers,b.isnetexam, b.teacherid, b.isoral
from temp2 a
inner join Exam b
on a.examid = b.examid
where now() &gt; b.endtime
</select>
<select id="findUserVoice" parameterType="map" resultType="com._3e.http.myhome.dto._3EResClassUserVoices">
select row_number,created,voiceid,avatar,truename,studentid,score,created as finishTime 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,d.score 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="findUserVoice1" parameterType="map" resultType="com._3e.http.myhome.dto._3EResClassUserVoices">
select row_number,created,voiceid,avatar,truename,studentid,score,finishTime from(
SELECT row_number()over(PARTITION by d.uid ORDER BY d.score desc) as row_number ,
a.*,d.voiceid,d.created finishTime,b.studentid,b.avatar,b.truename,ata.unitid,d.score 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="findUserVoice_1" parameterType="map" resultType="com._3e.http.myhome.dto._3EResClassUserVoices">
select row_number,created,voiceid,avatar,truename,studentid,recognizecode,avgScore,CAST(score AS VARCHAR),accuracy,fluent,integrity from(
SELECT row_number()over(PARTITION by d.uid ORDER BY d.score desc) as row_number ,
AVG(d.score) OVER (PARTITION BY d.uid) AS avgScore,
accuracy,fluent,integrity,
d.created,d.voiceid,d.score,b.studentid,b.recognizecode,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 order by r.studentid
</select>
<select id="findDubvoiceNum" parameterType="map" resultType="int">
select count(*) from
(
SELECT row_number()over(PARTITION by d.uid,a.assignmentid ORDER BY d.created desc) as row_number ,a.assignmentid,d.uid,
d.created,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='D' and d.created &lt; a.endtime and d.created > a.starttime and b.classesid=#{classesid} and a.status =1
and d.created between '${starttime} 00:00:00' and '${endtime} 23:59:59'
) r
INNER JOIN (
SELECT a.assignmentid from
assignment a INNER JOIN assigntoclass ac on a.assignmentid = ac.assignmentid and ac.classesid=#{classesid} and a.status =1
)
ff
on r.assignmentid = ff.assignmentid
where row_number=1
</select>
<select id="findDubvoiceNum_1" parameterType="map" resultType="int">
select count(*) from dubuservoice d
inner join studentownclass st on d.uid = st.studentid and st.status = 1
and st.areaid = #{areaid} and st.classesid =#{classesid} and d.isdelete = 0 and
d.created between '${starttime} 00:00:00' and '${endtime} 23:59:59'
</select>
<select id="findAssigntoclass" parameterType="map" resultType="com._3e.entity.Assigntoclass">
select * from assigntoclass where assignmentid = #{assignmentId}
</select>
<select id="findDubVideoClassesByTeacherId" resultType="com.dub.dto.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="findOverdueAssignment_L" resultType="com._3e.http.myhome.dto._3EResAssignment_1">
with temp1 as ( select distinct a.assignmentid , a.classesid
from AssignToClass a
where a.classesid in
<foreach item="item" index="index" collection="classeslists"
open="(" separator="," close=")">
#{item}
</foreach>
),
temp2 as ( select c.assignmentid , c.classesid , d.classname
from temp1 c
inner join Classes d
on c.classesid = d.classesid )
SELECT b.assignmentid, b.content , b.description, b.starttime, b.endtime, b.assigntype, b.created, a.classname,b.pointCaseTypes::text,
0 as examid,1 as type,'' as examtype,'' as title,'' as exampapers,-1 as isnetexam,0 as teacherid,-100 as isoral,a.classesid,-1 as isAi
from temp2 a
inner join assignment b
on a.assignmentid = b.assignmentid
where now() &gt; b.endtime and b.assigntype = #{assignType} and b.status = 1
order by created desc,assignmentid desc
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findOverdueAssignment_E" resultType="com._3e.http.myhome.dto._3EResAssignment_1">
SELECT a.examid as assignmentid,'' as content , b.description, b.starttime, b.endtime,'' as assigntype, b.created, c.classname ,'' as pointCaseTypes,
b.examid,b.type,b.examtype,b.title,b.exampapers,b.isnetexam, b.teacherid, b.isoral,a.classesid,-1 as isAi
from ClassOwnExam a
inner join Classes c on a.classesid=c.classesid and a.classesid in
<foreach item="item1" index="index" collection="classeslists"
open="(" separator="," close=")">
#{item1}
</foreach>
inner join Exam b
on a.examid = b.examid <!--and b.examType='S'-->
where now() &gt;b.endtime and b.type =#{type}
order by created desc,assignmentid desc
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findOverdueAssignment_AI" resultType="com._3e.http.myhome.dto._3EResAssignment_1">
SELECT a.examid as assignmentid,'' as content , b.description, b.starttime, b.endtime,'' as assigntype, b.created, c.classname ,'' as pointCaseTypes,
b.examid,1 as type,b.examtype,b.title,b.exampapers,b.isnetexam, b.teacherid, b.isoral,a.classesid,1 as isAi
from ClassOwnSouth a
inner join Classes c on a.classesid=c.classesid and a.classesid in
<foreach item="item1" index="index" collection="classeslists"
open="(" separator="," close=")">
#{item1}
</foreach>
inner join SouthExam b
on a.examid = b.examid <!--and b.examType='S'-->
where now() &gt;b.endtime
order by created desc,assignmentid desc
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findCustomizeAssignMediasByAssignmentId" resultType="java.lang.String">
select medias from assigndetail where assignmentid = #{assignmentId}
</select>
<select id="findCustomizeAssignAnswer" resultType="com._3e.http.myhome.dto.ResAssignAnswer">
select * from AssignAnswer where uid = #{uid} and assignmentId = #{assignmentId}
</select>
<select id="findMaxScoreJcontent" resultType="com._3e.dto.MaxScoreJContent">
with temp as (
SELECT *,RANK() OVER (PARTITION BY uid,areaid ORDER BY score DESC) AS rank
FROM Achivement where achiveType = 'L' and pointCaseType = 4
and objectId in
<foreach collection="lessonIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
and areaid=#{areaid}
and created &lt;= #{endTime} and created >= #{startTime}
),
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 t1.studentid AS uid,t2.jContent,t2.achivementId from temp1 t1
inner join temp t2
on t1.studentId = t2.uid
where t2.rank = 1
</select>
<select id="findAssgindetailNum" resultType="java.lang.Integer">
select number from assigndetail where assignDetailId = #{assignDetailId}
</select>
<select id="findCustomizeAssignAnswerList" resultType="com._3e.http.myhome.dto.ResAssignAnswer">
select * from AssignAnswer where assignmentId = #{assignmentId}
</select>
</mapper>