LibraryTeacherMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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.weixin.libmy.domain.LibVip" >
  20. select distinct t1.id,t1.child_name childName,t1.img_url imgUrl
  21. from tb_lib_vip t1 left join tb_class_student t2 on t1.id=t2.vip_id
  22. where t2.status=1
  23. <if test="classIdList !=null and classIdList.size()>0">
  24. and t2.class_id in
  25. <foreach collection="classIdList" open="(" item="classId" separator="," close=")">
  26. #{classId}
  27. </foreach>
  28. </if>
  29. <!--这里兼容注销逻辑-->
  30. <if test="vipIdList !=null and vipIdList.size()>0">
  31. and t1.id not in
  32. <foreach collection="vipIdList" open="(" item="vipId" separator="," close=")">
  33. #{vipId}
  34. </foreach>
  35. </if>
  36. </select>
  37. <select id="findVipListV1" resultType="com.ssj.bean.mybatis.LibVipMBDto" parameterType="java.util.Map">
  38. select
  39. <include refid="tbLibVip"/>
  40. ,t2.id pushId,t2.type,t2.push_time pushTime
  41. from tb_lib_vip t1
  42. join zyb_student_push t2 on t1.id = t2.vip_id and to_days(t2.push_time) = to_days( #{map.strdate})
  43. where
  44. <!--这里兼容注销逻辑-->
  45. t2.teacher_id = #{map.teacherId}
  46. <!--小孩的馆必须和签到的馆是一个馆才能显示 add by Mount 20200422 16:00-->
  47. and t1.lib_id = t2.lib_id
  48. and to_days(t2.push_time) = to_days( #{map.strdate})
  49. and t1.user_id is not null
  50. <!-- 为方便测试条件写为t2.type in (2, 6),实际上正常不可能出现6 -->
  51. and t2.type in (2, 6)
  52. order by t2.push_time,t1.id
  53. </select>
  54. <select id="findEditedVipList" resultType="com.ssj.bean.mybatis.LibVipMBDto" parameterType="java.util.Map">
  55. select
  56. <include refid="tbLibVip"/>
  57. ,t2.id pushId,t2.type,t2.push_time pushTime
  58. from tb_lib_vip t1
  59. join zyb_student_push t2 on t1.id = t2.vip_id and to_days(t2.push_time) = to_days( #{map.strdate})
  60. where
  61. <!--这里兼容注销逻辑-->
  62. t2.teacher_id != #{map.teacherId}
  63. and t2.teacher_id is not null
  64. <!--小孩的馆必须和签到的馆是一个馆才能显示 add by Mount 20200422 16:00-->
  65. and t1.lib_id = t2.lib_id
  66. and to_days(t2.push_time) = to_days( #{map.strdate})
  67. and t1.user_id is not null
  68. and t2.type !=0
  69. order by t2.push_time,t1.id
  70. </select>
  71. <select id="findTodayHomeworkByVipId" resultType="com.ssj.bean.mybatis.HomeworkPictureMBDto" parameterType="String">
  72. select
  73. t.course_name subject,
  74. t.type workType,
  75. sum(case when e.is_delete = 0 then 1 else 0 end) homeworkNum,
  76. ( sum(case when e.is_delete = 0 and e.is_feedback = 1 then 1 else 0 end ) +
  77. 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
  78. from
  79. ( SELECT a.id ,a.course_name , a.type from scon_no_homework_record a where a.vip_id =#{vipId}
  80. and to_days(a.create_time) = to_days( #{strdate} ) ) t
  81. left join scon_homework_picture e on e.homework_record_id = t.id and e.is_delete=0
  82. GROUP BY t.course_name
  83. </select>
  84. <select id="findTodayBadHomeworkByVipId" resultType="com.ssj.bean.mybatis.HomeworkPictureMBDto"
  85. parameterType="String">
  86. select t.isMark,t.fileKey,t.picNum,t.remindTime,t.subject
  87. from (select t.is_mark isMark,
  88. t.file_key fileKey,
  89. count(t.id) picNum,
  90. min(t.create_time) remindTime,
  91. t.subject
  92. from scon_homework_picture t
  93. where t.is_mark in (1, 3)
  94. and to_days(t.create_time) = to_days(now())
  95. and t.vip_id = #{vipId}
  96. group by t.vip_id, t.is_mark, t.subject) t
  97. order by t.remindTime
  98. </select>
  99. <select id="countHomeworkDataByClass" resultType="java.util.Map">
  100. select count(distinct kmt_homework_wrong_question.id) totalCount,
  101. sum(if(kmt_homework_wrong_question.type = 1, 1, 0)) wrongCount
  102. from tb_class_student,
  103. scon_homework,
  104. kmt_homework_wrong_question
  105. where tb_class_student.vip_id = scon_homework.vip_id
  106. and scon_homework.id = kmt_homework_wrong_question.homework_id
  107. and tb_class_student.status = 1
  108. and scon_homework.subject in
  109. <foreach collection="subjectList" open="(" item="subject" separator="," close=")">
  110. #{subject}
  111. </foreach>
  112. and tb_class_student.class_id = #{classId}
  113. and scon_homework.create_time > #{beginDateTimeStr}
  114. and #{endDateTimeStr} > scon_homework.create_time
  115. </select>
  116. <select id="countSubmittedStudentNum" resultType="java.lang.Integer">
  117. select count(distinct scon_homework_picture.vip_id)
  118. from (select vip_id
  119. from tb_class_student
  120. where class_id = #{classId}
  121. and status = 1) student
  122. join scon_homework_picture on student.vip_id = scon_homework_picture.vip_id and
  123. scon_homework_picture.create_time between #{beginDateTimeStr} and #{endDateTimeStr} and
  124. scon_homework_picture.subject in
  125. <foreach collection="subjectList" open="(" item="subject" separator="," close=")">
  126. #{subject}
  127. </foreach>
  128. <if test="corrected">
  129. and scon_homework_picture.is_feedback = 1
  130. and scon_homework_picture.is_mark in (0, 2)
  131. </if>
  132. </select>
  133. <select id="findHomeworkIdYesterdayByClass" resultType="java.lang.String">
  134. select distinct scon_homework_picture.homework_id
  135. from tb_class_student,
  136. scon_homework_picture
  137. where tb_class_student.class_id = #{classId}
  138. and tb_class_student.status = 1
  139. and tb_class_student.vip_id = scon_homework_picture.vip_id
  140. and scon_homework_picture.create_time > #{beginDateTimeStr}
  141. and #{endDateTimeStr} > scon_homework_picture.create_time
  142. and scon_homework_picture.subject in
  143. <foreach collection="subjectList" open="(" item="subject" separator="," close=")">
  144. #{subject}
  145. </foreach>
  146. and scon_homework_picture.is_feedback = 1
  147. and scon_homework_picture.is_mark in (0, 2)
  148. </select>
  149. <select id="findTypicalWrongQuestionListStep1"
  150. resultType="com.ssj.service.conch.teacher.library.dto.TypicalWrongQuestionDTO">
  151. select kmt_homework_wrong_question.question_id,
  152. count(kmt_homework_wrong_question.homework_id) studentCount
  153. from kmt_homework_wrong_question
  154. where kmt_homework_wrong_question.homework_id in
  155. <foreach collection="homeworkIdList" open="(" item="homeworkId" separator="," close=")">
  156. #{homeworkId}
  157. </foreach>
  158. and kmt_homework_wrong_question.type = 1
  159. group by kmt_homework_wrong_question.question_id
  160. </select>
  161. <select id="findTypicalWrongQuestionListStep2" resultType="java.util.Map">
  162. select kmt_exercise_book_course.book_name,
  163. kmt_exercise_book_course.unit,
  164. kmt_exercise_book_course.period,
  165. kmt_exercise_questions.big_question_index bigIndex,
  166. kmt_exercise_questions.small_question_name smallIndex
  167. from kmt_exercise_questions,
  168. kmt_exercise_book_course
  169. where kmt_exercise_questions.book_course_id = kmt_exercise_book_course.id
  170. and kmt_exercise_questions.id = #{questionId}
  171. limit 1
  172. </select>
  173. <select id="countHomeworkDataByGrade" resultType="java.util.Map">
  174. select sum(IF(type = 2, 1, 0)) rightCount, count(DISTINCT homework_id) totalCount
  175. from kmt_homework_wrong_question, scon_homework
  176. where kmt_homework_wrong_question.homework_id = scon_homework.id
  177. and kmt_homework_wrong_question.question_id = #{questionId}
  178. and scon_homework.grade = #{grade}
  179. and scon_homework.create_time > #{beginDateTimeStr}
  180. and #{endDateTimeStr} > scon_homework.create_time
  181. </select>
  182. <select id="findDependentKnowledge" resultType="com.ssj.service.conch.teacher.library.dto.KnowledgeDTO">
  183. select zyb_know_how_details_sort.alias name,
  184. kmt_exercise_question_know.how_details_id
  185. from kmt_exercise_question_know, zyb_know_how_details_sort
  186. where kmt_exercise_question_know.how_details_id = zyb_know_how_details_sort.how_details_id
  187. and zyb_know_how_details_sort.stat = 2
  188. and kmt_exercise_question_know.question_id = #{questionId}
  189. group by kmt_exercise_question_know.how_details_id
  190. </select>
  191. <select id="findSubmittedStudentList" resultType="com.ssj.service.conch.teacher.library.dto.StudentDTOV2">
  192. select tb_lib_vip.img_url photo,
  193. tb_lib_vip.child_name name,
  194. picture.vip_id,
  195. time
  196. from (select scon_homework_picture.vip_id, max(scon_homework_picture.create_time) time
  197. from (select vip_id
  198. from tb_class_student
  199. where class_id = #{classId}
  200. and status = 1) student
  201. join scon_homework_picture on student.vip_id = scon_homework_picture.vip_id and
  202. scon_homework_picture.create_time between #{beginDateTimeStr} and #{endDateTimeStr} and
  203. scon_homework_picture.subject in
  204. <foreach collection="subjectList" open="(" item="subject" separator="," close=")">
  205. #{subject}
  206. </foreach>
  207. group by scon_homework_picture.vip_id
  208. order by time desc) picture
  209. join tb_lib_vip on picture.vip_id = tb_lib_vip.id
  210. </select>
  211. <select id="findWrongQuestionDetail" resultType="com.ssj.service.conch.teacher.library.dto.WrongQuestionDetailDTO">
  212. select ifnull(classStudentPicture.corrected_picture_url, classStudentPicture.file_key) homeworkPictureUrl,
  213. tb_lib_vip.img_url studentPhoto,
  214. tb_lib_vip.child_name studentName
  215. from (select picture.*
  216. from (select scon_homework_picture.corrected_picture_url,
  217. scon_homework_picture.file_key,
  218. scon_homework_picture.vip_id
  219. from (select homework_picture_id
  220. from kmt_homework_wrong_question
  221. where question_id = #{questionId}) wrongQuestion
  222. join scon_homework_picture on wrongQuestion.homework_picture_id = scon_homework_picture.id and
  223. scon_homework_picture.create_time between #{beginDateTimeStr} and #{endDateTimeStr}) picture
  224. join tb_class_student on picture.vip_id = tb_class_student.vip_id and tb_class_student.status = 1 and
  225. tb_class_student.class_id = #{classId}) classStudentPicture
  226. join tb_lib_vip on classStudentPicture.vip_id = tb_lib_vip.id
  227. </select>
  228. <select id="findClassList" resultType="com.ssj.service.conch.teacher.v2.dto.ClassDto">
  229. select tb_class.id classId,
  230. tb_class.grade grade,
  231. tb_class.class_name className
  232. from tb_class_teacher left join
  233. tb_class on tb_class_teacher.class_id=tb_class.id
  234. where tb_class_teacher.status=1
  235. and tb_class.status in(1,2)
  236. and tb_class_teacher.teacher_id=#{teacherId}
  237. order by tb_class.create_time
  238. </select>
  239. <select id="findNewClassList" resultType="com.ssj.service.conch.teacher.v2.dto.NewClassDto">
  240. select ct.class_id, c.class_name, lj.league_name
  241. from tb_class_teacher ct
  242. join tb_lib_manager lm
  243. on ct.teacher_id = lm.user_id and lm.type = 10 and ct.lib_id = lm.lib_id and lm.state = 1
  244. join tb_class c on ct.class_id = c.id and c.status in (1, 2)
  245. join tb_lib_join lj on ct.lib_id = lj.id
  246. where ct.teacher_id = #{teacherId}
  247. and ct.status = 1
  248. order by c.create_time
  249. </select>
  250. <select id="findStudentList" resultType="com.ssj.service.conch.teacher.v2.dto.ClassStudentDto">
  251. select t2.img_url photo,
  252. t2.child_name name,
  253. t2.school school,
  254. t2.grade grade,
  255. t2.id vipId
  256. from tb_class_student t1 join
  257. tb_lib_vip t2 on t1.vip_id=t2.id and t2.stat=1
  258. where t1.vip_id=t2.id
  259. and t1.status=1
  260. and t1.class_id = #{classId}
  261. </select>
  262. <select id="countAllByClassId" resultType="java.lang.Integer">
  263. select count(distinct vip_id) from tb_class_student where class_id = #{classId} and status = 1
  264. </select>
  265. <select id="fingClassTeacherList" resultType="com.ssj.bean.mybatis.ManagerMBDto" parameterType="java.util.Map">
  266. select t.user_id userId,
  267. t.course_name courseName,
  268. t.name,
  269. t.t_photo tPhoto,
  270. t.telephone,
  271. sum(t.type) typeSum
  272. from tb_lib_manager t
  273. where t.type in (2, 10, 15)
  274. and t.state = 1
  275. <!--在本班的老师-->
  276. <if test="map.classId != null and map.classId != '' ">
  277. and exists(select 1 from tb_class_teacher where t.user_id=teacher_id and status=1 and
  278. class_id=#{map.classId})
  279. </if>
  280. <!--不在此班级的其他老师-->
  281. <if test="map.notThisClassId != null and map.notThisClassId != '' ">
  282. and t.user_id not in (select teacher_id from tb_class_teacher where class_id = #{map.notThisClassId} and
  283. status = 1)
  284. </if>
  285. <if test="map.libId != null and map.libId != '' ">
  286. and t.lib_id=#{map.libId}
  287. </if>
  288. group by t.user_id
  289. order by t.name
  290. <if test="map.nolimit != null and map.nolimit != '' ">
  291. limit 1000
  292. </if>
  293. </select>
  294. <select id="findFeedbackHistory" resultMap="FeedbackDTOResultMap">
  295. select push.*, scon_homework_picture.file_key
  296. from (select id push_id,
  297. vip_id,
  298. suggest,
  299. push_time push_time
  300. from zyb_student_push
  301. where vip_id = #{vipId}
  302. and type in (2, 5, 6)
  303. order by push_time desc
  304. limit #{offset}, #{pageSize}) push
  305. left join scon_homework_picture
  306. on push.vip_id = scon_homework_picture.vip_id
  307. and to_days(push.push_time) = to_days(scon_homework_picture.create_time)
  308. and scon_homework_picture.is_delete = 0
  309. order by push.push_time desc, field(scon_homework_picture.subject, '语文', '数学', '英语')
  310. </select>
  311. <select id="countFeedbackHistory" resultType="java.lang.Integer">
  312. select count(*)
  313. from zyb_student_push
  314. where vip_id = #{vipId}
  315. and type in (2, 5, 6)
  316. </select>
  317. <select id="getRankingList" resultType="java.util.Map">
  318. select user_name name, img_url imgUrl,ifNull(ranking_num,0) rankNum, rowno as `index`, vip_id vipId
  319. from (select a.child_name as user_name,
  320. a.img_url,
  321. a.vip_id,
  322. a.ranking_num,
  323. (@rowno := @rowno + 1) as rowno
  324. from (select tcs.vip_id ,shr.ranking_num ,tlv.child_name,tlv.img_url,shr.update_time
  325. from tb_class_student tcs left join scon_homework_ranking shr
  326. on tcs.vip_id=shr.vip_id
  327. left join tb_lib_vip tlv on tcs.vip_id=tlv.id
  328. where tcs.class_id in
  329. <foreach collection="classIdList" open="(" item="classId" separator="," close=")">
  330. #{classId}
  331. </foreach>
  332. and tlv.stat=1
  333. and tcs.status=1) as a,
  334. (select @rowno := 0) as row
  335. order by a.ranking_num desc, a.update_time desc) as temp
  336. </select>
  337. <select id="getClassList" resultType="java.util.Map">
  338. 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
  339. and t2.status=1
  340. </select>
  341. <select id="findAllStudentList" resultType="com.ssj.service.conch.teacher.library.dto.AllStudentDto">
  342. select lv.*, if(ls.id is not null, 1, 0) checked_in
  343. from (select cs.vip_id, tempLv.child_name student_name, tempLv.school, tempLv.grade, tempLv.img_url
  344. from (select vip_id
  345. from (select class_id from tb_class_teacher where teacher_id = #{teacherId} and status = 1) ct,
  346. tb_class_student tempCs
  347. where ct.class_id = tempCs.class_id
  348. and tempCs.status = 1) cs,
  349. tb_lib_vip tempLv
  350. where cs.vip_id = tempLv.id
  351. and tempLv.stat = '1'
  352. <if test="studentName != null and studentName != ''">
  353. and tempLv.child_name like '%${studentName}%'
  354. </if>
  355. ) lv
  356. left join tb_lib_subscribe ls on lv.vip_id = ls.vip_id and
  357. to_days(ls.ryke_time) = to_days(now()) and
  358. ls.flow_stat = '3'
  359. </select>
  360. <select id="findExitedStudentByVipId" resultType="com.ssj.service.conch.teacher.library.dto.AllStudentDto">
  361. select fcs.vip_id, lv.child_name student_name, lv.school, lv.grade, lv.img_url, 0 as checked_in, 1 as exited
  362. from (select vip_id
  363. from (select vip_id, class_id
  364. from tb_class_student
  365. where vip_id in
  366. <foreach collection="exitedVipIdList" open="(" item="exitedVipId" separator="," close=")">
  367. #{exitedVipId}
  368. </foreach>
  369. and status = 1) cs, tb_class_teacher ct
  370. where cs.class_id = ct.class_id
  371. and ct.teacher_id = #{teacherId}
  372. and ct.status = 1) fcs, tb_lib_vip lv
  373. where fcs.vip_id = lv.id
  374. and lv.stat = 1
  375. <if test="studentName != null and studentName != ''">
  376. and lv.child_name like '%${studentName}%'
  377. </if>
  378. </select>
  379. </mapper>