398 lines
16 KiB
XML
Raw Permalink Normal View History

2026-03-10 16:40:19 +08:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.univ3e.dao.UnivAchivementDao">
<select id= "getNextSeq" resultType="int">
SELECT NEXTVAL('seq_univachivementid')
</select>
<insert id= "doSave" parameterType="com.univ3e.entity.UnivAchivement">
INSERT INTO univachivement(achivementid,uid,achivetype,pointcasetype,objectid,score,accuracy,fluent,integrity,content,created,uuid,areaid)
VALUES (
<if test="achivementid == 0">
(SELECT NEXTVAL('seq_univachivementid')),
</if>
<if test="achivementid != 0">
#{achivementid},
</if>
#{uid},#{achivetype},#{pointcasetype},#{objectid},#{score},#{accuracy},#{fluent},#{integrity},#{content},#{created},#{uuid},#{areaid})
</insert>
<update id="doUpdateVoiceKey" parameterType="map" >
UPDATE univachivement SET uuid = #{uuid} WHERE achivementid = #{achivementid}
</update>
<select id= "findClassGoodVoice" parameterType="map" resultType="com._3e.http.myspace.dto._3EResClassGoodVoice" >
select a.uid , 0 as schoolId , '' as schoolName , a.uuid, a.created ,
0 as isFollowed , a.score ,
d.lessonId as bookId , d.lessonName as bookName ,
c.lessonId as unitId, c.lessonName as unitName,
b.lessonId as lessonid , b.lessonName as lessonname
from ( select p.uid , p.score , p.uuid , p.objectId , p.created
from UnivStudentOwnClass q
inner join UnivAchivement p
on q.classesId = #{classesId} and q.studentId = p.uid
and length( p.uuid ) &gt; 0 and p.achiveType = 'L'
and p.pointCaseType = 5 and p.uid = q.studentId
where q.status =1
<if test="begintime!=null">
and p.created &gt; #{begintime}
</if>
<if test="begintime==null">
and p.created &gt; (now() + interval '-1 month')
</if>
<if test="endtime!=null">
and p.created &lt;#{endtime}
</if>
<if test="endtime==null">
and p.created &lt; ( current_date +interval '-0 day')
</if>
) a
inner join Lesson b
on a.objectId = b.lessonId
inner join Lesson c
on b.parentId = c.lessonId
inner join Lesson d
on c.parentId = d.lessonId
order by a.score desc , a.created desc
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findMyAchGoodVoice" parameterType="long" resultType="com.univ3e.entity.UnivAchivement">
select *
from univachivement
where exists (
select *
from (
select b.*
from univstudentownclass b
where exists (
select c.*
from univstudentownclass c
where b.classesid = c.classesid and c.studentid = #{uid}
)
)d
where uid = d.studentid
)
and uuid <![CDATA[<>]]> '' and achivetype <![CDATA[<>]]> 'S'
</select>
<select id="findMyAchiveGoodVoice" parameterType="map" resultType="com.univ3e.entity.UnivAchivement" >
SELECT *
FROM UnivAchivement
WHERE uid = #{uid} and uuid <![CDATA[<>]]> '' and achivetype <![CDATA[<>]]> 'S'
and to_char(created, 'yyyy-MM-dd') &gt;= (#{begintime})
and to_char(created, 'yyyy-MM-dd') &lt;= (#{endtime})
ORDER BY score DESC
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findClassGradeCurve" parameterType="map" resultType="com._3e.dto.ClassGradeCurve" >
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 UnivStudentOwnClass a
INNER JOIN UnivAchivement b
ON a.classesId = #{classesId} and a.status = 1
AND a.studentId = b.uid
<if test="begintime != null">
and b.created &gt; #{begintime}
</if>
<if test="endtime != null">
and b.created &lt;= #{endtime}
</if>
AND b.achiveType in ('L','W')
AND b.pointCaseType in (3, 5, 6 , 7 , 8 )
GROUP BY extract( year from b.created ) ,
extract( month from b.created )
ORDER BY myYear , myMonth
</select>
<select id="findVUserGradeCurve" parameterType="map" resultType="com._3e.dto.VUserGradeCurve" >
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 UnivAchivement a
WHERE a.uid = #{uid} AND a.achiveType in ('L','W')
AND pointCaseType in (3, 5, 6 , 7 , 8 )
<if test="begintime != null">
and a.created &gt; #{begintime}
</if>
<if test="endtime != null">
and a.created &lt;= #{endtime}
</if>
GROUP BY extract( year from a.created ) ,
extract( month from a.created )
ORDER BY myYear , myMonth
</select>
<select id="findMyAllAchiveGrades" parameterType="map" resultType="com.univ3e.entity.UnivAchivement" >
SELECT a.*
FROM UnivAchivement a
WHERE uid = #{uid} AND achiveType in ('L','W')
and created &gt; '${begintime} 00:00:00'
and created &lt;= '${endtime} 23:59:59'
AND pointCaseType in (3, 5, 6 , 7 , 8 )
<if test="pointCaseType != null and pointCaseType != 0 ">
and pointCaseType = #{pointCaseType}
</if>
ORDER BY created desc
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findMyMaxAchiveGrades" parameterType="map" resultType="com.univ3e.entity.UnivAchivement" >
SELECT a.objectId ,a.pointCaseType , max( a.score ) as score , max( a.created ) as created,a.achivetype
FROM UnivAchivement a
WHERE a.uid = #{uid} AND a.achiveType in ('L','W')
and created &gt; '${begintime} 00:00:00'
and created &lt;= '${endtime} 23:59:59'
AND pointCaseType in (3, 5, 6 , 7 , 8 )
<if test="pointCaseType != null and pointCaseType != 0 ">
and pointCaseType = #{pointCaseType}
</if>
GROUP BY a.objectId , a.pointCaseType,a.achivetype
ORDER BY created desc
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="findAchivementByHsyb" parameterType="com.mobile.common.page.Page" resultType="com._3e.http.myhome.dto._3EResRankingList" >
SELECT a.uid , c.truename , b.schoolId , b.schoolName , a.uuid , a.created ,
0 AS isFollowed ,a.score AS value, 0 AS bookId , '' AS bookName , 0 AS unitId ,
'' AS unitName , 0 AS lessonId , '' AS lessonName
FROM ( SELECT p.uid , p.score , p.tempId , p.uuid , p.created , q.schoolId
FROM ( SELECT uid , score , uuid , created ,
max( achivementId ) OVER (PARTITION BY uid ORDER BY score DESC ) AS tempId ,
row_number() OVER (PARTITION BY uid ORDER BY score DESC ) AS rn
FROM univAchivement
WHERE pointcasetype = 5 AND length( uuid ) &gt; 0
AND achiveType = 'L'
AND created &lt; ( current_date +interval '-0 day')
) p
INNER JOIN univStudent q
ON p.uid = q.studentId AND p.rn =1
ORDER BY p.score DESC , p.tempId DESC
limit #{limit} offset #{offset} ) a
INNER JOIN university b
ON a.schoolId = b.schoolId
INNER JOIN univStudent c
ON a.uid = c.studentId
ORDER BY a.score DESC , a.created DESC
</select>
<select id="findUserByQxb" parameterType="com.mobile.common.page.Page" resultType="com._3e.http.myhome.dto._3EResRankingList" >
SELECT a.uid , a.truename , d.schoolId , d.schoolName , a.avgScore AS value ,
a.userLevel , a.levelName , 0 AS isFollowed
FROM ( SELECT l.uid , Round( l.totalScore / l.howmuch ) AS avgScore , l.howmuch ,
l.userLevel , l.levelName , m.truename ,l.totalScore , m.lastsignIn , m.schoolId
FROM UnivUserHonor l
INNER JOIN univStudent m ON l.uid = m.studentId
WHERE howmuch &gt; 1
ORDER BY Round( l.totalScore / l.howmuch ) DESC , l.totalScore DESC , m.lastsignIn DESC
limit #{limit} offset #{offset}) a
INNER JOIN university d ON a.schoolId = d.schoolId
ORDER BY a.avgScore DESC , a.totalScore DESC , a.lastsignIn DESC
</select>
<select id="findMyAchiveGradesByLessionids" parameterType="map" resultType="com.univ3e.entity.UnivAchivement" >
SELECT *
FROM UnivAchivement
WHERE uid = #{uid}
<if test="lessionidList != null">
AND objectid in
<foreach item="item" index="index" collection="lessionidList"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
ORDER BY created DESC
</select>
<select id="findClassTeacherGoodVoice" parameterType="map" resultType="com.univ3e.entity.UnivAchivement" >
SELECT *
FROM univachivement
WHERE EXISTS (
SELECT *
FROM (
SELECT b.*
FROM univteacher b
WHERE EXISTS (
SELECT C.*
FROM univclasses C
WHERE C.teacherid = b.teacherid AND C.teacherid = #{uid}
)
) d
WHERE uid = d.teacherid
)
and uuid <![CDATA[<>]]> ''
<if test="begintime != null">
and to_char(created, 'yyyy-MM-dd') &gt;= #{begintime}
</if>
<if test="endtime != null">
and to_char(created, 'yyyy-MM-dd') &lt; #{endtime}
</if>
</select>
<select id="findAlreadyLearnLessionNumByUnitId" parameterType="map" resultType="int" >
select count(DISTINCT objectid)
from univachivement
where uid = #{uid}
and objectid in (
select lessonid
from lesson
where parentid = #{unitid})
</select>
<select id="findAvgScoreByUnitidAndUid" parameterType="map" resultType="double" >
select avg(score)
from univachivement
where uid = #{uid}
and objectid in (select lessonid from lesson where parentid = #{unitid})
</select>
<select id="findStudentSelfUploadCourse" parameterType="map" resultType="com.univ3e.entity.UnivMaterial" >
SELECT a.* from (
SELECT distinct uid , materialId ,title , teacherId , origiVoice , isNetMate , picture
FROM V_UserOwnMaterial
WHERE isnetmate = 0 and uid = #{uid}
UNION ALL
SELECT distinct uid , materialId , title , teacherId , origiVoice , isNetMate , picture
FROM V_TeacherOwnMaterial
where isnetmate = 1
) a
<if test="title != null">
where a.title like '%'||#{title}||'%'
</if>
ORDER BY a.materialId DESC
</select>
<select id="findTeacherSelfUploadCourse" parameterType="map" resultType="com.univ3e.entity.UnivMaterial" >
SELECT a.* from (
SELECT distinct uid , materialId ,title , teacherId , origiVoice , isNetMate , picture
FROM V_TeacherOwnMaterial
WHERE isnetmate = 0 and uid = :uid
UNION ALL
SELECT distinct uid , materialId , title , teacherId , origiVoice , isNetMate , picture
FROM V_TeacherOwnMaterial
where isnetmate = 1
) a
<if test="title != null">
where a.title like '%'||#{title}||'%'
</if>
ORDER BY a.materialId DESC
</select>
<select id="findRecommendedCourse" parameterType="map" resultType="com._3e.entity.Goods" >
SELECT * FROM goods
WHERE isRecomm = 1
<if test="goodsname != null">
and goodsname like '%'||#{goodsname}||'%'
</if>
ORDER BY goodsId
<if test="page != null">
LIMIT #{page.limit} OFFSET #{page.offset}
</if>
</select>
<select id="find_3ETimeDto" parameterType="map" resultType="com._3e.dto._3ETimeDto" >
<!-- 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 ,s.month as month , s.year as year
from ( select uid, count(racescoreid) as race , 0 as achivement , 0 as exam , 0 as hearCount , extract(month from created) as month , extract(year from created) as year
from univracescore
where created &gt; #{startTime} and created &lt; #{endTime}
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 , extract(month from created) as month , extract(year from created) as year
from univachivement
where created &gt; #{startTime} and created &lt; #{endTime} and achivetype in ( 'L' , 'W' )
and pointCaseType in ( 3 , 5 , 6 , 7 , 8 )
group by uid ,extract(month from created) , extract(year from created)
union all
select distinct(userid) as uid ,0 as race , 0 as achivement , count(examanswerid) as exam ,0 as hearCount , extract(month from created) as month , extract(year from created) as year
from univexamanswer
where created &gt; #{startTime and created &lt; #{endTime}
group by userid ,extract(month from created) , extract(year from created)
union all
select distinct(userid) as uid ,0 as race , 0 as achivement , 0 as exam ,count(examanswerid) as hearCount , extract(month from created) as month , extract(year from created) as year
from univhearanswer
where created &gt; #{startTime} and created &lt; #{endTime}
group by userid ,extract(month from created) , extract(year from created) ) s
where uid = #{uid}
group by uid,month , year
-->
select distinct(s.uid) as uid , sum(s.race) as raceCount , sum(s.achivement) as achivementCount ,
sum(s.read) as hearSpokenCount, sum(s.exam) as examCount , sum(s.hearCount) as hearCount ,
sum(s.compExamCount) AS compExamCount, s.month as month , s.year as year
from ( select uid, count(racescoreid) as race , 0 as achivement , 0 as read, 0 as exam , 0 as hearCount ,
0 AS compExamCount, extract(month from created) as month , extract(year from created) as year
from univracescore
where created &gt; #{startTime} and created &lt; #{endTime}
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 read, 0 as exam , 0 as hearCount,
0 AS compExamCount,extract(month from created) as month , extract(year from created) as year
from univachivement
where created &gt; #{startTime} and created &lt; #{endTime} and achivetype in ( 'L' , 'W' )
and pointCaseType in ( 3 , 5 , 6 , 7 , 8 )
group by uid ,extract(month from created) , extract(year from created)
union all
select distinct(a.userid) as uid ,0 as race , 0 as achivement , count(a.examanswerid) as read,0 as exam ,
0 as hearCount, 0 AS compExamCount, extract(month from a.created) as month , extract(year from a.created) as year
from univexamanswer a
INNER JOIN univexam e ON e.examId = a.examId and e.isOral = 0
where a.created &gt; #{startTime} and a.created &lt; #{endTime}
group by a.userid ,extract(month from a.created) , extract(year from a.created)
union all
select distinct(a.userid) as uid ,0 as race , 0 as achivement , 0 as read, count(a.examanswerid) as exam ,
0 as hearCount, 0 AS compExamCount, extract(month from a.created) as month , extract(year from a.created) as year
from univexamanswer a
INNER JOIN univexam e ON e.examId = a.examId and e.isOral = 1
where a.created &gt; #{startTime} and a.created &lt; #{endTime}
group by a.userid ,extract(month from a.created) , extract(year from a.created)
union all
select distinct(a.userid) as uid ,0 as race , 0 as achivement , 0 as read, 0 as exam ,count(a.examanswerid) as hearCount , 0 AS compExamCount,
extract(month from a.created) as month , extract(year from a.created) as year
from univexamanswer a
INNER JOIN univexam e ON e.examId = a.examId and e.isOral = 2
where a.created &gt; #{startTime} and a.created &lt; #{endTime}
group by a.userid ,extract(month from a.created) , extract(year from a.created)
union all
select distinct(a.userid) as uid ,0 as race , 0 as achivement , 0 as read, 0 as exam ,0 as hearCount , count(a.examanswerid) AS compExamCount,
extract(month from a.created) as month , extract(year from a.created) as year
from univexamanswer a
INNER JOIN univexam e ON e.examId = a.examId and e.isOral = 3
where a.created &gt; #{startTime} and a.created &lt; #{endTime}
group by a.userid ,extract(month from a.created) , extract(year from a.created)
union all
select distinct(userid) as uid ,0 as race , 0 as achivement , 0 as read, 0 as exam ,
count(examanswerid) as hearCount , 0 AS compExamCount, extract(month from created) as month , extract(year from created) as year
from univhearanswer
where created &gt; #{startTime} and created &lt; #{endTime}
group by userid ,extract(month from created) , extract(year from created) ) s
where uid = #{uid}
group by uid,month , year
</select>
</mapper>