WbsTreeMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  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.WbsTreeMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="wbsTreeResultMap" type="org.springblade.manager.entity.WbsTree">
  6. <result column="id" property="id"/>
  7. <result column="w_id" property="wbsId"/>
  8. <result column="is_deleted" property="isDeleted"/>
  9. <result column="status" property="status"/>
  10. <result column="create_time" property="createTime"/>
  11. <result column="create_user" property="createUser"/>
  12. <result column="create_dept" property="createDept"/>
  13. <result column="update_user" property="updateUser"/>
  14. <result column="update_time" property="updateTime"/>
  15. <result column="type" property="type"/>
  16. <result column="table_type" property="tableType"/>
  17. <result column="tenant_id" property="tenantId"/>
  18. <result column="parent_id" property="parentId"/>
  19. <result column="ancestors" property="ancestors"/>
  20. <result column="node_type" property="nodeType"/>
  21. <result column="node_name" property="nodeName"/>
  22. <result column="full_name" property="fullName"/>
  23. <result column="sort" property="sort"/>
  24. <result column="remark" property="remark"/>
  25. <result column="unique_code" property="uniqueCode"/>
  26. <result column="partition_code" property="partitionCode"/>
  27. <result column="is_concrete" property="isConcrete"/>
  28. <result column="is_expernode" property="isExpernode"/>
  29. <result column="table_owner" property="tableOwner"/>
  30. <result column="major_data_type" property="majorDataType"/>
  31. <result column="init_table_name" property="initTableName"/>
  32. <result column="is_link_table" property="isLinkTable"/>
  33. <result column="is_exist_form" property="isExistForm"/>
  34. <result column="import_matching_info" property="importMatchingInfo"/>
  35. <result column="init_table_id" property="initTableId"/>
  36. <result column="et_tree_id" property="erTreeId"/>
  37. </resultMap>
  38. <resultMap id="treeNodeResultMap" type="org.springblade.manager.vo.TreeNodeVO">
  39. <id column="id" property="id"/>
  40. <result column="parent_id" property="parentId"/>
  41. <result column="title" property="title"/>
  42. <result column="value" property="value"/>
  43. <result column="key" property="key"/>
  44. <result column="has_children" property="hasChildren"/>
  45. <result column="type" property="type"/>
  46. <result column="nodeType" property="nodeType"/>
  47. <result column="wbsType" property="wbsType"/>
  48. <result column="isExistForm" property="isExistForm"/>
  49. <result column="ancestors" property="ancestors"/>
  50. </resultMap>
  51. <resultMap id="treeNodeResultMap2" type="org.springblade.manager.vo.WbsTreeVO2">
  52. <id column="id" property="id"/>
  53. <result column="parentId" 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="selectByNodeTableMap" type="org.springblade.manager.vo.WbsNodeTableVO">
  67. <id column="id" property="id"/>
  68. <result column="tableName" property="tableName"/>
  69. <result column="tableType" property="tableType"/>
  70. <result column="isCreateTable" property="isCreateTable"/>
  71. <result column="elementTotal" property="elementTotal"/>
  72. <result column="tableOwner" property="tableOwner"/>
  73. <result column="initTableName" property="initTableName"/>
  74. <result column="sort" property="sort"/>
  75. <result column="pKeyId" property="pKeyId"/>
  76. <result column="fillRate" property="fillRate"/>
  77. <result column="initTableId" property="initTableId"/>
  78. </resultMap>
  79. <resultMap id="wbsFormElementMap" type="org.springblade.manager.vo.WbsFormElementVO">
  80. <id column="id" property="id"/>
  81. <result column="f_id" property="fId"/>
  82. <result column="e_key" property="eKey"/>
  83. <result column="e_name" property="eName"/>
  84. <result column="e_type" property="eType"/>
  85. <result column="e_length" property="eLength"/>
  86. <result column="e_allow_deviation" property="eAllowDeviation"/>
  87. <result column="e_inspection_method" property="eInspectionMethod"/>
  88. <result column="tableElementKey" property="tableElementKey"/>
  89. <result column="initTableName" property="initTableName"/>
  90. <result column="nodeId" property="nodeId"/>
  91. <result column="globalFormula" property="globalFormula"/>
  92. <result column="isBussTime" property="isBussTime"/>
  93. <result column="dynamic_dict" property="dynamicDict"/>
  94. </resultMap>
  95. <insert id="addFormElement" parameterType="org.springblade.manager.dto.WbsFormElementDTO">
  96. insert into m_wbs_form_element(f_id,e_name,e_type,e_length)
  97. values (#{f_id},#{e_name},#{e_type},#{e_length})
  98. </insert>
  99. <insert id="insertForm">
  100. insert into m_wbs_tree
  101. </insert>
  102. <insert id="insertWbsTreePrivate">
  103. INSERT INTO m_wbs_tree_private(
  104. id,wbs_id,project_id,tenant_id,parent_id,ancestors,node_type,node_name,full_name,sort,remark,`type`,
  105. table_type,create_time,create_user,create_dept,update_user,update_time,`STATUS`,is_deleted,
  106. unique_code,partition_code,is_expernode,is_concrete,table_owner,major_data_type,init_table_name,is_link_table)
  107. VALUES(
  108. #{wbsTree.id},#{wbsTree.wbsId},#{projectId},#{wbsTree.tenantId},#{wbsTree.parentId},#{wbsTree.ancestors},
  109. #{wbsTree.nodeType},#{wbsTree.nodeName},#{wbsTree.fullName},#{wbsTree.sort},#{wbsTree.remark},#{wbsTree.type},
  110. #{wbsTree.tableType},#{wbsTree.createTime},#{wbsTree.createUser},#{wbsTree.createDept},#{wbsTree.updateUser},#{wbsTree.updateTime},
  111. #{wbsTree.status},#{wbsTree.isDeleted},#{wbsTree.uniqueCode},#{wbsTree.partitionCode},#{wbsTree.isExpernode},#{wbsTree.isConcrete},
  112. #{wbsTree.tableOwner},#{wbsTree.majorDataType},#{wbsTree.initTableName},#{wbsTree.isLinkTable})
  113. </insert>
  114. <insert id="insertWbsTreeContract">
  115. INSERT INTO m_wbs_tree_contract(
  116. id,wbs_id,project_id,contract_id,tenant_id,parent_id,ancestors,node_type,node_name,full_name,sort,remark,`type`,
  117. table_type,create_time,create_user,create_dept,update_user,update_time,`STATUS`,is_deleted,
  118. unique_code,partition_code,is_expernode,is_concrete,table_owner,major_data_type,init_table_name,is_link_table)
  119. VALUES(
  120. #{wbsTree.id},#{wbsTree.wbsId},#{projectId},#{contractId},#{wbsTree.tenantId},#{wbsTree.parentId},#{wbsTree.ancestors},
  121. #{wbsTree.nodeType},#{wbsTree.nodeName},#{wbsTree.fullName},#{wbsTree.sort},#{wbsTree.remark},#{wbsTree.type},
  122. #{wbsTree.tableType},#{wbsTree.createTime},#{wbsTree.createUser},#{wbsTree.createDept},#{wbsTree.updateUser},#{wbsTree.updateTime},
  123. #{wbsTree.status},#{wbsTree.isDeleted},#{wbsTree.uniqueCode},#{wbsTree.partitionCode},#{wbsTree.isExpernode},#{wbsTree.isConcrete},
  124. #{wbsTree.tableOwner},#{wbsTree.majorDataType},#{wbsTree.initTableName},#{wbsTree.isLinkTable})
  125. </insert>
  126. <update id="removeTableById">
  127. UPDATE m_wbs_tree AS wt SET is_deleted = 1 WHERE wt.type = 2 AND wt.id = #{id}
  128. </update>
  129. <update id="updateById2">
  130. UPDATE m_wbs_tree AS wt SET wt.ancestors = #{ancestors} WHERE is_deleted = 0 AND wt.id = #{id}
  131. </update>
  132. <update id="updateById3">
  133. UPDATE m_wbs_tree AS wt SET wt.parent_id = #{parentId} WHERE is_deleted = 0 AND wt.id = #{id}
  134. </update>
  135. <update id="createWbsTreeTable">
  136. create table ${tableName} as select * from m_wbs_tree WHERE 1=2
  137. </update>
  138. <update id="updateByCondition">
  139. UPDATE m_wbs_tree
  140. <trim prefix="set" suffixOverrides=",">
  141. <if test="wbsName != null and wbsName != '' ">
  142. `node_name` = #{wbsName},
  143. </if>
  144. <if test="status != null and status != '' ">
  145. `status` = #{status}
  146. </if>
  147. </trim>
  148. WHERE wbs_id = #{id}
  149. AND parent_id = 0
  150. AND is_deleted = 0
  151. </update>
  152. <update id="updateSortById">
  153. UPDATE m_wbs_tree
  154. SET sort = #{sort}
  155. WHERE id = #{id}
  156. AND type = 1
  157. AND status = 1
  158. AND is_deleted = 0
  159. </update>
  160. <delete id="deleteBatchProjectNodeId">
  161. delete from m_wbs_tree where project_node_id = #{projectNodeId} and id &lt;&gt; #{projectNodeId}
  162. </delete>
  163. <delete id="deleteBatch" parameterType="java.util.List">
  164. DELETE FROM m_wbs_tree_private
  165. WHERE id IN
  166. <foreach item="ids" collection="ids" open="(" close=")" separator=",">
  167. #{ids}
  168. </foreach>
  169. AND wbs_id = #{wbsId}
  170. AND project_id = #{projectId}
  171. </delete>
  172. <delete id="deleteBatch2" parameterType="java.util.List">
  173. DELETE FROM m_wbs_tree_private
  174. WHERE parent_id IN
  175. <foreach item="ids" collection="ids" open="(" close=")" separator=",">
  176. #{ids}
  177. </foreach>
  178. AND wbs_id = #{wbsId}
  179. AND project_id = #{projectId}
  180. </delete>
  181. <delete id="deleteLogicById">
  182. DELETE FROM m_wbs_tree WHERE id = #{id} OR project_node_id = #{id} OR ancestors like concat('%',#{id},'%')
  183. </delete>
  184. <delete id="cancelRelation">
  185. UPDATE m_wbs_tree SET is_link_table = 1 WHERE id = #{id}
  186. </delete>
  187. <delete id="deleteBatch3">
  188. delete from m_wbs_tree_private where project_id = #{project} and parent_id = -10 and `type` =10
  189. </delete>
  190. <update id="deleteLogicByWbsId">
  191. update m_wbs_tree set is_deleted = 1 where wbs_id = #{ids} and status = 1
  192. </update>
  193. <update id="updateIsExistFormById">
  194. UPDATE m_wbs_tree SET is_exist_form = 1 WHERE id = #{id} AND status = 1 AND is_deleted = 0
  195. </update>
  196. <update id="createTable">
  197. create table ${newTableName}
  198. (
  199. `id` bigint(20) NOT NULL,
  200. `p_key_id` bigint(20) COMMENT '合同段wbs表的p_key_id',
  201. `group_id` bigint(20) COMMENT '分组id',
  202. PRIMARY KEY (`id`) USING BTREE
  203. ) ENGINE=InnoDB DEFAULT CHARSET=utf8
  204. </update>
  205. <update id="alterTableFiled">
  206. ALTER TABLE ${initTableName} ADD COLUMN ${eKey} ${eType}(${eLength})
  207. </update>
  208. <update id="updateByParentId">
  209. UPDATE m_wbs_tree
  210. SET is_link_table = 1
  211. WHERE parent_id = #{parentId}
  212. AND id != #{id}
  213. AND type = 2
  214. AND status = 1
  215. AND is_deleted = 0
  216. </update>
  217. <select id="selectWbsTreePage" resultMap="wbsTreeResultMap">
  218. select *
  219. from m_wbs_tree where is_deleted = 0
  220. </select>
  221. <select id="tree" resultMap="treeNodeResultMap">
  222. select id, parent_id, node_name as title,type as "type", id as "value", id as "key", node_type as
  223. "nodeType",is_exist_form AS "isExistForm",
  224. (select wbs_type from m_wbs_info where id = #{wbsId}) as "wbsType"
  225. from m_wbs_tree where
  226. is_deleted = 0
  227. and status = 1
  228. <if test="wbsId!=null and wbsId!=''">
  229. and wbs_id = #{wbsId}
  230. </if>
  231. <if test="tenantId!=null and tenantId!=''">
  232. and tenant_id = #{tenantId}
  233. </if>
  234. <if test="type!=null and type!=''">
  235. and `type` = #{type}
  236. </if>
  237. ORDER BY sort
  238. </select>
  239. <select id="tree2" resultMap="treeNodeResultMap2">
  240. SELECT
  241. d.id,
  242. d.tenant_id AS "tenantId",
  243. d.parent_id AS "parentId",
  244. d.node_name AS title,
  245. d.type AS "type",
  246. d.id AS "value",
  247. d.id AS "key",
  248. d.major_data_type,
  249. d.node_type AS "nodeType",
  250. d.is_exist_form AS "isExistForm",
  251. a.wbs_type AS "wbsType"
  252. FROM m_wbs_tree d INNER JOIN m_wbs_info a ON a.id = #{wbsId}
  253. WHERE
  254. d.is_deleted = 0
  255. AND d.status = 1
  256. <if test="wbsId!=null and wbsId!=''">
  257. AND d.wbs_id = #{wbsId}
  258. </if>
  259. <if test="tenantId!=null and tenantId!=''">
  260. AND d.tenant_id = #{tenantId}
  261. </if>
  262. <if test="type!=null and type!=''">
  263. AND d.`type` = #{type}
  264. </if>
  265. ORDER BY d.sort
  266. </select>
  267. <select id="lazyTree2" resultMap="treeNodeResultMap2">
  268. SELECT
  269. t.id,
  270. t.type AS "type",
  271. t.node_type AS "nodeType",
  272. t.is_exist_form AS "isExistForm",
  273. t.parent_id,
  274. t.node_name AS title,
  275. t.id AS "value",
  276. t.id AS "key",
  277. t.ancestors AS "ancestors",
  278. (select case when count(1) > 0 then 1 else 0 end from m_wbs_tree where parent_id = t.id and is_deleted = 0) AS
  279. "has_children"
  280. FROM
  281. m_wbs_tree t
  282. WHERE
  283. t.parent_id = #{parentId} AND t.is_deleted = 0
  284. <if test="tenantId!=null and tenantId!=''">
  285. AND t.tenant_id = #{tenantId}
  286. </if>
  287. AND t.wbs_id = #{wbsId}
  288. AND t.type = 1
  289. AND status = 1
  290. ORDER BY t.sort
  291. </select>
  292. <select id="lazyTree" resultMap="treeNodeResultMap">
  293. SELECT
  294. (select wbs_type from m_wbs_info where id = #{wbsId}) AS wbsType,
  295. t.type AS "type",
  296. t.node_type AS "nodeType",
  297. t.is_exist_form AS "isExistForm",
  298. t.table_type,
  299. t.id,
  300. t.parent_id,
  301. t.node_name AS title,
  302. t.id AS "value",
  303. t.id AS "key",
  304. t.ancestors AS "ancestors",
  305. (select case when count(1) > 0 then 1 else 0 end from m_wbs_tree where parent_id = t.id and is_deleted = 0) AS
  306. "has_children"
  307. FROM
  308. m_wbs_tree t
  309. WHERE
  310. t.parent_id = #{parentId} AND t.is_deleted = 0
  311. <if test="tenantId!=null and tenantId!=''">
  312. AND t.tenant_id = #{tenantId}
  313. </if>
  314. AND t.wbs_id = #{wbsId}
  315. AND t.type = 1
  316. AND status = 1
  317. ORDER BY t.sort
  318. </select>
  319. <select id="selectByNodeTable" resultMap="selectByNodeTableMap">
  320. SELECT wt.id AS id,
  321. wt.node_name AS tableName,
  322. wt.sort AS sort,
  323. case
  324. when wt.table_type in (1, 9) then 1
  325. when wt.table_type in (2, 10) then 2
  326. else wt.table_type
  327. end as tableType,
  328. wt.`status` AS isCreateTable,
  329. wt.table_owner as tableOwner,
  330. wt.is_link_table,
  331. wt.init_table_name as "initTableName",
  332. wt.parent_id AS "parentId",
  333. wt.wbs_id AS "wbsId",
  334. wt.fill_rate AS "fillRate",
  335. wt.init_table_id AS initTableId,
  336. (SELECT count(1)
  337. FROM m_wbs_form_element
  338. WHERE f_id = wt.init_table_id and is_deleted = 0 and status = 1) AS
  339. "elementTotal"
  340. FROM m_wbs_tree AS wt
  341. WHERE wt.type = 2
  342. AND wt.is_deleted = 0
  343. AND wt.parent_id = #{id}
  344. ORDER BY wt.sort, wt.node_name, wt.create_time
  345. </select>
  346. <select id="selectByNodeTableByExcel" resultMap="selectByNodeTableMap">
  347. SELECT wt.p_key_id as pKeyId,
  348. wt.id AS id,
  349. wt.node_name AS tableName,
  350. wt.sort AS sort,
  351. wt.table_type AS tableType,
  352. wt.`status` AS isCreateTable,
  353. wt.table_owner as tableOwner,
  354. IF(wt.excel_id = #{liunxId}, IF(is_link_table = 2, 2, 1), 1) as is_link_table,
  355. wt.init_table_name as "initTableName",
  356. wt.parent_id AS "parentId",
  357. wt.wbs_id AS "wbsId",
  358. (SELECT count(*)
  359. FROM m_wbs_form_element AS wfe
  360. WHERE wfe.f_id = wt.id
  361. and wfe.is_deleted = 0) AS elementTotal
  362. FROM m_wbs_tree_private AS wt
  363. WHERE wt.type = 2
  364. AND wt.is_deleted = 0
  365. AND wt.parent_id = #{id}
  366. AND wt.project_id = #{projectid}
  367. ORDER BY wt.sort
  368. </select>
  369. <select id="selectByElementsTotal" resultType="java.lang.String">
  370. SELECT f_id,count(*) as elementTotal FROM m_wbs_form_element where f_id in #{ids} and is_deleted=0 GROUP BY f_id
  371. </select>
  372. <select id="selectFormElements" resultMap="wbsFormElementMap">
  373. select f_id,
  374. e_key,
  375. a.id,
  376. a.dynamic_dict,
  377. e_name,
  378. e_type,
  379. e_length,
  380. e_allow_deviation,
  381. e_Inspection_method,
  382. CONCAT(b.init_table_name, ':', e_key)
  383. as tableElementKey,
  384. init_table_name as initTableName,
  385. b.parent_id as nodeId
  386. from m_wbs_form_element a
  387. inner join m_wbs_tree b on a.f_id = b.init_table_id
  388. where b.id = #{id}
  389. and a.is_deleted = 0
  390. union
  391. select f_id,
  392. e_key,
  393. a.id,
  394. a.dynamic_dict,
  395. e_name,
  396. e_type,
  397. e_length,
  398. e_allow_deviation,
  399. e_Inspection_method,
  400. CONCAT(b.init_table_name, ':', e_key)
  401. as tableElementKey,
  402. init_table_name as initTableName,
  403. b.parent_id as nodeId
  404. from m_wbs_form_element a
  405. inner join m_wbs_tree_private b on a.f_id = b.init_table_id
  406. where b.p_key_id = #{id}
  407. and a.is_deleted = 0
  408. </select>
  409. <select id="selectFormElements4TableId" resultMap="wbsFormElementMap">
  410. select b.id
  411. , IF(c.formula_id > 0, 1, 0) globalFormula
  412. , b.e_name
  413. , e_type
  414. , e_length
  415. , e_allow_deviation
  416. , e_Inspection_method
  417. , CONCAT(a.tab_en_name, ':', e_key) as
  418. tableElementKey
  419. , a.tab_en_name as initTableName,
  420. if((SELECT count(d.tab_en_name) from m_tab_busstime_info d where b.id = d.col_id)>=1,2,0) isBussTime
  421. from (select * from m_table_info where id = #{id}) a
  422. INNER JOIN
  423. m_wbs_form_element b on a.id = b.f_id
  424. LEFT JOIN(select element_id, formula_id
  425. from m_element_formula_mapping
  426. where scope = 0) c on b.id = c.element_id
  427. where b.is_deleted = 0
  428. </select>
  429. <select id="selectPrivateFormElements" resultMap="wbsFormElementMap">
  430. select * from m_wbs_form_element a
  431. where a.f_id=#{id} and a.is_deleted=0
  432. <if test="eName != null and eName != '' ">
  433. and e_name like concat('%',#{eName},'%')
  434. </if>
  435. </select>
  436. <select id="selectRepeatByProjectId" resultType="java.lang.Integer">
  437. SELECT COUNT(*) FROM m_wbs_tree_private WHERE project_id = #{projectId} AND status = 1 AND is_deleted = 0
  438. </select>
  439. <select id="findAllNodeTableList" resultType="org.springblade.manager.entity.WbsTree">
  440. SELECT *
  441. FROM m_wbs_tree
  442. WHERE type = 2
  443. AND is_deleted = 0
  444. AND `status` = 1
  445. AND wbs_id = #{wbsId}
  446. </select>
  447. <select id="selectIsTable" resultType="org.springblade.manager.entity.WbsTree">
  448. SELECT *
  449. FROM m_wbs_tree
  450. WHERE type = 2
  451. AND is_deleted = 0
  452. AND `status` = 1
  453. AND parent_id = #{tableParentId}
  454. </select>
  455. <select id="selectNodeAndTable" resultType="org.springblade.manager.entity.WbsTree">
  456. SELECT *
  457. FROM m_wbs_tree
  458. WHERE id = #{id}
  459. OR (parent_id = #{id} and type = 2)
  460. AND is_deleted = 0 AND status = 1
  461. </select>
  462. <select id="selectByWbsId" resultType="org.springblade.manager.entity.WbsTree">
  463. SELECT *
  464. FROM m_wbs_tree
  465. WHERE wbs_id = #{id}
  466. AND status = 1
  467. AND is_deleted = 0
  468. AND parent_id = 0
  469. AND type = 1
  470. </select>
  471. <select id="selectListByUserId" resultType="org.springblade.manager.vo.SaveUserInfoByProjectVO2">
  472. SELECT mpau.id AS "id"
  473. , pi.project_name as "projectName"
  474. , ci.contract_name as "contractName"
  475. , (SELECT role_name FROM blade_role WHERE id = r.parent_id) as "roleType"
  476. , r.role_name as "roleName"
  477. FROM m_project_assignment_user mpau
  478. INNER JOIN blade_role r ON r.id = mpau.role_id
  479. INNER JOIN m_contract_info ci ON ci.id = mpau.contract_id
  480. INNER JOIN m_project_info pi ON pi.id = mpau.project_id
  481. WHERE mpau.is_deleted = 0
  482. AND mpau.`status` = 1
  483. AND mpau.user_id = #{userId}
  484. </select>
  485. <select id="selectWbsTreeListByParentId" resultType="org.springblade.manager.dto.WbsTreeDTO2">
  486. SELECT id,node_name AS "nodeName",sort
  487. FROM m_wbs_tree
  488. WHERE parent_id = #{parentId}
  489. AND status = 1
  490. AND is_deleted = 0
  491. AND type = 1
  492. ORDER BY sort
  493. </select>
  494. <select id="searchNodeTables" resultType="org.springblade.manager.vo.WbsNodeTableVO">
  495. SELECT wt.id AS id,
  496. wt.node_name AS tableName,
  497. wt.sort AS sort,
  498. wt.table_type AS tableType,
  499. wt.`status` AS `status`,
  500. wt.table_owner AS tableOwner,
  501. wt.init_table_name AS "initTableName",
  502. wt.parent_id AS "parentId",
  503. wt.wbs_id AS "wbsId",
  504. (SELECT count(1) FROM m_wbs_form_element WHERE f_id = wt.id) AS "elementTotal",
  505. (SELECT CASE WHEN count(1) > 0 THEN 2 ELSE 1 END
  506. FROM m_wbs_tab_relation_excel_tab b
  507. WHERE wt.id = b.wbs_tab_id
  508. AND b.excel_tab_id = #{excelId}) AS "isLinkTable"
  509. FROM m_wbs_tree AS wt
  510. WHERE wt.type = 2
  511. AND wt.is_deleted = 0
  512. AND wt.STATUS = 1
  513. AND wt.parent_id = #{nodeId}
  514. ORDER BY wt.sort
  515. </select>
  516. <select id="isThereAField" resultType="java.lang.Integer">
  517. select COUNT(*) from information_schema.columns WHERE table_name = #{initTableName} and column_name = #{keyId}
  518. </select>
  519. <select id="getTitleRange" resultType="org.springblade.manager.entity.WbsTreePrivate">
  520. SELECT id,node_name,status From m_wbs_tree_private where project_id = #{projectId} and node_type=1 and is_deleted=0
  521. and parent_id in (select id from m_wbs_tree_private where project_id= #{projectId} and parent_id=0 and is_deleted=0)
  522. </select>
  523. </mapper>