select sc.studentId , s.schoolName , c.className ,
st.recognizecode , st.trueName ,
uh.studyduration as timelength ,
case when ss.avgScore >0 then
round(ss.avgScore) else 0 end as score ,
case when ss.howmuch >0 then
ss.howmuch else 0 end as studyCount,
uo.endTime ,
case when oa.status >0 then
oa.status else 0 end as status,
t.trueName as teacherName
from sc
inner join Classes c
on sc.classesId = c.classesId
inner join School s
on s.schoolId = c.schoolId
inner join Teacher t
on c.teacherId = t.teacherId
inner join Student st
on sc.studentId = st.studentId
left join UserHonor uh
on sc.studentId = uh.uid
left join ( select uid , avg(score) as avgScore,
count(achivementid) as howmuch
from Achivement
where uid in ( select studentId from sc )
and achivetype in ('L','W')
and pointcasetype in (3,4,5,6,7,8)
and created > #{startTime} and created < #{endTime}
group by uid ) ss
on sc.studentId = ss.uid
left join ( select uid , max( endTime ) as endTime
from UserOwnLesson
where uid in ( select studentId from sc )
group by uid ) uo
on sc.studentId = uo.uid
left join ( select uid , count(uid) as status
from OrderInfo
where uid in ( select studentId from sc )
and payway > 0 and ispayed = 1
and created > #{startTime} and created < #{endTime}
group by uid ) oa
on sc.studentId = oa.uid
order by sc.studentId
select a.teacherId , s.schoolName , t.loginNo , t.trueName ,
case when ta.assignmentCount >0 then
ta.assignmentCount else 0 end as assignmentCount ,
case when cm.classMessageCount >0 then
cm.classMessageCount else 0 end as classMessageCount,
case when te.examCount >0 then
te.examCount else 0 end as examCount
,
uo.endTime
from tt as a
inner join School as s
on a.schoolId = s.schoolId
inner join Teacher as t
on a.teacherId = t.teacherId
left join ( select teacherId , count( assignmentId ) as assignmentCount
from Assignment
where teacherId in ( select teacherId from tt )
#{startTime}
]]>
and status != 0
group by teacherId ) as ta
on a.teacherId = ta.teacherId
left join ( select teacherId , count( classmessageId ) as classMessageCount
from ClassMessage
where teacherId in ( select teacherId from tt )
#{startTime}
]]>
group by teacherId ) as cm
on a.teacherId = cm.teacherId
left join ( select teacherId , count( distinct e.examId ) as examCount
from Classes c
inner join ClassOwnExam coe
on c.teacherId in ( select teacherId from tt )
and c.status = 1
and c.classesid = coe.classesId
inner join Exam e
on coe.examId = e.examId
#{startTime}
]]>
group by c.teacherId ) as te
on a.teacherid = te.teacherid
left join ( select uol.uid , max( uol.endTime ) as endTime
from tt
inner join UserOwnLesson uol
on tt.teacherId = uol.uid
group by uol.uid ) as uo
on a.teacherId = uo.uid
order by a.teacherId
with sc as (
select sc0.studentId , c0.classesId , c0.schoolId
from Area a0
inner join School as s0
on a0.parentId = #{areaId}
and s0.areaId = a0.areaId and s0.status = 1
inner join Classes as c0
on s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
inner join StudentOwnClass as sc0
on c0.classesId = sc0.classesId
and sc0.status = 1
order by sc0.studentId
limit #{pageSize}
offset #{offset}
)
select count( sc.studentId )
from Area a
inner join School as s
on a.parentId = #{areaId} and a.areaId = s.areaId
and s.status = 1
inner join Classes as c
on s.schoolId = c.schoolId
and c.classType = 1 and c.status = 1
inner join StudentOwnClass as sc
on c.classesId = sc.classesId and sc.status = 1
with sc as (
select sc0.studentId , c0.classesId , c0.schoolId
from School as s0
inner join Classes 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 StudentOwnClass as sc0
on c0.classesId = sc0.classesId
and sc0.status = 1
order by sc0.studentId
limit #{pageSize}
offset #{offset}
)
select count( sc.studentId )
from School as s
inner join Classes 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 StudentOwnClass as sc
on c.classesId = sc.classesId and sc.status = 1
with sc as (
select sc0.studentId , c0.classesId , c0.schoolId
from Classes as c0
inner join StudentOwnClass as sc0
on c0.schoolId = #{schoolId} and c0.classtype = 1
and c0.classesId = sc0.classesId and sc0.status = 1
order by sc0.studentId
limit #{pageSize}
offset #{offset}
)
select count( sc.studentId )
from Classes as c
inner join StudentOwnClass as sc
on c.schoolId = #{schoolId} and c.classtype = 1
and c.classesId = sc.classesId and sc.status = 1
with sc as ( select studentId , classesId
from studentOwnClass
where classesId = #{classesId} and status =1
order by studentId
limit #{pageSize}
offset #{offset}
)
select count( sc.studentId )
from StudentOwnClass sc
where sc.classesId =#{classesId} and sc.status = 1
with tt as ( select t.teacherId , t.schoolId
from Area a
inner join School s
on a.parentId = #{areaId}
and s.areaid = a.areaId and s.status = 1
inner join Teacher t
on t.schoolId = s.schoolid and t.status = 1
order by t.teacherId
limit #{pageSize}
offset #{offset}
)
with tt as ( select t.teacherId , t.schoolId
from School s
inner join Teacher t
on s.areaId =#{areaId} and s.status = 1
and t.schoolId = s.schoolid and t.status = 1
order by t.teacherId
limit #{pageSize}
offset #{offset}
)
with tt as ( select t.teacherId , t.schoolId
from Teacher t
where t.schoolId = #{schoolId} and t.status = 1
order by t.teacherId
limit #{pageSize}
offset #{offset}
)
with tt as ( select c.teacherId , c.schoolId
from Classes c )
select count( t.teacherId )
from Area as A
inner join School as S
on a.parentId = #{areaId}
and s.areaId = a.areaId and s.status = 1
inner join Teacher as T
on s.schoolId = t.schoolId and t.status = 1
select count( t.teacherId )
from School as S
inner join Teacher as T
on s.areaId = #{areaId} and s.status = 1
and s.schoolId = t.schoolId and t.status = 1
select count( tt.teacherId )
from Teacher tt
where tt.schoolId =#{schoolId} and tt.status = 1
select count( c.teacherId )
from Classes c
where c.classesId =#{classesId}
with clsyear as (
select c0.*, case when classlevel = 1 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear+3
when classlevel = 2 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear
when classlevel = 3 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
when classlevel =4 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
else EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +2
end
as gradeyear
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
),
temp as(
select soc.studentid,c.classesid from clsyear c
inner join school s on c.schoolid=s.schoolid and c.status=1 and c.classtype=1
and
s.areaid = #{areaId}
and
s.areaid in (select areaid from area where parentid = #{parentId})
and
s.areaid in (select areaid from area where parentid in
(select areaid from area where parentid=#{provinceId}) )
and
s.schoolid = #{schoolId}
and
c.classesid=#{filtClassesId}
and
c.classLevel=#{classLevel}
and
c.schoolYear=#{schoolYear}
inner join studentownclass soc on soc.classesid=c.classesid and soc.status=1
and
c.classesId = #{classesId}
inner join student st on st.studentid=soc.studentid and st.truename=#{username}
inner join student st on st.studentid=soc.studentid and st.recognizecode=#{recognizeCode}
where c.gradeyear < 7
),
classtemp as(
select s.studentid,c.classesid from temp s
inner join studentownclass c
on c.studentid = s.studentid and c.status=1
inner join clsyear cs on cs.classesid=c.classesid and cs.status=1 and cs.gradeyear < 7
),
sc as (
select sc.studentid,case when t.assigCount>0 then t.assigCount else 0 end as assignCount from
temp sc left join
(select sc.studentid,sum(case when fs.lessoncount=fs.completecount then 1 else 0 end) as assigCount
from classtemp sc inner join assigntoclass ao on sc.classesid=ao.classesId
inner join finishassignstat fs on fs.assignmentid=ao.assignmentid and fs.uid=sc.studentid
inner join assignment ag on ag.assignmentid = ao.assignmentid
and ag.created>#{startTime} and ag.created<=#{endTime}
and ag.status != 0
group by sc.studentId) as t
on t.studentid=sc.studentid
order by assignCount ${orderWay}, sc.studentid
limit #{pageSize}
offset #{offset}
)
select sc.studentId ,sc.assignCount, s.schoolName , c.className,c.classLevel,c.schoolYear ,
st.recognizecode , st.trueName ,
uh.studyduration as timelength ,
case when ss.avgScore >0 then
round(ss.avgScore) else 0 end as score ,
case when ss.howmuch >0 then
ss.howmuch else 0 end as studyCount,uo.endTime ,
case when oa.status >0 then
oa.status else 0 end as status,
t.trueName as teacherName ,
case when ec.examCount>0 and hc.hearCount>0 then ec.examCount+hc.hearCount
when ec.examCount>0 then ec.examCount
when hc.hearCount>0 then hc.hearCount
else 0 end as examCount,
case when bl.medalCount>0 then bl.medalCount
else 0 end as medalCount
from sc
inner join studentownclass soc on sc.studentid = soc.studentid and soc.status=1
inner join clsyear c on soc.classesId = c.classesId and c.gradeyear < 7
inner join School s on s.schoolId = c.schoolId
inner join Teacher t on c.teacherId = t.teacherId
inner join Student st on sc.studentId = st.studentId
left join (
SELECT ea.userId uid, count(ea.examId) examCount
FROM examanswer ea
inner join exam e
on ea.userId
in ( select studentId from sc ) and ea.examid=e.examid
and ea.created>e.starttime and ea.created <=e.endtime
and ea.created>#{startTime} and ea.created<=#{endTime}
group BY ea.userId ) ec
on sc.studentid = ec.uid
left join (
SELECT ea.userId uid, count(ea.examId) hearCount
FROM HearAnswer ea
inner join hearExam e
on ea.userId in ( select studentId from sc ) and ea.examid=e.examid
and ea.created>e.starttime and ea.created <=e.endtime
and ea.created>#{startTime} and ea.created<=#{endTime}
group BY ea.userId ) hc
on sc.studentid = hc.uid
left join UserHonor uh
on sc.studentId = uh.uid
left join ( select uid , avg(score) as
avgScore,
count(achivementid) as howmuch
from Achivement
where uid in (
select studentId from sc )
and achivetype in ('L','W')
and pointcasetype in (3,4,5,6,7,8)
and created > #{startTime} and created < #{endTime}
group by uid ) ss on sc.studentId = ss.uid
left join ( select uid , max(endTime ) as endTime
from UserOwnLesson
where uid in ( select studentId from sc )
group by uid ) uo on sc.studentId = uo.uid
left join ( select uid , count(uid) as status
from OrderInfo
where uid in (
select studentId from sc )
and payway > 0 and ispayed = 1
and created > #{startTime} and created < #{endTime}
group by uid ) oa
on sc.studentId = oa.uid
left join ( select userid , count(userid) as medalCount
from badgelog
where userid in (
select studentId from sc )
and badgecaseid = 4 and badgetype = 1
and created > #{startTime} and created < #{endTime}
group by userid ) bl
on sc.studentId = bl.userid
order by assignCount ${orderWay}
with clsyear as (
select c0.*, case when classlevel = 1 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear+3
when classlevel = 2 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear
when classlevel = 3 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
when classlevel =4 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
else EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +2
end
as gradeyear
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
)
select count( distinct sc.studentId )
from clsyear as c
inner join school as s
on s.status = 1 and s.schoolId = c.schoolId
and c.classType = 1 and c.status = 1
and
s.areaid = #{areaId}
and
s.areaid in (select areaid from area where parentid = #{parentId})
and
s.areaid in (select areaid from area where parentid in
(select areaid from area where parentid=#{provinceId}) )
and
s.schoolid = #{schoolId}
and
c.classesid=#{filtClassesId}
and
c.classLevel=#{classLevel}
and
c.schoolYear=#{schoolYear}
inner join StudentOwnClass as sc
on c.classesId = sc.classesId and sc.status = 1
inner join student st on st.studentid=sc.studentid and st.status=1
and st.truename=#{username}
and st.recognizecode=#{recognizeCode}
inner join connectlog cnco on cnco.uid = st.studentid
and cnco.areaId = #{areaId}
#{startTime}
]]>
left join connectlog cnco on cnco.uid = st.studentid
#{startTime}
]]>
left join teacher t on t.teacherid=c.teacherid and t.status=1
where c.gradeyear < 7
and c.classesId = #{classesId} and c.classType = 1 and c.status = 1
with clsyear as (
select c0.*, case when classlevel = 1 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear+3
when classlevel = 2 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear
when classlevel = 3 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
when classlevel =4 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
else EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +2
end
as gradeyear
from Classes as c0
where c0.classType = 1 and c0.status = 1
and c0.areaid = #{areaId}
)
select count(distinct s.schoolid)
from clsyear as c
inner join school as s
on s.status = 1 and s.schoolId = c.schoolId
and c.classType = 1 and c.status = 1 inner join studentownclass as stc on stc.classesid = c.classesid and stc.areaid = #{areaId}
and
s.areaid = #{areaId}
and
s.areaid in (select areaid from area where parentid = #{parentId})
and
s.areaid in (select areaid from area where parentid in
(select areaid from area where parentid=#{provinceId}) )
where c.gradeyear < 7
with sc as( select sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname,st.truename truename,
st.recognizecode,c0.teacherId,c0.schoolId,sum(cnco.timelength) as timelength
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
and
Exists (select areaid from area as ar where s0.areaid = ar.areaid and ar.parentid = #{parentId} )
and
EXISTS (select s0.areaid from (select ar.areaid from area as ar where EXISTS (select b.areaid from area as b where ar.areaid = b.areaid and b.parentid = #{provinceId})) as b2 where s0.areaid = b2.areaid)
and
s0.schoolid = #{schoolId}
and
c0.classesid=#{filtClassesId}
and
c0.classLevel=#{classLevel}
and
c0.schoolYear=#{schoolYear}
inner join StudentOwnClass as sc0
on c0.classesId = sc0.classesId and sc0.status = 1
and sc0.areaId = #{areaId}
and
c0.classesId=#{classesId}
inner join student st on st.studentid=sc0.studentid and st.status=1
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
inner join connectlog cnco on cnco.uid = st.studentid
and cnco.areaId = #{areaId}
#{startTime}
]]>
left join connectlog cnco on cnco.uid = st.studentid
and cnco.areaId = #{areaId}
#{startTime}
]]>
left join UserHonor uh on st.studentId = uh.uid
and uh.areaId = #{areaId}
group by sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname, truename,
st.recognizecode,c0.teacherId,c0.schoolId, uh.studyduration
order by
timelength ${orderWay} nulls last,
sc0.studentId
),scall as (select sum(timelength) as alltimelength from sc )
select sc.studentId ,scl.schoolName, sc.schoolYear,sc.classLevel,sc.className,tr.truename teacherName,sc.recognizecode,sc.trueName,sc.timelength as timelength ,case when alltimelength >0 then alltimelength
else 0 end as alltimelength from sc inner join school scl on sc.schoolid = scl.schoolid left join teacher tr on sc.teacherid = tr.teacherId ,scall
limit #{pageSize}
offset #{offset}
with sc as (
select sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname,st.truename truename,
st.recognizecode,c0.teacherId,c0.schoolId
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
and
Exists (select areaid from area as ar where s0.areaid = ar.areaid and ar.parentid = #{parentId} )
and
EXISTS (select s0.areaid from (select ar.areaid from area as ar where EXISTS (select b.areaid from area as b where ar.areaid = b.areaid and b.parentid = #{provinceId})) as b2 where s0.areaid = b2.areaid)
and
s0.schoolid = #{schoolId}
and
c0.classesid=#{filtClassesId}
and
c0.classLevel=#{classLevel}
and
c0.schoolYear=#{schoolYear}
inner join StudentOwnClass as sc0
on c0.classesId = sc0.classesId and sc0.status = 1
and sc0.areaId = #{areaId}
and
c0.classesId=#{classesId}
inner join student st on st.studentid=sc0.studentid and st.status=1
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
inner join connectlog cnco on cnco.uid = st.studentid
and cnco.areaId = #{areaId}
#{startTime}
]]>
group by sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname, truename,
st.recognizecode,c0.teacherId,c0.schoolId
order by
sc0.studentId
),
assignmentres as (select sc.studentid,ao.assignmentid
from sc inner join assigntoclass ao on sc.classesid=ao.classesId group by ao.assignmentid,sc.studentid),
ag as (select sc.studentid,sum(case when fs.lessoncount=fs.completecount then 1 else 0 end) as assignCount
from assignmentres as sc
inner join finishassignstat fs on fs.assignmentid=sc.assignmentid
and fs.areaid = #{areaId}
and fs.uid=sc.studentid and fs.created>#{startTime} and fs.created<=#{endTime}
inner join assignment ag on ag.assignmentid = sc.assignmentid
and ag.status = 1
group by sc.studentId),
agall as (select sum(assignCount) as allassignCount from ag)
select sc.studentid,case when ag.assignCount > 0 then ag.assignCount else 0 end as assignCount,case when allassignCount >0 then allassignCount
else 0 end as allassignCount from sc left join ag on ag.studentid = sc.studentid ,agall
limit #{pageSize}
offset #{offset}
with sc as (
select sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname,st.truename truename,
st.recognizecode,c0.teacherId,c0.schoolId
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
and
Exists (select areaid from area as ar where s0.areaid = ar.areaid and ar.parentid = #{parentId} )
and
EXISTS (select s0.areaid from (select ar.areaid from area as ar where EXISTS (select b.areaid from area as b where ar.areaid = b.areaid and b.parentid = #{provinceId})) as b2 where s0.areaid = b2.areaid)
and
s0.schoolid = #{schoolId}
and
c0.classesid=#{filtClassesId}
and
c0.classLevel=#{classLevel}
and
c0.schoolYear=#{schoolYear}
inner join StudentOwnClass as sc0
on c0.classesId = sc0.classesId and sc0.status = 1
and sc0.areaId = #{areaId}
and
c0.classesId=#{classesId}
inner join student st on st.studentid=sc0.studentid and st.status=1
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
inner join connectlog cnco on cnco.uid = st.studentid
and cnco.areaId = #{areaId}
#{startTime}
]]>
group by sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname, truename,
st.recognizecode,c0.teacherId,c0.schoolId
order by
sc0.studentId
),
ss as ( select uid , avg(score) as avgScore,
count(achivementid) as howmuch
from Achivement
where
uid in ( select studentId from sc )
and achivetype in ('L','W')
and pointcasetype in (3,4,5,6,7,8)
and areaid = #{areaId}
and created > #{startTime} and created < #{endTime}
group by uid ),
ssall as (select avg(case when avgScore is null then 0 else avgScore end) as allavgScore,sum(ss.howmuch) as allhowmuch from sc left join ss on sc.studentId=ss.uid)
select sc.studentId,
case when ss.avgScore >0 then round(ss.avgScore,2) else 0 end as score ,
case when ss.howmuch > 0 then
ss.howmuch else 0 end as studyCount ,
case when allavgScore >0 then round(allavgScore,2)
else 0 end as allavgScore ,
case when allhowmuch >0 then allhowmuch
else 0 end as allhowmuch
from sc left join ss on sc.studentid = ss.uid,ssall
limit #{pageSize}
offset #{offset}
with sc as (
select sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname,st.truename truename,
st.recognizecode,c0.teacherId,c0.schoolId
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
and
Exists (select areaid from area as ar where s0.areaid = ar.areaid and ar.parentid = #{parentId} )
and
EXISTS (select s0.areaid from (select ar.areaid from area as ar where EXISTS (select b.areaid from area as b where ar.areaid = b.areaid and b.parentid = #{provinceId})) as b2 where s0.areaid = b2.areaid)
and
s0.schoolid = #{schoolId}
and
c0.classesid=#{filtClassesId}
and
c0.classLevel=#{classLevel}
and
c0.schoolYear=#{schoolYear}
inner join StudentOwnClass as sc0
on c0.classesId = sc0.classesId and sc0.status = 1
and sc0.areaId = #{areaId}
and
c0.classesId=#{classesId}
inner join student st on st.studentid=sc0.studentid and st.status=1
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
inner join connectlog cnco on cnco.uid = st.studentid
and cnco.areaId = #{areaId}
#{startTime}
]]>
group by sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname, truename,
st.recognizecode,c0.teacherId,c0.schoolId
order by
sc0.studentId
),
uo as ( select uid , max( endTime ) as endTime
from UserOwnLesson
where uid in ( select studentId from sc )
and areaid = #{areaId}
group by uid ),
oa as ( select uid , count(uid) as status
from OrderInfo
where uid in ( select studentId from sc )
and payway > 0 and ispayed = 1
and created > #{startTime} and created < #{endTime}
group by uid )
select sc.studentid,uo.endTime ,
case when oa.status >0 then
oa.status else 0 end as status from sc left join uo on uo.uid = sc.studentid left join oa on uo.uid = oa.uid
limit #{pageSize}
offset #{offset}
with sc as (
select sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname,st.truename truename,
st.recognizecode,c0.teacherId,c0.schoolId
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
and
Exists (select areaid from area as ar where s0.areaid = ar.areaid and ar.parentid = #{parentId} )
and
EXISTS (select s0.areaid from (select ar.areaid from area as ar where EXISTS (select b.areaid from area as b where ar.areaid = b.areaid and b.parentid = #{provinceId})) as b2 where s0.areaid = b2.areaid)
and
s0.schoolid = #{schoolId}
and
c0.classesid=#{filtClassesId}
and
c0.classLevel=#{classLevel}
and
c0.schoolYear=#{schoolYear}
inner join StudentOwnClass as sc0
on c0.classesId = sc0.classesId and sc0.status = 1
and sc0.areaId = #{areaId}
and
c0.classesId=#{classesId}
inner join student st on st.studentid=sc0.studentid and st.status=1
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
inner join connectlog cnco on cnco.uid = st.studentid
and cnco.areaId = #{areaId}
#{startTime}
]]>
group by sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname, truename,
st.recognizecode,c0.teacherId,c0.schoolId
order by
sc0.studentId
),
ec as (
SELECT ea.userId uid, count(ea.examId) examCount
FROM
exam e inner join examanswer ea
on ea.userId
in ( select studentId from sc ) and ea.examid=e.examid
and ea.areaid = #{areaId}
and ea.created>e.starttime and ea.created <=e.endtime
and ea.created>#{startTime} and ea.created<= #{endTime}
group BY ea.userId ),
ecall as (select sum(examCount) as examCountall from ec)
select sc.studentid,case when ec.examCount >0 then ec.examCount else 0 end as examCount, case when examCountall >0 then examCountall
else 0 end as examCountall from sc left join ec on ec.uid = sc.studentid ,ecall
limit #{pageSize}
offset #{offset}
with sc as (
select sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname,st.truename truename,
st.recognizecode,c0.teacherId,c0.schoolId
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
and
Exists (select areaid from area as ar where s0.areaid = ar.areaid and ar.parentid = #{parentId} )
and
EXISTS (select s0.areaid from (select ar.areaid from area as ar where EXISTS (select b.areaid from area as b where ar.areaid = b.areaid and b.parentid = #{provinceId})) as b2 where s0.areaid = b2.areaid)
and
s0.schoolid = #{schoolId}
and
c0.classesid=#{filtClassesId}
and
c0.classLevel=#{classLevel}
and
c0.schoolYear=#{schoolYear}
inner join StudentOwnClass as sc0
on c0.classesId = sc0.classesId and sc0.status = 1
and sc0.areaId = #{areaId}
and
c0.classesId=#{classesId}
inner join student st on st.studentid=sc0.studentid and st.status=1
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
inner join connectlog cnco on cnco.uid = st.studentid
and cnco.areaId = #{areaId}
#{startTime}
]]>
group by sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname, truename,
st.recognizecode,c0.teacherId,c0.schoolId
order by
sc0.studentId
),
bl as ( select userid , count(userid) as medalCount
from badgelog
where userid in (
select studentId from sc )
and badgecaseid = 4 and badgetype = 1
and areaid = #{areaId}
and created > #{startTime} and created < #{endTime}
group by userid ),
blall as (select sum(medalCount) as medalCountall from bl)
select sc.studentid , case when bl.medalCount >0 then bl.medalCount
else 0 end as medalCount,case when medalCountall >0 then medalCountall
else 0 end as medalCountall from sc left join bl on sc.studentid = bl.userid,blall
limit #{pageSize}
offset #{offset}
with sc as (
select sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname,st.truename truename,
st.recognizecode,c0.teacherId,c0.schoolId
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
and
Exists (select areaid from area as ar where s0.areaid = ar.areaid and ar.parentid = #{parentId} )
and
EXISTS (select s0.areaid from (select ar.areaid from area as ar where EXISTS (select b.areaid from area as b where ar.areaid = b.areaid and b.parentid = #{provinceId})) as b2 where s0.areaid = b2.areaid)
and
s0.schoolid = #{schoolId}
and
c0.classesid=#{filtClassesId}
and
c0.classLevel=#{classLevel}
and
c0.schoolYear=#{schoolYear}
inner join StudentOwnClass as sc0
on c0.classesId = sc0.classesId and sc0.status = 1
and sc0.areaId = #{areaId}
and
c0.classesId=#{classesId}
inner join student st on st.studentid=sc0.studentid and st.status=1
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
inner join connectlog cnco on cnco.uid = st.studentid
and cnco.areaId = #{areaId}
#{startTime}
]]>
group by sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname, truename,
st.recognizecode,c0.teacherId,c0.schoolId
order by
sc0.studentId
),
dbc as (select db.uid,count(db.uid) as dubCount from dubuservoice as db where EXISTS (select sc.studentId from sc where sc.studentId = db.uid) and db.isdelete = 0
and db.areaid = #{areaId}
and db.created > #{startTime} and db.created < #{endTime} group by db.uid),
abcall as (select sum(dubCount) as dubCountall from dbc )
select sc.studentid,case when dubCountall >0 then dubCountall
else 0 end as dubCountall, case when dbc.dubCount >0 then dbc.dubCount
else 0 end as dubCount from sc left join dbc on sc.studentid= dbc.uid,abcall
limit #{pageSize}
offset #{offset}
with sc as (
select sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname,st.truename truename,
st.recognizecode,c0.teacherId,c0.schoolId
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
and
Exists (select areaid from area as ar where s0.areaid = ar.areaid and ar.parentid = #{parentId} )
and
EXISTS (select s0.areaid from (select ar.areaid from area as ar where EXISTS (select b.areaid from area as b where ar.areaid = b.areaid and b.parentid = #{provinceId})) as b2 where s0.areaid = b2.areaid)
and
s0.schoolid = #{schoolId}
and
c0.classesid=#{filtClassesId}
and
c0.classLevel=#{classLevel}
and
c0.schoolYear=#{schoolYear}
inner join StudentOwnClass as sc0
on c0.classesId = sc0.classesId and sc0.status = 1
and sc0.areaId = #{areaId}
and
c0.classesId=#{classesId}
inner join student st on st.studentid=sc0.studentid and st.status=1
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
inner join connectlog cnco on cnco.uid = st.studentid
and cnco.areaId = #{areaId}
#{startTime}
]]>
group by sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname, truename,
st.recognizecode,c0.teacherId,c0.schoolId
order by
timelength ${orderWay} nulls last,
sc0.studentId
),
rsc as (select rs.uid,count(rs.raceid) as raceCount from raceScore as rs where EXISTS (select sc.studentId from sc where sc.studentId = rs.uid)
and rs.areaid = #{areaId}
and rs.created > #{startTime} and rs.created < #{endTime} group by rs.uid),
rscall as (select sum(raceCount) as raceCountall from rsc )
select sc.studentid,case when rsc.raceCount >0 then rsc.raceCount
else 0 end as raceCount,case when raceCountall >0 then raceCountall
else 0 end as raceCountall from sc left join rsc on sc.studentid = rsc.uid ,rscall
limit #{pageSize}
offset #{offset}
with sc as (
select sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname,st.truename truename,
st.recognizecode,c0.teacherId,c0.schoolId
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
and
Exists (select areaid from area as ar where s0.areaid = ar.areaid and ar.parentid = #{parentId} )
and
EXISTS (select s0.areaid from (select ar.areaid from area as ar where EXISTS (select b.areaid from area as b where ar.areaid = b.areaid and b.parentid = #{provinceId})) as b2 where s0.areaid = b2.areaid)
and
s0.schoolid = #{schoolId}
and
c0.classesid=#{filtClassesId}
and
c0.classLevel=#{classLevel}
and
c0.schoolYear=#{schoolYear}
inner join StudentOwnClass as sc0
on c0.classesId = sc0.classesId and sc0.status = 1
and sc0.areaId = #{areaId}
and
c0.classesId=#{classesId}
inner join student st on st.studentid=sc0.studentid and st.status=1
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
and not EXISTS(select 1 from connectlog as cnco where st.studentid = cnco.uid
and cnco.areaId = #{areaId}
#{startTime}
]]>
)
group by sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname, truename,
st.recognizecode,c0.teacherId,c0.schoolId
order by
sc0.studentId
),
uo as ( select uid , max( endTime ) as endTime
from UserOwnLesson
where uid in ( select studentId from sc )
and areaid = #{areaId}
group by uid ),
oa as ( select uid , count(uid) as status
from OrderInfo
where uid in ( select studentId from sc )
and payway != 0 and ispayed != 0
and created > #{startTime} and created < #{endTime}
group by uid )
select sc.studentId ,sl.schoolName, sc.schoolYear,sc.classLevel,sc.classesId,sc.className,tr.truename teacherName,sc.recognizecode,sc.trueName,
case when oa.status >0 then
oa.status else 0 end as status,uo.endTime
from sc
inner join school sl on sl.schoolid=sc.schoolId
left join teacher tr on tr.teacherid = sc.teacherId and tr.status = 1
left join
uo
on sc.studentId = uo.uid
left join
oa
on sc.studentId = oa.uid
order by
sc.timelength ${orderWay} nulls last ,
sc.studentid
limit #{pageSize}
offset #{offset}
with sc as (
select sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname,st.truename truename,
st.recognizecode,c0.teacherId,c0.schoolId
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
and
Exists (select areaid from area as ar where s0.areaid = ar.areaid and ar.parentid = #{parentId} )
and
EXISTS (select s0.areaid from (select ar.areaid from area as ar where EXISTS (select b.areaid from area as b where ar.areaid = b.areaid and b.parentid = #{provinceId})) as b2 where s0.areaid = b2.areaid)
and
s0.schoolid = #{schoolId}
and
c0.classesid=#{filtClassesId}
and
c0.classLevel=#{classLevel}
and
c0.schoolYear=#{schoolYear}
inner join StudentOwnClass as sc0
on c0.classesId = sc0.classesId and sc0.status = 1
and sc0.areaId = #{areaId}
and
c0.classesId=#{classesId}
inner join student st on st.studentid=sc0.studentid and st.status=1
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
and not EXISTS(select 1 from connectlog as cnco where st.studentid = cnco.uid
and cnco.areaId = #{areaId}
#{startTime}
]]>
)
group by sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname, truename,
st.recognizecode,c0.teacherId,c0.schoolId
)
select count(*)
from sc
inner join school sl on sl.schoolid=sc.schoolId
with clsyear as (
select c0.*, case when classlevel = 1 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear+3
when classlevel = 2 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear
when classlevel = 3 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
when classlevel =4 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
else EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +2
end
as gradeyear
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
),
sc as (
select sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname,st.truename truename,
st.recognizecode,c0.teacherId,c0.schoolId,sum(cnco.timelength) as timelength
from clsyear as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
and
Exists (select areaid from area as ar where s0.areaid = ar.areaid and ar.parentid = #{parentId} )
and
EXISTS (select s0.areaid from (select ar.areaid from area as ar where EXISTS (select b.areaid from area as b where ar.areaid = b.areaid and b.parentid = #{provinceId})) as b2 where s0.areaid = b2.areaid)
and
s0.schoolid = #{schoolId}
and
c0.classesid=#{filtClassesId}
and
c0.classLevel=#{classLevel}
and
c0.schoolYear=#{schoolYear}
inner join StudentOwnClass as sc0
on c0.classesId = sc0.classesId and sc0.status = 1
and sc0.areaId = #{areaId}
and
c0.classesId=#{classesId}
inner join student st on st.studentid=sc0.studentid and st.status=1
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
inner join connectlog cnco on cnco.uid = st.studentid
and cnco.areaId = #{areaId}
#{startTime}
]]>
left join connectlog cnco on cnco.uid = st.studentid
and cnco.areaId = #{areaId}
#{startTime}
]]>
left join UserHonor uh on st.studentId = uh.uid
and uh.areaId = #{areaId}
where c0.gradeyear < 7
group by sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname, truename,
st.recognizecode,c0.teacherId,c0.schoolId, uh.studyduration
order by
timelength ${orderWay} nulls last,
sc0.studentId
),
scall as (select sum(timelength) as alltimelength from sc ),
assignmentres as (select sc.studentid,ao.assignmentid
from sc inner join assigntoclass ao on sc.classesid=ao.classesId group by ao.assignmentid,sc.studentid),
ag as (select sc.studentid,sum(case when fs.lessoncount=fs.completecount then 1 else 0 end) as assignCount
from assignmentres as sc
inner join finishassignstat fs on fs.assignmentid=sc.assignmentid
and fs.areaid = #{areaId}
and fs.uid=sc.studentid and fs.created>#{startTime} and fs.created<=#{endTime}
inner join assignment ag on ag.assignmentid = sc.assignmentid
and ag.status = 1
group by sc.studentId),
agall as (select sum(assignCount) as allassignCount from ag),
ss as ( select uid , avg(score) as avgScore,
count(achivementid) as howmuch
from Achivement
where
uid in ( select studentId from sc )
and achivetype in ('L','W')
and pointcasetype in (3,4,5,6,7,8)
and areaid = #{areaId}
and created > #{startTime} and created < #{endTime}
group by uid ),
ssall as (select avg(case when avgScore is null then 0 else avgScore end) as allavgScore,sum(ss.howmuch) as allhowmuch from sc left join ss on sc.studentId=ss.uid),
uo as ( select uid , max( endTime ) as endTime
from UserOwnLesson
where uid in ( select studentId from sc )
and areaid = #{areaId}
group by uid ),
oa as ( select uid , count(uid) as status
from OrderInfo
where uid in ( select studentId from sc )
and payway != 0 and ispayed != 0
and created > #{startTime} and created < #{endTime}
group by uid ),
ec as (
SELECT ea.userId uid, count(ea.examId) examCount
FROM
exam e inner join examanswer ea
on ea.userId
in ( select studentId from sc ) and ea.examid=e.examid
and ea.areaid = #{areaId}
and ea.created>e.starttime and ea.created <=e.endtime
and ea.created>#{startTime} and ea.created<= #{endTime}
group BY ea.userId ),
ecall as (select sum(examCount) as examCountall from ec),
hc as (
SELECT ea.userId uid, count(ea.examId) hearCount
FROM
hearExam e inner join HearAnswer ea
on ea.userId in ( select studentId from sc ) and ea.examid=e.examid
and ea.areaid = #{areaId}
and ea.created>e.starttime and ea.created <=e.endtime
and ea.created>#{startTime} and ea.created<=#{endTime}
group BY ea.userId ),
hcall as (select sum(hearCount) as hearCountall from hc) ,
bl as ( select userid , count(userid) as medalCount
from badgelog
where userid in (
select studentId from sc )
and badgecaseid = 4 and badgetype = 1
and areaid = #{areaId}
and created > #{startTime} and created < #{endTime}
group by userid ),
blall as (select sum(medalCount) as medalCountall from bl),
dbc as (select db.uid,count(db.uid) as dubCount from dubuservoice as db where EXISTS (select sc.studentId from sc where sc.studentId = db.uid) and db.isdelete = 0
and db.areaid = #{areaId}
and db.created > #{startTime} and db.created < #{endTime} group by db.uid),
abcall as (select sum(dubCount) as dubCountall from dbc ),
-- 获取参加竞赛次数
rsc as (select rs.uid,count(rs.raceid) as raceCount from raceScore as rs where EXISTS (select sc.studentId from sc where sc.studentId = rs.uid)
and rs.areaid = #{areaId}
and rs.created > #{startTime} and rs.created < #{endTime} group by rs.uid),
rscall as (select sum(raceCount) as raceCountall from rsc )
select sc.studentId ,sl.schoolName, sc.schoolYear,sc.classLevel,sc.classesId,sc.className,tr.truename teacherName,sc.recognizecode,sc.trueName,sc.timelength as timelength ,case when ss.avgScore >0 then round(ss.avgScore,2) else 0 end as score ,
case when ss.howmuch >0 then
ss.howmuch else 0 end as studyCount,
uo.endTime ,
case when oa.status >0 then
oa.status else 0 end as status,
case when ag.assignCount > 0 then ag.assignCount else 0 end as assignCount,
case when ec.examCount >0 and hc.hearCount >0 then ec.examCount+hc.hearCount
when ec.examCount >0 then ec.examCount
when hc.hearCount >0 then hc.hearCount
else 0 end as examCount,
case when bl.medalCount >0 then bl.medalCount
else 0 end as medalCount,
case when dbc.dubCount >0 then dbc.dubCount
else 0 end as dubCount,
case when rsc.raceCount >0 then rsc.raceCount
else 0 end as raceCount,
case when alltimelength >0 then alltimelength
else 0 end as alltimelength,
case when allassignCount >0 then allassignCount
else 0 end as allassignCount,
case when allavgScore >0 then round(allavgScore,2)
else 0 end as allavgScore ,
case when allhowmuch >0 then allhowmuch
else 0 end as allhowmuch,
case when examCountall >0 then examCountall
else 0 end as examCountall,
case when hearCountall >0 then hearCountall
else 0 end,
case when medalCountall >0 then medalCountall
else 0 end as medalCountall,
case when dubCountall >0 then dubCountall
else 0 end as dubCountall,
case when raceCountall >0 then raceCountall
else 0 end as raceCountall
from sc
inner join school sl on sl.schoolid=sc.schoolId
left join teacher tr on tr.teacherid = sc.teacherId and tr.status = 1
left join ag
on ag.studentid=sc.studentId
left join
ss
on sc.studentId = ss.uid
left join
uo
on sc.studentId = uo.uid
left join
oa
on sc.studentId = oa.uid
left join
ec
on sc.studentid = ec.uid
left join
hc
on sc.studentid = hc.uid
left join
bl
on sc.studentId = bl.userid
left join dbc on sc.studentId = dbc.uid left join
rsc on sc.studentId = rsc.uid ,scall,agall,ssall,ecall,hcall,blall,abcall,rscall
order by
sc.timelength ${orderWay} nulls last ,
sc.studentid
limit #{pageSize}
offset #{offset}
with sc as (
select sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname,st.truename truename,
st.recognizecode,c0.teacherId,c0.schoolId,sum(sts.timelength) as timelength,sum(sts.studytotal) as studytotal,
case when sum(sts.studycount) >0 then round(sum(sts.studytotal)/sum(sts.studycount),2) else 0 end as score,
case when sum(sts.studycount) >0 then sum(sts.studycount) else 0 end as studyCount,
case when sum(sts.assigncount) > 0 then sum(sts.assigncount) else 0 end as assignCount,
case when sum(sts.examcount) >0 then sum(sts.examCount) else 0 end as examCount,
case when sum(sts.goldcount) >0 then sum(sts.goldcount)else 0 end as medalCount,
case when sum(sts.dubvideocount) >0 then sum(sts.dubvideocount)
else 0 end as dubCount,
case when sum(sts.racecount) >0 then sum(sts.racecount)
else 0 end as raceCount,
case when sum(sts.wordfieldcount) >0 then sum(sts.wordfieldcount)
else 0 end as wordCount
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
and
Exists (select areaid from area as ar where s0.areaid = ar.areaid and ar.parentid = #{parentId} )
and
EXISTS (select s0.areaid from (select ar.areaid from area as ar where EXISTS (select b.areaid from area as b where ar.areaid = b.areaid and b.parentid = #{provinceId})) as b2 where s0.areaid = b2.areaid)
and
s0.schoolid = #{schoolId}
and
c0.classesid=#{filtClassesId}
and
c0.classLevel=#{classLevel}
and
c0.schoolYear=#{schoolYear}
inner join StudentOwnClass as sc0
on c0.classesId = sc0.classesId and sc0.status = 1
and sc0.areaId = #{areaId}
and
c0.classesId=#{classesId}
inner join student st on st.studentid=sc0.studentid and st.status=1 and st.areaid = #{areaId}
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
inner join studentstat as sts on sts.studentid=sc0.studentid and sts.areaid = #{areaId}
#{startTime}
]]>
left join studentstat as sts on sts.studentid=sc0.studentid and sts.areaid = #{areaId}
#{startTime}
]]>
left join UserHonor uh on st.studentId = uh.uid
and uh.areaId = #{areaId}
group by sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname, truename,
st.recognizecode,c0.teacherId,c0.schoolId
order by
timelength ${orderWay} nulls last,
sc0.studentId
),
scall as(select
sum(timelength) as alltimelength,
sum(assignCount) as allassignCount,
case when sum(studyCount) >0 then
round(sum(studytotal)/sum(studyCount),2) else 0 end as allavgScore,
sum(studyCount) as allhowmuch,
sum(examCount) as examCountall,
sum(medalCount) as medalCountall,
sum(dubCount) as dubCountall,
sum(raceCount) as raceCountall,
sum(wordCount) as wordCountall
from sc),
uo as ( select uid , max( endTime ) as endTime
from UserOwnLesson
where uid in ( select studentId from sc )
and areaid = #{areaId}
group by uid ),
oa as ( select uid , count(uid) as status
from OrderInfo
where uid in ( select studentId from sc )
and payway > 0 and ispayed = 1
and created > #{startTime} and created < #{endTime}
group by uid )
select
sc.studentId ,sl.schoolName, sc.schoolYear,sc.classLevel,sc.className,tr.truename teacherName,sc.recognizecode,sc.trueName,sc.timelength as timelength ,case when sc.score >0 then round(sc.score,2) else 0 end as score ,
case when sc.studyCount >0 then
sc.studyCount else 0 end as studyCount,
uo.endTime ,
case when oa.status >0 then
oa.status else 0 end as status,
sc.assignCount,
sc.examCount,
sc.wordCount,
sc.medalCount,
sc.dubCount ,
sc.raceCount,
case when alltimelength >0 then alltimelength
else 0 end as alltimelength,
case when allassignCount >0 then allassignCount
else 0 end as allassignCount,
case when allavgScore >0 then round(allavgScore,2)
else 0 end as allavgScore ,
case when allhowmuch >0 then allhowmuch
else 0 end as allhowmuch,
case when examCountall >0 then examCountall
else 0 end as examCountall,
case when medalCountall >0 then medalCountall
else 0 end as medalCountall,
case when dubCountall >0 then dubCountall
else 0 end as dubCountall,
case when raceCountall >0 then raceCountall
else 0 end as raceCountall,
case when wordCountall >0 then wordCountall
else 0 end as wordCountall
from sc
inner join school sl on sl.schoolid=sc.schoolId
left join teacher tr on tr.teacherid = sc.teacherId and tr.status = 1
left join
uo
on sc.studentId = uo.uid
left join
oa
on sc.studentId = oa.uid,scall
order by
sc.timelength ${orderWay} nulls last ,
sc.studentid
limit #{pageSize}
offset #{offset}
with clsyear as (
select c0.*, case when classlevel = 1 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear+3
when classlevel = 2 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear
when classlevel = 3 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
when classlevel =4 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
else EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +2
end
as gradeyear
from Classes as c0
where c0.classType = 1 and c0.status = 1
and c0.areaid = #{areaId}
),
temp as (select st.schoolId,sc.schoolName,sum(st.timelength) as timelength,sum(st.studytotal) as studytotal,sum(st.studyCount) as studyCount,sum(st.assignCount) as assignCount ,sum(st.examCount) as examCount,sum(st.wordFieldCount) as wordFieldCount,sum(st.dubVideoCount) as dubVideoCount,sum(st.raceCount) as raceCount,sum(goldCount) as goldCount from school as sc left join schoolstat st on sc.schoolid = st.schoolid and sc.areaid= #{areaId} where st.areaid = #{areaId} group by st.schoolId,sc.schoolName order by st.schoolId desc ),
allclass as (select temp.schoolid , count(distinct stc.studentid) as accountCount,count(distinct cls.classesid) as classCount from temp inner join clsyear as cls on cls.schoolid = temp.schoolid and cls.areaid = #{areaId} inner join studentownclass as stc on stc.classesid = cls.classesid and stc.areaid = #{areaId} inner join student as stu on stu.studentid = stc.studentid where cls.gradeyear < 7 and stu.status = 1 and stc.status = 1 and cls.status = 1 and cls.classtype =1 group by temp.schoolid),
allres as ( select sum(temp.timelength) as alltimelength,sum(temp.studytotal) as allstudytotal,sum(temp.studyCount) as allhowmuch,sum(temp.assignCount) as allassignCount ,sum(temp.examCount) as examCountall,sum(temp.wordFieldCount) as wordFieldCountAll,sum(temp.dubVideoCount) as dubCountall,sum(temp.raceCount) as raceCountAll,sum(goldCount) as medalCountall from temp )
select case when allclass.accountCount > 0 then allclass.accountCount else 0 end as accountCount,
case when temp.timelength > 0 then temp.timelength else 0 end as alltimelengthForSchool,
case when allclass.classCount > 0 then allclass.classCount else 0 end as classesCount,
case when temp.studyCount > 0 then round(temp.studytotal/temp.studyCount,2) else 0.0 end as score,
case when temp.studyCount > 0 then temp.studyCount else 0 end as howmuch,
case when temp.assignCount > 0 then temp.assignCount else 0 end as assignCount,
case when temp.examCount > 0 then temp.examCount else 0 end as examCount,
case when temp.wordFieldCount > 0 then temp.wordFieldCount else 0 end as wordFieldCount,
case when temp.dubVideoCount > 0 then temp.dubVideoCount else 0 end as dubCount,
case when temp.raceCount > 0 then temp.raceCount else 0 end as raceCount,
case when temp.goldCount > 0 then temp.goldCount else 0 end as medalCount,
case when allres.alltimelength > 0 then allres.alltimelength else 0 end as alltimelength,
case when allres.allhowmuch > 0 then round( allres.allstudytotal/allres.allhowmuch,2 )else 0.0 end as allavgScore,
case when allres.allhowmuch > 0 then allres.allhowmuch else 0 end as allhowmuch,
case when allres.allassignCount > 0 then allres.allassignCount else 0 end as allassignCount,
case when allres.examCountall > 0 then allres.examCountall else 0 end as examCountall,
case when allres.wordFieldCountAll > 0 then allres.wordFieldCountAll else 0 end as wordFieldCountAll,
case when allres.dubCountall > 0 then allres.dubCountall else 0 end as dubCountall,
case when allres.raceCountAll > 0 then allres.raceCountAll else 0 end as raceCountAll,
case when allres.medalCountall > 0 then allres.medalCountall else 0 end as medalCountall,
temp.schoolId as schoolId ,temp.schoolName from temp left join allclass on temp.schoolid = allclass.schoolid,allres
limit #{pageSize}
offset #{offset}
;
with sc as (
select sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname,st.truename truename,
st.recognizecode,c0.teacherId,c0.schoolid,uh.studyduration as timelength
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
and
Exists (select areaid from area as ar where s0.areaid = ar.areaid and ar.parentid = #{parentId} )
and
EXISTS (select s0.areaid from (select ar.areaid from area as ar where EXISTS (select b.areaid from area as b where ar.areaid = b.areaid and b.parentid = #{provinceId})) as b2 where s0.areaid = b2.areaid)
and
s0.schoolid = #{schoolId}
and
c0.classesid=#{filtClassesId}
and
c0.classLevel=#{classLevel}
and
c0.schoolYear=#{schoolYear}
inner join StudentOwnClass as sc0
on c0.classesId = sc0.classesId and sc0.status = 1
and
c0.classesId=#{classesId}
inner join student st on st.studentid=sc0.studentid
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
left join connectlog cnco on cnco.uid = st.studentid
and
cnco.areaid = #{areaId}
#{startTime}
]]>
left join UserHonor uh on st.studentId = uh.uid
and
uh.areaid = #{areaId}
group by sc0.studentId , c0.classesId,c0.classlevel,c0.schoolyear ,c0.classname, truename,
st.recognizecode,c0.teacherId,c0.schoolId, uh.studyduration
order by
timelength ${orderWay} nulls last,
sc0.studentId
),
rsc as (select sc.schoolid,count(rs.raceid) as raceCount from raceScore as rs inner join sc on sc.studentId = rs.uid
and rs.areaid = #{areaId}
and rs.created > #{startTime} and rs.created < #{endTime}
group by sc.schoolid),
rscall as (select sum(raceCount) as raceCountall from rsc ),
schools as (select sch.schoolid,sch.schoolName,count( distinct cls.classesid) as classesCount,count(distinct sc.studentId) as accountCount from school as sch inner join classes as cls on cls.schoolid = sch.schoolid
and sch.areaid = #{areaId}
and cls.areaid = #{areaId}
left join sc on sc.schoolid= sch.schoolid where sch.areaid = #{areaId} and sch.status =1 and cls.classType = 1 and cls.status = 1 group by sch.schoolid,sch.schoolName),
scallForSchool as (select schoolid, sum(timelength) as timelength from sc group by schoolid),
scall as (select sum(timelength) as alltimelength from scallForSchool ),
assignmentres as (select sc.studentid,ao.assignmentid,sc.classesid
from sc inner join assigntoclass ao on sc.classesid=ao.classesId
and ao.areaid = #{areaId}
group by ao.assignmentid,sc.studentid,sc.classesid),
ag as (select cls.schoolid,sum(case when fs.lessoncount=fs.completecount then 1 else 0 end) as assignCount
from assignmentres as sc inner join classes as cls on sc.classesid = cls.classesid
inner join finishassignstat fs on fs.assignmentid=sc.assignmentid
and fs.areaid = #{areaId}
and fs.uid=sc.studentid
and fs.created>#{startTime} and fs.created<=#{endTime}
inner join assignment ag on ag.assignmentid = sc.assignmentid
and ag.areaid = #{areaId}
and ag.status = 1
group by cls.schoolid),
agall as (select sum(assignCount) as allassignCount from ag),
ss as ( select sc.schoolid , avg(ach.score) as avgScore,
count(ach.achivementid) as howmuch
from Achivement as ach inner join sc on ach.uid = sc.studentid
where
ach.achivetype in ('L','W')
and ach.pointcasetype in (3,4,5,6,7,8)
and ach.areaid = #{areaId}
and ach.created > #{startTime} and ach.created < #{endTime}
group by sc.schoolid ),
ssall as (select avg(avgScore) as allavgScore,sum(howmuch) as allhowmuch from ss),
uo as ( select sc.schoolid , max( uol.endTime ) as endTime
from UserOwnLesson as uol inner join sc on uol.uid = sc.studentid
uol.areaid = #{areaId}
group by sc.schoolid ),
oa as ( select sc.schoolid , count(oi.uid) as status
from OrderInfo as oi inner join sc on oi.uid = sc.studentid
and oi.areaid = #{areaId}
where
oi.payway > 0 and oi.ispayed = 1
and oi.created > #{startTime} and oi.created < #{endTime}
group by sc.schoolid ),
ec as (
SELECT sc.schoolid, count(distinct ea.examId) examCount
FROM examanswer ea
inner join exam e
on ea.examid=e.examid inner join sc on ea.userId = sc.studentid
and ea.areaid = #{areaId}
and ea.created>e.starttime and ea.created <=e.endtime
and ea.created>#{startTime} and ea.created<= #{endTime}
group BY sc.schoolid ),
ecall as (select sum(examCount) as examCountall from ec),
hc as (
SELECT sc.schoolid , count(ea.examId) hearCount
FROM HearAnswer ea
inner join hearExam e on ea.examid=e.examid inner join sc on ea.userId = sc.studentid
and ea.areaid = #{areaId}
and ea.created>e.starttime and ea.created <=e.endtime
and ea.created>#{startTime} and ea.created<=#{endTime}
group BY sc.schoolid ),
hcall as (select sum(hearCount) as hearCountall from hc) ,
bl as ( select sc.schoolid , count(oi.userid) as medalCount
from badgelog as oi inner join sc on oi.userid = sc.studentid
where oi.badgecaseid = 4 and oi.badgetype = 1
and oi.areaid = #{areaId}
and oi.created > #{startTime} and oi.created < #{endTime}
group by sc.schoolid ),
blall as (select sum(medalCount) as medalCountall from bl),
dbc as (select sc.schoolid,count(db.uid) as dubCount from dubuservoice as db inner join sc on db.uid = sc.studentid where db.isdelete = 0
and db.areaid = #{areaId}
and db.created > #{startTime} and db.created < #{endTime}
group by sc.schoolid),
abcall as (select sum(dubCount) as dubCountall from dbc )
select sc.schoolid as schoolId ,sc.schoolName,case when ss.avgScore >0 then round(ss.avgScore,2) else 0 end as score ,
case when ss.howmuch >0 then
ss.howmuch else 0 end as howmuch,
case when ag.assignCount > 0 then ag.assignCount else 0 end as assignCount,
case when ec.examCount >0 and hc.hearCount >0 then ec.examCount+hc.hearCount
when ec.examCount >0 then ec.examCount
when hc.hearCount >0 then hc.hearCount
else 0 end as examCount,
case when bl.medalCount >0 then bl.medalCount
else 0 end as medalCount,
case when sc.classesCount >0 then sc.classesCount
else 0 end as classesCount,
case when dbc.dubCount >0 then dbc.dubCount
else 0 end as dubCount,
case when sc.accountCount >0 then sc.accountCount
else 0 end as accountCount,
case when scallForSchool.timelength >0 then scallForSchool.timelength
else 0 end as alltimelengthForSchool,
case when agall.allassignCount >0 then agall.allassignCount
else 0 end as allassignCount,
case when round(ssall.allavgScore,2)>0 then round(ssall.allavgScore,2)
else 0 end as allavgScore ,
case when ssall.allhowmuch >0 then ssall.allhowmuch
else 0 end as allhowmuch,
case when ecall.examCountall >0 then ecall.examCountall
else 0 end as examCountall,
case when hcall.hearCountall >0 then hcall.hearCountall
else 0 end as hearCountall,
case when blall.medalCountall >0 then blall.medalCountall
else 0 end as medalCountall,
case when abcall.dubCountall >0 then abcall.dubCountall
else 0 end as dubCountall,
case when rsc.raceCount >0 then rsc.raceCount
else 0 end as raceCount,
case when rscall.raceCountall >0 then rscall.raceCountall
else 0 end as raceCountAll,
case when scall.alltimelength >0 then scall.alltimelength
else 0 end as alltimelength
from schools sc
left join ag
on ag.schoolid=sc.schoolid
left join
ss
on ss.schoolid = sc.schoolid
left join
uo
on sc.schoolid = uo.schoolid
left join
oa
on sc.schoolid = oa.schoolid
left join
ec
on sc.schoolid = ec.schoolid
left join
hc
on sc.schoolid = hc.schoolid
left join
bl
on sc.schoolid = bl.schoolid
left join rsc on sc.schoolid = rsc.schoolid
left join dbc on sc.schoolid = dbc.schoolid left join scallForSchool on scallForSchool.schoolid = sc.schoolid ,scall,agall,ssall,ecall,hcall,blall,abcall,rscall
order by
sc.schoolid
limit #{pageSize}
offset #{offset}
with clsyear as (
select c0.*, case when classlevel = 1 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear+3
when classlevel = 2 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear
when classlevel = 3 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
when classlevel =4 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
else EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +2
end
as gradeyear
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
) ,
sc as (
select st.studentid,cs.classesid,cs.schoolid,
max(uol.endTime ) as endTime,
count(oi.orderinfoId) as status
from
clsyear cs
inner join school sl on
cs.schoolid=sl.schoolid and cs.classtype=1 and cs.status=1
and
sl.areaid = #{areaId}
and
sl.areaid in (select areaid from area where parentid = #{parentId})
and
sl.areaid in (select areaid from area where parentid in
(select areaid from area where parentid=#{provinceId}) )
and
sl.schoolid = #{schoolId}
and
cs.classesid=#{filtClassesId}
and
cs.classLevel=#{classLevel}
and
cs.schoolYear=#{schoolYear}
inner join studentownclass soc on
soc.classesid=cs.classesid and soc.status = 1
and
cs.classesId = #{classesId}
inner join student st on
st.studentid=soc.studentid
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
left join
UserOwnLesson uol on
uol.uid=st.studentid
left join
OrderInfo oi on
oi.uid=st.studentid
and payway > 0 and ispayed = 1
and oi.created > #{startTime} and oi.created < #{endTime}
where cs.gradeyear < 7
group by st.studentid,cs.classesid
,sl.schoolid
order by
endTime ${orderWay} nulls last ,
status ${orderWay} nulls last ,
st.studentid
limit #{pageSize}
offset #{offset}
),
classtemp as (
select sc.studentid,soc.classesid
from studentownclass soc
inner join sc on
soc.studentid = sc.studentid and soc.status=1
inner join clsyear c on
c.classesid=soc.classesid and c.status=1 and c.gradeyear < 7)
select sc.studentId , s.schoolName , c.classLevel,c.schoolYear,c.className , t.truename teacherName,
st.recognizecode , st.trueName ,
uh.studyduration as timelength ,
case when ss.avgScore>0 then round(ss.avgScore)
else 0 end as score ,
case when ss.howmuch>0 then ss.howmuch
else 0 end as studyCount,
sc.endTime ,
sc.status,
case when ag.assignCount > 0 then ag.assignCount else 0 end as assignCount,
case when ec.examCount>0 and hc.hearCount>0 then ec.examCount+hc.hearCount
when ec.examCount>0 then ec.examCount
when hc.hearCount>0 then hc.hearCount
else 0 end as examCount,
case when bl.medalCount>0 then bl.medalCount
else 0 end as medalCount
from sc
inner join clsyear c
on sc.classesId = c.classesId and c.gradeyear < 7
inner join School s
on s.schoolId = c.schoolId
inner join Teacher t
on c.teacherId = t.teacherId
inner join Student st
on sc.studentId = st.studentId
left join (select sc.studentid,sum(case when fs.lessoncount=fs.completecount then 1 else 0 end) as assignCount
from classtemp sc inner join assigntoclass ao on sc.classesid=ao.classesId
inner join finishassignstat fs on fs.assignmentid=ao.assignmentid and fs.uid=sc.studentid
inner join assignment ag on ag.assignmentid = ao.assignmentid
and ag.created>#{startTime} and ag.created<=#{endTime}
and ag.status != 0
group by sc.studentId) as ag
on ag.studentid=sc.studentId
left join UserHonor uh
on sc.studentId = uh.uid
left join ( select uid , avg(score) as avgScore,
count(achivementid) as howmuch
from Achivement
where uid in ( select studentId from sc )
and achivetype in ('L','W')
and pointcasetype in (3,4,5,6,7,8)
and created > #{startTime} and created < #{endTime}
group by uid ) ss
on sc.studentId = ss.uid
left join (
SELECT ea.userId uid, count(ea.examId) examCount
FROM examanswer ea
inner join exam e
on ea.userId
in ( select studentId from sc ) and ea.examid=e.examid
and ea.created>e.starttime and ea.created <=e.endtime
and ea.created>#{startTime} and ea.created<= #{endTime}
group BY ea.userId ) ec
on sc.studentid = ec.uid
left join (
SELECT ea.userId uid, count(ea.examId) hearCount
FROM HearAnswer ea
inner join hearExam e
on ea.userId in ( select studentId from sc ) and ea.examid=e.examid
and ea.created>e.starttime and ea.created <=e.endtime
and ea.created>#{startTime} and ea.created<=#{endTime}
group BY ea.userId ) hc
on sc.studentid = hc.uid
left join ( select userid , count(userid) as medalCount
from badgelog
where userid in (
select studentId from sc )
and badgecaseid = 4 and badgetype = 1
and created > #{startTime} and created < #{endTime}
group by userid ) bl
on sc.studentId = bl.userid
order by
sc.endTime ${orderWay} nulls last ,
sc.status ${orderWay} nulls last ,
sc.studentid
with clsyear as (
select c0.*, case when classlevel = 1 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear+3
when classlevel = 2 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear
when classlevel = 3 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
when classlevel =4 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
else EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +2
end
as gradeyear
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
) ,
sc as (select st.studentid,cs.classesid,cs.schoolid
from clsyear cs
inner join school sl on
cs.schoolid=sl.schoolid and cs.classtype=1 and cs.status=1
and
sl.areaid = #{areaId}
and
sl.areaid in (select areaid from area where parentid = #{parentId})
and
sl.areaid in (select areaid from area where parentid in
(select areaid from area where parentid=#{provinceId}) )
and
sl.schoolid = #{schoolId}
and
cs.classesid=#{filtClassesId}
and
cs.classLevel=#{classLevel}
and
cs.schoolYear=#{schoolYear}
inner join studentownclass soc on
soc.classesid=cs.classesid and soc.status = 1
and
cs.classesId = #{classesId}
inner join student st on
st.studentid=soc.studentid
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
where cs.gradeyear < 7
),
ex as (select sc.studentid,case when ec.examCount>0 and hc.examCount>0 then ec.examCount+hc.examCount
when ec.examCount>0 then ec.examCount
when hc.examCount>0 then hc.examCount
else 0 end as examCount
from sc left join
(SELECT sc.studentid, count(ea.examId) examCount
FROM sc inner join
examanswer ea on ea.userId = sc.studentid
inner join exam e on
ea.examid=e.examid
and ea.created>e.starttime and ea.created <=e.endtime
and ea.created>#{startTime} and ea.created<= #{endTime}
group BY sc.studentid )ec on ec.studentid=sc.studentid
left join
(SELECT sc.studentid, count(ea.examId) examCount
FROM sc inner join
HearAnswer ea on ea.userId = sc.studentid
inner join hearExam e on
ea.examid=e.examid
and ea.created>e.starttime and ea.created <=e.endtime
and ea.created>#{startTime} and ea.created<= #{endTime}
group BY sc.studentid) hc on hc.studentid=sc.studentid
order by examCount ${orderWay},studentid
limit #{pageSize}
offset #{offset}
),
classtemp as (
select ex.studentid,soc.classesid
from studentownclass soc
inner join ex on
soc.studentid = ex.studentid and soc.status=1
inner join clsyear c on
c.classesid=soc.classesid and c.status=1 and c.gradeyear < 7 )
select ex.studentId , s.schoolName , c.className,c.classLevel,c.schoolYear ,
st.recognizecode , st.trueName ,
uh.studyduration as timelength ,
case when ss.avgScore >0 then
round(ss.avgScore) else 0 end as score ,
case when ss.howmuch >0 then
ss.howmuch else 0 end as studyCount,uo.endTime ,
case when oa.status >0 then
oa.status else 0 end as status,
t.trueName as teacherName ,
case when ag.assignCount > 0 then ag.assignCount else 0 end as assignCount,
ex.examCount,
case when bl.medalCount>0 then bl.medalCount
else 0 end as medalCount
from ex
inner join Student st
on ex.studentId = st.studentId
inner join studentownclass soc
on soc.studentid = ex.studentid and soc.status=1
inner join clsyear c
on soc.classesId = c.classesId and c.classtype=1 and c.status=1 and c.gradeyear <7
inner join School s
on s.schoolId = c.schoolId
inner join Teacher t
on c.teacherId = t.teacherId
left join (
select sc.studentid,sum(case when fs.lessoncount=fs.completecount then 1 else 0 end) as assignCount
from classtemp sc inner join assigntoclass ao on sc.classesid=ao.classesId
inner join finishassignstat fs on fs.assignmentid=ao.assignmentid and fs.uid=sc.studentid
inner join assignment ag on ag.assignmentid = ao.assignmentid
and ag.created>#{startTime} and ag.created<=#{endTime}
and ag.status != 0
group by sc.studentId) as ag
on ex.studentid=ag.studentId
left join UserHonor uh
on ex.studentId = uh.uid
left join ( select uid , avg(score) as avgScore,
count(achivementid) as howmuch
from Achivement
where uid in ( select studentId from ex )
and achivetype in ('L','W')
and pointcasetype in (3,4,,7,8)
and created > #{startTime} and created < #{endTime}
group by uid ) ss
on ex.studentId = ss.uid
left join ( select uid , max( endTime ) as endTime
from UserOwnLesson
where uid in ( select studentId from ex )
group by uid ) uo
on ex.studentId = uo.uid
left join ( select uid , count(uid) as status
from OrderInfo
where uid in ( select studentId from ex )
and payway > 0 and ispayed = 1
and created > #{startTime} and created < #{endTime}
group by uid ) oa
on ex.studentId = oa.uid
left join ( select userid , count(userid) as medalCount
from badgelog
where userid in (
select studentId from ex )
and badgecaseid = 4 and badgetype = 1
and created > #{startTime} and created < #{endTime}
group by userid ) bl
on ex.studentId = bl.userid
order by examCount ${orderWay},studentid
with clsyear as (
select c0.*, case when classlevel = 1 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear+3
when classlevel = 2 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear
when classlevel = 3 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
when classlevel =4 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
else EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +2
end
as gradeyear
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
) ,
sc as (select st.studentid,cs.classesid,cs.schoolid
from clsyear cs
inner join school sl on
cs.schoolid=sl.schoolid and cs.classtype=1 and cs.status=1
and
sl.areaid = #{areaId}
and
sl.areaid in (select areaid from area where parentid = #{parentId})
and
sl.areaid in (select areaid from area where parentid in
(select areaid from area where parentid=#{provinceId}) )
and
sl.schoolid = #{schoolId}
and
cs.classesid=#{filtClassesId}
and
cs.classLevel=#{classLevel}
and
cs.schoolYear=#{schoolYear}
inner join studentownclass soc on
soc.classesid=cs.classesid and soc.status = 1
and
cs.classesId = #{classesId}
inner join student st on
st.studentid=soc.studentid
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
where cs.gradeyear < 7
),
ex as (select sc.studentid,case when count(bl.userid)>0 then count(bl.userid)
else 0 end as medalCount
from sc left join
badgelog bl
on bl.userid=sc.studentid
and bl.badgecaseid = 4 and bl.badgetype = 1
and bl.created > #{startTime} and bl.created < #{endTime}
group by sc.studentid
order by medalCount ${orderWay},studentid
limit #{pageSize}
offset #{offset}
),
classtemp as (
select ex.studentid,soc.classesid
from studentownclass soc
inner join ex on
soc.studentid = ex.studentid and soc.status=1
inner join clsyear c on
c.classesid=soc.classesid and c.status=1 where c.gradeyear < 7 )
select ex.studentId , s.schoolName , c.className,c.classLevel,c.schoolYear ,
st.recognizecode , st.trueName ,
uh.studyduration as timelength ,
case when ss.avgScore >0 then
round(ss.avgScore) else 0 end as score ,
case when ss.howmuch >0 then
ss.howmuch else 0 end as studyCount,uo.endTime ,
case when oa.status >0 then
oa.status else 0 end as status,
t.trueName as teacherName ,
case when ag.assignCount > 0 then ag.assignCount else 0 end as assignCount,
case when ec.examCount>0 and hc.hearCount>0 then ec.examCount+hc.hearCount
when ec.examCount>0 then ec.examCount
when hc.hearCount>0 then hc.hearCount
else 0 end as examCount,
ex.medalCount
from ex
inner join Student st
on ex.studentId = st.studentId
inner join studentownclass soc
on soc.studentid = ex.studentid and soc.status=1
inner join clsyear c
on soc.classesId = c.classesId and c.classtype=1 and c.status=1 and c.gradeyear < 7
inner join School s
on s.schoolId = c.schoolId
inner join Teacher t
on c.teacherId = t.teacherId
left join (
select sc.studentid,sum(case when fs.lessoncount=fs.completecount then 1 else 0 end) as assignCount
from classtemp sc inner join assigntoclass ao on sc.classesid=ao.classesId
inner join finishassignstat fs on fs.assignmentid=ao.assignmentid and fs.uid=sc.studentid
inner join assignment ag on ag.assignmentid = ao.assignmentid
and ag.created>#{startTime} and ag.created<=#{endTime}
and ag.status != 0
group by sc.studentId) as ag
on ex.studentid=ag.studentId
left join UserHonor uh
on ex.studentId = uh.uid
left join ( select uid , avg(score) as avgScore,
count(achivementid) as howmuch
from Achivement
where uid in ( select studentId from ex )
and achivetype in ('L','W')
and pointcasetype in (3,4,5,6,7,8)
and created > #{startTime} and created < #{endTime}
group by uid ) ss
on ex.studentId = ss.uid
left join ( select uid , max( endTime ) as endTime
from UserOwnLesson
where uid in ( select studentId from ex )
group by uid ) uo
on ex.studentId = uo.uid
left join ( select uid , count(uid) as status
from OrderInfo
where uid in ( select studentId from ex )
and payway > 0 and ispayed = 1
and created > #{startTime} and created < #{endTime}
group by uid ) oa
on ex.studentId = oa.uid
left join (
SELECT ea.userId uid, count(ea.examId) examCount
FROM examanswer ea
inner join exam e
on ea.userId
in ( select studentId from ex ) and ea.examid=e.examid
and ea.created>e.starttime and ea.created <=e.endtime
and ea.created>#{startTime} and ea.created<= #{endTime}
group BY ea.userId ) ec
on ex.studentid = ec.uid
left join (
SELECT ea.userId uid, count(ea.examId) hearCount
FROM HearAnswer ea
inner join hearExam e
on ea.userId in ( select studentId from ex ) and ea.examid=e.examid
and ea.created>e.starttime and ea.created <=e.endtime
and ea.created>#{startTime} and ea.created<=#{endTime}
group BY ea.userId ) hc
on ex.studentid = hc.uid
order by medalCount ${orderWay},studentid
with clsyear as (
select c0.*, case when classlevel = 1 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear+3
when classlevel = 2 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear
when classlevel = 3 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
when classlevel =4 then EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +3
else EXTRACT(YEAR FROM CURRENT_DATE) - schoolyear +2
end
as gradeyear
from Classes as c0
inner join School as s0
on s0.status = 1 and s0.schoolId = c0.schoolId
and c0.classType = 1 and c0.status = 1
and
s0.areaid = #{areaId}
) ,
sc as (
select st.studentid,cs.classesid,cs.schoolid,
case when avg(am.score)>0 then avg(am.score)
else 0 end as avgScore,
count(achivementid) as howmuch
from clsyear cs
inner join school sl on
cs.schoolid=sl.schoolid and cs.classtype=1 and cs.status=1
and
sl.areaid = #{areaId}
and
sl.areaid in (select areaid from area where parentid = #{parentId})
and
sl.areaid in (select areaid from area where parentid in
(select areaid from area where parentid=#{provinceId}) )
and
sl.schoolid = #{schoolId}
and
cs.classesid=#{filtClassesId}
and
cs.classLevel=#{classLevel}
and
cs.schoolYear=#{schoolYear}
inner join studentownclass soc on
soc.classesid=cs.classesid and soc.status = 1
and
cs.classesId = #{classesId}
inner join student st on
st.studentid=soc.studentid
and
st.truename=#{username}
and
st.recognizecode=#{recognizeCode}
left join
Achivement am
on am.uid=soc.studentid
and am.achivetype in ('L','W')
and am.pointcasetype in (3,4,5,6,7,8)
and am.created > #{startTime} and am.created < #{endTime}
where cs.gradeyear < 7
group by st.studentid,cs.classesid
,sl.schoolid
order by
avgScore ${orderWay} nulls last ,
howmuch ${orderWay} nulls last ,
st.studentid
limit #{pageSize}
offset #{offset}
),
classtemp as (
select sc.studentid,soc.classesid
from studentownclass soc
inner join sc on
soc.studentid = sc.studentid and soc.status=1
inner join classes c on
c.classesid=soc.classesid and c.status=1 )
select sc.studentId , s.schoolName , c.classLevel,c.schoolYear,c.className , t.truename teacherName,
st.recognizecode , st.trueName ,
uh.studyduration as timelength ,
case when sc.avgScore>0 then round(sc.avgScore)
else 0 end as score ,
case when sc.howmuch>0 then sc.howmuch
else 0 end as studyCount,
uo.endTime ,
oa.status,
case when ag.assignCount > 0 then ag.assignCount else 0 end as assignCount,
case when ec.examCount>0 and hc.hearCount>0 then ec.examCount+hc.hearCount
when ec.examCount>0 then ec.examCount
when hc.hearCount>0 then hc.hearCount
else 0 end as examCount,
case when bl.medalCount>0 then bl.medalCount
else 0 end as medalCount
from sc
inner join Classes c
on sc.classesId = c.classesId
inner join School s
on s.schoolId = c.schoolId
inner join Teacher t
on c.teacherId = t.teacherId
inner join Student st
on sc.studentId = st.studentId
left join UserHonor uh
on sc.studentId = uh.uid
left join (select sc.studentid,sum(case when fs.lessoncount=fs.completecount then 1 else 0 end) as assignCount
from classtemp sc inner join assigntoclass ao on sc.classesid=ao.classesId
inner join finishassignstat fs on fs.assignmentid=ao.assignmentid and fs.uid=sc.studentid
inner join assignment ag on ag.assignmentid = ao.assignmentid
and ag.created>#{startTime} and ag.created<=#{endTime}
and ag.status != 0
group by sc.studentId) as ag
on ag.studentid=sc.studentId
left join (
SELECT ea.userId uid, count(ea.examId) examCount
FROM examanswer ea
inner join exam e
on ea.userId
in ( select studentId from sc ) and ea.examid=e.examid
and ea.created>e.starttime and ea.created <=e.endtime
and ea.created>#{startTime} and ea.created<= #{endTime}
group BY ea.userId ) ec
on sc.studentid = ec.uid
left join (
SELECT ea.userId uid, count(ea.examId) hearCount
FROM HearAnswer ea
inner join hearExam e
on ea.userId in ( select studentId from sc ) and ea.examid=e.examid
and ea.created>e.starttime and ea.created <=e.endtime
and ea.created>#{startTime} and ea.created<=#{endTime}
group BY ea.userId ) hc
on sc.studentid = hc.uid
left join ( select uid , max( endTime ) as endTime
from UserOwnLesson
where uid in ( select studentId from sc )
group by uid ) uo
on sc.studentId = uo.uid
left join ( select uid , count(uid) as status
from OrderInfo
where uid in ( select studentId from sc )
and payway > 0 and ispayed = 1
and created > #{startTime} and created < #{endTime}
group by uid ) oa
on sc.studentId = oa.uid
left join ( select userid , count(userid) as medalCount
from badgelog
where userid in (
select studentId from sc )
and badgecaseid = 4 and badgetype = 1
and created > #{startTime} and created < #{endTime}
group by userid ) bl
on sc.studentId = bl.userid
order by
sc.avgScore ${orderWay} nulls last ,
sc.howmuch ${orderWay} nulls last ,
sc.studentid
with temp as ( select t.teacherId , t.schoolId
from School s
inner join Teacher t on
s.areaid in (select areaid from area where parentid = #{parentId})
s.areaid in (select areaid from area where parentid in
(select areaid from area where parentid=#{provinceId}) )
s.areaid = #{areaId}
s.schoolid = #{schoolId}
and s.status = 1
and t.schoolId = s.schoolid and t.status = 1
and
t.truename=#{username}
and
t.loginno=#{recognizeCode}
),
temp2 as(
select tt.teacherId,case when finishCount>0 then finishCount
else 0 end as finishCount,
case when aw.stuCount>0 then aw.stuCount
else 0 end as stuCount
from temp tt
left join
(
select t.teacherid,sum(case when fas.lessoncount>0 and fas.lessoncount = fas.lessoncount then 1 else 0 end) finishCount, count( soc.studentid) stuCount from temp t
inner join assignment a on a.teacherid=t.teacherid
and a.status!=0
and a.starttime>=#{startTime} and a.endtime< #{endTime}
inner join
assigntoclass atc on atc.assignmentid=a.assignmentid
inner join
classes c1 on c1.classesid=atc.classesid and c1.status=1
inner join
studentownclass soc on soc.classesid=c1.classesid and soc.status=1
left join
finishassignstat fas on fas.assignmentid=atc.assignmentid and fas.uid=soc.studentid
group by t.teacherid
) as aw on aw.teacherid = tt.teacherid
),
tt as (
select t.teacherid,tt.schoolid,case when stuCount>0 then round(finishCount::numeric/stuCount::numeric*100,2) else 0 end as finishRate
from temp2 t
inner join temp tt
on tt.teacherid= t.teacherid order by finishRate ${orderWay},t.teacherid
limit #{pageSize}
offset #{offset}
)
select a.teacherId ,a.finishRate, s.schoolName , t.loginNo , t.trueName ,
case when ta.assignmentCount >0 then
ta.assignmentCount else 0 end as assignmentCount ,
case when cm.classMessageCount >0 then
cm.classMessageCount else 0 end as classMessageCount,
case when te.examCount >0 then
te.examCount else 0 end as examCount
,
uo.endTime,case when ss.avgScore > 0 then round( ss.avgScore)
else 0 end as avgScore,
cla.classNames
from tt as a
inner join School as s
on a.schoolId = s.schoolId
inner join Teacher as t
on a.teacherId = t.teacherId
left join (select teacherId,array_to_string( array_agg (classname),'\r\n') as classNames from
classes where teacherId in (select teacherId from temp) and classType=1 and status=1 group by teacherId) as cla
on cla.teacherId = a.teacherId
left join (
select teacherId , count( assignmentId ) as assignmentCount
from Assignment
where teacherId in ( select teacherId from tt )
and created > #{startTime} and created < #{endTime}
and status != 0
group by teacherId ) as ta
on a.teacherId = ta.teacherId
left join (
select teacherId , count( classmessageId ) as classMessageCount
from ClassMessage
where teacherId in ( select teacherId from tt )
and created > #{startTime} and created < #{endTime}
group by teacherId ) as cm
on a.teacherId = cm.teacherId
left join (
select c.teacherId , count( distinct e.examId ) as examCount
from Classes c
inner join ClassOwnExam coe
on c.teacherId in ( select teacherId from tt )
and c.status = 1
and c.classesid = coe.classesId
inner join Exam e
on coe.examId = e.examId
and e.created > #{startTime} and e.created < #{endTime}
group by c.teacherId ) as te
on a.teacherid = te.teacherid
left join (
select uol.uid , max( uol.endTime ) as endTime
from tt
inner join
UserOwnLesson uol on tt.teacherId = uol.uid
group by uol.uid ) as uo
on a.teacherId = uo.uid
left join (
select tt.teacherid,avg(at.score) as avgScore from tt
inner join
classes cs on cs.classtype=1 and cs.status=1 and cs.teacherid=tt.teacherid
inner join
studentownclass soc on soc.classesid=cs.classesid and soc.status=1
inner join
achivement at on at.achivetype in ('L','W') and at.pointcasetype in (3,4,5,6,7,8)
and at.created > #{startTime} and at.created < #{endTime} and at.uid=soc.studentid
group by tt.teacherid) ss on ss.teacherid=a.teacherid
order by a.finishRate ${orderWay},a.teacherId
select count(t.teacherId)
from School s
inner join Teacher t on
s.areaid in (select areaid from area where parentid = #{parentId})
s.areaid in (select areaid from area where parentid in
(select areaid from area where parentid=#{provinceId}) )
s.areaid = #{areaId}
s.schoolid = #{schoolId}
and s.status = 1
and t.schoolId = s.schoolid and t.status = 1
and
t.truename=#{username}
and
t.loginno=#{recognizeCode}
select count( distinct s.schoolid)
from School s
s.areaid in (select areaid from area where parentid = #{parentId})
s.areaid in (select areaid from area where parentid in
(select areaid from area where parentid=#{provinceId}) )
s.areaid = #{areaId}
and s.status = 1
with temp as (
select t.teacherId ,t.truename,t.loginNo,s.schoolname, t.schoolId ,count(distinct assignmentId ) as assignmentCount,
count( distinct classmessageId ) as classMessageCount,
max( uol.endTime ) as endTime
from School s
inner join Teacher t on
s.areaid in (select areaid from area where parentid = #{parentId})
s.areaid in (select areaid from area where parentid in
(select areaid from area where parentid=#{provinceId}) )
s.areaid = #{areaId}
s.schoolid = #{schoolId}
and s.status = 1
and t.schoolId = s.schoolid and t.status = 1
and
t.truename=#{username}
and
t.loginno=#{recognizeCode}
left join Assignment a on a.teacherid=t.teacherid and
a.endTime > #{startTime}
and a.endTime < #{endTime}
and a.status != 0
left join UserOwnLesson uol on uol.uid=t.teacherid
left join
ClassMessage cm
on cm.teacherId=t.teacherid
and cm.created > #{startTime} and cm.created < #{endTime} and cm.isexam=0
group by t.teacherId ,t.truename,t.loginNo, t.schoolId ,s.schoolname
order by
t.truename ${orderWay} nulls last,
t.loginNo ${orderWay} nulls last ,
assignmentCount ${orderWay} nulls last ,
classMessageCount ${orderWay} nulls last ,
endTime ${orderWay} nulls last ,
t.teacherId
),
assignCountall as (select sum (assignmentCount) as assignCountall from temp),
-- 学生完成次数 学习次数
aw as (
select t.teacherid,sum(case when fas.lessoncount>0 and fas.lessoncount = fas.completecount then 1 else 0 end) finishCount, count( soc.studentid) stuCount from temp t
inner join assignment a on a.teacherid=t.teacherid and a.status=1 and a.assigntype <> 'D'
and a.endtime>=#{startTime} and a.endtime< #{endTime}
inner join
assigntoclass atc on atc.assignmentid=a.assignmentid
inner join
classes c1 on c1.classesid=atc.classesid and c1.status=1
inner join
studentownclass soc on soc.classesid=c1.classesid and soc.status=1
left join
finishassignstat fas on fas.assignmentid=atc.assignmentid and fas.uid=soc.studentid
group by t.teacherid
) ,
awall as (select sum(finishCount) as finishCountAll,sum(stuCount) as stuCountAll from aw),
temp2 as(
select tt.teacherId,case when finishCount>0 then finishCount
else 0 end as finishCount,
case when aw.stuCount>0 then aw.stuCount
else 0 end as stuCount
from temp tt
left join
aw on aw.teacherid = tt.teacherid
),
cla as (select teacherId,array_to_string( array_agg (classname),'\r\n') as classNames from
classes where teacherId in (select teacherId from temp) and status=1 group by teacherId),
-- 发布公告次数
cm as (select teacherId , count( classmessageId ) as classMessageCount from ClassMessage
where teacherId in ( select teacherId from temp ) and created > #{startTime} and created < #{endTime} and isexam = 0 group by teacherId ) ,
cmall as (select sum(classMessageCount) as classMessageCountAll from cm),
-- 发布考试次数
te as (
select c.teacherId , count( distinct e.examId ) as examCount
from Classes c
inner join ClassOwnExam coe
on c.teacherId in ( select teacherId from temp )
and c.status = 1
and c.classesid = coe.classesId
inner join Exam e
on coe.examId = e.examId
and e.endtime > #{startTime} and e.endtime < #{endTime}
group by c.teacherId ) ,
teall as (select sum(examCount) as examCountAll from te ),
-- 听力考试次数
he as (
select c.teacherId , count( distinct c.examId ) as examCount
from hearexam c
where
c.teacherId in ( select teacherId from temp )
and c.created > #{startTime} and c.created < #{endTime}
group by c.teacherId ),
heall as (select sum(examCount) as hearexamCountAll from he ),
-- 平均分
ss as (
select case when round( avg(at.score),2) > 0 then round(avg(at.score),2) else 0 end as avgScore , tt.teacherid from temp tt
inner join
classes cs on cs.status=1 and cs.teacherid=tt.teacherid
inner join
studentownclass soc on soc.classesid=cs.classesid and soc.status=1
inner join
achivement at on at.uid=soc.studentid and at.achivetype in ('L','W') and at.pointcasetype in (3,4,5,6,7,8)
and at.created > #{startTime} and at.created < #{endTime}
group by tt.teacherid),
ssall as (select sum(avgScore)/count(temp.teacherid) as avgScoreAll from temp left join ss on ss.teacherid=temp.teacherid),
-- 获取发布配音作业次数
dub as (
select ass.teacherId , count( distinct ass.assignmentid ) as dubCount
from assignment ass
where
ass.teacherId in ( select teacherId from temp ) and assigntype='D'
and ass.endtime > #{startTime} and ass.endtime < #{endTime}
group by ass.teacherId
),
duball as (select sum(dubCount) as dubCountAll from dub)
select a.teacherId ,case when stuCount>0 then round(finishCount::numeric/stuCount::numeric*100,2) else 0 end as finishRate , a.schoolName , a.loginNo , a.trueName ,
case when a.assignmentCount >0 then
case when dub.dubCount >0 then a.assignmentCount-dub.dubCount else a.assignmentCount-0 end
else 0 end as assignmentCount,
case when a.classMessageCount >0 then
a.classMessageCount else 0 end as classMessageCount,
case when te.examCount >0 and he.examCount >0 then
te.examCount + he.examCount
when te.examCount >0 then te.examCount
when he.examCount >0 then he.examCount
else 0 end as examCount
,
a.endTime,
case when ss.avgScore > 0 then round( ss.avgScore,2) else 0 end as avgScore,
case when assignCountall.assignCountall > 0 then round( assignCountall.assignCountall) else 0 end as assignCountall,
case when stuCountAll>0 then round(finishCountAll::numeric/stuCountAll::numeric*100,2) else 0 end as finishRateAll ,
case when classMessageCountAll >0 then classMessageCountAll else 0 end as classMessageCountAll ,
case when examCountAll >0 then examCountAll else 0 end as examCountAll ,
case when hearexamCountAll >0 then hearexamCountAll else 0 end as hearexamCountAll ,
case when avgScoreAll >0 then round(avgScoreAll,2) else 0 end as avgScoreAll ,
case when dubCountAll >0 then round(dubCountAll) else 0 end as dubCountAll,
case when dub.dubCount >0 then dub.dubCount else 0 end as dubCount,
cla.classNames
from temp as a
left join cla
on cla.teacherId = a.teacherId
left join
temp2 t2 on t2.teacherid=a.teacherid
left join cm
on a.teacherId = cm.teacherId
left join te
on a.teacherid = te.teacherid
left join he
on a.teacherid = he.teacherid
left join ss on ss.teacherid=a.teacherid
left join dub on a.teacherid = dub.teacherid,awall,cmall,teall,heall,ssall,duball,assignCountall
order by
a.truename ${orderWay} nulls last,
a.loginNo ${orderWay} nulls last ,
assignmentCount ${orderWay} nulls last ,
classMessageCount ${orderWay} nulls last ,
endTime ${orderWay} nulls last ,
a.teacherId
limit #{pageSize}
offset #{offset}
with temp1 as (select t.teacherId ,t.truename,t.loginNo,s.schoolname, t.schoolId from school as s inner join teacher as t on t.schoolid = s.schoolid where s.status = 1 and t.status = 1
and s.areaid in (select areaid from area where parentid = #{parentId})
and s.areaid in (select areaid from area where parentid in
(select areaid from area where parentid=#{provinceId}) )
and s.areaid = #{areaId} and t.areaid= #{areaId}
and s.schoolid = #{schoolId}
and t.schoolId = s.schoolid
and
t.truename=#{username}
and
t.loginno=#{recognizeCode}
),
temp2 as (select t.teacherId ,t.truename,t.loginNo,t.schoolname, t.schoolId ,count( distinct assignmentId ) as assignmentCount from temp1 t left join Assignment as b on b.teacherid = t.teacherid
and
b.created > #{startTime}
and b.created < #{endTime}
and b.areaid = #{areaId}
and b.status != 0 group by t.teacherId ,t.truename,t.loginNo, t.schoolId ,t.schoolname order by t.teacherId),
temp3 as (select t.teacherId ,t.truename,t.loginNo,t.schoolname, t.schoolId ,count( distinct classmessageId ) as classMessageCount from temp1 t left join ClassMessage cm on cm.teacherId=t.teacherid
and cm.created > #{startTime} and cm.created < #{endTime}
and cm.areaid = #{areaId}
and cm.isexam=0
group by t.teacherId ,t.truename,t.loginNo,t.schoolname, t.schoolId order by t.teacherId ),
temp as (select t2.teacherId ,t2.truename,t2.loginNo,t2.schoolname, t2.schoolId, t2.assignmentCount,t3.classMessageCount from temp2 as t2 left join temp3 t3 on t2.teacherid =t3.teacherid
order by t2.teacherId
),
asscount as (select t.schoolid,t.schoolName ,sum(t.assignmentCount) as assignmentCount from temp t group by t.schoolid,t.schoolName),
tempclass as (select t.teacherId ,t.truename,t.loginNo,s.schoolid, s.classesid ,count(distinct ac.assignmentid ) as teastucount from classes as s left join teacher as t on t.teacherid = s.teacherid left join studentownclass as stc on s.classesid = stc.classesid left join assigntoclass as ac on ac.classesid = stc.classesid
and stc.areaid = #{areaId}
and stc.status = 1 where s.status = 1 and t.status = 1
and
t.areaid = #{areaId}
and s.areaid = #{areaId}
and s.classtype=1 group by t.teacherId ,t.truename,t.loginNo,s.schoolid, s.classesid),
tempclass1 as (select schoolid,sum(teastucount) as stuCount from tempclass GROUP BY schoolid),
tempclass2 as (select s.schoolid , sum(case when fas.lessoncount > 0 and fas.lessoncount = fas.completecount then 1 else 0 end) finishCount from school as s inner join teacher t on t.schoolid = s.schoolid
and s.areaid = #{areaId}
left join assignment as b on b.teacherid=t.teacherid
and b.areaid = #{areaId}
and b.status=1
left join finishassignstat fas on fas.assignmentid=b.assignmentid
and fas.areaid = #{areaId}
group by s.schoolid),
-- 学生完成次数 学习次数
aw as (select t.schoolid,t.schoolName, b.finishCount, c.stuCount,sum(t.assignmentCount) assignmentCount,sum(t.classMessageCount) classMessageCount from temp as t left join tempclass2 as b on t.schoolid = b.schoolid left join tempclass1 as c on t.schoolid = c.schoolid group by t.schoolid,t.schoolName, b.finishCount, c.stuCount),
pyc as (select schoolid,count(distinct teacherId) as accountCount from temp group by schoolid),
awall as (select sum(finishCount) as finishCountAll,sum(stuCount) as stuCountAll from aw),
asscountall as (select sum(assignmentCount) as assignmentCountAll from asscount),
-- 发布公告次数
cm as (select scl.schoolid as schoolid , count( cms.classmessageId ) as classMessageCount ,count(distinct cls.classesid) as classesCount from classes as cls inner join school as scl on scl.schoolid = cls.schoolid
and scl.areaid = #{areaId}
left join ClassMessage as cms on cls.teacherid = cms.teacherid and cms.status = 1 and cms.isexam = 0
and cms.areaid = #{areaId}
where
-- cls.teacherId in ( select teacherId from temp ) and
cls.status = 1 and scl.status = 1
and cms.created > #{startTime} and cms.created < #{endTime}
group by scl.schoolid ) ,
cmall as (select sum(classMessageCount) as classMessageCountAll from cm),
-- 发布考试次数
te as (
select scl.schoolid , count( distinct e.examId ) as examCount
from Classes c
inner join school as scl on scl.schoolid = c.schoolid and scl.status = 1
inner join ClassOwnExam coe
on c.teacherId in ( select teacherId from temp )
and c.status = 1
and c.classesid = coe.classesId
inner join Exam e
on coe.examId = e.examId
and e.created > #{startTime} and e.created < #{endTime}
group by scl.schoolid ) ,
acc as (select scl.schoolid,count(distinct cl.classesid) as classesCount from student as st inner join studentownclass as stc on st.studentid = stc.studentid
and stc.areaid = #{areaId}
inner join classes as cl on cl.classesid= stc.classesid inner join school as scl on scl.schoolid = cl.schoolid and scl.status = 1 where st.status= 1 and cl.status=1 and cl.classtype =1
and cl.areaid =#{areaId}
group by scl.schoolid),
teall as (select sum(examCount) as examCountAll from te ),
-- 听力考试次数
he as (
select scl.schoolid , count( distinct c.examId ) as examCount
from hearexam c inner join classes as cls on c.teacherid = cls.teacherid
inner join school as scl on scl.schoolid = cls.schoolid and scl.status = 1
where
c.teacherId in ( select teacherId from temp )
and c.created > #{startTime} and c.created < #{endTime}
group by scl.schoolid ),
heall as (select sum(examCount) as hearexamCountAll from he ),
-- 平均分
ss as (
select tt.schoolid,avg(at.score) as avgScore from temp tt
inner join
classes cs on cs.classtype=1 and cs.status=1 and cs.teacherid=tt.teacherid
inner join
studentownclass soc on soc.classesid=cs.classesid and soc.status=1
and soc.areaid =#{areaId}
inner join
achivement at on at.achivetype in ('L','W') and at.pointcasetype in (3,4,5,6,7,8)
and at.created > #{startTime} and at.created < #{endTime}
and at.areaid =#{areaId}
and at.uid=soc.studentid
group by tt.schoolid),
ssall as (select avg(avgScore) as avgScoreAll from ss ),
-- 获取发布配音作业次数
dub as (
select scl.schoolid , count( distinct ass.assignmentid ) as dubCount
from assignment ass inner join classes as cls on cls.teacherid = ass.teacherid
inner join school as scl on scl.schoolid = cls.schoolid and scl.status = 1
where
ass.teacherId in ( select teacherId from temp ) and assigntype='D'
and ass.created > #{startTime} and ass.created < #{endTime}
group by scl.schoolid
),
duball as (select sum(dubCount) as dubCountAll from dub)
select aw.schoolid ,case when aw.stuCount>0 then round(finishCount::numeric/aw.stuCount::numeric*100,2) else 0 end as finishRate , aw.schoolName ,
case when asscount.assignmentCount >0 then
asscount.assignmentCount else 0 end as assignmentCount ,
case when cm.classMessageCount >0 then
cm.classMessageCount else 0 end as classMessageCount,
case when asscountall.assignmentCountAll >0 then
asscountall.assignmentCountAll else 0 end as assignmentCountAll,
case when cm.classesCount >0 then
cm.classesCount else 0 end as classesCount,
case when te.examCount >0 and he.examCount >0 then
te.examCount + he.examCount
when te.examCount >0 then te.examCount
when he.examCount >0 then he.examCount
else 0 end as examCount
,
case when dub.dubCount > 0 then dub.dubCount else 0 end as dubCount,
case when pyc.accountCount > 0 then pyc.accountCount else 0 end as accountCount,
case when ss.avgScore > 0 then round( ss.avgScore,2) else 0 end as avgScore,
case when stuCountAll>0 then round(finishCountAll::numeric/stuCountAll::numeric*100,2) else 0 end as finishRateAll ,
case when classMessageCountAll >0 then classMessageCountAll else 0 end as classMessageCountAll ,
case when examCountAll >0 then examCountAll else 0 end as examCountAll ,
case when hearexamCountAll >0 then hearexamCountAll else 0 end as hearexamCountAll ,
case when avgScoreAll >0 then round(avgScoreAll,2) else 0 end as avgScoreAll ,
case when dubCountAll >0 then round(dubCountAll) else 0 end as dubCountAll
from aw
left join cm
on aw.schoolid = cm.schoolid
left join te
on aw.schoolid = te.schoolid
left join acc
on aw.schoolid = acc.schoolid
left join pyc
on aw.schoolid = pyc.schoolid
left join asscount
on aw.schoolid = asscount.schoolid
left join he
on aw.schoolid = he.schoolid
left join ss on ss.schoolid=aw.schoolid
left join dub on aw.schoolid = dub.schoolid,awall,cmall,teall,heall,ssall,duball,asscountall
order by
aw.schoolid
limit #{pageSize}
offset #{offset}
with temp as (select st.schoolId,sc.schoolName,sum(st.t_assigns) as assignmentCount,sum(t_messages) as classMessageCount,sum(st.t_assigntotals) as assigntotals,sum(st.t_assignfinishs) as assignfinishs , sum(st.t_exams) as examCount,sum(st.t_dubvideos) as dubCount,sum(st.studytotal) as studytotal,sum(st.studycount) as studycount from school as sc left join schoolstat st on sc.schoolid = st.schoolid and sc.areaid= #{areaId} where st.areaid = #{areaId} group by st.schoolId,sc.schoolName order by st.schoolId desc ),
allclass as (select temp.schoolid,count(distinct cls.classesid) as classCount ,count(distinct tea.teacherId) as accountCount from temp inner join classes as cls on cls.schoolid = temp.schoolid and cls.areaid = #{areaId} left join teacher as tea on temp.schoolid = tea.schoolid and tea.areaid = #{areaId} where cls.status =1 and cls.classtype =1 group by temp.schoolid),
allres as ( select sum(temp.assignmentCount) as assignmentCountAll,sum(assigntotals) as assigntotalsAll,sum(assignfinishs) as assignfinishsAll ,sum(classMessageCount) as classMessageCountAll ,sum(examCount) as examCountAll,sum(dubCount) as dubCountAll ,sum(studytotal) as studytotalAll ,sum(studycount) as studycountAll from temp )
select case when allclass.accountCount > 0 then allclass.accountCount else 0 end as accountCount,
case when temp.classMessageCount > 0 then temp.classMessageCount else 0 end as classMessageCount,
case when allres.classMessageCountAll > 0 then allres.classMessageCountAll else 0 end as classMessageCountAll,
case when allclass.classCount > 0 then allclass.classCount else 0 end as classesCount,
case when temp.studyCount > 0 then round(temp.studytotal/temp.studyCount,2) else 0.0 end as avgScore,
case when allres.studycountAll > 0 then round(allres.studytotalAll/allres.studycountAll,2) else 0.0 end as avgScoreAll,
case when temp.assigntotals > 0 then round(temp.assignfinishs*100/temp.assigntotals,2) else 0.0 end as finishRate,
case when allres.assigntotalsAll > 0 then round(allres.assignfinishsAll*100/allres.assigntotalsAll,2) else 0.0 end as finishRateAll,
case when temp.assignmentCount > 0 then temp.assignmentCount else 0 end as assignmentCount,
case when allres.assignmentCountAll > 0 then allres.assignmentCountAll+allres.dubCountAll+ allres.examCountAll else 0 end as assignmentCountAll,
case when temp.examCount > 0 then temp.examCount else 0 end as examCount,
case when allres.examCountAll > 0 then allres.examCountAll else 0 end as examCountAll,
case when temp.dubCount > 0 then temp.dubCount else 0 end as dubCount,
case when allres.dubCountAll > 0 then allres.dubCountAll else 0 end as dubCountAll,
case when allclass.classCount > 0 then allclass.classCount else 0 end as classesCount,
case when temp.schoolName != '' then temp.schoolName else '' end as schoolName,
temp.schoolId as schoolId from temp inner join allclass on temp.schoolid = allclass.schoolid ,allres
with temp as ( select t.teacherId , t.schoolId , case when avg(score)>0 then avg(score)
else 0 end as avgScore
from School s
inner join Teacher t on
s.areaid in (select areaid from area where parentid = #{parentId})
s.areaid in (select areaid from area where parentid in
(select areaid from area where parentid=#{provinceId}) )
s.areaid = #{areaId}
s.schoolid = #{schoolId}
and s.status = 1
and t.schoolId = s.schoolid and t.status = 1
and
t.truename=#{username}
and
t.loginno=#{recognizeCode}
left join
classes cs on cs.classtype=1 and cs.status=1 and cs.teacherid=t.teacherid
left join
studentownclass soc on soc.classesid=cs.classesid and soc.status=1
left join
achivement at on at.achivetype in ('L','W') and at.pointcasetype in (3,4,5,6,7,8)
and at.created > #{startTime} and at.created < #{endTime} and at.uid=soc.studentid
group by t.teacherId , t.schoolId
order by avgScore ${orderWay} ,t.teacherId
limit #{pageSize}
offset #{offset}
),
temp2 as(
select tt.teacherId,case when finishCount>0 then finishCount
else 0 end as finishCount,
case when aw.stuCount>0 then aw.stuCount
else 0 end as stuCount
from temp tt
left join
(
select t.teacherid,sum(case when fas.lessoncount>0 and fas.lessoncount = fas.lessoncount then 1 else 0 end) finishCount, count( soc.studentid) stuCount from temp t
inner join assignment a on a.teacherid=t.teacherid and a.status=1
and a.starttime>=#{startTime} and a.endtime< #{endTime}
inner join
assigntoclass atc on atc.assignmentid=a.assignmentid
inner join
classes c1 on c1.classesid=atc.classesid and c1.status=1
inner join
studentownclass soc on soc.classesid=c1.classesid and soc.status=1
left join
finishassignstat fas on fas.assignmentid=atc.assignmentid and fas.uid=soc.studentid
group by t.teacherid
) as aw on aw.teacherid = tt.teacherid )
select a.teacherId ,case when stuCount>0 then round(finishCount::numeric/stuCount::numeric*100,2) else 0 end as finishRate, s.schoolName , t.loginNo , t.trueName ,
case when ta.assignmentCount >0 then
ta.assignmentCount else 0 end as assignmentCount ,
case when cm.classMessageCount >0 then
cm.classMessageCount else 0 end as classMessageCount,
case when te.examCount >0 and he.examCount >0 then
te.examCount + he.examCount
when te.examCount >0 then te.examCount
when he.examCount >0 then he.examCount
else 0 end as examCount
,
uo.endTime,case when a.avgScore > 0 then round( a.avgScore)
else 0 end as avgScore,
cla.classNames
from temp as a
left join (select teacherId,array_to_string( array_agg (classname),'\r\n') as classNames from
classes where teacherId in (select teacherId from temp) and classType=1 and status=1 group by teacherId) as cla
on cla.teacherId = a.teacherId
left join
temp2 t2 on t2.teacherid=a.teacherid
inner join School as s
on a.schoolId = s.schoolId
inner join Teacher as t
on a.teacherId = t.teacherId
left join (
select teacherId , count( assignmentId ) as assignmentCount
from Assignment
where teacherId in ( select teacherId from temp )
and created > #{startTime} and created < #{endTime}
and status != 0
group by teacherId ) as ta
on a.teacherId = ta.teacherId
left join (
select teacherId , count( classmessageId ) as classMessageCount
from ClassMessage
where teacherId in ( select teacherId from temp )
and created > #{startTime} and created < #{endTime}
group by teacherId ) as cm
on a.teacherId = cm.teacherId
left join (
select c.teacherId , count( distinct e.examId ) as examCount
from Classes c
inner join ClassOwnExam coe
on c.teacherId in ( select teacherId from temp )
and c.status = 1
and c.classesid = coe.classesId
inner join Exam e
on coe.examId = e.examId
and e.created > #{startTime} and e.created < #{endTime}
group by c.teacherId ) as te
on a.teacherid = te.teacherid
left join (
select c.teacherId , count( distinct c.examId ) as examCount
from hearexam c
where
c.teacherId in ( select teacherId from temp )
and c.created > #{startTime} and c.created < #{endTime}
group by c.teacherId ) as he
on a.teacherid = he.teacherid
left join (
select uol.uid , max( uol.endTime ) as endTime
from temp tt
inner join
UserOwnLesson uol on tt.teacherId = uol.uid
group by uol.uid ) as uo
on a.teacherId = uo.uid
order by avgScore ${orderWay},a.teacherId
with temp as ( select t.teacherId , t.schoolId ,count( distinct e.examId )+count( distinct he.examId) examCount
from School s
inner join Teacher t on
s.areaid in (select areaid from area where parentid = #{parentId})
s.areaid in (select areaid from area where parentid in
(select areaid from area where parentid=#{provinceId}) )
s.areaid = #{areaId}
s.schoolid = #{schoolId}
and s.status = 1
and t.schoolId = s.schoolid and t.status = 1
and
t.truename=#{username}
and
t.loginno=#{recognizeCode}
left join
Classes c on c.status = 1 and c.teacherid = t.teacherid
left join
ClassOwnExam coe on c.classesId=coe.classesid
left join
Exam e on coe.examId = e.examId
and e.created > #{startTime} and e.created < #{endTime}
left join
hearexam he on he.teacherid = t.teacherid
and he.created > #{startTime} and he.created < #{endTime}
group by t.teacherId , t.schoolId
order by examCount ${orderWay} ,t.teacherId
limit #{pageSize}
offset #{offset}
),
temp2 as(
select tt.teacherId,case when finishCount>0 then finishCount
else 0 end as finishCount,
case when aw.stuCount>0 then aw.stuCount
else 0 end as stuCount
from temp tt
left join
(
select t.teacherid,sum(case when fas.lessoncount>0 and fas.lessoncount = fas.lessoncount then 1 else 0 end) finishCount, count( soc.studentid) stuCount from temp t
inner join assignment a on a.teacherid=t.teacherid and a.status=1
and a.starttime>=#{startTime} and a.endtime< #{endTime}
inner join
assigntoclass atc on atc.assignmentid=a.assignmentid
inner join
classes c1 on c1.classesid=atc.classesid and c1.status=1
inner join
studentownclass soc on soc.classesid=c1.classesid and soc.status=1
left join
finishassignstat fas on fas.assignmentid=atc.assignmentid and fas.uid=soc.studentid
group by t.teacherid
) as aw on aw.teacherid = tt.teacherid )
select a.teacherId ,case when stuCount>0 then round(finishCount::numeric/stuCount::numeric*100,2)
else 0 end as finishRate, s.schoolName , t.loginNo , t.trueName ,
case when ta.assignmentCount >0 then
ta.assignmentCount else 0 end as assignmentCount ,
case when cm.classMessageCount >0 then
cm.classMessageCount else 0 end as classMessageCount,
case when a.examCount >0 then
a.examCount else 0 end as examCount
,
uo.endTime,case when ss.avgScore > 0 then round( ss.avgScore)
else 0 end as avgScore,
cla.classNames
from temp as a
left join (select teacherId,array_to_string( array_agg (classname),'\r\n') as classNames from
classes where teacherId in (select teacherId from temp) and classType=1 and status=1 group by teacherId) as cla
on cla.teacherId = a.teacherId
left join
temp2 t2 on t2.teacherid=a.teacherid
inner join School as s
on a.schoolId = s.schoolId
inner join Teacher as t
on a.teacherId = t.teacherId
left join (
select teacherId , count( assignmentId ) as assignmentCount
from Assignment
where teacherId in ( select teacherId from temp )
and created > #{startTime} and created < #{endTime}
and status != 0
group by teacherId ) as ta
on a.teacherId = ta.teacherId
left join (
select teacherId , count( classmessageId ) as classMessageCount
from ClassMessage
where teacherId in ( select teacherId from temp )
and created > #{startTime} and created < #{endTime}
group by teacherId ) as cm
on a.teacherId = cm.teacherId
left join (
select uol.uid , max( uol.endTime ) as endTime
from temp tt
inner join
UserOwnLesson uol on tt.teacherId = uol.uid
group by uol.uid ) as uo
on a.teacherId = uo.uid
left join (
select tt.teacherid,avg(at.score) as avgScore from temp tt
inner join
classes cs on cs.classtype=1 and cs.status=1 and cs.teacherid=tt.teacherid
inner join
studentownclass soc on soc.classesid=cs.classesid and soc.status=1
inner join
achivement at on at.achivetype in ('L','W') and at.pointcasetype in (3,4,5,6,7,8)
and at.created > #{startTime} and at.created < #{endTime} and at.uid=soc.studentid
group by tt.teacherid) ss on ss.teacherid=a.teacherid
order by examCount ${orderWay},a.teacherId
with temp as (
select a.classesid,a.classlevel,a.schoolyear,a.classname,a.teacherId,a.classorder from classes as a inner join teacher as b on a.teacherId = b.teacherid where b.schoolId = #{schoolId} and a.status=1 group by a.classesid,a.classname,a.teacherId,a.classorder )
select distinct t.truename,t.teacherid,t.loginno,a.classesId,a.className,a.classlevel,a.schoolyear ,t.teacherid ,a.classorder ,
case when b.stuCount>0 then round(c.finishCount::numeric/b.stuCount::numeric*100,2)
else 0 end as examRate,
b.examCount,
case when d.stuCount>0 then round(e.finishCount::numeric/d.stuCount::numeric*100,2)
else 0 end as assignRate,
d.assignCount assignCount,
case when f.stuCount>0 then round(g.finishCount::numeric/f.stuCount::numeric*100,2)
else 0 end as dubRate,
f.assignCount dubCount,
h.assignCount personalCount,
case when h.stuCount>0 then round(i.finishCount::numeric/h.stuCount::numeric*100,2)
else 0 end as personalRate,
j.xkwAssignCount xkwCount,
case when j.stuCount>0 then round(k.finishCount::numeric/j.stuCount::numeric*100,2) else 0 end as xkwRate,
l.essayCount essayCount,
case when l.stuCount>0 then round(m.finishCount::numeric/l.stuCount::numeric*100,2) else 0 end as essayRate
from temp a
inner join
teacher t on a.teacherId=t.teacherid
left join(
select count( distinct e.examid) examCount, coe.classesid, count( distinct(soc.studentid,e.examid)) as stuCount from exam e
inner join
classownexam coe on e.examid=coe.examid and e.status =1
left join
studentownclass soc on soc.classesid=coe.classesid and soc.status=1
where coe.classesid in (select classesid from temp) and e.endtime<=#{endTime} and e.endtime>#{startTime}
group by coe.classesid
) as b on a.classesId = b.classesId
left join(
select count(distinct (userId,b.examid)) finishCount,coe.classesId from examanswer a inner join exam b
on a.examid=b.examid and b.status = 1
and a.score>0 and b.endtime<=#{endTime} and b.endtime>#{startTime}
inner join
classownexam coe on coe.classesid in (select classesid from temp) and coe.examId=a.examId
inner join studentownclass soc on soc.studentid=a.userid and soc.classesid=coe.classesid and soc.status=1
group by coe.classesId
) as c on a.classesId = c.classesId
left join(
select count( distinct e.assignmentid) assignCount, coe.classesId, count( distinct (soc.studentid,e.assignmentid)) as stuCount
from assignment e
inner join
assigntoclass coe on e.assignmentid=coe.assignmentid and e.assignType in ('L','W')
left join
studentownclass soc on soc.classesid=coe.classesid and soc.status=1
where coe.classesid in (select classesid from temp)
and e.endtime<=#{endTime} and e.endtime>#{startTime}
and e.status != 0
group by coe.classesId
) as d on a.classesId = d.classesId
left join(
select count(case when a.lessonCount=a.completeCount then uid else null end) finishCount ,atc.classesid
from finishAssignstat a inner join assignment b
on a.assignmentid=b.assignmentid
and b.status != 0
and b.endtime<=#{endTime} and b.endtime>#{startTime}
inner join assigntoclass atc on atc.classesid in (select classesid from temp) and atc.assignmentid=a.assignmentid
inner join studentownclass soc on soc.studentid=a.uid and soc.classesid=atc.classesid and soc.status=1
group by atc.classesid
) as e on a.classesid = e.classesid
left join(
select count( distinct e.assignmentid) assignCount,coe.classesid, count( distinct (soc.studentid,e.assignmentid)) as stuCount
from assignment e
inner join
assigntoclass coe on e.assignmentid=coe.assignmentid and e.assignType='D'
and e.status != 0
left join
studentownclass soc on soc.classesid=coe.classesid and soc.status=1
where e.teacherid in (select teacherid from temp) and e.endtime<=#{endTime} and e.endtime>#{startTime}
group by coe.classesid
) as f on a.classesid = f.classesid
left join(
select count(distinct(b.assignmentid,duv.uid)) finishCount,atc.classesid
from assignment b
inner join assigndetail a on a.assignmentid=b.assignmentid
and b.endtime<=#{endTime} and b.endtime>#{startTime}
and b.status != 0
inner join assigntoclass atc on atc.assignmentid=b.assignmentid
inner join studentownclass soc on soc.classesid=atc.classesid and soc.status=1
inner join DubUserVoice duv on duv.videoId=a.unitid and duv.uid=soc.studentid
where duv.created>b.startTime and duv.created<b.endTime
and a.assignmentid=b.assignmentid and b.teacherid in (select teacherid from temp)
and b.status !=0
group by atc.classesid
) as g on a.classesid = g.classesid
left join(
select count( distinct e.assignmentid) assignCount,coe.classesid,count( distinct (soc.classesid,soc.studentid,e.assignmentid)) as stuCount
from assignment e
inner join
assigntoclass coe on e.assignmentid=coe.assignmentid and e.assignType='S'
and e.status != 0
left join
studentownclass soc on soc.classesid=coe.classesid and soc.status=1
where e.teacherid in (select teacherid from temp) and e.endtime<=#{endTime} and e.endtime>#{startTime}
group by coe.classesid
) as h on a.classesid = h.classesid
left join(
select count(distinct(b.assignmentid,aas1.uid)) finishCount,atc.classesid
from assignment b
inner join assigntoclass atc on atc.assignmentid=b.assignmentid
inner join assignanswer as aas1 on atc.assignmentid = aas1.assignmentid
inner join studentownclass soc on soc.classesid=atc.classesid and soc.status=1 and soc.studentid = aas1.uid
and b.status != 0
where
b.teacherid in (select teacherid from temp) and b.assignType='S' and b.endtime<=#{endTime} and b.endtime>#{startTime}
and b.status !=0
group by atc.classesid
) as i on a.classesid = i.classesid
left join (
select count( distinct a.assignmentid) xkwAssignCount, b.classesid, count( distinct(soc.studentid,a.assignmentid)) as stuCount from xkw_assignment as a inner join xkw_assigntoclass as b on a.assignmentid = b.assignmentid and a.status =1 left join
studentownclass soc on soc.classesid=b.classesid and soc.status=1 where b.classesid in (select classesid from temp) and a.endtime<=#{endTime} and a.endtime>#{startTime}
group by b.classesid
) as j on a.classesid = j.classesid
left join (
select count(case when a.questionCount <= a.completeCount then a.uid else null end) finishCount, b.classesid from finishxkw_assignstat as a inner join xkw_assignment as c on a.assignmentid = c.assignmentid inner join xkw_assigntoclass as b on a.assignmentid = b.assignmentid and c.status =1 inner join studentownclass soc on soc.studentid=a.uid and soc.classesid=b.classesid and soc.status=1 where b.classesid in (select classesid from temp) and c.endtime<=#{endTime} and c.endtime>#{startTime} group by b.classesId
) as k on a.classesid = k.classesid
left join (
select count(distinct a.assignmentid) essayCount,b.classesid, count(distinct(soc.studentid,a.assignmentid)) as stuCount from essayassign as a inner join classownessay as b on a.assignmentid = b.assignmentid and a.status =1 left join studentownclass soc on soc.classesid=b.classesid and soc.status=1 where b.classesid in (select classesid from temp) and a.endtime<=#{endTime} and a.endtime>#{startTime}
group by b.classesid
) as l on a.classesid = l.classesid
left join (
select count(distinct (a.assignmentid,a.uid)) as finishCount,b.classesid from essayanswer as a inner join essayassign as c on a.assignmentid = c.assignmentid inner join classownessay as b on c.assignmentid = b.assignmentid and c.status = 1 inner join studentownclass soc on soc.studentid=a.uid and soc.classesid=b.classesid and soc.status=1 where b.classesid in (select classesid from temp) and c.endtime<=#{endTime} and c.endtime>#{startTime} group by b.classesId
) as m on a.classesid = m.classesid
order by a.classlevel,a.schoolyear desc,t.teacherid desc,a.classorder asc,a.classesid desc
with temp as(
select a.assignmentid,created,startTime,endTime,description,assignType from assignment a
inner join assigntoclass at on a.assignmentid=at.assignmentid
and a.status != 0
and
a.endtime>#{startTime} and a.endtime<=#{endTime} and at.classesId=#{classesId}
and a.assignType in ('L','W')
order by created desc
LIMIT #{pageSize}
OFFSET #{offset}
)
select a.assignmentid,a.starttime,a.endtime,a.description,a.assignType,
case when c.stuCount>0 then round(b.finishCount::numeric/c.stuCount::numeric*100,2)
else 0 end as assignRate from temp a
left join
(
select count( case when f.lessonCount=f.completeCount then uid else null end) as finishCount ,f.assignmentid
from finishassignstat f
inner join studentownclass soc on soc.studentid=f.uid and soc.classesid=#{classesId}
where
f.assignmentid in (select assignmentid from temp) group by
f.assignmentid
) as b on a.assignmentid=b.assignmentid
left join
(
select count(distinct studentid) as stuCount,a.assignmentid from
assigntoclass a
inner join
studentownclass stc
on
a.assignmentid in (select assignmentid from temp)
and a.classesid=stc.classesid and stc.status=1 and stc.classesid=#{classesId}
group by
a.assignmentid
) as c on a.assignmentid=c.assignmentid
order by a.created desc
select count(a.assignmentid) from assignment a
inner join assigntoclass at on a.assignmentid=at.assignmentid and
a.endtime>#{startTime} and a.endtime<=#{endTime}
and a.status!=0
and at.classesId=#{classesId}
and a.assignType in ('L','W')
and a.assignType='D'
and a.assignType='S'
select count(a.assignmentid) from xkw_assignment a
inner join xkw_assigntoclass at on a.assignmentid=at.assignmentid and
a.endtime>#{startTime} and a.endtime<=#{endTime}
and a.status!=0
and at.classesId=#{classesId}
with temp as(
select a.assignmentid,a.created,a.startTime,a.endTime,b.unitid,b.title,a.assignType from assignment a
inner join assigntoclass at on a.assignmentid=at.assignmentid
and a.status != 0
and
a.endtime>#{startTime} and a.endtime<=#{endTime} and at.classesId=#{classesId}
and a.assignType='D'
inner join assigndetail b on a.assignmentid=b.assignmentid
order by created desc
LIMIT #{pageSize}
OFFSET #{offset}
)
select a.assignmentid,a.starttime,a.endtime,a.title description,a.assignType,
case when c.stuCount>0 then round(b.finishCount::numeric/c.stuCount::numeric*100,2)
else 0 end as assignRate from temp a
left join
(
select count(distinct(duv.uid)) finishCount,a.assignmentid
from temp a
inner join assigntoclass atc on atc.assignmentid=a.assignmentid
inner join studentownclass soc on soc.classesid=atc.classesid and soc.status=1 and soc.classesid=#{classesId}
inner join DubUserVoice duv on duv.videoId=a.unitid and duv.uid=soc.studentid
and duv.created>a.startTime and duv.created<a.endTime
group by a.assignmentid
) as b on a.assignmentid=b.assignmentid
left join
(
select count(distinct studentid) as stuCount,a.assignmentid from
assigntoclass a
inner join
studentownclass stc
on
a.assignmentid in (select assignmentid from temp)
and a.classesid=stc.classesid and stc.status=1 and stc.classesid=#{classesId}
group by
a.assignmentid
) as c on a.assignmentid=c.assignmentid
order by a.created desc
with temp as(
select a.examid,created,startTime,endTime,title,isOral from exam a
inner join classownexam at on a.examid=at.examid and a.status =1 and
a.endtime>#{startTime} and a.endtime<=#{endTime} and at.classesId=#{classesId}
order by created desc
LIMIT #{pageSize}
OFFSET #{offset}
)
select a.examid assignmentid,a.starttime,a.endtime,a.title description,isOral as assignType,
case when c.stuCount>0 then round(b.finishCount::numeric/c.stuCount::numeric*100,2)
else 0 end as assignRate from temp a
left join
(
select count( distinct userId) as finishCount ,f.examid
from examanswer f
inner join studentownclass soc on soc.studentid=f.userId and soc.classesid=#{classesId}
where
f.examid in (select examid from temp) group by
f.examid
) as b on a.examid=b.examid
left join
(
select count(distinct studentid) as stuCount,a.examid from
classownexam a
inner join
studentownclass stc
on
a.examid in (select examid from temp)
and a.classesid=stc.classesid and stc.status=1 and stc.classesid=#{classesId}
group by
a.examid
) as c on a.examid=c.examid
order by a.created desc
select count(a.examid) from exam a
inner join classownexam at on a.examid=at.examid and
a.endtime>#{startTime} and a.endtime<#{endTime}
and at.classesId=#{classesId}
with temp as(
select a.assignmentid,created,startTime,endTime,description,assignType from assignment a
inner join assigntoclass at on a.assignmentid=at.assignmentid
and a.status != 0
and
a.endtime>#{startTime} and a.endtime<=#{endTime} and at.classesId=#{classesId}
and a.assignType ='S'
order by created desc
LIMIT #{pageSize}
OFFSET #{offset}
)
select a.assignmentid,a.starttime,a.endtime,a.description,a.assignType,
case when c.stuCount>0 then round(b.finishCount::numeric/c.stuCount::numeric*100,2)
else 0 end as assignRate from temp a
left join
(
select count(distinct(aas.uid)) finishCount ,b.assignmentid
from assignment b
inner join assigntoclass atc on atc.assignmentid=b.assignmentid and b.assignType = 'S'
inner join studentownclass soc on soc.classesid=atc.classesid and soc.status=1
inner join assignAnswer as aas on aas.assignmentid = b.assignmentid
and b.endtime<=#{endTime} and b.endtime>=#{startTime}
and b.status != 0 and soc.classesid = #{classesId}
where
b.teacherid in (select teacherid from temp)
and b.status !=0
group by b.assignmentid
) as b on a.assignmentid=b.assignmentid
left join
(
select count(distinct studentid) as stuCount,a.assignmentid from
assigntoclass a
inner join
studentownclass stc
on
a.assignmentid in (select assignmentid from temp)
and a.classesid=stc.classesid and stc.status=1 and stc.classesid=#{classesId}
group by
a.assignmentid
) as c on a.assignmentid=c.assignmentid
order by a.created desc
with temp as(
select a.assignmentid,created,startTime,endTime,description from xkw_assignment a
inner join xkw_assigntoclass at on a.assignmentid=at.assignmentid
and a.status != 0
and
a.endtime>#{startTime} and a.endtime<=#{endTime} and at.classesId=#{classesId}
order by created desc
LIMIT #{pageSize}
OFFSET #{offset}
)
select a.assignmentid,a.starttime,a.endtime,a.description,'X' as assignType,
case when c.stuCount>0 then round(b.finishCount::numeric/c.stuCount::numeric*100,2)
else 0 end as assignRate from temp a
left join
(
select count(distinct case when aas.questionCount <= aas.completeCount then aas.uid else null end) finishCount,b.assignmentid
from xkw_assignment b
inner join finishxkw_assignstat as aas on aas.assignmentid = b.assignmentid
inner join studentownclass soc on soc.studentid=aas.uid and soc.status=1
and b.endtime<=#{endTime} and b.endtime>#{startTime}
and b.status != 0 and soc.classesid = #{classesId}
where
b.teacherid in (select teacherid from temp)
and b.status !=0
group by b.assignmentid
) as b on a.assignmentid=b.assignmentid
left join
(
select count(distinct studentid) as stuCount,a.assignmentid from
xkw_assigntoclass a
inner join
studentownclass stc
on
a.assignmentid in (select assignmentid from temp)
and a.classesid=stc.classesid and stc.status=1 and stc.classesid=#{classesId}
group by
a.assignmentid
) as c on a.assignmentid=c.assignmentid
order by a.created desc
with temp as(
select a.assignmentid,created,startTime,endTime,description,essaybaseid from essayassign a
inner join classownessay at on a.assignmentid=at.assignmentid
and a.status != 0
and
a.endtime>#{startTime} and a.endtime <=#{endTime} and at.classesId=#{classesId}
order by created desc
LIMIT #{pageSize}
OFFSET #{offset}
)
select a.assignmentid,a.starttime,a.endtime,a.description,'Z' as assignType,a.essaybaseid,
case when c.stuCount>0 then round(b.finishCount::numeric/c.stuCount::numeric*100,2)
else 0 end as assignRate from temp a
left join
(
select count(distinct aas.uid) finishCount,b.assignmentid
from essayassign b
inner join essayanswer as aas on aas.assignmentid = b.assignmentid inner join classownessay as coe on coe.assignmentid = b.assignmentid
inner join studentownclass soc on soc.studentid=aas.uid and soc.status=1
and b.endtime<=#{endTime} and b.endtime>#{startTime}
and b.status != 0 and soc.classesid = #{classesId}
where
b.teacherid in (select teacherid from temp)
and b.status !=0
group by b.assignmentid
) as b on a.assignmentid=b.assignmentid
left join
(
select count(distinct studentid) as stuCount,a.assignmentid from
classownessay a
inner join
studentownclass stc
on
a.assignmentid in (select assignmentid from temp)
and a.classesid=stc.classesid and stc.status=1 and stc.classesid=#{classesId}
group by
a.assignmentid
) as c on a.assignmentid=c.assignmentid
order by a.created desc
select count(a.assignmentid) from essayassign a
inner join classownessay at on a.assignmentid=at.assignmentid
and a.status != 0
and
a.endtime>#{startTime} and a.endtime<#{endTime} and at.classesId=#{classesId}