1058 lines
43 KiB
XML
1058 lines
43 KiB
XML
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||
|
|
<mapper namespace="StudyStatistics">
|
||
|
|
<resultMap id="BaseResultMap" type="AchiStatOfUid">
|
||
|
|
<result column="studentId" property="studentId"/>
|
||
|
|
<result column="avgScore" property="avgScore"/>
|
||
|
|
<result column="howmuch" property="howmuch"/>
|
||
|
|
<result column="total" property="total"/>
|
||
|
|
<result column="maxScore" property="maxScore"/>
|
||
|
|
<result column="lastTime" property="lastTime"/>
|
||
|
|
<result column="voice" property="voice"/>
|
||
|
|
<result column="isSign" property="isSign"/>
|
||
|
|
<result column="achivementId" property="achivementId"/>
|
||
|
|
<result property="jcontent" column="jcontent" typeHandler="com.spoken.api.handlers.JSONTypeHandlerPg1"/>
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<resultMap id="BaseResultMapForWechat" type="AchiStatOfUidForWechat">
|
||
|
|
<result column="studentId" property="studentId"/>
|
||
|
|
<result column="avgScore" property="avgScore"/>
|
||
|
|
<result column="howmuch" property="howmuch"/>
|
||
|
|
<result column="total" property="total"/>
|
||
|
|
<result column="maxScore" property="maxScore"/>
|
||
|
|
<result column="lastTime" property="lastTime"/>
|
||
|
|
<result column="voice" property="voice"/>
|
||
|
|
<result column="isSign" property="isSign"/>
|
||
|
|
<result column="assignmentId" property="assignmentId"/>
|
||
|
|
<result property="jcontent" column="jcontent" typeHandler="com.spoken.api.handlers.JSONTypeHandlerPg1"/>
|
||
|
|
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<select id="StudyStatByClass" parameterType="java.util.Map" resultType="StudyStatInfo">
|
||
|
|
|
||
|
|
<!-- select b.studentId as uid , b.recognizeCode , b.trueName , b.nickname ,
|
||
|
|
c.totalTime , c.totalNum , d.avgScore , d.totalLesson
|
||
|
|
from StudentOwnClass a
|
||
|
|
inner join Student b
|
||
|
|
on a.classesId = #{classesId} and a.studentId = b.studentId and a.status = 1
|
||
|
|
left join (select m.studentId , sum( timeLength ) as totalTime , count(*) as totalNum
|
||
|
|
from StudentOwnClass m
|
||
|
|
inner join ConnectLog n
|
||
|
|
on m.classesId = #{classesId} and m.studentId = n.uid
|
||
|
|
where n.startTime > #{startTime} and n.endTime <= #{endTime}
|
||
|
|
group by m.studentId ) c
|
||
|
|
on a.studentId = c.studentId
|
||
|
|
left join (select p.studentId , round( avg( q.score ) ) as avgScore ,
|
||
|
|
count( objectId ) as totalLesson
|
||
|
|
from StudentOwnClass p
|
||
|
|
inner join Achivement q
|
||
|
|
on p.classesId = #{classesId} and p.studentId = q.uid
|
||
|
|
and q.pointCaseType in (3, 5 , 6 , 7 , 8 )
|
||
|
|
and q.achiveType in ( 'L' , 'W' )
|
||
|
|
where q.created > #{startTime} and q.created <= #{endTime}
|
||
|
|
group by p.studentId ) d
|
||
|
|
on a.studentId = d.studentId
|
||
|
|
order by a.studentId
|
||
|
|
limit #{pageSize} offset #{offset} -->
|
||
|
|
|
||
|
|
with temp1 as ( select studentId from StudentOwnClass where classesId = #{classesId} and areaId=#{areaId} and status = 1
|
||
|
|
) ,
|
||
|
|
temp2 as ( select m.studentId , sum( timeLength ) as totalTime , count(*) as totalNum
|
||
|
|
from temp1 m
|
||
|
|
inner join ConnectLog n
|
||
|
|
on m.studentId = n.uid where n.startTime > #{startTime} and n.endTime <= #{endTime} and n.areaId=#{areaId}
|
||
|
|
group by m.studentId ) ,
|
||
|
|
temp4 as ( select p.studentId ,avg( q.score ) as avgScore , count( q.objectId ) as totalLesson
|
||
|
|
from temp1 p
|
||
|
|
inner join Achivement q
|
||
|
|
on p.studentId = q.uid and q.pointCaseType in (3,4, 5 , 6 , 7 , 8 ) and q.areaId=#{areaId}
|
||
|
|
and q.achiveType in ( 'L' , 'W' )
|
||
|
|
and q.created >#{startTime} and q.created <= #{endTime}
|
||
|
|
group by p.studentId ) ,
|
||
|
|
temp5 as( select t.studentId,count(case when f.lessoncount is not null and f.lessoncount=f.completecount then 1 else null end) as totalAssign from temp1 t
|
||
|
|
inner join finishassignstat f on t.studentid=f.uid and f.areaId=#{areaId}
|
||
|
|
and f.created >#{startTime} and f.created <= #{endTime}
|
||
|
|
group by t.studentId
|
||
|
|
)
|
||
|
|
select b.studentId as uid , b.recognizeCode , b.trueName , b.nickname ,case when c.totalTime is null then 0 else c.totalTime end ,
|
||
|
|
case when c.totalNum is null then 0 else c.totalNum end , case when d.avgScore is null then 0 else d.avgScore end as avgScore , case when d.totalLesson is null then 0 else d.totalLesson end as totalLesson ,case when e.totalAssign is null then 0 else e.totalAssign end as totalAssign
|
||
|
|
from temp1 a
|
||
|
|
inner join Student b
|
||
|
|
on a.studentId = b.studentId and b.areaId=#{areaId}
|
||
|
|
left join temp2 c
|
||
|
|
on a.studentId = c.studentId
|
||
|
|
left join temp4 d
|
||
|
|
on a.studentId = d.studentId
|
||
|
|
left join temp5 e
|
||
|
|
on a.studentId = e.studentId
|
||
|
|
|
||
|
|
order by avgScore desc,totalLesson desc,totalAssign desc,b.studentId
|
||
|
|
|
||
|
|
|
||
|
|
<if test="pageSize != null and offset != null">
|
||
|
|
limit #{pageSize} offset #{offset}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
|
||
|
|
<!-- with temp1 as ( select studentId from StudentOwnClass where classesId = #{classesId} and areaId=#{areaId} and status = 1
|
||
|
|
order by studentid
|
||
|
|
limit #{pageSize} offset #{offset}) ,
|
||
|
|
temp2 as ( select m.studentId , sum( timeLength ) as totalTime , count(*) as totalNum
|
||
|
|
from temp1 m
|
||
|
|
inner join ConnectLog n
|
||
|
|
on m.studentId = n.uid where n.startTime > #{startTime} and n.endTime <= #{endTime} and n.areaId=#{areaId}
|
||
|
|
group by m.studentId ) ,
|
||
|
|
temp4 as ( select p.studentId ,avg( q.score ) as avgScore , count( q.objectId ) as totalLesson
|
||
|
|
from temp1 p
|
||
|
|
inner join Achivement q
|
||
|
|
on p.studentId = q.uid and q.pointCaseType in (3,4, 5 , 6 , 7 , 8 ) and q.areaId=#{areaId}
|
||
|
|
and q.achiveType in ( 'L' , 'W' )
|
||
|
|
and q.created >#{startTime} and q.created <= #{endTime}
|
||
|
|
group by p.studentId ) ,
|
||
|
|
temp5 as( select t.studentId,count(case when f.lessoncount is not null and f.lessoncount=f.completecount then 1 else null end) as totalAssign from temp1 t
|
||
|
|
inner join finishassignstat f on t.studentid=f.uid and f.areaId=#{areaId}
|
||
|
|
and f.created >#{startTime} and f.created <= #{endTime}
|
||
|
|
group by t.studentId
|
||
|
|
)
|
||
|
|
select b.studentId as uid , b.recognizeCode , b.trueName , b.nickname , c.totalTime ,
|
||
|
|
c.totalNum , d.avgScore , d.totalLesson ,e.totalAssign
|
||
|
|
from temp1 a
|
||
|
|
inner join Student b
|
||
|
|
on a.studentId = b.studentId and b.areaId=#{areaId}
|
||
|
|
left join temp2 c
|
||
|
|
on a.studentId = c.studentId
|
||
|
|
left join temp4 d
|
||
|
|
on a.studentId = d.studentId
|
||
|
|
left join temp5 e
|
||
|
|
on a.studentId = e.studentId
|
||
|
|
|
||
|
|
order by a.studentId -->
|
||
|
|
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="studentStatCurve" parameterType="java.util.Map" resultType="StudyStatCurve">
|
||
|
|
SELECT extract( year from a.created ) as myYear ,
|
||
|
|
extract( month from a.created ) as myMonth,
|
||
|
|
max( a.score ) as maxScore , avg( a.score ) as avgScore
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid = #{uid} AND a.achiveType in ('L','W') and a.areaId=#{areaId}
|
||
|
|
AND pointCaseType in (3, 4,5, 6 , 7 , 8 )
|
||
|
|
|
||
|
|
AND a.created > #{startTime} and a.created <= #{endTime}
|
||
|
|
|
||
|
|
GROUP BY extract( year from a.created ) ,
|
||
|
|
extract( month from a.created )
|
||
|
|
ORDER BY myYear desc , myMonth desc
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="classesStatCurve" parameterType="java.util.Map" resultType="StudyStatCurve">
|
||
|
|
SELECT extract( year from b.created ) as myYear ,
|
||
|
|
extract( month from b.created ) as myMonth,
|
||
|
|
max( b.score ) as maxScore , avg( b.score ) as avgScore
|
||
|
|
FROM StudentOwnClass a
|
||
|
|
INNER JOIN Achivement b
|
||
|
|
ON a.classesId = #{classesId} and a.status = 1
|
||
|
|
AND a.studentId = b.uid
|
||
|
|
and b.areaId=#{areaId}
|
||
|
|
WHERE b.created > #{startTime} and b.created <= #{endTime}
|
||
|
|
|
||
|
|
|
||
|
|
AND b.achiveType in ('L','W')
|
||
|
|
AND b.pointCaseType in (3, 4,5, 6 , 7 , 8 )
|
||
|
|
GROUP BY extract( year from b.created ) ,
|
||
|
|
extract( month from b.created )
|
||
|
|
ORDER BY myYear , myMonth
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="singleArchStat" parameterType="java.util.Map" resultType="SingleArchStat">
|
||
|
|
SELECT a.objectId as lessonId ,a.pointCaseType , a.score as score , a.created as lastTime ,a.achiveType
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid = #{uid} AND a.achiveType in ('L','W','S') and a.areaId=#{areaId}
|
||
|
|
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
|
||
|
|
<if test="pointCaseType != null">AND
|
||
|
|
pointCaseType = #{pointCaseType}
|
||
|
|
</if>
|
||
|
|
AND pointCaseType in (3, 4,5, 6 , 7 , 8 )
|
||
|
|
|
||
|
|
ORDER BY lastTime desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="singleArchStatCount" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
SELECT count(*)
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid = #{uid} AND a.achiveType in ('L','W','S') and a.areaId=#{areaId}
|
||
|
|
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
|
||
|
|
<if test="pointCaseType != null">
|
||
|
|
AND
|
||
|
|
pointCaseType = #{pointCaseType}
|
||
|
|
</if>
|
||
|
|
AND pointCaseType in (3, 4,5, 6 , 7 , 8 )
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="singleArchStatAllCase" parameterType="java.util.Map" resultType="SingleArchStat">
|
||
|
|
SELECT a.objectId as lessonId , pointCaseType , a.score as score , a.created as lastTime ,a.achiveType
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid = #{uid} AND a.achiveType in ('L','W','S')
|
||
|
|
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
|
||
|
|
AND pointCaseType in (3,4, 5, 6 , 7 , 8 )
|
||
|
|
|
||
|
|
ORDER BY lastTime desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="singleArchStatAllCaseCount" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
SELECT count(*)
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid = #{uid} AND a.achiveType in ('L','W','S')
|
||
|
|
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
|
||
|
|
AND pointCaseType in (3, 4,5, 6 , 7 , 8 )
|
||
|
|
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="classArchStat" parameterType="java.util.Map" resultType="SingleArchStat">
|
||
|
|
SELECT a.objectId as lessonId ,a.pointCaseType , a.score as score , a.created as lastTime
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid in ( select distinct(studentId) from studentownclass where classesid= #{classesId}
|
||
|
|
and areaid=#{areaId} and status = 1)
|
||
|
|
AND a.achiveType in ('L','W')
|
||
|
|
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
and a.areaId=#{areaId}
|
||
|
|
<if test="pointCaseType != null">AND
|
||
|
|
pointCaseType = #{pointCaseType}
|
||
|
|
</if>
|
||
|
|
AND pointCaseType in (3, 4,5, 6 , 7 , 8 )
|
||
|
|
|
||
|
|
ORDER BY lastTime desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="classArchStatCount" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
SELECT count(*)
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid in ( select distinct(studentId) from studentownclass where classesid= #{classesId}
|
||
|
|
and areaid=#{areaId} and status = 1)
|
||
|
|
AND a.achiveType in ('L','W')
|
||
|
|
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
and a.areaId=#{areaId}
|
||
|
|
<if test="pointCaseType != null">AND
|
||
|
|
pointCaseType = #{pointCaseType}
|
||
|
|
</if>
|
||
|
|
AND pointCaseType in (3, 4,5, 6 , 7 , 8 )
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="classArchStatAllCase" parameterType="java.util.Map" resultType="SingleArchStat">
|
||
|
|
SELECT a.objectId as lessonId , pointCaseType , a.score as score , a.created as lastTime
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid in ( select distinct(studentId) from studentownclass where classesid= #{classesId} and status = 1)
|
||
|
|
AND a.achiveType in ('L','W')
|
||
|
|
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
|
||
|
|
AND pointCaseType in (3, 4,5, 6 , 7 , 8 )
|
||
|
|
|
||
|
|
ORDER BY lastTime desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="classArchStatAllCaseCount" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
SELECT count(*)
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid in ( select distinct(studentId) from studentownclass where classesid= #{classesId} and status = 1)
|
||
|
|
AND a.achiveType in ('L','W')
|
||
|
|
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
|
||
|
|
AND pointCaseType in (3, 4,5, 6 , 7 , 8 )
|
||
|
|
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="MaxclassArchStat" parameterType="java.util.Map" resultType="SingleArchStat">
|
||
|
|
SELECT a.objectId as lessonId ,a.pointCaseType , max( a.score ) as score , max( a.created ) as lastTime
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid in ( select distinct(studentId) from studentownclass where classesid= #{classesId}
|
||
|
|
and areaId=#{areaId} and status = 1)
|
||
|
|
AND a.achiveType in ('L','W')
|
||
|
|
and a.areaId=#{areaId}
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
|
||
|
|
<if test="pointCaseType != null">AND
|
||
|
|
pointCaseType = #{pointCaseType}
|
||
|
|
</if>
|
||
|
|
AND pointCaseType in (3, 4,5, 6 , 7 , 8 )
|
||
|
|
GROUP BY a.objectId , a.pointCaseType
|
||
|
|
ORDER BY lastTime desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="MaxclassArchStatCount" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
SELECT count(distinct (a.objectId, a.pointCaseType))
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid in ( select distinct(studentId) from studentownclass where classesid= #{classesId}
|
||
|
|
and areaId=#{areaId} and status = 1 )
|
||
|
|
AND a.achiveType in ('L','W')
|
||
|
|
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
and a.areaId=#{areaId}
|
||
|
|
<if test="pointCaseType != null">AND
|
||
|
|
pointCaseType = #{pointCaseType}
|
||
|
|
</if>
|
||
|
|
AND pointCaseType in (3,4, 5, 6 , 7 , 8 )
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="MaxclassArchStatAllCase" parameterType="java.util.Map" resultType="SingleArchStat">
|
||
|
|
SELECT a.objectId as lessonId , pointCaseType , max( a.score ) as score , max( a.created ) as lastTime
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid in ( select distinct(studentId) from studentownclass where classesid= #{classesId} and status = 1)
|
||
|
|
AND a.achiveType in ('L','W')
|
||
|
|
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
|
||
|
|
AND pointCaseType in (3,4, 5, 6 , 7 , 8 )
|
||
|
|
GROUP BY a.objectId , pointCaseType
|
||
|
|
ORDER BY lastTime desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="MaxclassArchStatAllCaseCount" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
SELECT count(distinct (a.objectId))
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid in ( select distinct(studentId) from studentownclass where classesid= #{classesId} and status = 1)
|
||
|
|
AND a.achiveType in ('L','W')
|
||
|
|
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
|
||
|
|
AND pointCaseType in (3,4, 5, 6 , 7 , 8 )
|
||
|
|
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="MaxsingleArchStat" parameterType="java.util.Map" resultType="SingleArchStat">
|
||
|
|
<!-- SELECT a.objectId as lessonId ,a.pointCaseType , max( a.score ) as score , max( a.created ) as lastTime
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid = #{uid} AND a.achiveType in ('L','W')
|
||
|
|
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
|
||
|
|
<if test="pointCaseType != null">AND
|
||
|
|
pointCaseType = #{pointCaseType}
|
||
|
|
</if>
|
||
|
|
AND pointCaseType in (3, 5, 6 , 7 , 8 )
|
||
|
|
GROUP BY a.objectId , a.pointCaseType
|
||
|
|
ORDER BY lastTime desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if> -->
|
||
|
|
|
||
|
|
|
||
|
|
with temp as(
|
||
|
|
select achivementid,objectid,score,created,pointCaseType,achiveType,ROW_NUMBER()
|
||
|
|
OVER (PARTITION BY objectid,pointCaseType ORDER BY score DESC,created desc) AS rn
|
||
|
|
from achivement a WHERE a.uid = #{uid} and a.areaId=#{areaId}
|
||
|
|
<if test="pointCaseType != null">AND
|
||
|
|
pointCaseType = #{pointCaseType}
|
||
|
|
</if>
|
||
|
|
AND pointCaseType in (3,4, 5, 6 , 7 , 8 ) AND a.achiveType in ('L','W','S')
|
||
|
|
AND a.created > #{startTime} AND a.created< #{endTime}
|
||
|
|
order by created )
|
||
|
|
select objectId as lessonId , pointCaseType , score , created as lastTime ,achiveType
|
||
|
|
from temp where rn=1
|
||
|
|
order by lastTime desc
|
||
|
|
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="MaxsingleArchStatCount" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
SELECT count(distinct (a.objectId, a.pointCaseType))
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid = #{uid} AND a.achiveType in ('L','W','S') and a.areaId=#{areaId}
|
||
|
|
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
|
||
|
|
<if test="pointCaseType != null">AND
|
||
|
|
pointCaseType = #{pointCaseType}
|
||
|
|
</if>
|
||
|
|
AND pointCaseType in (3,4, 5, 6 , 7 , 8 )
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="MaxsingleArchStatAllCase" parameterType="java.util.Map" resultType="SingleArchStat">
|
||
|
|
<!-- SELECT a.objectId as lessonId , pointCaseType , max( a.score ) as score , max( a.created ) as lastTime
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid = #{uid} AND a.achiveType in ('L','W')
|
||
|
|
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
|
||
|
|
AND pointCaseType in (3, 5, 6 , 7 , 8 )
|
||
|
|
GROUP BY a.objectId , pointCaseType
|
||
|
|
ORDER BY lastTime desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if> -->
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
with temp as(
|
||
|
|
select achivementid,objectid,score,created,pointCaseType,achiveType,ROW_NUMBER()
|
||
|
|
OVER (PARTITION BY objectid,pointCaseType ORDER BY score DESC,created desc) AS rn
|
||
|
|
from achivement a WHERE a.uid = #{uid} and a.areaId=#{areaId} AND pointCaseType in (3, 4,5, 6 , 7 , 8 ) AND a.achiveType in ('L','W','S')
|
||
|
|
AND a.created > #{startTime} AND a.created< #{endTime}
|
||
|
|
order by created )
|
||
|
|
select objectId as lessonId , pointCaseType , score , created as lastTime ,achiveType
|
||
|
|
from temp where rn=1
|
||
|
|
order by lastTime desc
|
||
|
|
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="MaxsingleArchStatAllCaseCount" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
SELECT count(distinct (a.objectId,a.pointCaseType))
|
||
|
|
FROM Achivement a
|
||
|
|
WHERE a.uid = #{uid} and a.areaId=#{areaId} AND a.achiveType in ('L','W','S')
|
||
|
|
|
||
|
|
AND a.created > #{startTime} AND a.created < #{endTime}
|
||
|
|
|
||
|
|
AND pointCaseType in (3, 4,5, 6 , 7 , 8 )
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="studyCheckByClass" parameterType="java.util.Map" resultType="AchiStatOfUid">
|
||
|
|
WITH temp1 as ( select s.studentId
|
||
|
|
from StudentOwnClass s inner join student st on s.studentid=st.studentid
|
||
|
|
where classesId = #{classesId} and st.areaId=#{areaId} and s.areaId=#{areaId} and s.status = 1 ) ,
|
||
|
|
temp2 as ( select n.uid ,score , n.objectId , n.created , n.achiveType , n.pointCaseType
|
||
|
|
from temp1 m
|
||
|
|
inner join Achivement n
|
||
|
|
ON m.studentId = n.uid and n.areaId=#{areaId}
|
||
|
|
<if test="startTime!=null">
|
||
|
|
<![CDATA[
|
||
|
|
and n.created >= #{startTime}
|
||
|
|
]]>
|
||
|
|
</if>
|
||
|
|
<if test="endTime!=null">
|
||
|
|
<![CDATA[
|
||
|
|
and n.created < #{endTime}
|
||
|
|
]]>
|
||
|
|
</if> ) ,
|
||
|
|
temp3 as ( select uid ,score , objectId , created
|
||
|
|
from temp2 n
|
||
|
|
where n.achiveType in ('L','W') AND n.pointCaseType in (3, 4,5, 6 , 7 ,8 )
|
||
|
|
<if test="lessonIds != null and lessonIds.size() != 0">
|
||
|
|
AND n.objectId in
|
||
|
|
<foreach collection="lessonIds" item="item" separator="," close=")" open="(">
|
||
|
|
#{item}
|
||
|
|
</foreach>
|
||
|
|
|
||
|
|
</if>
|
||
|
|
<if test="lessonIds == null or lessonIds.size() == 0">
|
||
|
|
AND n.objectId is null
|
||
|
|
|
||
|
|
</if>
|
||
|
|
|
||
|
|
|
||
|
|
)
|
||
|
|
SELECT a.studentId , avg(b.score) as avgScore ,
|
||
|
|
count( distinct b.objectId ) as howmuch ,
|
||
|
|
count(b.objectId) as total ,
|
||
|
|
max(b.score) as maxScore,
|
||
|
|
max( b.created ) as lastTime
|
||
|
|
FROM temp1 as a
|
||
|
|
LEFT JOIN temp3 as b
|
||
|
|
ON a.studentId = b.uid
|
||
|
|
GROUP BY a.studentId
|
||
|
|
ORDER BY maxScore desc nulls last,avgScore desc nulls last ,a.studentId
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<!-- WITH temp1 as ( select studentId
|
||
|
|
from StudentOwnClass
|
||
|
|
where classesId = #{classesId} and status = 1 ) ,
|
||
|
|
temp2 as ( select uid ,score , objectId , created
|
||
|
|
from temp1 m
|
||
|
|
inner join Achivement n
|
||
|
|
ON m.studentId = n.uid
|
||
|
|
AND n.achiveType in ('L','W') AND n.pointCaseType in (3, 5, 6 , 7 ,8 )
|
||
|
|
AND n.objectId in
|
||
|
|
<iterate conjunction="," open="(" close=")" property="lessonIds">
|
||
|
|
#{item}
|
||
|
|
</iterate> )
|
||
|
|
SELECT a.studentId , round( avg(b.score) ) as avgScore ,
|
||
|
|
count( distinct b.objectId ) as howmuch ,
|
||
|
|
count(b.objectId) as total ,
|
||
|
|
max(b.score) as maxScore,
|
||
|
|
max( b.created ) as lastTime
|
||
|
|
FROM temp1 as a
|
||
|
|
LEFT JOIN temp2 as b
|
||
|
|
ON a.studentId = b.uid
|
||
|
|
<dynamic>
|
||
|
|
<isNotEmpty prepend=" AND " property="startTime">
|
||
|
|
<![CDATA[
|
||
|
|
b.created >= #{startTime}
|
||
|
|
]]>
|
||
|
|
</isNotEmpty>
|
||
|
|
<isNotEmpty prepend=" AND " property="endTime">
|
||
|
|
<![CDATA[
|
||
|
|
b.created < #{endTime}
|
||
|
|
]]>
|
||
|
|
</isNotEmpty>
|
||
|
|
</dynamic>
|
||
|
|
GROUP BY a.studentId
|
||
|
|
ORDER BY maxScore desc nulls last,avgScore desc nulls last
|
||
|
|
<dynamic>
|
||
|
|
<isNotEmpty prepend=" LIMIT " property="pageSize">
|
||
|
|
#{pageSize}
|
||
|
|
</isNotEmpty>
|
||
|
|
|
||
|
|
<isNotEmpty prepend=" OFFSET " property="offset">
|
||
|
|
#{offset}
|
||
|
|
</isNotEmpty>
|
||
|
|
</dynamic> -->
|
||
|
|
|
||
|
|
<!--
|
||
|
|
SELECT a.studentId , round( avg(b.score) ) as avgScore ,
|
||
|
|
count( distinct b.objectId ) as howmuch ,
|
||
|
|
count(b.objectId) as total ,
|
||
|
|
max(b.score) as maxScore,
|
||
|
|
max( b.created ) as lastTime
|
||
|
|
FROM StudentOwnClass a
|
||
|
|
LEFT JOIN Achivement b
|
||
|
|
ON a.studentId = b.uid
|
||
|
|
<dynamic>
|
||
|
|
<isNotEmpty prepend=" AND " property="startTime">
|
||
|
|
<![CDATA[
|
||
|
|
b.created >= #{startTime}
|
||
|
|
]]>
|
||
|
|
</isNotEmpty>
|
||
|
|
<isNotEmpty prepend=" AND " property="endTime">
|
||
|
|
<![CDATA[
|
||
|
|
b.created < #{endTime}
|
||
|
|
]]>
|
||
|
|
</isNotEmpty>
|
||
|
|
</dynamic>
|
||
|
|
AND b.achiveType in ('L','W')
|
||
|
|
AND pointCaseType in (3, 5, 6 , 7 ,8 )
|
||
|
|
AND b.objectId in
|
||
|
|
<iterate conjunction="," open="(" close=")" property="lessonIds">
|
||
|
|
#{item}
|
||
|
|
</iterate>
|
||
|
|
WHERE a.classesId = #{classesId} and a.status = 1
|
||
|
|
GROUP BY a.studentId order by maxScore desc nulls last,avgScore desc nulls last
|
||
|
|
<dynamic>
|
||
|
|
<isNotEmpty prepend=" LIMIT " property="pageSize">
|
||
|
|
#{pageSize}
|
||
|
|
</isNotEmpty>
|
||
|
|
|
||
|
|
<isNotEmpty prepend=" OFFSET " property="offset">
|
||
|
|
#{offset}
|
||
|
|
</isNotEmpty>
|
||
|
|
</dynamic>
|
||
|
|
-->
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getLessonIdByMultiUnitId" parameterType="java.util.List" resultType="java.lang.Integer">
|
||
|
|
SELECT a.lessonId
|
||
|
|
FROM Lesson a
|
||
|
|
WHERE a.parentId in
|
||
|
|
<foreach collection="list" index="index" item="item" separator="," close=")" open="(">
|
||
|
|
|
||
|
|
#{item}
|
||
|
|
|
||
|
|
</foreach>
|
||
|
|
and a.status=1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getLessonIdByMultiBookId" parameterType="java.util.List" resultType="java.lang.Integer">
|
||
|
|
SELECT a.lessonId
|
||
|
|
FROM Lesson a
|
||
|
|
INNER JOIN Lesson b
|
||
|
|
on a.parentId = b.lessonId and b.status=1 and a.status=1
|
||
|
|
WHERE b.parentId in
|
||
|
|
<foreach collection="list" index="index" item="item" separator="," close=")" open="(">
|
||
|
|
|
||
|
|
#{item}
|
||
|
|
|
||
|
|
</foreach>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="singleTotalStatConnectLog" parameterType="java.util.Map" resultType="java.util.HashMap">
|
||
|
|
|
||
|
|
SELECT
|
||
|
|
sum( c.timeLength ) as studyDuration
|
||
|
|
FROM ConnectLog c
|
||
|
|
WHERE c.uid = #{uid}
|
||
|
|
and areaId=#{areaId}
|
||
|
|
AND c.startTime > #{startTime}
|
||
|
|
AND c.startTime < #{endTime}
|
||
|
|
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="singleTotalStatAchive" parameterType="java.util.Map" resultType="java.util.HashMap">
|
||
|
|
SELECT case when avg( d.score ) is null then 0 else avg( d.score ) end as avgScore , count(d.achivementid) as studyNum
|
||
|
|
FROM achivement d
|
||
|
|
WHERE d.uid = #{uid}
|
||
|
|
and d.areaid=#{areaId}
|
||
|
|
AND d.created > #{startTime}
|
||
|
|
AND d.created < #{endTime}
|
||
|
|
|
||
|
|
AND d.achiveType in ('L','W')
|
||
|
|
AND d.pointCaseType in (3, 4,5, 6 , 7 ,8 )
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getTimeAxisByUid" parameterType="java.util.Map" resultType="java.util.HashMap">
|
||
|
|
select distinct(s.uid) as uid , sum(s.race) as raceCount , sum(s.achivement) as achivementCount , sum(s.exam) as examCount , sum(s.hearCount) as hearCount ,sum(s.hearexamcount) as hearexamcount,sum(s.synchroCount) synchroCount ,s.month as month , s.year as year from (
|
||
|
|
|
||
|
|
select uid, count(racescoreid) as race , 0 as achivement , 0 as exam , 0 as hearCount ,0 as hearexamcount,0 as synchroCount, extract(month from created) as month , extract(year from created) as year from racescore
|
||
|
|
where created > #{startTime} and created < #{endTime} and uid=#{uid} and areaid=#{areaId}
|
||
|
|
group by uid ,extract(month from created) , extract(year from created)
|
||
|
|
union all
|
||
|
|
select distinct(uid) , 0 as race, count(achivementid) as achivement , 0 as exam , 0 as hearCount ,0 as hearexamcount,0 as synchroCount, extract(month from created) as month , extract(year from created) as year from achivement
|
||
|
|
where created > #{startTime} and created < #{endTime} and achivetype in ( 'L' , 'W' )
|
||
|
|
and pointCaseType in ( 3 , 4,5 , 6 , 7 , 8 ) and uid=#{uid} and areaid=#{areaId}
|
||
|
|
group by uid ,extract(month from created) , extract(year from created)
|
||
|
|
|
||
|
|
union all
|
||
|
|
select distinct(ea.userid) as uid ,0 as race , 0 as achivement , count(ea.examanswerid) as exam ,0 as hearCount ,0 as hearexamcount,0 as synchroCount, extract(month from ea.created) as month , extract(year from ea.created) as year
|
||
|
|
from examanswer ea
|
||
|
|
inner join exam e on ea.examid=e.examid and e.isOral = 1 and ea.userid = #{uid} and
|
||
|
|
ea.created > #{startTime} and ea.created < #{endTime} and ea.areaid=#{areaId}
|
||
|
|
group by userid ,extract(month from ea.created) , extract(year from ea.created)
|
||
|
|
union all
|
||
|
|
select distinct(ea.userid) as uid ,0 as race , 0 as achivement , 0 as exam ,0 as hearCount ,count(ea.examanswerid) as hearexamcount,0 as synchroCount, extract(month from ea.created) as month , extract(year from ea.created) as year
|
||
|
|
from examanswer ea
|
||
|
|
inner join exam e on ea.examid=e.examid and e.isOral = 0 and ea.userid = #{uid} and
|
||
|
|
ea.created > #{startTime} and ea.created < #{endTime} and ea.areaid=#{areaId}
|
||
|
|
group by userid ,extract(month from ea.created) , extract(year from ea.created)
|
||
|
|
union all
|
||
|
|
select distinct(ea.userid) as uid ,0 as race , 0 as achivement , 0 as exam ,0 as hearCount ,0 as hearexamcount,count(ea.examanswerid) as synchroCount, extract(month from ea.created) as month , extract(year from ea.created) as year
|
||
|
|
from examanswer ea
|
||
|
|
inner join exam e on ea.examid=e.examid and e.isOral = 3 and ea.userid = #{uid} and
|
||
|
|
ea.created > #{startTime} and ea.created < #{endTime} and ea.areaid=#{areaId}
|
||
|
|
group by userid ,extract(month from ea.created) , extract(year from ea.created)
|
||
|
|
|
||
|
|
union all
|
||
|
|
select distinct(ea.userid) as uid ,0 as race , 0 as achivement , 0 as exam ,count(ea.examanswerid) as hearCount ,0 as hearexamcount,0 as synchroCount, extract(month from ea.created) as month , extract(year from ea.created) as year
|
||
|
|
from examanswer ea
|
||
|
|
inner join exam e on ea.examid=e.examid and e.isOral = 2 and ea.userid = #{uid} and
|
||
|
|
ea.created > #{startTime} and ea.created < #{endTime} and ea.areaid=#{areaId}
|
||
|
|
group by userid ,extract(month from ea.created) , extract(year from ea.created)
|
||
|
|
union all
|
||
|
|
select distinct(userid) as uid ,0 as race , 0 as achivement , 0 as exam ,count(examanswerid) as hearCount ,0 as hearexamcount,0 as synchroCount, extract(month from created) as month , extract(year from created) as year from hearanswer
|
||
|
|
where created > #{startTime} and created < #{endTime} and userid = #{uid} and areaid=#{areaId}
|
||
|
|
group by userid ,extract(month from created) , extract(year from created) ) s
|
||
|
|
where uid =#{uid}
|
||
|
|
group by uid,month , year
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!-- 根据地区统计基教的数据 -->
|
||
|
|
<select id="baseStatByArea" parameterType="java.util.Map" resultType="java.util.HashMap">
|
||
|
|
|
||
|
|
select m.areaName , a.schoolCount, b.classCount , c.teacherCount , d.studentCount
|
||
|
|
from
|
||
|
|
( select tempAreaId , count(schoolId ) as schoolCount
|
||
|
|
from ( select floor( areaId / #{factor} ) * #{factor} as tempAreaId, schoolId
|
||
|
|
from School
|
||
|
|
where status = 1
|
||
|
|
and areaId >= #{startId} and areaId < #{endId} ) as a1
|
||
|
|
group by tempAreaId ) as a
|
||
|
|
inner join Area as m
|
||
|
|
on a.tempAreaId = m.areaId
|
||
|
|
left join
|
||
|
|
( select tempAreaId , count(classesId ) as classCount
|
||
|
|
from ( select floor( areaId / #{factor} ) * #{factor} as tempAreaId, classesId
|
||
|
|
from Classes
|
||
|
|
where status = 1 and classtype = 1
|
||
|
|
and areaId >= #{startId} and areaId < #{endId} ) as b1
|
||
|
|
group by tempAreaId ) as b
|
||
|
|
on a.tempAreaId = b.tempAreaId
|
||
|
|
left join
|
||
|
|
( select tempAreaId , count(teacherId ) as teacherCount
|
||
|
|
from ( select floor( areaId / #{factor} ) * #{factor} as tempAreaId, teacherId
|
||
|
|
from Teacher
|
||
|
|
where status = 1
|
||
|
|
and areaId >= #{startId} and areaId < #{endId} ) as c1
|
||
|
|
group by tempAreaId ) as c
|
||
|
|
on a.tempAreaId = c.tempAreaId
|
||
|
|
left join
|
||
|
|
( select tempAreaId , count(studentId ) as studentCount
|
||
|
|
from ( select floor( areaId / #{factor} ) * #{factor} as tempAreaId, studentId
|
||
|
|
from Student
|
||
|
|
where status = 1
|
||
|
|
and areaId >= #{startId} and areaId < #{endId} ) as d1
|
||
|
|
group by tempAreaId ) as d
|
||
|
|
on a.tempAreaId = d.tempAreaId
|
||
|
|
order by m.areaId ;
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!-- 根据班级、作业统计完成该作业的音频 -->
|
||
|
|
<select id="classVoices" parameterType="java.util.Map" resultType="SuperVoice">
|
||
|
|
|
||
|
|
|
||
|
|
<!-- SELECT n.uid , '' as truename , 0 as schoolId , '' as schoolName , n.uuid as voice ,
|
||
|
|
0 as isFollowed , n.score , 0 as bookId , '' as bookName ,
|
||
|
|
0 as unitId , '' as unitName , n.objectId as lessonId , '' as lessonName ,
|
||
|
|
n.created
|
||
|
|
FROM
|
||
|
|
( SELECT b.achivementid ,
|
||
|
|
row_number() OVER (PARTITION BY b.uid order by b.score desc , b.created asc ) as rn
|
||
|
|
FROM ( SELECT studentId from StudentOwnClass
|
||
|
|
where classesId = #{classesId} and status = 1 ) a
|
||
|
|
INNER JOIN Achivement b
|
||
|
|
ON a.studentId = b.uid
|
||
|
|
AND b.created >= #{startTime} AND b.created < #{endTime}
|
||
|
|
AND b.achiveType in ('L') AND pointCaseType in ( 5, 6 , 7 ,8 )
|
||
|
|
AND b.objectId in ( select distinct lessonid from AssignDetail where assignmentId = #{assignmentId} )
|
||
|
|
AND length( trim( b.uuid )) > 0 ) as m
|
||
|
|
INNER JOIN Achivement as n
|
||
|
|
on m.achivementId = n.achivementId and m.rn = 1 -->
|
||
|
|
|
||
|
|
<!-- with temp1 as (
|
||
|
|
SELECT studentId from StudentOwnClass where classesId = #{classesId} and status = 1 ) ,
|
||
|
|
temp2 as (
|
||
|
|
select distinct lessonid from AssignDetail where assignmentId = #{assignmentId} ) ,
|
||
|
|
temp3 as (
|
||
|
|
SELECT b.achivementid ,
|
||
|
|
b.uid , b.uuid , b.score , b.objectId , b.created
|
||
|
|
FROM temp1 a
|
||
|
|
INNER JOIN Achivement b
|
||
|
|
ON a.studentId = b.uid
|
||
|
|
AND b.achiveType in ('L') AND pointCaseType in ( 5, 6 , 7 ,8 )
|
||
|
|
AND b.objectId in (
|
||
|
|
select distinct lessonid from AssignDetail where assignmentId = #{assignmentId} )
|
||
|
|
AND length( trim( b.uuid )) > 0 ) ,
|
||
|
|
temp4 as (
|
||
|
|
SELECT C.achivementid , row_number() OVER (PARTITION BY C.uid order by C.score desc , C.created asc ) as rn ,
|
||
|
|
C.uid , C.uuid , C.score , C.objectId , C.created
|
||
|
|
FROM temp3 c
|
||
|
|
WHERE C.created >= #{startTime} AND C.created < #{endTime} )
|
||
|
|
SELECT n.uid , '' as truename , 0 as schoolId , '' as schoolName , n.uuid as voice ,
|
||
|
|
0 as isFollowed , n.score , 0 as bookId , '' as bookName , 0 as unitId , '' as unitName ,
|
||
|
|
n.objectId as lessonId , '' as lessonName , n.created
|
||
|
|
FROM temp4 as n
|
||
|
|
WHERE n.rn = 1 -->
|
||
|
|
|
||
|
|
with temp1 as ( SELECT studentId from StudentOwnClass where classesId = #{classesId} and areaId=#{areaId} and status = 1 ) ,
|
||
|
|
temp2 as ( select distinct lessonid from AssignDetail where assignmentId = #{assignmentId} ) ,
|
||
|
|
temp3 as ( SELECT b.achivementid , b.uid , b.uuid , b.score , b.objectId , b.created ,
|
||
|
|
b.achiveType , b.pointCaseType
|
||
|
|
FROM temp1 a
|
||
|
|
INNER JOIN Achivement b
|
||
|
|
ON a.studentId = b.uid and b.areaId=#{areaId}
|
||
|
|
and b.created >= #{startTime} AND b.created < #{endTime}
|
||
|
|
) ,
|
||
|
|
temp4 as ( SELECT C.achivementid , row_number() OVER (PARTITION BY C.uid order by C.score desc , C.created asc ) as rn ,
|
||
|
|
C.uid , C.uuid , C.score , C.objectId , C.created
|
||
|
|
FROM temp3 c
|
||
|
|
WHERE C.created >= #{startTime} AND C.created < #{endTime}
|
||
|
|
AND c.achiveType in ('L') AND c.pointCaseType in (4, 5, 6 , 7 ,8 )
|
||
|
|
AND c.objectId in ( select lessonid from temp2 )
|
||
|
|
AND length( trim( c.uuid )) > 0)
|
||
|
|
SELECT n.uid , '' as truename , 0 as schoolId , '' as schoolName , n.uuid as voice ,
|
||
|
|
0 as isFollowed , n.score , 0 as bookId , '' as bookName , 0 as unitId , '' as unitName ,
|
||
|
|
n.objectId as lessonId , '' as lessonName , n.created
|
||
|
|
FROM temp4 as n
|
||
|
|
WHERE n.rn = 1
|
||
|
|
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="studyStatForExcel" parameterType="java.util.HashMap" resultType="java.util.HashMap">
|
||
|
|
|
||
|
|
SELECT a.uid , s.truename ,
|
||
|
|
a.unitId , u.lessonname as unitname , u.orderId as uOrder ,
|
||
|
|
a.lessonId , l.lessonname , l.orderId as lOrder ,
|
||
|
|
a.howmuch , a.maxscore , a.avgscore ,
|
||
|
|
b.lessonId as bookid , b.lessonname as bookname
|
||
|
|
FROM
|
||
|
|
(select m.uid , m.unitId , m.lessonId , count(*) as howmuch ,
|
||
|
|
max( m.score ) as maxscore , avg( m.score ) as avgscore
|
||
|
|
from
|
||
|
|
( select a1.uid , a1.objectId as unitId , 0 as lessonId , a1.score
|
||
|
|
from StudentOwnClass sc1
|
||
|
|
inner join Achivement a1
|
||
|
|
on sc1.classesId = #{classesId} and sc1.studentId = a1.uid and sc1.areaId=#{areaId}
|
||
|
|
and a1.achiveType = 'W'
|
||
|
|
and a1.pointCaseType = 3
|
||
|
|
and a1.created > #{startTime}
|
||
|
|
and a1.created < #{endTime} and a1.areaId=#{areaId}
|
||
|
|
union
|
||
|
|
select a2.uid , l2.parentId as unitId , a2.objectId as lessonId , a2.score
|
||
|
|
from StudentOwnClass sc2
|
||
|
|
inner join Achivement a2
|
||
|
|
on sc2.classesId = #{classesId} and sc2.studentId = a2.uid and sc2.areaId=#{areaId}
|
||
|
|
and a2.achiveType = 'L'
|
||
|
|
and a2.pointCaseType in ( 4,5 , 6 , 7 , 8 )
|
||
|
|
and a2.created > #{startTime}
|
||
|
|
and a2.created < #{endTime} and a2.areaId=#{areaId}
|
||
|
|
inner join Lesson l2
|
||
|
|
on a2.objectId = l2.lessonId ) as m
|
||
|
|
group by m.uid , m.unitId , m.lessonId ) as a
|
||
|
|
INNER JOIN Student as s
|
||
|
|
on a.uid = s.studentId and s.areaId=#{areaId}
|
||
|
|
INNER JOIN Lesson as u
|
||
|
|
on a.unitId = u.lessonId
|
||
|
|
INNER JOIN Lesson as b
|
||
|
|
on u.parentId = b.lessonId
|
||
|
|
LEFT JOIN Lesson as l
|
||
|
|
on a.lessonId = l.lessonId
|
||
|
|
where s.status = 1
|
||
|
|
ORDER BY a.uid , u.orderId , l.orderId
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="studyCheckForFinishAssignStat" parameterType="java.util.Map" resultType="FinishAssignStatDTO">
|
||
|
|
select c.uid,c.assignmentId,c.content,c.lessonCount,c.completeCount,c.created,c.howmuch,c.maxScore,c.avgScore,c.areaId,c.uuid,c.isSign,c.avgAccuracy,c.avgFluent,
|
||
|
|
c.avgIntegrity,c.jcontent from
|
||
|
|
FinishAssignStat as c inner join assignment as b on b.assignmentid =c.assignmentid and b.areaId = #{areaId}
|
||
|
|
where c.assignmentId=#{assignmentId} and c.uid=#{uid} and c.areaId =#{areaId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="studyCheckByClassOfWord" parameterType="java.util.Map" resultType="AchiStatOfUid">
|
||
|
|
|
||
|
|
with wdscount as(select count(distinct(wordsid)) as wordsCount from words where lessonid in
|
||
|
|
<foreach collection="lessonIds" item="item" separator="," close=")" open="(">
|
||
|
|
#{item}
|
||
|
|
</foreach>
|
||
|
|
),
|
||
|
|
stu as(select studentId,wordsCount from studentownclass,wdsCount where classesid=#{classesId} and areaId=#{areaId} and status=1 ),
|
||
|
|
|
||
|
|
wds as(select wordsid,lessonid from words where lessonid in
|
||
|
|
<foreach collection="lessonIds" item="item" separator="," close=")" open="(">
|
||
|
|
#{item}
|
||
|
|
</foreach> ),
|
||
|
|
|
||
|
|
temp as (
|
||
|
|
select s.studentid ,round(avg(s.avgScore)) as avgScore ,sum(s.finishCount) finishCount,
|
||
|
|
sum(s.howmuch) howmuch,sum(s.total) total,max(s.maxScore) maxScore,max(s.lastTime) lastTime
|
||
|
|
from
|
||
|
|
(select stu.studentid,round(avg(w.score)) as avgScore,count(distinct(w.wordsid)) as finishCount ,
|
||
|
|
case when count(distinct(w.wordsid))>0 then 1 else 0 end as howmuch ,
|
||
|
|
count(w.wordsid) as total,max(w.score) as maxScore,max(w.created) as lastTime
|
||
|
|
from stu inner join wordachive w on stu.studentid=w.uid and w.areaId=#{areaId}
|
||
|
|
<if test="startTime!=null">
|
||
|
|
<![CDATA[
|
||
|
|
and w.created >= #{startTime}
|
||
|
|
]]>
|
||
|
|
</if>
|
||
|
|
<if test="endTime!=null">
|
||
|
|
<![CDATA[
|
||
|
|
and w.created < #{endTime}
|
||
|
|
]]>
|
||
|
|
</if>
|
||
|
|
inner join wds on wds.wordsid=w.wordsid
|
||
|
|
group by stu.studentid,wds.lessonid
|
||
|
|
|
||
|
|
) as s
|
||
|
|
group by s.studentId
|
||
|
|
)
|
||
|
|
select stu.studentId,t.avgScore,howmuch,total,maxScore,lastTime,
|
||
|
|
(case when finishCount is null then 0 else finishCount end )||'/'||wordsCount as finishWords
|
||
|
|
from stu left join temp t on t.studentid=stu.studentId
|
||
|
|
order by maxScore desc nulls last,avgScore desc nulls last,stu.studentid
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
|
||
|
|
</select>
|
||
|
|
<select id="getWordCountOfAssignment" parameterType="java.lang.Integer" resultType="java.lang.Integer">
|
||
|
|
select count( distinct b.wordsid ) as wordscount
|
||
|
|
from AssignDetail a
|
||
|
|
inner join Words b
|
||
|
|
on a.assignmentid = #{assignmentId} and a.unitid = b.lessonid and b.status =1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="studyCheckByClassOfWordTwo" parameterType="java.util.Map" resultType="AchiStatOfUid">
|
||
|
|
with temp as ( select s.studentId from studentownClass s
|
||
|
|
inner join student st on s.studentid=st.studentid
|
||
|
|
where classesid = #{classesId} and st.areaId=#{areaId} and s.areaId=#{areaId} and s.status = 1 and st.status=1 )
|
||
|
|
select stu.studentId,t.avgScore,t.completecount as howmuch,
|
||
|
|
t.howmuch as total,t.maxScore,created as lastTime,
|
||
|
|
(case when completecount is null then 0 else completecount end )||'/'||cast( ${wordsCount} as char(20)) as finishWords,
|
||
|
|
t.isSign
|
||
|
|
from temp stu
|
||
|
|
left join finishAssignStat t
|
||
|
|
on stu.studentId = t.uid and assignmentid = #{assignmentId} and t.areaId=#{areaId}
|
||
|
|
order by maxScore desc nulls last,avgScore desc nulls last,stu.studentid
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<select id="studyCheckByClassTwo" parameterType="java.util.Map" resultMap="BaseResultMap">
|
||
|
|
|
||
|
|
WITH temp1 as ( select s.studentId
|
||
|
|
from StudentOwnClass s
|
||
|
|
inner join student st on s.studentid=st.studentid
|
||
|
|
where classesId = #{classesId} and st.areaId=#{areaId} and s.areaId=#{areaId} and s.status = 1 ),
|
||
|
|
<if test="pointCaseType==4">
|
||
|
|
temp2 as (select c.*, first_value (b.achivementid) over ( PARTITION BY c.uid order by b.score desc ) AS achivementid from assignment as d inner join assigndetail as a on a.assignmentid = d.assignmentid inner join achivement as b on a.lessonid = b.objectId and a.areaId = #{areaId} and b.areaId = #{areaId} inner join FinishAssignStat as c on c.uid = b.uid and c.areaId =#{areaId} and c.assignmentid = a.assignmentid where a.assignmentid = #{assignmentId} and b.created > d.starttime and b.created < d.endtime
|
||
|
|
<if test="pointCaseType!=null">
|
||
|
|
and b.pointcasetype = #{pointCaseType}
|
||
|
|
</if>
|
||
|
|
),
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="pointCaseType!=4">
|
||
|
|
temp2 as (
|
||
|
|
select c.* from FinishAssignStat as c where c.assignmentid = #{assignmentId} and c.areaId=#{areaId}
|
||
|
|
<if test="pointCaseType!=null">
|
||
|
|
and b.pointcasetype = #{pointCaseType}
|
||
|
|
</if>
|
||
|
|
),
|
||
|
|
</if>
|
||
|
|
|
||
|
|
temp3 as (SELECT distinct a.studentId , b.avgScore , b.completecount as howmuch,
|
||
|
|
b.howmuch as total, b.maxScore, b.created as lastTime ,b.uuid as voice,b.isSign
|
||
|
|
<if test="pointCaseType==4">
|
||
|
|
,b.achivementid as achivementId
|
||
|
|
</if>
|
||
|
|
FROM temp1 as a
|
||
|
|
left JOIN temp2 as b ON a.studentId = b.uid ORDER BY b.maxScore desc nulls last,b.avgScore desc nulls last,a.studentId)
|
||
|
|
<if test="pointCaseType==4">
|
||
|
|
select
|
||
|
|
b.studentId , b.avgScore , b.howmuch,
|
||
|
|
b.total, b.maxScore, b.lastTime ,b.voice,b.isSign,b.achivementId,c.jcontent as jcontent
|
||
|
|
|
||
|
|
from temp3 as b left join achivement as c on b.achivementid = c.achivementid and c.areaId = #{areaId}
|
||
|
|
</if>
|
||
|
|
<if test="pointCaseType!=4">
|
||
|
|
select
|
||
|
|
b.studentId , b.avgScore , b.howmuch,
|
||
|
|
b.total, b.maxScore, b.lastTime ,b.voice,b.isSign
|
||
|
|
from temp3 as b
|
||
|
|
</if>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="studyCheckByClassTwoForWechat" parameterType="java.util.Map" resultMap="BaseResultMapForWechat" >
|
||
|
|
WITH temp1 as ( select s.studentId
|
||
|
|
from StudentOwnClass s
|
||
|
|
inner join student st on s.studentid=st.studentid
|
||
|
|
where classesId = #{classesId} and st.areaId=#{areaId} and s.areaId=#{areaId} and s.status = 1 ),
|
||
|
|
|
||
|
|
temp2 as (select c.* ,b.pointcasetypes from FinishAssignStat as c inner join assignment as b on b.assignmentid =c.assignmentid and b.areaId = #{areaId} where c.assignmentid = #{assignmentId} and c.areaId=#{areaId} )
|
||
|
|
|
||
|
|
SELECT a.studentId , b.avgScore , b.completecount as howmuch,
|
||
|
|
b.howmuch as total, b.maxScore, b.created as lastTime ,b.uuid as voice,b.isSign
|
||
|
|
,b.assignmentid as assignmentId,b.jcontent as jcontent
|
||
|
|
FROM temp1 as a
|
||
|
|
left JOIN temp2 as b ON a.studentId = b.uid ORDER BY b.maxScore desc nulls last,b.avgScore desc nulls last,a.studentId
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getTotalAssignById" parameterType="java.util.Map" resultType="java.lang.Integer">
|
||
|
|
select count(case when lessoncount is not null and lessoncount=completecount then 1 else null end) as totalAssign from
|
||
|
|
finishassignstat where uid =#{uid} and areaId=#{areaId}
|
||
|
|
<if test="startTime!=null">
|
||
|
|
and created >#{startTime} and created <= #{endTime}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
group by uid
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
</mapper>
|