CuratorMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  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.service.mapper.CuratorMapper">
  4. <select id="findMyInfo" resultType="com.ssj.service.conch.curator.dto.CuratorDTO">
  5. select tb_lib_manager.name curator_name,
  6. tb_lib_manager.telephone phone,
  7. tb_lib_manager.lib_id,
  8. tb_lib_join.league_name lib_name
  9. from tb_lib_manager,
  10. tb_lib_join
  11. where tb_lib_manager.lib_id = tb_lib_join.id
  12. and tb_lib_manager.user_id = #{curatorUserId}
  13. and tb_lib_manager.type = 4
  14. and tb_lib_manager.state = 1
  15. limit 1
  16. </select>
  17. <select id="findApplyInfo" resultType="com.ssj.service.conch.curator.dto.CuratorDTO">
  18. select tb_lib_manager_audit.name curator_name,
  19. tb_lib_manager_audit.telephone phone,
  20. tb_lib_manager_audit.lib_id,
  21. tb_lib_join.league_name lib_name
  22. from tb_lib_manager_audit,
  23. tb_lib_join
  24. where tb_lib_manager_audit.lib_id = tb_lib_join.id
  25. and tb_lib_manager_audit.user_id = #{curatorUserId}
  26. and tb_lib_manager_audit.type = 4
  27. limit 1
  28. </select>
  29. <!--校长端老师列表-->
  30. <select id="findCuratorTeacherList" resultType="com.ssj.bean.conch.curator.dto.CuratorTeacherListDto">
  31. select lm.user_id teacher_id, group_concat(lm.type) teacher_type_list, group_concat(distinct course_name) subject,
  32. lm.name, lm.t_photo img_url, lm.telephone phone,ct.class_sum from tb_lib_manager lm
  33. left join (select teacher_id, count(class_id) class_sum from tb_class_teacher where status=1 and lib_id=#{libId} group by teacher_id) ct
  34. on ct.teacher_id=lm.user_id
  35. where lm.type in
  36. <foreach collection="types" open="(" item="type" separator="," close=")">
  37. #{type}
  38. </foreach>
  39. <if test="searchKey != null and searchKey != '' ">
  40. and lm.name regexp #{searchKey}
  41. </if>
  42. and lm.state=1 and lm.lib_id=#{libId}
  43. group by lm.user_id
  44. </select>
  45. <select id="findCuratorAuditTeacherList" resultType="com.ssj.bean.conch.curator.dto.CuratorTeacherListDto">
  46. select lm.user_id teacher_id, group_concat(lm.type) teacher_type_list, group_concat(distinct subject) subject,
  47. lm.name, (select t_photo from tb_lib_manager where id=lm.lib_manager_id) img_url, lm.telephone phone,0 class_sum
  48. from tb_lib_manager_audit lm
  49. where lm.type in
  50. <foreach collection="types" open="(" item="type" separator="," close=")">
  51. #{type}
  52. </foreach>
  53. <if test="searchKey != null and searchKey != '' ">
  54. and lm.name regexp #{searchKey}
  55. </if>
  56. and lm.status=3
  57. and lm.lib_id=#{libId}
  58. group by lm.user_id
  59. </select>
  60. <!--老师详情-->
  61. <select id="findCuratorTeacherDetailData" resultType="com.ssj.bean.conch.curator.dto.CuratorTeacherListDto">
  62. select lm.user_id teacher_id, group_concat(lm.type) teacher_type_list, group_concat(distinct course_name) subject,
  63. lm.name, lm.t_photo img_url, lm.telephone phone from tb_lib_manager lm
  64. where lm.state = 1 and lm.user_id=#{teacherId} and lm.type in
  65. <foreach collection="types" open="(" item="type" separator="," close=")">
  66. #{type}
  67. </foreach>
  68. group by lm.user_id
  69. </select>
  70. <!--老师详情-->
  71. <select id="findCuratorTeacherDetailDataV1" resultType="com.ssj.bean.conch.curator.dto.CuratorTeacherListDto">
  72. select lm.user_id teacher_id, group_concat(lm.type) teacher_type_list, group_concat(distinct course_name) subject,
  73. lm.name, lm.t_photo img_url, lm.telephone phone from tb_lib_manager lm
  74. where lm.state = 1 and lm.user_id=#{teacherId} and lm.lib_id=#{libId} and lm.type in
  75. <foreach collection="types" open="(" item="type" separator="," close=")">
  76. #{type}
  77. </foreach>
  78. group by lm.user_id
  79. </select>
  80. <!--查询老师详情的班级列表-->
  81. <select id="findTeacherDetailClassList" resultType="com.ssj.bean.conch.curator.dto.TeacherDetailClassListDto">
  82. select c.id class_id, c.class_name, if(c.status=2, 1, 0) is_default from tb_class_teacher ct
  83. left join tb_class c on ct.class_id=c.id
  84. where ct.teacher_id=#{teacherId} and ct.status=1 and c.status in (1, 2)
  85. </select>
  86. <!--查询老师详情的班级列表-->
  87. <select id="findTeacherDetailClassListV1" resultType="com.ssj.bean.conch.curator.dto.TeacherDetailClassListDto">
  88. select c.id class_id, c.class_name, if(c.status=2, 1, 0) is_default from tb_class_teacher ct
  89. left join tb_class c on ct.class_id=c.id
  90. where ct.teacher_id=#{teacherId} and ct.lib_id=#{libId} and ct.status=1 and c.status in (1, 2)
  91. </select>
  92. <!--查询班级列表的学生数-->
  93. <select id="findClassStudentCount" resultType="com.ssj.bean.conch.curator.dto.TeacherDetailClassListDto">
  94. select class_id, count(1) student_sum from tb_class_student t1 left join tb_lib_vip t2
  95. on t1.vip_id=t2.id
  96. where t1.class_id in
  97. <foreach collection="classIds" open="(" item="classId" separator="," close=")">
  98. #{classId}
  99. </foreach>
  100. and t1.lib_id=t2.lib_id
  101. and t1.status in(1,2)
  102. and t1.vip_id is not null
  103. group by t1.class_id
  104. </select>
  105. <!--查询班级列表的学生数-->
  106. <select id="findClassTeacherCount" resultType="com.ssj.bean.conch.curator.dto.TeacherDetailClassListDto">
  107. select class_id, count(1) teacher_sum from tb_class_teacher
  108. where class_id in
  109. <foreach collection="classIds" open="(" item="classId" separator="," close=")">
  110. #{classId}
  111. </foreach>
  112. and status = 1
  113. group by class_id
  114. </select>
  115. <!--查询老师不在的的班级列表-->
  116. <select id="findTeacherNotInClassList" resultType="com.ssj.bean.conch.curator.dto.TeacherDetailClassListDto">
  117. select class.id class_id, class.class_name, if(class.status=2, 1, 0) is_default from tb_class class
  118. left join tb_class_teacher teacher on class.id=teacher.class_id
  119. and teacher.status=1
  120. and teacher.teacher_id = #{teacherId}
  121. where class.lib_id=#{libId} and class.status in (1, 2) and teacher.id is null
  122. </select>
  123. <sql id="studentDetail">
  124. select t.class_name className,t.id classId, t2.id vipId,t2.child_name childName,t2.img_url imgUrl,t2.grade,t2.sex,t2.school,IF(t3.mobile is null,t2.phone,t3.mobile) phone,
  125. case when t4.stat = 2 or t4.stat is null then -1 else 0 end as correctType,
  126. case when t4.stat = 2 or t4.stat is null then 1 else 0 end sort_no
  127. from tb_lib_vip t2
  128. left join (select tc.class_name,tc.id,tcs.vip_id
  129. from tb_class_student tcs,tb_class tc
  130. where tcs.status in (1,2)
  131. and tcs.lib_id=#{libId}
  132. and tc.status=1
  133. and tcs.class_id=tc.id
  134. ) t on t2.id=t.vip_id
  135. left join tb_user t3 on t2.user_id=t3.id
  136. left join tb_lib_vip_service t4 on t2.id = t4.vip_id and t4.type='C025' and t4.species='S003'
  137. where 1=1
  138. and t4.lib_id=#{libId}
  139. </sql>
  140. <select id="findCorrectType" resultType="Integer">
  141. select IF(ts.species='S999',999,correct_type) from tb_lib_vip_service ts
  142. where ts.vip_id=#{vipId}
  143. and ts.stat = 1
  144. and ts.species in ('S003','S999')
  145. and to_days(ts.start_time) &lt;=to_days(now())
  146. and to_days(ts.end_time) >= to_days(now())
  147. ORDER BY ts.species,ts.service_sort,ts.correct_type,ts.start_time limit 1
  148. </select>
  149. <!--查询校区指定班级的学生-->
  150. <select id="findClassStudentDetail" resultType="java.util.Map">
  151. <include refid="studentDetail" />
  152. and t.id=#{classId}
  153. <if test="name != null and name != '' ">
  154. and t2.child_name regexp #{name}
  155. </if>
  156. order by convert(childName using gbk) asc
  157. </select>
  158. <!--查询校区所有学生,包含分班和未分班的-->
  159. <select id="findClassStudentDetailByLibId" resultType="java.util.Map">
  160. <include refid="studentDetail" />
  161. <if test="name != null and name != '' ">
  162. and t2.child_name regexp #{name}
  163. </if>
  164. order by sort_no,convert(childName using gbk) asc
  165. </select>
  166. <!--查询不在本班的其余学生列表,包含分班和未分班的-->
  167. <select id="findOtherClassStudentDetail" resultType="java.util.Map">
  168. <include refid="studentDetail" />
  169. and (t.id !=#{classId} or t.id is null)
  170. and t4.stat=1
  171. <if test="name != null and name != '' ">
  172. and t2.child_name regexp #{name}
  173. </if>
  174. order by sort_no,convert(childName using gbk) asc
  175. </select>
  176. <!--查询校区对应学生详情-->
  177. <select id="findStudentDetailByVipId" resultType="java.util.Map">
  178. <include refid="studentDetail" />
  179. and t2.id=#{vipId}
  180. limit 1
  181. </select>
  182. <select id="findClassList" resultType="java.util.Map">
  183. select t1.id classId,
  184. t1.class_name className,
  185. (select count(distinct t2.vip_id)
  186. from tb_class_student t2,
  187. tb_lib_subscribe ls
  188. where t2.class_id = t1.id
  189. and t2.status = 1
  190. and ls.vip_id = t2.vip_id
  191. and to_days(ls.ryke_time) = to_days(now())
  192. and ls.lib_id = #{libId}
  193. and ls.stat = '1'
  194. and ls.flow_stat in ('3', '4')
  195. and t2.vip_id is not null) signedStudentCount,
  196. (select count(distinct t2.vip_id)
  197. from tb_class_student t2,tb_lib_vip t3
  198. where t2.vip_id = t3.id
  199. and t2.lib_id = t3.lib_id
  200. and t2.class_id = t1.id
  201. and t2.status =1
  202. and t2.vip_id is not null) studentSum,
  203. (select count(distinct t3.teacher_id)
  204. from tb_class_teacher t3
  205. where t3.class_id = t1.id
  206. and t3.lib_id = t1.lib_id
  207. and t3.status = 1
  208. and exists(
  209. select t4.user_id
  210. from tb_lib_manager t4
  211. where t4.lib_id = t1.lib_id
  212. and t4.user_id = t3.teacher_id
  213. and t4.state = 1
  214. and t4.type in (2, 10, 15)
  215. and t4.is_cancelled = 0
  216. )
  217. and t3.teacher_id is not null) teacherSum
  218. from tb_class t1
  219. where t1.lib_id = #{libId}
  220. and t1.status =1
  221. order by t1.status desc, t1.create_time
  222. </select>
  223. <!--查询学生不在的的班级列表-->
  224. <select id="findStudentNotInClass" resultType="java.util.Map">
  225. select t1.id classId,t1.class_name className,
  226. (
  227. select count(distinct t2.vip_id) from tb_class_student t2 where
  228. t2.class_id=t1.id
  229. and t2.lib_id=t1.lib_id
  230. and t2.status =1
  231. and t2.vip_id is not null
  232. ) as studentSum,
  233. (
  234. select count(distinct t3.teacher_id) from tb_class_teacher t3
  235. where t3.class_id=t1.id and t3.lib_id=t1.lib_id
  236. and t3.status=1
  237. and exists(
  238. select t4.user_id from tb_lib_manager t4
  239. where t4.lib_id=t1.lib_id
  240. and t4.user_id=t3.teacher_id
  241. and t4.state=1
  242. and t4.type in(2,10,15)
  243. and t4.is_cancelled=0
  244. )
  245. and t3.teacher_id is not null
  246. ) as teacherSum
  247. from tb_class t1
  248. where
  249. <if test="libId != null and libId != '' ">
  250. t1.lib_id =#{libId}
  251. </if>
  252. <if test="classId != null and classId != '' ">
  253. and t1.id !=#{classId}
  254. </if>
  255. and t1.status =1
  256. order by t1.status desc,t1.create_time
  257. </select>
  258. <select id="getTodayStudentHomeworkSum" resultType="java.util.Map">
  259. select sum(case when s.is_delete = 0 then 1 else 0 end) homeworkNum,
  260. sum(case when s.is_delete = 0 and s.is_feedback = 1 then 1 else 0 end ) feedbackNum1,
  261. sum(case when s.is_delete = 0 and s.is_feedback = 0 and s.is_mark in(1,3) then 1 else 0 end ) feedbackNum2
  262. from scon_homework_picture s where s.vip_id = #{vipId} and s.is_delete = 0 and TO_DAYS(s.create_time) = TO_DAYS(NOW())
  263. </select>
  264. <select id="getUploadHomeworkSumByClassId" resultType="java.lang.Integer">
  265. select count(*) from (
  266. select s.vip_id from scon_homework_picture s where s.vip_id in (
  267. select t1.vip_id from tb_class t left join tb_class_student t1
  268. on t.id=t1.class_id
  269. left join tb_lib_vip t2
  270. on t1.vip_id=t2.id
  271. where t.id=#{classId}
  272. and t1.status=1
  273. and t1.lib_id=t2.lib_id
  274. and t2.stat=1)
  275. and s.create_time regexp #{date} and s.is_delete = 0 GROUP BY s.vip_id) as sss
  276. </select>
  277. <select id="getNoCorrectSumByClassId" resultType="java.lang.Integer">
  278. select count(*) from (
  279. select s.vip_id from scon_homework_picture s where s.vip_id in (
  280. select t1.vip_id from tb_class t left join tb_class_student t1
  281. on t.id=t1.class_id
  282. left join tb_lib_vip t2
  283. on t1.vip_id=t2.id
  284. where t.id=#{classId}
  285. and t1.status=1
  286. and t1.lib_id=t2.lib_id
  287. and t2.stat=1)
  288. and s.create_time regexp #{date} and s.is_delete = 0 and s.is_feedback = 0 and is_mark in (0, 2) GROUP BY s.vip_id) as sss
  289. </select>
  290. <select id="getStudentSumByClassId" resultType="java.lang.Integer">
  291. select count(*) from (
  292. select t1.vip_id from tb_class t left join tb_class_student t1
  293. on t.id=t1.class_id
  294. left join tb_lib_vip t2
  295. on t1.vip_id=t2.id
  296. where t.id=#{classId}
  297. and t1.status=1
  298. and t1.lib_id=t2.lib_id
  299. and t2.stat=1) as sss
  300. </select>
  301. <select id="renewStudentList" resultType="java.util.Map">
  302. select t.id vipId,
  303. t.child_name childName,
  304. t.img_url imgUrl,
  305. t.grade,
  306. (select concat(IF(ts.species = 'S999', 999, ts.correct_type), '#S', ts.end_time)
  307. from tb_lib_vip_service ts
  308. where ts.stat = 1
  309. and ts.species in ('S003', 'S999')
  310. and to_days(ts.start_time) &lt;= to_days(now())
  311. and to_days(ts.end_time) >= to_days(now())
  312. and t.id = ts.vip_id
  313. ORDER BY ts.species, ts.service_sort, ts.correct_type, ts.start_time
  314. limit 1
  315. ) serviceInfo,
  316. (select tc.class_name from tb_class_student tcs,tb_class tc
  317. where tcs.class_id = tc.id and t.id = tcs.vip_id and tcs.status = 1 and tc.status>0 limit 1) className
  318. from tb_lib_vip t
  319. where 1 = 1
  320. <if test="map.libId != null and map.libId != '' ">
  321. and t.lib_id=#{map.libId}
  322. </if>
  323. <if test="map.classIdList != null and map.classIdList.size() > 0">
  324. and exists(select 1 from tb_class_student tc where t.id = tc.vip_id and status = 1
  325. and tc.class_id in
  326. <foreach collection="map.classIdList" index="i" item="classId" open="(" close=")" separator=",">
  327. #{classId}
  328. </foreach>
  329. )
  330. </if>
  331. </select>
  332. <select id="getUploadHomeworkSumByLibId" resultType="java.lang.Integer">
  333. select count(*) from (
  334. select s.id from scon_homework_picture s where s.vip_id in (
  335. select t2.id from tb_lib_vip t2
  336. where t2.lib_id=#{libId}
  337. and t2.stat=1)
  338. and TO_DAYS(s.create_time) = TO_DAYS(NOW()) and s.is_delete = 0 GROUP BY s.vip_id) as sss
  339. </select>
  340. <select id="homeworkIndex" resultType="java.util.Map">
  341. select t11.vip_id,t.id,t12.child_name,t12.grade,t13.league_name,t12.school,count(1) as pictureCount,group_concat(t11.file_key) as file_keys,t11.create_time,t.`subject`
  342. ,count(IF(t11.corrected_picture_url is not null,true,null)) as correctedCount,group_concat(t11.corrected_picture_url) as corrected_keys
  343. ,count(IF(t.subject='语文',true,null)) as count1,count(IF(t.subject='数学',true,null)) as count2,count(IF(t.subject='英语',true,null)) as count3
  344. from scon_homework t
  345. left join scon_homework_picture t11 on t.id = t11.homework_id
  346. left join tb_lib_vip t12 on t11.vip_id = t12.id
  347. left join tb_lib_join t13 on t12.lib_id = t13.id
  348. where t11.create_time regexp #{queryDate}
  349. and t12.lib_id=#{libId} and t11.is_delete = 0
  350. <if test="searchValue != '' ">
  351. and t12.child_name regexp #{searchValue}
  352. </if>
  353. group by t11.vip_id
  354. order by t.subject,t11.create_time desc
  355. </select>
  356. <select id="findPageStudentList" resultType="java.util.Map">
  357. select distinct t.class_name className,t.id classId, t1.vip_id vipId,t2.child_name childName,t2.img_url imgUrl,t2.grade grade,t3.mobile phone
  358. from tb_class t left join tb_class_student t1
  359. on t.id=t1.class_id
  360. left join tb_lib_vip t2 on t1.vip_id=t2.id
  361. left join tb_user t3 on t2.user_id=t3.id
  362. left join tb_lib_vip_service t4 on t2.id = t4.vip_id
  363. where t.lib_id=#{map.libId}
  364. and t1.status=1
  365. and t2.stat=1
  366. <if test="map.searchValue != null and map.searchValue != '' ">
  367. and t2.child_name regexp #{map.searchValue}
  368. </if>
  369. <if test="map.startDate != null and map.startDate != '' ">
  370. and to_days(t4.end_time) >= to_days(#{map.startDate})
  371. </if>
  372. <if test="map.endDate != null and map.endDate != '' ">
  373. and to_days(#{map.endDate}) >= to_days(t4.end_time)
  374. </if>
  375. <if test="map.stat != null and map.stat != '' ">
  376. and t4.stat=#{map.stat}
  377. </if>
  378. <if test="map.classId != null and map.classId != '' ">
  379. and t.id=#{map.classId}
  380. </if>
  381. <if test="map.serviceType != null and map.serviceType != '' and map.serviceType=='S999'">
  382. and t4.species='S999'
  383. </if>
  384. <if test="map.serviceType != null and map.serviceType != '' and map.serviceType!='S999'">
  385. and t4.correct_type=#{map.serviceType}
  386. </if>
  387. group by t2.id
  388. </select>
  389. <select id="findServiceListByVipId" resultType="java.util.Map">
  390. select t.start_time,t.end_time,case when t.stat=1 then '有效' else '无效' end stat,
  391. case when t.species='S999' then '内部用户' when t.correct_type=0 then '无服务' when t.correct_type=1 then '平台服务(家长购买)'
  392. when t.correct_type=2 then '校区服务' when t.correct_type=4 then '平台服务(机构购买)' when t.correct_type=0 then '服务已关闭' else '批改服务'
  393. end as correct_type
  394. from tb_lib_vip_service t
  395. where t.vip_id=#{map.vipId} and t.species in ('S003', 'S999')
  396. <if test="map.startDate != null and map.startDate != '' ">
  397. and to_days(t.end_time) >= to_days(#{map.startDate})
  398. </if>
  399. <if test="map.endDate != null and map.endDate != '' ">
  400. and to_days(#{map.endDate}) >= to_days(t.end_time)
  401. </if>
  402. <if test="map.stat != null and map.stat != '' ">
  403. and t.stat=#{map.stat}
  404. </if>
  405. <if test="map.serviceType != null and map.serviceType != '' and map.serviceType=='S999'">
  406. and t.species='S999'
  407. </if>
  408. <if test="map.serviceType != null and map.serviceType != '' and map.serviceType!='S999'">
  409. and t.correct_type=#{map.serviceType}
  410. </if>
  411. order by t.end_time desc
  412. </select>
  413. <select id="findClassListBySys" resultType="java.util.Map">
  414. select t1.id classId,
  415. t1.class_name className,
  416. (select count(distinct t2.vip_id)
  417. from tb_class_student t2,
  418. tb_lib_subscribe ls
  419. where t2.class_id = t1.id
  420. and t2.status = 1
  421. and ls.vip_id = t2.vip_id
  422. and to_days(ls.ryke_time) = to_days(now())
  423. and ls.lib_id = #{libId}
  424. and ls.stat = '1'
  425. and ls.flow_stat in ('3', '4')
  426. and t2.vip_id is not null) signedStudentCount,
  427. (select count(distinct t2.vip_id)
  428. from tb_class_student t2,tb_lib_vip t3
  429. where t2.vip_id = t3.id
  430. and t2.lib_id = t3.lib_id
  431. and t2.class_id = t1.id
  432. and t2.status = 1
  433. and t2.vip_id is not null) studentSum,
  434. (select count(distinct t3.teacher_id)
  435. from tb_class_teacher t3
  436. where t3.class_id = t1.id
  437. and t3.lib_id = t1.lib_id
  438. and t3.status = 1
  439. and exists(
  440. select t4.user_id
  441. from tb_lib_manager t4
  442. where t4.lib_id = t1.lib_id
  443. and t4.user_id = t3.teacher_id
  444. and t4.state = 1
  445. and t4.type in (2, 10, 15)
  446. and t4.is_cancelled = 0
  447. )
  448. and t3.teacher_id is not null) teacherSum
  449. from tb_class t1
  450. where t1.lib_id = #{libId}
  451. and t1.status in (1, 2)
  452. <if test="searchValue != null and searchValue != '' ">
  453. and t1.class_name regexp #{searchValue}
  454. </if>
  455. <if test="teacherId != null and teacherId != '' ">
  456. and t1.id in (
  457. select class_id from tb_class_teacher where status = 1
  458. and teacher_id=#{teacherId}
  459. )
  460. </if>
  461. order by t1.status desc, t1.create_time
  462. </select>
  463. <select id="findCuratorTeacherListBySys" resultType="com.ssj.bean.conch.curator.dto.CuratorTeacherListDto">
  464. select lm.user_id teacher_id, group_concat(distinct lm.type) teacher_type_list, group_concat(distinct lm.course_name) subject,
  465. lm.name, lm.t_photo img_url, lm.telephone phone,count(distinct ct.class_id) as class_sum from tb_lib_manager lm
  466. left join tb_class_teacher ct on ct.teacher_id=lm.user_id and lm.lib_id = ct.lib_id and ct.status = 1
  467. where lm.type in
  468. <foreach collection="types" open="(" item="type" separator="," close=")">
  469. #{type}
  470. </foreach>
  471. <if test="searchKey != null and searchKey != '' ">
  472. and lm.name regexp #{searchKey}
  473. </if>
  474. <if test="classId != null and classId != '' ">
  475. and ct.class_id = #{classId}
  476. </if>
  477. and lm.state=1 and lm.lib_id=#{libId} and lm.is_cancelled = 0
  478. group by lm.user_id
  479. </select>
  480. <select id="findClassStudentScore" resultType="java.util.Map">
  481. select user_name name, img_url imgUrl,ifNull(ranking_num,0) rankNum, rowno as `index`, class_name className, vip_id vipId
  482. from (select a.child_name as user_name,
  483. a.img_url,
  484. a.vip_id,
  485. a.class_name,
  486. a.ranking_num,
  487. (@rowno := @rowno + 1) as rowno
  488. from (select tcs.vip_id ,shr.ranking_num ,tlv.child_name,tlv.img_url, c.class_name,shr.update_time
  489. from tb_class_student tcs left join scon_homework_ranking shr
  490. on tcs.vip_id=shr.vip_id
  491. left join tb_lib_vip tlv on tcs.vip_id=tlv.id
  492. join tb_class c on tcs.class_id = c.id
  493. where tlv.stat = 1
  494. <if test="classId != null and classId != '' ">
  495. and tcs.class_id = #{classId}
  496. </if>
  497. and tcs.lib_id=#{libId}
  498. and tcs.status=1) as a,
  499. (select @rowno := 0) as row
  500. order by a.ranking_num desc, a.update_time desc) as temp
  501. </select>
  502. <select id="allLibIndex" resultType="java.util.Map">
  503. select count(1) as totolCount,count(if(t.subject='语文',true,null)) as chineseCount,count(if(t.subject='数学',true,null)) as shuxueCount,count(if(t.subject='英语',true,null)) as englishCount from
  504. scon_homework_picture t
  505. left join tb_lib_vip t1 on t.vip_id = t1.id
  506. where t.is_delete = 0 and t1.lib_id is not null
  507. <if test="queryDate != null and queryDate != '' ">
  508. and t.create_time regexp #{queryDate}
  509. </if>
  510. </select>
  511. <select id="searchHomeworkAllTop" resultType="java.util.Map">
  512. SELECT sum(totolCount) as totolCount,a.lib_id,b.league_name from (
  513. select count(1) as totolCount,t1.lib_id
  514. from scon_homework_picture t
  515. left join tb_lib_vip t1 on t.vip_id = t1.id
  516. where is_delete = 0 and t1.lib_id is not null
  517. <if test="startDate != null and startDate != '' ">
  518. and t.create_time >= #{startDate}
  519. </if>
  520. <if test="endDate != null and endDate != '' ">
  521. and #{endDate} >= t.create_time
  522. </if>
  523. <if test="subject != null and subject != '' ">
  524. and t.subject = #{subject}
  525. </if>
  526. group by t1.lib_id
  527. order by totolCount desc)a join tb_lib_join b on a.lib_id = b.id
  528. GROUP BY a.lib_id
  529. order by totolCount desc
  530. </select>
  531. <select id="searchActiveTop" resultType="java.util.Map">
  532. select t2.league_name,t1.lib_id ,
  533. (select count(1) from tb_lib_vip a where a.lib_id = t1.lib_id) as all_vips,
  534. count(distinct t.vip_id) as active_count
  535. from scon_homework t
  536. left join tb_lib_vip t1 on t.vip_id = t1.id
  537. join tb_lib_join t2 on t1.lib_id = t2.id
  538. where t1.lib_id is not null
  539. <if test="startDate != null and startDate != '' ">
  540. and t.create_time >= #{startDate}
  541. </if>
  542. <if test="endDate != null and endDate != '' ">
  543. and #{endDate} >= t.create_time
  544. </if>
  545. group by t1.lib_id
  546. </select>
  547. </mapper>