LibraryTeacherMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.ssj.mapper.libraryteacher.LibraryTeacherMapper">
  4. <resultMap id="FeedbackDTOResultMap" type="com.ssj.service.conch.teacher.library.dto.FeedbackDTO">
  5. <id column="push_id" property="pushId"/>
  6. <result column="suggest" property="suggest"/>
  7. <result column="push_time" property="pushTime"/>
  8. <collection property="homeworkPictureList" ofType="String">
  9. <constructor>
  10. <arg column="file_key"/>
  11. </constructor>
  12. </collection>
  13. </resultMap>
  14. <sql id="tbLibVip">
  15. t1.id,
  16. t1.child_name childName,
  17. t1.img_url imgUrl
  18. </sql>
  19. <select id="findVipList" resultType="com.ssj.bean.mybatis.LibVipMBDto" parameterType="java.util.Map">
  20. select
  21. <include refid="tbLibVip"/>
  22. ,t2.id pushId,t2.type,t2.push_time pushTime
  23. from tb_lib_vip t1
  24. join zyb_student_push t2 on t1.id = t2.vip_id and to_days(t2.push_time) = to_days( #{map.strdate})
  25. where
  26. <!--这里兼容注销逻辑-->
  27. t2.teacher_id = #{map.teacherId}
  28. <!--小孩的馆必须和签到的馆是一个馆才能显示 add by Mount 20200422 16:00-->
  29. and t1.lib_id = t2.lib_id
  30. and to_days(t2.push_time) = to_days( #{map.strdate})
  31. and t1.user_id is not null
  32. <if test="map.type != null and map.type != '' ">
  33. and t2.type = #{map.type}
  34. </if>
  35. order by t2.push_time,t1.id
  36. </select>
  37. <select id="findTodayHomeworkByVipId" resultType="com.ssj.bean.mybatis.HomeworkPictureMBDto" parameterType="String">
  38. select
  39. t.course_name subject,
  40. t.type workType,
  41. sum(case when e.is_delete = 0 then 1 else 0 end) homeworkNum,
  42. ( sum(case when e.is_delete = 0 and e.is_feedback = 1 then 1 else 0 end ) +
  43. 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
  44. from
  45. ( SELECT a.id ,a.course_name , a.type from scon_no_homework_record a where a.vip_id =#{vipId}
  46. and to_days(a.create_time) = to_days( #{strdate} ) ) t
  47. left join scon_homework_picture e on e.homework_record_id = t.id and e.is_delete=0
  48. GROUP BY t.course_name
  49. </select>
  50. <select id="findTodayBadHomeworkByVipId" resultType="com.ssj.bean.mybatis.HomeworkPictureMBDto"
  51. parameterType="String">
  52. select t.isMark,t.fileKey,t.picNum,t.remindTime,t.subject
  53. from (select t.is_mark isMark,
  54. t.file_key fileKey,
  55. count(t.id) picNum,
  56. min(t.create_time) remindTime,
  57. t.subject
  58. from scon_homework_picture t
  59. where t.is_mark in (1, 3)
  60. and to_days(t.create_time) = to_days(now())
  61. and t.vip_id = #{vipId}
  62. group by t.vip_id, t.is_mark, t.subject) t
  63. order by t.remindTime
  64. </select>
  65. <select id="countHomeworkDataByClass" resultType="java.util.Map">
  66. select count(distinct kmt_homework_wrong_question.id) totalCount,
  67. sum(if(kmt_homework_wrong_question.type = 1, 1, 0)) wrongCount
  68. from tb_class_student,
  69. scon_homework,
  70. kmt_homework_wrong_question
  71. where tb_class_student.vip_id = scon_homework.vip_id
  72. and scon_homework.id = kmt_homework_wrong_question.homework_id
  73. and tb_class_student.status = 1
  74. and scon_homework.subject in
  75. <foreach collection="subjectList" open="(" item="subject" separator="," close=")">
  76. #{subject}
  77. </foreach>
  78. and tb_class_student.class_id = #{classId}
  79. and scon_homework.create_time > #{beginDateTimeStr}
  80. and #{endDateTimeStr} > scon_homework.create_time
  81. </select>
  82. <select id="countSubmittedStudentNum" resultType="java.lang.Integer">
  83. select count(distinct scon_homework_picture.vip_id)
  84. from (select vip_id
  85. from tb_class_student
  86. where class_id = #{classId}
  87. and status = 1) student
  88. join scon_homework_picture on student.vip_id = scon_homework_picture.vip_id and
  89. scon_homework_picture.create_time between #{beginDateTimeStr} and #{endDateTimeStr} and
  90. scon_homework_picture.subject in
  91. <foreach collection="subjectList" open="(" item="subject" separator="," close=")">
  92. #{subject}
  93. </foreach>
  94. <if test="corrected">
  95. and scon_homework_picture.is_feedback = 1
  96. and scon_homework_picture.is_mark in (0, 2)
  97. </if>
  98. </select>
  99. <select id="findHomeworkIdYesterdayByClass" resultType="java.lang.String">
  100. select distinct scon_homework_picture.homework_id
  101. from tb_class_student,
  102. scon_homework_picture
  103. where tb_class_student.class_id = #{classId}
  104. and tb_class_student.status = 1
  105. and tb_class_student.vip_id = scon_homework_picture.vip_id
  106. and scon_homework_picture.create_time > #{beginDateTimeStr}
  107. and #{endDateTimeStr} > scon_homework_picture.create_time
  108. and scon_homework_picture.subject in
  109. <foreach collection="subjectList" open="(" item="subject" separator="," close=")">
  110. #{subject}
  111. </foreach>
  112. and scon_homework_picture.is_feedback = 1
  113. and scon_homework_picture.is_mark in (0, 2)
  114. </select>
  115. <select id="findTypicalWrongQuestionList"
  116. resultType="com.ssj.service.conch.teacher.library.dto.TypicalWrongQuestionDTO">
  117. select kmt_homework_wrong_question.question_id,
  118. kmt_exercise_book_course.book_name,
  119. kmt_exercise_book_course.unit,
  120. kmt_exercise_book_course.period,
  121. kmt_exercise_questions.big_question_index bigIndex,
  122. kmt_exercise_questions.small_question_name smallIndex,
  123. count(kmt_homework_wrong_question.homework_id) studentCount
  124. from kmt_homework_wrong_question,
  125. kmt_exercise_questions,
  126. kmt_exercise_book_course
  127. where kmt_homework_wrong_question.homework_id in
  128. <foreach collection="homeworkIdList" open="(" item="homeworkId" separator="," close=")">
  129. #{homeworkId}
  130. </foreach>
  131. and kmt_homework_wrong_question.type = 1
  132. and kmt_homework_wrong_question.question_id = kmt_exercise_questions.id
  133. and kmt_exercise_questions.book_course_id = kmt_exercise_book_course.id
  134. group by kmt_homework_wrong_question.question_id
  135. </select>
  136. <select id="countHomeworkDataByGrade" resultType="java.util.Map">
  137. select sum(IF(type = 2, 1, 0)) rightCount, count(DISTINCT homework_id) totalCount
  138. from kmt_homework_wrong_question, scon_homework
  139. where kmt_homework_wrong_question.homework_id = scon_homework.id
  140. and kmt_homework_wrong_question.question_id = #{questionId}
  141. and scon_homework.grade = #{grade}
  142. and scon_homework.create_time > #{beginDateTimeStr}
  143. and #{endDateTimeStr} > scon_homework.create_time
  144. </select>
  145. <select id="findDependentKnowledge" resultType="com.ssj.service.conch.teacher.library.dto.KnowledgeDTO">
  146. select zyb_know_how_details_sort.alias name
  147. from kmt_exercise_question_know, zyb_know_how_details_sort
  148. where kmt_exercise_question_know.how_details_id = zyb_know_how_details_sort.how_details_id
  149. and zyb_know_how_details_sort.stat = 2
  150. and kmt_exercise_question_know.question_id = #{questionId}
  151. group by kmt_exercise_question_know.how_details_id
  152. </select>
  153. <select id="findSubmittedStudentList" resultType="com.ssj.service.conch.teacher.library.dto.StudentDTOV2">
  154. select tb_lib_vip.img_url photo,
  155. tb_lib_vip.child_name name,
  156. picture.vip_id,
  157. time
  158. from (select scon_homework_picture.vip_id, max(scon_homework_picture.create_time) time
  159. from (select vip_id
  160. from tb_class_student
  161. where class_id = #{classId}
  162. and status = 1) student
  163. join scon_homework_picture on student.vip_id = scon_homework_picture.vip_id and
  164. scon_homework_picture.create_time between #{beginDateTimeStr} and #{endDateTimeStr} and
  165. scon_homework_picture.subject in
  166. <foreach collection="subjectList" open="(" item="subject" separator="," close=")">
  167. #{subject}
  168. </foreach>
  169. group by scon_homework_picture.vip_id
  170. order by time desc) picture
  171. join tb_lib_vip on picture.vip_id = tb_lib_vip.id
  172. </select>
  173. <select id="findWrongQuestionDetail" resultType="com.ssj.service.conch.teacher.library.dto.WrongQuestionDetailDTO">
  174. select ifnull(classStudentPicture.corrected_picture_url, classStudentPicture.file_key) homeworkPictureUrl,
  175. tb_lib_vip.img_url studentPhoto,
  176. tb_lib_vip.child_name studentName
  177. from (select picture.*
  178. from (select scon_homework_picture.corrected_picture_url,
  179. scon_homework_picture.file_key,
  180. scon_homework_picture.vip_id
  181. from (select homework_picture_id
  182. from kmt_homework_wrong_question
  183. where question_id = #{questionId}) wrongQuestion
  184. join scon_homework_picture on wrongQuestion.homework_picture_id = scon_homework_picture.id and
  185. scon_homework_picture.create_time between #{beginDateTimeStr} and #{endDateTimeStr}) picture
  186. join tb_class_student on picture.vip_id = tb_class_student.vip_id and tb_class_student.status = 1 and
  187. tb_class_student.class_id = #{classId}) classStudentPicture
  188. join tb_lib_vip on classStudentPicture.vip_id = tb_lib_vip.id
  189. </select>
  190. <select id="findClassList" resultType="com.ssj.service.conch.teacher.v2.dto.ClassDto">
  191. select tb_class.id classId,
  192. tb_class.grade grade,
  193. tb_class.class_name className
  194. from tb_class_teacher left join
  195. tb_class on tb_class_teacher.class_id=tb_class.id
  196. where tb_class_teacher.status=1
  197. and tb_class.status in(1,2)
  198. and tb_class_teacher.teacher_id=#{teacherId}
  199. order by tb_class.create_time
  200. </select>
  201. <select id="findNewClassList" resultType="com.ssj.service.conch.teacher.v2.dto.NewClassDto">
  202. select ct.class_id, c.class_name, lj.league_name
  203. from tb_class_teacher ct
  204. join tb_lib_manager lm
  205. on ct.teacher_id = lm.user_id and lm.type = 10 and ct.lib_id = lm.lib_id and lm.state = 1
  206. join tb_class c on ct.class_id = c.id and c.status in (1, 2)
  207. join tb_lib_join lj on ct.lib_id = lj.id
  208. where ct.teacher_id = #{teacherId}
  209. and ct.status = 1
  210. order by c.create_time
  211. </select>
  212. <select id="findStudentList" resultType="com.ssj.service.conch.teacher.v2.dto.ClassStudentDto">
  213. select t2.img_url photo,
  214. t2.child_name name,
  215. t2.school school,
  216. t2.grade grade,
  217. t2.id vipId
  218. from tb_class_student t1 join
  219. tb_lib_vip t2 on t1.vip_id=t2.id and t2.stat=1
  220. where t1.vip_id=t2.id
  221. and t1.status=1
  222. and t1.class_id = #{classId}
  223. </select>
  224. <select id="countAllByClassId" resultType="java.lang.Integer">
  225. select count(distinct vip_id) from tb_class_student where class_id = #{classId} and status = 1
  226. </select>
  227. <select id="fingClassTeacherList" resultType="com.ssj.bean.mybatis.ManagerMBDto" parameterType="java.util.Map">
  228. select t.user_id userId,
  229. t.course_name courseName,
  230. t.name,
  231. t.t_photo tPhoto,
  232. t.telephone,
  233. sum(t.type) typeSum
  234. from tb_lib_manager t
  235. where t.type in (2, 10, 15)
  236. and t.state = 1
  237. <!--在本班的老师-->
  238. <if test="map.classId != null and map.classId != '' ">
  239. and exists(select 1 from tb_class_teacher where t.user_id=teacher_id and status=1 and
  240. class_id=#{map.classId})
  241. </if>
  242. <!--不在此班级的其他老师-->
  243. <if test="map.notThisClassId != null and map.notThisClassId != '' ">
  244. and t.user_id not in (select teacher_id from tb_class_teacher where class_id = #{map.notThisClassId} and
  245. status = 1)
  246. </if>
  247. <if test="map.libId != null and map.libId != '' ">
  248. and t.lib_id=#{map.libId}
  249. </if>
  250. group by t.user_id
  251. order by t.name
  252. <if test="map.nolimit != null and map.nolimit != '' ">
  253. limit 1000
  254. </if>
  255. </select>
  256. <select id="findFeedbackHistory" resultMap="FeedbackDTOResultMap">
  257. select push.*, scon_homework_picture.file_key
  258. from (select id push_id,
  259. vip_id,
  260. suggest,
  261. push_time push_time
  262. from zyb_student_push
  263. where vip_id = #{vipId}
  264. and #{endDate} > push_time
  265. and type > 0
  266. order by push_time desc
  267. limit #{offset}, #{pageSize}) push
  268. left join scon_homework_picture
  269. on push.vip_id = scon_homework_picture.vip_id
  270. and to_days(push.push_time) = to_days(scon_homework_picture.create_time)
  271. and scon_homework_picture.is_delete = 0
  272. order by push.push_time desc, field(scon_homework_picture.subject, '语文', '数学', '英语')
  273. </select>
  274. <select id="countFeedbackHistory" resultType="java.lang.Integer">
  275. select count(*)
  276. from zyb_student_push
  277. where vip_id = #{vipId}
  278. and #{endDate} > push_time
  279. and type > 0
  280. </select>
  281. </mapper>