spokenServer/out/production/pcserver/sqlmap/UnivAccountCount.xml
2026-03-10 14:30:24 +08:00

478 lines
15 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="AccountCount">
<sql id="UnivstudentcountDetail_useStat">
select sc.studentId , s.schoolName , c.className ,
st.recognizecode , st.trueName ,
<!--uh.studyduration as timelength ,-->
case when uc.timelength>0 then uc.timelength else 0 end as timelength,
case when ss.avgScore &gt;0 then
round(ss.avgScore) else 0 end as score ,
case when ss.howmuch &gt;0 then
ss.howmuch else 0 end as studyCount,
t.trueName as teacherName
, uc.loginCount
from sc
inner join UnivClasses c
on sc.classesId = c.classesId
inner join university s
on s.schoolId = c.schoolId
inner join UnivTeacher t
on c.teacherId = t.teacherId
inner join UnivStudent st
on sc.studentId = st.studentId
left join UnivUserHonor uh
on sc.studentId = uh.uid
left join ( select uid , avg(score) as avgScore,
count(achivementid) as howmuch
from UnivAchivement
where uid in ( select studentId from sc )
and achivetype in ('L','W')
and pointcasetype in (3,5,6,7,8)
and created &gt; #{startTime} and created &lt; #{endTime}
group by uid ) ss
on sc.studentId = ss.uid
left join ( select studentId ,sum(ucl.timelength) as timelength, count( distinct ucl.connectlogid ) as loginCount
from sc
inner join UnivConnectLog ucl
on sc.studentId = ucl.uid
<if test="startTime!=null">
<![CDATA[
and ucl.created > #{startTime}
]]>
</if>
<if test="endTime!=null">
<![CDATA[
and ucl.endTime < #{endTime}
]]>
</if>
group by sc.studentId ) as uc
on sc.studentId = uc.studentId
order by sc.studentId
</sql>
<sql id="UnivstudentcountDetail_useStatForLibrarian">
select sc.studentId , s.schoolName , c.className ,
st.recognizecode , st.trueName ,
<!--uh.studyduration as timelength ,-->
case when uc.timelength>0 then uc.timelength else 0 end as timelength,
case when ss.avgScore &gt;0 then
round(ss.avgScore) else 0 end as score ,
case when ss.howmuch &gt;0 then
ss.howmuch else 0 end as studyCount,
t.trueName as teacherName
,
case when uc.loginCount &gt;0 then
uc.loginCount else 0 end as loginCount
from sc
inner join UnivClasses c
on sc.classesId = c.classesId and classtype=1
inner join university s
on s.schoolId = c.schoolId
inner join UnivTeacher t
on c.teacherId = t.teacherId
inner join UnivStudent st
on sc.studentId = st.studentId
left join UnivUserHonor uh
on sc.studentId = uh.uid
left join ( select uid , avg(score) as avgScore,
count(achivementid) as howmuch
from UnivAchivement
where uid in ( select studentId from sc )
and achivetype in ('L','W')
and pointcasetype in (3,5,6,7,8)
and created &gt; #{startTime} and created &lt; #{endTime}
group by uid ) ss
on sc.studentId = ss.uid
left join ( select studentId ,sum(ucl.timelength) as timelength, count( distinct ucl.connectlogid ) as loginCount
from sc
inner join UnivConnectLog ucl
on sc.studentId = ucl.uid
<if test="startTime!=null">
<![CDATA[
and ucl.created > #{startTime}
]]>
</if>
<if test="endTime!=null">
<![CDATA[
and ucl.endTime < #{endTime}
]]>
</if>
group by sc.studentId ) as uc
on sc.studentId = uc.studentId
<if test="checked == 1">
order by loginCount desc
</if>
<if test="checked == 2">
order by studyCount desc
</if>
<if test="checked == 3">
order by timelength desc
</if>
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
</sql>
<sql id="UnivteachercountDetail_useStat">
select a.teacherId , s.schoolName , t.loginNo , t.trueName ,
case when ta.assignmentCount &gt;0 then
ta.assignmentCount else 0 end as assignmentCount ,
case when cm.classMessageCount &gt;0 then
cm.classMessageCount else 0 end as classMessageCount,
case when te.examCount &gt;0 then
te.examCount else 0 end as examCount ,
case when uc.loginCount &gt;0 then
uc.loginCount else 0 end as loginCount
from tt as a
inner join University as s
on a.schoolId = s.schoolId
inner join UnivTeacher as t
on a.teacherId = t.teacherId
left join ( select teacherId , count( assignmentId ) as assignmentCount
from UnivAssignment
where teacherId in ( select teacherId from tt )
<if test="startTime!=null">
<![CDATA[
and created > #{startTime}
]]>
</if>
<if test="endTime!=null">
<![CDATA[
and created < #{endTime}
]]>
</if>
group by teacherId ) as ta
on a.teacherId = ta.teacherId
left join ( select teacherId , count( classmessageId ) as classMessageCount
from UnivClassMessage
where teacherId in ( select teacherId from tt )
<if test="startTime!=null">
<![CDATA[
and created > #{startTime}
]]>
</if>
<if test="endTime!=null">
<![CDATA[
and created < #{endTime}
]]>
</if>
group by teacherId ) as cm
on a.teacherId = cm.teacherId
left join ( select c.teacherId , count( distinct e.examId ) as examCount
from UnivClasses c
inner join UnivClassOwnExam coe
on c.teacherId in ( select teacherId from tt )
and c.status = 1
and c.classesid = coe.classesId
inner join UnivExam e
on coe.examId = e.examId
<if test="startTime!=null">
<![CDATA[
and e.created > #{startTime}
]]>
</if>
<if test="endTime!=null">
<![CDATA[
and e.created < #{endTime}
]]>
</if>
group by c.teacherId ) as te
on a.teacherid = te.teacherid
left join ( select teacherId , count( ucl.connectlogid ) as loginCount
from tt
inner join UnivConnectLog ucl
on tt.teacherId = ucl.uid
<if test="startTime!=null">
<![CDATA[
and ucl.created > #{startTime}
]]>
</if>
<if test="endTime!=null">
<![CDATA[
and ucl.endTime < #{endTime}
]]>
</if>
group by tt.teacherId ) as uc
on a.teacherid = uc.teacherid
order by a.teacherId
</sql>
<select id="getUnivAccountCountDetailByParentIdByStudent" parameterType="java.util.Map" resultType="AccountCountStudentDto">
with sc as (
select sc0.studentId , c0.classesId , c0.schoolId
from Area a0
inner join University as s0
on a0.parentId = #{areaId}
and s0.areaId = a0.areaId and s0.status = 1
inner join UnivClasses as c0
on s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
inner join UnivStudentOwnClass as sc0
on c0.classesId = sc0.classesId
and sc0.status = 1
order by sc0.studentId
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
)
<include refid="UnivstudentcountDetail_useStat"/>
</select>
<select id="getUnivAccountCountDetailCountByParentIdByStudent" parameterType="java.util.Map" resultType="Integer">
select count( sc.studentId )
from Area a
inner join University as s
on a.parentId = #{areaId} and a.areaId = s.areaId
and s.status = 1
inner join UnivClasses as c
on s.schoolId = c.schoolId
and c.classType = 1 and c.status = 1
inner join UnivStudentOwnClass as sc
on c.classesId = sc.classesId and sc.status = 1
</select>
<select id="getUnivAccountCountDetailByAreaIdByStudent" parameterType="java.util.Map" resultType="AccountCountStudentDto">
with sc as (
select sc0.studentId , c0.classesId , c0.schoolId
from University as s0
inner join UnivClasses as c0
on s0.areaId = #{areaId} and s0.status = 1
and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
inner join UnivStudentOwnClass as sc0
on c0.classesId = sc0.classesId
and sc0.status = 1
order by sc0.studentId
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
)
<include refid="UnivstudentcountDetail_useStat"/>
</select>
<select id="getUnivAccountCountDetailCountByAreaIdByStudent" parameterType="java.util.Map" resultType="Integer">
select count( sc.studentId )
from University as s
inner join UnivClasses as c
on s.areaId = #{areaId} and s.status = 1
and s.schoolId = c.schoolId
and c.classType = 1 and c.status = 1
inner join UnivStudentOwnClass as sc
on c.classesId = sc.classesId and sc.status = 1
</select>
<select id="getUnivAccountCountDetailBySchoolIdByStudent" parameterType="java.util.Map" resultType="AccountCountStudentDto">
with sc as (
select sc0.studentId , c0.classesId , c0.schoolId
from UnivClasses as c0
inner join UnivStudentOwnClass as sc0
on c0.schoolId = #{schoolId} and c0.classtype = 1
and c0.classesId = sc0.classesId and sc0.status = 1
order by sc0.studentId
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
)
<include refid="UnivstudentcountDetail_useStat"/>
</select>
<select id="getUnivAccountCountDetailCountBySchoolIdByStudent" parameterType="java.util.Map" resultType="Integer">
select count( sc.studentId )
from UnivClasses as c
inner join UnivStudentOwnClass as sc
on c.schoolId = #{schoolId} and c.classtype = 1
and c.classesId = sc.classesId and sc.status = 1
</select>
<select id="getUnivAccountCountDetailByClassesIdByStudent" parameterType="java.util.Map" resultType="AccountCountStudentDto">
with sc as ( select studentId , classesId
from UnivstudentOwnClass
where classesId = #{classesId} and status =1
order by studentId
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
)
<include refid="UnivstudentcountDetail_useStat"/>
</select>
<select id="getUnivAccountCountDetailByClassesIdByStudentForAll" parameterType="java.util.Map" resultType="AccountCountStudentDto">
with sc as ( select uc.studentId , uc.classesId
from UnivstudentOwnClass uc inner join UnivClasses c on uc.classesId = c.classesId
where c.schoolId = #{schoolId} and c.status =1
)
<include refid="UnivstudentcountDetail_useStatForLibrarian"/>
</select>
<select id="getUnivAccountCountDetailByClassesIdByStudentForLibrarian" parameterType="java.util.Map" resultType="AccountCountStudentDto">
with sc as ( select studentId , classesId
from UnivstudentOwnClass
where classesId = #{classesId} and status =1
)
<include refid="UnivstudentcountDetail_useStatForLibrarian"/>
</select>
<select id="getUnivAccountCountDetailCountByClassesIdByStudentForAll" parameterType="java.util.Map" resultType="Integer">
select count( sc.studentId )
from UnivstudentOwnClass sc inner join UnivClasses c on sc.classesId = c.classesId
inner join university s
on s.schoolId = c.schoolId
inner join UnivTeacher t
on c.teacherId = t.teacherId
inner join UnivStudent st
on sc.studentId = st.studentId
where c.schoolId = #{schoolId} and c.status =1
</select>
<select id="getUnivAccountCountDetailCountByClassesIdByStudent" parameterType="java.util.Map" resultType="Integer">
select count( sc.studentId )
from UnivStudentOwnClass sc inner join UnivClasses c
on sc.classesId = c.classesId
inner join university s
on s.schoolId = c.schoolId
inner join UnivTeacher t
on c.teacherId = t.teacherId
inner join UnivStudent st
on sc.studentId = st.studentId
where sc.classesId =#{classesId} and sc.status = 1
</select>
<select id="getUnivAccountCountDetailByParentIdByTeacher" parameterType="java.util.Map" resultType="AccountCountTeacherDto">
with tt as ( select t.teacherId , t.schoolId
from Area a
inner join University s
on a.parentId = #{areaId}
and s.areaid = a.areaId and s.status = 1
inner join UnivTeacher t
on t.schoolId = s.schoolid and t.status = 1
order by t.teacherId
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
)
<include refid="UnivteachercountDetail_useStat"/>
</select>
<select id="getUnivAccountCountDetailByAreaIdByTeacher" parameterType="java.util.Map" resultType="AccountCountTeacherDto">
with tt as ( select t.teacherId , t.schoolId
from University s
inner join UnivTeacher t
on s.areaId =#{areaId} and s.status = 1
and t.schoolId = s.schoolid and t.status = 1
order by t.teacherId
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
)
<include refid="UnivteachercountDetail_useStat"/>
</select>
<select id="getUnivAccountCountDetailBySchoolIdByTeacher" parameterType="java.util.Map" resultType="AccountCountTeacherDto">
with tt as ( select t.teacherId , t.schoolId
from UnivTeacher t
where t.schoolId = #{schoolId} and t.status = 1
order by t.teacherId
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
)
<include refid="UnivteachercountDetail_useStat"/>
</select>
<select id="getUnivAccountCountDetailByClassesIdByTeacher" parameterType="java.util.Map" resultType="AccountCountTeacherDto">
with tt as ( select c.teacherId , c.schoolId
from UnivClasses c )
<include refid="UnivteachercountDetail_useStat"/>
</select>
<select id="getUnivAccountCountDetailCountByParentIdByTeacher" parameterType="java.util.Map" resultType="Integer">
select count( t.teacherId )
from Area as A
inner join University as S
on a.parentId = #{areaId}
and s.areaId = a.areaId and s.status = 1
inner join UnivTeacher as T
on s.schoolId = t.schoolId and t.status = 1
</select>
<select id="getUnivAccountCountDetailCountByAreaIdByTeacher" parameterType="java.util.Map" resultType="Integer">
select count( t.teacherId )
from University as S
inner join UnivTeacher as T
on s.areaId = #{areaId} and s.status = 1
and s.schoolId = t.schoolId and t.status = 1
</select>
<select id="getUnivAccountCountDetailCountBySchoolIdByTeacher" parameterType="java.util.Map" resultType="Integer">
select count( tt.teacherId )
from UnivTeacher tt
where tt.schoolId =#{schoolId} and tt.status = 1
</select>
<select id="getUnivAccountCountDetailCountByClassesIdByTeacher" parameterType="java.util.Map" resultType="Integer">
select count( c.teacherId )
from UnivClasses c
where c.classesId =#{classesId}
</select>
</mapper>