StudentReportRecordMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.xjrsoft.module.student.mapper.StudentReportRecordMapper">
  6. <select id="getClassStatistics" parameterType="com.xjrsoft.module.student.dto.StudentReportRecordStatisticsDto"
  7. resultType="com.xjrsoft.module.student.vo.StudentReportRecordStatisticsVo">
  8. SELECT t1.name AS class_name,t2.name AS teacher_name,
  9. (
  10. SELECT COUNT(*) FROM xjr_user a1
  11. INNER JOIN base_student_school_roll a2 ON a1.id = a2.user_id
  12. WHERE a1.delete_mark = 0 AND a2.delete_mark = 0
  13. AND a2.class_id = t1.id
  14. ) AS all_count,
  15. (
  16. SELECT COUNT(*) FROM xjr_user a1
  17. INNER JOIN base_student_school_roll a2 ON a1.id = a2.user_id
  18. WHERE a1.delete_mark = 0 AND a2.delete_mark = 0
  19. AND a1.gender = 'SB10001' AND a2.class_id = t1.id
  20. ) AS male_count,
  21. (
  22. SELECT COUNT(*) FROM xjr_user a1
  23. INNER JOIN base_student_school_roll a2 ON a1.id = a2.user_id
  24. WHERE a1.delete_mark = 0 AND a2.delete_mark = 0
  25. AND a1.gender = 'SB10002' AND a2.class_id = t1.id
  26. ) AS female_count,
  27. (
  28. SELECT COUNT(distinct(a1.id)) FROM xjr_user a1
  29. INNER JOIN base_student_school_roll a2 ON a1.id = a2.user_id
  30. INNER JOIN student_report_record a3 ON a1.id = a3.user_id
  31. WHERE a1.delete_mark = 0 AND a2.delete_mark = 0 and a3.delete_mark = 0
  32. AND a2.class_id = t1.id AND a3.base_semester_id = #{dto.baseSemesterId} AND a3.report_time IS NOT NULL
  33. <if test="dto.studentReportPlanId != null">
  34. and a3.student_report_plan_id = #{dto.studentReportPlanId}
  35. </if>
  36. ) AS arrived_count
  37. FROM base_class t1
  38. INNER JOIN xjr_user t2 ON t1.teacher_id = t2.id
  39. WHERE t1.delete_mark = 0
  40. <if test="dto.teacherId != null">
  41. AND t1.teacher_id = #{dto.teacherId}
  42. </if>
  43. <if test="dto.gradeId != null">
  44. and t1.grade_id = #{dto.gradeId}
  45. </if>
  46. <if test="dto.classId != null">
  47. AND t1.id = #{dto.classId}
  48. </if>
  49. </select>
  50. <select id="getMobilePage" parameterType="com.xjrsoft.module.student.dto.StudentReportRecordPageDto"
  51. resultType="com.xjrsoft.module.student.vo.StudentReportRecordPageVo">
  52. SELECT t1.id as user_id,t1.name,t1.credential_number,t1.mobile,t4.name AS stduy_status_cn,t5.telephone AS parent_mobile,t2.graduated_university,
  53. (select count(*) from student_report_record where user_id = t1.id and base_semester_id = #{dto.baseSemesterId} and delete_mark = 0) as is_report FROM xjr_user t1
  54. INNER JOIN base_student_school_roll t2 ON t1.id = t2.user_id
  55. INNER JOIN base_class t3 ON t2.class_id = t3.id
  56. LEFT JOIN xjr_dictionary_detail t4 ON t2.stduy_status = t4.code
  57. LEFT JOIN base_student_family t5 ON t5.user_id = t1.id
  58. WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
  59. AND t3.teacher_id = #{dto.teacherId} and t2.grade_id = #{dto.gradeId}
  60. <if test="dto.keyword != null and dto.keyword != ''">
  61. and t1.name like concat('%', #{dto.keyword},'%')
  62. </if>
  63. <if test="dto.classId != null">
  64. and t3.id = #{dto.classId}
  65. </if>
  66. ORDER BY t1.create_date DESC, t2.create_date DESC,t3.create_date DESC,t1.id
  67. </select>
  68. <select id="getPlanPage" parameterType="com.xjrsoft.module.student.dto.StudentReportRecordPageDto" resultType="com.xjrsoft.module.student.vo.StudentReportRecordPlanPageVo">
  69. SELECT t1.id, t1.user_id, t4.name AS grade_name,t5.name AS class_name,t6.name AS teacher_name,
  70. t3.name,t7.name AS gender,t3.credential_number,t3.mobile,t8.name AS student_type_cn,
  71. t9.name AS stduy_status_cn,t10.name AS archives_status_cn,
  72. t1.report_time,IF(t1.report_time IS NULL, 0, 1) as is_report,
  73. (SELECT telephone FROM base_student_family WHERE delete_mark = 0 AND user_id = t1.user_id ORDER BY create_date ASC LIMIT 0,1) as parent_mobile
  74. FROM student_report_record t1
  75. INNER JOIN base_student_school_roll t2 ON t1.user_id = t2.user_id
  76. INNER JOIN xjr_user t3 ON t3.id = t1.user_id
  77. LEFT JOIN base_grade t4 ON t2.grade_id = t4.id
  78. LEFT JOIN base_class t5 ON t2.class_id = t5.id
  79. LEFT JOIN xjr_user t6 ON t5.teacher_id = t6.id
  80. LEFT JOIN xjr_dictionary_detail t7 ON t3.gender = t7.code
  81. LEFT JOIN xjr_dictionary_detail t8 ON t2.student_type = t8.code
  82. LEFT JOIN xjr_dictionary_detail t9 ON t2.stduy_status = t9.code
  83. LEFT JOIN xjr_dictionary_detail t10 ON t2.archives_status = t10.code
  84. WHERE t1.delete_mark = 0 AND t1.enabled_mark = 1
  85. and t1.student_report_plan_id = #{dto.studentReportPlanId}
  86. <if test="dto.keyword != null and dto.keyword != ''">
  87. and t1.name like concat('%', #{dto.keyword},'%')
  88. </if>
  89. <if test="dto.classId != null">
  90. and t5.id = #{dto.classId}
  91. </if>
  92. <if test="dto.gradeId != null">
  93. and t4.id = #{dto.gradeId}
  94. </if>
  95. <if test="dto.name != null and dto.name != ''">
  96. and t3.name like concat('%', #{dto.name}, '%')
  97. </if>
  98. <if test="dto.className != null and dto.className != ''">
  99. and t5.name like concat('%', #{dto.className}, '%')
  100. </if>
  101. <if test="dto.credentialNumber != null and dto.credentialNumber != ''">
  102. and t3.credentialNumber like concat('%', #{dto.credentialNumber}, '%')
  103. </if>
  104. <if test="dto.archivesStatus != null and dto.archivesStatus != ''">
  105. and t2.archives_status = #{dto.archivesStatus}
  106. </if>
  107. <if test="dto.stduyStatus != null and dto.stduyStatus != ''">
  108. and t2.stduy_status = #{dto.stduyStatus}
  109. </if>
  110. <if test="dto.studentType != null and dto.studentType != ''">
  111. and t2.student_type = #{dto.studentType}
  112. </if>
  113. <if test="dto.studentType != null and dto.studentType != ''">
  114. and t2.student_type = #{dto.studentType}
  115. </if>
  116. <if test="dto.isReport != null">
  117. <if test="dto.isReport == 1">
  118. and t1.report_time is not null
  119. </if>
  120. <if test="dto.isReport == 0">
  121. and t1.report_time is null
  122. </if>
  123. </if>
  124. <if test="dto.reportTimeStart != null and dto.reportTimeEnd != null">
  125. and t1.report_time between #{dto.reportTimeStart} and #{dto.reportTimeEnd}
  126. </if>
  127. ORDER BY t1.report_time IS NULL DESC, t1.report_time DESC,t5.name
  128. </select>
  129. <select id="getPlanPageList" parameterType="com.xjrsoft.module.student.dto.StudentReportRecordPageDto" resultType="com.xjrsoft.module.student.vo.StudentReportRecordPlanPageVo">
  130. SELECT t1.id, t1.user_id, t4.name AS grade_name,t5.name AS class_name,t6.name AS teacher_name,
  131. t3.name,t7.name AS gender,t3.credential_number,t3.mobile,t8.name AS student_type_cn,
  132. t9.name AS stduy_status_cn,t10.name AS archives_status_cn,
  133. t1.report_time,IF(t1.report_time IS NULL, 0, 1) as is_report,
  134. (SELECT mobile FROM base_student_family_member WHERE delete_mark = 0 AND user_id = t1.user_id ORDER BY create_date ASC LIMIT 0,1) as parent_mobile
  135. FROM student_report_record t1
  136. INNER JOIN base_student_school_roll t2 ON t1.user_id = t2.user_id
  137. INNER JOIN xjr_user t3 ON t3.id = t1.user_id
  138. LEFT JOIN base_grade t4 ON t2.grade_id = t4.id
  139. LEFT JOIN base_class t5 ON t2.class_id = t5.id
  140. LEFT JOIN xjr_user t6 ON t5.teacher_id = t6.id
  141. LEFT JOIN xjr_dictionary_detail t7 ON t3.gender = t7.code
  142. LEFT JOIN xjr_dictionary_detail t8 ON t2.student_type = t8.code
  143. LEFT JOIN xjr_dictionary_detail t9 ON t2.stduy_status = t9.code
  144. LEFT JOIN xjr_dictionary_detail t10 ON t2.archives_status = t10.code
  145. WHERE t1.delete_mark = 0 AND t1.enabled_mark = 1
  146. and t1.student_report_plan_id = #{dto.studentReportPlanId}
  147. <if test="dto.keyword != null and dto.keyword != ''">
  148. and t1.name like concat('%', #{dto.keyword},'%')
  149. </if>
  150. <if test="dto.classId != null">
  151. and t5.id = #{dto.classId}
  152. </if>
  153. <if test="dto.gradeId != null">
  154. and t4.id = #{dto.gradeId}
  155. </if>
  156. <if test="dto.name != null and dto.name != ''">
  157. and t3.name like concat('%', #{dto.name}, '%')
  158. </if>
  159. <if test="dto.className != null and dto.className != ''">
  160. and t5.name like concat('%', #{dto.className}, '%')
  161. </if>
  162. <if test="dto.credentialNumber != null and dto.credentialNumber != ''">
  163. and t3.credentialNumber like concat('%', #{dto.credentialNumber}, '%')
  164. </if>
  165. <if test="dto.archivesStatus != null and dto.archivesStatus != ''">
  166. and t2.archives_status = #{dto.archivesStatus}
  167. </if>
  168. <if test="dto.stduyStatus != null and dto.stduyStatus != ''">
  169. and t2.stduy_status = #{dto.stduyStatus}
  170. </if>
  171. <if test="dto.studentType != null and dto.studentType != ''">
  172. and t2.student_type = #{dto.studentType}
  173. </if>
  174. <if test="dto.studentType != null and dto.studentType != ''">
  175. and t2.student_type = #{dto.studentType}
  176. </if>
  177. <if test="dto.isReport != null">
  178. <if test="dto.isReport == 1">
  179. and t1.report_time is not null
  180. </if>
  181. <if test="dto.isReport == 0">
  182. and t1.report_time is null
  183. </if>
  184. </if>
  185. <if test="dto.reportTimeStart != null and dto.reportTimeEnd != null">
  186. and t1.report_time between #{dto.reportTimeStart} and #{dto.reportTimeEnd}
  187. </if>
  188. ORDER BY t1.report_time IS NULL DESC, t1.report_time DESC,t5.name
  189. </select>
  190. <select id="getStatisticsDataList" parameterType="com.xjrsoft.module.student.dto.StudentReportRecordStatisticsDto"
  191. resultType="com.xjrsoft.module.student.vo.StudentReportRecordStatisticsListVo">
  192. SELECT t1.name,t1.credential_number,t2.gender,t4.graduated_university,t4.stduy_status,t5.report_time ,
  193. t6.name AS class_name,t8.name as class_type,t7.name AS major_name,t9.name as dept_name FROM base_new_student t1
  194. INNER JOIN xjr_user t2 ON t1.credential_number = t2.credential_number
  195. INNER JOIN enrollment_plan t3 ON t3.id = t1.enrollment_plan_id
  196. INNER JOIN base_student_school_roll t4 ON t4.user_id = t2.id
  197. LEFT JOIN student_report_record t5 ON t2.id = t5.user_id AND t5.delete_mark = 0
  198. INNER JOIN base_class t6 ON t6.id = t4.class_id
  199. INNER JOIN base_major_set t7 ON t7.id = t6.major_set_id
  200. left join xjr_dictionary_detail t8 on t6.class_type = t8.code and t8.item_id = 2023000000000000039
  201. INNER JOIN xjr_department t9 ON t9.id = t6.org_id
  202. WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
  203. AND t3.grade_id = #{dto.gradeId} AND t3.enroll_type = #{dto.enrollType}
  204. AND (t1.delete_reason IS NULL OR t1.delete_reason = '')
  205. AND t2.delete_mark = 0
  206. </select>
  207. </mapper>