ArchiveTreeContractMapper.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  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.ArchiveTreeContractMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="archiveTreeContractResultMap" type="org.springblade.manager.entity.ArchiveTreeContract">
  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="project_id" property="projectId"/>
  15. <result column="contract_id" property="contractId"/>
  16. <result column="is_upload_file_display_configuration_tree" property="isUploadFileDisplayConfigurationTree"/>
  17. <result column="parent_id" property="parentId"/>
  18. <result column="ancestors" property="ancestors"/>
  19. <result column="node_name" property="nodeName"/>
  20. <result column="full_name" property="fullName"/>
  21. <result column="node_type" property="nodeType"/>
  22. <result column="post_type" property="postType"/>
  23. <result column="association_type" property="associationType"/>
  24. <result column="major_data_type" property="majorDataType"/>
  25. <result column="display_hierarchy" property="displayHierarchy"/>
  26. <result column="is_storage_node" property="isStorageNode"/>
  27. <result column="is_built_drawing" property="isBuiltDrawing"/>
  28. <result column="is_interface_node" property="isInterfaceNode"/>
  29. <result column="interface_type" property="interfaceType"/>
  30. <result column="sort" property="sort"/>
  31. <result column="tree_sort" property="treeSort"/>
  32. <result column="remark" property="remark"/>
  33. <result column="project_type" property="projectType"/>
  34. <result column="storage_type" property="storageType"/>
  35. <result column="ext_type" property="extType"/>
  36. <result column="ext_id" property="extId"/>
  37. <result column="exp_data_type" property="expDataType"/>
  38. <result column="from_id" property="fromId"/>
  39. <result column="archive_auto_type" property="archiveAutoType"/>
  40. <result column="archive_auto_node_id" property="archiveAutoNodeId"/>
  41. <result column="archive_auto_group_select" property="archiveAutoGroupSelect"/>
  42. <result column="archive_auto_group_id" property="archiveAutoGroupId"/>
  43. <result column="tree_code" property="treeCode"/>
  44. <result column="file_number_prefix" property="fileNumberPrefix"/>
  45. <result column="storage_time" property="storageTime"/>
  46. <result column="rollor" property="rollor"/>
  47. <result column="reviewer" property="reviewer"/>
  48. <result column="specification" property="specification"/>
  49. <result column="archive_name_suffix" property="archiveNameSuffix"/>
  50. <result column="ext_key_id" property="extKeyId"/>
  51. <result column="out_id" property="outId"/>
  52. </resultMap>
  53. <delete id="removeImageNodeChild">
  54. delete from m_archive_tree_contract
  55. where contract_id = #{contractId} and is_deleted = 0 and FIND_IN_SET(#{id},ancestors) > 0
  56. </delete>
  57. <delete id="removeImageNodeFile">
  58. delete from u_archive_file
  59. where contract_id = #{contractId}
  60. and node_id in
  61. (
  62. select id from m_archive_tree_contract
  63. where contract_id = #{contractId} and is_deleted = 0 and FIND_IN_SET(#{id},ancestors) > 0
  64. )
  65. </delete>
  66. <select id="selectArchiveTreeContractPage" resultMap="archiveTreeContractResultMap">
  67. select * from m_archive_tree_contract where is_deleted = 0
  68. </select>
  69. <resultMap id="treeNodeResultMap" type="org.springblade.manager.vo.TreeNodeVO2">
  70. <id column="id" property="id"/>
  71. <result column="parent_id" property="parentId"/>
  72. <result column="title" property="title"/>
  73. <result column="value" property="value"/>
  74. <result column="key" property="key"/>
  75. <result column="has_children" property="hasChildren"/>
  76. <result column="displayHierarchy" property="displayHierarchy"/>
  77. <result column="majorDataType" property="majorDataType"/>
  78. <result column="isStorageNode" property="isStorageNode"/>
  79. <result column="isDisplayTree" property="isDisplayTree"/>
  80. <result column="isStorageNode" property="isStorageNode"/>
  81. <result column="isBuiltDrawing" property="isBuiltDrawing"/>
  82. <result column="postType" property="postType"/>
  83. <result column="project_type" property="projectType"/>
  84. <result column="storage_type" property="storageType"/>
  85. <result column="ext_type" property="extType"/>
  86. <result column="ext_id" property="extId"/>
  87. <result column="archive_auto_type" property="archiveAutoType"/>
  88. <result column="archive_auto_node_id" property="archiveAutoNodeId"/>
  89. <result column="from_id" property="fromId"/>
  90. <result column="ext_attach_id" property="extAttachId"/>
  91. </resultMap>
  92. <resultMap id="ArchiveTreeContractVO2ResultMap" type="org.springblade.manager.vo.ArchiveTreeContractVO2">
  93. <id column="id" property="id"/>
  94. <result column="parent_id" property="parentId"/>
  95. <result column="title" property="title"/>
  96. <result column="value" property="value"/>
  97. <result column="key" property="key"/>
  98. <result column="contract_id" property="contractId"/>
  99. <result column="has_children" property="hasChildren"/>
  100. <result column="displayHierarchy" property="displayHierarchy"/>
  101. <result column="majorDataType" property="majorDataType"/>
  102. <result column="isStorageNode" property="isStorageNode"/>
  103. <result column="isDisplayTree" property="isDisplayTree"/>
  104. <result column="isStorageNode" property="isStorageNode"/>
  105. <result column="isBuiltDrawing" property="isBuiltDrawing"/>
  106. <result column="association_type" property="associationType"/>
  107. <result column="nodeType" property="nodeType"/>
  108. <result column="postType" property="postType"/>
  109. <result column="project_type" property="projectType"/>
  110. <result column="storage_type" property="storageType"/>
  111. <result column="ext_type" property="extType"/>
  112. <result column="ext_id" property="extId"/>
  113. <result column="ext_key_id" property="extKeyId"/>
  114. <result column="exp_data_type" property="expDataType"/>
  115. <result column="from_id" property="fromId"/>
  116. <result column="archive_auto_type" property="archiveAutoType"/>
  117. <result column="archive_auto_node_id" property="archiveAutoNodeId"/>
  118. <result column="archive_auto_group_select" property="archiveAutoGroupSelect"/>
  119. <result column="archive_auto_group_id" property="archiveAutoGroupId"/>
  120. <result column="tree_sort" property="treeSort"/>
  121. <result column="tree_code" property="treeCode"/>
  122. <result column="file_number_prefix" property="fileNumberPrefix"/>
  123. <result column="storage_time" property="storageTime"/>
  124. <result column="rollor" property="rollor"/>
  125. <result column="reviewer" property="reviewer"/>
  126. <result column="specification" property="specification"/>
  127. <result column="archive_name_suffix" property="archiveNameSuffix"/>
  128. <result column="tree_number" property="treeNumber"/>
  129. </resultMap>
  130. <select id="lazyTree" resultMap="treeNodeResultMap">
  131. SELECT
  132. d.id,
  133. d.parent_id,
  134. d.node_name AS title,
  135. d.id AS "value",
  136. d.id AS "key",
  137. d.major_data_type AS "majorDataType",
  138. d.display_hierarchy AS "displayHierarchy",
  139. d.is_storage_node AS "isStorageNode",
  140. d.post_type AS postType,
  141. d.project_type,
  142. d.storage_type,
  143. d.ext_type,
  144. d.ext_id,
  145. d.archive_auto_type,
  146. d.archive_auto_node_id,
  147. (SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_archive_tree_contract WHERE parent_id = d.id and is_deleted = 0 and project_id = #{projectId})
  148. AS "has_children"
  149. FROM
  150. m_archive_tree_contract d
  151. WHERE
  152. d.parent_id = #{parentId} AND d.is_deleted = 0 and project_id = #{projectId}
  153. <if test="tenantId!=null and tenantId!=''">
  154. AND d.tenant_id = #{tenantId}
  155. </if>
  156. ORDER BY d.sort
  157. </select>
  158. <select id="tree" resultMap="treeNodeResultMap">
  159. SELECT
  160. id,
  161. parent_id,
  162. node_name AS title,
  163. id AS "value",
  164. id AS "key",
  165. major_data_type AS "majorDataType",
  166. display_hierarchy AS "displayHierarchy",
  167. is_storage_node AS "isStorageNode",
  168. is_upload_file_display_configuration_tree AS "isDisplayTree",
  169. is_built_drawing AS "isBuiltDrawing",
  170. post_type AS postType,
  171. project_type,
  172. storage_type,
  173. ext_type,
  174. ext_id,
  175. archive_auto_type,
  176. archive_auto_node_id
  177. FROM m_archive_tree_contract
  178. WHERE is_deleted = 0 and project_id = #{projectId}
  179. <if test=" tenantId!=null and tenantId!='' ">
  180. AND tenant_id = #{tenantId}
  181. </if>
  182. <if test=" disPlayTree!=null and disPlayTree!='' ">
  183. AND is_upload_file_display_configuration_tree = 1
  184. </if>
  185. <if test=" nodeType !=null and nodeType !='' ">
  186. /*根节点=0 关联电子原生文件=1 数字化上传文件=2*/
  187. AND node_type in (0,#{nodeType})
  188. </if>
  189. OR parent_id = 0
  190. ORDER BY sort
  191. </select>
  192. <select id="lazyTree2" resultMap="ArchiveTreeContractVO2ResultMap">
  193. SELECT
  194. d.id,
  195. d.parent_id,
  196. IFNULL(if(length(trim(d.full_name))>0,d.full_name,d.node_name),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.association_type,
  205. d.project_type,
  206. d.storage_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.tree_sort,
  215. d.file_number_prefix,
  216. d.storage_time,
  217. d.rollor,
  218. d.reviewer,
  219. d.specification,
  220. d.archive_name_suffix,
  221. d.contract_id,
  222. (SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_archive_tree_contract WHERE parent_id = d.id and is_deleted = 0 and project_id = #{projectId})
  223. AS "has_children",
  224. (SELECT count(1) FROM m_archive_tree_contract WHERE is_deleted = 0 and project_id = #{projectId} and ancestors like CONCAT('%',d.id,'%')
  225. <if test="code!=null and code!=''">
  226. AND (tree_code = #{code} or tree_code = #{contractId} or parent_id = 0)
  227. </if>
  228. ) as tree_number
  229. FROM
  230. m_archive_tree_contract d
  231. WHERE
  232. d.parent_id = #{parentId} AND d.is_deleted = 0 and project_id = #{projectId}
  233. <if test="tenantId!=null and tenantId!=''">
  234. AND d.tenant_id = #{tenantId}
  235. </if>
  236. <if test="code!=null and code!=''">
  237. AND (d.tree_code = #{code} or d.tree_code = #{contractId} or d.parent_id = 0)
  238. </if>
  239. ORDER BY d.tree_sort, d.sort
  240. </select>
  241. <select id="tree2" resultMap="ArchiveTreeContractVO2ResultMap">
  242. SELECT
  243. id,
  244. parent_id,
  245. contract_id,
  246. node_name AS title,
  247. id AS "value",
  248. id AS "key",
  249. major_data_type AS "majorDataType",
  250. display_hierarchy AS "displayHierarchy",
  251. is_storage_node AS "isStorageNode",
  252. is_upload_file_display_configuration_tree AS "isDisplayTree",
  253. is_built_drawing AS "isBuiltDrawing",
  254. post_type AS postType,
  255. node_type AS nodeType,
  256. association_type,
  257. project_type,
  258. storage_type,
  259. ext_type,
  260. ext_id,
  261. exp_data_type,
  262. archive_auto_type,
  263. archive_auto_node_id,
  264. archive_auto_group_select,
  265. archive_auto_group_id,
  266. from_id,
  267. tree_sort,
  268. tree_code
  269. FROM m_archive_tree_contract
  270. WHERE is_deleted = 0 and project_id = #{projectId}
  271. <if test=" tenantId!=null and tenantId!='' ">
  272. AND tenant_id = #{tenantId}
  273. </if>
  274. <if test=" disPlayTree!=null and disPlayTree!='' ">
  275. AND is_upload_file_display_configuration_tree = 1
  276. </if>
  277. <if test=" nodeType !=null and nodeType !='' ">
  278. /*根节点=0 关联电子原生文件=1 数字化上传文件=2*/
  279. AND node_type in (0,#{nodeType})
  280. </if>
  281. <if test="code!=null and code!=''">
  282. AND (d.tree_code = #{code} or d.tree_code = #{contractId} or d.parent_id = 0)
  283. </if>
  284. OR ( parent_id = 0 AND project_id = #{projectId} AND is_deleted = 0 )
  285. ORDER BY sort
  286. </select>
  287. <update id="updateBatch">
  288. UPDATE m_archive_tree_contract
  289. SET is_upload_file_display_configuration_tree = 1
  290. WHERE id IN
  291. <foreach item="diffRent" collection="diffRent" open="(" close=")" separator=",">
  292. #{diffRent}
  293. </foreach>
  294. AND is_deleted = 0
  295. AND status = 1
  296. </update>
  297. <update id="updateBatch2">
  298. UPDATE m_archive_tree_contract
  299. SET is_upload_file_display_configuration_tree = 0
  300. WHERE id IN
  301. <foreach item="diffRent" collection="diffRent" open="(" close=")" separator=",">
  302. #{diffRent}
  303. </foreach>
  304. AND is_deleted = 0
  305. AND status = 1
  306. </update>
  307. <update id="updateBatch3">
  308. UPDATE m_archive_tree_contract
  309. SET is_upload_file_display_configuration_tree = 0
  310. WHERE
  311. node_type = 2
  312. AND is_deleted = 0
  313. AND status = 1
  314. </update>
  315. <select id="getHavedFileNodeByProjectID" resultMap="archiveTreeContractResultMap">
  316. SELECT
  317. *
  318. FROM
  319. m_archive_tree_contract
  320. WHERE
  321. 1 = 1
  322. AND project_id = #{projectId}
  323. AND is_deleted = 0
  324. AND archive_auto_type IS NOT NULL
  325. AND id IN (
  326. SELECT
  327. node_id
  328. FROM
  329. u_archive_file
  330. WHERE
  331. 1 = 1
  332. AND project_id = #{projectId}
  333. AND is_deleted = 0
  334. AND ( is_archive = 0 OR is_archive IS NULL )
  335. AND node_id IS NOT NULL
  336. )
  337. order by ancestors asc,tree_sort asc
  338. </select>
  339. <select id="getHavedBoxFileNodeByProjectID" resultMap="archiveTreeContractResultMap">
  340. SELECT
  341. *
  342. FROM
  343. m_archive_tree_contract
  344. WHERE
  345. 1 = 1
  346. AND project_id = #{projectId}
  347. AND is_deleted = 0
  348. AND id IN (
  349. SELECT
  350. node_id
  351. FROM
  352. u_archive_file
  353. WHERE
  354. 1 = 1
  355. AND project_id = #{projectId}
  356. AND is_deleted = 0
  357. AND ( is_archive = 0 OR is_archive IS NULL )
  358. AND node_id IS NOT NULL
  359. AND (box_number IS NOT NULL and box_number != -1 )
  360. )
  361. order by ancestors asc,tree_sort asc
  362. </select>
  363. <select id="getListByProjectId" resultType="org.springblade.manager.entity.ArchiveTreeContract">
  364. select id,project_id as projectId,contract_id as contractId,parent_id as parentId,ancestors,node_name as nodeName,status,tree_code as treeCode, ext_type as extType,
  365. is_deleted as isDeleted,create_time as createTime, file_number_prefix as fileNumberPrefix
  366. from m_archive_tree_contract
  367. where project_id=#{projectId} and is_deleted = 0 order by tree_sort asc;
  368. </select>
  369. <select id="getStorageNodeByGroupId" resultMap="archiveTreeContractResultMap">
  370. SELECT
  371. *
  372. FROM
  373. m_archive_tree_contract
  374. WHERE
  375. 1 = 1
  376. AND project_id = #{projectId}
  377. AND is_deleted = 0
  378. AND archive_auto_type =2
  379. AND is_storage_node =1
  380. AND archive_auto_group_id =#{archiveAutoGroupId}
  381. order by tree_sort asc
  382. </select>
  383. <select id="getArchiveTreeAndArchiveCount" resultType="java.util.Map">
  384. SELECT
  385. matc1.id as id,
  386. matc1.node_name as name,
  387. (SELECT COUNT(*)
  388. FROM u_archives_auto uaa1
  389. WHERE uaa1.is_destroy =0 and uaa1.is_deleted =0 and uaa1.is_archive = 1 and (uaa1.node_id in
  390. (select id from m_archive_tree_contract matc2 WHERE matc2.project_id = #{projectId} and matc2.ancestors like CONCAT('%',matc1.id,'%')) or uaa1.node_id = matc1.id)
  391. ) as 'auto',
  392. (SELECT COUNT(*)
  393. FROM u_archives_auto uaa1
  394. WHERE uaa1.is_destroy =1 and uaa1.is_deleted =1 and uaa1.is_archive = 1 and (uaa1.node_id in
  395. (select id from m_archive_tree_contract matc2 WHERE matc2.project_id = #{projectId} and matc2.ancestors like CONCAT('%',matc1.id,'%')) or uaa1.node_id = matc1.id)
  396. ) as 'deleted',
  397. if((SELECT COUNT(*) from m_archive_tree_contract matc WHERE parent_id = matc1.id)=0,false,true) as hasChildren
  398. FROM m_archive_tree_contract matc1 WHERE matc1.project_id =#{projectId} and matc1.parent_id = #{nodeId} and matc1.is_deleted = 0
  399. </select>
  400. <select id="getArchiveTreeByNodeType" resultType="org.springblade.manager.vo.ArchiveTreeContractVO3">
  401. SELECT matc1.*,if((SELECT COUNT(*) from m_archive_tree_contract matc WHERE matc.parent_id = matc1.id)=0,true,false)
  402. as notExsitChild
  403. FROM m_archive_tree_contract matc1
  404. WHERE matc1.parent_id = (select id from m_archive_tree_contract
  405. WHERE parent_id = (select id from m_archive_tree_contract WHERE parent_id = 0 and project_id = #{projectId})
  406. and tree_code = #{nodeType})
  407. and matc1.is_deleted = 0
  408. <if test="contractId !=null and contractId !=''">
  409. AND matc1.contract_id = #{contractId}
  410. </if>
  411. </select>
  412. <select id="getArchiveTreeByNodeType2" resultType="org.springblade.manager.vo.ArchiveTreeContractVO3">
  413. SELECT matc1.*,if((SELECT COUNT(*) from m_archive_tree_contract matc WHERE matc.parent_id = matc1.id)=0,true,false)
  414. as notExsitChild
  415. FROM m_archive_tree_contract matc1
  416. WHERE matc1.parent_id in (select id from m_archive_tree_contract
  417. WHERE parent_id = (select id from m_archive_tree_contract WHERE parent_id = 0 and project_id = #{projectId} and is_deleted = 0)
  418. and is_deleted = 0 and tree_code is NULL)
  419. and matc1.is_deleted = 0
  420. </select>
  421. <select id="getChildrenNodeByNodeId" resultType="org.springblade.manager.vo.ArchiveTreeContractVO3">
  422. select matc1.*,if((SELECT COUNT(*) from m_archive_tree_contract matc WHERE matc.parent_id = matc1.id)=0,true,false)
  423. as notExsitChild
  424. from m_archive_tree_contract matc1 WHERE matc1.parent_id = #{nodeId} and matc1.is_deleted =0
  425. ORDER BY sort
  426. </select>
  427. <select id="getAuthCodeList" resultMap="archiveTreeContractResultMap">
  428. SELECT
  429. d.id
  430. FROM
  431. m_archive_tree_contract d
  432. WHERE
  433. d.is_deleted = 0
  434. AND d.ancestors like concat('%',#{id},'%')
  435. <if test="authCode !=null and authCode !=''">
  436. AND (d.tree_code = #{authCode} or d.tree_code = #{contractId} or d.parent_id = 0)
  437. </if>
  438. ORDER BY d.sort
  439. </select>
  440. <select id="getArchiveTreeContractListByIds" resultMap="archiveTreeContractResultMap">
  441. SELECT
  442. d.*
  443. FROM
  444. m_archive_tree_contract d
  445. WHERE
  446. d.is_deleted = 0 and d.id in
  447. <foreach item="id" collection="idsList" open="(" close=")" separator=",">
  448. #{id}
  449. </foreach>
  450. ORDER BY d.ancestors
  451. </select>
  452. <select id="getUserRoleName" resultType="java.lang.String">
  453. SELECT br.role_name
  454. FROM blade_role br
  455. WHERE br.id = (
  456. SELECT role_id FROM m_project_assignment_user
  457. WHERE project_id = #{projectId} AND contract_id = #{contractId} AND user_id = #{userId}
  458. )
  459. </select>
  460. <select id="getArchiveTreeContractByNodeName"
  461. resultType="org.springblade.manager.entity.ArchiveTreeContract">
  462. SELECT *
  463. FROM m_archive_tree_contract
  464. WHERE node_name = #{nodeName} and is_deleted = 0
  465. </select>
  466. <select id="getFirstNodeByTreeCode" resultType="org.springblade.manager.entity.ArchiveTreeContract">
  467. select * from m_archive_tree_contract
  468. WHERE parent_id = (select id from m_archive_tree_contract WHERE parent_id = 0 and project_id = #{projectId} and is_deleted = 0)
  469. and is_deleted = 0 and tree_code is NULL
  470. </select>
  471. <select id="getFirstNodeByTreeCode2" resultType="org.springblade.manager.entity.ArchiveTreeContract">
  472. select * from m_archive_tree_contract
  473. WHERE parent_id = (select id from m_archive_tree_contract WHERE parent_id = 0 and project_id = #{projectId} and is_deleted = 0)
  474. and is_deleted = 0 and tree_code = #{type}
  475. </select>
  476. <select id="getSelectRuleNode" resultType="org.springblade.manager.entity.ArchiveTreeContract">
  477. select * from m_archive_tree_contract
  478. WHERE project_id = #{projectId}) and is_deleted = 0 and archive_auto_group_select = 1
  479. </select>
  480. <select id="getCountfromIdIsNull" resultType="java.lang.Integer">
  481. select count(*) from m_archive_tree_contract
  482. WHERE project_id = #{projectId}) and is_deleted = 0 and from_id is null and like concat('%',#{id},'%')
  483. </select>
  484. <select id="getArchiveTreeContractByContractId"
  485. resultType="org.springblade.manager.entity.ArchiveTreeContract">
  486. select id from m_archive_tree_contract
  487. where contract_id = #{contractId} and is_deleted = 0
  488. order by ancestors
  489. limit 1
  490. </select>
  491. <!-- <select id="getUnitAllNode" resultType="org.springblade.manager.vo.InspectTreeVO">-->
  492. <!-- <if test="ownerUnit != null">-->
  493. <!-- select id,parent_id,node_name,-->
  494. <!-- (CASE when LENGTH(expert_id) > 0 then 0 else 1 end) as isSelect,-->
  495. <!-- (CASE when LENGTH(expert_id) > 0 then concat('该目录已分属', atc.expert_name , '专家') else '' end) as nodeInfo-->
  496. <!-- from m_archive_tree_contract atc-->
  497. <!-- WHERE is_deleted =0 and project_id = #{projectId}-->
  498. <!-- and (id = #{ownerUnit} or FIND_IN_SET(#{ownerUnit},ancestors))-->
  499. <!-- </if>-->
  500. <!-- <if test="ownerUnit != null and (supervisorUnit != null or buildUnit != null)">-->
  501. <!-- UNION all-->
  502. <!-- </if>-->
  503. <!-- <if test="supervisorUnit != null">-->
  504. <!-- select id,parent_id,node_name,-->
  505. <!-- (CASE when LENGTH(expert_id) > 0 then 0 else 1 end) as isSelect,-->
  506. <!-- (CASE when LENGTH(expert_id) > 0 then concat('该目录已分属', atc.expert_name , '专家') else '' end) as nodeInfo-->
  507. <!-- from m_archive_tree_contract atc-->
  508. <!-- WHERE is_deleted =0 and project_id = #{projectId}-->
  509. <!-- and (id = #{supervisorUnit} or FIND_IN_SET(#{supervisorUnit},ancestors))-->
  510. <!-- </if>-->
  511. <!-- <if test="supervisorUnit != null and buildUnit != null">-->
  512. <!-- UNION all-->
  513. <!-- </if>-->
  514. <!-- <if test="buildUnit != null ">-->
  515. <!-- select id,parent_id,node_name,-->
  516. <!-- (CASE when LENGTH(expert_id) > 0 then 0 else 1 end) as isSelect,-->
  517. <!-- (CASE when LENGTH(expert_id) > 0 then concat('该目录已分属', atc.expert_name , '专家') else '' end) as nodeInfo-->
  518. <!-- from m_archive_tree_contract atc-->
  519. <!-- WHERE is_deleted =0 and project_id = #{projectId}-->
  520. <!-- and (id = #{buildUnit} or FIND_IN_SET(#{buildUnit},ancestors))-->
  521. <!-- </if>-->
  522. <!-- </select>-->
  523. <select id="getUnitAllNode" resultType="org.springblade.manager.vo.InspectTreeVO">
  524. <if test="ownerUnit != null">
  525. select id,parent_id,
  526. (CASE when LENGTH(expert_id) > 0 then 0 else 1 end) as isSelect,
  527. if((select COUNT(1) from m_archive_tree_contract WHERE is_deleted = 0 and parent_id = atc.id) > 0,true,false) as isChildren,
  528. (CASE when LENGTH(expert_id) > 0 then concat('该目录已分属', atc.expert_name , '专家') else '' end) as nodeInfo,
  529. atc.node_name as node_name ,
  530. ( select count(1) from u_archives_auto where is_apply = 1 and is_deleted = 0 and node_id = atc.id ) as total
  531. from m_archive_tree_contract atc
  532. WHERE is_deleted =0 and project_id = #{projectId}
  533. and (id = #{ownerUnit} or FIND_IN_SET(#{ownerUnit},ancestors))
  534. </if>
  535. <if test="ownerUnit != null and (supervisorUnit != null or buildUnit != null)">
  536. UNION all
  537. </if>
  538. <if test="supervisorUnit != null">
  539. select id,parent_id,
  540. (CASE when LENGTH(expert_id) > 0 then 0 else 1 end) as isSelect,
  541. if((select COUNT(1) from m_archive_tree_contract WHERE is_deleted = 0 and parent_id = atc.id) > 0,true,false) as isChildren,
  542. (CASE when LENGTH(expert_id) > 0 then concat('该目录已分属', atc.expert_name , '专家') else '' end) as nodeInfo,
  543. atc.node_name as node_name ,
  544. ( select count(1) from u_archives_auto where is_apply = 1 and is_deleted = 0 and node_id = atc.id ) as total
  545. from m_archive_tree_contract atc
  546. WHERE is_deleted =0 and project_id = #{projectId}
  547. and (id = #{supervisorUnit} or FIND_IN_SET(#{supervisorUnit},ancestors))
  548. </if>
  549. <if test="supervisorUnit != null and buildUnit != null">
  550. UNION all
  551. </if>
  552. <if test="buildUnit != null ">
  553. select id,parent_id,
  554. (CASE when LENGTH(expert_id) > 0 then 0 else 1 end) as isSelect,
  555. if((select COUNT(1) from m_archive_tree_contract WHERE is_deleted = 0 and parent_id = atc.id) > 0,true,false) as isChildren,
  556. (CASE when LENGTH(expert_id) > 0 then concat('该目录已分属', atc.expert_name , '专家') else '' end) as nodeInfo,
  557. atc.node_name as node_name ,
  558. ( select count(1) from u_archives_auto where is_apply = 1 and is_deleted = 0 and node_id = atc.id ) as total
  559. from m_archive_tree_contract atc
  560. WHERE is_deleted =0 and project_id = #{projectId}
  561. and (id = #{buildUnit} or FIND_IN_SET(#{buildUnit},ancestors))
  562. </if>
  563. </select>
  564. <select id="getFirstNode" resultType="org.springblade.manager.vo.InspectTreeVO">
  565. select id,parent_id,
  566. (CASE when LENGTH(expert_id) > 0 then 0 else 1 end) as isSelect,
  567. if((select COUNT(1) from m_archive_tree_contract WHERE is_deleted = 0 and parent_id = atc.id) > 0,true,false) as isChildren,
  568. atc.node_name as node_name ,
  569. ( select count(1) from u_archives_auto where project_id = #{projectId} and is_apply = 1 and is_deleted = 0) as total
  570. from m_archive_tree_contract atc
  571. WHERE atc.parent_id = 0 and atc.is_deleted = 0 and project_id =#{projectId}
  572. </select>
  573. <select id="getUnitFirstNode" resultType="org.springblade.manager.entity.ArchiveTreeContract">
  574. SELECT id,
  575. (CASE tree_code WHEN 'C' THEN 3 WHEN 's' THEN 2 ELSE 1 END) as tree_code
  576. from m_archive_tree_contract
  577. WHERE parent_id = #{id} and is_deleted = 0
  578. </select>
  579. <select id="getSelectNodes" resultType="org.springblade.manager.entity.ArchiveTreeContract">
  580. select id,expert_id,expert_name
  581. from m_archive_tree_contract where id in
  582. <foreach collection="ids" item="id" open="(" separator="," close=")">
  583. #{id}
  584. </foreach>
  585. </select>
  586. <select id="MyLazyTree" resultType="org.springblade.manager.vo.MyInspectTreeVO">
  587. select *,node_name as title,
  588. if((select COUNT(1) from m_archive_tree_contract WHERE is_deleted = 0 and parent_id = d.id) > 0,true,false) as hasChildren
  589. FROM
  590. m_archive_tree_contract d
  591. WHERE
  592. d.parent_id = #{parentId} AND d.is_deleted = 0 and project_id = #{projectId}
  593. and FIND_IN_SET(#{userId},d.expert_id)
  594. ORDER BY d.sort
  595. </select>
  596. <select id="getNewTable" resultType="org.springblade.archive.entity.ArchiveExpertConclusion">
  597. select * from u_archive_expert_conclusion
  598. WHERE is_deleted = 0 and project_id = #{projectId}
  599. order by create_time DESC
  600. limit 1
  601. </select>
  602. <update id="updateAllSonNodeIdsForArchiveAutoRule">
  603. <if test="archiveAutoType ==1 ">
  604. update m_archive_tree_contract
  605. set
  606. archive_auto_node_id = #{archiveAutoNodeId}
  607. where
  608. is_deleted = 0 and ancestors like concat('', #{ancestors}, '%');
  609. </if>
  610. <if test="archiveAutoType ==1 and archiveAutoGroupId != null">
  611. update m_archive_tree_contract
  612. set
  613. archive_auto_type= #{archiveAutoType}
  614. where
  615. is_deleted = 0 and ancestors like concat('', #{ancestors}, '%')
  616. and archive_auto_group_id = #{archiveAutoGroupId} and archive_auto_type = 2 and archive_auto_group_select = 0 ;
  617. </if>
  618. update m_archive_tree_contract
  619. set
  620. archive_auto_type= #{archiveAutoType}
  621. <if test="archiveAutoType ==2 ">
  622. ,archive_auto_group_id=#{archiveAutoGroupId},
  623. archive_auto_group_select=0
  624. </if>
  625. <if test="fileNumberPrefix != null and fileNumberPrefix != ''">
  626. ,file_number_prefix = #{fileNumberPrefix}
  627. </if>
  628. where
  629. is_deleted = 0 and ancestors like concat('', #{ancestors}, '%')
  630. /*最高并卷规则不能覆盖 分类并卷规则,单独组卷规则*/
  631. <if test="archiveAutoType ==1 ">
  632. and (archive_auto_type != 2 and archive_auto_type != 3 or archive_auto_type is null)
  633. </if>
  634. </update>
  635. <update id="updateByNodeName">
  636. update m_archive_tree_contract
  637. set node_name = #{name}
  638. where node_name = #{contractName} and contract_id = #{id}
  639. </update>
  640. <update id="updateBatchFileSortById">
  641. <foreach collection="list" item="item" index="index" separator=";">
  642. update u_archive_file
  643. <set>
  644. sort = #{item.sort},
  645. pdf_file_url = #{item.pdfFileUrl},
  646. e_visa_file = #{item.eVisaFile},
  647. file_page = #{item.filePage},
  648. file_size = #{item.fileSize},
  649. is_certification = 1,
  650. certification_time = #{item.certificationTime},
  651. file_time = #{item.fileTime}
  652. </set>
  653. where id = #{item.id}
  654. </foreach>
  655. </update>
  656. <!-- 批量添加归档合同树 -->
  657. <insert id="batchInsertArchiveTreeContract" parameterType="java.util.List">
  658. INSERT INTO m_archive_tree_contract (id, tenant_id, project_id, contract_id, parent_id, ancestors, node_name,
  659. full_name, tree_code, ext_type, ext_id, ext_key_id, ext_attach_id, sort, status, is_deleted, from_id, node_type,
  660. is_storage_node, post_type, major_data_type, project_type, storage_type, create_user, create_dept, create_time, tree_structure)
  661. VALUES
  662. <foreach collection="list" item="item" separator=",">
  663. (#{item.id}, #{item.tenantId}, #{item.projectId}, #{item.contractId}, #{item.parentId},#{item.ancestors},
  664. #{item.nodeName},#{item.fullName},#{item.treeCode},#{item.extType},#{item.extId},#{item.extKeyId},#{item.extAttachId},
  665. #{item.sort},#{item.status},#{item.isDeleted},#{item.fromId},#{item.nodeType},#{item.isStorageNode},#{item.postType},#{item.majorDataType}
  666. ,#{item.projectType},#{item.storageType},#{item.createUser},#{item.createDept},#{item.createTime}, #{item.treeStructure})
  667. </foreach>
  668. </insert>
  669. <!-- 批量删除归档合同树 -->
  670. <update id="batchDeleteArchiveTreeContractByIdList">
  671. update
  672. m_archive_tree_contract
  673. set
  674. is_deleted = #{isDeleted},
  675. update_time = NOW()
  676. where
  677. id in
  678. <foreach collection="ids" item="id" open="(" separator="," close=")">
  679. #{id}
  680. </foreach>
  681. </update>
  682. <!-- 批量修改归档树 -->
  683. <update id="batchUpdateArchiveTreeContract">
  684. <foreach collection="list" item="item" index="index" separator=";">
  685. update
  686. m_archive_tree_contract
  687. <set>
  688. parent_id = #{item.parentId},
  689. ancestors = #{item.ancestors},
  690. node_name = #{item.nodeName},
  691. node_type = #{item.nodeType},
  692. full_name = #{item.fullName},
  693. tree_structure = #{item.treeStructure},
  694. update_time = NOW()
  695. </set>
  696. where id = #{item.id}
  697. </foreach>
  698. </update>
  699. <update id="updateAllChild">
  700. update
  701. m_archive_tree_contract
  702. <set>
  703. file_number_prefix = #{node.fileNumberPrefix},
  704. storage_time = #{node.storageTime},
  705. rollor = #{node.rollor},
  706. reviewer = #{node.reviewer},
  707. specification = #{node.specification},
  708. archive_name_suffix = #{node.archiveNameSuffix}
  709. </set>
  710. where is_deleted = 0 and project_id = #{node.projectId} and FIND_IN_SET(#{node.id},ancestors) > 0
  711. </update>
  712. <resultMap id="getArchiveTreeContractDtoMap" type="org.springblade.manager.dto.ArchiveTreeContractDTO">
  713. <id column="id" property="id"/>
  714. <result column="project_id" property="projectId"></result>
  715. <result column="contract_id" property="contractId"></result>
  716. <result column="parent_id" property="parentID"></result>
  717. <result column="node_name" property="nodeName"></result>
  718. <result column="update_time" property="updateUserTime"></result>
  719. <result column="real_name" property="updateUserName"></result>
  720. </resultMap>
  721. <select id="getArchiveTreeContractDto" resultMap="getArchiveTreeContractDtoMap">
  722. select a.id,a.project_id,a.parent_id,a.contract_id,a.node_name,b.real_name,a.update_time from m_archive_tree_contract AS a LEFT JOIN blade_user AS b
  723. on a.update_user=b.id where a.project_id=#{projectId}
  724. and (a.contract_id in
  725. <foreach collection="dtos" item="item" open="(" separator="," close=")">
  726. #{item.cqContractId}
  727. </foreach>
  728. or a.contract_id is null) and a.tenant_id!='000000';
  729. </select>
  730. <select id="getLogDict" resultType="org.springblade.system.entity.DictBiz">
  731. select * from blade_dict_biz where parent_id != 0 and code = 'contract_log_type' and is_deleted = 0
  732. </select>
  733. <select id="getAllTrialNode" resultType="org.springblade.manager.vo.ArchiveSyncTrialVO">
  734. select p_key_id,id,parent_id,node_name,full_name,node_type,sort
  735. from m_wbs_tree_private
  736. where wbs_type = 2 and project_id = #{projectId} and `type` = 1 and is_deleted = 0
  737. and node_type in (51,52,53)
  738. order by sort
  739. </select>
  740. <select id="getAllTrialRecord" resultType="org.springblade.business.entity.TrialSelfInspectionRecord">
  741. select *
  742. from u_trial_self_inspection_record
  743. where contract_id = #{contractId} and is_deleted = 0 and task_status = '已审批'
  744. </select>
  745. <select id="getAllTrialRecordFile"
  746. resultType="org.springblade.business.vo.TrialSelfInspectionRecordFileVO">
  747. select id,self_id,url,type,
  748. (select node_id from u_trial_self_inspection_record sir where sir.id = sirf.self_id) as nodeId
  749. from u_trial_self_inspection_record_file sirf
  750. where self_id in
  751. <foreach collection="ids" item="id" open="(" separator="," close=")">
  752. #{id}
  753. </foreach>
  754. </select>
  755. <select id="getAllThreeTestNode"
  756. resultType="org.springblade.manager.entity.TrialClassificationConfiguration">
  757. select *
  758. from m_trial_classification_configuration
  759. where is_deleted = 0 and parent_id in
  760. (
  761. select id from m_trial_classification_configuration where is_deleted = 0 and parent_id = 0 and node_type in (1,2)
  762. )
  763. </select>
  764. <select id="getAllTrialTestRecord" resultType="org.springblade.business.entity.TrialDetectionData">
  765. select *
  766. from m_trial_detection_data
  767. where contract_id = #{contractId} and is_deleted = 0
  768. </select>
  769. <select id="getOutNodes" resultType="org.springblade.manager.entity.ArchiveTreeContract">
  770. select id,node_name,parent_id,out_id from m_archive_tree_contract
  771. WHERE project_id = #{projectId} and is_deleted = 0 and out_id is not null
  772. </select>
  773. <select id="getOutNodesByOutIds" resultType="org.springblade.manager.entity.ArchiveTreeContract">
  774. select id,node_name,parent_id,out_id
  775. from m_archive_tree_contract
  776. where project_id = #{projectId} and is_deleted = 0 and
  777. out_id in
  778. <foreach collection="ids" item="id" open="(" separator="," close=")">
  779. #{id}
  780. </foreach>
  781. </select>
  782. </mapper>