WbsTreeContractMapper.xml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  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.WbsTreeContractMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="ResultMap" type="org.springblade.manager.entity.WbsTreeContract">
  6. <result column="id" property="id"/>
  7. <result column="p_key_id" property="pKeyId"/>
  8. <result column="wbs_id" property="wbsId"/>
  9. <result column="project_id" property="projectId"/>
  10. <result column="contract_id" property="contractId"/>
  11. <result column="contract_type" property="contractType"/>
  12. <result column="contract_id_relation" property="contractIdRelation"/>
  13. <result column="is_deleted" property="isDeleted"/>
  14. <result column="status" property="status"/>
  15. <result column="create_time" property="createTime"/>
  16. <result column="create_user" property="createUser"/>
  17. <result column="create_dept" property="createDept"/>
  18. <result column="update_user" property="updateUser"/>
  19. <result column="update_time" property="updateTime"/>
  20. <result column="type" property="type"/>
  21. <result column="table_type" property="tableType"/>
  22. <result column="tenant_id" property="tenantId"/>
  23. <result column="parent_id" property="parentId"/>
  24. <result column="ancestors" property="ancestors"/>
  25. <result column="node_type" property="nodeType"/>
  26. <result column="node_name" property="nodeName"/>
  27. <result column="full_name" property="fullName"/>
  28. <result column="sort" property="sort"/>
  29. <result column="remark" property="remark"/>
  30. <result column="unique_code" property="uniqueCode"/>
  31. <result column="partition_code" property="partitionCode"/>
  32. <result column="is_concrete" property="isConcrete"/>
  33. <result column="is_expernode" property="isExpernode"/>
  34. <result column="table_owner" property="tableOwner"/>
  35. <result column="major_data_type" property="majorDataType"/>
  36. <result column="init_table_name" property="initTableName"/>
  37. <result column="is_link_table" property="isLinkTable"/>
  38. <result column="wbs_type" property="wbsType"/>
  39. <result column="excel_id" property="excelId"/>
  40. <result column="old_id" property="oldId"/>
  41. <result column="html_url" property="htmlUrl"/>
  42. <result column="pdf_url" property="pdfUrl"/>
  43. <result column="is_buss_show" property="isBussShow"/>
  44. <result column="tab_file_type" property="tabFileType"/>
  45. <result column="is_cope_tab" property="isCopeTab"/>
  46. <result column="is_tab_pdf" property="isTabPdf"/>
  47. <result column="is_type_private_pid" property="isTypePrivatePid"/>
  48. <result column="is_import_identification_node" property="isImportIdentificationNode"/>
  49. <result column="import_matching_info" property="importMatchingInfo"/>
  50. <result column="is_concealed_works_node" property="isConcealedWorksNode"/>
  51. <result column="is_ele" property="isEle"/>
  52. <result column="tab_group_id" property="tabGroupId"/>
  53. <result column="tree_code" property="treeCode"/>
  54. </resultMap>
  55. <!-- 通用查询映射结果 -->
  56. <resultMap id="appResultMap" type="org.springblade.manager.vo.AppWbsTreeContractVO">
  57. <result column="id" property="id"/>
  58. <result column="p_key_id" property="pKeyId"/>
  59. <result column="wbs_id" property="wbsId"/>
  60. <result column="project_id" property="projectId"/>
  61. <result column="contract_id" property="contractId"/>
  62. <result column="contract_type" property="contractType"/>
  63. <result column="contract_id_relation" property="contractIdRelation"/>
  64. <result column="is_deleted" property="isDeleted"/>
  65. <result column="status" property="status"/>
  66. <result column="create_time" property="createTime"/>
  67. <result column="create_user" property="createUser"/>
  68. <result column="create_dept" property="createDept"/>
  69. <result column="update_user" property="updateUser"/>
  70. <result column="update_time" property="updateTime"/>
  71. <result column="type" property="type"/>
  72. <result column="table_type" property="tableType"/>
  73. <result column="tenant_id" property="tenantId"/>
  74. <result column="parent_id" property="parentId"/>
  75. <result column="ancestors" property="ancestors"/>
  76. <result column="node_type" property="nodeType"/>
  77. <result column="node_name" property="nodeName"/>
  78. <result column="full_name" property="fullName"/>
  79. <result column="sort" property="sort"/>
  80. <result column="remark" property="remark"/>
  81. <result column="unique_code" property="uniqueCode"/>
  82. <result column="partition_code" property="partitionCode"/>
  83. <result column="is_concrete" property="isConcrete"/>
  84. <result column="is_expernode" property="isExpernode"/>
  85. <result column="table_owner" property="tableOwner"/>
  86. <result column="major_data_type" property="majorDataType"/>
  87. <result column="init_table_name" property="initTableName"/>
  88. <result column="is_link_table" property="isLinkTable"/>
  89. <result column="wbs_type" property="wbsType"/>
  90. <result column="excel_id" property="excelId"/>
  91. <result column="old_id" property="oldId"/>
  92. <result column="html_url" property="htmlUrl"/>
  93. <result column="pdf_url" property="pdfUrl"/>
  94. <result column="is_buss_show" property="isBussShow"/>
  95. <result column="tab_file_type" property="tabFileType"/>
  96. <result column="is_cope_tab" property="isCopeTab"/>
  97. <result column="is_tab_pdf" property="isTabPdf"/>
  98. <result column="is_type_private_pid" property="isTypePrivatePid"/>
  99. <result column="is_import_identification_node" property="isImportIdentificationNode"/>
  100. <result column="import_matching_info" property="importMatchingInfo"/>
  101. <result column="is_concealed_works_node" property="isConcealedWorksNode"/>
  102. <result column="is_ele" property="isEle"/>
  103. <collection property="appUserList" javaType="java.util.List" ofType="org.springblade.manager.entity.AppUser"
  104. select="getuserInfoByaccount"
  105. column="{sonId=p_key_id}">
  106. </collection>
  107. </resultMap>
  108. <resultMap id="resultMap2" type="org.springblade.manager.vo.WbsTreeContractVO">
  109. <result column="id" property="id"/>
  110. <result column="wbs_id" property="wbsId"/>
  111. <result column="project_id" property="projectId"/>
  112. <result column="project_name" property="projectName"/>
  113. <result column="contract_id" property="contractId"/>
  114. </resultMap>
  115. <resultMap id="treeNodeResultMap" type="org.springblade.manager.vo.TreeNodeVO">
  116. <id column="id" property="id"/>
  117. <result column="parent_id" property="parentId"/>
  118. <result column="fullName" property="title"/>
  119. <result column="has_children" property="hasChildren"/>
  120. <result column="type" property="type"/>
  121. <result column="nodeType" property="nodeType"/>
  122. <result column="wbsType" property="wbsType"/>
  123. <result column="contractType" property="contractType"/>
  124. <result column="contractId" property="contractId"/>
  125. <result column="primaryKeyId" property="primaryKeyId"/>
  126. <result column="tenantId" property="tenantId"/>
  127. <result column="key" property="key"/>
  128. <result column="value" property="value"/>
  129. <result column="contractIdRelation" property="contractIdRelation"/>
  130. </resultMap>
  131. <resultMap id="apiTreeNodeResultMap" type="org.springblade.manager.vo.APIWbsContractNodeVo">
  132. <id column="id" property="id"/>
  133. <result column="p_key_id" property="pkeyId"/>
  134. <result column="parent_id" property="parentId"/>
  135. <result column="node_name" property="nodeName"/>
  136. <result column="type" property="type"/>
  137. <result column="has_children" property="hasChildren"/>
  138. </resultMap>
  139. <resultMap id="apiTreeNodeHzrcResultMap" type="org.springblade.manager.vo.APIWbsContractNodeHzrcVo">
  140. <id column="id" property="id"/>
  141. <result column="p_key_id" property="pkeyId"/>
  142. <result column="parent_id" property="parentId"/>
  143. <result column="node_name" property="nodeName"/>
  144. <result column="isMea" property="isMea"/>
  145. <result column="fileUrl" property="fileUrl"/>
  146. <result column="has_children" property="hasChildren"/>
  147. <result column="taskStatus" property="taskStatus"/>
  148. <result column="partitionCode" property="partitionCode"/>
  149. </resultMap>
  150. <insert id="insertByCondition">
  151. INSERT INTO m_wbs_tree_contract(p_key_id, id, wbs_id, wbs_type, project_id, contract_id, contract_type,
  152. tenant_id, parent_id, ancestors, node_type, node_name, full_name, sort,
  153. remark, `type`,
  154. table_type, create_time, create_user, create_dept, update_user, update_time,
  155. `STATUS`, is_deleted,
  156. unique_code, partition_code, is_expernode, is_concrete, table_owner,
  157. major_data_type, init_table_name, is_link_table, excel_id, html_url,
  158. is_type_private_pid, is_ele)
  159. VALUES (#{pKeyId}, #{wbsTree.id}, #{wbsTree.wbsId}, #{wbsType}, #{wbsTree.projectId}, #{contractId}, 1,
  160. #{wbsTree.tenantId}, #{wbsTree.parentId}, #{wbsTree.ancestors},
  161. #{wbsTree.nodeType}, #{wbsTree.nodeName}, #{wbsTree.fullName}, #{wbsTree.sort}, #{wbsTree.remark},
  162. #{wbsTree.type},
  163. #{wbsTree.tableType}, #{wbsTree.createTime}, #{wbsTree.createUser}, #{wbsTree.createDept},
  164. #{wbsTree.updateUser}, #{wbsTree.updateTime},
  165. #{wbsTree.status}, #{wbsTree.isDeleted}, #{wbsTree.uniqueCode}, #{wbsTree.partitionCode},
  166. #{wbsTree.isExpernode}, #{wbsTree.isConcrete},
  167. #{wbsTree.tableOwner}, #{wbsTree.majorDataType}, #{wbsTree.initTableName}, #{wbsTree.isLinkTable},
  168. #{wbsTree.excelId}, #{wbsTree.htmlUrl}, #{wbsTree.pKeyId}, 1)
  169. </insert>
  170. <update id="deleteBatch">
  171. DELETE FROM m_wbs_tree_contract
  172. WHERE (id IN
  173. <foreach item="ids" collection="ids" open="(" close=")" separator=",">
  174. #{ids}
  175. </foreach>
  176. OR parent_id IN
  177. <foreach item="ids" collection="ids" open="(" close=")" separator=",">
  178. #{ids}
  179. </foreach>)
  180. AND wbs_id = #{wbsId}
  181. AND project_id = #{projectId}
  182. AND contract_id = #{contractId}
  183. </update>
  184. <update id="updateByCondition">
  185. UPDATE m_wbs_tree_contract
  186. SET is_deleted = 0
  187. WHERE id = #{id}
  188. AND wbs_id = #{wbsId}
  189. AND project_id = #{projectId}
  190. AND contract_id = #{contractId}
  191. </update>
  192. <!-- <update id="updateByCondition1">-->
  193. <!-- UPDATE m_wbs_tree_contract-->
  194. <!-- SET node_type = #{wbsTP.nodeType},-->
  195. <!-- node_name = #{wbsTP.nodeName},-->
  196. <!-- unique_code = #{wbsTP.uniqueCode},-->
  197. <!-- partition_code = #{wbsTP.partitionCode},-->
  198. <!-- major_data_type = #{wbsTP.majorDataType}-->
  199. <!-- WHERE project_id = #{wbsTP.projectId}-->
  200. <!-- AND id = #{wbsTP.id}-->
  201. <!-- AND wbs_id = #{wbsTP.wbsId}-->
  202. <!-- </update>-->
  203. <update id="updateByCondition1">
  204. UPDATE m_wbs_tree_contract
  205. SET node_type = #{wbsTP.nodeType}
  206. <if test="wbsTP.isClassifition!=null and wbsTP.isClassifition!='' and wbsTP.isClassifition=1">
  207. ,is_classifition=#{wbsTP.isClassifition},class_name=#{wbsTP.className},unit_name=#{wbsTP.unitName}
  208. </if>
  209. WHERE project_id = #{wbsTP.projectId}
  210. AND is_type_private_pid = #{wbsTP.pKeyId}
  211. </update>
  212. <update id="updateByCondition2">
  213. UPDATE m_wbs_tree_contract
  214. SET is_deleted = 0
  215. WHERE contract_id = #{contractId}
  216. AND contract_id_relation = #{contractIdRelation}
  217. AND status = 1
  218. </update>
  219. <delete id="deleteByIds">
  220. DELETE FROM m_wbs_tree_contract WHERE p_key_id IN
  221. <foreach item="ids" collection="ids" open="(" close=")" separator=",">
  222. #{ids}
  223. </foreach>
  224. </delete>
  225. <delete id="deleteLogicByIds">
  226. UPDATE m_wbs_tree_contract SET is_deleted=1 WHERE p_key_id IN
  227. <foreach item="ids" collection="ids" open="(" close=")" separator=",">
  228. #{ids}
  229. </foreach>
  230. </delete>
  231. <select id="selectAll" resultMap="resultMap2">
  232. SELECT wtc.id,
  233. wtc.wbs_id,
  234. wtc.project_id,
  235. (SELECT project_name FROM m_project_info pi WHERE wtc.project_id = pi.id) AS project_name,
  236. contract_id
  237. FROM m_wbs_tree_contract wtc
  238. WHERE is_deleted = 0
  239. AND STATUS = 1
  240. GROUP BY project_id
  241. </select>
  242. <select id="selectByCondition" resultType="org.springblade.manager.entity.WbsTreeContract">
  243. SELECT *
  244. FROM m_wbs_tree_contract
  245. WHERE id = #{id}
  246. AND project_id = #{projectId}
  247. AND contract_id = #{contractId}
  248. AND wbs_id = #{wbsId}
  249. AND STATUS = 1
  250. AND is_deleted = 0
  251. </select>
  252. <select id="selectByCondition2" resultType="org.springblade.manager.entity.WbsTreeContract">
  253. SELECT *
  254. FROM m_wbs_tree_contract
  255. WHERE id = #{id}
  256. AND project_id = #{projectId}
  257. AND contract_id = #{contractId}
  258. AND wbs_id = #{wbsId}
  259. AND STATUS = 1
  260. </select>
  261. <select id="selectParent" resultType="org.springblade.manager.entity.WbsTreePrivate">
  262. SELECT p_key_id, node_name, full_name
  263. FROM m_wbs_tree_private
  264. WHERE project_id = #{projectId}
  265. AND wbs_id = #{wbsId}
  266. AND id = #{parentId}
  267. </select>
  268. <select id="queryCurrentContractLogList" resultMap="ResultMap">
  269. select p_key_id,
  270. node_name,
  271. full_name,
  272. node_type,
  273. excel_id,
  274. is_link_table
  275. from m_wbs_tree_private
  276. where is_deleted = 0
  277. and major_data_type = 5
  278. and wbs_type = 4
  279. and project_id = #{projectId}
  280. </select>
  281. <select id="selectListByCondition" resultType="org.springblade.manager.vo.WbsTreeContractVO2">
  282. SELECT p_key_id AS "pKeyId",
  283. id AS "id",
  284. node_name AS "nodeName",
  285. full_name AS "fullName",
  286. wbs_type AS "wbsType",
  287. wbs_id AS "wbsId",
  288. project_id AS "projectId",
  289. contract_id AS "contractId",
  290. contract_type AS "contractType",
  291. (select project_name from m_project_info where id = #{projectId}) AS "projectName",
  292. (select contract_name from m_contract_info ci where ci.id = t.contract_id) AS "contractName"
  293. FROM m_wbs_tree_contract t
  294. WHERE project_id = #{projectId}
  295. /*AND contract_type = 1*/
  296. AND status = 1
  297. AND parent_id = 0
  298. AND is_deleted = 0
  299. </select>
  300. <select id="selectCondition" resultType="org.springblade.manager.entity.WbsTreeContract">
  301. SELECT *
  302. FROM m_wbs_tree_contract
  303. WHERE is_deleted = 1
  304. AND parent_id = 0
  305. AND contract_id = #{getContractId}
  306. AND id = #{id}
  307. AND contract_id_relation = #{getContractIdRelation}
  308. AND contract_type = #{contractType}
  309. </select>
  310. <select id="lazyTreeTwo" resultMap="treeNodeResultMap">
  311. SELECT
  312. dept.type AS "type",
  313. dept.wbs_type AS "wbsType",
  314. dept.contract_type AS "contractType",
  315. dept.contract_id AS "contractId",
  316. dept.p_key_id AS "id",
  317. dept.node_type AS "nodeType",
  318. dept.id AS "primaryKeyId",
  319. dept.id AS "value",
  320. dept.id AS "key" ,
  321. dept.parent_id,
  322. IFNULL(dept.full_name,dept.node_name) AS "fullName",
  323. dept.tenant_id AS "tenantId",
  324. dept.contract_id_relation AS "contractIdRelation",
  325. (SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract WHERE parent_id = dept.id and
  326. is_deleted = 0 ) AS "has_children"
  327. FROM
  328. m_wbs_tree_contract dept
  329. WHERE
  330. dept.is_deleted = 0
  331. <if test="contractIdRelation != null and contractIdRelation != ''">
  332. AND contract_id_relation = #{contractIdRelation}
  333. </if>
  334. /* major_data_type = 5是日志类型,日志类型不需要直接在划分树上体现 */
  335. AND (major_data_type != 5 or major_data_type is null)
  336. AND dept.contract_id = #{contractId}
  337. AND dept.contract_type = #{contractType}
  338. AND parent_id = #{parentId}
  339. AND dept.type = 1
  340. AND status = 1
  341. ORDER BY dept.sort
  342. </select>
  343. <select id="lazyTreeThree" resultType="org.springblade.manager.vo.WbsTreeContractTreeVO3">
  344. SELECT
  345. c.id AS "primaryKeyId",
  346. c.p_key_id AS "id",
  347. c.type AS "type",
  348. c.wbs_type AS "wbsType",
  349. c.contract_type AS "contractType",
  350. c.contract_id AS "contractId",
  351. c.node_type AS "nodeType",
  352. c.parent_id,
  353. c.tenant_id AS "tenantId",
  354. c.id AS "originallyId",
  355. c.p_key_id AS "originallyPkeyId",
  356. case
  357. when c.full_name is null then c.node_name
  358. when c.full_name = '' then c.node_name
  359. else c.full_name end AS "title",
  360. c.contract_id AS "contractIdRelation",
  361. (SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
  362. FROM m_wbs_tree_contract
  363. WHERE parent_id = c.id
  364. AND is_deleted = 0) AS "has_children"
  365. FROM m_wbs_tree_contract c
  366. WHERE (major_data_type != 5 or major_data_type is null)
  367. AND c.contract_id in
  368. <foreach item="contractIdRelation" collection="contractIdRelation" open="(" close=")" separator=",">
  369. #{contractIdRelation}
  370. </foreach>
  371. AND parent_id = #{parentId}
  372. AND c.contract_type = 1
  373. AND c.type = 1
  374. AND c.status = 1
  375. AND c.is_deleted = 0
  376. ORDER BY c.sort
  377. </select>
  378. <select id="appSearchConcealedNodes" resultType="org.springblade.manager.vo.WbsContractNodeVo">
  379. SELECT t.*,
  380. (SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
  381. FROM m_wbs_tree_contract
  382. WHERE parent_id = t.id
  383. and is_deleted = 0) AS "has_children"
  384. FROM m_wbs_tree_contract t,
  385. (SELECT getParentList(#{contractId}) AS keyxs) b
  386. WHERE FIND_IN_SET(t.id, b.keyxs)
  387. and contract_id = #{contractId}
  388. and is_deleted = 0
  389. </select>
  390. <select id="searchParentAllNode" resultType="org.springblade.manager.entity.WbsTreeContract">
  391. SELECT DISTINCT T2.id,
  392. if(length(trim(T2.full_name)) > 0, T2.full_name, T2.node_name) as node_name,
  393. T2.parent_id,
  394. T2.p_key_id
  395. FROM (
  396. SELECT @r AS _id,(SELECT @r := parent_id FROM m_wbs_tree_contract WHERE id = _id and contract_id = h.contract_id
  397. ) AS pid, @l := @l + 1 AS lvl
  398. FROM (SELECT @r := #{primaryKeyId}, @l := 0) vars, m_wbs_tree_contract h
  399. WHERE @r != 0 and contract_id=#{contractId}
  400. union ALL
  401. (
  402. SELECT id, parent_id, 0
  403. FROM m_wbs_tree_contract
  404. where parent_id=#{primaryKeyId}
  405. and contract_id=#{contractId} LIMIT 1)
  406. ) T1
  407. JOIN m_wbs_tree_contract T2 ON T1._id = T2.id
  408. where T2.contract_id=#{contractId} and T2.type&lt;&gt;2
  409. </select>
  410. <select id="updateAllNodeTabById" resultType="org.springblade.manager.entity.WbsTreeContract">
  411. update m_wbs_tree_contract
  412. set excel_id= #{aPrivate.excelId},
  413. node_name = #{aPrivate.nodeName},
  414. full_name = #{aPrivate.fullName},
  415. init_table_name = #{aPrivate.initTableName},
  416. is_link_table = 2,
  417. html_url = #{aPrivate.htmlUrl}
  418. where type = 2
  419. and project_id = #{aPrivate.projectId}
  420. and id = #{aPrivate.id};
  421. </select>
  422. <select id="selectWbsTableOwnerRoleList" resultType="org.springblade.manager.entity.WbsTableOwnerRole">
  423. select id, role_id as "roleId", table_owner_number as "tableOwnerNumber"
  424. from m_wbs_table_owner_role
  425. where role_id = #{roleId}
  426. </select>
  427. <!--APP返回appResultMap(内部嵌套子查询(不清楚为什么要这样嵌套查询,导致一直递归))-->
  428. <select id="selectWbsTreeContractList" resultMap="appResultMap">
  429. SELECT * FROM
  430. m_wbs_tree_contract
  431. WHERE project_id = #{projectId}
  432. AND wbs_id = #{wbsId}
  433. AND contract_id = #{contractId}
  434. AND parent_id = #{parentId}
  435. AND type = 2
  436. AND status = 1
  437. AND is_deleted = 0
  438. <if test="contractIdRelation != null and contractIdRelation!= ''">
  439. AND contract_id = #{contractIdRelation}
  440. </if>
  441. <if test="roleTableOwnerSets != null and roleTableOwnerSets!= ''">
  442. AND table_owner in
  443. <foreach item="roleTableOwnerSets" collection="roleTableOwnerSets" open="(" close=")" separator=",">
  444. #{roleTableOwnerSets}
  445. </foreach>
  446. </if>
  447. ORDER BY sort,full_name,create_time
  448. </select>
  449. <!--客户端返回WbsTreeContract-->
  450. <select id="selectWbsTreeContractListClient" resultType="org.springblade.manager.vo.AppWbsTreeContractVO">
  451. SELECT * FROM
  452. m_wbs_tree_contract
  453. WHERE project_id = #{projectId}
  454. AND wbs_id = #{wbsId}
  455. AND contract_id = #{contractId}
  456. AND parent_id = #{parentId}
  457. AND type = 2
  458. AND status = 1
  459. AND is_deleted = 0
  460. <if test="contractIdRelation != null and contractIdRelation!= ''">
  461. AND contract_id = #{contractIdRelation}
  462. </if>
  463. <if test="roleTableOwnerSets != null and roleTableOwnerSets!= ''">
  464. AND table_owner in
  465. <foreach item="roleTableOwnerSets" collection="roleTableOwnerSets" open="(" close=")" separator=",">
  466. #{roleTableOwnerSets}
  467. </foreach>
  468. </if>
  469. ORDER BY sort,full_name,create_time
  470. </select>
  471. <select id="selectRoleInfo" resultType="org.springblade.manager.entity.SaveUserInfoByProject">
  472. SELECT role_id
  473. FROM m_project_assignment_user
  474. WHERE user_id = #{userId}
  475. AND contract_id = #{contractId}
  476. AND project_id = #{projectId}
  477. AND status = 1
  478. AND is_deleted = 0
  479. AND role_id is not null
  480. </select>
  481. <select id="selectContractRelationInfo" resultType="org.springblade.manager.entity.ContractRelationJlyz">
  482. SELECT *
  483. FROM m_contract_relation_jlyz
  484. WHERE contract_id_jlyz = #{id}
  485. </select>
  486. <select id="selectContractInfo" resultType="org.springblade.manager.entity.ContractInfo">
  487. SELECT contract_name
  488. FROM m_contract_info
  489. WHERE id = #{contractId}
  490. </select>
  491. <select id="selectContractRelationInfoByidSG" resultType="org.springblade.manager.entity.ContractRelationJlyz">
  492. SELECT *
  493. FROM m_contract_relation_jlyz
  494. WHERE contract_id_sg = #{contractId}
  495. </select>
  496. <select id="selectContractRelationInfoByidSG2" resultType="org.springblade.manager.entity.ContractRelationJlyz">
  497. SELECT *
  498. FROM m_contract_relation_jlyz
  499. WHERE contract_id_sg = #{contractId}
  500. </select>
  501. <select id="queryContractSubmitWbsTreeByContractId" resultMap="ResultMap">
  502. select p_key_id, contract_id, major_data_type
  503. from m_wbs_tree_contract
  504. where is_deleted = 0
  505. and major_data_type in (1, 2, 3, 4)
  506. and contract_id = #{contractId}
  507. </select>
  508. <select id="selectInformationQueryInfo" resultType="org.springblade.business.entity.InformationQuery">
  509. SELECT wbs_id FROM u_information_query
  510. WHERE wbs_id IN
  511. <foreach item="ids" collection="ids" open="(" close=")" separator=",">
  512. #{ids}
  513. </foreach>
  514. AND is_deleted = 0
  515. </select>
  516. <select id="selectTableListInfo" resultType="org.springblade.manager.entity.WbsTreeContract">
  517. SELECT p_key_id AS "pKeyId"
  518. ,id,node_name AS "nodeName"
  519. ,type,parent_id AS "parentId"
  520. ,is_tab_pdf AS "isTabPdf"
  521. FROM m_wbs_tree_contract
  522. WHERE ( id IN
  523. <foreach item="ids" collection="ids" open="(" close=")" separator=",">
  524. #{ids}
  525. </foreach>
  526. OR (parent_id IN
  527. <foreach item="ids" collection="ids" open="(" close=")" separator=",">
  528. #{ids}
  529. </foreach>
  530. ) )
  531. AND wbs_id = #{wbsId}
  532. AND project_id = #{projectId}
  533. AND contract_id = #{contractId}
  534. /*AND contract_type = 1*/
  535. </select>
  536. <update id="regainRemoveTreeByPrimaryKeyIds">
  537. update m_wbs_tree_contract set is_deleted = 0
  538. <where>
  539. p_key_id in
  540. <foreach collection="primaryKeyIds" item="primaryKeyId" open="(" separator="," close=")">
  541. #{primaryKeyId}
  542. </foreach>
  543. </where>
  544. </update>
  545. <update id="updateBatchByIds">
  546. UPDATE m_wbs_tree_contract
  547. SET node_name = #{wbsTree.nodeName},
  548. full_name = #{wbsTree.nodeName},
  549. node_type = #{wbsTree.nodeType},
  550. major_data_type = #{wbsTree.majorDataType},
  551. unique_code = #{wbsTree.uniqueCode},
  552. partition_code = #{wbsTree.partitionCode},
  553. table_type = #{wbsTree.tableType},
  554. table_owner = #{wbsTree.tableOwner}
  555. <if test="wbsTree.sort != null and wbsTree.sort != ''">
  556. , sort = #{wbsTree.sort}
  557. </if>
  558. WHERE id = #{wbsTree.id}
  559. AND contract_id = #{id}
  560. AND status = 1
  561. AND is_deleted = 0
  562. </update>
  563. <update id="updateBatchByIds2">
  564. UPDATE m_wbs_tree_contract
  565. SET node_name = #{wbsTreePrivate.nodeName},
  566. full_name = #{wbsTreePrivate.nodeName},
  567. node_type = #{wbsTreePrivate.nodeType},
  568. major_data_type = #{wbsTreePrivate.majorDataType},
  569. unique_code = #{wbsTreePrivate.uniqueCode},
  570. partition_code = #{wbsTreePrivate.partitionCode},
  571. table_type = #{wbsTreePrivate.tableType},
  572. table_owner = #{wbsTreePrivate.tableOwner}
  573. <if test="wbsTreePrivate.sort != null and wbsTreePrivate.sort != ''">
  574. , sort = #{wbsTreePrivate.sort}
  575. </if>
  576. WHERE id = #{wbsTreePrivate.id}
  577. AND contract_id = #{id}
  578. AND status = 1
  579. AND is_deleted = 0
  580. </update>
  581. <update id="updateContractTablesInfo">
  582. UPDATE m_wbs_tree_contract
  583. SET
  584. node_name =
  585. CASE
  586. WHEN node_name LIKE '%_PL_%' THEN CONCAT(#{wbsTreePrivate.nodeName}, SUBSTRING(node_name FROM INSTR(node_name,
  587. '_PL_')))
  588. WHEN node_name LIKE '%__%' THEN CONCAT(#{wbsTreePrivate.nodeName}, SUBSTRING(node_name FROM INSTR(node_name,
  589. '__')))
  590. ELSE #{wbsTreePrivate.nodeName}
  591. END,
  592. full_name =
  593. CASE
  594. WHEN full_name LIKE '%_PL_%' THEN CONCAT(#{wbsTreePrivate.nodeName}, SUBSTRING(full_name FROM INSTR(full_name,
  595. '_PL_')))
  596. WHEN full_name LIKE '%__%' THEN CONCAT(#{wbsTreePrivate.nodeName}, SUBSTRING(full_name FROM INSTR(full_name,
  597. '__')))
  598. ELSE #{wbsTreePrivate.nodeName}
  599. END,
  600. table_type = #{wbsTreePrivate.tableType},
  601. table_owner = #{wbsTreePrivate.tableOwner}
  602. <if test="wbsTreePrivate.sort != null and wbsTreePrivate.sort != ''">
  603. ,sort = #{wbsTreePrivate.sort}
  604. </if>
  605. WHERE
  606. p_key_id in
  607. <foreach collection="pKeyIdsContracts" item="pKeyIds" open="(" close=")" separator=",">
  608. #{pKeyIds}
  609. </foreach>
  610. </update>
  611. <update id="updateBatchWbsContract" parameterType="java.util.List">
  612. <foreach collection="listContract" item="item" index="index" separator=";">
  613. UPDATE m_wbs_tree_contract
  614. <set>
  615. node_name =
  616. CASE
  617. WHEN node_name LIKE '%_PL_%'
  618. THEN CONCAT(
  619. <if test="item.nodeName != null and item.nodeName != ''">
  620. #{item.nodeName}
  621. </if>,
  622. SUBSTRING(node_name FROM INSTR(node_name, '_PL_'))
  623. )
  624. WHEN node_name LIKE '%__%'
  625. THEN CONCAT(
  626. <if test="item.nodeName != null and item.nodeName != ''">
  627. #{item.nodeName}
  628. </if>,
  629. SUBSTRING(node_name FROM INSTR(node_name, '__'))
  630. )
  631. ELSE
  632. <if test="item.nodeName != null and item.nodeName != ''">
  633. #{item.nodeName}
  634. </if>
  635. END,
  636. full_name =
  637. CASE
  638. WHEN full_name LIKE '%_PL_%'
  639. THEN CONCAT(
  640. <if test="item.nodeName != null and item.nodeName != ''">
  641. #{item.nodeName}
  642. </if>,
  643. SUBSTRING(full_name FROM INSTR(full_name, '_PL_'))
  644. )
  645. WHEN full_name LIKE '%__%'
  646. THEN CONCAT(
  647. <if test="item.nodeName != null and item.nodeName != ''">
  648. #{item.nodeName}
  649. </if>,
  650. SUBSTRING(full_name FROM INSTR(full_name, '__'))
  651. )
  652. ELSE
  653. <if test="item.nodeName != null and item.nodeName != ''">
  654. #{item.nodeName}
  655. </if>
  656. END,
  657. <if test="item.nodeType != null and item.nodeType != ''">
  658. node_type = #{item.nodeType},
  659. </if>
  660. <if test="item.majorDataType != null and item.majorDataType != ''">
  661. major_data_type = #{item.majorDataType},
  662. </if>
  663. <if test="item.tableType != null and item.tableType != ''">
  664. table_type = #{item.tableType},
  665. </if>
  666. <if test="item.tableOwner != null and item.tableOwner != ''">
  667. table_owner = #{item.tableOwner},
  668. </if>
  669. <if test="item.htmlUrl != null and item.htmlUrl != ''">
  670. html_url = #{item.htmlUrl},
  671. </if>
  672. <if test="item.excelId != null and item.excelId != ''">
  673. excel_id = #{item.excelId},
  674. </if>
  675. <if test="item.sort != null and item.sort != ''">
  676. sort = #{item.sort}
  677. </if>
  678. </set>
  679. WHERE id = #{item.id}
  680. AND project_id = #{item.projectId}
  681. AND contract_id = #{item.contractId}
  682. AND status = 1
  683. AND is_deleted = 0
  684. </foreach>
  685. </update>
  686. <update id="updateDeletedByIds">
  687. UPDATE m_wbs_tree_contract
  688. SET is_deleted = 1
  689. WHERE type = 2
  690. AND p_key_id in
  691. <foreach item="ids" collection="ids" open="(" close=")" separator=",">
  692. #{ids}
  693. </foreach>
  694. </update>
  695. <update id="syncCurrentFormToAllContract">
  696. UPDATE m_wbs_tree_contract
  697. SET html_url = #{wbsTreePrivate.htmlUrl},
  698. init_table_name = #{wbsTreePrivate.initTableName},
  699. node_name = #{wbsTreePrivate.nodeName},
  700. full_name = #{wbsTreePrivate.fullName}
  701. WHERE project_id = #{wbsTreePrivate.projectId}
  702. and excel_id = #{wbsTreePrivate.excelId}
  703. </update>
  704. <update id="updateIsPId">
  705. <foreach item="value" collection="map" index="key" separator=";">
  706. UPDATE m_wbs_tree_contract
  707. <set>
  708. is_type_private_pid = #{value}
  709. </set>
  710. where p_key_id = #{key}
  711. </foreach>
  712. </update>
  713. <update id="tableSort">
  714. <foreach item="value" collection="map" index="key" separator=";">
  715. UPDATE m_wbs_tree_contract
  716. <set>
  717. sort = #{value}
  718. </set>
  719. where p_key_id = #{key}
  720. </foreach>
  721. </update>
  722. <update id="batchUpdateTable">
  723. <foreach item="item" collection="list" separator=";">
  724. ${item}
  725. </foreach>
  726. </update>
  727. <update id="updateContractPid">
  728. UPDATE m_wbs_tree_contract a
  729. LEFT JOIN (
  730. SELECT
  731. tree_p_id,
  732. p_key_id
  733. FROM
  734. m_wbs_tree_contract
  735. WHERE
  736. project_id = #{projectId} and contract_id = #{contractId} ) b ON a.parent_id = b.tree_p_id
  737. SET a.p_id = IFNULL( b.p_key_id, 0 )
  738. WHERE
  739. a.project_id = #{projectId} and contract_id = #{contractId}
  740. </update>
  741. <update id="updateBatchAncestorsByPKeyId">
  742. <foreach collection="allNodes" item="item" separator=";">
  743. UPDATE m_wbs_tree_contract
  744. <set>`ancestors_p_id` = #{item.ancestorsPId}</set>
  745. where p_key_id = #{item.pKeyId}
  746. </foreach>
  747. </update>
  748. <select id="selectQueryValueLikeNodeName" resultMap="ResultMap">
  749. select *
  750. from m_wbs_tree_contract
  751. where is_deleted = 0
  752. and contract_id = #{contractId}
  753. and (node_name like concat('%', #{queryValue}, '%') or full_name like concat('%', #{queryValue}, '%'))
  754. and `type` = '1'
  755. </select>
  756. <select id="selectQueryCurrentNodeByAncestors" resultMap="ResultMap">
  757. select * from m_wbs_tree_contract where is_deleted = 0 and contract_id = #{contractId} and `type` = '1' and (
  758. parent_id = '0' or parent_id = (select id from m_wbs_tree_contract where parent_id = '0' and contract_id =
  759. #{contractId}) or (
  760. <foreach collection="ids" item="id" index="index" separator="or">
  761. ancestors like concat('%',#{id},'%')
  762. </foreach>
  763. )
  764. ) group by id order by parent_id,`sort`
  765. </select>
  766. <select id="selectContractList" resultType="org.springblade.manager.entity.WbsTreeContract">
  767. SELECT contract_id FROM m_wbs_tree_contract WHERE id in
  768. <foreach item="ids" collection="ids" open="(" close=")" separator=",">
  769. #{ids}
  770. </foreach>
  771. AND project_id = #{projectId}
  772. AND wbs_id = #{wbsId}
  773. AND is_deleted = 0
  774. </select>
  775. <select id="getuserInfoByaccount" resultType="org.springblade.manager.entity.AppUser">
  776. SELECT b.*
  777. from u_operation_log a,
  778. blade_user b
  779. where b.tenant_id = '000000' /*只查询后管系统的用户*/
  780. and a.contract_id = 1
  781. and a.operation_account = b.account
  782. and a.operation_type = 1
  783. and a.business_id like concat('%', #{sonId}, '%')
  784. group by b.id
  785. </select>
  786. <select id="getAllTableFileSize" resultType="java.lang.Long">
  787. select sum(DATA_LENGTH)
  788. from information_schema.tables
  789. where table_schema = 'bladex'
  790. AND table_name in (SELECT mwtc.init_table_name
  791. FROM m_wbs_tree_contract mwtc
  792. WHERE mwtc.project_id = #{projectId}
  793. and mwtc.init_table_name is NOT NULL
  794. and mwtc.init_table_name
  795. != ''
  796. GROUP by mwtc.init_table_name );
  797. </select>
  798. <select id="getProjectAllFillNode" resultType="java.lang.Integer">
  799. select COUNT(1) from m_wbs_tree_contract
  800. WHERE project_id = #{projectId} and node_type = 6 and is_deleted = 0
  801. </select>
  802. <select id="getAllAppTotal" resultType="java.lang.Integer">
  803. select COUNT(1) from u_information_query
  804. WHERE project_id = #{projectId} and status = 2 and classify = 1 and is_deleted = 0
  805. </select>
  806. <select id="getAllAppTotal2" resultType="java.lang.Integer">
  807. select COUNT(1) from u_construction_ledger
  808. WHERE project_id = #{projectId} and is_deleted = 0 and site_end_time &lt; NOW()
  809. </select>
  810. <select id="getAllNodeByProjectId" resultType="org.springblade.manager.entity.WbsTreeContract">
  811. select p_key_id,id,wbs_id,project_id from m_wbs_tree_contract
  812. WHERE project_id = #{projectId} and type = 1 and is_deleted = 0 and is_type_private_pid is null
  813. </select>
  814. <select id="apiTreeNode" resultMap="apiTreeNodeResultMap">
  815. select distinct p_key_id ,type, id , parent_id , node_name
  816. from m_wbs_tree_contract
  817. where
  818. is_deleted = 0
  819. and status = 1
  820. and wbs_type = 1
  821. and type=1
  822. and contract_id = #{contractId}
  823. <if test="nodeName != null and nodeName != ''">
  824. AND node_name like CONCAT(CONCAT('%', #{nodeName}), '%')
  825. </if>
  826. ORDER BY type,sort
  827. </select>
  828. <select id="apiTreeNodeHzrc" resultMap="apiTreeNodeHzrcResultMap">
  829. select distinct a.p_key_id , a.id , a.parent_id , a.node_name , b.e_visa_pdf_url as fileUrl,
  830. (SELECT count(1) from u_task e ,u_task_parallel f,m_project_assignment_user g where e.process_instance_id = f.process_instance_id and f.task_user = g.user_id and g.role_id in(
  831. SELECT id from blade_role where role_name like '监理员%' and is_deleted=0) and g.contract_id=1792792387901288450 and e.form_data_id=b.id )
  832. AS isMea,
  833. a.partition_Code as partitionCode,
  834. b.taskStatus
  835. from m_wbs_tree_contract a LEFT JOIN (SELECT c.e_visa_pdf_url ,d.`status` as taskStatus,c.wbs_id ,,d.id from u_information_query c,u_task d where d.form_data_id=c.id and c.contract_id = #{contractId} and c.classify = #{classType}) b on a.p_key_id = b.wbs_id
  836. where
  837. a.is_deleted = 0
  838. and a.status = 1
  839. and a.wbs_type = 1
  840. and a.type=1
  841. and a.contract_id = #{contractId}
  842. ORDER BY a.type,a.sort
  843. </select>
  844. <select id="getContractAllNode" resultType="org.springblade.manager.vo.ArchiveSyncWbsVO">
  845. select p_key_id,id,parent_id,node_name,full_name,sort
  846. from m_wbs_tree_contract where contract_id = #{contractId} and type = 1 and is_deleted = 0
  847. ORDER BY sort,create_time
  848. </select>
  849. <select id="projectAllTable" resultType="org.springblade.manager.entity.WbsTreeContract">
  850. select p_key_id,init_table_name
  851. from m_wbs_tree_contract where project_id = #{projectId} and type = 2 and is_deleted = 0
  852. </select>
  853. <select id="selectContractJLForm" resultType="org.springblade.manager.vo.WbsTreeContractTreeVOS">
  854. select id from m_wbs_tree_contract where p_key_id in (
  855. <foreach collection="list" item="pkeyId" separator=",">
  856. #{pkeyId}
  857. </foreach>
  858. ) and pdf_url is not null and pdf_url != '' and (table_owner = 4 or table_owner = 5 or table_owner = 6) and is_deleted = 0
  859. </select>
  860. </mapper>