123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="org.springblade.manager.mapper.WbsTreeMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="wbsTreeResultMap" type="org.springblade.manager.entity.WbsTree">
- <result column="id" property="id"/>
- <result column="w_id" property="wbsId"/>
- <result column="is_deleted" property="isDeleted"/>
- <result column="status" property="status"/>
- <result column="create_time" property="createTime"/>
- <result column="create_user" property="createUser"/>
- <result column="create_dept" property="createDept"/>
- <result column="update_user" property="updateUser"/>
- <result column="update_time" property="updateTime"/>
- <result column="type" property="type"/>
- <result column="table_type" property="tableType"/>
- <result column="tenant_id" property="tenantId"/>
- <result column="parent_id" property="parentId"/>
- <result column="ancestors" property="ancestors"/>
- <result column="node_type" property="nodeType"/>
- <result column="node_name" property="nodeName"/>
- <result column="full_name" property="fullName"/>
- <result column="sort" property="sort"/>
- <result column="remark" property="remark"/>
- <result column="unique_code" property="uniqueCode"/>
- <result column="partition_code" property="partitionCode"/>
- <result column="is_concrete" property="isConcrete"/>
- <result column="is_expernode" property="isExpernode"/>
- <result column="table_owner" property="tableOwner"/>
- <result column="major_data_type" property="majorDataType"/>
- <result column="init_table_name" property="initTableName"/>
- <result column="is_link_table" property="isLinkTable"/>
- <result column="is_exist_form" property="isExistForm"/>
- <result column="import_matching_info" property="importMatchingInfo"/>
- <result column="init_table_id" property="initTableId"/>
- <result column="et_tree_id" property="erTreeId"/>
- </resultMap>
- <resultMap id="treeNodeResultMap" type="org.springblade.manager.vo.TreeNodeVO">
- <id column="id" property="id"/>
- <result column="parent_id" property="parentId"/>
- <result column="title" property="title"/>
- <result column="value" property="value"/>
- <result column="key" property="key"/>
- <result column="has_children" property="hasChildren"/>
- <result column="type" property="type"/>
- <result column="nodeType" property="nodeType"/>
- <result column="wbsType" property="wbsType"/>
- <result column="isExistForm" property="isExistForm"/>
- <result column="ancestors" property="ancestors"/>
- </resultMap>
- <resultMap id="treeNodeResultMap2" type="org.springblade.manager.vo.WbsTreeVO2">
- <id column="id" property="id"/>
- <result column="parentId" property="parentId"/>
- <result column="title" property="title"/>
- <result column="value" property="value"/>
- <result column="key" property="key"/>
- <result column="has_children" property="hasChildren"/>
- <result column="major_data_type" property="majorDataType"/>
- <result column="type" property="type"/>
- <result column="nodeType" property="nodeType"/>
- <result column="wbsType" property="wbsType"/>
- <result column="isExistForm" property="isExistForm"/>
- <result column="ancestors" property="ancestors"/>
- <result column="tenantId" property="tenantId"/>
- </resultMap>
- <resultMap id="selectByNodeTableMap" type="org.springblade.manager.vo.WbsNodeTableVO">
- <id column="id" property="id"/>
- <result column="tableName" property="tableName"/>
- <result column="tableType" property="tableType"/>
- <result column="isCreateTable" property="isCreateTable"/>
- <result column="elementTotal" property="elementTotal"/>
- <result column="tableOwner" property="tableOwner"/>
- <result column="initTableName" property="initTableName"/>
- <result column="sort" property="sort"/>
- <result column="pKeyId" property="pKeyId"/>
- <result column="fillRate" property="fillRate"/>
- <result column="initTableId" property="initTableId"/>
- </resultMap>
- <resultMap id="wbsFormElementMap" type="org.springblade.manager.vo.WbsFormElementVO">
- <id column="id" property="id"/>
- <result column="f_id" property="fId"/>
- <result column="e_key" property="eKey"/>
- <result column="e_name" property="eName"/>
- <result column="e_type" property="eType"/>
- <result column="e_length" property="eLength"/>
- <result column="e_allow_deviation" property="eAllowDeviation"/>
- <result column="e_inspection_method" property="eInspectionMethod"/>
- <result column="tableElementKey" property="tableElementKey"/>
- <result column="initTableName" property="initTableName"/>
- <result column="nodeId" property="nodeId"/>
- <result column="globalFormula" property="globalFormula"/>
- <result column="isBussTime" property="isBussTime"/>
- <result column="dynamic_dict" property="dynamicDict"/>
- </resultMap>
- <insert id="addFormElement" parameterType="org.springblade.manager.dto.WbsFormElementDTO">
- insert into m_wbs_form_element(f_id,e_name,e_type,e_length)
- values (#{f_id},#{e_name},#{e_type},#{e_length})
- </insert>
- <insert id="insertForm">
- insert into m_wbs_tree
- </insert>
- <insert id="insertWbsTreePrivate">
- INSERT INTO m_wbs_tree_private(
- id,wbs_id,project_id,tenant_id,parent_id,ancestors,node_type,node_name,full_name,sort,remark,`type`,
- table_type,create_time,create_user,create_dept,update_user,update_time,`STATUS`,is_deleted,
- unique_code,partition_code,is_expernode,is_concrete,table_owner,major_data_type,init_table_name,is_link_table)
- VALUES(
- #{wbsTree.id},#{wbsTree.wbsId},#{projectId},#{wbsTree.tenantId},#{wbsTree.parentId},#{wbsTree.ancestors},
- #{wbsTree.nodeType},#{wbsTree.nodeName},#{wbsTree.fullName},#{wbsTree.sort},#{wbsTree.remark},#{wbsTree.type},
- #{wbsTree.tableType},#{wbsTree.createTime},#{wbsTree.createUser},#{wbsTree.createDept},#{wbsTree.updateUser},#{wbsTree.updateTime},
- #{wbsTree.status},#{wbsTree.isDeleted},#{wbsTree.uniqueCode},#{wbsTree.partitionCode},#{wbsTree.isExpernode},#{wbsTree.isConcrete},
- #{wbsTree.tableOwner},#{wbsTree.majorDataType},#{wbsTree.initTableName},#{wbsTree.isLinkTable})
- </insert>
- <insert id="insertWbsTreeContract">
- INSERT INTO m_wbs_tree_contract(
- id,wbs_id,project_id,contract_id,tenant_id,parent_id,ancestors,node_type,node_name,full_name,sort,remark,`type`,
- table_type,create_time,create_user,create_dept,update_user,update_time,`STATUS`,is_deleted,
- unique_code,partition_code,is_expernode,is_concrete,table_owner,major_data_type,init_table_name,is_link_table)
- VALUES(
- #{wbsTree.id},#{wbsTree.wbsId},#{projectId},#{contractId},#{wbsTree.tenantId},#{wbsTree.parentId},#{wbsTree.ancestors},
- #{wbsTree.nodeType},#{wbsTree.nodeName},#{wbsTree.fullName},#{wbsTree.sort},#{wbsTree.remark},#{wbsTree.type},
- #{wbsTree.tableType},#{wbsTree.createTime},#{wbsTree.createUser},#{wbsTree.createDept},#{wbsTree.updateUser},#{wbsTree.updateTime},
- #{wbsTree.status},#{wbsTree.isDeleted},#{wbsTree.uniqueCode},#{wbsTree.partitionCode},#{wbsTree.isExpernode},#{wbsTree.isConcrete},
- #{wbsTree.tableOwner},#{wbsTree.majorDataType},#{wbsTree.initTableName},#{wbsTree.isLinkTable})
- </insert>
- <update id="removeTableById">
- UPDATE m_wbs_tree AS wt SET is_deleted = 1 WHERE wt.type = 2 AND wt.id = #{id}
- </update>
- <update id="updateById2">
- UPDATE m_wbs_tree AS wt SET wt.ancestors = #{ancestors} WHERE is_deleted = 0 AND wt.id = #{id}
- </update>
- <update id="updateById3">
- UPDATE m_wbs_tree AS wt SET wt.parent_id = #{parentId} WHERE is_deleted = 0 AND wt.id = #{id}
- </update>
- <update id="createWbsTreeTable">
- create table ${tableName} as select * from m_wbs_tree WHERE 1=2
- </update>
- <update id="updateByCondition">
- UPDATE m_wbs_tree
- <trim prefix="set" suffixOverrides=",">
- <if test="wbsName != null and wbsName != '' ">
- `node_name` = #{wbsName},
- </if>
- <if test="status != null and status != '' ">
- `status` = #{status}
- </if>
- </trim>
- WHERE wbs_id = #{id}
- AND parent_id = 0
- AND is_deleted = 0
- </update>
- <update id="updateSortById">
- UPDATE m_wbs_tree
- SET sort = #{sort}
- WHERE id = #{id}
- AND type = 1
- AND status = 1
- AND is_deleted = 0
- </update>
- <delete id="deleteBatchProjectNodeId">
- delete from m_wbs_tree where project_node_id = #{projectNodeId} and id <> #{projectNodeId}
- </delete>
- <delete id="deleteBatch" parameterType="java.util.List">
- DELETE FROM m_wbs_tree_private
- WHERE id IN
- <foreach item="ids" collection="ids" open="(" close=")" separator=",">
- #{ids}
- </foreach>
- AND wbs_id = #{wbsId}
- AND project_id = #{projectId}
- </delete>
- <delete id="deleteBatch2" parameterType="java.util.List">
- DELETE FROM m_wbs_tree_private
- WHERE parent_id IN
- <foreach item="ids" collection="ids" open="(" close=")" separator=",">
- #{ids}
- </foreach>
- AND wbs_id = #{wbsId}
- AND project_id = #{projectId}
- </delete>
- <delete id="deleteLogicById">
- DELETE FROM m_wbs_tree WHERE id = #{id} OR project_node_id = #{id} OR ancestors like concat('%',#{id},'%')
- </delete>
- <delete id="cancelRelation">
- UPDATE m_wbs_tree SET is_link_table = 1 WHERE id = #{id}
- </delete>
- <delete id="deleteBatch3">
- delete from m_wbs_tree_private where project_id = #{project} and parent_id = -10 and `type` =10
- </delete>
- <update id="deleteLogicByWbsId">
- update m_wbs_tree set is_deleted = 1 where wbs_id = #{ids} and status = 1
- </update>
- <update id="updateIsExistFormById">
- UPDATE m_wbs_tree SET is_exist_form = 1 WHERE id = #{id} AND status = 1 AND is_deleted = 0
- </update>
- <update id="createTable">
- create table ${newTableName}
- (
- `id` bigint(20) NOT NULL,
- `p_key_id` bigint(20) COMMENT '合同段wbs表的p_key_id',
- `group_id` bigint(20) COMMENT '分组id',
- PRIMARY KEY (`id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
- </update>
- <update id="alterTableFiled">
- ALTER TABLE ${initTableName} ADD COLUMN ${eKey} ${eType}(${eLength})
- </update>
- <update id="updateByParentId">
- UPDATE m_wbs_tree
- SET is_link_table = 1
- WHERE parent_id = #{parentId}
- AND id != #{id}
- AND type = 2
- AND status = 1
- AND is_deleted = 0
- </update>
- <select id="selectWbsTreePage" resultMap="wbsTreeResultMap">
- select *
- from m_wbs_tree where is_deleted = 0
- </select>
- <select id="tree" resultMap="treeNodeResultMap">
- select id, parent_id, node_name as title,type as "type", id as "value", id as "key", node_type as
- "nodeType",is_exist_form AS "isExistForm",
- (select wbs_type from m_wbs_info where id = #{wbsId}) as "wbsType"
- from m_wbs_tree where
- is_deleted = 0
- and status = 1
- <if test="wbsId!=null and wbsId!=''">
- and wbs_id = #{wbsId}
- </if>
- <if test="tenantId!=null and tenantId!=''">
- and tenant_id = #{tenantId}
- </if>
- <if test="type!=null and type!=''">
- and `type` = #{type}
- </if>
- ORDER BY sort
- </select>
- <select id="tree2" resultMap="treeNodeResultMap2">
- SELECT
- d.id,
- d.tenant_id AS "tenantId",
- d.parent_id AS "parentId",
- d.node_name AS title,
- d.type AS "type",
- d.id AS "value",
- d.id AS "key",
- d.major_data_type,
- d.node_type AS "nodeType",
- d.is_exist_form AS "isExistForm",
- a.wbs_type AS "wbsType"
- FROM m_wbs_tree d INNER JOIN m_wbs_info a ON a.id = #{wbsId}
- WHERE
- d.is_deleted = 0
- AND d.status = 1
- <if test="wbsId!=null and wbsId!=''">
- AND d.wbs_id = #{wbsId}
- </if>
- <if test="tenantId!=null and tenantId!=''">
- AND d.tenant_id = #{tenantId}
- </if>
- <if test="type!=null and type!=''">
- AND d.`type` = #{type}
- </if>
- ORDER BY d.sort
- </select>
- <select id="lazyTree2" resultMap="treeNodeResultMap2">
- SELECT
- t.id,
- t.type AS "type",
- t.node_type AS "nodeType",
- t.is_exist_form AS "isExistForm",
- t.parent_id,
- t.node_name AS title,
- t.id AS "value",
- t.id AS "key",
- t.ancestors AS "ancestors",
- (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
- "has_children"
- FROM
- m_wbs_tree t
- WHERE
- t.parent_id = #{parentId} AND t.is_deleted = 0
- <if test="tenantId!=null and tenantId!=''">
- AND t.tenant_id = #{tenantId}
- </if>
- AND t.wbs_id = #{wbsId}
- AND t.type = 1
- AND status = 1
- ORDER BY t.sort
- </select>
- <select id="lazyTree" resultMap="treeNodeResultMap">
- SELECT
- (select wbs_type from m_wbs_info where id = #{wbsId}) AS wbsType,
- t.type AS "type",
- t.node_type AS "nodeType",
- t.is_exist_form AS "isExistForm",
- t.table_type,
- t.id,
- t.parent_id,
- t.node_name AS title,
- t.id AS "value",
- t.id AS "key",
- t.ancestors AS "ancestors",
- (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
- "has_children"
- FROM
- m_wbs_tree t
- WHERE
- t.parent_id = #{parentId} AND t.is_deleted = 0
- <if test="tenantId!=null and tenantId!=''">
- AND t.tenant_id = #{tenantId}
- </if>
- AND t.wbs_id = #{wbsId}
- AND t.type = 1
- AND status = 1
- ORDER BY t.sort
- </select>
- <select id="selectByNodeTable" resultMap="selectByNodeTableMap">
- SELECT wt.id AS id,
- wt.node_name AS tableName,
- wt.sort AS sort,
- case
- when wt.table_type in (1, 9) then 1
- when wt.table_type in (2, 10) then 2
- else wt.table_type
- end as tableType,
- wt.`status` AS isCreateTable,
- wt.table_owner as tableOwner,
- wt.is_link_table,
- wt.init_table_name as "initTableName",
- wt.parent_id AS "parentId",
- wt.wbs_id AS "wbsId",
- wt.fill_rate AS "fillRate",
- wt.init_table_id AS initTableId,
- (SELECT count(1)
- FROM m_wbs_form_element
- WHERE f_id = wt.init_table_id and is_deleted = 0 and status = 1) AS
- "elementTotal"
- FROM m_wbs_tree AS wt
- WHERE wt.type = 2
- AND wt.is_deleted = 0
- AND wt.parent_id = #{id}
- ORDER BY wt.sort, wt.node_name, wt.create_time
- </select>
- <select id="selectByNodeTableByExcel" resultMap="selectByNodeTableMap">
- SELECT wt.p_key_id as pKeyId,
- wt.id AS id,
- wt.node_name AS tableName,
- wt.sort AS sort,
- wt.table_type AS tableType,
- wt.`status` AS isCreateTable,
- wt.table_owner as tableOwner,
- IF(wt.excel_id = #{liunxId}, IF(is_link_table = 2, 2, 1), 1) as is_link_table,
- wt.init_table_name as "initTableName",
- wt.parent_id AS "parentId",
- wt.wbs_id AS "wbsId",
- (SELECT count(*)
- FROM m_wbs_form_element AS wfe
- WHERE wfe.f_id = wt.id
- and wfe.is_deleted = 0) AS elementTotal
- FROM m_wbs_tree_private AS wt
- WHERE wt.type = 2
- AND wt.is_deleted = 0
- AND wt.parent_id = #{id}
- AND wt.project_id = #{projectid}
- ORDER BY wt.sort
- </select>
- <select id="selectByElementsTotal" resultType="java.lang.String">
- SELECT f_id,count(*) as elementTotal FROM m_wbs_form_element where f_id in #{ids} and is_deleted=0 GROUP BY f_id
- </select>
- <select id="selectFormElements" resultMap="wbsFormElementMap">
- select f_id,
- e_key,
- a.id,
- a.dynamic_dict,
- e_name,
- e_type,
- e_length,
- e_allow_deviation,
- e_Inspection_method,
- CONCAT(b.init_table_name, ':', e_key)
- as tableElementKey,
- init_table_name as initTableName,
- b.parent_id as nodeId
- from m_wbs_form_element a
- inner join m_wbs_tree b on a.f_id = b.init_table_id
- where b.id = #{id}
- and a.is_deleted = 0
- union
- select f_id,
- e_key,
- a.id,
- a.dynamic_dict,
- e_name,
- e_type,
- e_length,
- e_allow_deviation,
- e_Inspection_method,
- CONCAT(b.init_table_name, ':', e_key)
- as tableElementKey,
- init_table_name as initTableName,
- b.parent_id as nodeId
- from m_wbs_form_element a
- inner join m_wbs_tree_private b on a.f_id = b.init_table_id
- where b.p_key_id = #{id}
- and a.is_deleted = 0
- </select>
- <select id="selectFormElements4TableId" resultMap="wbsFormElementMap">
- select b.id
- , IF(c.formula_id > 0, 1, 0) globalFormula
- , b.e_name
- , e_type
- , e_length
- , e_allow_deviation
- , e_Inspection_method
- , CONCAT(a.tab_en_name, ':', e_key) as
- tableElementKey
- , a.tab_en_name as initTableName,
- if((SELECT count(d.tab_en_name) from m_tab_busstime_info d where b.id = d.col_id)>=1,2,0) isBussTime
- from (select * from m_table_info where id = #{id}) a
- INNER JOIN
- m_wbs_form_element b on a.id = b.f_id
- LEFT JOIN(select element_id, formula_id
- from m_element_formula_mapping
- where scope = 0) c on b.id = c.element_id
- where b.is_deleted = 0
- </select>
- <select id="selectPrivateFormElements" resultMap="wbsFormElementMap">
- select * from m_wbs_form_element a
- where a.f_id=#{id} and a.is_deleted=0
- <if test="eName != null and eName != '' ">
- and e_name like concat('%',#{eName},'%')
- </if>
- </select>
- <select id="selectRepeatByProjectId" resultType="java.lang.Integer">
- SELECT COUNT(*) FROM m_wbs_tree_private WHERE project_id = #{projectId} AND status = 1 AND is_deleted = 0
- </select>
- <select id="findAllNodeTableList" resultType="org.springblade.manager.entity.WbsTree">
- SELECT *
- FROM m_wbs_tree
- WHERE type = 2
- AND is_deleted = 0
- AND `status` = 1
- AND wbs_id = #{wbsId}
- </select>
- <select id="selectIsTable" resultType="org.springblade.manager.entity.WbsTree">
- SELECT *
- FROM m_wbs_tree
- WHERE type = 2
- AND is_deleted = 0
- AND `status` = 1
- AND parent_id = #{tableParentId}
- </select>
- <select id="selectNodeAndTable" resultType="org.springblade.manager.entity.WbsTree">
- SELECT *
- FROM m_wbs_tree
- WHERE id = #{id}
- OR (parent_id = #{id} and type = 2)
- AND is_deleted = 0 AND status = 1
- </select>
- <select id="selectByWbsId" resultType="org.springblade.manager.entity.WbsTree">
- SELECT *
- FROM m_wbs_tree
- WHERE wbs_id = #{id}
- AND status = 1
- AND is_deleted = 0
- AND parent_id = 0
- AND type = 1
- </select>
- <select id="selectListByUserId" resultType="org.springblade.manager.vo.SaveUserInfoByProjectVO2">
- SELECT mpau.id AS "id"
- , pi.project_name as "projectName"
- , ci.contract_name as "contractName"
- , (SELECT role_name FROM blade_role WHERE id = r.parent_id) as "roleType"
- , r.role_name as "roleName"
- FROM m_project_assignment_user mpau
- INNER JOIN blade_role r ON r.id = mpau.role_id
- INNER JOIN m_contract_info ci ON ci.id = mpau.contract_id
- INNER JOIN m_project_info pi ON pi.id = mpau.project_id
- WHERE mpau.is_deleted = 0
- AND mpau.`status` = 1
- AND mpau.user_id = #{userId}
- </select>
- <select id="selectWbsTreeListByParentId" resultType="org.springblade.manager.dto.WbsTreeDTO2">
- SELECT id,node_name AS "nodeName",sort
- FROM m_wbs_tree
- WHERE parent_id = #{parentId}
- AND status = 1
- AND is_deleted = 0
- AND type = 1
- ORDER BY sort
- </select>
- <select id="searchNodeTables" resultType="org.springblade.manager.vo.WbsNodeTableVO">
- SELECT wt.id AS id,
- wt.node_name AS tableName,
- wt.sort AS sort,
- wt.table_type AS tableType,
- wt.`status` AS `status`,
- wt.table_owner AS tableOwner,
- wt.init_table_name AS "initTableName",
- wt.parent_id AS "parentId",
- wt.wbs_id AS "wbsId",
- (SELECT count(1) FROM m_wbs_form_element WHERE f_id = wt.id) AS "elementTotal",
- (SELECT CASE WHEN count(1) > 0 THEN 2 ELSE 1 END
- FROM m_wbs_tab_relation_excel_tab b
- WHERE wt.id = b.wbs_tab_id
- AND b.excel_tab_id = #{excelId}) AS "isLinkTable"
- FROM m_wbs_tree AS wt
- WHERE wt.type = 2
- AND wt.is_deleted = 0
- AND wt.STATUS = 1
- AND wt.parent_id = #{nodeId}
- ORDER BY wt.sort
- </select>
- <select id="isThereAField" resultType="java.lang.Integer">
- select COUNT(*) from information_schema.columns WHERE table_name = #{initTableName} and column_name = #{keyId}
- </select>
- <select id="getTitleRange" resultType="org.springblade.manager.entity.WbsTreePrivate">
- SELECT id,node_name,status From m_wbs_tree_private where project_id = #{projectId} and node_type=1 and is_deleted=0
- and parent_id in (select id from m_wbs_tree_private where project_id= #{projectId} and parent_id=0 and is_deleted=0)
- </select>
- </mapper>
|