ArchiveTreeMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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="org.springblade.manager.mapper.ArchiveTreeMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="archiveTreeResultMap" type="org.springblade.manager.entity.ArchiveTree">
  6. <result column="id" property="id"/>
  7. <result column="create_time" property="createTime"/>
  8. <result column="create_user" property="createUser"/>
  9. <result column="create_dept" property="createDept"/>
  10. <result column="update_user" property="updateUser"/>
  11. <result column="update_time" property="updateTime"/>
  12. <result column="status" property="status"/>
  13. <result column="is_deleted" property="isDeleted"/>
  14. <result column="parent_id" property="parentId"/>
  15. <result column="project_id" property="projectId"/>
  16. <result column="ancestors" property="ancestors"/>
  17. <result column="node_name" property="nodeName"/>
  18. <result column="full_name" property="fullName"/>
  19. <result column="node_type" property="nodeType"/>
  20. <result column="post_type" property="postType"/>
  21. <result column="association_type" property="associationType"/>
  22. <result column="major_data_type" property="majorDataType"/>
  23. <result column="display_hierarchy" property="displayHierarchy"/>
  24. <result column="is_storage_node" property="isStorageNode"/>
  25. <result column="is_built_drawing" property="isBuiltDrawing"/>
  26. <result column="is_interface_node" property="isInterfaceNode"/>
  27. <result column="interface_type" property="interfaceType"/>
  28. <result column="sort" property="sort"/>
  29. <result column="remark" property="remark"/>
  30. <result column="project_type" property="projectType"/>
  31. <result column="storage_type" property="storageType"/>
  32. <result column="ext_type" property="extType"/>
  33. <result column="ext_id" property="extId"/>
  34. <result column="exp_data_type" property="expDataType"/>
  35. <result column="from_id" property="fromId"/>
  36. <result column="archive_auto_type" property="archiveAutoType"/>
  37. <result column="archive_auto_node_id" property="archiveAutoNodeId"/>
  38. <result column="archive_auto_group_select" property="archiveAutoGroupSelect"/>
  39. <result column="archive_auto_group_id" property="archiveAutoGroupId"/>
  40. <result column="is_upload_file_display_configuration_tree" property="isUploadFileDisplayConfigurationTree"/>
  41. </resultMap>
  42. <resultMap id="ArchiveTreeVOResultMap" type="org.springblade.manager.vo.ArchiveTreeVO2">
  43. <id column="id" property="id"/>
  44. <result column="parent_id" property="parentId"/>
  45. <result column="project_id" property="projectId"/>
  46. <result column="title" property="title"/>
  47. <result column="value" property="value"/>
  48. <result column="key" property="key"/>
  49. <result column="has_children" property="hasChildren"/>
  50. <result column="displayHierarchy" property="displayHierarchy"/>
  51. <result column="majorDataType" property="majorDataType"/>
  52. <result column="isStorageNode" property="isStorageNode"/>
  53. <result column="isDisplayTree" property="isDisplayTree"/>
  54. <result column="isStorageNode" property="isStorageNode"/>
  55. <result column="isBuiltDrawing" property="isBuiltDrawing"/>
  56. <result column="association_type" property="associationType"/>
  57. <result column="exp_data_type" property="expDataType"/>
  58. <result column="postType" property="postType"/>
  59. <result column="project_type" property="projectType"/>
  60. <result column="storage_type" property="storageType"/>
  61. <result column="ext_type" property="extType"/>
  62. <result column="ext_id" property="extId"/>
  63. <result column="from_id" property="fromId"/>
  64. <result column="archive_auto_type" property="archiveAutoType"/>
  65. <result column="archive_auto_node_id" property="archiveAutoNodeId"/>
  66. <result column="archive_auto_group_id" property="archiveAutoGroupId"/>
  67. <result column="archive_auto_group_select" property="archiveAutoGroupSelect"/>
  68. <result column="is_interface_node" property="isInterfaceNode"/>
  69. <result column="interface_type" property="interfaceType"/>
  70. <result column="sort" property="sort"/>
  71. </resultMap>
  72. <resultMap id="treeNodeResultMap" type="org.springblade.manager.vo.TreeNodeVO2">
  73. <id column="id" property="id"/>
  74. <result column="parent_id" property="parentId"/>
  75. <result column="title" property="title"/>
  76. <result column="value" property="value"/>
  77. <result column="key" property="key"/>
  78. <result column="has_children" property="hasChildren"/>
  79. <result column="displayHierarchy" property="displayHierarchy"/>
  80. <result column="majorDataType" property="majorDataType"/>
  81. <result column="isStorageNode" property="isStorageNode"/>
  82. <result column="isDisplayTree" property="isDisplayTree"/>
  83. <result column="isStorageNode" property="isStorageNode"/>
  84. <result column="isBuiltDrawing" property="isBuiltDrawing"/>
  85. <result column="project_type" property="projectType"/>
  86. <result column="storage_type" property="storageType"/>
  87. <result column="ext_type" property="extType"/>
  88. <result column="ext_id" property="extId"/>
  89. <result column="archive_auto_type" property="archiveAutoType"/>
  90. <result column="archive_auto_node_id" property="archiveAutoNodeId"/>
  91. <result column="postType" property="postType"/>
  92. </resultMap>
  93. <resultMap id="getAllSonNodeforGroupViewResultMap" type="org.springblade.manager.vo.ArchiveTreeAutoRuleVO">
  94. <id column="id" property="nodeId"/>
  95. <result column="parent_id" property="parentId"/>
  96. <result column="node_name" property="nodeName"/>
  97. <result column="archive_auto_type" property="archiveAutoType"/>
  98. <result column="archive_auto_node_id" property="archiveAutoNodeId"/>
  99. <result column="archive_auto_group_id" property="archiveAutoGroupId"/>
  100. <result column="archive_auto_group_select" property="archiveAutoGroupSelect"/>
  101. </resultMap>
  102. <update id="updateBatch">
  103. UPDATE m_archive_tree
  104. SET is_upload_file_display_configuration_tree = 1
  105. WHERE id IN
  106. <foreach item="diffRent" collection="diffRent" open="(" close=")" separator=",">
  107. #{diffRent}
  108. </foreach>
  109. AND is_deleted = 0
  110. AND status = 1
  111. </update>
  112. <update id="updateBatch2">
  113. UPDATE m_archive_tree
  114. SET is_upload_file_display_configuration_tree = 0
  115. WHERE id IN
  116. <foreach item="diffRent" collection="diffRent" open="(" close=")" separator=",">
  117. #{diffRent}
  118. </foreach>
  119. AND is_deleted = 0
  120. AND status = 1
  121. </update>
  122. <update id="updateBatch3">
  123. UPDATE m_archive_tree
  124. SET is_upload_file_display_configuration_tree = 0
  125. WHERE node_type = 2
  126. AND is_deleted = 0
  127. AND status = 1
  128. </update>
  129. <select id="lazyTree" resultMap="treeNodeResultMap">
  130. SELECT
  131. d.id,
  132. d.parent_id,
  133. d.node_name AS title,
  134. d.id AS "value",
  135. d.id AS "key",
  136. d.major_data_type AS "majorDataType",
  137. d.display_hierarchy AS "displayHierarchy",
  138. d.is_storage_node AS "isStorageNode",
  139. d.post_type AS postType,
  140. d.project_type,
  141. d.storage_type,
  142. d.ext_type,
  143. d.ext_id,
  144. d.archive_auto_type,
  145. d.archive_auto_node_id,
  146. (SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_archive_tree WHERE parent_id = d.id and is_deleted = 0)
  147. AS "has_children"
  148. FROM
  149. m_archive_tree d
  150. WHERE
  151. d.parent_id = #{parentId} AND d.is_deleted = 0
  152. <if test="tenantId!=null and tenantId!=''">
  153. AND d.tenant_id = #{tenantId}
  154. </if>
  155. ORDER BY d.sort
  156. </select>
  157. <select id="tree" resultMap="treeNodeResultMap">
  158. SELECT
  159. id,
  160. parent_id,
  161. node_name AS title,
  162. id AS "value",
  163. id AS "key",
  164. major_data_type AS "majorDataType",
  165. display_hierarchy AS "displayHierarchy",
  166. is_storage_node AS "isStorageNode",
  167. is_upload_file_display_configuration_tree AS "isDisplayTree",
  168. is_built_drawing AS "isBuiltDrawing",
  169. post_type AS postType,
  170. project_type,
  171. storage_type,
  172. ext_type,
  173. ext_id,
  174. archive_auto_type,
  175. archive_auto_node_id,
  176. FROM m_archive_tree
  177. WHERE is_deleted = 0
  178. <if test=" tenantId!=null and tenantId!='' ">
  179. AND tenant_id = #{tenantId}
  180. </if>
  181. <if test=" disPlayTree!=null and disPlayTree!='' ">
  182. AND is_upload_file_display_configuration_tree = 1
  183. </if>
  184. <if test=" nodeType !=null and nodeType !='' ">
  185. /*根节点=0 关联电子原生文件=1 数字化上传文件=2*/
  186. AND node_type in (0,#{nodeType})
  187. </if>
  188. OR parent_id = 0
  189. ORDER BY sort
  190. </select>
  191. <select id="lazyTree2" resultMap="ArchiveTreeVOResultMap">
  192. SELECT
  193. d.id,
  194. d.project_id,
  195. d.parent_id,
  196. d.node_name AS title,
  197. d.id AS "value",
  198. d.id AS "key",
  199. d.major_data_type AS "majorDataType",
  200. d.display_hierarchy AS "displayHierarchy",
  201. d.is_storage_node AS "isStorageNode",
  202. d.post_type AS postType,
  203. d.node_type AS nodeType,
  204. d.project_type,
  205. d.storage_type,
  206. d.association_type,
  207. d.ext_type,
  208. d.ext_id,
  209. d.exp_data_type,
  210. d.archive_auto_type,
  211. d.archive_auto_node_id,
  212. d.archive_auto_group_select,
  213. d.archive_auto_group_id,
  214. d.is_interface_node,
  215. d.interface_type,
  216. d.sort,
  217. (SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_archive_tree WHERE parent_id = d.id and is_deleted = 0)
  218. AS "has_children"
  219. FROM
  220. m_archive_tree d
  221. WHERE
  222. d.parent_id = #{parentId} AND d.is_deleted = 0 AND project_id = #{projectId}
  223. <if test="tenantId!=null and tenantId!=''">
  224. AND d.tenant_id = #{tenantId}
  225. </if>
  226. ORDER BY d.sort
  227. </select>
  228. <select id="tree2" resultMap="ArchiveTreeVOResultMap">
  229. SELECT
  230. id,
  231. project_id,
  232. parent_id,
  233. node_name AS title,
  234. id AS "value",
  235. id AS "key",
  236. major_data_type AS "majorDataType",
  237. display_hierarchy AS "displayHierarchy",
  238. is_storage_node AS "isStorageNode",
  239. is_upload_file_display_configuration_tree AS "isDisplayTree",
  240. is_built_drawing AS "isBuiltDrawing",
  241. post_type AS postType,
  242. node_type AS nodeType,
  243. project_type,
  244. storage_type,
  245. association_type,
  246. from_id,
  247. ext_type,
  248. ext_id,
  249. exp_data_type,
  250. archive_auto_type,
  251. archive_auto_node_id,
  252. archive_auto_group_select,
  253. archive_auto_group_id,
  254. is_interface_node,
  255. interface_type,
  256. sort,
  257. ( SELECT CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END FROM m_archive_tree t2 WHERE t2.parent_id = t1 .id and
  258. t2.node_type in (0, #{nodeType})) AS "has_children"
  259. FROM m_archive_tree t1
  260. WHERE is_deleted = 0 AND project_id = #{projectId}
  261. <if test=" tenantId!=null and tenantId!='' ">
  262. AND tenant_id = #{tenantId}
  263. </if>
  264. <if test=" disPlayTree!=null and disPlayTree!='' ">
  265. AND is_upload_file_display_configuration_tree = 1
  266. </if>
  267. <if test=" nodeType !=null and nodeType !='' ">
  268. /*根节点=0 关联电子原生文件=1 数字化上传文件=2*/
  269. AND node_type in (0,#{nodeType})
  270. </if>
  271. OR (parent_id = 0 and is_deleted = 0 AND project_id = #{projectId})
  272. ORDER BY sort
  273. </select>
  274. <update id="updateAllSonNodeIdsForArchiveAutoRule">
  275. <if test="archiveAutoType ==1 ">
  276. update m_archive_tree
  277. set
  278. archive_auto_node_id = #{archiveAutoNodeId}
  279. where
  280. is_deleted = 0 and ancestors like concat('', #{ancestors}, '%');
  281. </if>
  282. update m_archive_tree
  283. set
  284. archive_auto_type= #{archiveAutoType}
  285. <if test="archiveAutoType ==2 ">
  286. ,archive_auto_group_id=#{archiveAutoGroupId},
  287. archive_auto_group_select=0
  288. </if>
  289. where
  290. is_deleted = 0 and ancestors like concat('', #{ancestors}, '%')
  291. /*最高并卷规则不能覆盖 分类并卷规则,单独组卷规则*/
  292. <if test="archiveAutoType ==1 ">
  293. and (archive_auto_type != 2 and archive_auto_type != 3 or archive_auto_type is null)
  294. </if>
  295. /*分类并卷规则不能覆盖单独组卷规则*/
  296. <if test="archiveAutoType ==2 ">
  297. and (archive_auto_type != 3 or archive_auto_type is null)
  298. </if>
  299. </update>
  300. <update id="removeAllSonNodeforTypeIsNUll">
  301. update m_archive_tree
  302. set archive_auto_type = null,
  303. archive_auto_group_select =NULL
  304. where is_deleted = 0
  305. and ancestors like concat('', #{ancestors}, '%')
  306. and archive_auto_type = 1
  307. and archive_auto_node_id is NULL
  308. or id = #{nodeId};
  309. </update>
  310. <update id="removeAllSonNodeIdsForArchiveAutoRule_1">
  311. update m_archive_tree
  312. set archive_auto_node_id = NULL
  313. where is_deleted = 0
  314. and ancestors like concat('', #{ancestors}, '%')
  315. or id = #{nodeId};
  316. update m_archive_tree
  317. set archive_auto_type = NULL,
  318. archive_auto_group_select =NULL
  319. where is_deleted = 0
  320. and ancestors like concat('', #{ancestors}, '%')
  321. /*取消规则 只取消规则与自己一致的*/
  322. and archive_auto_type = #{archiveAutoType}
  323. or id = #{nodeId};
  324. </update>
  325. <update id="removeAllSonNodeIdsForArchiveAutoRule_3">
  326. update m_archive_tree
  327. set
  328. /*取消规则 恢复默认规则 不需要设置为null,如果最高并卷节点取消规则,archive_auto_node_id会为空,相当于无规则不会进到自动组卷流程*/
  329. archive_auto_type = 1,
  330. archive_auto_group_select =NULL
  331. where is_deleted = 0
  332. and ancestors like concat('', #{ancestors}, '%')
  333. /*取消规则 只取消规则与自己一致的*/
  334. and archive_auto_type = #{archiveAutoType}
  335. or id = #{nodeId};
  336. </update>
  337. <update id="removeAllSonNodeIdsForArchiveAutoRule_2">
  338. /*取消单个节点的分类并卷规则*/
  339. update m_archive_tree
  340. set
  341. /*取消规则 恢复默认规则 不需要设置为null,如果最高并卷节点取消规则,archive_auto_node_id会为空,相当于无规则不会进到自动组卷流程*/
  342. archive_auto_type = 1,
  343. archive_auto_group_id = NULL,
  344. archive_auto_group_select =NULL
  345. where is_deleted = 0
  346. and ancestors like concat('', #{ancestors}, '%')
  347. /*取消规则 只取消规则与自己一致的*/
  348. and archive_auto_type = #{archiveAutoType}
  349. or id = #{nodeId};
  350. </update>
  351. <update id="removeNodeForArchiveAutoRule_Group">
  352. /**取消同一组的分类并卷规则*/
  353. update m_archive_tree
  354. set archive_auto_type = 1,
  355. archive_auto_group_id = NULL,
  356. archive_auto_group_select =NULL
  357. where is_deleted = 0
  358. and archive_auto_group_id = #{archiveAutoGroupId}
  359. </update>
  360. <select id="getAllSonNodeforGroupView" resultMap="getAllSonNodeforGroupViewResultMap">
  361. SELECT id,
  362. parent_id,
  363. node_name,
  364. archive_auto_type,
  365. archive_auto_node_id,
  366. archive_auto_group_id,
  367. archive_auto_group_select
  368. FROM m_archive_tree
  369. where is_deleted = 0
  370. and ancestors like concat('', #{ancestors}, '%')
  371. and (archive_auto_type !=3 or archive_auto_type is null)
  372. and id not in (
  373. select id from m_archive_tree where archive_auto_type = 2 and archive_auto_group_id
  374. != #{groupId}
  375. )
  376. or id=#{bigNodeID}
  377. order by ancestors asc, sort asc
  378. </select>
  379. </mapper>