123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
- <?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.ssj.mapper.libraryteacher.LibraryTeacherMapper">
- <resultMap id="FeedbackDTOResultMap" type="com.ssj.service.conch.teacher.library.dto.FeedbackDTO">
- <id column="push_id" property="pushId"/>
- <result column="suggest" property="suggest"/>
- <result column="push_time" property="pushTime"/>
- <collection property="homeworkPictureList" ofType="String">
- <constructor>
- <arg column="file_key"/>
- </constructor>
- </collection>
- </resultMap>
- <sql id="tbLibVip">
- t1.id,
- t1.child_name childName,
- t1.img_url imgUrl
- </sql>
- <select id="findVipList" resultType="com.ssj.bean.weixin.libmy.domain.LibVip" >
- select distinct t1.id,t1.child_name childName,t1.img_url imgUrl
- from tb_lib_vip t1 left join tb_class_student t2 on t1.id=t2.vip_id
- where t2.status=1
- <if test="classIdList !=null and classIdList.size()>0">
- and t2.class_id in
- <foreach collection="classIdList" open="(" item="classId" separator="," close=")">
- #{classId}
- </foreach>
- </if>
- <!--这里兼容注销逻辑-->
- <if test="vipIdList !=null and vipIdList.size()>0">
- and t1.id not in
- <foreach collection="vipIdList" open="(" item="vipId" separator="," close=")">
- #{vipId}
- </foreach>
- </if>
- </select>
- <select id="findVipListV1" resultType="com.ssj.bean.mybatis.LibVipMBDto" parameterType="java.util.Map">
- select
- <include refid="tbLibVip"/>
- ,t2.id pushId,t2.type,t2.push_time pushTime
- from tb_lib_vip t1
- join zyb_student_push t2 on t1.id = t2.vip_id and to_days(t2.push_time) = to_days( #{map.strdate})
- where
- <!--这里兼容注销逻辑-->
- t2.teacher_id = #{map.teacherId}
- <!--小孩的馆必须和签到的馆是一个馆才能显示 add by Mount 20200422 16:00-->
- and t1.lib_id = t2.lib_id
- and to_days(t2.push_time) = to_days( #{map.strdate})
- and t1.user_id is not null
- <!-- 为方便测试条件写为t2.type in (2, 6),实际上正常不可能出现6 -->
- and t2.type in (2, 6)
- order by t2.push_time,t1.id
- </select>
- <select id="findEditedVipList" resultType="com.ssj.bean.mybatis.LibVipMBDto" parameterType="java.util.Map">
- select
- <include refid="tbLibVip"/>
- ,t2.id pushId,t2.type,t2.push_time pushTime
- from tb_lib_vip t1
- join zyb_student_push t2 on t1.id = t2.vip_id and to_days(t2.push_time) = to_days( #{map.strdate})
- where
- <!--这里兼容注销逻辑-->
- t2.teacher_id != #{map.teacherId}
- and t2.teacher_id is not null
- <!--小孩的馆必须和签到的馆是一个馆才能显示 add by Mount 20200422 16:00-->
- and t1.lib_id = t2.lib_id
- and to_days(t2.push_time) = to_days( #{map.strdate})
- and t1.user_id is not null
- and t2.type !=0
- order by t2.push_time,t1.id
- </select>
- <select id="findTodayHomeworkByVipId" resultType="com.ssj.bean.mybatis.HomeworkPictureMBDto" parameterType="String">
- select
- t.course_name subject,
- t.type workType,
- sum(case when e.is_delete = 0 then 1 else 0 end) homeworkNum,
- ( sum(case when e.is_delete = 0 and e.is_feedback = 1 then 1 else 0 end ) +
- sum(case when e.is_delete = 0 and e.is_feedback = 0 and e.is_mark in(1,3) then 1 else 0 end ) ) feedbackNum
- from
- ( SELECT a.id ,a.course_name , a.type from scon_no_homework_record a where a.vip_id =#{vipId}
- and to_days(a.create_time) = to_days( #{strdate} ) ) t
- left join scon_homework_picture e on e.homework_record_id = t.id and e.is_delete=0
- GROUP BY t.course_name
- </select>
- <select id="findTodayBadHomeworkByVipId" resultType="com.ssj.bean.mybatis.HomeworkPictureMBDto"
- parameterType="String">
- select t.isMark,t.fileKey,t.picNum,t.remindTime,t.subject
- from (select t.is_mark isMark,
- t.file_key fileKey,
- count(t.id) picNum,
- min(t.create_time) remindTime,
- t.subject
- from scon_homework_picture t
- where t.is_mark in (1, 3)
- and to_days(t.create_time) = to_days(now())
- and t.vip_id = #{vipId}
- group by t.vip_id, t.is_mark, t.subject) t
- order by t.remindTime
- </select>
- <select id="countHomeworkDataByClass" resultType="java.util.Map">
- select count(distinct kmt_homework_wrong_question.id) totalCount,
- sum(if(kmt_homework_wrong_question.type = 1, 1, 0)) wrongCount
- from tb_class_student,
- scon_homework,
- kmt_homework_wrong_question
- where tb_class_student.vip_id = scon_homework.vip_id
- and scon_homework.id = kmt_homework_wrong_question.homework_id
- and tb_class_student.status = 1
- and scon_homework.subject in
- <foreach collection="subjectList" open="(" item="subject" separator="," close=")">
- #{subject}
- </foreach>
- and tb_class_student.class_id = #{classId}
- and scon_homework.create_time > #{beginDateTimeStr}
- and #{endDateTimeStr} > scon_homework.create_time
- </select>
- <select id="countSubmittedStudentNum" resultType="java.lang.Integer">
- select count(distinct scon_homework_picture.vip_id)
- from (select vip_id
- from tb_class_student
- where class_id = #{classId}
- and status = 1) student
- join scon_homework_picture on student.vip_id = scon_homework_picture.vip_id and
- scon_homework_picture.create_time between #{beginDateTimeStr} and #{endDateTimeStr} and
- scon_homework_picture.subject in
- <foreach collection="subjectList" open="(" item="subject" separator="," close=")">
- #{subject}
- </foreach>
- <if test="corrected">
- and scon_homework_picture.is_feedback = 1
- and scon_homework_picture.is_mark in (0, 2)
- </if>
- </select>
- <select id="findHomeworkIdYesterdayByClass" resultType="java.lang.String">
- select distinct scon_homework_picture.homework_id
- from tb_class_student,
- scon_homework_picture
- where tb_class_student.class_id = #{classId}
- and tb_class_student.status = 1
- and tb_class_student.vip_id = scon_homework_picture.vip_id
- and scon_homework_picture.create_time > #{beginDateTimeStr}
- and #{endDateTimeStr} > scon_homework_picture.create_time
- and scon_homework_picture.subject in
- <foreach collection="subjectList" open="(" item="subject" separator="," close=")">
- #{subject}
- </foreach>
- and scon_homework_picture.is_feedback = 1
- and scon_homework_picture.is_mark in (0, 2)
- </select>
- <select id="findTypicalWrongQuestionListStep1"
- resultType="com.ssj.service.conch.teacher.library.dto.TypicalWrongQuestionDTO">
- select kmt_homework_wrong_question.question_id,
- count(kmt_homework_wrong_question.homework_id) studentCount
- from kmt_homework_wrong_question
- where kmt_homework_wrong_question.homework_id in
- <foreach collection="homeworkIdList" open="(" item="homeworkId" separator="," close=")">
- #{homeworkId}
- </foreach>
- and kmt_homework_wrong_question.type = 1
- group by kmt_homework_wrong_question.question_id
- </select>
- <select id="findTypicalWrongQuestionListStep2" resultType="java.util.Map">
- select kmt_exercise_book_course.book_name,
- kmt_exercise_book_course.unit,
- kmt_exercise_book_course.period,
- kmt_exercise_questions.big_question_index bigIndex,
- kmt_exercise_questions.small_question_name smallIndex
- from kmt_exercise_questions,
- kmt_exercise_book_course
- where kmt_exercise_questions.book_course_id = kmt_exercise_book_course.id
- and kmt_exercise_questions.id = #{questionId}
- limit 1
- </select>
- <select id="countHomeworkDataByGrade" resultType="java.util.Map">
- select sum(IF(type = 2, 1, 0)) rightCount, count(DISTINCT homework_id) totalCount
- from kmt_homework_wrong_question, scon_homework
- where kmt_homework_wrong_question.homework_id = scon_homework.id
- and kmt_homework_wrong_question.question_id = #{questionId}
- and scon_homework.grade = #{grade}
- and scon_homework.create_time > #{beginDateTimeStr}
- and #{endDateTimeStr} > scon_homework.create_time
- </select>
- <select id="findDependentKnowledge" resultType="com.ssj.service.conch.teacher.library.dto.KnowledgeDTO">
- select zyb_know_how_details_sort.alias name,
- kmt_exercise_question_know.how_details_id
- from kmt_exercise_question_know, zyb_know_how_details_sort
- where kmt_exercise_question_know.how_details_id = zyb_know_how_details_sort.how_details_id
- and zyb_know_how_details_sort.stat = 2
- and kmt_exercise_question_know.question_id = #{questionId}
- group by kmt_exercise_question_know.how_details_id
- </select>
- <select id="findSubmittedStudentList" resultType="com.ssj.service.conch.teacher.library.dto.StudentDTOV2">
- select tb_lib_vip.img_url photo,
- tb_lib_vip.child_name name,
- picture.vip_id,
- time
- from (select scon_homework_picture.vip_id, max(scon_homework_picture.create_time) time
- from (select vip_id
- from tb_class_student
- where class_id = #{classId}
- and status = 1) student
- join scon_homework_picture on student.vip_id = scon_homework_picture.vip_id and
- scon_homework_picture.create_time between #{beginDateTimeStr} and #{endDateTimeStr} and
- scon_homework_picture.subject in
- <foreach collection="subjectList" open="(" item="subject" separator="," close=")">
- #{subject}
- </foreach>
- group by scon_homework_picture.vip_id
- order by time desc) picture
- join tb_lib_vip on picture.vip_id = tb_lib_vip.id
- </select>
- <select id="findWrongQuestionDetail" resultType="com.ssj.service.conch.teacher.library.dto.WrongQuestionDetailDTO">
- select ifnull(classStudentPicture.corrected_picture_url, classStudentPicture.file_key) homeworkPictureUrl,
- tb_lib_vip.img_url studentPhoto,
- tb_lib_vip.child_name studentName
- from (select picture.*
- from (select scon_homework_picture.corrected_picture_url,
- scon_homework_picture.file_key,
- scon_homework_picture.vip_id
- from (select homework_picture_id
- from kmt_homework_wrong_question
- where question_id = #{questionId}) wrongQuestion
- join scon_homework_picture on wrongQuestion.homework_picture_id = scon_homework_picture.id and
- scon_homework_picture.create_time between #{beginDateTimeStr} and #{endDateTimeStr}) picture
- join tb_class_student on picture.vip_id = tb_class_student.vip_id and tb_class_student.status = 1 and
- tb_class_student.class_id = #{classId}) classStudentPicture
- join tb_lib_vip on classStudentPicture.vip_id = tb_lib_vip.id
- </select>
- <select id="findClassList" resultType="com.ssj.service.conch.teacher.v2.dto.ClassDto">
- select tb_class.id classId,
- tb_class.grade grade,
- tb_class.class_name className
- from tb_class_teacher left join
- tb_class on tb_class_teacher.class_id=tb_class.id
- where tb_class_teacher.status=1
- and tb_class.status in(1,2)
- and tb_class_teacher.teacher_id=#{teacherId}
- order by tb_class.create_time
- </select>
- <select id="findNewClassList" resultType="com.ssj.service.conch.teacher.v2.dto.NewClassDto">
- select ct.class_id, c.class_name, lj.league_name
- from tb_class_teacher ct
- join tb_lib_manager lm
- on ct.teacher_id = lm.user_id and lm.type = 10 and ct.lib_id = lm.lib_id and lm.state = 1
- join tb_class c on ct.class_id = c.id and c.status in (1, 2)
- join tb_lib_join lj on ct.lib_id = lj.id
- where ct.teacher_id = #{teacherId}
- and ct.status = 1
- order by c.create_time
- </select>
- <select id="findStudentList" resultType="com.ssj.service.conch.teacher.v2.dto.ClassStudentDto">
- select t2.img_url photo,
- t2.child_name name,
- t2.school school,
- t2.grade grade,
- t2.id vipId
- from tb_class_student t1 join
- tb_lib_vip t2 on t1.vip_id=t2.id and t2.stat=1
- where t1.vip_id=t2.id
- and t1.status=1
- and t1.class_id = #{classId}
- </select>
- <select id="countAllByClassId" resultType="java.lang.Integer">
- select count(distinct vip_id) from tb_class_student where class_id = #{classId} and status = 1
- </select>
- <select id="fingClassTeacherList" resultType="com.ssj.bean.mybatis.ManagerMBDto" parameterType="java.util.Map">
- select t.user_id userId,
- t.course_name courseName,
- t.name,
- t.t_photo tPhoto,
- t.telephone,
- sum(t.type) typeSum
- from tb_lib_manager t
- where t.type in (2, 10, 15)
- and t.state = 1
- <!--在本班的老师-->
- <if test="map.classId != null and map.classId != '' ">
- and exists(select 1 from tb_class_teacher where t.user_id=teacher_id and status=1 and
- class_id=#{map.classId})
- </if>
- <!--不在此班级的其他老师-->
- <if test="map.notThisClassId != null and map.notThisClassId != '' ">
- and t.user_id not in (select teacher_id from tb_class_teacher where class_id = #{map.notThisClassId} and
- status = 1)
- </if>
- <if test="map.libId != null and map.libId != '' ">
- and t.lib_id=#{map.libId}
- </if>
- group by t.user_id
- order by t.name
- <if test="map.nolimit != null and map.nolimit != '' ">
- limit 1000
- </if>
- </select>
- <select id="findFeedbackHistory" resultMap="FeedbackDTOResultMap">
- select push.*, scon_homework_picture.file_key
- from (select id push_id,
- vip_id,
- suggest,
- push_time push_time
- from zyb_student_push
- where vip_id = #{vipId}
- and type in (2, 5, 6)
- order by push_time desc
- limit #{offset}, #{pageSize}) push
- left join scon_homework_picture
- on push.vip_id = scon_homework_picture.vip_id
- and to_days(push.push_time) = to_days(scon_homework_picture.create_time)
- and scon_homework_picture.is_delete = 0
- order by push.push_time desc, field(scon_homework_picture.subject, '语文', '数学', '英语')
- </select>
- <select id="countFeedbackHistory" resultType="java.lang.Integer">
- select count(*)
- from zyb_student_push
- where vip_id = #{vipId}
- and type in (2, 5, 6)
- </select>
- <select id="getRankingList" resultType="java.util.Map">
- select user_name name, img_url imgUrl,ifNull(ranking_num,0) rankNum, rowno as `index`, vip_id vipId
- from (select a.child_name as user_name,
- a.img_url,
- a.vip_id,
- a.ranking_num,
- (@rowno := @rowno + 1) as rowno
- from (select tcs.vip_id ,shr.ranking_num ,tlv.child_name,tlv.img_url,shr.update_time
- from tb_class_student tcs left join scon_homework_ranking shr
- on tcs.vip_id=shr.vip_id
- left join tb_lib_vip tlv on tcs.vip_id=tlv.id
- where tcs.class_id in
- <foreach collection="classIdList" open="(" item="classId" separator="," close=")">
- #{classId}
- </foreach>
- and tlv.stat=1
- and tcs.status=1) as a,
- (select @rowno := 0) as row
- order by a.ranking_num desc, a.update_time desc) as temp
- </select>
- <select id="getClassList" resultType="java.util.Map">
- select distinct t1.class_id from tb_class_teacher t1 left join tb_class t2 on t1.class_id=t2.id where t1.teacher_id=#{teacherId} and t1.status=1
- and t2.status=1
- </select>
- <select id="findAllStudentList" resultType="com.ssj.service.conch.teacher.library.dto.AllStudentDto">
- select lv.*, if(ls.id is not null, 1, 0) checked_in
- from (select cs.vip_id, tempLv.child_name student_name, tempLv.school, tempLv.grade, tempLv.img_url
- from (select vip_id
- from (select class_id from tb_class_teacher where teacher_id = #{teacherId} and status = 1) ct,
- tb_class_student tempCs
- where ct.class_id = tempCs.class_id
- and tempCs.status = 1) cs,
- tb_lib_vip tempLv
- where cs.vip_id = tempLv.id
- and tempLv.stat = '1'
- <if test="studentName != null and studentName != ''">
- and tempLv.child_name like '%${studentName}%'
- </if>
- ) lv
- left join tb_lib_subscribe ls on lv.vip_id = ls.vip_id and
- to_days(ls.ryke_time) = to_days(now()) and
- ls.flow_stat = '3'
- </select>
- <select id="findExitedStudentByVipId" resultType="com.ssj.service.conch.teacher.library.dto.AllStudentDto">
- select fcs.vip_id, lv.child_name student_name, lv.school, lv.grade, lv.img_url, 0 as checked_in, 1 as exited
- from (select vip_id
- from (select vip_id, class_id
- from tb_class_student
- where vip_id in
- <foreach collection="exitedVipIdList" open="(" item="exitedVipId" separator="," close=")">
- #{exitedVipId}
- </foreach>
- and status = 1) cs, tb_class_teacher ct
- where cs.class_id = ct.class_id
- and ct.teacher_id = #{teacherId}
- and ct.status = 1) fcs, tb_lib_vip lv
- where fcs.vip_id = lv.id
- and lv.stat = 1
- <if test="studentName != null and studentName != ''">
- and lv.child_name like '%${studentName}%'
- </if>
- </select>
- </mapper>
|