WbsTreePrivateMapper.xml 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949
  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.WbsTreePrivateMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="wbsTreeResultMap" type="org.springblade.manager.entity.WbsTreePrivate">
  6. <result column="project_id" property="projectId"/>
  7. <result column="p_key_id" property="pKeyId"/>
  8. <result column="id" property="id"/>
  9. <result column="tree_p_id" property="treePId"/>
  10. <result column="w_id" property="wbsId"/>
  11. <result column="is_deleted" property="isDeleted"/>
  12. <result column="status" property="status"/>
  13. <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
  14. <result column="create_user" property="createUser"/>
  15. <result column="create_dept" property="createDept"/>
  16. <result column="update_user" property="updateUser"/>
  17. <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  18. <result column="type" property="type"/>
  19. <result column="table_type" property="tableType"/>
  20. <result column="tenant_id" property="tenantId"/>
  21. <result column="parent_id" property="parentId"/>
  22. <result column="ancestors" property="ancestors"/>
  23. <result column="node_type" property="nodeType"/>
  24. <result column="node_name" property="nodeName"/>
  25. <result column="full_name" property="fullName"/>
  26. <result column="sort" property="sort"/>
  27. <result column="remark" property="remark"/>
  28. <result column="unique_code" property="uniqueCode"/>
  29. <result column="partition_code" property="partitionCode"/>
  30. <result column="is_concrete" property="isConcrete"/>
  31. <result column="is_expernode" property="isExpernode"/>
  32. <result column="table_owner" property="tableOwner"/>
  33. <result column="major_data_type" property="majorDataType"/>
  34. <result column="init_table_name" property="initTableName"/>
  35. <result column="init_table_id" property="initTableId"/>
  36. <result column="is_link_table" property="isLinkTable"/>
  37. <result column="import_matching_info" property="importMatchingInfo"/>
  38. <result column="tab_file_type" property="tabFileType"/>
  39. <result column="trial_tab_contract_id" property="trialTabContractId"/>
  40. <result column="yzer_tree_id" property="yzerTreeId"/>
  41. <result column="jler_tree_id" property="jlerTreeId"/>
  42. </resultMap>
  43. <resultMap id="resultMap2" type="org.springblade.manager.vo.WbsTreePrivateVO2">
  44. <result column="pKeyId" property="pKeyId"/>
  45. <result column="wbs_id" property="wbsId"/>
  46. <result column="wbs_type" property="wbsType"/>
  47. <result column="project_id" property="projectId"/>
  48. <result column="project_name" property="projectName"/>
  49. </resultMap>
  50. <resultMap id="WbsTreeResultMap2" type="org.springblade.manager.vo.WbsTreeVO2">
  51. <id column="id" property="id"/>
  52. <result column="primaryKeyId" property="primaryKeyId"/>
  53. <result column="parent_id" property="parentId"/>
  54. <result column="title" property="title"/>
  55. <result column="value" property="value"/>
  56. <result column="key" property="key"/>
  57. <result column="has_children" property="hasChildren"/>
  58. <result column="major_data_type" property="majorDataType"/>
  59. <result column="type" property="type"/>
  60. <result column="nodeType" property="nodeType"/>
  61. <result column="wbsType" property="wbsType"/>
  62. <result column="isExistForm" property="isExistForm"/>
  63. <result column="ancestors" property="ancestors"/>
  64. <result column="tenantId" property="tenantId"/>
  65. </resultMap>
  66. <resultMap id="treeNodeResultMap" type="org.springblade.manager.vo.TreeNodeVO">
  67. <id column="id" property="id"/>
  68. <result column="parent_id" property="parentId"/>
  69. <result column="title" property="title"/>
  70. <result column="value" property="value"/>
  71. <result column="key" property="key"/>
  72. <result column="has_children" property="hasChildren"/>
  73. <result column="type" property="type"/>
  74. <result column="wbsType" property="wbsType"/>
  75. <result column="primaryKeyId" property="primaryKeyId"/>
  76. <result column="nodeType" property="nodeType"/>
  77. <result column="isExistForm" property="isExistForm"/>
  78. <result column="majorDataType" property="majorDataType"/>
  79. <result column="mixRatioTestIds" property="mixRatioTestIds"/>
  80. </resultMap>
  81. <resultMap id="treeNodeResultMap2" type="org.springblade.manager.vo.TreeNodeVO">
  82. <id column="id" property="id"/>
  83. <result column="parent_id" property="parentId"/>
  84. <result column="title" property="title"/>
  85. <result column="has_children" property="hasChildren"/>
  86. <result column="primaryKeyId" property="primaryKeyId"/>
  87. </resultMap>
  88. <resultMap id="treeNodeResultMapTabType" type="org.springblade.manager.vo.TreeNodeVOByTabType">
  89. <id column="id" property="id"/>
  90. <result column="parent_id" property="parentId"/>
  91. <result column="title" property="title"/>
  92. <result column="has_children" property="hasChildren"/>
  93. <result column="primaryKeyId" property="primaryKeyId"/>
  94. <result column="tabOwner" property="tabOwner"/>
  95. <result column="tabType" property="tabType"/>
  96. <result column="elementTotal" property="elementTotal"/>
  97. <result column="fillRate" property="fillRate"/>
  98. <result column="initTableId" property="initTableId"/>
  99. <result column="excelIds" property="excelIds"/>
  100. </resultMap>
  101. <insert id="insertCombination1">
  102. INSERT INTO m_wbs_tree_private(p_key_id, id, wbs_id, wbs_type, project_id, tenant_id, parent_id, ancestors,
  103. node_type, node_name, full_name, sort, remark, `type`,
  104. table_type, create_time, create_user, create_dept, update_user, update_time,
  105. `STATUS`, is_deleted,
  106. unique_code, partition_code, is_expernode, is_concrete, table_owner,
  107. major_data_type, init_table_name, is_link_table)
  108. VALUES (#{snowId}, #{wbsTree.id}, #{wbsTree.wbsId}, #{wbsType}, #{projectId}, #{wbsTree.tenantId},
  109. #{wbsTree.parentId}, #{wbsTree.ancestors},
  110. #{wbsTree.nodeType}, #{wbsTree.nodeName}, #{wbsTree.fullName}, #{wbsTree.sort}, #{wbsTree.remark},
  111. #{wbsTree.type},
  112. #{wbsTree.tableType}, #{wbsTree.createTime}, #{wbsTree.createUser}, #{wbsTree.createDept},
  113. #{wbsTree.updateUser}, #{wbsTree.updateTime},
  114. #{wbsTree.status}, #{wbsTree.isDeleted}, #{wbsTree.uniqueCode}, #{wbsTree.partitionCode},
  115. #{wbsTree.isExpernode}, #{wbsTree.isConcrete},
  116. #{wbsTree.tableOwner}, #{wbsTree.majorDataType}, #{wbsTree.initTableName}, #{wbsTree.isLinkTable})
  117. </insert>
  118. <insert id="insertCombination2">
  119. INSERT INTO m_wbs_tree_private(p_key_id, id, wbs_id, wbs_type, project_id, tenant_id, parent_id, ancestors,
  120. node_type, node_name, full_name, sort, remark, `type`,
  121. table_type, create_time, create_user, create_dept, update_user, update_time,
  122. `STATUS`, is_deleted,
  123. unique_code, partition_code, is_expernode, is_concrete, table_owner,
  124. major_data_type, init_table_name, is_link_table)
  125. VALUES (#{snowId}, #{wbsTree.id}, #{wbsTree.wbsId}, #{wbsTree.wbsType}, #{projectId}, #{wbsTree.tenantId},
  126. #{wbsTree.parentId}, #{wbsTree.ancestors},
  127. #{wbsTree.nodeType}, #{wbsTree.nodeName}, #{wbsTree.fullName}, #{wbsTree.sort}, #{wbsTree.remark},
  128. #{wbsTree.type},
  129. #{wbsTree.tableType}, #{wbsTree.createTime}, #{wbsTree.createUser}, #{wbsTree.createDept},
  130. #{wbsTree.updateUser}, #{wbsTree.updateTime},
  131. #{wbsTree.status}, #{wbsTree.isDeleted}, #{wbsTree.uniqueCode}, #{wbsTree.partitionCode},
  132. #{wbsTree.isExpernode}, #{wbsTree.isConcrete},
  133. #{wbsTree.tableOwner}, #{wbsTree.majorDataType}, #{wbsTree.initTableName}, #{wbsTree.isLinkTable})
  134. </insert>
  135. <update id="deleteByCondition">
  136. UPDATE m_wbs_tree_private
  137. SET is_deleted = 1
  138. WHERE id = #{id}
  139. AND wbs_id = #{wbsId}
  140. AND project_id = #{projectId}
  141. </update>
  142. <update id="deleteByCondition2">
  143. UPDATE m_wbs_tree_private
  144. SET is_deleted = 1
  145. WHERE parent_id = #{id}
  146. AND wbs_id = #{wbsId}
  147. AND project_id = #{projectId}
  148. </update>
  149. <update id="updateByCondition">
  150. UPDATE m_wbs_tree_private
  151. SET is_deleted = 0
  152. WHERE id = #{id}
  153. AND wbs_id = #{wbsId}
  154. AND project_id = #{projectId}
  155. </update>
  156. <update id="updateTableByCondition">
  157. UPDATE m_wbs_tree_private
  158. SET is_deleted = 0
  159. WHERE parent_id = #{id}
  160. AND project_id = #{projectId}
  161. AND wbs_id = #{wbsId}
  162. AND type = 2
  163. </update>
  164. <update id="updateDeletedByCondition">
  165. UPDATE m_wbs_tree_private
  166. SET is_deleted = 1
  167. WHERE type = 2
  168. AND id = #{id}
  169. AND wbs_id = #{wbsId}
  170. AND project_id = #{projectId}
  171. </update>
  172. <update id="updateByPKeyId">
  173. update m_wbs_tree_private
  174. set tenant_id = #{wbsTP.tenantId},
  175. parent_id = #{wbsTP.parentId},
  176. node_type = #{wbsTP.nodeType},
  177. node_name = #{wbsTP.nodeName},
  178. full_name = #{wbsTP.nodeName},
  179. ancestors = #{wbsTP.ancestors},
  180. unique_code = #{wbsTP.uniqueCode},
  181. partition_code = #{wbsTP.partitionCode},
  182. major_data_type = #{wbsTP.majorDataType},
  183. create_user = #{wbsTP.createUser},
  184. create_dept = #{wbsTP.createDept},
  185. create_time = #{wbsTP.createTime},
  186. update_user = #{wbsTP.updateUser},
  187. update_time = #{wbsTP.updateTime},
  188. mix_ratio_test_ids = #{wbsTP.mixRatioTestIds},
  189. is_concrete = #{wbsTP.isConcrete},
  190. is_expernode = #{wbsTP.isExpernode},
  191. is_add_conceal = #{wbsTP.isAddConceal},
  192. status = 1,
  193. is_deleted = 0
  194. <if test="wbsTP.className!=null and wbsTP.className!=''">
  195. ,class_name =#{wbsTP.className},
  196. unit_name =#{wbsTP.unitName},
  197. is_classifition =#{wbsTP.isClassifition}
  198. </if>
  199. where p_key_id = #{pKeyId}
  200. </update>
  201. <update id="updateSortById">
  202. UPDATE m_wbs_tree_private
  203. SET sort = #{sort}
  204. WHERE p_key_id = #{pKeyId}
  205. AND type = 1
  206. AND status = 1
  207. AND is_deleted = 0
  208. </update>
  209. <update id="updateSortById2">
  210. UPDATE m_wbs_tree_private
  211. SET sort = #{sort}
  212. WHERE p_key_id = #{pKeyId}
  213. AND type = 2
  214. -- AND status = 1
  215. AND is_deleted = 0
  216. </update>
  217. <update id="updateSortById3">
  218. UPDATE m_wbs_tree_private
  219. SET sort = #{sort}
  220. WHERE id = #{id}
  221. AND status = 1
  222. AND is_deleted = 0
  223. </update>
  224. <update id="updateIsDeletedByPKeyId">
  225. UPDATE m_wbs_tree_private
  226. SET is_deleted = 1
  227. WHERE p_key_id = #{pKeyId}
  228. AND status = 1
  229. AND is_deleted = 0
  230. </update>
  231. <update id="updateBatchByIds">
  232. UPDATE m_wbs_tree_private
  233. SET node_name = #{wbsTree.nodeName},
  234. full_name =#{wbsTree.nodeName},
  235. node_type = #{wbsTree.nodeType},
  236. major_data_type = #{wbsTree.majorDataType},
  237. unique_code = #{wbsTree.uniqueCode},
  238. partition_code = #{wbsTree.partitionCode},
  239. table_type = #{wbsTree.tableType},
  240. table_owner = #{wbsTree.tableOwner}
  241. fill_rate = #{wbsTree.fillRate}
  242. <if test="wbsTree.sort != null and wbsTree.sort != ''">
  243. , sort = #{wbsTree.sort}
  244. </if>
  245. WHERE id = #{wbsTree.id}
  246. AND project_id = #{projectId}
  247. AND status = 1
  248. AND is_deleted = 0
  249. </update>
  250. <update id="updateBatchByIds2">
  251. UPDATE m_wbs_tree_private
  252. SET node_name = #{wbsTreePrivate.nodeName},
  253. full_name = #{wbsTreePrivate.fullName},
  254. node_type = #{wbsTreePrivate.nodeType},
  255. major_data_type = #{wbsTreePrivate.majorDataType},
  256. unique_code = #{wbsTreePrivate.uniqueCode},
  257. partition_code = #{wbsTreePrivate.partitionCode},
  258. table_type = #{wbsTreePrivate.tableType},
  259. table_owner = #{wbsTreePrivate.tableOwner},
  260. fill_rate = #{wbsTreePrivate.fillRate},
  261. import_matching_info = #{item.importMatchingInfo}
  262. <if test="wbsTreePrivate.sort != null and wbsTreePrivate.sort != ''">
  263. , sort = #{wbsTreePrivate.sort}
  264. </if>
  265. WHERE id = #{wbsTreePrivate.id}
  266. AND project_id = #{projectId}
  267. AND wbs_id = #{wbsId}
  268. AND status = 1
  269. AND is_deleted = 0
  270. </update>
  271. <update id="updateBatchWbsPrivate" parameterType="java.util.List">
  272. <foreach collection="listPrivate" item="item" index="index" separator=";">
  273. UPDATE m_wbs_tree_private
  274. <set>
  275. node_name = #{item.nodeName},
  276. full_name = #{item.fullName},
  277. node_type = #{item.nodeType},
  278. major_data_type = #{item.majorDataType},
  279. table_type = #{item.tableType},
  280. table_owner = #{item.tableOwner},
  281. fill_rate = #{item.fillRate},
  282. import_matching_info = #{item.importMatchingInfo},
  283. mix_ratio_test_ids = #{item.mixRatioTestIds},
  284. init_table_name = #{item.initTableName},
  285. init_table_id = #{item.initTableId},
  286. html_url = #{item.htmlUrl},
  287. excel_id = #{item.excelId},
  288. sort = #{item.sort}
  289. </set>
  290. WHERE id = #{item.id}
  291. AND project_id = #{item.projectId}
  292. AND wbs_id = #{item.wbsId}
  293. AND status = 1
  294. AND is_deleted = 0
  295. </foreach>
  296. </update>
  297. <update id="updateBatchByPKeyId">
  298. <foreach item="item" collection="list" separator=";">
  299. UPDATE m_wbs_tree_private
  300. <set>html_url = #{item.htmlUrl}</set>
  301. where p_key_id = #{item.pKeyId}
  302. </foreach>
  303. </update>
  304. <update id="syncCurrentFormInProject">
  305. UPDATE m_wbs_tree_private
  306. SET html_url = #{wbsTreePrivate.htmlUrl},
  307. init_table_name = #{wbsTreePrivate.initTableName},
  308. init_table_id = #{wbsTreePrivate.initTableId},
  309. node_name = #{wbsTreePrivate.nodeName},
  310. full_name = #{wbsTreePrivate.fullName}
  311. WHERE project_id = #{wbsTreePrivate.projectId}
  312. and excel_id = #{wbsTreePrivate.excelId}
  313. </update>
  314. <update id="updateContractByPId">
  315. <foreach collection="list" item="item" separator=";">
  316. update
  317. m_wbs_tree_contract
  318. set
  319. is_type_private_pid = #{item.isTypePrivatePid}
  320. where
  321. p_key_id = #{item.pKeyId}
  322. </foreach>
  323. </update>
  324. <select id="lazyTree" resultMap="treeNodeResultMap">
  325. SELECT
  326. d.p_key_id as "primaryKeyId",
  327. d.type AS "type",
  328. d.table_type,
  329. d.id,
  330. d.parent_id,
  331. IFNULL(d.yzer_tree_id,d.jler_tree_id) as erTreeId,
  332. CASE
  333. WHEN d.parent_id = 0 THEN
  334. (SELECT project_alias FROM m_project_info WHERE id = #{projectId})
  335. ELSE d.node_name
  336. END AS title,
  337. d.node_type AS "nodeType",
  338. d.id AS "value",
  339. d.id AS "key",
  340. d.major_data_type AS "majorDataType",
  341. d.is_exist_form AS "isExistForm",
  342. d.mix_ratio_test_ids AS "mixRatioTestIds",
  343. (
  344. SELECT
  345. CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
  346. FROM
  347. m_wbs_tree_private
  348. WHERE
  349. parent_id = d.id and is_deleted = 0 and type != 2
  350. ) AS "has_children"
  351. FROM
  352. m_wbs_tree_private d
  353. WHERE
  354. d.is_deleted = 0
  355. AND d.parent_id = #{parentId}
  356. AND d.project_id = #{projectId}
  357. <if test="wbsType != null and wbsType != '' and wbsType != -1">
  358. AND d.wbs_type = #{wbsType}
  359. </if>
  360. <if test="wbsId != null and wbsId != '' and wbsType !=-1">
  361. AND d.wbs_id = #{wbsId}
  362. </if>
  363. AND d.type = 1
  364. AND status = 1
  365. ORDER BY d.sort
  366. </select>
  367. <select id="selectAll" resultMap="resultMap2">
  368. SELECT
  369. wtp.p_key_id AS "pKeyId",
  370. wtp.wbs_id,
  371. wtp.wbs_type,
  372. wtp.project_id,
  373. ( SELECT project_name FROM m_project_info pi WHERE wtp.project_id = pi.id ) AS project_name
  374. FROM
  375. m_wbs_tree_private AS wtp
  376. WHERE
  377. is_deleted = 0
  378. AND STATUS = 1
  379. AND parent_id = 0
  380. <if test="wbsType != null and wbsType != ''">
  381. AND wbs_type = #{wbsType}
  382. </if>
  383. GROUP BY
  384. project_id
  385. ORDER BY
  386. ( SELECT create_time FROM m_project_info pi WHERE wtp.project_id = pi.id )
  387. </select>
  388. <select id="tree" resultMap="treeNodeResultMap">
  389. select p_key_id as "primaryKeyId",
  390. id, parent_id, node_name as title,type as "type", id as "value", id as "key" ,
  391. node_type AS "nodeType", is_exist_form AS "isExistForm",
  392. wbs_type as "wbsType"
  393. from m_wbs_tree_private
  394. where
  395. is_deleted = 0
  396. and status = 1
  397. and `type` = 1
  398. and project_id = #{projectId}
  399. and wbs_id = #{wbsId}
  400. <if test="wbsType != null and wbsType != ''">
  401. and wbs_type = #{wbsType}
  402. </if>
  403. <if test="parentId != null and parentId != ''">
  404. and parent_id = 0
  405. </if>
  406. ORDER BY sort
  407. </select>
  408. <select id="tree2" resultMap="WbsTreeResultMap2">
  409. select p_key_id as "primaryKeyId",
  410. id, parent_id , node_name as title,type as "type", id as "value", id as "key" ,
  411. node_type AS "nodeType", is_exist_form AS "isExistForm",major_data_type,
  412. wbs_type as "wbsType"
  413. from m_wbs_tree_private
  414. where
  415. is_deleted = 0
  416. and status = 1
  417. and `type` = 1
  418. and project_id = #{projectId}
  419. and wbs_id = #{wbsId}
  420. and parent_id is not null
  421. <if test="wbsType != null and wbsType != ''">
  422. and wbs_type = #{wbsType}
  423. </if>
  424. ORDER BY sort
  425. </select>
  426. <select id="selectByCondition" resultType="org.springblade.manager.entity.WbsTreePrivate">
  427. SELECT *
  428. FROM m_wbs_tree_private
  429. WHERE (id = #{id}
  430. AND type = 1
  431. AND project_id = #{projectId}
  432. AND wbs_id = #{wbsId}
  433. AND STATUS = 1
  434. AND is_deleted = 0)
  435. OR (parent_id = #{id}
  436. AND type = 2
  437. AND project_id = #{projectId}
  438. AND wbs_id = #{wbsId}
  439. AND STATUS = 1
  440. AND is_deleted = 0)
  441. </select>
  442. <select id="selectByCondition2" resultType="org.springblade.manager.entity.WbsTreePrivate">
  443. SELECT p_key_id
  444. FROM m_wbs_tree_private
  445. WHERE id = #{id}
  446. AND project_id = #{projectId}
  447. AND wbs_id = #{wbsId}
  448. AND STATUS = 1
  449. AND is_deleted = 1
  450. </select>
  451. <select id="selectIsTable" resultType="org.springblade.manager.entity.WbsTree">
  452. SELECT *
  453. FROM m_wbs_tree_private
  454. WHERE type = 2
  455. AND is_deleted = 0
  456. AND `status` = 1
  457. AND parent_id = #{tableId}
  458. AND project_id = #{projectId}
  459. </select>
  460. <select id="selectByNodeTable" resultType="org.springblade.manager.vo.WbsNodeTableVO">
  461. SELECT wt.p_key_id AS "pKeyId",
  462. wt.id AS id,
  463. wt.wbs_type AS wbsType,
  464. wt.node_name AS tableName,
  465. IFNULL(if(length(trim(wt.full_name)) > 0, wt.full_name, wt.node_name), wt.node_name) AS fullName,
  466. case
  467. when wt.table_type in (1, 9) then 1
  468. when wt.table_type in (2, 10) then 2
  469. else wt.table_type
  470. end as tableType,
  471. wt.`status` AS isCreateTable,
  472. wt.table_owner AS tableOwner,
  473. wt.is_link_table,
  474. wt.init_table_name,
  475. wt.init_table_id as initTableId,
  476. wt.excel_id AS excelId,
  477. wt.sort,
  478. wt.status,
  479. wt.node_type AS nodeType,
  480. wt.fill_rate AS "fillRate",
  481. wt.html_url AS htmlUrl,
  482. (SELECT count(1)
  483. FROM m_wbs_form_element
  484. WHERE f_id = wt.init_table_id
  485. and is_deleted = 0) AS "elementTotal"
  486. FROM m_wbs_tree_private AS wt
  487. WHERE wt.type = 2
  488. AND wt.is_deleted = 0
  489. AND wt.parent_id = #{id}
  490. AND wt.wbs_id = #{wbsId}
  491. AND wt.project_id = #{projectId}
  492. AND wt.trial_tab_contract_id is null
  493. -- AND (wt.wbs_type != 2 OR wt.table_type IN (1,2,9,10))
  494. ORDER BY wt.sort, fullName
  495. </select>
  496. <select id="getByCondition" resultType="org.springblade.manager.entity.WbsTreePrivate">
  497. SELECT *
  498. FROM m_wbs_tree_private
  499. WHERE project_id = #{projectId}
  500. AND id = #{parentId}
  501. AND wbs_id = #{wbsId}
  502. AND is_deleted = 0
  503. AND status = 1
  504. AND type = 1
  505. </select>
  506. <select id="getByPKeyId" resultType="org.springblade.manager.entity.WbsTreePrivate">
  507. SELECT *
  508. FROM m_wbs_tree_private
  509. WHERE p_key_id = #{pKeyId}
  510. </select>
  511. <select id="selectByCondition3" resultType="org.springblade.manager.entity.WbsTreePrivate">
  512. SELECT p_key_id
  513. FROM m_wbs_tree_private
  514. WHERE id = #{id}
  515. AND project_id = #{referencePrivateWbsProjectId}
  516. AND wbs_id = #{wbsId}
  517. AND STATUS = 1
  518. AND is_deleted = 0
  519. AND type = 1
  520. AND parent_id = 0
  521. </select>
  522. <select id="selectByPKeyId" resultType="org.springblade.manager.entity.WbsTreePrivate">
  523. SELECT *
  524. FROM m_wbs_tree_private
  525. WHERE p_key_id = #{referenceWbsTemplateId}
  526. </select>
  527. <select id="selectNodeListByCondition" resultType="org.springblade.manager.dto.WbsTreePrivateDTO2">
  528. SELECT p_key_id as "pKeyId", node_name AS "tableName", sort
  529. FROM m_wbs_tree_private
  530. WHERE project_id = #{projectId}
  531. AND parent_id = #{parentId}
  532. AND wbs_id = #{wbsId}
  533. AND status = 1
  534. AND is_deleted = 0
  535. AND type = 1
  536. ORDER BY sort
  537. </select>
  538. <select id="selectNodeAndTable" resultType="org.springblade.manager.entity.WbsTreePrivate">
  539. SELECT * FROM m_wbs_tree_private
  540. WHERE
  541. (
  542. type = 1
  543. <if test="id != null and id != ''">
  544. AND id = #{id}
  545. </if>
  546. AND project_id = #{referencePrivateWbsProjectId}
  547. AND wbs_id = #{wbsId}
  548. AND STATUS = 1
  549. AND is_deleted = 0
  550. )
  551. OR
  552. (
  553. type = 2
  554. <if test="id != null and id != ''">
  555. parent_id = #{id}
  556. </if>
  557. AND project_id = #{referencePrivateWbsProjectId}
  558. AND wbs_id = #{wbsId}
  559. AND STATUS = 1
  560. AND is_deleted = 0
  561. )
  562. OR
  563. (
  564. type = 10
  565. AND project_id = #{referencePrivateWbsProjectId}
  566. AND wbs_id is null
  567. AND parent_id = -10
  568. AND STATUS = 1
  569. AND is_deleted = 0
  570. )
  571. </select>
  572. <select id="selectNodeAndTable2" resultType="org.springblade.manager.entity.WbsTreePrivate">
  573. SELECT *
  574. FROM m_wbs_tree_private
  575. WHERE project_id = #{referencePrivateWbsProjectId}
  576. AND wbs_id = #{wbsId}
  577. AND STATUS = 1
  578. AND is_deleted = 0
  579. </select>
  580. <select id="selectByIds" resultType="org.springblade.manager.entity.WbsTreePrivate">
  581. SELECT * FROM m_wbs_tree_private
  582. WHERE id in
  583. <foreach item="ids" collection="ids" open="(" close=")" separator=",">
  584. #{ids}
  585. </foreach>
  586. AND project_id = #{projectId}
  587. </select>
  588. <select id="selectNodeTabAndParamList" resultType="org.springblade.manager.vo.WbsNodeTableVO">
  589. SELECT wt.p_key_id AS "pKeyId",
  590. wt.id AS id,
  591. wt.node_name AS tableName,
  592. wt.table_type AS tableType,
  593. wt.`status` AS isCreateTable,
  594. wt.table_owner as tableOwner,
  595. wt.is_link_table,
  596. wt.init_table_name,
  597. wt.init_table_id initTableId,
  598. wt.excel_id as excelId,
  599. wt.sort,
  600. wt.status,
  601. wt.parent_id AS parentId,
  602. (SELECT count(1) FROM m_wbs_form_element WHERE f_id = wt.id) AS "elementTotal"
  603. FROM m_wbs_tree_private AS wt
  604. WHERE wt.type = 2
  605. AND wt.is_deleted = 0
  606. AND wt.parent_id = #{id}
  607. AND wt.wbs_id = #{wbsId}
  608. AND wt.project_id = #{projectId}
  609. ORDER BY wt.sort, wt.node_name, wt.create_time
  610. </select>
  611. <!-- 项目级 表单类型分类 wbs树 -->
  612. <select id="tabTypeLazyTree" resultMap="treeNodeResultMapTabType">
  613. SELECT a.exceIds AS excelIds,
  614. p_key_id as id,p_key_id as primaryKeyId,title,parent_id,fill_rate as fillRate,initTableId,
  615. (SELECT dict_value from blade_dict where code='table_type' and dict_key not in(-1,0) and dict_key=table_type )
  616. as tabType,
  617. (SELECT count(1) FROM m_wbs_form_element WHERE f_id = initTableId and is_deleted=0) AS "elementTotal",
  618. (SELECT dict_value from blade_dict where code='owner_type' and dict_key not in(-1,0) and dict_key=table_owner )
  619. as tabOwner,
  620. /*排序*/
  621. -- (SELECT sort FROM m_wbs_node_sort c WHERE a.p_key_id = c.p_key_id) AS sort,
  622. (
  623. SELECT
  624. CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
  625. FROM
  626. (
  627. SELECT '12345678910' as p_key_id , '表单类型' as node_name, 0 as parent_id
  628. union all
  629. SELECT dict_key as p_key_id ,dict_value as node_name,'12345678910' as parent_id from blade_dict where
  630. code='table_type' and dict_key not in(-1,0)
  631. union all
  632. SELECT p_key_id,node_name,table_type as parent_id from m_wbs_tree_private WHERE project_id=#{projectId} and
  633. is_deleted=0 and type=10 and table_type is not NULL GROUP BY node_name
  634. ) b
  635. WHERE
  636. b.parent_id = a.p_key_id
  637. ) AS "has_children"
  638. from (
  639. SELECT '12345678910' as p_key_id , '表单类型' as title, 0 as parent_id,0 as table_type,0 as fill_rate,0 as
  640. table_owner,0 as initTableId,0 as exceIds
  641. union all
  642. SELECT dict_key as p_key_id ,dict_value as title,'12345678910' as parent_id,0 as table_type,0 as fill_rate,0 as
  643. table_owner,0 as initTableId,0 as exceIds from blade_dict where code='table_type' and dict_key not in(-1,0)
  644. union all
  645. SELECT p_key_id,node_name as title,table_type as parent_id,table_type,fill_rate,table_owner,init_table_id as
  646. initTableId,
  647. IFNULL(GROUP_CONCAT( excel_id ),-1) AS excelIds
  648. from m_wbs_tree_private WHERE project_id=#{projectId} and
  649. is_deleted=0 and type=10 and table_type is not NULL GROUP BY node_name
  650. ) a where 1=1
  651. <if test="parentId != null and parentId != ''">
  652. and a.parent_id = #{parentId}
  653. </if>
  654. <if test="titleName != null and titleName != ''">
  655. and a.title like concat('%',#{titleName},'%') and LENGTH(a.p_key_id)>11
  656. </if>
  657. /*排序*/
  658. -- order by sort,title
  659. </select>
  660. <!-- 项目级 表单类型分类 wbs树 -->
  661. <select id="tabTypeLazyTreeAll" resultMap="treeNodeResultMapTabType">
  662. SELECT p_key_id as id,p_key_id as primaryKeyId,title,parent_id,fill_rate as fillRate,0 as
  663. excelIds,initTableId,initTableName,
  664. (SELECT dict_value from blade_dict where code='table_type' and dict_key not in(-1,0) and dict_key=table_type )
  665. as tabType,
  666. (SELECT count(1) FROM m_wbs_form_element WHERE f_id = initTableId and is_deleted=0) AS "elementTotal",
  667. (SELECT dict_value from blade_dict where code='owner_type' and dict_key not in(-1,0) and dict_key=table_owner )
  668. as tabOwner,
  669. (
  670. SELECT
  671. CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
  672. FROM
  673. (
  674. SELECT '12345678910' as p_key_id , '表单类型' as node_name, 0 as parent_id
  675. union all
  676. SELECT dict_key as p_key_id ,dict_value as node_name,'12345678910' as parent_id from blade_dict where
  677. code='table_type' and dict_key not in(-1,0)
  678. union all
  679. SELECT id as p_key_id,tab_ch_name as node_name,tab_type as parent_id from m_table_info WHERE is_deleted=0
  680. ) b
  681. WHERE
  682. b.parent_id = a.p_key_id
  683. ) AS "has_children"
  684. from (
  685. SELECT '12345678910' as p_key_id , '表单类型' as title, 0 as parent_id,0 as table_type,0 as fill_rate,0 as
  686. table_owner,0 as initTableId,0 as initTableName
  687. union all
  688. SELECT dict_key as p_key_id ,dict_value as title,'12345678910' as parent_id,0 as table_type,0 as fill_rate,0 as
  689. table_owner,0 as initTableId,0 as initTableName from blade_dict where code='table_type' and dict_key not
  690. in(-1,0)
  691. union all
  692. SELECT id as p_key_id,tab_ch_name as title,tab_type as parent_id,tab_type as table_type,fill_rate,table_owner,id
  693. as initTableId,tab_en_name as initTableName from m_table_info WHERE is_deleted=0
  694. ) a where 1=1
  695. <if test="parentId != null and parentId != ''">
  696. and a.parent_id = #{parentId}
  697. </if>
  698. <if test="titleName != null and titleName != ''">
  699. and a.title like concat('%',#{titleName},'%') and LENGTH(a.p_key_id)>11
  700. </if>
  701. </select>
  702. <select id="selectWbsTreeTrialTabList" resultType="org.springblade.manager.vo.WbsTreePrivateVO4">
  703. SELECT
  704. p_key_id,
  705. node_name,
  706. full_name,
  707. node_type,
  708. case when table_type in(1,9) then 1
  709. when table_type in(2,10) then 2
  710. else table_type
  711. end as tableType,
  712. table_owner,
  713. is_link_table,
  714. is_tab_pdf,
  715. is_buss_show,
  716. tab_file_type,
  717. wbs_id,
  718. wbs_type,
  719. html_url,
  720. excel_id,
  721. project_id,
  722. parent_id,
  723. type,
  724. init_table_name,
  725. init_table_id,
  726. fill_rate,
  727. pdf_url,
  728. sort,
  729. create_time,
  730. ancestors,
  731. (CASE WHEN locate('__',node_name) > 0 THEN 1 ELSE 0 END) AS isCopyTab
  732. FROM
  733. m_wbs_tree_private
  734. WHERE project_id = #{projectId}
  735. AND wbs_id = #{wbsId}
  736. AND parent_id = #{parentId}
  737. AND table_type in (${tableType})
  738. AND type = 2
  739. AND status = 1
  740. AND is_deleted = 0
  741. /*试验所属方=7*/
  742. AND table_owner = 7
  743. /*解决不同合同段中复制表问题*/
  744. <if test="contractId == null">
  745. -- 后管加载原始表
  746. AND trial_tab_contract_id is null
  747. </if>
  748. <if test="contractId != null and contractId != ''">
  749. -- 客户端加载当前合同段表+原始表
  750. AND (trial_tab_contract_id is null OR (trial_tab_contract_id = #{contractId}))
  751. </if>
  752. ORDER BY sort,node_name,create_time
  753. </select>
  754. <select id="selectTabInfoAll" resultType="org.springblade.manager.entity.TableInfo">
  755. select *
  756. from m_table_info
  757. </select>
  758. <select id="treeRecordTrial" resultType="org.springblade.manager.vo.WbsTreePrivateVO5">
  759. select id, parent_id,
  760. node_name as title,
  761. node_type AS "nodeType",
  762. wbs_type as "wbsType"
  763. from m_wbs_tree_private
  764. where
  765. is_deleted = 0
  766. and status = 1
  767. and `type` = 1
  768. and project_id = #{projectId}
  769. and wbs_id = #{wbsId}
  770. <if test="wbsType != null and wbsType != ''">
  771. and wbs_type = #{wbsType}
  772. </if>
  773. ORDER BY sort
  774. </select>
  775. <select id="getAllPrivateTableByIds" resultType="java.lang.Long">
  776. select p_key_id from m_wbs_tree_private
  777. where is_deleted = 0 and project_id = #{projectId} and id in
  778. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  779. #{id}
  780. </foreach>
  781. </select>
  782. <select id="getALLTableConfig" resultType="org.springblade.manager.entity.TextdictInfo">
  783. select * from m_textdict_info where is_deleted = 0 and tab_id in
  784. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  785. #{id}
  786. </foreach>
  787. </select>
  788. <select id="getSelectNodes" resultType="org.springblade.manager.vo.WbsTreePrivateVO6">
  789. select *,ifnull((select count(1) from m_wbs_tree_private wtp2 where wtp2.parent_id = wtp.id and wtp2.is_deleted = 0 and project_id = #{projectId}),0) as formCount,
  790. (select GROUP_CONCAT(id)
  791. from m_wbs_tree_private wtp3 WHERE wtp3.parent_id = wtp.id and wtp3.is_deleted = 0 and project_id = #{projectId}) as formIds
  792. from m_wbs_tree_private wtp where p_key_id in
  793. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  794. #{id}
  795. </foreach>
  796. </select>
  797. <select id="getSelectContractNodes" resultType="org.springblade.manager.vo.WbsTreeContractVO7">
  798. select *,
  799. ifnull((select count(1) from m_wbs_tree_contract wtc2 where wtc2.project_id = #{projectId}
  800. and wtc2.contract_id = wtc.contract_id and wtc2.parent_id = wtc.id ),0) as formCount,
  801. (select GROUP_CONCAT(id)
  802. from m_wbs_tree_contract wtc3 WHERE wtc3.parent_id = wtc.id and wtc3.project_id = #{projectId}
  803. and wtc3.contract_id = wtc.contract_id and wtc3.parent_id = wtc.id) as formIds
  804. from m_wbs_tree_contract wtc where is_type_private_pid in
  805. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  806. #{id}
  807. </foreach>
  808. </select>
  809. <select id="getContractNode" resultType="org.springblade.manager.entity.WbsTreeContract">
  810. select p_key_id,id,wbs_id,contract_id,old_id,is_type_private_pid
  811. from m_wbs_tree_contract where project_id = #{projectId} and `type` = 1 and is_deleted = 0 and (is_type_private_pid = -1 or is_type_private_pid is null)
  812. </select>
  813. <select id="getPrivateNode" resultType="org.springblade.manager.entity.WbsTreePrivate">
  814. select p_key_id,id,wbs_id
  815. from m_wbs_tree_private where project_id = #{projectId} and `type` = 1 and is_deleted = 0
  816. </select>
  817. <select id="getThisForm" resultType="org.springblade.manager.entity.WbsTreePrivate">
  818. select * from m_wbs_tree_private where project_id = #{projectId} and parent_id = #{parentId} and id = #{id} and is_deleted = 0
  819. </select>
  820. <select id="getcontractAllNode" resultType="org.springblade.manager.entity.WbsTreeContract">
  821. select p_key_id,project_id,contract_id,id,wbs_id,old_id
  822. from m_wbs_tree_contract where project_id = #{projectId} and `type` = 1 and is_deleted = 0
  823. </select>
  824. <select id="getAllNodeByProjectId" resultType="org.springblade.manager.entity.WbsTreePrivate">
  825. select p_key_id,id,wbs_id,project_id from m_wbs_tree_private where project_id = #{projectId} and type = 1 and is_deleted = 0
  826. </select>
  827. <select id="getProjectOpinionNode" resultType="org.springblade.manager.entity.WbsTreePrivate">
  828. select * from m_wbs_tree_private where type = 2 and project_id = #{projectId} and parent_id = #{id} limit 1;
  829. </select>
  830. <delete id="delTabProjectById">
  831. delete
  832. from m_wbs_tree_private
  833. WHERE p_key_id = #{pKeyId}
  834. and project_id = #{projectId}AND type = 10
  835. </delete>
  836. <delete id="delTableById">
  837. delete
  838. from m_table_info
  839. WHERE id = #{pKeyId}
  840. </delete>
  841. <update id="cancelLinkNodeTreeInfoByJL">
  842. UPDATE m_wbs_tree_private
  843. SET jler_tree_id = NULL
  844. WHERE jler_tree_id = #{pkeyId}
  845. AND is_deleted = 0
  846. AND `type` = 1;
  847. </update>
  848. <update id="cancelLinkNodeTreeInfoByYZ">
  849. UPDATE m_wbs_tree_private
  850. SET yzer_tree_id = NULL
  851. WHERE yzer_tree_id = #{pkeyId}
  852. AND is_deleted = 0
  853. AND `type` = 1;
  854. </update>
  855. <update id="linkNodeTreeInfoByYZ" >
  856. <foreach collection="list" item="item" separator=";" >
  857. update m_wbs_tree_private set yzer_tree_id = #{pkeyid} where p_key_id = #{item} and is_deleted=0 and `type` = 1
  858. </foreach>
  859. </update>
  860. <update id="linkNodeTreeInfoByJL" >
  861. <foreach collection="list" item="item" separator=";" >
  862. update m_wbs_tree_private set jler_tree_id = #{pkeyid} where p_key_id = #{item} and is_deleted=0 and `type` = 1
  863. </foreach>
  864. </update>
  865. <update id="batchUpdateIsAddConceal">
  866. update m_wbs_tree_private
  867. set is_add_conceal = #{private.isAddConceal}
  868. where project_id = #{private.projectId}
  869. and FIND_IN_SET(#{pId},ancestors) > 0
  870. </update>
  871. <update id="updatePrivatePid">
  872. UPDATE m_wbs_tree_private a
  873. LEFT JOIN ( SELECT tree_p_id, p_key_id FROM m_wbs_tree_private WHERE project_id = #{projectId} ) b ON a.parent_id = b.tree_p_id
  874. SET a.p_id =IFNULL(b.p_key_id, 0)
  875. WHERE
  876. a.project_id = #{projectId}
  877. </update>
  878. <update id="updateBatchAncestorsByPKeyId">
  879. <foreach collection="allNodes" item="item" separator=";">
  880. UPDATE m_wbs_tree_private
  881. <set>`ancestors_p_id` = #{item.ancestorsPId}</set>
  882. where p_key_id = #{item.pKeyId}
  883. </foreach>
  884. </update>
  885. <select id="linkNodeTreeBynodeId" resultType="java.lang.Long" >
  886. select p_key_id from m_wbs_tree_private where `type` = 1 and is_deleted = 0
  887. <if test="nodeType != null and nodeType != '' and nodeType==1">
  888. and yzer_tree_id = #{pkeyid}
  889. </if>
  890. <if test="nodeType != null and nodeType != '' and nodeType==2">
  891. and jler_tree_id = #{pkeyid}
  892. </if>
  893. </select>
  894. <select id="getContractAllLog" resultType="org.springblade.manager.vo.ArchiveSyncLogVO">
  895. select id,create_user_name,record_time,file_name,pdf_url,e_visa_pdf_url,create_user,create_time,
  896. (select node_type from m_wbs_tree_private where p_key_id = ucl.wbs_node_id) as logType,
  897. (select node_name from m_wbs_tree_private where p_key_id = ucl.wbs_node_id) as logName
  898. from u_contract_log ucl
  899. where contract_id = #{contractId} and is_deleted = 0
  900. </select>
  901. </mapper>