TextbookMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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,t1.publishing_date,t1.is_secd,t1.category,t1.plan_batch,t1.work_total_count,t1.textbook_category
  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. LEFT JOIN xjr_dictionary_detail t8 ON t1.textbook_category = t8.code
  26. WHERE t1.delete_mark = 0
  27. <if test="dto.textbookType != null and dto.textbookType != ''">
  28. and t1.textbook_type = #{dto.textbookType}
  29. </if>
  30. <!-- <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">-->
  31. <!-- and t1.base_semester_id = #{dto.baseSemesterId}-->
  32. <!-- </if>-->
  33. <if test="dto.subjectGroupId != null and dto.subjectGroupId > 0">
  34. and t1.subject_group_id = #{dto.subjectGroupId}
  35. </if>
  36. <if test="dto.courseSubjectId != null and dto.courseSubjectId > 0">
  37. and t1.course_subject_id = #{dto.courseSubjectId}
  38. </if>
  39. <if test="dto.bookName != null and dto.bookName != ''">
  40. and t1.book_name like concat('%',#{dto.bookName}, '%')
  41. </if>
  42. <if test="dto.isTextbookPlan != null and dto.isTextbookPlan != ''">
  43. and t1.is_textbook_plan = #{dto.isTextbookPlan}
  44. </if>
  45. <if test="dto.issn != null and dto.issn != ''">
  46. and t1.issn like concat('%', #{dto.issn}, '%')
  47. </if>
  48. <if test="dto.editorInChief != null and dto.editorInChief != ''">
  49. and t1.editor_in_chief like concat('%', #{dto.editorInChief}, '%')
  50. </if>
  51. <if test="dto.publishingHouse != null and dto.publishingHouse != ''">
  52. and t1.publishing_house like concat('%', #{dto.publishingHouse}, '%')
  53. </if>
  54. order by t3.name desc
  55. </select>
  56. <select id="subscriptionList" resultType="com.xjrsoft.module.textbook.vo.TextbookSubscriptionRecordVo">
  57. SELECT t2.create_date,
  58. t4.name AS applicant_user,
  59. t8.issn,
  60. t8.book_name,
  61. t8.publishing_house,
  62. t8.editor_in_chief,
  63. t8.appraisal_price,
  64. t5.name AS is_textbook_plan_cn,
  65. t6.name AS course_name,
  66. t3.student_subscription_number,
  67. t3.teacher_subscription_number,
  68. t3.teacher_reference_number,
  69. t3.class_ids
  70. FROM textbook_subscription_record t1
  71. LEFT JOIN wf_textbook_subscription t2 ON t1.wf_textbook_subscription_id = t2.id
  72. LEFT JOIN wf_textbook_subscription_item t3 ON t3.id = t1.wf_textbook_subscription_item_id
  73. LEFT JOIN xjr_user t4 ON t2.applicant_user_id = t4.id
  74. LEFT JOIN textbook t8 ON t8.id = t1.textbook_id
  75. LEFT JOIN xjr_dictionary_detail t5
  76. ON t8.is_textbook_plan = t5.code AND t5.item_id = 1737360269850038273
  77. LEFT JOIN base_course_subject t6 ON t8.course_subject_id = t6.id
  78. WHERE t1.delete_mark = 0
  79. AND t1.textbook_id = #{id}
  80. </select>
  81. <select id="exerciseBookSubscriptionList" resultType="com.xjrsoft.module.textbook.vo.TextbookSubscriptionRecordVo">
  82. SELECT t2.create_date,
  83. t4.name AS applicant_user,
  84. t5.book_name,
  85. t3.specifications_models,
  86. t6.name as useClass,
  87. t3.appraisal_price,
  88. t3.subscription_number as studentSubscriptionNumber
  89. FROM textbook_subscription_record t1
  90. LEFT JOIN wf_exercise_book t2 ON t1.wf_textbook_subscription_id = t2.id
  91. LEFT JOIN wf_exercise_book_item t3 ON t3.wf_exercise_book_id = t2.id
  92. LEFT JOIN xjr_user t4 ON t2.applicant_user_id = t4.id
  93. LEFT JOIN textbook t5 ON t5.id = t1.textbook_id
  94. LEFT JOIN base_class t6 ON t6.id = t2.class_id
  95. WHERE t1.delete_mark = 0
  96. AND t1.textbook_id = #{id}
  97. </select>
  98. <select id="getClassInfo" resultType="com.xjrsoft.module.textbook.vo.TextbookSubscriptionClassVo">
  99. SELECT NAME FROM base_class WHERE id IN
  100. <foreach item="classId" index="index" collection="ids" open="(" close=")" separator=",">
  101. #{classId}
  102. </foreach>
  103. </select>
  104. <select id="getInfoByissn" resultType="com.xjrsoft.module.textbook.vo.TextbookVo">
  105. SELECT *
  106. FROM textbook
  107. WHERE delete_mark = 0
  108. AND issn = #{issn}
  109. order by create_date desc
  110. limit 0,1
  111. </select>
  112. <select id="warehouseList" resultType="com.xjrsoft.module.textbook.vo.TextbookWarehouseRecordListVo">
  113. SELECT t1.create_date AS warehouse_date, t2.name AS warehouse_user, t1.warehouse_number, t3.name as source
  114. FROM textbook_warehouse_record t1
  115. LEFT JOIN xjr_user t2 ON t1.create_user_id = t2.id
  116. LEFT JOIN xjr_dictionary_detail t3 ON t1.source = t3.code and item_id = 1739821114335490050
  117. WHERE t1.delete_mark = 0
  118. AND t1.textbook_id = #{id}
  119. order by t1.sort_code
  120. </select>
  121. <select id="issueList" resultType="com.xjrsoft.module.textbook.vo.TextbookIssueRecordListVo">
  122. SELECT t1.create_date AS issue_date,
  123. t2.name AS issue_user,
  124. t1.issue_number,
  125. t6.name AS issue_mode,
  126. CONCAT(ifnull(t4.name, ''), ifnull(t5.name, ''), ' ', ifnull(t7.name, ''),
  127. ifnull(t9.recede_address, '')) as remark
  128. FROM textbook_issue_record t1
  129. LEFT JOIN xjr_user t2 ON t1.create_user_id = t2.id
  130. left join base_student_school_roll t3 on t3.user_id = t1.receive_user_id
  131. left join base_class t4 on t4.id = t3.class_id
  132. left join base_class t5 on t5.teacher_id = t1.issue_user_id
  133. LEFT JOIN xjr_dictionary_detail t6 ON t6.code = t1.issue_mode AND t6.item_id = 1739821685805215745
  134. left join xjr_user t7 on t1.receive_user_id = t7.id
  135. left join wf_textbook_recede t9 on t9.id = t1.data_id
  136. WHERE t1.delete_mark = 0
  137. AND t1.textbook_id = #{id}
  138. ORDER BY t1.create_date;
  139. </select>
  140. <select id="getClassRelation" resultType="com.xjrsoft.module.textbook.entity.TextbookClassRelation">
  141. SELECT *
  142. FROM textbook_class_relation
  143. WHERE delete_mark = 0
  144. AND textbook_id = #{id}
  145. </select>
  146. <select id="listTextbookStandingExportQuery"
  147. parameterType="com.xjrsoft.module.textbook.dto.TextbookStandingExportQuerytDto"
  148. resultType="com.xjrsoft.module.textbook.vo.TextbookStandingExportQueryVo">
  149. SELECT t1.issn,
  150. t1.book_name,
  151. t1.publishing_house,
  152. t1.editor_in_chief,
  153. t1.version,
  154. t2.group_name,
  155. t4.name AS course_name,
  156. t7.name AS is_textbook_plan_cn,
  157. t5.name AS textbook_type_cn,
  158. t1.specifications_models,
  159. t1.appraisal_price,
  160. t1.price,
  161. t1.discount,
  162. t1.subtotal,
  163. t1.stock
  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"
  196. parameterType="com.xjrsoft.module.textbook.dto.TextbookSubscriptionExportQueryDto"
  197. resultType="com.xjrsoft.module.textbook.vo.TextbookSubscriptionExportQueryVo">
  198. SELECT t3.issn,
  199. t3.book_name,
  200. t3.publishing_house,
  201. t3.editor_in_chief,
  202. t3.appraisal_price,
  203. t5.name AS is_textbook_plan_cn,
  204. t6.name AS course_name,
  205. t9.name as useGrade,
  206. t3.class_ids,
  207. t3.student_subscription_number,
  208. t3.teacher_subscription_number,
  209. t3.teacher_reference_number,
  210. t10.group_name,
  211. t7.name AS is_support_resources_cn
  212. FROM textbook_subscription_record t1
  213. LEFT JOIN wf_textbook_subscription t2 ON t1.wf_textbook_subscription_id = t2.id
  214. LEFT JOIN wf_textbook_subscription_item t3 ON t3.id = t1.wf_textbook_subscription_item_id
  215. LEFT JOIN xjr_dictionary_detail t5
  216. ON t3.is_textbook_plan = t5.code AND t5.item_id = 1737360269850038273
  217. LEFT JOIN base_course_subject t6 ON t3.course_subject_id = t6.id
  218. LEFT JOIN xjr_dictionary_detail t7
  219. ON t3.is_support_resources = t7.code AND t7.item_id = 1737360269850038273
  220. LEFT JOIN textbook t8 ON t8.id = t1.textbook_id
  221. LEFT JOIN base_grade t9 ON t9.id = t8.grade_id
  222. LEFT JOIN subject_group t10 ON t10.id = t2.subject_group_id
  223. WHERE t1.delete_mark = 0
  224. <if test="dto.textbookType != null and dto.textbookType != ''">
  225. and t8.textbook_type = #{dto.textbookType}
  226. </if>
  227. <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
  228. and t8.base_semester_id = #{dto.baseSemesterId}
  229. </if>
  230. <if test="dto.subjectGroupId != null and dto.subjectGroupId > 0">
  231. and t8.subject_group_id = #{dto.subjectGroupId}
  232. </if>
  233. <if test="dto.courseSubjectId != null and dto.courseSubjectId > 0">
  234. and t8.course_subject_id = #{dto.courseSubjectId}
  235. </if>
  236. <if test="dto.bookName != null and dto.bookName != ''">
  237. and t8.book_name like concat('%',#{dto.bookName}, '%')
  238. </if>
  239. <if test="dto.isTextbookPlan != null and dto.isTextbookPlan != ''">
  240. and t8.is_textbook_plan = #{dto.isTextbookPlan}
  241. </if>
  242. <if test="dto.issn != null and dto.issn != ''">
  243. and t8.issn like concat('%', #{dto.issn}, '%')
  244. </if>
  245. </select>
  246. <select id="listTextbookClaimExportQuery"
  247. parameterType="com.xjrsoft.module.textbook.dto.TextbookClaimExportQueryDto"
  248. resultType="com.xjrsoft.module.textbook.vo.TextbookClaimExportQueryVo">
  249. with textbook_class as
  250. (select 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. textbook_recode as
  273. (select t.base_semester_id,
  274. t.class_id,
  275. t1.textbook_id,
  276. sum(t1.number) as recedeNum
  277. from wf_textbook_recede t
  278. inner join wf_textbook_recede_item t1 on t1.wf_textbook_recede_id = t.id
  279. left join textbook_class t2
  280. on t2.base_semester_id = t.base_semester_id and t2.class_id = t.class_id and
  281. t2.textbook_id = t1.textbook_id
  282. where t.recede_type = 'recede_deans_office'
  283. AND t.status = 1
  284. group by t.base_semester_id, t.class_id, t1.textbook_id)
  285. select t.base_semester_id,
  286. t3.name as baseSemesterIdCn,
  287. t.class_id,
  288. t4.name as classIdCn,
  289. t5.name as headTeacherName,
  290. t6.name as classRoomName,
  291. t.textbook_id,
  292. t2.name as textbookTypeCn,
  293. t1.book_name,
  294. t1.editor_in_chief,
  295. t1.publishing_house,
  296. t1.issn,
  297. t1.price,
  298. t1.subtotal,
  299. t.num,
  300. t.claimNum,
  301. ifnull(t7.recedeNum, 0) as recedeNum,
  302. (t.claimNum - ifnull(t7.recedeNum, 0)) as studentClaimNum
  303. from textbook_class t
  304. left join textbook t1 on t1.id = t.textbook_id
  305. left join xjr_dictionary_detail t2 on t2.code = t1.textbook_type
  306. left join base_semester t3 on t3.id = t.base_semester_id
  307. left join base_class t4 on t4.id = t.class_id
  308. left join xjr_user t5 on t5.id = t4.teacher_id
  309. left join base_classroom t6 on t6.id = t4.classroom_id
  310. left join textbook_recode t7 on t7.base_semester_id = t.base_semester_id and t7.class_id = t.class_id and
  311. t7.textbook_id = t.textbook_id
  312. where t1.delete_mark = 0
  313. <if test="dto.textbookType != null and dto.textbookType != ''">
  314. and t1.textbook_type = #{dto.textbookType}
  315. </if>
  316. <if test="dto.subjectGroupId != null and dto.subjectGroupId > 0">
  317. and t1.subject_group_id = #{dto.subjectGroupId}
  318. </if>
  319. <if test="dto.courseSubjectId != null and dto.courseSubjectId > 0">
  320. and t1.course_subject_id = #{dto.courseSubjectId}
  321. </if>
  322. <if test="dto.bookName != null and dto.bookName != ''">
  323. and t1.book_name like concat('%',#{dto.bookName}, '%')
  324. </if>
  325. <if test="dto.isTextbookPlan != null and dto.isTextbookPlan != ''">
  326. and t1.is_textbook_plan = #{dto.isTextbookPlan}
  327. </if>
  328. <if test="dto.issn != null and dto.issn != ''">
  329. and t1.issn like concat('%', #{dto.issn}, '%')
  330. </if>
  331. order by t2.name desc
  332. </select>
  333. <select id="getSubscriptionPageByClass"
  334. parameterType="com.xjrsoft.module.textbook.dto.TextbookSubscriptionListDto"
  335. resultType="com.xjrsoft.module.textbook.vo.TextbookSubscriptionListVo">
  336. SELECT distinct t3.id, t3.id AS textbookId, t2.name AS courseName, t3.issn, t3.book_name,
  337. t3.publishing_house, t3.editor_in_chief, t3.course_subject_id, t3.version,
  338. t3.textbook_type, t3.use_type FROM base_class_course t
  339. LEFT JOIN base_class t1 ON (t1.id = t.class_id)
  340. LEFT JOIN base_course_subject t2 ON (t2.id = t.course_id)
  341. LEFT JOIN textbook t3 ON (t3.id = t.textbook_id)
  342. LEFT JOIN base_semester t4 ON (t4.id = t.base_semester_id)
  343. WHERE t.delete_mark = 0 AND t3.delete_mark = 0
  344. AND (t.base_semester_id = #{dto.baseSemesterId} AND t.class_id in
  345. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")" separator=",">
  346. #{classId}
  347. </foreach>
  348. )
  349. </select>
  350. </mapper>