BaseStudentAssessmentInspectionMapper.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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 and t.enabled_mark = 1
  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 and t.enabled_mark = 1
  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
  68. base_student_assessment_inspection_id = t1.id AND class_id = t.class_id AND delete_mark = 0 and enabled_mark = 1
  69. ) AS student_count,t1.assessment_type,
  70. (
  71. SELECT COUNT(*) FROM base_student_assessment_student_relation WHERE base_student_assessment_inspection_id =
  72. t1.id AND class_id = t.class_id AND delete_mark = 0 and enabled_mark = 1
  73. ) AS student_count,t1.assessment_type,t6.name AS assessment_item_name
  74. FROM base_student_assessment_class_relation t
  75. LEFT JOIN base_student_assessment_inspection t1 ON t1.id=t.base_student_assessment_inspection_id
  76. LEFT JOIN base_student_assessment_category t2 ON (t2.id = t1.base_student_assessment_category_id)
  77. LEFT JOIN base_student_assessment_project t3 ON (t3.id = t1.base_student_assessment_project_id)
  78. LEFT JOIN base_student_assessment_item t6 ON (t6.id = t1.base_student_assessment_item_id)
  79. LEFT JOIN xjr_dictionary_detail t4 ON t4.code=t1.score_type
  80. LEFT JOIN base_class t5 ON t5.id=t.class_id
  81. WHERE t1.delete_mark = 0 and t1.enabled_mark = 1 and t.class_id in
  82. <foreach item="classId" index="index" collection="dto.classIds" open="(" close=")" separator=",">
  83. #{classId}
  84. </foreach>
  85. <if test="dto.projectIds != null and dto.projectIds.size() > 0">
  86. and t1.base_student_assessment_project_id in
  87. <foreach item="projectId" index="index" collection="dto.projectIds" open="(" close=")" separator=",">
  88. #{projectId}
  89. </foreach>
  90. </if>
  91. <if test="dto.startDate != null and dto.startDate != ''">
  92. and t1.assessment_date &gt;= #{dto.startDate}
  93. </if>
  94. <if test="dto.endDate != null and dto.endDate != ''">
  95. and t1.assessment_date &lt;= #{dto.endDate}
  96. </if>
  97. </select>
  98. <select id="getMobileInfo" resultType="com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionMobileVo">
  99. 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,
  100. 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,t1.assessment_type,
  101. t8.name as assessment_item_name,t9.name as modify_user_name,t1.modify_date
  102. from base_student_assessment_class_relation t
  103. left join base_student_assessment_inspection t1 on t1.id=t.base_student_assessment_inspection_id
  104. left join base_student_assessment_category t2 on (t2.id = t1.base_student_assessment_category_id)
  105. left join base_student_assessment_project t3 on (t3.id = t1.base_student_assessment_project_id)
  106. left join base_student_assessment_item t8 on (t8.id = t1.base_student_assessment_item_id)
  107. left join xjr_dictionary_detail t4 on t4.code=t1.score_type
  108. left join base_class t5 on t5.id=t.class_id
  109. left join xjr_user t6 on t1.assessment_user_id = t6.id
  110. left join xjr_user t7 on t1.create_user_id = t7.id
  111. left join xjr_user t9 on t1.modify_user_id = t9.id
  112. where t.id = #{id};
  113. </select>
  114. <select id="getStudentIndividualBehaviorExcelVoList" parameterType="com.xjrsoft.module.student.dto.QuantitativeAssessmentExcelDto" resultType="com.xjrsoft.module.student.vo.QuantitativeAssessmentSubTableExcelVo">
  115. with total_score as (
  116. select
  117. t.user_id as studentUserId,
  118. sum(if(t1.score_type = 'score_add', t1.score, -1 * t1.score)) as finalScore
  119. from base_student_assessment_student_relation t
  120. left join base_student_assessment_inspection t1 on t1.id = t.base_student_assessment_inspection_id
  121. where t1.delete_mark = 0 and t.delete_mark = 0 and t.enabled_mark = 1
  122. <if test="dto.yearAndMonth != null and dto.yearAndMonth != ''">
  123. and date_format(t1.assessment_date, '%Y-%m') = #{dto.yearAndMonth}
  124. </if>
  125. group by t.user_id
  126. )
  127. select
  128. t4.id as headTeacherUserId,
  129. t4.user_name as headTeacherUserName,
  130. t4.name as headTeacherName,
  131. t.class_id as classId,
  132. t.class_name as className,
  133. t.user_id as studentUserId,
  134. t.student_id as studentId,
  135. t.name as studentName,
  136. t5.base_score as baseScore,
  137. t2.id as baseStudentAssessmentProjectId,
  138. t2.name as baseStudentAssessmentProjectIdCN,
  139. t1.assessment_date as assessmentDate,
  140. if(t1.score_type = 'score_add', t1.score, -1 * t1.score) as projectScore,
  141. t5.base_score + t6.finalScore as finalScore
  142. from base_student_assessment_student_relation t
  143. left join base_student_assessment_inspection t1 on t1.id = t.base_student_assessment_inspection_id
  144. left join base_student_assessment_project t2 on t2.id = t1.base_student_assessment_project_id
  145. left join base_class t3 on t3.id = t.class_id
  146. left join xjr_user t4 on t4.id = t3.teacher_id
  147. left join base_student_assessment_base_score t5 on t5.base_semester_id = t1.base_semester_id
  148. left join total_score t6 on t6.studentUserId = t.user_id
  149. where t1.delete_mark = 0 and t.delete_mark = 0 and t.enabled_mark = 1
  150. <if test="dto.yearAndMonth != null and dto.yearAndMonth != ''">
  151. and date_format(t1.assessment_date, '%Y-%m') = #{dto.yearAndMonth}
  152. </if>
  153. order by t.class_id, t.user_id
  154. </select>
  155. <select id="getQuantitativeAssessmentSubTableExcelVoList" parameterType="com.xjrsoft.module.student.dto.QuantitativeAssessmentExcelDto" resultType="com.xjrsoft.module.student.vo.QuantitativeAssessmentSubTableExcelVo">
  156. with total_score as (select t.user_id as studentUserId,
  157. sum(if(t1.score_type = 'score_add', t1.score, -1 * t1.score)) as finalScore
  158. from base_student_assessment_student_relation t
  159. left join base_student_assessment_inspection t1
  160. on t1.id = t.base_student_assessment_inspection_id
  161. where t1.delete_mark = 0 and t.delete_mark = 0 and t.enabled_mark = 1
  162. and t1.base_student_assessment_category_id = #{dto.baseStudentAssessmentCategoryId}
  163. <if test="dto.classIdList != null and !dto.classIdList.isEmpty()">
  164. and t1.class_ids in
  165. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")" separator=",">
  166. #{classId}
  167. </foreach>
  168. </if>
  169. <if test="dto.baseStudentAssessmentCategoryId != null and dto.baseStudentAssessmentCategoryId > 0">
  170. and t1.base_student_assessment_category_id = #{dto.baseStudentAssessmentCategoryId}
  171. </if>
  172. <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
  173. and t1.base_semester_id &gt; #{dto.baseSemesterId}
  174. </if>
  175. <if test="dto.startTime != null">
  176. and t1.create_date &gt; #{dto.startTime}
  177. </if>
  178. <if test="dto.endTime != null">
  179. and t1.create_date &lt; #{dto.endTime}
  180. </if>
  181. group by t.user_id)
  182. select t4.id as headTeacherUserId,
  183. t4.user_name as headTeacherUserName,
  184. t4.name as headTeacherName,
  185. t.class_id as classId,
  186. t.class_name as className,
  187. t.user_id as studentUserId,
  188. t.student_id as studentId,
  189. t.name as studentName,
  190. t5.base_score as baseScore,
  191. t2.id as baseStudentAssessmentProjectId,
  192. t2.name as baseStudentAssessmentProjectIdCN,
  193. t1.assessment_date as assessmentDate,
  194. if(t1.score_type = 'score_add', t1.score, -1 * t1.score) as projectScore,
  195. t5.base_score + t6.finalScore as finalScore
  196. from base_student_assessment_student_relation t
  197. left join base_student_assessment_inspection t1 on t1.id = t.base_student_assessment_inspection_id
  198. left join base_student_assessment_project t2 on t2.id = t1.base_student_assessment_project_id
  199. left join base_class t3 on t3.id = t.class_id
  200. left join xjr_user t4 on t4.id = t3.teacher_id
  201. left join base_student_assessment_base_score t5 on t5.base_semester_id = t1.base_semester_id
  202. left join total_score t6 on t6.studentUserId = t.user_id
  203. where t1.delete_mark = 0 and t.delete_mark = 0 and t.enabled_mark = 1
  204. and t1.base_student_assessment_category_id = #{dto.baseStudentAssessmentCategoryId}
  205. <if test="dto.classIdList != null and !dto.classIdList.isEmpty()">
  206. and t1.class_ids in
  207. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")" separator=",">
  208. #{classId}
  209. </foreach>
  210. </if>
  211. <if test="dto.baseStudentAssessmentCategoryId != null and dto.baseStudentAssessmentCategoryId > 0">
  212. and t1.base_student_assessment_category_id = #{dto.baseStudentAssessmentCategoryId}
  213. </if>
  214. <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
  215. and t1.base_semester_id &gt; #{dto.baseSemesterId}
  216. </if>
  217. <if test="dto.startTime != null">
  218. and t1.create_date &gt; #{dto.startTime}
  219. </if>
  220. <if test="dto.endTime != null">
  221. and t1.create_date &lt; #{dto.endTime}
  222. </if>
  223. order by t.class_id, t.user_id
  224. </select>
  225. <select id="getAssessmentInspectionByClassIdList" parameterType="com.xjrsoft.module.student.dto.QuantitativeAssessmentSingleScoreDto" resultType="com.xjrsoft.module.student.vo.QuantitativeAssessmentSingleScoreVo">
  226. select
  227. t.class_ids as class_id,
  228. SUM(t.score * (LENGTH(personal_student_user_ids) - LENGTH(REPLACE(personal_student_user_ids, ',', '')) + 1)) AS sumScore
  229. from base_student_assessment_inspection t
  230. inner join base_student_assessment_category t1 on t1.id = t.base_student_assessment_category_id
  231. where t.delete_mark = 0 and t.enabled_mark = 1
  232. <if test="dto.classIdList != null and !dto.classIdList.isEmpty()">
  233. and t.class_ids in
  234. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")" separator=",">
  235. #{classId}
  236. </foreach>
  237. </if>
  238. <if test="dto.baseStudentAssessmentCategoryId != null and dto.baseStudentAssessmentCategoryId > 0">
  239. and t.base_student_assessment_category_id = #{dto.baseStudentAssessmentCategoryId}
  240. </if>
  241. <if test="dto.categoryCode != null and dto.categoryCode != ''">
  242. and t1.code = #{dto.categoryCode}
  243. </if>
  244. <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
  245. and t.base_semester_id &gt; #{dto.baseSemesterId}
  246. </if>
  247. <if test="dto.startTime != null">
  248. and t.create_date &gt; #{dto.startTime}
  249. </if>
  250. <if test="dto.endTime != null">
  251. and t.create_date &lt; #{dto.endTime}
  252. </if>
  253. group by t.class_ids;
  254. </select>
  255. <select id="getConventionalManagementList" parameterType="com.xjrsoft.module.student.dto.QuantitativeAssessmentSingleScoreDto" resultType="com.xjrsoft.module.student.vo.QuantitativeAssessmentSingleScoreVo">
  256. select
  257. t.class_id as classId,
  258. sum(t1.score) as score
  259. from base_student_assessment_class_relation t
  260. left join base_student_assessment_inspection t1 on t1.id = t.base_student_assessment_inspection_id
  261. left join base_student_assessment_category t2 on t2.id = t1.base_student_assessment_category_id
  262. where t2.code = 'convention_manage' and t1.enabled_mark = 1
  263. and t.class_id in
  264. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")" separator=",">
  265. #{classId}
  266. </foreach>
  267. <if test="dto.startTime != null">
  268. and t1.create_date &gt; #{dto.startTime}
  269. </if>
  270. <if test="dto.endTime != null">
  271. and t1.create_date &lt; #{dto.endTime}
  272. </if>
  273. group by t.class_id;
  274. </select>
  275. <select id="getAwardsAndHonorList" parameterType="com.xjrsoft.module.student.dto.QuantitativeAssessmentSingleScoreDto" resultType="com.xjrsoft.module.student.vo.QuantitativeAssessmentSingleScoreVo">
  276. select
  277. t.class_id as classId,
  278. sum(t1.score) as score
  279. from base_student_assessment_student_relation t
  280. left join base_student_assessment_inspection t1 on t1.id = t.base_student_assessment_inspection_id
  281. left join base_student_assessment_category t2 on t2.id = t1.base_student_assessment_category_id
  282. where t2.code = 'awards_and_honors' and t.enabled_mark = 1
  283. and t.class_id in
  284. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")" separator=",">
  285. #{classId}
  286. </foreach>
  287. <if test="dto.startTime != null">
  288. and t1.create_date &gt; #{dto.startTime}
  289. </if>
  290. <if test="dto.endTime != null">
  291. and t1.create_date &lt; #{dto.endTime}
  292. </if>
  293. group by t.class_id;
  294. </select>
  295. <select id="getParamilitaryList" parameterType="com.xjrsoft.module.student.dto.QuantitativeAssessmentSingleScoreDto" resultType="com.xjrsoft.module.student.vo.QuantitativeAssessmentSingleScoreVo">
  296. select
  297. t.class_id as classId,
  298. sum(t1.score) as score
  299. from base_student_assessment_student_relation t
  300. left join base_student_assessment_inspection t1 on t1.id = t.base_student_assessment_inspection_id
  301. left join base_student_assessment_category t2 on t2.id = t1.base_student_assessment_category_id
  302. where t2.code = 'militarize_manage' and t.delete_mark = 0 and t.enabled_mark = 1
  303. and t.class_id in
  304. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")" separator=",">
  305. #{classId}
  306. </foreach>
  307. <if test="dto.startTime != null">
  308. and t1.create_date &gt; #{dto.startTime}
  309. </if>
  310. <if test="dto.endTime != null">
  311. and t1.create_date &lt; #{dto.endTime}
  312. </if>
  313. group by t.class_id;
  314. </select>
  315. <select id="getStudentListByInspectionId"
  316. resultType="com.xjrsoft.module.student.entity.BaseStudentAssessmentStudentRelation">
  317. SELECT t1.id,t1.user_id,t1.class_id,t3.student_id,t2.name,t6.name AS nation,t4.name AS class_name,
  318. t5.name AS major_name,t7.name as gender,t1.score,t1.enabled_mark
  319. FROM base_student_assessment_student_relation t1
  320. INNER JOIN xjr_user t2 ON t1.user_id = t2.id
  321. INNER JOIN base_student t3 ON t2.id = t3.user_id
  322. INNER JOIN base_class t4 ON t4.id = t1.class_id
  323. INNER JOIN base_major_set t5 ON t4.major_set_id = t5.id
  324. LEFT JOIN xjr_dictionary_detail t6 ON t3.nation = t6.code
  325. LEFT JOIN xjr_dictionary_detail t7 ON t2.gender = t7.code
  326. WHERE t1.base_student_assessment_inspection_id = #{id}
  327. </select>
  328. </mapper>