TextbookMapper.xml 16 KB

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