746 lines
29 KiB
XML
Raw Normal View History

2026-03-10 14:30:24 +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="UnivAssignment">
<insert id="insertUnivAssignment" parameterType="UnivAssignment">
INSERT INTO UnivAssignment ( assignmentId, teacherId, content, description,
created, startTime, endTime, status , areaid , packageName ,assignType )
Values ( #{assignmentId}, #{teacherId}, #{content}, #{description},
current_timestamp, #{startTime}, #{endTime}, #{status} ,
#{areaid} , #{packageName} , #{assignType} )
</insert>
<update id="updateUnivAssignment" parameterType="UnivAssignment">
UPDATE UnivAssignment
SET assignmentId = #{assignmentId}, teacherId = #{teacherId},
content = #{content}, description = #{description},
created = #{created}, startTime = #{startTime},
endTime = #{endTime}, status = #{status} , areaid = #{areaid} ,
packageName = #{packageName} ,assignType=#{assignType}
where assignmentId=#{assignmentId}
</update>
<select id="getUnivAssignmentByKey" parameterType="java.lang.Integer" resultType="UnivAssignment">
SELECT assignmentId , teacherId , content , description , created ,
startTime , endTime , status , areaid , packageName ,assignType
FROM UnivAssignment
WHERE assignmentId=#{assignmentId}
</select>
<select id="getSeqUnivAssignment" resultType="Integer" useCache="false" flushCache="true">
SELECT nextval('seq_UnivassignmentId')
</select>
<select id="getUnivAssignmentsCountByTeacherId" parameterType="java.util.Map" resultType="Integer">
SELECT count( a.assignmentId ) as howmuch
FROM UnivAssignment a
WHERE a.status = 1
AND a.teacherId=#{teacherId}
and a.assignmentid
not in (
select distinct a.assignmentid
from univassignment a inner join univassigndetail b on a.teacherid=#{teacherId}
and a.assignmentid=b.assignmentid and b.unitid
in (select lessonid from lesson where parentid in (select lessonid from Respackage where language='zh')))
<if test="areaid != null">AND
a.areaid = #{areaid}
</if>
<if test="nowTime != null">AND
a.endTime &gt; #{nowTime}
</if>
</select>
<select id="getUnivAssignmentsByTeacherId" parameterType="java.util.Map" resultType="UnivAssignment">
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 UnivAssignment a
INNER JOIN UnivAssignToClass b
on a.assignmentId = b.assignmentId
WHERE a.status = 1
AND a.teacherId=#{teacherId}
and a.assignmentid
not in (
select distinct a.assignmentid
from univassignment a inner join univassigndetail b on a.teacherid=#{teacherId}
and a.assignmentid=b.assignmentid and b.unitid
in (select lessonid from lesson where parentid in (select lessonid from Respackage where language='zh')))
<if test="areaid != null">AND
a.areaid = #{areaid}
</if>
<if test="nowTime != null">AND
a.endTime &gt; #{nowTime}
</if>
ORDER BY a.assignmentId desc
LIMIT #{pageSize} OFFSET #{offset}
</select>
<update id="UnivassignmentBatchUpdateByAssignmentId" parameterType="java.util.List">
UPDATE UnivAssignment
SET status = 0
WHERE assignmentId in
<foreach collection="list" index="index" item="item" separator="," close=")" open="(">
#{item}
</foreach>
</update>
<select id="getLastUnivAssignment" parameterType="Long" resultType="UnivAssignment">
SELECT b.assignmentId , b.teacherId , b.content , b.description ,
b.created , b.startTime , b.endTime , b.status , b.areaid ,
b.packageName ,b.assignType
FROM UnivAssignToClass a
INNER JOIN UnivAssignment b
ON a.classesId = #{classesId} AND a.assignmentId = b.assignmentId
WHERE b.status = 1
ORDER BY b.assignmentId desc
LIMIT 1
</select>
<select id="getUnivAssignmentsCountByClassesId" parameterType="java.lang.Long" resultType="Integer">
SELECT count(*) as howmuch
FROM UnivAssignToClass a
INNER JOIN UnivAssignment b
ON a.classesId = #{classesId}
AND a.assignmentId = b.assignmentId
AND b.status = 1
and b.assignmentid
not in (
select distinct a.assignmentid
from univassignment a
inner join
UnivAssignToClass c on a.assignmentId = c.assignmentId and c.classesId = #{classesId}
inner join
univassigndetail b on
a.assignmentid=b.assignmentid and b.unitid
in (select lessonid from lesson where parentid in (select lessonid from Respackage where language='zh')))
</select>
<select id="getUnivAssignmentsByClassesId" parameterType="java.util.Map" resultType="UnivAssignment">
SELECT b.assignmentId , b.teacherId , b.content , b.description ,
b.created , b.startTime , b.endTime , b.status , b.areaid ,
b.packageName , b.packageName,b.assignType
FROM UnivAssignToClass a
INNER JOIN UnivAssignment b
ON a.classesId = #{classesId}
AND a.assignmentId = b.assignmentId
AND b.status = 1
and b.assignmentid
not in (
select distinct a.assignmentid
from univassignment a
inner join
UnivAssignToClass c on a.assignmentId = c.assignmentId and c.classesId = #{classesId}
inner join
univassigndetail b on
a.assignmentid=b.assignmentid and b.unitid
in (select lessonid from lesson where parentid in (select lessonid from Respackage where language='zh')))
ORDER BY b.assignmentId desc
LIMIT #{pageSize} OFFSET #{offset}
</select>
<select id="getUnivAssignmentsCountByStudentId" parameterType="java.util.Map" resultType="Integer">
SELECT count( distinct d.assignmentId ) as howmuch
FROM ( select n.classesId
from UnivStudentownClass m
INNER JOIN UnivClasses n
ON m.classesid = n.classesId and m.status =1 and n.status =1
where m.studentId = #{studentId} and m.areaid = #{areaid} ) as a
INNER JOIN UnivAssignToClass c
ON a.classesid = c.classesId
INNER JOIN UnivAssignment d
ON c.assignmentId = d.assignmentId and d.status =1
and d.assignmentid
not in (
select distinct a.assignmentid
from univassignment a
inner join
UnivAssignToClass c on a.assignmentId = c.assignmentId
and c.classesId in (select n.classesId
from UnivStudentownClass m
INNER JOIN UnivClasses n
ON m.classesid = n.classesId and m.status =1 and n.status =1
where m.studentId = #{studentId})
inner join
univassigndetail b on
a.assignmentid=b.assignmentid and b.unitid
in (select lessonid from lesson where parentid in (select lessonid from Respackage where language='zh')))
</select>
<select id="getUnivAssignmentsByStudentId" parameterType="java.util.Map" resultType="UnivAssignment">
SELECT distinct d.assignmentId , d.teacherId , d.content , d.description ,
d.created , d.startTime , d.endTime , d.status , d.areaid ,
d.packageName ,d.assignType
FROM ( select n.classesId
from UnivStudentownClass m
INNER JOIN UnivClasses n
ON m.classesid = n.classesId and m.status =1 and n.status =1
where m.studentId = #{studentId} and m.areaid = #{areaid} ) as a
INNER JOIN UnivAssignToClass c
ON a.classesid = c.classesId
INNER JOIN UnivAssignment d
ON c.assignmentId = d.assignmentId and d.status =1
and d.assignmentid
not in (
select distinct a.assignmentid
from univassignment a
inner join
UnivAssignToClass c on a.assignmentId = c.assignmentId
and c.classesId in (select n.classesId
from UnivStudentownClass m
INNER JOIN UnivClasses n
ON m.classesid = n.classesId and m.status =1 and n.status =1
where m.studentId = #{studentId})
inner join
univassigndetail b on
a.assignmentid=b.assignmentid and b.unitid
in (select lessonid from lesson where parentid in (select lessonid from Respackage where language='zh')))
ORDER BY d.assignmentId desc
LIMIT #{pageSize} OFFSET #{offset}
</select>
<select id="getUnivAssignmentDtosByStudentId" parameterType="java.util.Map" resultType="AssignmentDto">
SELECT distinct d.assignmentId , d.teacherId , d.content , d.description ,
d.created , d.startTime , d.endTime , d.status , d.areaid , d.assignType,
d.packageName ,a.classesId,a.className
FROM ( select n.classesId,n.className
from UnivStudentownClass m
INNER JOIN UnivClasses n
ON m.classesid = n.classesId and m.status =1 and n.status =1
where m.studentId = #{studentId} ) as a
INNER JOIN UnivAssignToClass c
ON a.classesid = c.classesId
INNER JOIN UnivAssignment d
ON c.assignmentId = d.assignmentId and d.status =1
and d.assignmentid
not in (
select distinct a.assignmentid
from univassignment a
inner join
UnivAssignToClass c on a.assignmentId = c.assignmentId
and c.classesId in (select n.classesId
from UnivStudentownClass m
INNER JOIN UnivClasses n
ON m.classesid = n.classesId and m.status =1 and n.status =1
where m.studentId = #{studentId})
inner join
univassigndetail b on
a.assignmentid=b.assignmentid and b.unitid
in (select lessonid from lesson where parentid in (select lessonid from Respackage where language='zh')))
<if test="nowTime != null">
AND d.endTime &gt; #{nowTime}
</if>
<if test="assignType!=null">
and d.assignType=#{assignType}
</if>
ORDER BY d.assignmentId desc
LIMIT #{pageSize}
OFFSET #{offset}
</select>
<select id="getUnivAssignmentDtosCountByStudentId" parameterType="java.util.Map" resultType="Integer">
SELECT count( d.assignmentId ) as howmuch
FROM ( select n.classesId
from UnivStudentownClass m
INNER JOIN UnivClasses n
ON m.classesid = n.classesId and m.status =1 and n.status =1
where m.studentId = #{studentId} ) as a
INNER JOIN UnivAssignToClass c
ON a.classesid = c.classesId
INNER JOIN UnivAssignment d
ON c.assignmentId = d.assignmentId and d.status =1
and d.assignmentid
not in (
select distinct a.assignmentid
from univassignment a
inner join
UnivAssignToClass c on a.assignmentId = c.assignmentId
and c.classesId in (select n.classesId
from UnivStudentownClass m
INNER JOIN UnivClasses n
ON m.classesid = n.classesId and m.status =1 and n.status =1
where m.studentId = #{studentId})
inner join
univassigndetail b on
a.assignmentid=b.assignmentid and b.unitid
in (select lessonid from lesson where parentid in (select lessonid from Respackage where language='zh')))
<if test="nowTime != null">
AND d.endTime &gt; #{nowTime}
</if>
<if test="assignType!=null">
and d.assignType=#{assignType}
</if>
</select>
<select id="getUnivAssignmentDtosCountByTeacherId" parameterType="java.util.Map" resultType="Integer">
SELECT count( a.assignmentId ) as howmuch
FROM UnivAssignment a
WHERE a.status = 1
AND a.teacherId=#{teacherId}
<if test="nowTime != null">
AND a.endTime &gt; #{nowTime}
</if>
<if test="assignType!=null">
and a.assignType=#{assignType}
</if>
</select>
<select id="getUnivAssignmentDtosByTeacherId" parameterType="java.util.Map" resultType="AssignmentDto">
SELECT distinct a.assignmentId , a.teacherId , a.content , a.description ,
a.created , a.startTime , a.endTime , a.status , a.areaid , a.assignType,
a.packageName,c.classesId,c.className
FROM UnivAssignment a
INNER JOIN UnivAssignToClass b
on a.assignmentId = b.assignmentId
inner join univclasses c on
b.classesid=c.classesid
WHERE a.status = 1
AND a.teacherId=#{teacherId}
and a.assignmentid
not in (
select distinct a.assignmentid
from univassignment a inner join univassigndetail b on a.teacherid=#{teacherId}
and a.assignmentid=b.assignmentid and b.unitid
in (select lessonid from lesson where parentid in (select lessonid from Respackage where language='zh')))
<if test="nowTime != null">AND
a.endTime &gt; #{nowTime}
</if>
<if test="assignType!=null">
and a.assignType=#{assignType}
</if>
ORDER BY a.assignmentId desc
LIMIT #{pageSize}
OFFSET #{offset}
</select>
<select id="getUnivAssignExamBystudentId" parameterType="java.util.Map" resultType="AssignmentDto">
select e.examid assignmentId,title as content,e.description,e.isOral,e.created,starttime,endtime,
1 as status,cs.areaId,null as packageName,'E' as assignType,cs.classesId,cs.className,e.examType
from univexam e
inner join
univclassownexam c on e.examid=c.examid
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &gt; #{nowTime}
</if>
inner join
univstudentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1
inner join
univclasses cs on cs.classesid=s.classesid and cs.status=1
union all
select e.examid assignmentId,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
from univhearexam e
inner join
univclassownhear c on e.examid=c.examid
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &gt; #{nowTime}
</if>
inner join
univstudentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1
inner join
univclasses cs on cs.classesid=s.classesid and cs.status=1
order by created desc,content desc,assignmentid desc,classesId LIMIT #{pageSize} OFFSET #{offset}
</select>
<select id="getUnivAssignExamCountBystudentId" parameterType="java.util.Map" resultType="java.lang.Integer">
with temp1 as ( select count (e.examid) howmuch from univexam e
inner join
univclassownexam c on e.examid=c.examid
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &gt; #{nowTime}
</if>
inner join
univstudentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1
inner join
univclasses cs on cs.classesid=s.classesid and cs.status=1
),
temp2 as ( select count(e.examid) howmuch from univhearexam e
inner join
univclassownhear c on e.examid=c.examid
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &gt; #{nowTime}
</if>
inner join
univstudentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1
inner join
univclasses cs on cs.classesid=s.classesid and cs.status=1
)
select temp1.howmuch+temp2.howmuch from temp1,temp2
</select>
<select id="getUnivAssignExamByTeacherId" parameterType="java.util.Map" resultType="AssignmentDto">
select e.examid assignmentId,ut.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 from univexam e
inner join
UnivTeacherOwnExam ut on ut.examid=e.examid and ut.teacherId=#{teacherId}
inner join
univclassownexam c on e.examid=c.examid
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &gt; #{nowTime}
</if>
inner join
univclasses 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 from univhearexam e
inner join
univclassownhear c on e.examid=c.examid and teacherId = #{teacherId}
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &gt; #{nowTime}
</if>
inner join
univclasses 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 LIMIT #{pageSize} OFFSET #{offset}
</select>
<select id="getUnivAssignExamCountByTeacherId" parameterType="java.util.Map" resultType="java.lang.Integer">
with temp1 as ( select count (e.examid) howmuch from Univexam e
inner join
UnivTeacherOwnExam ut on ut.examid=e.examid and ut.teacherId=#{teacherId}
inner join
Univclassownexam c on e.examid=c.examid
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &gt; #{nowTime}
</if>
<if test="classesId!=null">
and c.classesId=#{classesId}
</if>
inner join UnivClasses cs on c.classesid = cs.classesid and cs.status = 1
),
temp2 as ( select count(e.examid) howmuch from Univhearexam e
inner join
Univclassownhear c on e.examid=c.examid
and teacherId = #{teacherId}
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &gt; #{nowTime}
</if>
<if test="classesId!=null">
and c.classesId=#{classesId}
</if>
inner join UnivClasses cs on c.classesid = cs.classesid and cs.status = 1
)
select temp1.howmuch+temp2.howmuch from temp1,temp2
</select>
<select id="getUnivPreviousAssignByTeacherId" parameterType="java.util.Map" resultType="AssignmentDto">
select e.examid assignmentId,ut.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 from univexam e
inner join
UnivTeacherOwnExam ut on ut.examid=e.examid and ut.teacherId=#{teacherId}
inner join
univclassownexam c on e.examid=c.examid
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &lt;= #{nowTime}
</if>
inner join
univclasses cs on cs.classesid=c.classesid and cs.status=1
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 from univhearexam e
inner join
univclassownhear c on e.examid=c.examid and teacherId = #{teacherId}
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &lt;= #{nowTime}
</if>
inner join
univclasses cs on cs.classesid=c.classesid and cs.status=1
union
SELECT distinct a.assignmentId , a.teacherId , a.content , a.description , 0 as isOral,
a.created , a.startTime , a.endTime , a.status ,
a.packageName,a.assignType,c.classesId,c.className,'' as examType
FROM UnivAssignment a
INNER JOIN UnivAssignToClass b
on a.assignmentId = b.assignmentId
inner join univclasses c on
b.classesid=c.classesid
WHERE a.status = 1
AND a.teacherId=#{teacherId}
and a.assignmentid
not in (
select distinct a.assignmentid
from univassignment a inner join univassigndetail b on a.teacherid=#{teacherId}
and a.assignmentid=b.assignmentid and b.unitid
in (select lessonid from lesson where parentid in (select lessonid from Respackage where language='zh')))
<if test="nowTime != null">AND
a.endTime &lt;=#{nowTime}
</if>
order by created desc,content desc,assignmentid desc,classesId LIMIT #{pageSize} OFFSET #{offset}
</select>
<select id="getUnivPreviousAssignCountByTeacherId" parameterType="java.util.Map" resultType="java.lang.Integer">
with temp1 as ( select count (e.examid) howmuch from Univexam e
inner join
UnivTeacherOwnExam ut on ut.examid=e.examid and ut.teacherId=#{teacherId}
inner join
Univclassownexam c on e.examid=c.examid
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &lt;= #{nowTime}
</if>
inner join UnivClasses cs on c.classesid = cs.classesid and cs.status = 1
),
temp2 as ( select count(e.examid) howmuch from Univhearexam e
inner join
Univclassownhear c on e.examid=c.examid
and teacherId = #{teacherId}
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &lt;= #{nowTime}
</if>
inner join UnivClasses cs on c.classesid = cs.classesid and cs.status = 1
),
temp3 as (
SELECT count( a.assignmentId ) as howmuch
FROM UnivAssignment a
INNER JOIN UnivAssignToClass b
on a.assignmentId = b.assignmentId
inner join univclasses c on
b.classesid=c.classesid
WHERE a.status = 1
AND a.teacherId=#{teacherId}
and a.assignmentid
not in (
select distinct a.assignmentid
from univassignment a inner join univassigndetail b on a.teacherid=#{teacherId}
and a.assignmentid=b.assignmentid and b.unitid
in (select lessonid from lesson where parentid in (select lessonid from Respackage where language='zh')))
<if test="nowTime != null">
AND a.endTime &lt;= #{nowTime}
</if>
)
select temp1.howmuch+temp2.howmuch+temp3.howmuch from temp1,temp2,temp3
</select>
<select id="getUnivPreviousAssignBystudentId" parameterType="java.util.Map" resultType="AssignmentDto">
select e.examid assignmentId,title as content,e.description,e.isOral,e.created,starttime,endtime,
1 as status,cs.areaId,null as packageName,'E' as assignType,cs.classesId,cs.className,e.examType
from univexam e
inner join
univclassownexam c on e.examid=c.examid
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &lt; #{nowTime}
</if>
inner join
univstudentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1
inner join
univclasses cs on cs.classesid=s.classesid and cs.status=1
union all
select e.examid assignmentId,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
from univhearexam e
inner join
univclassownhear c on e.examid=c.examid
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &lt; #{nowTime}
</if>
inner join
univstudentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1
inner join
univclasses cs on cs.classesid=s.classesid and cs.status=1
union all
SELECT distinct d.assignmentId , d.content , d.description , 0 as isOral,
d.created , d.startTime , d.endTime , d.status , d.areaid ,
d.packageName,d.assignType ,a.classesId,a.className , '' as examType
FROM ( select n.classesId,n.className
from UnivStudentownClass m
INNER JOIN UnivClasses n
ON m.classesid = n.classesId and m.status =1 and n.status =1
where m.studentId = #{studentId} ) as a
INNER JOIN UnivAssignToClass c
ON a.classesid = c.classesId
INNER JOIN UnivAssignment d
ON c.assignmentId = d.assignmentId and d.status =1
and d.assignmentid
not in (
select distinct a.assignmentid
from univassignment a
inner join
UnivAssignToClass c on a.assignmentId = c.assignmentId
and c.classesId in (select n.classesId
from UnivStudentownClass m
INNER JOIN UnivClasses n
ON m.classesid = n.classesId and m.status =1 and n.status =1
where m.studentId = #{studentId})
inner join
univassigndetail b on
a.assignmentid=b.assignmentid and b.unitid
in (select lessonid from lesson where parentid in (select lessonid from Respackage where language='zh')))
<if test="nowTime != null">
AND d.endTime &lt; #{nowTime}
</if>
order by created desc,content desc,assignmentid desc,classesId LIMIT #{pageSize} OFFSET #{offset}
</select>
<select id="getUnivPreviousAssignCountBystudentId" parameterType="java.util.Map" resultType="java.lang.Integer">
with temp1 as ( select count (e.examid) howmuch from univexam e
inner join
univclassownexam c on e.examid=c.examid
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &lt;= #{nowTime}
</if>
inner join
univstudentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1
inner join
univclasses cs on cs.classesid=s.classesid and cs.status=1
),
temp2 as ( select count(e.examid) howmuch from univhearexam e
inner join
univclassownhear c on e.examid=c.examid
<if test="examType!=null">
and examtype=#{examType}
</if>
<if test="nowTime != null">AND
e.endTime &lt;= #{nowTime}
</if>
inner join
univstudentownclass s on s.classesid=c.classesid and s.studentid=#{studentId} and s.status=1
inner join
univclasses cs on cs.classesid=s.classesid and cs.status=1
),
temp3 as (SELECT count( d.assignmentId ) as howmuch
FROM ( select n.classesId
from UnivStudentownClass m
INNER JOIN UnivClasses n
ON m.classesid = n.classesId and m.status =1 and n.status =1
where m.studentId = #{studentId} ) as a
INNER JOIN UnivAssignToClass c
ON a.classesid = c.classesId
INNER JOIN UnivAssignment d
ON c.assignmentId = d.assignmentId and d.status =1
and d.assignmentid
not in (
select distinct a.assignmentid
from univassignment a
inner join
UnivAssignToClass c on a.assignmentId = c.assignmentId
and c.classesId in (select n.classesId
from UnivStudentownClass m
INNER JOIN UnivClasses n
ON m.classesid = n.classesId and m.status =1 and n.status =1
where m.studentId = #{studentId})
inner join
univassigndetail b on
a.assignmentid=b.assignmentid and b.unitid
in (select lessonid from lesson where parentid in (select lessonid from Respackage where language='zh')))
<if test="nowTime != null">
AND d.endTime &lt;= #{nowTime}
</if> )
select temp1.howmuch+temp2.howmuch+temp3.howmuch from temp1,temp2,temp3
</select>
<select id="getCateIdsByAssignmentId" parameterType="java.lang.Integer" resultType="java.util.Map">
<!--select distinct e.cateid as "cateId" from univassigndetail a inner join lesson b on a.unitid=b.lessonid and assignmentid=#{assignmentId}
inner join univassignment c on a.assignmentid=c.assignmentid
inner join goodsownpackage d on d.lessonid=b.parentid and c.assigntype=d.coursetype
inner join univcateowngoods e on e.goodsid=d.goodsid order by e.cateid -->
with temp as (select assignmentid,unitid from Univassigndetail where assignmentid = #{assignmentId})
select distinct e.cateid as "cateId" from temp a inner join lesson b on a.unitid=b.lessonid inner join univassignment c on a.assignmentid=c.assignmentid inner join goodsownpackage d on d.lessonid=b.parentid and c.assigntype=d.coursetype inner join univcateowngoods e on e.goodsid=d.goodsid order by e.cateid ;
</select>
</mapper>