TextbookStudentClaimMapper.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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.textbook.mapper.TextbookStudentClaimMapper">
  6. <select id="getTextbookClaimList" parameterType="com.xjrsoft.module.textbook.dto.TextbookClaimStudentConfirmDto"
  7. resultType="com.xjrsoft.module.textbook.vo.TextbookClaimVO">
  8. SELECT t.id AS textbookStudentClaimId,
  9. t1.price * t1.discount/10 AS discountPrice,
  10. t.sort_code as sortCode,
  11. t.textbook_id as textbookId,
  12. t.is_claim as isClaim,
  13. t1.book_name as bookName,
  14. t1.price as price
  15. FROM textbook_student_claim t
  16. inner JOIN textbook t1 ON (t1.id = t.textbook_id)
  17. WHERE t.delete_mark = 0
  18. AND (t.student_user_id = #{dto.studentUserId})
  19. AND (t.base_semester_id = #{dto.baseSemesterId})
  20. <if test="dto.showOrConfirm != null and dto.showOrConfirm == 2">
  21. and t.is_claim = 0
  22. </if>
  23. ORDER BY t.id DESC
  24. </select>
  25. <select id="getTeacherCheckByclassList" parameterType="com.xjrsoft.module.textbook.dto.TeacherCheckByclassDto"
  26. resultType="com.xjrsoft.module.textbook.vo.TeacherCheckByclassVo">
  27. WITH textbook_claim_counts AS
  28. (SELECT t.base_semester_id, t.class_id, t1.textbook_id, sum(t1.issue_number) AS received_num
  29. FROM wf_textbook_claim t
  30. inner JOIN wf_textbook_claim_item t1 ON t1.wf_textbook_claim_id = t.id
  31. where t.delete_mark = 0
  32. and t1.delete_mark = 0
  33. <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
  34. AND t.base_semester_id = #{dto.baseSemesterId}
  35. </if>
  36. <if test="dto.classIdList != null and dto.classIdList.size() > 0">
  37. AND t.class_id IN
  38. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
  39. separator=",">
  40. #{classId}
  41. </foreach>
  42. </if>
  43. AND t.claim_type = 'claim_class'
  44. GROUP BY t.base_semester_id, t.class_id, t1.textbook_id),
  45. actual_claim_counts AS
  46. (SELECT base_semester_id, class_id, textbook_id, count(is_claim) AS claim_num
  47. FROM textbook_student_claim
  48. WHERE is_claim = 1
  49. and delete_mark = 0
  50. <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
  51. AND base_semester_id = #{dto.baseSemesterId}
  52. </if>
  53. <if test="dto.classIdList != null and dto.classIdList.size() > 0">
  54. AND class_id IN
  55. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
  56. separator=",">
  57. #{classId}
  58. </foreach>
  59. </if>
  60. GROUP BY base_semester_id, class_id, textbook_id),
  61. class_stu_num AS
  62. (SELECT class_id, count(t.id) AS total_student
  63. FROM base_student_school_roll t
  64. WHERE t.delete_mark = 0
  65. and t.archives_status = 'FB2901'
  66. <if test="dto.classIdList != null and dto.classIdList.size() > 0">
  67. AND t.class_id IN
  68. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
  69. separator=",">
  70. #{classId}
  71. </foreach>
  72. </if>
  73. GROUP BY class_id)
  74. SELECT t.base_semester_id,
  75. t.class_id,
  76. t.textbook_id,
  77. t1.book_name,
  78. t2.name as classIdCn,
  79. t5.name as baseSemesterIdCN,
  80. ifnull(t.received_num, 0) AS actualReceivedNum,
  81. ifnull(t4.total_student, 0) AS classStudentNum,
  82. ifnull(t3.claim_num, 0) AS actualClaimNum,
  83. if(t.received_num > 0, 1, 0) as is_issue
  84. FROM textbook_claim_counts t
  85. inner join textbook t1 on t1.id = t.textbook_id
  86. LEFT JOIN base_class t2 ON t2.id = t.class_id
  87. LEFT JOIN base_semester t5 ON t5.id = t.base_semester_id
  88. LEFT JOIN actual_claim_counts t3 ON t3.base_semester_id = t.base_semester_id AND t3.class_id = t.class_id AND
  89. t3.textbook_id = t.textbook_id
  90. LEFT JOIN class_stu_num t4 ON t4.class_id = t.class_id
  91. where t.class_id &lt;&gt; 0
  92. <if test="dto.classIdList != null and dto.classIdList.size() > 0">
  93. AND t.class_id IN
  94. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
  95. separator=",">
  96. #{classId}
  97. </foreach>
  98. </if>
  99. <if test="dto.claimStatus != null and dto.claimStatus == 2">
  100. AND t.received_num &lt;= t3.claim_num
  101. </if>
  102. <if test="dto.claimStatus != null and dto.claimStatus == 3">
  103. AND t.received_num &gt; t3.claim_num
  104. </if>
  105. </select>
  106. <select id="getTeacherCheckStuClaimList" parameterType="com.xjrsoft.module.textbook.dto.TeacherCheckStuClaimDto"
  107. resultType="com.xjrsoft.module.textbook.vo.TeacherCheckStuClaimVo">
  108. SELECT t.id as textbookStudentClaimId,
  109. t.textbook_id,
  110. t1.book_name as bookName,
  111. t.student_user_id,
  112. t2.student_id as studentId,
  113. t3.name as studentName,
  114. t.is_claim
  115. FROM textbook_student_claim t
  116. LEFT JOIN textbook t1 ON (t1.id = t.textbook_id)
  117. LEFT JOIN base_student t2 ON (t2.user_id = t.student_user_id)
  118. LEFT JOIN xjr_user t3 ON (t3.id = t.student_user_id)
  119. WHERE t.delete_mark = 0
  120. and t.class_id = #{dto.classId}
  121. and t.textbook_id = #{dto.textbookId}
  122. ORDER BY t.is_claim
  123. </select>
  124. <select id="getTeacherCheckByStuList" parameterType="com.xjrsoft.module.textbook.dto.TeacherCheckByStuDto"
  125. resultType="com.xjrsoft.module.textbook.vo.TeacherCheckByStuVo">
  126. SELECT
  127. t.id as studentUserId,
  128. t.name as studentUserIdCN,
  129. t1.student_id as studentId
  130. FROM xjr_user t
  131. LEFT JOIN base_student t1 ON (t1.user_id = t.id)
  132. where t.id in (SELECT distinct student_user_id
  133. FROM textbook_student_claim t
  134. WHERE delete_mark = 0
  135. <if test="dto.claimStatus != null and dto.claimStatus == 3">
  136. and (select count(*) from textbook_student_claim where is_claim = 1 and student_user_id = t.student_user_id)
  137. != (select count(*) from textbook_student_claim where student_user_id = t.student_user_id)
  138. </if>
  139. <if test="dto.claimStatus != null and dto.claimStatus == 2">
  140. and (select count(*) from textbook_student_claim where is_claim = 1 and student_user_id = t.student_user_id)
  141. = (select count(*) from textbook_student_claim where student_user_id = t.student_user_id)
  142. </if>
  143. <if test="dto.classIdList != null and dto.classIdList.size() > 0">
  144. and class_id in
  145. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
  146. separator=",">
  147. #{classId}
  148. </foreach>
  149. </if>
  150. )
  151. <if test="dto.studentUserId != null and dto.studentUserId != 0 and dto.studentUserId != ''">
  152. and t.id = #{dto.studentUserId}
  153. </if>
  154. </select>
  155. <select id="getTextbookClaimVOList"
  156. resultType="com.xjrsoft.module.textbook.vo.TextbookClaimVO">
  157. SELECT t.id as textbookStudentClaimId,
  158. t.textbook_id,
  159. t1.book_name as bookName,
  160. t.is_claim
  161. FROM textbook_student_claim t
  162. LEFT JOIN textbook t1 ON (t1.id = t.textbook_id)
  163. where t.student_user_id = #{studentUserId}
  164. ORDER BY t.is_claim
  165. </select>
  166. </mapper>