TextbookMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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.TextbookMapper">
  6. <select id="getPage" parameterType="com.xjrsoft.module.textbook.dto.TextbookPageDto"
  7. resultType="com.xjrsoft.module.textbook.vo.TextbookPageVo">
  8. SELECT t1.id,t1.id AS textbookId,t1.sort_code,t1.issn,t1.book_name,t1.publishing_house,t1.editor_in_chief,
  9. t1.subject_group_id,t2.group_name,t3.name AS semester_name,t4.name AS course_name,t7.name AS
  10. is_textbook_plan_cn,
  11. t5.name AS textbook_type_cn,t1.specifications_models,t1.appraisal_price,t1.price,t1.discount,t1.subtotal,t1.stock,
  12. (SELECT GROUP_CONCAT(c2.name) FROM textbook_class_relation c1
  13. LEFT JOIN base_class c2 ON c1.class_id = c2.id
  14. WHERE c1.textbook_id = t1.id) AS use_class,
  15. t6.name AS use_grade,t1.version FROM textbook t1
  16. LEFT JOIN subject_group t2 ON t1.subject_group_id = t2.id
  17. LEFT JOIN base_semester t3 ON t1.base_semester_id = t3.id
  18. LEFT JOIN base_course_subject t4 ON t1.course_subject_id = t4.id
  19. LEFT JOIN xjr_dictionary_detail t5 ON t1.textbook_type = t5.code AND t5.item_id = 1739209191193636865
  20. LEFT JOIN base_grade t6 ON t1.grade_id = t6.id
  21. LEFT JOIN xjr_dictionary_detail t7 ON t1.is_textbook_plan = t7.code AND t7.item_id = 1737360269850038273
  22. WHERE t1.delete_mark = 0
  23. <if test="dto.textbookType != null and dto.textbookType != ''">
  24. and t1.textbook_type = #{dto.textbookType}
  25. </if>
  26. <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
  27. and t1.base_semester_id = #{dto.baseSemesterId}
  28. </if>
  29. <if test="dto.subjectGroupId != null and dto.subjectGroupId > 0">
  30. and t1.subject_group_id = #{dto.subjectGroupId}
  31. </if>
  32. <if test="dto.courseSubjectId != null and dto.courseSubjectId > 0">
  33. and t1.course_subject_id = #{dto.courseSubjectId}
  34. </if>
  35. <if test="dto.bookName != null and dto.bookName != ''">
  36. and t1.book_name like concat('%',#{dto.bookName}, '%')
  37. </if>
  38. <if test="dto.isTextbookPlan != null and dto.isTextbookPlan != ''">
  39. and t1.is_textbook_plan = #{dto.isTextbookPlan}
  40. </if>
  41. <if test="dto.issn != null and dto.issn != ''">
  42. and t1.issn like concat('%', #{dto.issn}, '%')
  43. </if>
  44. <if test="dto.editorInChief != null and dto.editorInChief != ''">
  45. and t1.editor_in_chief like concat('%', #{dto.editorInChief}, '%')
  46. </if>
  47. <if test="dto.publishingHouse != null and dto.publishingHouse != ''">
  48. and t1.publishing_house like concat('%', #{dto.publishingHouse}, '%')
  49. </if>
  50. order by t3.name desc
  51. </select>
  52. <select id="subscriptionList" resultType="com.xjrsoft.module.textbook.vo.TextbookSubscriptionRecordVo">
  53. SELECT t2.create_date,
  54. t4.name AS applicant_user,
  55. t3.issn,
  56. t3.book_name,
  57. t3.publishing_house,
  58. t3.editor_in_chief,
  59. t3.appraisal_price,
  60. t5.name AS is_textbook_plan_cn,
  61. t6.name AS course_name,
  62. t3.student_subscription_number,
  63. t3.teacher_subscription_number,
  64. t3.teacher_reference_number,
  65. t7.name AS is_support_resources_cn,
  66. t3.version,
  67. t3.class_ids,
  68. t3.student_subscription_number,
  69. t3.teacher_subscription_number,
  70. t3.teacher_reference_number,
  71. t9.name as gradeName,
  72. t10.group_name as subjectGroupIdCN
  73. FROM textbook_subscription_record t1
  74. LEFT JOIN wf_textbook_subscription t2 ON t1.wf_textbook_subscription_id = t2.id
  75. LEFT JOIN wf_textbook_subscription_item t3 ON t3.id = t1.wf_textbook_subscription_item_id
  76. LEFT JOIN xjr_user t4 ON t2.applicant_user_id = t4.id
  77. LEFT JOIN xjr_dictionary_detail t5
  78. ON t3.is_textbook_plan = t5.code AND t5.item_id = 1737360269850038273
  79. LEFT JOIN base_course_subject t6 ON t3.course_subject_id = t6.id
  80. LEFT JOIN xjr_dictionary_detail t7
  81. ON t3.is_support_resources = t7.code AND t7.item_id = 1737360269850038273
  82. LEFT JOIN textbook t8 ON t8.id = t1.textbook_id
  83. LEFT JOIN base_grade t9 ON t9.id = t8.grade_id
  84. LEFT JOIN subject_group t10 ON t10.id = t2.subject_group_id
  85. WHERE t1.delete_mark = 0
  86. AND t1.textbook_id = #{id}
  87. </select>
  88. <select id="exerciseBookSubscriptionList" resultType="com.xjrsoft.module.textbook.vo.TextbookSubscriptionRecordVo">
  89. SELECT t2.create_date,
  90. t4.name AS applicant_user,
  91. t5.book_name,
  92. t3.specifications_models,
  93. t6.name as useClass,
  94. t3.appraisal_price,
  95. t3.subscription_number as studentSubscriptionNumber
  96. FROM textbook_subscription_record t1
  97. LEFT JOIN wf_exercise_book t2 ON t1.wf_textbook_subscription_id = t2.id
  98. LEFT JOIN wf_exercise_book_item t3 ON t3.wf_exercise_book_id = t2.id
  99. LEFT JOIN xjr_user t4 ON t2.applicant_user_id = t4.id
  100. LEFT JOIN textbook t5 ON t5.id = t1.textbook_id
  101. LEFT JOIN base_class t6 ON t6.id = t2.class_id
  102. WHERE t1.delete_mark = 0
  103. AND t1.textbook_id = #{id}
  104. </select>
  105. <select id="getClassInfo" resultType="com.xjrsoft.module.textbook.vo.TextbookSubscriptionClassVo">
  106. SELECT NAME FROM base_class WHERE id IN
  107. <foreach item="classId" index="index" collection="ids" open="(" close=")" separator=",">
  108. #{classId}
  109. </foreach>
  110. </select>
  111. <select id="getInfoByissn" resultType="com.xjrsoft.module.textbook.vo.TextbookVo">
  112. SELECT *
  113. FROM textbook
  114. WHERE delete_mark = 0
  115. AND issn = #{issn}
  116. order by create_date desc limit 0,1
  117. </select>
  118. <select id="warehouseList" resultType="com.xjrsoft.module.textbook.vo.TextbookWarehouseRecordListVo">
  119. SELECT t1.create_date AS warehouse_date, t2.name AS warehouse_user, t1.warehouse_number, t1.source
  120. FROM textbook_warehouse_record t1
  121. LEFT JOIN xjr_user t2 ON t1.create_user_id = t2.id
  122. WHERE t1.delete_mark = 0
  123. AND t1.textbook_id = #{id}
  124. order by t1.sort_code
  125. </select>
  126. <select id="issueList" resultType="com.xjrsoft.module.textbook.vo.TextbookIssueRecordListVo">
  127. SELECT t1.create_date AS issue_date,
  128. t2.name AS issue_user,
  129. t1.issue_number,
  130. t6.name AS issue_mode,
  131. CONCAT(ifnull(t4.name, ''), ifnull(t5.name, ''), ' ', ifnull(t7.name, ''), ifnull(t9.recede_address, '')) as remark
  132. FROM textbook_issue_record t1
  133. LEFT JOIN xjr_user t2 ON t1.create_user_id = t2.id
  134. left join base_student_school_roll t3 on t3.user_id = t1.receive_user_id
  135. left join base_class t4 on t4.id = t3.class_id
  136. left join base_class t5 on t5.teacher_id = t1.issue_user_id
  137. LEFT JOIN xjr_dictionary_detail t6 ON t6.code = t1.issue_mode AND t6.item_id = 1739821685805215745
  138. left join xjr_user t7 on t1.receive_user_id = t7.id
  139. left join wf_textbook_recede t9 on t9.id = t1.data_id
  140. WHERE t1.delete_mark = 0
  141. AND t1.textbook_id = #{id}
  142. ORDER BY t1.create_date;
  143. </select>
  144. <select id="getClassRelation" resultType="com.xjrsoft.module.textbook.entity.TextbookClassRelation">
  145. SELECT *
  146. FROM textbook_class_relation
  147. WHERE delete_mark = 0
  148. AND textbook_id = #{id}
  149. </select>
  150. <select id="listTextbookStandingExportQuery" parameterType="com.xjrsoft.module.textbook.dto.TextbookStandingExportQuerytDto"
  151. resultType="com.xjrsoft.module.textbook.vo.TextbookStandingExportQueryVo">
  152. SELECT t1.issn,
  153. t1.book_name,
  154. t1.publishing_house,
  155. t1.editor_in_chief,
  156. t2.group_name,
  157. t6.name AS use_grade,
  158. (SELECT GROUP_CONCAT(c2.name)
  159. FROM textbook_class_relation c1
  160. LEFT JOIN base_class c2 ON c1.class_id = c2.id
  161. WHERE c1.textbook_id = t1.id) AS use_class,
  162. t4.name AS course_name,
  163. t7.name AS is_textbook_plan_cn,
  164. t5.name AS textbook_type_cn,
  165. t1.specifications_models,
  166. t1.appraisal_price,
  167. t1.price,
  168. t1.discount,
  169. t1.subtotal,
  170. t1.stock,
  171. t8.name as use_semester
  172. FROM textbook t1
  173. LEFT JOIN subject_group t2 ON t1.subject_group_id = t2.id
  174. LEFT JOIN base_course_subject t4 ON t1.course_subject_id = t4.id
  175. LEFT JOIN xjr_dictionary_detail t5 ON t1.textbook_type = t5.code AND t5.item_id = 1739209191193636865
  176. LEFT JOIN base_grade t6 ON t1.grade_id = t6.id
  177. LEFT JOIN xjr_dictionary_detail t7 ON t1.is_textbook_plan = t7.code AND t7.item_id = 1737360269850038273
  178. LEFT JOIN base_semester t8 ON t1.base_semester_id = t8.id
  179. WHERE t1.delete_mark = 0
  180. <if test="dto.textbookType != null and dto.textbookType != ''">
  181. and t1.textbook_type = #{dto.textbookType}
  182. </if>
  183. <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
  184. and t1.base_semester_id = #{dto.baseSemesterId}
  185. </if>
  186. <if test="dto.subjectGroupId != null and dto.subjectGroupId > 0">
  187. and t1.subject_group_id = #{dto.subjectGroupId}
  188. </if>
  189. <if test="dto.courseSubjectId != null and dto.courseSubjectId > 0">
  190. and t1.course_subject_id = #{dto.courseSubjectId}
  191. </if>
  192. <if test="dto.bookName != null and dto.bookName != ''">
  193. and t1.book_name like concat('%',#{dto.bookName}, '%')
  194. </if>
  195. <if test="dto.isTextbookPlan != null and dto.isTextbookPlan != ''">
  196. and t1.is_textbook_plan = #{dto.isTextbookPlan}
  197. </if>
  198. <if test="dto.issn != null and dto.issn != ''">
  199. and t1.issn like concat('%', #{dto.issn}, '%')
  200. </if>
  201. order by t6.name desc
  202. </select>
  203. <select id="listTextbookSubscriptionExportQuery" parameterType="com.xjrsoft.module.textbook.dto.TextbookSubscriptionExportQueryDto"
  204. resultType="com.xjrsoft.module.textbook.vo.TextbookSubscriptionExportQueryVo">
  205. SELECT t3.issn,
  206. t3.book_name,
  207. t3.publishing_house,
  208. t3.editor_in_chief,
  209. t3.appraisal_price,
  210. t5.name AS is_textbook_plan_cn,
  211. t6.name AS course_name,
  212. t9.name as useGrade,
  213. t3.class_ids,
  214. t3.student_subscription_number,
  215. t3.teacher_subscription_number,
  216. t3.teacher_reference_number,
  217. t10.group_name,
  218. t7.name AS is_support_resources_cn
  219. FROM textbook_subscription_record t1
  220. LEFT JOIN wf_textbook_subscription t2 ON t1.wf_textbook_subscription_id = t2.id
  221. LEFT JOIN wf_textbook_subscription_item t3 ON t3.id = t1.wf_textbook_subscription_item_id
  222. LEFT JOIN xjr_dictionary_detail t5
  223. ON t3.is_textbook_plan = t5.code AND t5.item_id = 1737360269850038273
  224. LEFT JOIN base_course_subject t6 ON t3.course_subject_id = t6.id
  225. LEFT JOIN xjr_dictionary_detail t7
  226. ON t3.is_support_resources = t7.code AND t7.item_id = 1737360269850038273
  227. LEFT JOIN textbook t8 ON t8.id = t1.textbook_id
  228. LEFT JOIN base_grade t9 ON t9.id = t8.grade_id
  229. LEFT JOIN subject_group t10 ON t10.id = t2.subject_group_id
  230. WHERE t1.delete_mark = 0
  231. <if test="dto.textbookType != null and dto.textbookType != ''">
  232. and t8.textbook_type = #{dto.textbookType}
  233. </if>
  234. <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
  235. and t8.base_semester_id = #{dto.baseSemesterId}
  236. </if>
  237. <if test="dto.subjectGroupId != null and dto.subjectGroupId > 0">
  238. and t8.subject_group_id = #{dto.subjectGroupId}
  239. </if>
  240. <if test="dto.courseSubjectId != null and dto.courseSubjectId > 0">
  241. and t8.course_subject_id = #{dto.courseSubjectId}
  242. </if>
  243. <if test="dto.bookName != null and dto.bookName != ''">
  244. and t8.book_name like concat('%',#{dto.bookName}, '%')
  245. </if>
  246. <if test="dto.isTextbookPlan != null and dto.isTextbookPlan != ''">
  247. and t8.is_textbook_plan = #{dto.isTextbookPlan}
  248. </if>
  249. <if test="dto.issn != null and dto.issn != ''">
  250. and t8.issn like concat('%', #{dto.issn}, '%')
  251. </if>
  252. </select>
  253. <select id="listTextbookClaimExportQuery" parameterType="com.xjrsoft.module.textbook.dto.TextbookClaimExportQueryDto"
  254. resultType="com.xjrsoft.module.textbook.vo.TextbookClaimExportQueryVo">
  255. with textbook_class as (
  256. select
  257. t.base_semester_id,
  258. t.class_id,
  259. t1.textbook_id,
  260. sum(t2.stock) as num,
  261. sum(t1.issue_number) as claimNum
  262. from wf_textbook_claim t
  263. inner join wf_textbook_claim_item t1 on t1.wf_textbook_claim_id = t.id
  264. left join textbook t2 on t2.id = t1.textbook_id
  265. where claim_type = 'claim_student'
  266. AND t.status = 1
  267. <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
  268. and t.base_semester_id = #{dto.baseSemesterId}
  269. </if>
  270. <if test="dto.classId != null and dto.classId > 0">
  271. and t.class_id = #{dto.classId}
  272. </if>
  273. <if test="dto.textbookId != null and dto.textbookId > 0">
  274. and t1.textbook_id = #{dto.textbookId}
  275. </if>
  276. group by t.base_semester_id, t.class_id, t1.textbook_id
  277. )
  278. select
  279. t.base_semester_id,
  280. t3.name as baseSemesterIdCn,
  281. t.class_id,
  282. t4.name as classIdCn,
  283. t5.name as headTeacherName,
  284. t6.name as classRoomName,
  285. t.textbook_id,
  286. t2.name as textbookTypeCn,
  287. t1.book_name,
  288. t1.editor_in_chief,
  289. t1.publishing_house,
  290. t1.issn,
  291. t1.appraisal_price,
  292. t1.subtotal,
  293. t.num,
  294. t.claimNum
  295. from textbook_class t
  296. left join textbook t1 on t1.id = t.textbook_id
  297. left join xjr_dictionary_detail t2 on t2.code = t1.textbook_type
  298. left join base_semester t3 on t3.id = t.base_semester_id
  299. left join base_class t4 on t4.id = t.class_id
  300. left join xjr_user t5 on t5.id = t4.teacher_id
  301. left join base_classroom t6 on t6.id = t4.classroom_id
  302. <where>
  303. <if test="dto.textbookType != null and dto.textbookType != ''">
  304. and t1.textbook_type = #{dto.textbookType}
  305. </if>
  306. <if test="dto.subjectGroupId != null and dto.subjectGroupId > 0">
  307. and t1.subject_group_id = #{dto.subjectGroupId}
  308. </if>
  309. <if test="dto.courseSubjectId != null and dto.courseSubjectId > 0">
  310. and t1.course_subject_id = #{dto.courseSubjectId}
  311. </if>
  312. <if test="dto.bookName != null and dto.bookName != ''">
  313. and t1.book_name like concat('%',#{dto.bookName}, '%')
  314. </if>
  315. <if test="dto.isTextbookPlan != null and dto.isTextbookPlan != ''">
  316. and t1.is_textbook_plan = #{dto.isTextbookPlan}
  317. </if>
  318. <if test="dto.issn != null and dto.issn != ''">
  319. and t1.issn like concat('%', #{dto.issn}, '%')
  320. </if>
  321. </where>
  322. order by t2.name desc
  323. </select>
  324. </mapper>