MarkStudentMapper.xml 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065
  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.qmth.teachcloud.mark.mapper.MarkStudentMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.qmth.teachcloud.mark.entity.MarkStudent">
  6. <id column="id" property="id"/>
  7. <result column="exam_id" property="examId"/>
  8. <result column="paper_number" property="paperNumber"/>
  9. <result column="course_paper_id" property="coursePaperId"/>
  10. <result column="secret_number" property="secretNumber"/>
  11. <result column="student_code" property="studentCode"/>
  12. <result column="package_code" property="packageCode"/>
  13. <result column="exam_place" property="examPlace"/>
  14. <result column="exam_room" property="examRoom"/>
  15. <result column="remark" property="remark"/>
  16. <result column="batch_code" property="batchCode"/>
  17. <result column="sheet_count" property="sheetCount"/>
  18. <result column="answers" property="answers"/>
  19. <result column="is_upload" property="upload"/>
  20. <result column="is_absent" property="absent"/>
  21. <result column="is_manual_absent" property="manualAbsent"/>
  22. <result column="is_breach" property="breach"/>
  23. <result column="upload_time" property="uploadTime"/>
  24. <result column="check_time" property="checkTime"/>
  25. <result column="check_user_id" property="checkUserId"/>
  26. <result column="objective_score" property="objectiveScore"/>
  27. <result column="objective_score_list" property="objectiveScoreList"/>
  28. <result column="subjective_status" property="subjectiveStatus"/>
  29. <result column="subjective_score" property="subjectiveScore"/>
  30. <result column="subjective_score_list" property="subjectiveScoreList"/>
  31. <result column="scan_status" property="scanStatus"/>
  32. <result column="omr_absent_checked" property="omrAbsentChecked"/>
  33. <result column="question_filled" property="questionFilled"/>
  34. <result column="assigned" property="assigned"/>
  35. <result column="absent_suspect" property="absentSuspect"/>
  36. <result column="incomplete" property="incomplete"/>
  37. <result column="breach_code" property="breachCode"/>
  38. <result column="card_number" property="cardNumber"/>
  39. </resultMap>
  40. <sql id="pageStudentScoreCommon">
  41. SELECT
  42. ms.id studentId,
  43. ms.exam_id examId,
  44. bc.code courseCode,
  45. bc.name courseName,
  46. ms.paper_number paperNumber,
  47. ms.paper_type paperType,
  48. bes.student_name studentName,
  49. bes.student_code studentCode,
  50. bes.college_name collegeName,
  51. ms.secret_number secretNumber,
  52. bes.college_name college,
  53. bes.major_name majorName,
  54. bes.teach_class_name teachClassName,
  55. bes.class_name className,
  56. su1.real_name teacherName,
  57. ms.objective_score objectiveScore,
  58. ms.subjective_score subjectiveScore,
  59. ifnull(ms.objective_score, 0) + ifnull(ms.subjective_score, 0) totalScore,
  60. ms.objective_score_list objectiveScoreList,
  61. ms.subjective_score_list subjectiveScoreList,
  62. ms.check_user_id checkUserId,
  63. su.login_name checkUserLoginName,
  64. su.real_name checkUserName,
  65. ms.check_time checkTime,
  66. ms.sheet_path sheetPath,
  67. ms.exam_start_time examStartTime,
  68. ms.exam_end_time examEndTime,
  69. ms.scan_status scanStatus,
  70. ms.subjective_status subjectiveStatus,
  71. ms.is_absent absent,
  72. ms.omr_absent omrAbsent,
  73. ms.is_manual_absent manualAbsent,
  74. ms.is_upload upload,
  75. bes.status studentStatus,
  76. ms.is_breach breach,
  77. ms.omr_breach omrBreach,
  78. ifnull(ms.is_manual_breach,0) manualBreach
  79. FROM
  80. (select * from mark_student where exam_id = #{examId} and paper_number = #{paperNumber}) ms
  81. LEFT JOIN
  82. (select * from basic_exam_student where exam_id = #{examId}) bes ON ms.basic_student_id = bes.id
  83. LEFT JOIN
  84. basic_course bc ON ms.course_id = bc.id
  85. LEFT JOIN
  86. sys_user su ON ms.check_user_id = su.id
  87. LEFT JOIN
  88. sys_user su1 ON bes.teacher_id = su1.id
  89. <where>
  90. <if test="college != null and college != ''">
  91. AND bes.college_name LIKE CONCAT('%', #{college}, '%')
  92. </if>
  93. <if test="majorName != null and majorName != ''">
  94. AND bes.major_name LIKE CONCAT('%', #{majorName}, '%')
  95. </if>
  96. <if test="teachClassName != null and teachClassName != ''">
  97. AND bes.teach_class_name LIKE CONCAT('%', #{teachClassName}, '%')
  98. </if>
  99. <if test="className != null and className != ''">
  100. AND bes.class_name LIKE CONCAT('%', #{className}, '%')
  101. </if>
  102. <if test="teacher != null and teacher != ''">
  103. AND su1.real_name LIKE CONCAT('%', #{teacher},'%')
  104. </if>
  105. <if test="filter != null">
  106. <choose>
  107. <when test="filter == 1">
  108. AND ms.objective_score = 0
  109. </when>
  110. <when test="filter == 2">
  111. AND ms.objective_score = 0 AND ms.subjective_score > 0
  112. </when>
  113. <when test="filter == 3">
  114. AND ms.objective_score > 0 AND ms.subjective_score = 0
  115. </when>
  116. </choose>
  117. </if>
  118. <if test="status != null">
  119. <choose>
  120. <when test="status == 'ABSENT'">
  121. AND (ms.is_absent = 1 OR ms.omr_absent = 1 OR ms.is_manual_absent = 1 OR bes.status = 'M')
  122. </when>
  123. <when test="status == 'NORMAL'">
  124. AND (ms.is_absent = 0 and ms.omr_absent = 0 and ms.is_manual_absent = 0 and bes.status != 'M' and ms.scan_status = 'SCANNED' AND ms.is_upload = 1)
  125. </when>
  126. <otherwise>
  127. AND (ms.scan_status = 'UNEXIST' and ms.is_absent = 0 and ms.omr_absent = 0 and ms.is_manual_absent = 0 and bes.status != 'M')
  128. </otherwise>
  129. </choose>
  130. </if>
  131. <if test="breach != null">
  132. <choose>
  133. <when test="breach == true">
  134. AND (ms.is_breach = 1 OR ms.omr_breach = 1 OR ms.is_manual_breach = 1 OR bes.status = 'B')
  135. </when>
  136. <otherwise>
  137. AND (ms.is_breach = 0 AND ms.omr_breach = 0 AND ms.is_manual_breach = 0 OR bes.status != 'B')
  138. </otherwise>
  139. </choose>
  140. </if>
  141. <if test="startScore != null">
  142. <choose>
  143. <when test="startScore == 0">
  144. AND (ms.is_absent = 1 OR ms.is_breach = 1 OR ((ifnull(ms.subjective_score, 0) +
  145. ifnull(ms.objective_score, 0)) &gt;= #{startScore} AND (ifnull(ms.subjective_score,0) +
  146. ifnull(ms.objective_score,0)) &lt;= #{endScore}))
  147. </when>
  148. <otherwise>
  149. AND (ms.is_absent = 0 AND ms.is_breach = 0 AND ((ifnull(ms.subjective_score,0) +
  150. ifnull(ms.objective_score,0)) &gt;= #{startScore} AND (ifnull(ms.subjective_score,0) +
  151. ifnull(ms.objective_score,0)) &lt;= #{endScore}))
  152. </otherwise>
  153. </choose>
  154. </if>
  155. <if test="subjectiveStartScore != null">
  156. <choose>
  157. <when test="subjectiveStartScore == 0">
  158. AND (ms.is_absent = 1 OR ms.is_breach = 1
  159. OR ((ifnull(ms.subjective_score, 0) &gt;= #{subjectiveStartScore}
  160. AND ifnull(ms.subjective_score, 0) &lt;= #{subjectiveEndScore})))
  161. </when>
  162. <otherwise>
  163. AND (ms.is_absent = 0 AND ms.is_breach = 0
  164. AND ((ifnull(ms.subjective_score, 0) &gt;= #{subjectiveStartScore}
  165. AND ifnull(ms.subjective_score, 0) &lt;= #{subjectiveEndScore})))
  166. </otherwise>
  167. </choose>
  168. </if>
  169. <if test="objectiveStartScore != null">
  170. <choose>
  171. <when test="objectiveStartScore == 0">
  172. AND (ms.is_absent = 1 OR ms.is_breach = 1
  173. OR ((ifnull(ms.objective_score, 0) &gt;= #{objectiveStartScore}
  174. AND ifnull(ms.objective_score, 0) &lt;= #{objectiveEndScore})))
  175. </when>
  176. <otherwise>
  177. AND (ms.is_absent = 0 AND ms.is_breach = 0
  178. AND ((ifnull(ms.objective_score, 0) &gt;= #{objectiveStartScore}
  179. AND ifnull(ms.objective_score, 0) &lt;= #{objectiveEndScore})))
  180. </otherwise>
  181. </choose>
  182. </if>
  183. <if test="subScore != null">
  184. AND exists (SELECT 1 FROM mark_subjective_score mss WHERE ms.id = mss.student_id AND mss.score =
  185. #{subScore})
  186. </if>
  187. <if test="objectiveScoreLt != null">
  188. AND ms.objective_score &lt; #{objectiveScoreLt}
  189. </if>
  190. <if test="studentName != null and studentName != ''">
  191. AND bes.student_name like concat('%',#{studentName}, '%')
  192. </if>
  193. <if test="studentCode != null and studentCode != ''">
  194. AND bes.student_code = #{studentCode}
  195. </if>
  196. <if test="secretNumber != null and secretNumber != ''">
  197. AND ms.secret_number = #{secretNumber}
  198. </if>
  199. <if test="dpr != null">
  200. <if test="dpr.requestUserId != null">
  201. AND bes.teacher_id = #{dpr.requestUserId}
  202. </if>
  203. <if test="dpr.courseUserId != null">
  204. AND EXISTS( SELECT 1 FROM (select course_id from teach_course where exam_id = #{examId} and user_id = #{dpr.courseUserId}) tc WHERE tc.course_id = ms.course_id)
  205. </if>
  206. <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  207. AND bc.teaching_room_id IN
  208. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  209. #{item}
  210. </foreach>
  211. </if>
  212. </if>
  213. </where>
  214. <if test="orderType != null and orderType != '' and orderField != null and orderField != ''">
  215. <choose>
  216. <when test="orderField == 'totalScore'">
  217. <if test="orderType == 'ASC'">
  218. order by (ifnull(ms.objective_score, 0) + ifnull(ms.subjective_score, 0)) ASC
  219. </if>
  220. <if test="orderType == 'DESC'">
  221. order by (ifnull(ms.objective_score, 0) + ifnull(ms.subjective_score, 0)) DESC
  222. </if>
  223. </when>
  224. <otherwise>
  225. order by #{orderField} #{orderType}
  226. </otherwise>
  227. </choose>
  228. </if>
  229. <if test="orderType == null or orderType == '' or orderField == null or orderField == ''">
  230. order by ms.is_absent, bes.status desc, bes.student_code
  231. </if>
  232. </sql>
  233. <update id="updateBasicExamStudentPaperType">
  234. update basic_exam_student set paper_type = #{paperType} where id = #{basicStudentId}
  235. </update>
  236. <select id="pageStudentScore" resultType="com.qmth.teachcloud.mark.dto.mark.score.StudentScoreDetailDto">
  237. <include refid="pageStudentScoreCommon" />
  238. </select>
  239. <select id="pageStudentScoreExport" resultType="com.qmth.teachcloud.mark.dto.mark.score.StudentScoreDetailDto">
  240. <include refid="pageStudentScoreCommon" />
  241. </select>
  242. <select id="listAbsentOrBreachMarkTaskStudent" resultMap="BaseResultMap">
  243. SELECT *
  244. FROM mark_student ms
  245. WHERE ms.exam_id = #{examId}
  246. AND ms.paper_number = #{paperNumber}
  247. AND ms.is_upload = TRUE
  248. AND (is_absent = TRUE OR is_manual_absent = TRUE OR omr_absent = TRUE)
  249. AND EXISTS(SELECT 1
  250. FROM mark_task mt
  251. WHERE ms.id = mt.student_id)
  252. </select>
  253. <select id="listUnMarkTaskStudent" resultMap="BaseResultMap">
  254. SELECT ms.*
  255. FROM mark_student ms
  256. WHERE ms.exam_id = #{examId}
  257. AND ms.paper_number = #{paperNumber}
  258. AND ms.is_upload = TRUE
  259. AND is_absent = FALSE
  260. AND is_manual_absent = FALSE
  261. AND omr_absent = FALSE
  262. AND NOT EXISTS(SELECT 1
  263. FROM mark_task mt
  264. WHERE ms.id = mt.student_id
  265. AND mt.question_id = #{questionId})
  266. </select>
  267. <sql id="queryWhereAndOrder">
  268. where t.exam_id=#{query.examId}
  269. <if test="query.studentId != null and query.studentId !=''">
  270. and t.id=#{query.studentId}
  271. </if>
  272. <if test="query.status != null and query.status.size>0">
  273. AND t.scan_status in
  274. <foreach collection="query.status" index="index" item="st"
  275. open="(" separator="," close=")">
  276. #{st}
  277. </foreach>
  278. </if>
  279. <if test="query.studentCode != null and query.studentCode !=''">
  280. and t.student_code=#{query.studentCode}
  281. </if>
  282. <if test="query.studentName != null and query.studentName !=''">
  283. and bes.student_name=#{query.studentName}
  284. </if>
  285. <if test="query.packageCode != null and query.packageCode !=''">
  286. and t.package_code=#{query.packageCode}
  287. </if>
  288. <if test="query.courseId != null">
  289. and t.course_id=#{query.courseId}
  290. </if>
  291. <if test="query.coursePaperId != null and query.coursePaperId !=''">
  292. and t.course_paper_id=#{query.coursePaperId}
  293. </if>
  294. <if test="query.coursePaperNumber != null and query.coursePaperNumber !=''">
  295. and t.paper_number=#{query.coursePaperNumber}
  296. </if>
  297. <if test="query.examPlace != null and query.examPlace !=''">
  298. and bes.exam_place=#{query.examPlace}
  299. </if>
  300. <if test="query.examRoom != null and query.examRoom !=''">
  301. and bes.exam_room=#{query.examRoom}
  302. </if>
  303. <if test="query.absentSuspect != null">
  304. and t.absent_suspect=#{query.absentSuspect}
  305. </if>
  306. <if test="query.omrAbsent != null">
  307. and t.omr_absent=#{query.omrAbsent}
  308. </if>
  309. <if test="query.omrAbsentChecked != null">
  310. and t.omr_absent_checked=#{query.omrAbsentChecked}
  311. </if>
  312. <if test="query.manualAbsent != null">
  313. and t.is_manual_absent=#{query.manualAbsent}
  314. </if>
  315. <if test="query.assigned != null">
  316. and t.assigned=#{query.assigned}
  317. </if>
  318. <if test="query.assignConfirmed != null">
  319. and t.assign_confirmed=#{query.assignConfirmed}
  320. </if>
  321. <if test="query.invalid != null">
  322. and t.invalid=#{query.invalid}
  323. </if>
  324. <if test="query.incomplete != null">
  325. and t.incomplete=#{query.incomplete}
  326. </if>
  327. <if test="query.questionFilled != null">
  328. and t.question_filled=#{query.questionFilled}
  329. </if>
  330. <if test="query.missScan != null">
  331. and t.miss_scan=#{query.missScan}
  332. </if>
  333. <if test="query.studentCodeOrName != null and query.studentCodeOrName !=''">
  334. and (t.student_code=#{query.studentCodeOrName} or bes.student_name=#{query.studentCodeOrName})
  335. </if>
  336. <if test="query.paperType != null and query.paperType != ''">
  337. and ifnull(t.paper_type, '#') = #{query.paperType}
  338. </if>
  339. <if test="query.paperTypeCheckStatus != null">
  340. and t.paper_type_check_status=#{query.paperTypeCheckStatus}
  341. </if>
  342. <if test="query.omrBreach != null">
  343. and t.omr_breach = #{query.omrBreach}
  344. </if>
  345. <if test="query.manualBreach != null">
  346. and t.is_manual_breach = #{query.manualBreach}
  347. </if>
  348. <if test="dpr != null and dpr.requestUserId != null">
  349. AND t.create_id = #{dpr.requestUserId}
  350. </if>
  351. </sql>
  352. <select id="queryPage"
  353. resultType="com.qmth.teachcloud.mark.bean.scananswer.AnswerQueryVo">
  354. select t.id,
  355. bes.student_code,
  356. bes.site_number,
  357. bes.student_name,
  358. bc.code courseCode,
  359. bc.name courseName,
  360. t.course_paper_id,
  361. bes.exam_place,
  362. bes.exam_room,
  363. t.package_code,
  364. t.absent_suspect,
  365. t.omr_absent,
  366. t.omr_absent_checked,
  367. t.is_manual_absent manualAbsent,
  368. t.assigned,
  369. t.invalid,
  370. t.incomplete,
  371. t.card_number,
  372. t.is_absent,
  373. t.scan_status status,
  374. t.paper_number coursePaperNumber,
  375. c.paper_count cardPaperCount,
  376. t.paper_type paperType,
  377. t.paper_type_check_status paperTypeCheckStatus,
  378. t.miss_scan missScan,
  379. t.omr_breach omrBreach,
  380. t.is_manual_breach manualBreach
  381. from mark_student t
  382. inner join basic_exam_student bes on t.basic_student_id = bes.id
  383. left join scan_answer_card c on t.exam_id=c.exam_id and t.card_number=c.number
  384. inner join mark_paper s on s.course_paper_id=t.course_paper_id and s.exam_id=t.exam_id
  385. <if test="query.markPaperStatus != null">
  386. and s.status = #{query.markPaperStatus}
  387. </if>
  388. left join sys_user su on t.create_id = su.id
  389. inner join basic_course bc on t.course_id = bc.id
  390. <if test="dpr != null and dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  391. AND bc.teaching_room_id IN
  392. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  393. #{item}
  394. </foreach>
  395. </if>
  396. <include refid="queryWhereAndOrder"/>
  397. order by t.id
  398. </select>
  399. <select id="querySummary" resultType="java.lang.String">
  400. select
  401. t.id
  402. from mark_student t
  403. inner join basic_exam_student bes on t.basic_student_id = bes.id
  404. inner join mark_paper s on s.course_paper_id=t.course_paper_id and s.exam_id=t.exam_id
  405. <if test="query.markPaperStatus != null">
  406. and s.status = #{query.markPaperStatus}
  407. </if>
  408. left join sys_user su on t.create_id = su.id
  409. inner join basic_course bc on t.course_id = bc.id
  410. <if test="dpr != null and dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  411. AND bc.teaching_room_id IN
  412. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  413. #{item}
  414. </foreach>
  415. </if>
  416. <include refid="queryWhereAndOrder"/>
  417. order by t.id
  418. </select>
  419. <select id="findIdByExamIdAndPaperNumber" resultType="java.lang.Long">
  420. select id
  421. from mark_student
  422. where exam_id = #{examId}
  423. and paper_number = #{paperNumber}
  424. </select>
  425. <select id="studentList"
  426. resultType="com.qmth.teachcloud.mark.bean.archivescore.ArchiveStudentVo">
  427. select s.id studentId,
  428. s.paper_type paperType,
  429. s.objective_score objectiveScore,
  430. s.subjective_score subjectiveScore,
  431. ifnull(s.objective_score, 0) + ifnull(s.subjective_score, 0) totalScore,
  432. s.objective_score_list objectiveScoreList,
  433. s.subjective_score_list subjectiveScoreList,
  434. s.check_user_id checkUserId,
  435. s.check_time checkTime,
  436. s.sheet_path sheetPath,
  437. s.scan_status scanStatus,
  438. s.subjective_status subjectiveStatus,
  439. s.is_absent absent,
  440. s.omr_absent omrAbsent,
  441. ifnull(s.is_manual_absent,0) manualAbsent,
  442. s.is_upload upload,
  443. bes.status studentStatus,
  444. s.is_breach breach,
  445. s.omr_breach omrBreach,
  446. ifnull(s.is_manual_breach,0) manualBreach,
  447. bes.student_code studentCode,
  448. bes.student_name studentName,
  449. bes.college_name collegeName,
  450. bes.major_name majorName,
  451. bes.class_name className,
  452. bes.teach_class_name teachClassName,
  453. bc.code courseCode,
  454. bc.name courseName,
  455. su.real_name teacherName,
  456. bes.exam_start_time examStartTime,
  457. bes.exam_end_time examEndTime
  458. from mark_student s
  459. left join basic_exam_student bes on s.basic_student_id = bes.id
  460. left join sys_user su on bes.teacher_id = su.id
  461. left join (select * from basic_course where school_id = #{schoolId}) bc on s.course_id = bc.id
  462. <include refid="archiveQuery"/>
  463. <if test="dpr != null">
  464. <if test="dpr.requestUserId != null">
  465. AND bes.teacher_id = #{dpr.requestUserId}
  466. </if>
  467. <if test="dpr.courseUserId != null">
  468. AND EXISTS( SELECT 1 FROM (select course_id from teach_course where exam_id = #{req.examId} and user_id = #{dpr.courseUserId}) tc WHERE tc.course_id = s.course_id)
  469. </if>
  470. <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  471. AND bc.teaching_room_id IN
  472. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  473. #{item}
  474. </foreach>
  475. </if>
  476. </if>
  477. <if test="req.orderType != null and req.orderType != '' and req.orderField != null and req.orderField != ''">
  478. <choose>
  479. <when test="req.orderField == 'totalScore'">
  480. <if test="req.orderType == 'ASC'">
  481. order by (ifnull(s.objective_score, 0) + ifnull(s.subjective_score, 0)) ASC
  482. </if>
  483. <if test="req.orderType == 'DESC'">
  484. order by (ifnull(s.objective_score, 0) + ifnull(s.subjective_score, 0)) DESC
  485. </if>
  486. </when>
  487. <otherwise>
  488. order by #{req.orderField} #{req.orderType}
  489. </otherwise>
  490. </choose>
  491. </if>
  492. <if test="req.orderType == null or req.orderType == '' or req.orderField == null or req.orderField == ''">
  493. order by s.is_absent, bes.status desc, bes.student_code
  494. </if>
  495. </select>
  496. <sql id="archiveQuery">
  497. where s.exam_id=#{req.examId} and s.paper_number=#{req.paperNumber}
  498. <if test="req.studentCode != null and req.studentCode !=''">
  499. and bes.student_code=#{req.studentCode}
  500. </if>
  501. <if test="req.startStudentCode != null and req.startStudentCode !=''">
  502. and bes.student_code &gt;= #{req.startStudentCode}
  503. </if>
  504. <if test="req.endStudentCode != null and req.endStudentCode !=''">
  505. and bes.student_code &lt;= #{req.endStudentCode}
  506. </if>
  507. <if test="req.studentName != null and req.studentName !=''">
  508. and bes.student_name=#{req.studentName}
  509. </if>
  510. <if test="req.college != null and req.college !=''">
  511. and bes.college_name like concat(#{req.college}, '%')
  512. </if>
  513. <if test="req.majorName != null and req.majorName !=''">
  514. and bes.major_name like concat(#{req.majorName}, '%')
  515. </if>
  516. <if test="req.teachClassName != null and req.teachClassName !=''">
  517. and bes.teach_class_name like concat(#{req.teachClassName}, '%')
  518. </if>
  519. <if test="req.className != null and req.className !=''">
  520. and bes.class_name like concat(#{req.className}, '%')
  521. </if>
  522. <if test="req.startScore != null and req.startScore !=''">
  523. and (ifnull(s.objective_score,0)+ifnull(s.subjective_score,0)) &gt;= #{req.startScore}
  524. </if>
  525. <if test="req.endScore != null and req.endScore !=''">
  526. and (ifnull(s.objective_score,0)+ifnull(s.subjective_score,0)) &lt;= #{req.endScore}
  527. </if>
  528. <if test="req.objectiveStartScore != null and req.objectiveStartScore !=''">
  529. and ifnull(s.objective_score,0) &gt;= #{req.objectiveStartScore}
  530. </if>
  531. <if test="req.objectiveEndScore != null and req.objectiveEndScore !=''">
  532. and ifnull(s.objective_score,0) &lt;= #{req.objectiveEndScore}
  533. </if>
  534. <if test="req.subjectiveStartScore != null and req.subjectiveStartScore !=''">
  535. and ifnull(s.subjective_score,0) &gt;= #{req.subjectiveStartScore}
  536. </if>
  537. <if test="req.subjectiveEndScore != null and req.subjectiveEndScore !=''">
  538. and ifnull(s.subjective_score,0) &lt;= #{req.subjectiveEndScore}
  539. </if>
  540. <if test="dpr != null">
  541. <if test="dpr.requestUserId != null">
  542. AND bes.teacher_id = #{dpr.requestUserId}
  543. </if>
  544. <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  545. AND bc.teaching_room_id IN
  546. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  547. #{item}
  548. </foreach>
  549. </if>
  550. </if>
  551. </sql>
  552. <select id="overview" resultType="com.qmth.teachcloud.mark.bean.archivescore.OverViewVo">
  553. SELECT count(*) studentCount,
  554. sum(case
  555. when s.is_absent = 0 and s.omr_absent = 0 and s.is_breach = 0 and s.is_upload = 1 then 1
  556. else 0 end) actualCount,
  557. sum(case when s.is_absent = 1 or s.omr_absent = 1 then 1 else 0 end) absentCount,
  558. sum(case when s.is_breach = 1 then 1 else 0 end) breachCount,
  559. avg(case when s.is_absent !=1 then ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) else null end) avgScore,
  560. max(case when s.is_absent !=1 then ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) else null end) maxScore,
  561. min(case when s.is_absent !=1 then ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) else null end) minScore,
  562. sum(case
  563. when ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) >= t.total_score * t.pass_score / 100 then 1
  564. else 0 end) passCount,
  565. sum(case
  566. when ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) >= t.total_score * t.excellent_score / 100 then 1
  567. else 0 end) excellentCount
  568. FROM mark_student s
  569. left join (select * from basic_exam_student where exam_id=#{req.examId}) bes on s.basic_student_id = bes.id
  570. left join mark_paper t on s.exam_id = t.exam_id
  571. and s.paper_number = t.paper_number
  572. left join sys_user su on bes.teacher_id = su.id
  573. left join (select * from basic_course where school_id = #{schoolId}) bc on s.course_id = bc.id
  574. <include refid="archiveQuery"/>
  575. </select>
  576. <select id="getCountByScoreRange" resultType="int">
  577. SELECT count(*)
  578. FROM mark_student s
  579. WHERE s.exam_id = #{examId}
  580. and s.paper_number = #{paperNumber}
  581. and s.is_absent !=1 and s.objective_score+s.subjective_score&gt;=#{start}
  582. and s.objective_score+s.subjective_score&lt;=#{end}
  583. </select>
  584. <select id="college" resultType="com.qmth.teachcloud.mark.bean.archivescore.CollegeVo">
  585. SELECT bes.college_name college,
  586. count(*) studentCount,
  587. sum(case when s.is_absent = 1 then 1 else 0 end) absentCount,
  588. avg(case when s.is_absent !=1 then ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) else null end) avgScore,
  589. max(case when s.is_absent !=1 then ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) else null end) maxScore,
  590. min(case when s.is_absent !=1 then ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) else null end) minScore,
  591. sum(case
  592. when ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) >= t.total_score * t.pass_score / 100 then 1
  593. else 0 end) passCount,
  594. sum(case
  595. when ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) >= t.total_score * t.excellent_score / 100 then 1
  596. else 0 end) excellentCount
  597. FROM mark_student s
  598. left join mark_paper t on s.exam_id = t.exam_id
  599. and s.paper_number = t.paper_number
  600. left join (select * from basic_exam_student where exam_id=#{req.examId}) bes on s.basic_student_id = bes.id
  601. left join sys_user su on bes.teacher_id = su.id
  602. left join (select * from basic_course where school_id = #{schoolId}) bc on s.course_id = bc.id
  603. <include refid="archiveQuery"/>
  604. and bes.college_name is not null
  605. group by bes.college_name
  606. </select>
  607. <select id="classData" resultType="com.qmth.teachcloud.mark.bean.archivescore.ClassVo">
  608. SELECT bes.teach_class_name className,
  609. count(*) studentCount,
  610. sum(case when s.is_absent = 1 then 1 else 0 end) absentCount,
  611. avg(case when s.is_absent !=1 then ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) else null end) avgScore,
  612. max(case when s.is_absent !=1 then ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) else null end) maxScore,
  613. min(case when s.is_absent !=1 then ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) else null end) minScore,
  614. sum(case
  615. when ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) >= t.total_score * t.pass_score / 100 then 1
  616. else 0 end) passCount,
  617. sum(case
  618. when ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) >= t.total_score * t.excellent_score / 100 then 1
  619. else 0 end) excellentCount
  620. FROM mark_student s
  621. left join mark_paper t on s.exam_id = t.exam_id
  622. and s.paper_number = t.paper_number
  623. left join (select * from basic_exam_student where exam_id=#{req.examId}) bes on s.basic_student_id = bes.id
  624. left join sys_user su on bes.teacher_id = su.id
  625. left join (select * from basic_course where school_id = #{schoolId}) bc on s.course_id = bc.id
  626. <include refid="archiveQuery"/>
  627. and bes.teach_class_name is not null
  628. group by bes.teach_class_name
  629. </select>
  630. <select id="teacher" resultType="com.qmth.teachcloud.mark.bean.archivescore.TeacherVo">
  631. SELECT su.real_name teacher,
  632. bes.teacher_id,
  633. count(*) studentCount,
  634. sum(case when s.is_absent = 1 then 1 else 0 end) absentCount,
  635. avg(case when s.is_absent !=1 then ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) else null end) avgScore,
  636. max(case when s.is_absent !=1 then ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) else null end) maxScore,
  637. min(case when s.is_absent !=1 then ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) else null end) minScore,
  638. sum(case
  639. when ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) >= t.total_score * t.pass_score / 100 then 1
  640. else 0 end) passCount,
  641. sum(case
  642. when ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) >= t.total_score * t.excellent_score / 100 then 1
  643. else 0 end) excellentCount
  644. FROM mark_student s
  645. left join mark_paper t on s.exam_id = t.exam_id
  646. and s.paper_number = t.paper_number
  647. left join (select * from basic_exam_student where exam_id=#{req.examId}) bes on s.basic_student_id = bes.id
  648. left join sys_user su on bes.teacher_id = su.id
  649. left join (select * from basic_course where school_id = #{schoolId}) bc on s.course_id = bc.id
  650. <include refid="archiveQuery"/>
  651. and su.real_name is not null
  652. group by bes.teacher_id, su.real_name
  653. </select>
  654. <select id="findOne" resultType="com.qmth.teachcloud.mark.bean.student.StudentVo"
  655. parameterType="com.qmth.teachcloud.mark.bean.student.StudentQuery">
  656. select ms.id,
  657. bes.student_code studentCode,
  658. bes.student_name studentName,
  659. bc.code courseCode,
  660. bc.name courseName,
  661. ms.course_paper_id coursePaperId,
  662. ms.paper_number coursePaperNumber,
  663. ms.package_code packageCode,
  664. bes.site_number siteNumber,
  665. ms.exam_room examRoom,
  666. ms.scan_status status
  667. from mark_student ms join basic_exam_student bes on ms.basic_student_id = bes.id
  668. left join basic_course bc on ms.course_id = bc.id
  669. where ms.exam_id = #{query.examId}
  670. and ms.course_paper_id = #{query.coursePaperId}
  671. and bes.student_code = #{query.studentCode}
  672. </select>
  673. <select id="listUnexistStudentByExamIdAndCoursePaperId"
  674. resultType="com.qmth.teachcloud.mark.dto.UnexistStudentDto">
  675. SELECT
  676. bc.code courseCode,
  677. bc.name courseName,
  678. so.name teachingRoomName,
  679. t.paper_number paperNumber,
  680. t.student_code studentCode,
  681. bes.student_name studentName
  682. FROM
  683. (select * from mark_student where exam_id = #{examId}) t
  684. left join (select * from basic_exam_student where exam_id = #{examId}) bes on t.basic_student_id = bes.id
  685. left join sys_user su on t.create_id = su.id
  686. left join basic_course bc on t.course_id = bc.id
  687. left join sys_org so on bc.teaching_room_id = so.id
  688. WHERE
  689. t.scan_status = 'UNEXIST'
  690. <if test="courseId != null">
  691. and t.course_id = #{courseId}
  692. </if>
  693. <if test="coursePaperId != null and coursePaperId != ''">
  694. and t.course_paper_id = #{coursePaperId}
  695. </if>
  696. <if test="status != null and status != ''">
  697. and exists(select 1 from mark_paper mp where t.exam_id = mp.exam_id and t.course_paper_id =
  698. mp.course_paper_id and mp.status = #{status})
  699. </if>
  700. <if test="dpr != null">
  701. <if test="dpr.requestUserId != null">
  702. AND t.create_id = #{dpr.requestUserId}
  703. </if>
  704. <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  705. AND bc.teaching_room_id IN
  706. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  707. #{item}
  708. </foreach>
  709. </if>
  710. </if>
  711. order by t.student_code
  712. </select>
  713. <select id="teacherClass" resultType="com.qmth.teachcloud.mark.bean.archivescore.TeacherClassVo">
  714. SELECT bes.teacher_id,
  715. su.real_name teacher,
  716. bes.teach_class_name className,
  717. count(*) studentCount,
  718. sum(case when s.is_absent = 1 then 1 else 0 end) absentCount,
  719. avg(case when s.is_absent !=1 then ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) else null end) avgScore,
  720. max(case when s.is_absent !=1 then ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) else null end) maxScore,
  721. min(case when s.is_absent !=1 then ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) else null end) minScore,
  722. sum(case
  723. when ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) >= t.total_score * t.pass_score / 100 then 1
  724. else 0 end) passCount,
  725. sum(case
  726. when ifnull(s.objective_score,0) + ifnull(s.subjective_score,0) >= t.total_score * t.excellent_score / 100 then 1
  727. else 0 end) excellentCount
  728. FROM mark_student s
  729. left join mark_paper t on s.exam_id = t.exam_id
  730. and s.paper_number = t.paper_number
  731. left join (select * from basic_exam_student where exam_id=#{req.examId}) bes on s.basic_student_id = bes.id
  732. left join sys_user su on bes.teacher_id = su.id
  733. left join (select * from basic_course where school_id = #{schoolId}) bc on s.course_id = bc.id
  734. <include refid="archiveQuery"/>
  735. and bes.teach_class_name is not null
  736. group by bes.teacher_id, su.real_name, bes.teach_class_name
  737. </select>
  738. <select id="selectCountByQuery" resultType="java.lang.Integer">
  739. select count(1) from mark_student ms INNER join basic_course bc on ms.course_id = bc.id
  740. <if test="dpr != null and dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  741. AND bc.teaching_room_id IN
  742. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  743. #{item}
  744. </foreach>
  745. </if>
  746. <if test="markStudent.markPaperStatus != null">
  747. INNER JOIN mark_paper mp ON ms.exam_id = mp.exam_id
  748. and ms.paper_number = mp.paper_number
  749. and mp.status = #{markStudent.markPaperStatus}
  750. </if>
  751. <where>
  752. and ms.exam_id = #{markStudent.examId}
  753. <if test="markStudent.courseId != null">
  754. and ms.course_id = #{markStudent.courseId}
  755. </if>
  756. <if test="markStudent.paperNumber != null and markStudent.paperNumber != ''">
  757. and ms.paper_number = #{markStudent.paperNumber}
  758. </if>
  759. <if test="markStudent.paperType != null and markStudent.paperType != ''">
  760. and ms.paper_type = #{markStudent.paperType}
  761. </if>
  762. <if test="markStudent.coursePaperId != null and markStudent.coursePaperId != ''">
  763. and ms.course_paper_id = #{markStudent.coursePaperId}
  764. </if>
  765. <if test="markStudent.scanStatus != null">
  766. and ms.scan_status = #{markStudent.scanStatus}
  767. </if>
  768. <if test="markStudent.manualAbsent != null">
  769. and ms.is_manual_absent = #{markStudent.manualAbsent}
  770. </if>
  771. <if test="markStudent.omrAbsent != null">
  772. and ms.omr_absent = #{markStudent.omrAbsent}
  773. </if>
  774. <if test="markStudent.omrAbsentChecked != null">
  775. and ms.omr_absent_checked = #{markStudent.omrAbsentChecked}
  776. </if>
  777. <if test="markStudent.incomplete != null">
  778. and ms.incomplete = #{markStudent.incomplete}
  779. </if>
  780. <if test="markStudent.missScan != null">
  781. and ms.miss_scan = #{markStudent.missScan}
  782. </if>
  783. <if test="markStudent.paperTypeCheckStatus != null">
  784. and ms.paper_type_check_status = #{markStudent.paperTypeCheckStatus}
  785. </if>
  786. <if test="dpr != null and dpr.requestUserId != null">
  787. AND ms.create_id = #{dpr.requestUserId}
  788. </if>
  789. </where>
  790. </select>
  791. <select id="countAssigned" resultType="java.lang.Integer">
  792. SELECT
  793. count(1)
  794. FROM
  795. mark_student ms
  796. LEFT JOIN basic_course bc ON ms.course_id = bc.id
  797. <if test="dpr != null and dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  798. AND bc.teaching_room_id IN
  799. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  800. #{item}
  801. </foreach>
  802. </if>
  803. <if test="markStudent.markPaperStatus != null">
  804. INNER JOIN mark_paper mp ON ms.exam_id = mp.exam_id
  805. and ms.paper_number = mp.paper_number
  806. and mp.status = #{markStudent.markPaperStatus}
  807. </if>
  808. <where>
  809. ms.exam_id = #{markStudent.examId}
  810. <if test="markStudent.courseId != null">
  811. AND ms.course_id = #{markStudent.courseId}
  812. </if>
  813. <if test="markStudent.coursePaperId != null">
  814. AND ms.course_paper_id = #{markStudent.coursePaperId}
  815. </if>
  816. <if test="markStudent.assigned != null">
  817. AND ms.assigned = #{markStudent.assigned}
  818. </if>
  819. <if test="markStudent.assignConfirmed != null">
  820. AND ms.assign_confirmed = #{markStudent.assignConfirmed}
  821. </if>
  822. <if test="dpr != null and dpr.requestUserId != null">
  823. AND ms.create_id = #{dpr.requestUserId}
  824. </if>
  825. </where>
  826. </select>
  827. <select id="listScanCollegeByExamIdAndCourseCodeAndCoursePaperId"
  828. resultType="com.qmth.teachcloud.mark.entity.MarkStudent">
  829. SELECT
  830. distinct ms.exam_place, ms.exam_room
  831. FROM
  832. mark_student ms
  833. LEFT JOIN basic_course bc ON ms.course_id = bc.id
  834. <where>
  835. ms.exam_id = #{examId}
  836. <if test="courseId != null">
  837. AND ms.course_id = #{courseId}
  838. </if>
  839. <if test="coursePaperId != null and coursePaperId != ''">
  840. AND ms.course_paper_id = #{coursePaperId}
  841. </if>
  842. <if test="dpr != null">
  843. <if test="dpr.requestUserId != null">
  844. AND ms.create_id = #{dpr.requestUserId}
  845. </if>
  846. <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  847. AND bc.teaching_room_id IN
  848. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  849. #{item}
  850. </foreach>
  851. </if>
  852. </if>
  853. <if test="status != null">
  854. AND exists(select 1 from mark_paper mp where ms.exam_id = mp.exam_id and ms.paper_number =
  855. mp.paper_number and mp.status = #{status})
  856. </if>
  857. </where>
  858. </select>
  859. <select id="getBasicTeachClazzById" resultType="com.qmth.teachcloud.common.entity.BasicTeachClazz"
  860. parameterType="java.lang.Long">
  861. select * from basic_teach_clazz where id = #{clazzId}
  862. </select>
  863. <select id="maxCardNumber" resultType="java.lang.Integer">
  864. select max(card_number) from mark_student where exam_id = #{examId} and paper_number = #{paperNumber} and card_number is not null
  865. </select>
  866. <select id="selectByExamIdAndCoursePaperIdAndStudentCode"
  867. resultType="com.qmth.teachcloud.mark.entity.MarkStudent">
  868. select ms.id,
  869. bes.student_code,
  870. bes.student_name,
  871. bc.code courseCode,
  872. bc.name courseName,
  873. ms.paper_number,
  874. ms.course_paper_id,
  875. ms.exam_id,
  876. ms.exam_place,
  877. ms.exam_room,
  878. ms.scan_status,
  879. ms.is_absent absent,
  880. ms.is_upload upload,
  881. ms.is_manual_absent manualAbsent,
  882. ms.omr_absent,
  883. ms.omr_absent_checked
  884. from mark_student ms
  885. LEFT JOIN
  886. basic_exam_student bes on ms.basic_student_id = bes.id
  887. left join
  888. basic_course bc on bc.id = bes.course_id
  889. where ms.exam_id = #{examId} and ms.course_paper_id = #{coursePaperId} and bes.student_code = #{studentCode}
  890. </select>
  891. <select id="listMarkStudentVo" resultType="com.qmth.teachcloud.mark.dto.mark.MarkStudentVo">
  892. SELECT
  893. ms.*,
  894. ms.is_upload upload,
  895. ms.is_absent absent,
  896. ms.is_breach breach,
  897. ms.is_manual_absent manualAbsent,
  898. bes.student_name,
  899. bc.code courseCode,
  900. bc.name courseName,
  901. bes.college_name,
  902. bes.major_name,
  903. bes.teach_class_name AS teachClassName,
  904. bes.class_name,
  905. su.real_name teacher,
  906. bes.teacher_id
  907. FROM
  908. mark_student ms
  909. LEFT JOIN
  910. basic_exam_student bes ON ms.basic_student_id = bes.id
  911. LEFT JOIN
  912. basic_course bc ON ms.course_id = bc.id
  913. LEFT JOIN
  914. sys_user su ON bes.teacher_id = su.id
  915. <where>
  916. <if test="markStudentQuery.id != null">
  917. and ms.id = #{markStudentQuery.id}
  918. </if>
  919. <if test="markStudentQuery.examId != null">
  920. and ms.exam_id = #{markStudentQuery.examId}
  921. </if>
  922. <if test="markStudentQuery.paperNumber != null">
  923. and ms.paper_number = #{markStudentQuery.paperNumber}
  924. </if>
  925. <if test="markStudentQuery.upload != null">
  926. and ms.is_upload = #{markStudentQuery.upload}
  927. </if>
  928. <if test="markStudentQuery.absent != null">
  929. and ms.is_absent = #{markStudentQuery.absent}
  930. </if>
  931. <if test="markStudentQuery.breach != null">
  932. and ms.is_breach = #{markStudentQuery.breach}
  933. </if>
  934. <if test="markStudentQuery.omrAbsent != null">
  935. and ms.omr_absent = #{markStudentQuery.omrAbsent}
  936. </if>
  937. </where>
  938. </select>
  939. <select id="countOmrAbsentStudent" resultType="java.lang.Integer">
  940. select count(1) from mark_student ms
  941. left join basic_exam_student bes on bes.id = ms.basic_student_id
  942. <where> 1 = 1
  943. <if test="examId != null and examId != ''">
  944. and ms.exam_id = #{examId}
  945. </if>
  946. <if test="paperNumber != null and paperNumber != ''">
  947. and ms.paper_number = #{paperNumber}
  948. </if>
  949. and ms.omr_absent = true
  950. <if test="isOmrAbsentConfirm != null and isOmrAbsentConfirm != '' or isOmrAbsentConfirm == 0">
  951. and ms.omr_absent_checked = #{isOmrAbsentConfirm}
  952. </if>
  953. <if test="teachClassName != null and teachClassName != ''">
  954. and bes.teach_class_name = #{teachClassName}
  955. </if>
  956. </where>
  957. </select>
  958. <select id="countAssignedNew" resultType="java.lang.Integer">
  959. SELECT
  960. count(1)
  961. FROM
  962. mark_student ms
  963. LEFT JOIN basic_course bc ON ms.course_id = bc.id
  964. left join basic_exam_student bes on bes.id = ms.basic_student_id
  965. <where>
  966. ms.exam_id = #{markStudent.examId}
  967. <if test="markStudent.courseId != null">
  968. AND ms.course_id = #{markStudent.courseId}
  969. </if>
  970. <if test="markStudent.coursePaperId != null">
  971. AND ms.course_paper_id = #{markStudent.coursePaperId}
  972. </if>
  973. <if test="markStudent.assigned != null">
  974. AND ms.assigned = #{markStudent.assigned}
  975. </if>
  976. <if test="markStudent.assignConfirmed != null">
  977. AND ms.assign_confirmed = #{markStudent.assignConfirmed}
  978. </if>
  979. <if test="dpr != null">
  980. <if test="dpr.requestUserId != null">
  981. AND ms.create_id = #{dpr.requestUserId}
  982. </if>
  983. <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  984. AND bc.teaching_room_id IN
  985. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  986. #{item}
  987. </foreach>
  988. </if>
  989. </if>
  990. <if test="markStudent.markPaperStatus != null">
  991. AND exists(select 1 from mark_paper mp where ms.exam_id = mp.exam_id and ms.paper_number =
  992. mp.paper_number and mp.status = #{markStudent.markPaperStatus})
  993. </if>
  994. <if test="teachClassName != null and teachClassName != ''">
  995. and bes.teach_class_name = #{teachClassName}
  996. </if>
  997. </where>
  998. </select>
  999. <select id="getDetailById" resultType="com.qmth.teachcloud.mark.dto.mark.MarkStudentVo">
  1000. SELECT
  1001. bes.student_code,
  1002. bes.student_name,
  1003. bc.code courseCode,
  1004. bc.name courseName,
  1005. ms.paper_number,
  1006. bes.college_name,
  1007. bes.major_name,
  1008. bes.teach_class_name,
  1009. bes.class_name
  1010. FROM
  1011. mark_student ms
  1012. LEFT JOIN
  1013. basic_exam_student bes ON ms.basic_student_id = bes.id
  1014. LEFT JOIN
  1015. basic_course bc ON ms.course_id = bc.id
  1016. where
  1017. ms.id = #{studentId}
  1018. </select>
  1019. <select id="findExamTaskPaperTypeOpenStatus" resultType="com.qmth.teachcloud.mark.dto.mark.AbInfoVo">
  1020. SELECT
  1021. et.open_ab openAb,
  1022. bcr.paper_type paperTypeStyle
  1023. FROM
  1024. exam_task et
  1025. LEFT JOIN
  1026. basic_card_rule bcr ON et.card_rule_id = bcr.id
  1027. <where>
  1028. <if test="examId != null">
  1029. AND exam_id = #{examId}
  1030. </if>
  1031. <if test="paperNumber != null and paperNumber != ''">
  1032. AND paper_number = #{paperNumber}
  1033. </if>
  1034. </where>
  1035. </select>
  1036. <select id="findUnMarked" resultType="java.lang.Long">
  1037. SELECT m.id
  1038. FROM mark_student m
  1039. <where>
  1040. m.exam_id = #{examId}
  1041. AND m.paper_number = #{paperNumber}
  1042. AND m.subjective_status = 'UNMARK'
  1043. AND EXISTS(SELECT 1
  1044. FROM mark_task mt
  1045. WHERE m.id = mt.student_id)
  1046. <if test="classMark == true">
  1047. AND EXISTS (
  1048. SELECT 1
  1049. FROM
  1050. (select * from mark_user_class where exam_id = #{examId} and paper_number = #{paperNumber} and user_id = #{userId}) mc
  1051. join
  1052. (select ms.id, bes.teach_class_name from (select * from mark_student where exam_id = #{examId} and paper_number = #{paperNumber}) ms join (select id,teach_class_name from basic_exam_student where exam_id = #{examId}) bes on ms.basic_student_id = bes.id) s on mc.class_name = s.teach_class_name
  1053. WHERE m.id = s.id
  1054. )
  1055. </if>
  1056. </where>
  1057. </select>
  1058. </mapper>