BaseStudentAssessmentInspectionMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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.BaseStudentAssessmentInspectionMapper">
  6. <select id="getPage" parameterType="com.xjrsoft.module.student.dto.BaseStudentAssessmentInspectionPageDto" resultType="com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionPageVo">
  7. SELECT t.id,t.score,t.total_score,t.score_type,t.assessment_date,t.reason,t1.name AS assessment_category_name,t2.name AS assessment_project_name,t3.name AS semester_name,t4.name AS grade_name,t5.name AS assessment_user_name,t6.name AS score_type_cn,
  8. (
  9. SELECT NAME FROM base_class
  10. WHERE id = t.class_ids
  11. ) AS assessment_class_names,
  12. (
  13. (LENGTH(personal_student_user_ids) - LENGTH(REPLACE(personal_student_user_ids, ',', '')))
  14. ) + 1 AS student_count,t.enabled_mark,t.assessment_type
  15. FROM base_student_assessment_inspection t
  16. LEFT JOIN base_student_assessment_category t1 ON (t1.id = t.base_student_assessment_category_id)
  17. LEFT JOIN base_student_assessment_project t2 ON (t2.id = t.base_student_assessment_project_id)
  18. LEFT JOIN base_semester t3 ON t.base_semester_id = t3.id AND t3.delete_mark = 0
  19. LEFT JOIN base_grade t4 ON t.grade_id = t4.id
  20. LEFT JOIN xjr_user t5 ON t.assessment_user_id = t5.id
  21. LEFT JOIN xjr_dictionary_detail t6 ON t6.code= t.score_type
  22. LEFT JOIN base_class t7 ON t7.id = CAST(t.class_ids AS SIGNED)
  23. WHERE t.delete_mark = 0 AND t.delete_mark = 0 AND t2.delete_mark = 0
  24. <if test="dto.projectIds != null">
  25. and t.base_student_assessment_category_id = #{dto.projectIds}
  26. </if>
  27. <if test="dto.gradeId != null">
  28. and t.grade_id = #{dto.gradeId}
  29. </if>
  30. <if test="dto.semesterId != null">
  31. and t.base_semester_id = #{dto.semesterId}
  32. </if>
  33. <if test="dto.startDate != null">
  34. and t.assessment_date &gt;= #{dto.startDate}
  35. </if>
  36. <if test="dto.endDate != null">
  37. and t.assessment_date &lt;= #{dto.endDate}
  38. </if>
  39. <if test="dto.assessmentUserName != null and dto.assessmentUserName != ''">
  40. and t5.name like concat('%',#{dto.assessmentUserName},'%')
  41. </if>
  42. <if test="dto.assessmentType != null and dto.assessmentType != ''">
  43. and t.assessment_type like concat('%',#{dto.assessmentType},'%')
  44. </if>
  45. <if test="dto.teacherId != null">
  46. and t7.teacher_id = #{dto.teacherId}
  47. </if>
  48. </select>
  49. <select id="getInfo" resultType="com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionVo">
  50. select t.id,t.score,t.score_type,t.assessment_date,t.reason,t1.name as assessment_category_name,t2.name as assessment_project_name,
  51. t3.name as semester_name,t4.name as grade_name,t5.name as assessment_user_name,t6.name as score_type_cn,t.file_id,t7.name as create_user_name
  52. ,t.total_score
  53. from base_student_assessment_inspection t
  54. left join base_student_assessment_category t1 on (t1.id = t.base_student_assessment_category_id)
  55. left join base_student_assessment_project t2 on (t2.id = t.base_student_assessment_project_id)
  56. left join base_semester t3 on t.base_semester_id=t3.id
  57. left join base_grade t4 on t.grade_id=t4.id
  58. left join xjr_user t5 on t.assessment_user_id=t5.id
  59. left join xjr_dictionary_detail t6 on t6.code=t.score_type
  60. left join xjr_user t7 on t.create_user_id=t7.id
  61. where t.id=#{id} and t.delete_mark=0 and t1.delete_mark=0 and t2.delete_mark=0;
  62. </select>
  63. <select id="getMobilePage" parameterType="com.xjrsoft.module.student.dto.BaseStudentAssessmentInspectionMobilePageDto" resultType="com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionMobilePageVo">
  64. select t.id,t1.assessment_date,t2.name as assessment_category_name,t3.name as assessment_project_name,t5.name as
  65. assessment_class_name,t1.reason,t1.score,t1.score_type,t4.name as score_type_cn,
  66. (
  67. SELECT count(*) FROM base_student_assessment_student_relation WHERE base_student_assessment_inspection_id =
  68. t1.id and class_id=t.class_id
  69. ) as student_count
  70. from base_student_assessment_class_relation t
  71. left join base_student_assessment_inspection t1 on t1.id=t.base_student_assessment_inspection_id
  72. left join base_student_assessment_category t2 on (t2.id = t1.base_student_assessment_category_id)
  73. left join base_student_assessment_project t3 on (t3.id = t1.base_student_assessment_project_id)
  74. left join xjr_dictionary_detail t4 on t4.code=t1.score_type
  75. left join base_class t5 on t5.id=t.class_id
  76. where t1.delete_mark = 0 and t.class_id in
  77. <foreach item="classId" index="index" collection="dto.classIds" open="(" close=")" separator=",">
  78. #{classId}
  79. </foreach>
  80. <if test="dto.projectIds != null and dto.projectIds.size() > 0">
  81. and t1.base_student_assessment_project_id in
  82. <foreach item="projectId" index="index" collection="dto.projectIds" open="(" close=")" separator=",">
  83. #{projectId}
  84. </foreach>
  85. </if>
  86. <if test="dto.startDate != null and dto.startDate != ''">
  87. and t1.assessment_date &gt;= #{dto.startDate}
  88. </if>
  89. <if test="dto.endDate != null and dto.endDate != ''">
  90. and t1.assessment_date &lt;= #{dto.endDate}
  91. </if>
  92. </select>
  93. <select id="getMobileInfo" resultType="com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionMobileVo">
  94. select t.id,t.class_id,t.base_student_assessment_inspection_id,t1.score,t5.name as assessment_class_name,t2.name as assessment_category_name,t3.name as assessment_project_name,t1.assessment_date,t1.reason,
  95. t6.name as assessment_user_name,t7.name as create_user_name,t1.create_date,t1.file_id,t1.score_type,t4.name as score_type_cn
  96. from base_student_assessment_class_relation t
  97. left join base_student_assessment_inspection t1 on t1.id=t.base_student_assessment_inspection_id
  98. left join base_student_assessment_category t2 on (t2.id = t1.base_student_assessment_category_id)
  99. left join base_student_assessment_project t3 on (t3.id = t1.base_student_assessment_project_id)
  100. left join xjr_dictionary_detail t4 on t4.code=t1.score_type
  101. left join base_class t5 on t5.id=t.class_id
  102. left join xjr_user t6 on t1.assessment_user_id=t6.id
  103. left join xjr_user t7 on t1.create_user_id=t7.id
  104. where t.id=#{id};
  105. </select>
  106. <select id="getStudentIndividualBehaviorExcelVoList" parameterType="com.xjrsoft.module.student.dto.QuantitativeAssessmentExcelDto" resultType="com.xjrsoft.module.student.vo.QuantitativeAssessmentSubTableExcelVo">
  107. with total_score as (
  108. select
  109. t.user_id as studentUserId,
  110. sum(if(t1.score_type = 'score_add', t1.score, -1 * t1.score)) as finalScore
  111. from base_student_assessment_student_relation t
  112. left join base_student_assessment_inspection t1 on t1.id = t.base_student_assessment_inspection_id
  113. where t1.delete_mark = 0
  114. <if test="dto.yearAndMonth != null and dto.yearAndMonth != ''">
  115. and date_format(t1.assessment_date, '%Y-%m') = #{dto.yearAndMonth}
  116. </if>
  117. group by t.user_id
  118. )
  119. select
  120. t4.id as headTeacherUserId,
  121. t4.user_name as headTeacherUserName,
  122. t4.name as headTeacherName,
  123. t.class_id as classId,
  124. t.class_name as className,
  125. t.user_id as studentUserId,
  126. t.student_id as studentId,
  127. t.name as studentName,
  128. t5.base_score as baseScore,
  129. t2.id as baseStudentAssessmentProjectId,
  130. t2.name as baseStudentAssessmentProjectIdCN,
  131. t1.assessment_date as assessmentDate,
  132. if(t1.score_type = 'score_add', t1.score, -1 * t1.score) as projectScore,
  133. t5.base_score + t6.finalScore as finalScore
  134. from base_student_assessment_student_relation t
  135. left join base_student_assessment_inspection t1 on t1.id = t.base_student_assessment_inspection_id
  136. left join base_student_assessment_project t2 on t2.id = t1.base_student_assessment_project_id
  137. left join base_class t3 on t3.id = t.class_id
  138. left join xjr_user t4 on t4.id = t3.teacher_id
  139. left join base_student_assessment_base_score t5 on t5.base_semester_id = t1.base_semester_id
  140. left join total_score t6 on t6.studentUserId = t.user_id
  141. where t1.delete_mark = 0
  142. <if test="dto.yearAndMonth != null and dto.yearAndMonth != ''">
  143. and date_format(t1.assessment_date, '%Y-%m') = #{dto.yearAndMonth}
  144. </if>
  145. order by t.class_id, t.user_id
  146. </select>
  147. <select id="getQuantitativeAssessmentSubTableExcelVoList" parameterType="com.xjrsoft.module.student.dto.QuantitativeAssessmentExcelDto" resultType="com.xjrsoft.module.student.vo.QuantitativeAssessmentSubTableExcelVo">
  148. with total_score as (select t.user_id as studentUserId,
  149. sum(if(t1.score_type = 'score_add', t1.score, -1 * t1.score)) as finalScore
  150. from base_student_assessment_student_relation t
  151. left join base_student_assessment_inspection t1
  152. on t1.id = t.base_student_assessment_inspection_id
  153. where t1.delete_mark = 0
  154. and t1.base_student_assessment_category_id = #{dto.baseStudentAssessmentCategoryId}
  155. <if test="dto.classIdList != null and !dto.classIdList.isEmpty()">
  156. and t1.class_ids in
  157. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")" separator=",">
  158. #{classId}
  159. </foreach>
  160. </if>
  161. <if test="dto.baseStudentAssessmentCategoryId != null and dto.baseStudentAssessmentCategoryId > 0">
  162. and t1.base_student_assessment_category_id = #{dto.baseStudentAssessmentCategoryId}
  163. </if>
  164. <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
  165. and t1.base_semester_id &gt; #{dto.baseSemesterId}
  166. </if>
  167. <if test="dto.startTime != null">
  168. and t1.create_date &gt; #{dto.startTime}
  169. </if>
  170. <if test="dto.endTime != null">
  171. and t1.create_date &lt; #{dto.endTime}
  172. </if>
  173. group by t.user_id)
  174. select t4.id as headTeacherUserId,
  175. t4.user_name as headTeacherUserName,
  176. t4.name as headTeacherName,
  177. t.class_id as classId,
  178. t.class_name as className,
  179. t.user_id as studentUserId,
  180. t.student_id as studentId,
  181. t.name as studentName,
  182. t5.base_score as baseScore,
  183. t2.id as baseStudentAssessmentProjectId,
  184. t2.name as baseStudentAssessmentProjectIdCN,
  185. t1.assessment_date as assessmentDate,
  186. if(t1.score_type = 'score_add', t1.score, -1 * t1.score) as projectScore,
  187. t5.base_score + t6.finalScore as finalScore
  188. from base_student_assessment_student_relation t
  189. left join base_student_assessment_inspection t1 on t1.id = t.base_student_assessment_inspection_id
  190. left join base_student_assessment_project t2 on t2.id = t1.base_student_assessment_project_id
  191. left join base_class t3 on t3.id = t.class_id
  192. left join xjr_user t4 on t4.id = t3.teacher_id
  193. left join base_student_assessment_base_score t5 on t5.base_semester_id = t1.base_semester_id
  194. left join total_score t6 on t6.studentUserId = t.user_id
  195. where t1.delete_mark = 0
  196. and t1.base_student_assessment_category_id = #{dto.baseStudentAssessmentCategoryId}
  197. <if test="dto.classIdList != null and !dto.classIdList.isEmpty()">
  198. and t1.class_ids in
  199. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")" separator=",">
  200. #{classId}
  201. </foreach>
  202. </if>
  203. <if test="dto.baseStudentAssessmentCategoryId != null and dto.baseStudentAssessmentCategoryId > 0">
  204. and t1.base_student_assessment_category_id = #{dto.baseStudentAssessmentCategoryId}
  205. </if>
  206. <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
  207. and t1.base_semester_id &gt; #{dto.baseSemesterId}
  208. </if>
  209. <if test="dto.startTime != null">
  210. and t1.create_date &gt; #{dto.startTime}
  211. </if>
  212. <if test="dto.endTime != null">
  213. and t1.create_date &lt; #{dto.endTime}
  214. </if>
  215. order by t.class_id, t.user_id
  216. </select>
  217. <select id="getAssessmentInspectionByClassIdList" parameterType="com.xjrsoft.module.student.dto.QuantitativeAssessmentSingleScoreDto" resultType="com.xjrsoft.module.student.vo.QuantitativeAssessmentSingleScoreVo">
  218. select
  219. t.class_ids as class_id,
  220. SUM(t.score * (LENGTH(personal_student_user_ids) - LENGTH(REPLACE(personal_student_user_ids, ',', '')) + 1)) AS sumScore
  221. from base_student_assessment_inspection t
  222. where t.delete_mark = 0
  223. <if test="dto.classIdList != null and !dto.classIdList.isEmpty()">
  224. and t.class_ids in
  225. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")" separator=",">
  226. #{classId}
  227. </foreach>
  228. </if>
  229. <if test="dto.baseStudentAssessmentCategoryId != null and dto.baseStudentAssessmentCategoryId > 0">
  230. and t.base_student_assessment_category_id = #{dto.baseStudentAssessmentCategoryId}
  231. </if>
  232. <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
  233. and t.base_semester_id &gt; #{dto.baseSemesterId}
  234. </if>
  235. <if test="dto.startTime != null">
  236. and t.create_date &gt; #{dto.startTime}
  237. </if>
  238. <if test="dto.endTime != null">
  239. and t.create_date &lt; #{dto.endTime}
  240. </if>
  241. group by t.class_ids;
  242. </select>
  243. <select id="getConventionalManagementList" parameterType="com.xjrsoft.module.student.dto.QuantitativeAssessmentSingleScoreDto" resultType="com.xjrsoft.module.student.vo.QuantitativeAssessmentSingleScoreVo">
  244. select
  245. t.class_id as classId,
  246. sum(t1.score) as score
  247. from base_student_assessment_class_relation t
  248. left join base_student_assessment_inspection t1 on t1.id = t.base_student_assessment_inspection_id
  249. left join base_student_assessment_category t2 on t2.id = t1.base_student_assessment_category_id
  250. where t1.base_student_assessment_category_id = 1754411705233838080
  251. and t.class_id in
  252. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")" separator=",">
  253. #{classId}
  254. </foreach>
  255. <if test="dto.startTime != null">
  256. and t1.create_date &gt; #{dto.startTime}
  257. </if>
  258. <if test="dto.endTime != null">
  259. and t1.create_date &lt; #{dto.endTime}
  260. </if>
  261. group by t.class_id;
  262. </select>
  263. <select id="getAwardsAndHonorList" parameterType="com.xjrsoft.module.student.dto.QuantitativeAssessmentSingleScoreDto" resultType="com.xjrsoft.module.student.vo.QuantitativeAssessmentSingleScoreVo">
  264. select
  265. t.class_id as classId,
  266. sum(t1.score) as score
  267. from base_student_assessment_student_relation t
  268. left join base_student_assessment_inspection t1 on t1.id = t.base_student_assessment_inspection_id
  269. left join base_student_assessment_category t2 on t2.id = t1.base_student_assessment_category_id
  270. where t1.base_student_assessment_category_id = 1754412347985760256
  271. and t.class_id in
  272. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")" separator=",">
  273. #{classId}
  274. </foreach>
  275. <if test="dto.startTime != null">
  276. and t1.create_date &gt; #{dto.startTime}
  277. </if>
  278. <if test="dto.endTime != null">
  279. and t1.create_date &lt; #{dto.endTime}
  280. </if>
  281. group by t.class_id;
  282. </select>
  283. <select id="getParamilitaryList" parameterType="com.xjrsoft.module.student.dto.QuantitativeAssessmentSingleScoreDto" resultType="com.xjrsoft.module.student.vo.QuantitativeAssessmentSingleScoreVo">
  284. select
  285. t.class_id as classId,
  286. sum(t1.score) as score
  287. from base_student_assessment_student_relation t
  288. left join base_student_assessment_inspection t1 on t1.id = t.base_student_assessment_inspection_id
  289. left join base_student_assessment_category t2 on t2.id = t1.base_student_assessment_category_id
  290. where t1.base_student_assessment_category_id = 1754412347985760256
  291. and t.class_id in
  292. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")" separator=",">
  293. #{classId}
  294. </foreach>
  295. <if test="dto.startTime != null">
  296. and t1.create_date &gt; #{dto.startTime}
  297. </if>
  298. <if test="dto.endTime != null">
  299. and t1.create_date &lt; #{dto.endTime}
  300. </if>
  301. group by t.class_id;
  302. </select>
  303. <select id="getStudentListByInspectionId"
  304. resultType="com.xjrsoft.module.student.entity.BaseStudentAssessmentStudentRelation">
  305. SELECT t1.id,t1.user_id,t1.class_id,t3.student_id,t2.name,t6.name AS nation,t4.name AS class_name,
  306. t5.name AS major_name,t7.name as gender,t1.score
  307. FROM base_student_assessment_student_relation t1
  308. INNER JOIN xjr_user t2 ON t1.user_id = t2.id
  309. INNER JOIN base_student t3 ON t2.id = t3.user_id
  310. INNER JOIN base_class t4 ON t4.id = t1.class_id
  311. INNER JOIN base_major_set t5 ON t4.major_set_id = t5.id
  312. LEFT JOIN xjr_dictionary_detail t6 ON t3.nation = t6.code
  313. LEFT JOIN xjr_dictionary_detail t7 ON t2.gender = t7.code
  314. WHERE t1.base_student_assessment_inspection_id = #{id}
  315. </select>
  316. </mapper>