archiveMapper.xml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.gz.mapper.archive.ArchiveMapper">
  4. <select id="searchList" resultType="com.gz.rvo.archive.ArchiveRVO"
  5. parameterType="com.gz.vo.archive.SearchArchiveVO">
  6. SELECT
  7. d.dict_name mj_text,
  8. a.*
  9. FROM `tab_archives` a
  10. LEFT JOIN tab_dict d
  11. ON a.mj = d.dict_code
  12. <where>
  13. a.deleted = 0
  14. and ml IN (
  15. SELECT
  16. `code`
  17. FROM
  18. tab_archives_tree atr
  19. LEFT JOIN tab_menu_role tmr ON atr.id = tmr.menu_id
  20. WHERE
  21. tmr.role_id = #{roleId}
  22. AND tmr.role_type = 1
  23. )
  24. and mj in (select d.dict_code from tab_dict d left join tab_menu_role mr on d.id = mr.menu_id where
  25. mr.role_id = #{roleId} and mr.role_type = 2 )
  26. <if test="dh != null and dh != ''">
  27. AND a.dh like concat(concat('%',#{dh}),'%')
  28. </if>
  29. <if test="mlh != null and mlh != ''">
  30. AND a.mlh = #{mlh}
  31. </if>
  32. <if test="wjbh != null and wjbh != ''">
  33. AND a.wjbh like concat(concat('%',#{wjbh}),'%')
  34. </if>
  35. <if test="ml != null and ml != ''">
  36. AND a.ml = #{ml}
  37. </if>
  38. <if test="bgqx != null and bgqx != ''">
  39. AND a.bgqx = #{bgqx}
  40. </if>
  41. <if test="mj != null and mj != ''">
  42. AND a.mj = #{mj}
  43. </if>
  44. <if test="gdnd != null and gdnd != ''">
  45. AND a.gdnd = #{gdnd}
  46. </if>
  47. <if test="ztc != null and ztc != ''">
  48. AND (a.ztc like concat(concat('%',#{ztc}),'%') OR a.tm like concat(concat('%',#{ztc}),'%'))
  49. </if>
  50. <if test="sql != null and sql != ''">
  51. ${sql}
  52. </if>
  53. </where>
  54. <if test="field != null and field != '' and order != null and order != ''">
  55. order by ${field} ${order}
  56. </if>
  57. </select>
  58. <select id="againSearchList" resultType="com.gz.rvo.archive.ArchiveRVO"
  59. parameterType="com.gz.vo.archive.SearchArchiveVO">
  60. SELECT
  61. a.*
  62. FROM (${searchSql}) a
  63. <where>
  64. <if test="dh != null and dh != ''">
  65. AND a.dh like concat(concat('%',#{dh}),'%')
  66. </if>
  67. <if test="mlh != null and mlh != ''">
  68. AND a.mlh = #{mlh}
  69. </if>
  70. <if test="wjbh != null and wjbh != ''">
  71. AND a.wjbh like concat(concat('%',#{wjbh}),'%')
  72. </if>
  73. <if test="ml != null and ml != ''">
  74. AND a.ml = #{ml}
  75. </if>
  76. <if test="bgqx != null and bgqx != ''">
  77. AND a.bgqx = #{bgqx}
  78. </if>
  79. <if test="gdnd != null and gdnd != ''">
  80. AND a.gdnd = #{gdnd}
  81. </if>
  82. <if test="mj != null and mj != ''">
  83. AND a.mj = #{mj}
  84. </if>
  85. <if test="ztc != null and ztc != ''">
  86. AND (a.ztc like concat(concat('%',#{ztc}),'%') OR a.tm like concat(concat('%',#{ztc}),'%'))
  87. </if>
  88. <if test="sql != null and sql != ''">
  89. ${sql}
  90. </if>
  91. </where>
  92. <if test="field != null and field != '' and order != null and order != ''">
  93. order by ${field} ${order}
  94. </if>
  95. </select>
  96. <select id="selectBorrowList" resultType="com.gz.rvo.borrow.ArchiveBorrowListRVO" parameterType="int">
  97. <![CDATA[
  98. SELECT IF
  99. (
  100. (SELECT count(admin_id) num
  101. FROM tab_archive_borrow ab
  102. WHERE ab.archive_id = a.id
  103. AND ab.borrow_type = 1
  104. AND ab.audit_status = 2
  105. AND ab.return_status = 0) <= 0,
  106. '可借阅',
  107. '已借阅'
  108. ) original_status,
  109. a.*
  110. FROM tab_archives a
  111. WHERE a.deleted = 0
  112. and a.ml IN (
  113. SELECT `code`
  114. FROM tab_archives_tree atr
  115. LEFT JOIN tab_menu_role tmr ON atr.id = tmr.menu_id
  116. WHERE tmr.role_id = #{roleId}
  117. AND tmr.role_type = 1
  118. )
  119. and a.mj in (select d.dict_code
  120. from tab_dict d
  121. left join tab_menu_role mr on d.id = mr.menu_id
  122. where mr.role_id = #{roleId}
  123. and mr.role_type = 2)
  124. ]]>
  125. </select>
  126. <select id="selectMaxJH" resultType="java.lang.Integer" parameterType="string">
  127. SELECT max(jh) + 1
  128. from tab_archives
  129. where deleted = 0
  130. and ml = #{mlCode}
  131. </select>
  132. <select id="selectRoleAll" resultType="com.gz.dto.archive.ArchiveDTO" parameterType="int">
  133. SELECT *
  134. FROM tab_archives
  135. WHERE deleted = 0
  136. and ml IN (
  137. SELECT `code`
  138. FROM tab_archives_tree atr
  139. LEFT JOIN tab_menu_role tmr ON atr.id = tmr.menu_id
  140. WHERE tmr.role_id = #{roleId}
  141. AND tmr.role_type = 1
  142. )
  143. and mj in (select d.dict_code
  144. from tab_dict d
  145. left join tab_menu_role mr on d.id = mr.menu_id
  146. where mr.role_id = #{roleId}
  147. and mr.role_type = 2)
  148. order by create_time desc
  149. </select>
  150. <select id="selectByRolePrimaryKey" resultType="com.gz.dto.archive.ArchiveDTO" parameterType="int">
  151. SELECT *
  152. FROM tab_archives
  153. WHERE deleted = 0
  154. and id = #{id}
  155. and ml IN (
  156. SELECT `code`
  157. FROM tab_archives_tree atr
  158. LEFT JOIN tab_menu_role tmr ON atr.id = tmr.menu_id
  159. WHERE tmr.role_id = #{roleId}
  160. AND tmr.role_type = 1
  161. )
  162. and mj in (select d.dict_code
  163. from tab_dict d
  164. left join tab_menu_role mr on d.id = mr.menu_id
  165. where mr.role_id = #{roleId}
  166. and mr.role_type = 2)
  167. order by create_time desc
  168. </select>
  169. <select id="selectByPrimaryKeyText" resultType="com.gz.rvo.archive.ArchiveRVO">
  170. SELECT IF
  171. (
  172. atr.parent_id = - 1,
  173. atr.title,
  174. concat(
  175. concat((SELECT c.title FROM tab_archives_tree c WHERE c.id = atr.parent_id), '-'),
  176. atr.title
  177. )
  178. ) mlText,
  179. d.dict_name mjText,
  180. d1.dict_name bgqxText,
  181. a.*
  182. FROM tab_archives a
  183. LEFT JOIN tab_archives_tree atr ON a.ml = atr.CODE
  184. left join tab_dict d on a.mj = d.dict_code
  185. left join tab_dict d1 on a.bgqx = d1.dict_code
  186. where a.deleted = 0
  187. and d.deleted = 0
  188. and atr.deleted = 0
  189. and a.id = #{id}
  190. </select>
  191. <select id="selectByPk" resultType="com.gz.rvo.archive.ArchiveRVO" parameterType="int">
  192. SELECT
  193. d.dict_name mj_text,
  194. d1.dict_name bgqx_text,
  195. d2.title ml_Text,
  196. a.*
  197. FROM `tab_archives` a
  198. LEFT JOIN tab_dict d ON a.mj = d.dict_code
  199. LEFT JOIN tab_dict d1 ON a.bgqx = d1.dict_code
  200. LEFT JOIN tab_archives_tree d2 ON a.ml = d2.code
  201. where a.deleted = 0
  202. and a.id = #{id}
  203. </select>
  204. <select id="selectByDh" resultType="com.gz.rvo.archive.ArchiveRVO" parameterType="string">
  205. SELECT
  206. d.dict_name mj_text,
  207. d1.dict_name bgqx_text,
  208. d2.title ml_Text,
  209. a.*
  210. FROM `tab_archives` a
  211. LEFT JOIN tab_dict d ON a.mj = d.dict_code
  212. LEFT JOIN tab_dict d1 ON a.bgqx = d1.dict_code
  213. LEFT JOIN tab_archives_tree d2 ON a.ml = d2.code
  214. where a.deleted = 0
  215. and a.dh = #{dh}
  216. </select>
  217. </mapper>