CuratorMapper.xml 25 KB

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