TextbookMapper.xml 15 KB

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