ExamDetailMapper.xml 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781
  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.distributed.print.business.mapper.ExamDetailMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.qmth.distributed.print.business.entity.ExamDetail">
  6. <result column="id" property="id" />
  7. <result column="school_id" property="schoolId" />
  8. <result column="print_plan_id" property="printPlanId" />
  9. <result column="print_plan_name" property="printPlanName" />
  10. <result column="exam_start_time" property="examStartTime" />
  11. <result column="exam_end_time" property="examEndTime" />
  12. <result column="exam_place" property="examPlace" />
  13. <result column="total_subjects" property="totalSubjects" />
  14. <result column="exam_room" property="examRoom" />
  15. <result column="print_progress" property="printProgress" />
  16. <result column="print_user" property="printUser" />
  17. <result column="package_code" property="packageCode" />
  18. <result column="create_id" property="createId" />
  19. <result column="create_time" property="createTime" />
  20. </resultMap>
  21. <!-- 通用查询结果列 -->
  22. <sql id="Base_Column_List">
  23. id,
  24. school_id, print_plan_id, print_plan_name, exam_name, exam_start_time, exam_end_time, exam_place, total_subjects, exam_room, print_progress, print_user, package_code, create_id, create_time
  25. </sql>
  26. <select id="listPrintTask" resultType="com.qmth.distributed.print.business.bean.dto.PrintTaskDto">
  27. SELECT
  28. b.id examDetailId,
  29. b.package_code packageCode,
  30. a.id printPlanId,
  31. a.name printPlanName,
  32. b.exam_start_time examStartTime,
  33. b.exam_end_time examEndTime,
  34. c.courseNameCode,
  35. c.paperNumber,
  36. b.exam_place examPlace,
  37. b.exam_room examRoom,
  38. b.total_subjects totalSubjects,
  39. ifnull(b.paper_pages, 0) paperPages,
  40. ifnull(b.card_pages, 0) cardPages,
  41. ifnull(b.pages_a4, 0) pagesA4,
  42. c.singlePagesA3,
  43. b.status,
  44. b.validate,
  45. b.print_start_time printStartTime,
  46. b.print_end_time printEndTime,
  47. b.normal,
  48. b.print_house_id as printHouseId,
  49. b.task_id taskId,
  50. e.name as printHouseName,
  51. e.code as printHouseCode,
  52. a.semester_id as semesterId,
  53. a.semester_name as semesterName,
  54. a.exam_id as examId,
  55. a.exam_name as examName
  56. FROM
  57. (select epp.id, epp.exam_id, epp.name, be.name exam_name, bs.id semester_id, bs.name semester_name
  58. from exam_print_plan epp
  59. LEFT JOIN
  60. basic_exam be ON be.id = epp.exam_id
  61. LEFT JOIN
  62. basic_semester bs ON bs.id = be.semester_id
  63. <where>
  64. <if test="schoolId != null">
  65. and epp.school_id = #{schoolId}
  66. </if>
  67. <if test="semesterId != null">
  68. and bs.id = #{semesterId}
  69. </if>
  70. <if test="examId != null">
  71. and be.id = #{examId}
  72. </if>
  73. <if test="printPlanId != null">
  74. and epp.id = #{printPlanId}
  75. </if>
  76. <if test="dpr != null">
  77. <if test="dpr.requestUserId != null">
  78. AND epp.create_id = #{dpr.requestUserId}
  79. </if>
  80. <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  81. AND epp.org_id IN
  82. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  83. #{item}
  84. </foreach>
  85. </if>
  86. </if>
  87. </where>) a
  88. JOIN
  89. (select * from exam_detail
  90. <where>
  91. <if test="status != null and status != ''">
  92. and status = #{status}
  93. </if>
  94. <if test="examPlace != null and examPlace != ''">
  95. and exam_place = #{examPlace}
  96. </if>
  97. <if test="examRoom != null and examRoom != ''">
  98. and exam_room = #{examRoom}
  99. </if>
  100. <if test="examStartTime != null and examStartTime != ''">
  101. and exam_start_time &gt; #{examStartTime}
  102. </if>
  103. <if test="examEndTime != null and examEndTime != ''">
  104. and exam_end_time &lt; #{examEndTime}
  105. </if>
  106. <if test="printStartTime != null and printStartTime != ''">
  107. and print_start_time &gt; #{printStartTime}
  108. </if>
  109. <if test="printEndTime != null and printEndTime != ''">
  110. and print_start_time &lt; #{printEndTime}
  111. </if>
  112. <if test="printHouseId != null and printHouseId != ''">
  113. and print_house_id = #{printHouseId}
  114. </if>
  115. </where>) b ON a.id = b.print_plan_id
  116. JOIN
  117. (SELECT
  118. exam_detail_id,
  119. GROUP_CONCAT(CONCAT(course_name, '(', course_code, ')')) courseNameCode,
  120. GROUP_CONCAT(paper_number) paperNumber,
  121. GROUP_CONCAT(ifnull(paper_pages_a3, 0) + ifnull(card_pages_a3, 0)) singlePagesA3
  122. FROM
  123. exam_detail_course
  124. <where>
  125. <if test="courseCode != null and courseCode != ''">
  126. and course_code = #{courseCode}
  127. </if>
  128. <if test="paperNumber != null and paperNumber != ''">
  129. and paper_number = #{paperNumber}
  130. </if>
  131. </where>
  132. GROUP BY exam_detail_id) c ON b.id = c.exam_detail_id
  133. LEFT JOIN
  134. sys_org e ON b.print_house_id = e.id
  135. ORDER BY b.id desc
  136. </select>
  137. <select id="findBriefPage" resultType="com.qmth.distributed.print.business.bean.result.ExaminationResult">
  138. SELECT
  139. det.id AS id,
  140. MAX(bs.id) AS semesterId,
  141. MAX(bs.name) AS semesterName,
  142. MAX(be.id) AS examId,
  143. MAX(be.name) AS examName,
  144. MAX(det.school_id) AS schoolId,
  145. MAX(det.print_plan_id) AS printPlanId,
  146. MAX(det.print_plan_name) AS printPlanName,
  147. MAX(det.exam_start_time) AS examStartTime,
  148. MAX(det.exam_end_time) AS examEndTime,
  149. MAX(det.exam_place) AS examPlace,
  150. MAX(det.total_subjects) AS totalSubjects,
  151. MAX(det.exam_room) AS examRoom,
  152. MAX(det.package_code) AS packageCode,
  153. MAX(det.create_id) AS createId,
  154. MAX(det.create_time) AS createTime,
  155. GROUP_CONCAT(cou.id) AS examDetailCourseIds,
  156. GROUP_CONCAT(CONCAT(cou.course_name, '(', cou.course_code, ')')) AS courseNameCode,
  157. GROUP_CONCAT(cou.course_code) AS courseCodes,
  158. GROUP_CONCAT(cou.paper_number) AS paperNumber
  159. FROM
  160. exam_detail det
  161. INNER JOIN
  162. exam_detail_course cou ON det.id = cou.exam_detail_id
  163. LEFT JOIN
  164. basic_exam be on be.id = det.exam_id
  165. LEFT JOIN
  166. basic_semester bs on bs.id = be.semester_id
  167. <where>
  168. and be.enable = true
  169. <if test="schoolId != null and schoolId > 0">
  170. AND det.school_id = #{schoolId}
  171. </if>
  172. <if test="printPlanIdList != null and printPlanIdList != '' and printPlanIdList.size() > 0">
  173. AND det.print_plan_id IN
  174. <foreach collection="printPlanIdList" item="item" index="index" open="(" separator="," close=")">
  175. #{item}
  176. </foreach>
  177. </if>
  178. <if test="examPlace != null and examPlace != ''">
  179. AND det.exam_place = #{examPlace}
  180. </if>
  181. <if test="examRoom != null and examRoom != ''">
  182. AND det.exam_room = #{examRoom}
  183. </if>
  184. <if test="packageCode != null and packageCode != ''">
  185. AND det.package_code = #{packageCode}
  186. </if>
  187. <if test="startDate != null and startDate > 0">
  188. AND det.exam_start_time >= #{startDate}
  189. </if>
  190. <if test="endDate != null and endDate > 0">
  191. AND #{endDate} >= det.exam_end_time
  192. </if>
  193. <if test="semesterId != null and semesterId != ''">
  194. AND bs.id = #{semesterId}
  195. </if>
  196. <if test="examId != null and examId != ''">
  197. AND be.id = #{examId}
  198. </if>
  199. <if test="dpr != null">
  200. <if test="dpr.requestUserId != null">
  201. AND det.create_id = #{dpr.requestUserId}
  202. </if>
  203. <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  204. AND det.org_id IN
  205. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  206. #{item}
  207. </foreach>
  208. </if>
  209. </if>
  210. </where>
  211. GROUP BY det.id
  212. <trim prefix="having" suffixOverrides="and">
  213. <if test="courseCode != null and courseCode != ''">
  214. find_in_set(#{courseCode},courseCodes) and
  215. </if>
  216. <if test="paperNumber != null and paperNumber != ''">
  217. find_in_set(#{paperNumber},paperNumber) and
  218. </if>
  219. </trim>
  220. order by det.id desc
  221. </select>
  222. <select id="findDetailPage"
  223. resultType="com.qmth.distributed.print.business.bean.result.ExaminationDetailResult">
  224. SELECT
  225. stu.id AS id,
  226. stu.exam_detail_course_id,
  227. stu.student_name AS studentName,
  228. stu.student_code AS studentCode,
  229. stu.ticket_number AS ticketNumber,
  230. stu.site_number AS siteNumber,
  231. stu.create_id AS createId,
  232. stu.create_time AS createTime,
  233. a.exam_id AS examId,
  234. a.exam_name AS examName,
  235. CONCAT(a.course_name,
  236. '(',
  237. a.course_code,
  238. ')') AS courseNameCode,
  239. a.paper_number AS paperNumber,
  240. a.print_plan_id AS printPlanId,
  241. a.print_plan_name AS printPlanName,
  242. a.exam_start_time AS examStartTime,
  243. a.exam_end_time AS examEndTime,
  244. a.exam_place AS examPlace,
  245. a.exam_room AS examRoom
  246. FROM
  247. (select be.id exam_id,
  248. be.name exam_name,
  249. edc.id exam_detail_course_id,
  250. edc.course_code,
  251. edc.course_name,
  252. edc.paper_number,
  253. ed.print_plan_id,
  254. ed.print_plan_name,
  255. ed.exam_start_time,
  256. ed.exam_end_time,
  257. ed.exam_place,
  258. ed.exam_room
  259. from exam_detail ed
  260. JOIN
  261. exam_detail_course edc on ed.id = edc.exam_detail_id
  262. LEFT JOIN
  263. sys_user b on ed.create_id = b.id
  264. LEFT JOIN
  265. basic_exam be ON be.id = ed.exam_id
  266. LEFT JOIN
  267. basic_semester bs ON bs.id = be.semester_id
  268. <where>
  269. and be.enable = true
  270. <if test="schoolId != null">
  271. AND ed.school_id = #{schoolId}
  272. </if>
  273. <if test="semesterId != null">
  274. and bs.id = #{semesterId}
  275. </if>
  276. <if test="examId != null">
  277. and be.id = #{examId}
  278. </if>
  279. <if test="printPlanIdList != null and printPlanIdList != '' and printPlanIdList.size() > 0">
  280. AND ed.print_plan_id IN
  281. <foreach collection="printPlanIdList" item="item" index="index" open="(" separator="," close=")">
  282. #{item}
  283. </foreach>
  284. </if>
  285. <if test="courseCode != null and courseCode != ''">
  286. AND edc.course_code = #{courseCode}
  287. </if>
  288. <if test="paperNumber != null and paperNumber != ''">
  289. AND edc.paper_number = #{paperNumber}
  290. </if>
  291. <if test="examPlace != null and examPlace != ''">
  292. AND ed.exam_place = #{examPlace}
  293. </if>
  294. <if test="examRoom != null and examRoom != ''">
  295. AND ed.exam_room = #{examRoom}
  296. </if>
  297. <if test="startDate != null and startDate > 0">
  298. AND ed.exam_start_time &gt;= #{startDate}
  299. </if>
  300. <if test="endDate != null and endDate > 0">
  301. AND ed.exam_end_time &lt;= #{endDate}
  302. </if>
  303. <if test="dpr != null">
  304. <if test="dpr.requestUserId != null">
  305. AND b.id = #{dpr.requestUserId}
  306. </if>
  307. <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  308. AND b.org_id IN
  309. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  310. #{item}
  311. </foreach>
  312. </if>
  313. </if>
  314. </where>) a
  315. join
  316. exam_student stu ON a.exam_detail_course_id = stu.exam_detail_course_id
  317. <where>
  318. <if test="studentParams != null and studentParams != ''">
  319. AND (stu.ticket_number LIKE CONCAT('%',#{studentParams},'%') OR stu.student_code LIKE CONCAT('%',#{studentParams},'%') OR stu.student_name LIKE CONCAT('%',#{studentParams},'%'))
  320. </if>
  321. </where>
  322. order by stu.exam_detail_course_id desc, stu.id desc
  323. </select>
  324. <select id="findDetailPageById"
  325. resultType="com.qmth.distributed.print.business.bean.result.ExaminationDetailResult">
  326. SELECT
  327. stu.id AS id,
  328. stu.exam_detail_course_id,
  329. stu.student_name AS studentName,
  330. stu.student_code AS studentCode,
  331. stu.ticket_number AS ticketNumber,
  332. stu.site_number AS siteNumber,
  333. stu.create_id AS createId,
  334. stu.create_time AS createTime,
  335. CONCAT(cou.course_name,
  336. '(',
  337. cou.course_code,
  338. ')') AS courseNameCode,
  339. cou.paper_number AS paperNumber,
  340. det.print_plan_id AS printPlanId,
  341. det.print_plan_name AS printPlanName,
  342. det.exam_place AS examPlace,
  343. det.exam_room AS examRoom,
  344. bs.id AS semesterId,
  345. bs.name AS semesterName,
  346. be.id AS examId,
  347. be.name AS examName,
  348. stu.can_delete canDelete
  349. FROM
  350. exam_student stu
  351. INNER JOIN
  352. exam_detail_course cou ON stu.exam_detail_course_id = cou.id
  353. AND stu.school_id = cou.school_id
  354. INNER JOIN
  355. exam_detail det ON cou.exam_detail_id = det.id
  356. AND stu.school_id = det.school_id
  357. LEFT JOIN
  358. exam_print_plan epp ON det.print_plan_id = epp.id
  359. LEFT JOIN
  360. basic_exam be ON be.id = epp.exam_id
  361. LEFT JOIN
  362. basic_semester bs ON bs.id = be.semester_id
  363. <where>
  364. <if test="examDetailId != null">
  365. AND det.id = #{examDetailId}
  366. </if>
  367. <if test="param != null and param != ''">
  368. AND (stu.student_name like concat('%', #{param}) or stu.student_code like concat('%', #{param}))
  369. </if>
  370. </where>
  371. order by stu.can_delete desc, stu.student_code
  372. </select>
  373. <select id="taskTotalData" resultType="com.qmth.distributed.print.business.bean.dto.PrintTaskTotalDto">
  374. SELECT
  375. ifnull(count(b.package_code), 0) packageCount,
  376. ifnull(sum(b.total_subjects), 0) totalSubjects,
  377. ifnull(sum(ifnull(b.paper_pages, 0)), 0)/2 paperPages,
  378. ifnull(sum(ifnull(b.card_pages, 0)), 0)/2 cardPages,
  379. ifnull(sum(ifnull(b.pages_a4, 0)), 0) /2 pagesA4,
  380. ifnull(sum(case b.status when 'FINISH' then 0 else ifnull(b.paper_pages, 0) end),0)/2 paperPagesLeft,
  381. ifnull(sum(case b.status when 'FINISH' then 0 else ifnull(b.card_pages, 0) end),0)/2 cardPagesLeft,
  382. ifnull(sum(case b.status when 'FINISH' then 0 else ifnull(b.pages_a4, 0) end),0)/2 pagesA4Left
  383. FROM
  384. (select epp.id from exam_print_plan epp
  385. LEFT JOIN
  386. basic_exam be ON be.id = epp.exam_id
  387. LEFT JOIN
  388. basic_semester bs ON bs.id = be.semester_id
  389. <where>
  390. and be.enable = true
  391. <if test="schoolId != null">
  392. and epp.school_id = #{schoolId}
  393. </if>
  394. <if test="semesterId != null">
  395. and bs.id = #{semesterId}
  396. </if>
  397. <if test="examId != null">
  398. and be.id = #{examId}
  399. </if>
  400. <if test="printPlanId != null">
  401. and epp.id = #{printPlanId}
  402. </if>
  403. <if test="dpr != null">
  404. <if test="dpr.requestUserId != null">
  405. AND epp.create_id = #{dpr.requestUserId}
  406. </if>
  407. <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  408. AND epp.org_id IN
  409. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  410. #{item}
  411. </foreach>
  412. </if>
  413. </if>
  414. </where>) a
  415. JOIN
  416. (select * from exam_detail ed
  417. <where>
  418. <if test="status != null and status != ''">
  419. and ed.status = #{status}
  420. </if>
  421. <if test="examPlace != null and examPlace != ''">
  422. and ed.exam_place = #{examPlace}
  423. </if>
  424. <if test="examRoom != null and examRoom != ''">
  425. and ed.exam_room = #{examRoom}
  426. </if>
  427. <if test="examStartTime != null and examStartTime != ''">
  428. and ed.exam_start_time &gt; #{examStartTime}
  429. </if>
  430. <if test="examEndTime != null and examEndTime != ''">
  431. and ed.exam_end_time &lt; #{examEndTime}
  432. </if>
  433. <if test="printStartTime != null and printStartTime != ''">
  434. and ed.print_start_time &gt; #{printStartTime}
  435. </if>
  436. <if test="printEndTime != null and printEndTime != ''">
  437. and ed.print_start_time &lt; #{printEndTime}
  438. </if>
  439. <if test="printHouseId != null and printHouseId != ''">
  440. and ed.print_house_id = #{printHouseId}
  441. </if>
  442. <if test="courseCode != null or paperNumber != null">
  443. and exists (select 1 from exam_detail_course edc where ed.id = edc.exam_detail_id
  444. <if test="courseCode != null">
  445. and edc.course_code = #{courseCode}
  446. </if>
  447. <if test="paperNumber != null">
  448. and edc.paper_number = #{paperNumber}
  449. </if>
  450. )
  451. </if>
  452. </where>) b ON a.id = b.print_plan_id
  453. </select>
  454. <select id="listStudentByExamDetailCourseId" resultType="java.util.Map">
  455. SELECT
  456. b.course_code courseCode,
  457. b.course_name courseName,
  458. b.paper_number paperNumber,
  459. c.student_name studentName,
  460. c.student_code studentCode,
  461. c.attachment_id attachmentId,
  462. c.paper_type paperType
  463. FROM
  464. exam_detail a
  465. JOIN
  466. exam_detail_course b ON a.id = b.exam_detail_id
  467. JOIN
  468. exam_student c ON b.id = c.exam_detail_course_id
  469. WHERE
  470. b.id = #{examDetailCourseId}
  471. <if test="type == 'ONE'">
  472. and c.student_code = #{studentCode}
  473. </if>
  474. <if test="type == 'MORE'">
  475. and c.student_code >= #{studentCode}
  476. </if>
  477. </select>
  478. <select id="selectPaperCount" resultType="java.lang.Integer">
  479. SELECT
  480. count(distinct c.paper_number, c.paper_type)
  481. FROM
  482. exam_print_plan a
  483. JOIN
  484. exam_detail b ON a.id = b.print_plan_id
  485. JOIN
  486. exam_detail_course c ON b.id = c.exam_detail_id
  487. JOIN
  488. sys_user d ON a.create_id = d.id
  489. JOIN
  490. basic_exam e ON a.exam_id = e.id
  491. <where>
  492. and c.paper_type is not null and e.enable = true
  493. <if test="schoolId != null and schoolId != ''">
  494. and a.school_id = #{schoolId}
  495. </if>
  496. <if test="semesterId != null and semesterId != ''">
  497. and e.semester_id = #{semesterId}
  498. </if>
  499. <if test="examId != null and examId != ''">
  500. and e.id = #{examId}
  501. </if>
  502. <if test="printPlanId != null and printPlanId != ''">
  503. and a.id = #{printPlanId}
  504. </if>
  505. <if test="status != null and status != ''">
  506. and b.status = #{status}
  507. </if>
  508. <if test="courseCode != null and courseCode != ''">
  509. and c.course_code = #{courseCode}
  510. </if>
  511. <if test="paperNumber != null and paperNumber != ''">
  512. and c.paper_number = #{paperNumber}
  513. </if>
  514. <if test="examPlace != null and examPlace != ''">
  515. and b.exam_place = #{examPlace}
  516. </if>
  517. <if test="examRoom != null and examRoom != ''">
  518. and b.exam_room = #{examRoom}
  519. </if>
  520. <if test="examStartTime != null and examStartTime != ''">
  521. and b.exam_start_time &gt; #{examStartTime}
  522. </if>
  523. <if test="examEndTime != null and examEndTime != ''">
  524. and b.exam_end_time &lt; #{examEndTime}
  525. </if>
  526. <if test="printHouseId != null and printHouseId != ''">
  527. and b.print_house_id = #{printHouseId}
  528. </if>
  529. <if test="dpr != null">
  530. <if test="dpr.requestUserId != null">
  531. AND a.create_id = #{dpr.requestUserId}
  532. </if>
  533. <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  534. AND a.org_id IN
  535. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  536. #{item}
  537. </foreach>
  538. </if>
  539. </if>
  540. </where>
  541. </select>
  542. <select id="findPdfDownload" resultType="com.qmth.distributed.print.business.bean.dto.ExamDetailPdfDownloadDto">
  543. select
  544. ed.*,
  545. bs.name as semesterName,
  546. be.name as examName,
  547. GROUP_CONCAT(CONCAT(edc.course_name, '(', edc.course_code, ')')) as courseNameCode,
  548. GROUP_CONCAT(edc.paper_number) paperNumber
  549. from
  550. exam_detail ed
  551. join exam_print_plan epp on
  552. epp.id = ed.print_plan_id
  553. join basic_exam be on
  554. be.id = epp.exam_id
  555. join basic_semester bs on
  556. bs.id = be.semester_id
  557. join exam_detail_course edc on
  558. edc.exam_detail_id = ed.id
  559. <where>
  560. <if test="ids != null and ids != '' and ids.size > 0">
  561. AND ed.id IN
  562. <foreach collection="ids" item="id" index="index" open="(" separator="," close=")">
  563. #{id}
  564. </foreach>
  565. </if>
  566. </where>
  567. GROUP BY
  568. edc.exam_detail_id
  569. order by bs.name
  570. </select>
  571. <select id="findSummarizedData"
  572. resultType="com.qmth.distributed.print.business.bean.result.SummarizedDataResult">
  573. SELECT
  574. det.school_id schoolId,
  575. sum(ifnull(det.total_subjects, 0)) AS totalSubjects,
  576. count(det.package_code) AS packageCount,
  577. GROUP_CONCAT(cou.course_code) AS courseCodes,
  578. GROUP_CONCAT(cou.paper_number) AS paperNumbers
  579. FROM
  580. exam_detail det
  581. INNER JOIN
  582. exam_detail_course cou ON det.id = cou.exam_detail_id
  583. LEFT JOIN
  584. exam_print_plan epp on epp.id = det.print_plan_id
  585. LEFT JOIN
  586. basic_exam be on be.id = epp.exam_id
  587. LEFT JOIN
  588. basic_semester bs on bs.id = be.semester_id
  589. <where>
  590. <if test="schoolId != null and schoolId > 0">
  591. AND det.school_id = #{schoolId}
  592. </if>
  593. <if test="semesterId != null and semesterId != ''">
  594. AND bs.id = #{semesterId}
  595. </if>
  596. <if test="examId != null and examId != ''">
  597. AND be.id = #{examId}
  598. </if>
  599. <if test="printPlanIdList != null and printPlanIdList != '' and printPlanIdList.size() > 0">
  600. AND det.print_plan_id IN
  601. <foreach collection="printPlanIdList" item="item" index="index" open="(" separator="," close=")">
  602. #{item}
  603. </foreach>
  604. </if>
  605. <if test="courseCode != null and courseCode != ''">
  606. AND cou.course_code = #{courseCode}
  607. </if>
  608. <if test="paperNumber != null and paperNumber != ''">
  609. AND cou.paper_number = #{paperNumber}
  610. </if>
  611. <if test="examPlace != null and examPlace != ''">
  612. AND det.exam_place = #{examPlace}
  613. </if>
  614. <if test="examRoom != null and examRoom != ''">
  615. AND det.exam_room = #{examRoom}
  616. </if>
  617. <if test="packageCode != null and packageCode != ''">
  618. AND det.package_code = #{packageCode}
  619. </if>
  620. <if test="startDate != null and startDate > 0">
  621. AND det.exam_start_time >= #{startDate}
  622. </if>
  623. <if test="endDate != null and endDate > 0">
  624. AND #{endDate} >= det.exam_end_time
  625. </if>
  626. <if test="dpr != null">
  627. <if test="dpr.requestUserId != null">
  628. AND det.create_id = #{dpr.requestUserId}
  629. </if>
  630. <if test="dpr.orgIdSet != null and dpr.orgIdSet != '' and dpr.orgIdSet.size > 0">
  631. AND det.org_id IN
  632. <foreach collection="dpr.orgIdSet" item="item" index="index" open="(" separator="," close=")">
  633. #{item}
  634. </foreach>
  635. </if>
  636. </if>
  637. </where>
  638. GROUP BY det.school_id
  639. <trim prefix="having" suffixOverrides="and">
  640. <if test="courseCode != null and courseCode != ''">
  641. find_in_set(#{courseCode},courseCodes) and
  642. </if>
  643. <if test="paperNumber != null and paperNumber != ''">
  644. find_in_set(#{paperNumber},paperNumbers) and
  645. </if>
  646. </trim>
  647. </select>
  648. <select id="listByExamIdAndCourseCode"
  649. resultType="com.qmth.distributed.print.business.bean.dto.ExamDetailCourseDto">
  650. SELECT
  651. edc.clazz_id clazzId,
  652. su.login_name loginName,
  653. su.real_name realName
  654. FROM
  655. exam_detail_course edc
  656. JOIN
  657. exam_detail ed ON edc.exam_detail_id = ed.id
  658. left join
  659. sys_user su ON ed.create_id = su.id
  660. WHERE
  661. edc.school_id = #{schoolId} AND ed.exam_id = #{examId}
  662. AND edc.course_code = #{courseCode} AND ed.status != 'CANCEL'
  663. </select>
  664. <select id="listPrintFinishExamDetailCourse"
  665. resultType="com.qmth.distributed.print.business.bean.dto.initMarkData.ExamDetailCourseInitMarkDto">
  666. SELECT
  667. ed.school_id schoolId,
  668. be.semester_id semesterId,
  669. ed.exam_id examId,
  670. edc.course_code courseCode,
  671. edc.course_name courseName,
  672. edc.paper_number paperNumber,
  673. et.id coursePaperId,
  674. edc.paper_type paperType,
  675. et.user_id createId,
  676. ed.exam_start_time examStartTime,
  677. ed.exam_end_time examEndTime,
  678. group_concat(ed.package_code) packageCodes,
  679. group_concat(edc.id) examDetailCourseIds
  680. FROM
  681. exam_detail ed
  682. LEFT JOIN
  683. exam_detail_course edc ON ed.id = edc.exam_detail_id
  684. LEFT JOIN
  685. exam_task et ON ed.exam_id = et.exam_id AND edc.paper_number = et.paper_number
  686. JOIN
  687. (select * from basic_exam where enable = true)be ON be.id = ed.exam_id
  688. WHERE
  689. ed.status = #{printStatus}
  690. AND ed.print_end_time > #{startTime}
  691. AND NOT EXISTS( SELECT
  692. 1
  693. FROM
  694. mark_paper mp
  695. WHERE
  696. ed.exam_id = mp.exam_id
  697. AND edc.paper_number = mp.paper_number
  698. AND mp.status = #{markStatus})
  699. GROUP BY ed.school_id , be.semester_id, ed.exam_id , edc.course_code , edc.course_name , edc.paper_number , et.id , edc.paper_type , et.user_id, ed.exam_start_time, ed.exam_end_time
  700. </select>
  701. <select id="countMakeupUsedByExamIdAndPaperNumber" resultType="java.lang.Integer">
  702. SELECT
  703. COUNT(1)
  704. FROM
  705. exam_detail ed
  706. LEFT JOIN
  707. exam_detail_course edc ON ed.id = edc.exam_detail_id
  708. WHERE
  709. ed.exam_id = #{examId}
  710. AND edc.paper_number = #{paperNumber}
  711. AND EXISTS( SELECT
  712. 1
  713. FROM
  714. exam_print_plan epp
  715. WHERE
  716. ed.print_plan_id = epp.id
  717. AND epp.category = 'MAKEUP')
  718. </select>
  719. <select id="listByExamIdAndCourseCodeAndPaperNumber"
  720. resultType="com.qmth.distributed.print.business.entity.ExamDetail">
  721. SELECT
  722. b.*
  723. FROM
  724. exam_detail_course a
  725. JOIN
  726. exam_detail b ON a.exam_detail_id = b.id
  727. WHERE
  728. a.school_id = #{schoolId}
  729. AND b.exam_id = #{examId}
  730. AND a.course_code = #{courseCode}
  731. AND a.paper_number = #{paperNumber}
  732. </select>
  733. <select id="listPrintFinishPackageCode"
  734. resultType="com.qmth.distributed.print.business.bean.dto.initMarkData.ExamDetailCourseInitMarkDto">
  735. SELECT
  736. ed.exam_id examId,
  737. edc.course_code courseCode,
  738. edc.course_name courseName,
  739. edc.paper_number paperNumber,
  740. edc.course_paper_id coursePaperId,
  741. ed.package_code
  742. FROM
  743. exam_detail ed
  744. LEFT JOIN
  745. exam_detail_course edc ON ed.id = edc.exam_detail_id
  746. WHERE
  747. ed.exam_id = #{examId}
  748. AND edc.paper_number = #{paperNumber}
  749. AND edc.paper_type LIKE CONCAT('%', #{paperType}, '%')
  750. AND NOT EXISTS( SELECT
  751. 1
  752. FROM
  753. mark_paper_package mpp
  754. WHERE
  755. ed.exam_id = mpp.exam_id
  756. AND edc.paper_number = mpp.paper_number
  757. AND mpp.paper_type = #{paperType}
  758. AND ed.package_code = mpp.package_code)
  759. </select>
  760. <select id="listPrintFinishExamDetailCourseIds" resultType="com.qmth.distributed.print.business.bean.dto.initMarkData.InitExamDetailDto">
  761. SELECT
  762. edc.id examDetailCourseId,
  763. ed.exam_place examPlace,
  764. ed.exam_room examRoom,
  765. ed.package_code packageCode
  766. FROM
  767. exam_detail ed
  768. LEFT JOIN
  769. exam_detail_course edc ON ed.id = edc.exam_detail_id
  770. WHERE
  771. ed.exam_id = #{examId}
  772. AND edc.paper_number = #{paperNumber}
  773. AND edc.paper_type LIKE CONCAT('%', #{paperType}, '%')
  774. </select>
  775. </mapper>