123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821 |
- <?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.ArchiveTreeContractMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="archiveTreeContractResultMap" type="org.springblade.manager.entity.ArchiveTreeContract">
- <result column="id" property="id"/>
- <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="status" property="status"/>
- <result column="is_deleted" property="isDeleted"/>
- <result column="project_id" property="projectId"/>
- <result column="contract_id" property="contractId"/>
- <result column="is_upload_file_display_configuration_tree" property="isUploadFileDisplayConfigurationTree"/>
- <result column="parent_id" property="parentId"/>
- <result column="ancestors" property="ancestors"/>
- <result column="node_name" property="nodeName"/>
- <result column="full_name" property="fullName"/>
- <result column="node_type" property="nodeType"/>
- <result column="post_type" property="postType"/>
- <result column="association_type" property="associationType"/>
- <result column="major_data_type" property="majorDataType"/>
- <result column="display_hierarchy" property="displayHierarchy"/>
- <result column="is_storage_node" property="isStorageNode"/>
- <result column="is_built_drawing" property="isBuiltDrawing"/>
- <result column="is_interface_node" property="isInterfaceNode"/>
- <result column="interface_type" property="interfaceType"/>
- <result column="sort" property="sort"/>
- <result column="tree_sort" property="treeSort"/>
- <result column="remark" property="remark"/>
- <result column="project_type" property="projectType"/>
- <result column="storage_type" property="storageType"/>
- <result column="ext_type" property="extType"/>
- <result column="ext_id" property="extId"/>
- <result column="exp_data_type" property="expDataType"/>
- <result column="from_id" property="fromId"/>
- <result column="archive_auto_type" property="archiveAutoType"/>
- <result column="archive_auto_node_id" property="archiveAutoNodeId"/>
- <result column="archive_auto_group_select" property="archiveAutoGroupSelect"/>
- <result column="archive_auto_group_id" property="archiveAutoGroupId"/>
- <result column="tree_code" property="treeCode"/>
- <result column="file_number_prefix" property="fileNumberPrefix"/>
- <result column="storage_time" property="storageTime"/>
- <result column="rollor" property="rollor"/>
- <result column="reviewer" property="reviewer"/>
- <result column="specification" property="specification"/>
- <result column="archive_name_suffix" property="archiveNameSuffix"/>
- <result column="ext_key_id" property="extKeyId"/>
- <result column="out_id" property="outId"/>
- </resultMap>
- <delete id="removeImageNodeChild">
- delete from m_archive_tree_contract
- where contract_id = #{contractId} and is_deleted = 0 and FIND_IN_SET(#{id},ancestors) > 0
- </delete>
- <delete id="removeImageNodeFile">
- delete from u_archive_file
- where contract_id = #{contractId}
- and node_id in
- (
- select id from m_archive_tree_contract
- where contract_id = #{contractId} and is_deleted = 0 and FIND_IN_SET(#{id},ancestors) > 0
- )
- </delete>
- <select id="selectArchiveTreeContractPage" resultMap="archiveTreeContractResultMap">
- select * from m_archive_tree_contract where is_deleted = 0
- </select>
- <resultMap id="treeNodeResultMap" type="org.springblade.manager.vo.TreeNodeVO2">
- <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="displayHierarchy" property="displayHierarchy"/>
- <result column="majorDataType" property="majorDataType"/>
- <result column="isStorageNode" property="isStorageNode"/>
- <result column="isDisplayTree" property="isDisplayTree"/>
- <result column="isStorageNode" property="isStorageNode"/>
- <result column="isBuiltDrawing" property="isBuiltDrawing"/>
- <result column="postType" property="postType"/>
- <result column="project_type" property="projectType"/>
- <result column="storage_type" property="storageType"/>
- <result column="ext_type" property="extType"/>
- <result column="ext_id" property="extId"/>
- <result column="archive_auto_type" property="archiveAutoType"/>
- <result column="archive_auto_node_id" property="archiveAutoNodeId"/>
- <result column="from_id" property="fromId"/>
- <result column="ext_attach_id" property="extAttachId"/>
- </resultMap>
- <resultMap id="ArchiveTreeContractVO2ResultMap" type="org.springblade.manager.vo.ArchiveTreeContractVO2">
- <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="contract_id" property="contractId"/>
- <result column="has_children" property="hasChildren"/>
- <result column="displayHierarchy" property="displayHierarchy"/>
- <result column="majorDataType" property="majorDataType"/>
- <result column="isStorageNode" property="isStorageNode"/>
- <result column="isDisplayTree" property="isDisplayTree"/>
- <result column="isStorageNode" property="isStorageNode"/>
- <result column="isBuiltDrawing" property="isBuiltDrawing"/>
- <result column="association_type" property="associationType"/>
- <result column="nodeType" property="nodeType"/>
- <result column="postType" property="postType"/>
- <result column="project_type" property="projectType"/>
- <result column="storage_type" property="storageType"/>
- <result column="ext_type" property="extType"/>
- <result column="ext_id" property="extId"/>
- <result column="ext_key_id" property="extKeyId"/>
- <result column="exp_data_type" property="expDataType"/>
- <result column="from_id" property="fromId"/>
- <result column="archive_auto_type" property="archiveAutoType"/>
- <result column="archive_auto_node_id" property="archiveAutoNodeId"/>
- <result column="archive_auto_group_select" property="archiveAutoGroupSelect"/>
- <result column="archive_auto_group_id" property="archiveAutoGroupId"/>
- <result column="tree_sort" property="treeSort"/>
- <result column="tree_code" property="treeCode"/>
- <result column="file_number_prefix" property="fileNumberPrefix"/>
- <result column="storage_time" property="storageTime"/>
- <result column="rollor" property="rollor"/>
- <result column="reviewer" property="reviewer"/>
- <result column="specification" property="specification"/>
- <result column="archive_name_suffix" property="archiveNameSuffix"/>
- <result column="tree_number" property="treeNumber"/>
- </resultMap>
- <select id="lazyTree" resultMap="treeNodeResultMap">
- SELECT
- d.id,
- d.parent_id,
- d.node_name AS title,
- d.id AS "value",
- d.id AS "key",
- d.major_data_type AS "majorDataType",
- d.display_hierarchy AS "displayHierarchy",
- d.is_storage_node AS "isStorageNode",
- d.post_type AS postType,
- d.project_type,
- d.storage_type,
- d.ext_type,
- d.ext_id,
- d.archive_auto_type,
- d.archive_auto_node_id,
- (SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_archive_tree_contract WHERE parent_id = d.id and is_deleted = 0 and project_id = #{projectId})
- AS "has_children"
- FROM
- m_archive_tree_contract d
- WHERE
- d.parent_id = #{parentId} AND d.is_deleted = 0 and project_id = #{projectId}
- <if test="tenantId!=null and tenantId!=''">
- AND d.tenant_id = #{tenantId}
- </if>
- ORDER BY d.sort
- </select>
- <select id="tree" resultMap="treeNodeResultMap">
- SELECT
- id,
- parent_id,
- node_name AS title,
- id AS "value",
- id AS "key",
- major_data_type AS "majorDataType",
- display_hierarchy AS "displayHierarchy",
- is_storage_node AS "isStorageNode",
- is_upload_file_display_configuration_tree AS "isDisplayTree",
- is_built_drawing AS "isBuiltDrawing",
- post_type AS postType,
- project_type,
- storage_type,
- ext_type,
- ext_id,
- archive_auto_type,
- archive_auto_node_id
- FROM m_archive_tree_contract
- WHERE is_deleted = 0 and project_id = #{projectId}
- <if test=" tenantId!=null and tenantId!='' ">
- AND tenant_id = #{tenantId}
- </if>
- <if test=" disPlayTree!=null and disPlayTree!='' ">
- AND is_upload_file_display_configuration_tree = 1
- </if>
- <if test=" nodeType !=null and nodeType !='' ">
- /*根节点=0 关联电子原生文件=1 数字化上传文件=2*/
- AND node_type in (0,#{nodeType})
- </if>
- OR parent_id = 0
- ORDER BY sort
- </select>
- <select id="lazyTree2" resultMap="ArchiveTreeContractVO2ResultMap">
- SELECT
- d.id,
- d.parent_id,
- IFNULL(if(length(trim(d.full_name))>0,d.full_name,d.node_name),d.node_name)AS title,
- d.id AS "value",
- d.id AS "key",
- d.major_data_type AS "majorDataType",
- d.display_hierarchy AS "displayHierarchy",
- d.is_storage_node AS "isStorageNode",
- d.post_type AS postType,
- d.node_type AS nodeType,
- d.association_type,
- d.project_type,
- d.storage_type,
- d.ext_type,
- d.ext_id,
- d.exp_data_type,
- d.archive_auto_type,
- d.archive_auto_node_id,
- d.archive_auto_group_select,
- d.archive_auto_group_id,
- d.tree_sort,
- d.file_number_prefix,
- d.storage_time,
- d.rollor,
- d.reviewer,
- d.specification,
- d.archive_name_suffix,
- d.contract_id,
- (SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_archive_tree_contract WHERE parent_id = d.id and is_deleted = 0 and project_id = #{projectId})
- AS "has_children",
- (SELECT count(1) FROM m_archive_tree_contract WHERE is_deleted = 0 and project_id = #{projectId} and ancestors like CONCAT('%',d.id,'%')
- <if test="code!=null and code!=''">
- AND (tree_code = #{code} or tree_code = #{contractId} or parent_id = 0)
- </if>
- ) as tree_number
- FROM
- m_archive_tree_contract d
- WHERE
- d.parent_id = #{parentId} AND d.is_deleted = 0 and project_id = #{projectId}
- <if test="tenantId!=null and tenantId!=''">
- AND d.tenant_id = #{tenantId}
- </if>
- <if test="code!=null and code!=''">
- AND (d.tree_code = #{code} or d.tree_code = #{contractId} or d.parent_id = 0)
- </if>
- ORDER BY d.tree_sort, d.sort
- </select>
- <select id="tree2" resultMap="ArchiveTreeContractVO2ResultMap">
- SELECT
- id,
- parent_id,
- contract_id,
- node_name AS title,
- id AS "value",
- id AS "key",
- major_data_type AS "majorDataType",
- display_hierarchy AS "displayHierarchy",
- is_storage_node AS "isStorageNode",
- is_upload_file_display_configuration_tree AS "isDisplayTree",
- is_built_drawing AS "isBuiltDrawing",
- post_type AS postType,
- node_type AS nodeType,
- association_type,
- project_type,
- storage_type,
- ext_type,
- ext_id,
- exp_data_type,
- archive_auto_type,
- archive_auto_node_id,
- archive_auto_group_select,
- archive_auto_group_id,
- from_id,
- tree_sort,
- tree_code
- FROM m_archive_tree_contract
- WHERE is_deleted = 0 and project_id = #{projectId}
- <if test=" tenantId!=null and tenantId!='' ">
- AND tenant_id = #{tenantId}
- </if>
- <if test=" disPlayTree!=null and disPlayTree!='' ">
- AND is_upload_file_display_configuration_tree = 1
- </if>
- <if test=" nodeType !=null and nodeType !='' ">
- /*根节点=0 关联电子原生文件=1 数字化上传文件=2*/
- AND node_type in (0,#{nodeType})
- </if>
- <if test="code!=null and code!=''">
- AND (d.tree_code = #{code} or d.tree_code = #{contractId} or d.parent_id = 0)
- </if>
- OR ( parent_id = 0 AND project_id = #{projectId} AND is_deleted = 0 )
- ORDER BY sort
- </select>
- <update id="updateBatch">
- UPDATE m_archive_tree_contract
- SET is_upload_file_display_configuration_tree = 1
- WHERE id IN
- <foreach item="diffRent" collection="diffRent" open="(" close=")" separator=",">
- #{diffRent}
- </foreach>
- AND is_deleted = 0
- AND status = 1
- </update>
- <update id="updateBatch2">
- UPDATE m_archive_tree_contract
- SET is_upload_file_display_configuration_tree = 0
- WHERE id IN
- <foreach item="diffRent" collection="diffRent" open="(" close=")" separator=",">
- #{diffRent}
- </foreach>
- AND is_deleted = 0
- AND status = 1
- </update>
- <update id="updateBatch3">
- UPDATE m_archive_tree_contract
- SET is_upload_file_display_configuration_tree = 0
- WHERE
- node_type = 2
- AND is_deleted = 0
- AND status = 1
- </update>
- <select id="getHavedFileNodeByProjectID" resultMap="archiveTreeContractResultMap">
- SELECT
- *
- FROM
- m_archive_tree_contract
- WHERE
- 1 = 1
- AND project_id = #{projectId}
- AND is_deleted = 0
- AND archive_auto_type IS NOT NULL
- AND id IN (
- SELECT
- node_id
- FROM
- u_archive_file
- WHERE
- 1 = 1
- AND project_id = #{projectId}
- AND is_deleted = 0
- AND ( is_archive = 0 OR is_archive IS NULL )
- AND node_id IS NOT NULL
- )
- order by ancestors asc,tree_sort asc
- </select>
- <select id="getHavedBoxFileNodeByProjectID" resultMap="archiveTreeContractResultMap">
- SELECT
- *
- FROM
- m_archive_tree_contract
- WHERE
- 1 = 1
- AND project_id = #{projectId}
- AND is_deleted = 0
- AND id IN (
- SELECT
- node_id
- FROM
- u_archive_file
- WHERE
- 1 = 1
- AND project_id = #{projectId}
- AND is_deleted = 0
- AND ( is_archive = 0 OR is_archive IS NULL )
- AND node_id IS NOT NULL
- AND (box_number IS NOT NULL and box_number != -1 )
- )
- order by ancestors asc,tree_sort asc
- </select>
- <select id="getListByProjectId" resultType="org.springblade.manager.entity.ArchiveTreeContract">
- select id,project_id as projectId,contract_id as contractId,parent_id as parentId,ancestors,node_name as nodeName,status,tree_code as treeCode, ext_type as extType,
- is_deleted as isDeleted,create_time as createTime, file_number_prefix as fileNumberPrefix
- from m_archive_tree_contract
- where project_id=#{projectId} and is_deleted = 0 order by tree_sort asc;
- </select>
- <select id="getStorageNodeByGroupId" resultMap="archiveTreeContractResultMap">
- SELECT
- *
- FROM
- m_archive_tree_contract
- WHERE
- 1 = 1
- AND project_id = #{projectId}
- AND is_deleted = 0
- AND archive_auto_type =2
- AND is_storage_node =1
- AND archive_auto_group_id =#{archiveAutoGroupId}
- order by tree_sort asc
- </select>
- <select id="getArchiveTreeAndArchiveCount" resultType="java.util.Map">
- SELECT
- matc1.id as id,
- matc1.node_name as name,
- (SELECT COUNT(*)
- FROM u_archives_auto uaa1
- WHERE uaa1.is_destroy =0 and uaa1.is_deleted =0 and uaa1.is_archive = 1 and (uaa1.node_id in
- (select id from m_archive_tree_contract matc2 WHERE matc2.project_id = #{projectId} and matc2.ancestors like CONCAT('%',matc1.id,'%')) or uaa1.node_id = matc1.id)
- ) as 'auto',
- (SELECT COUNT(*)
- FROM u_archives_auto uaa1
- WHERE uaa1.is_destroy =1 and uaa1.is_deleted =1 and uaa1.is_archive = 1 and (uaa1.node_id in
- (select id from m_archive_tree_contract matc2 WHERE matc2.project_id = #{projectId} and matc2.ancestors like CONCAT('%',matc1.id,'%')) or uaa1.node_id = matc1.id)
- ) as 'deleted',
- if((SELECT COUNT(*) from m_archive_tree_contract matc WHERE parent_id = matc1.id)=0,false,true) as hasChildren
- FROM m_archive_tree_contract matc1 WHERE matc1.project_id =#{projectId} and matc1.parent_id = #{nodeId} and matc1.is_deleted = 0
- </select>
- <select id="getArchiveTreeByNodeType" resultType="org.springblade.manager.vo.ArchiveTreeContractVO3">
- SELECT matc1.*,if((SELECT COUNT(*) from m_archive_tree_contract matc WHERE matc.parent_id = matc1.id)=0,true,false)
- as notExsitChild
- FROM m_archive_tree_contract matc1
- WHERE matc1.parent_id = (select id from m_archive_tree_contract
- WHERE parent_id = (select id from m_archive_tree_contract WHERE parent_id = 0 and project_id = #{projectId})
- and tree_code = #{nodeType})
- and matc1.is_deleted = 0
- <if test="contractId !=null and contractId !=''">
- AND matc1.contract_id = #{contractId}
- </if>
- </select>
- <select id="getArchiveTreeByNodeType2" resultType="org.springblade.manager.vo.ArchiveTreeContractVO3">
- SELECT matc1.*,if((SELECT COUNT(*) from m_archive_tree_contract matc WHERE matc.parent_id = matc1.id)=0,true,false)
- as notExsitChild
- FROM m_archive_tree_contract matc1
- WHERE matc1.parent_id in (select id from m_archive_tree_contract
- WHERE parent_id = (select id from m_archive_tree_contract WHERE parent_id = 0 and project_id = #{projectId} and is_deleted = 0)
- and is_deleted = 0 and tree_code is NULL)
- and matc1.is_deleted = 0
- </select>
- <select id="getChildrenNodeByNodeId" resultType="org.springblade.manager.vo.ArchiveTreeContractVO3">
- select matc1.*,if((SELECT COUNT(*) from m_archive_tree_contract matc WHERE matc.parent_id = matc1.id)=0,true,false)
- as notExsitChild
- from m_archive_tree_contract matc1 WHERE matc1.parent_id = #{nodeId} and matc1.is_deleted =0
- ORDER BY sort
- </select>
- <select id="getAuthCodeList" resultMap="archiveTreeContractResultMap">
- SELECT
- d.id
- FROM
- m_archive_tree_contract d
- WHERE
- d.is_deleted = 0
- AND d.ancestors like concat('%',#{id},'%')
- <if test="authCode !=null and authCode !=''">
- AND (d.tree_code = #{authCode} or d.tree_code = #{contractId} or d.parent_id = 0)
- </if>
- ORDER BY d.sort
- </select>
- <select id="getArchiveTreeContractListByIds" resultMap="archiveTreeContractResultMap">
- SELECT
- d.*
- FROM
- m_archive_tree_contract d
- WHERE
- d.is_deleted = 0 and d.id in
- <foreach item="id" collection="idsList" open="(" close=")" separator=",">
- #{id}
- </foreach>
- ORDER BY d.ancestors
- </select>
- <select id="getUserRoleName" resultType="java.lang.String">
- SELECT br.role_name
- FROM blade_role br
- WHERE br.id = (
- SELECT role_id FROM m_project_assignment_user
- WHERE project_id = #{projectId} AND contract_id = #{contractId} AND user_id = #{userId}
- )
- </select>
- <select id="getArchiveTreeContractByNodeName"
- resultType="org.springblade.manager.entity.ArchiveTreeContract">
- SELECT *
- FROM m_archive_tree_contract
- WHERE node_name = #{nodeName} and is_deleted = 0
- </select>
- <select id="getFirstNodeByTreeCode" resultType="org.springblade.manager.entity.ArchiveTreeContract">
- select * from m_archive_tree_contract
- WHERE parent_id = (select id from m_archive_tree_contract WHERE parent_id = 0 and project_id = #{projectId} and is_deleted = 0)
- and is_deleted = 0 and tree_code is NULL
- </select>
- <select id="getFirstNodeByTreeCode2" resultType="org.springblade.manager.entity.ArchiveTreeContract">
- select * from m_archive_tree_contract
- WHERE parent_id = (select id from m_archive_tree_contract WHERE parent_id = 0 and project_id = #{projectId} and is_deleted = 0)
- and is_deleted = 0 and tree_code = #{type}
- </select>
- <select id="getSelectRuleNode" resultType="org.springblade.manager.entity.ArchiveTreeContract">
- select * from m_archive_tree_contract
- WHERE project_id = #{projectId}) and is_deleted = 0 and archive_auto_group_select = 1
- </select>
- <select id="getCountfromIdIsNull" resultType="java.lang.Integer">
- select count(*) from m_archive_tree_contract
- WHERE project_id = #{projectId}) and is_deleted = 0 and from_id is null and like concat('%',#{id},'%')
- </select>
- <select id="getArchiveTreeContractByContractId"
- resultType="org.springblade.manager.entity.ArchiveTreeContract">
- select id from m_archive_tree_contract
- where contract_id = #{contractId} and is_deleted = 0
- order by ancestors
- limit 1
- </select>
- <!-- <select id="getUnitAllNode" resultType="org.springblade.manager.vo.InspectTreeVO">-->
- <!-- <if test="ownerUnit != null">-->
- <!-- select id,parent_id,node_name,-->
- <!-- (CASE when LENGTH(expert_id) > 0 then 0 else 1 end) as isSelect,-->
- <!-- (CASE when LENGTH(expert_id) > 0 then concat('该目录已分属', atc.expert_name , '专家') else '' end) as nodeInfo-->
- <!-- from m_archive_tree_contract atc-->
- <!-- WHERE is_deleted =0 and project_id = #{projectId}-->
- <!-- and (id = #{ownerUnit} or FIND_IN_SET(#{ownerUnit},ancestors))-->
- <!-- </if>-->
- <!-- <if test="ownerUnit != null and (supervisorUnit != null or buildUnit != null)">-->
- <!-- UNION all-->
- <!-- </if>-->
- <!-- <if test="supervisorUnit != null">-->
- <!-- select id,parent_id,node_name,-->
- <!-- (CASE when LENGTH(expert_id) > 0 then 0 else 1 end) as isSelect,-->
- <!-- (CASE when LENGTH(expert_id) > 0 then concat('该目录已分属', atc.expert_name , '专家') else '' end) as nodeInfo-->
- <!-- from m_archive_tree_contract atc-->
- <!-- WHERE is_deleted =0 and project_id = #{projectId}-->
- <!-- and (id = #{supervisorUnit} or FIND_IN_SET(#{supervisorUnit},ancestors))-->
- <!-- </if>-->
- <!-- <if test="supervisorUnit != null and buildUnit != null">-->
- <!-- UNION all-->
- <!-- </if>-->
- <!-- <if test="buildUnit != null ">-->
- <!-- select id,parent_id,node_name,-->
- <!-- (CASE when LENGTH(expert_id) > 0 then 0 else 1 end) as isSelect,-->
- <!-- (CASE when LENGTH(expert_id) > 0 then concat('该目录已分属', atc.expert_name , '专家') else '' end) as nodeInfo-->
- <!-- from m_archive_tree_contract atc-->
- <!-- WHERE is_deleted =0 and project_id = #{projectId}-->
- <!-- and (id = #{buildUnit} or FIND_IN_SET(#{buildUnit},ancestors))-->
- <!-- </if>-->
- <!-- </select>-->
- <select id="getUnitAllNode" resultType="org.springblade.manager.vo.InspectTreeVO">
- <if test="ownerUnit != null">
- select id,parent_id,
- (CASE when LENGTH(expert_id) > 0 then 0 else 1 end) as isSelect,
- if((select COUNT(1) from m_archive_tree_contract WHERE is_deleted = 0 and parent_id = atc.id) > 0,true,false) as isChildren,
- (CASE when LENGTH(expert_id) > 0 then concat('该目录已分属', atc.expert_name , '专家') else '' end) as nodeInfo,
- atc.node_name as node_name ,
- ( select count(1) from u_archives_auto where is_apply = 1 and is_deleted = 0 and node_id = atc.id ) as total
- from m_archive_tree_contract atc
- WHERE is_deleted =0 and project_id = #{projectId}
- and (id = #{ownerUnit} or FIND_IN_SET(#{ownerUnit},ancestors))
- </if>
- <if test="ownerUnit != null and (supervisorUnit != null or buildUnit != null)">
- UNION all
- </if>
- <if test="supervisorUnit != null">
- select id,parent_id,
- (CASE when LENGTH(expert_id) > 0 then 0 else 1 end) as isSelect,
- if((select COUNT(1) from m_archive_tree_contract WHERE is_deleted = 0 and parent_id = atc.id) > 0,true,false) as isChildren,
- (CASE when LENGTH(expert_id) > 0 then concat('该目录已分属', atc.expert_name , '专家') else '' end) as nodeInfo,
- atc.node_name as node_name ,
- ( select count(1) from u_archives_auto where is_apply = 1 and is_deleted = 0 and node_id = atc.id ) as total
- from m_archive_tree_contract atc
- WHERE is_deleted =0 and project_id = #{projectId}
- and (id = #{supervisorUnit} or FIND_IN_SET(#{supervisorUnit},ancestors))
- </if>
- <if test="supervisorUnit != null and buildUnit != null">
- UNION all
- </if>
- <if test="buildUnit != null ">
- select id,parent_id,
- (CASE when LENGTH(expert_id) > 0 then 0 else 1 end) as isSelect,
- if((select COUNT(1) from m_archive_tree_contract WHERE is_deleted = 0 and parent_id = atc.id) > 0,true,false) as isChildren,
- (CASE when LENGTH(expert_id) > 0 then concat('该目录已分属', atc.expert_name , '专家') else '' end) as nodeInfo,
- atc.node_name as node_name ,
- ( select count(1) from u_archives_auto where is_apply = 1 and is_deleted = 0 and node_id = atc.id ) as total
- from m_archive_tree_contract atc
- WHERE is_deleted =0 and project_id = #{projectId}
- and (id = #{buildUnit} or FIND_IN_SET(#{buildUnit},ancestors))
- </if>
- </select>
- <select id="getFirstNode" resultType="org.springblade.manager.vo.InspectTreeVO">
- select id,parent_id,
- (CASE when LENGTH(expert_id) > 0 then 0 else 1 end) as isSelect,
- if((select COUNT(1) from m_archive_tree_contract WHERE is_deleted = 0 and parent_id = atc.id) > 0,true,false) as isChildren,
- atc.node_name as node_name ,
- ( select count(1) from u_archives_auto where project_id = #{projectId} and is_apply = 1 and is_deleted = 0) as total
- from m_archive_tree_contract atc
- WHERE atc.parent_id = 0 and atc.is_deleted = 0 and project_id =#{projectId}
- </select>
- <select id="getUnitFirstNode" resultType="org.springblade.manager.entity.ArchiveTreeContract">
- SELECT id,
- (CASE tree_code WHEN 'C' THEN 3 WHEN 's' THEN 2 ELSE 1 END) as tree_code
- from m_archive_tree_contract
- WHERE parent_id = #{id} and is_deleted = 0
- </select>
- <select id="getSelectNodes" resultType="org.springblade.manager.entity.ArchiveTreeContract">
- select id,expert_id,expert_name
- from m_archive_tree_contract where id in
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </select>
- <select id="MyLazyTree" resultType="org.springblade.manager.vo.MyInspectTreeVO">
- select *,node_name as title,
- if((select COUNT(1) from m_archive_tree_contract WHERE is_deleted = 0 and parent_id = d.id) > 0,true,false) as hasChildren
- FROM
- m_archive_tree_contract d
- WHERE
- d.parent_id = #{parentId} AND d.is_deleted = 0 and project_id = #{projectId}
- and FIND_IN_SET(#{userId},d.expert_id)
- ORDER BY d.sort
- </select>
- <select id="getNewTable" resultType="org.springblade.archive.entity.ArchiveExpertConclusion">
- select * from u_archive_expert_conclusion
- WHERE is_deleted = 0 and project_id = #{projectId}
- order by create_time DESC
- limit 1
- </select>
- <update id="updateAllSonNodeIdsForArchiveAutoRule">
- <if test="archiveAutoType ==1 ">
- update m_archive_tree_contract
- set
- archive_auto_node_id = #{archiveAutoNodeId}
- where
- is_deleted = 0 and ancestors like concat('', #{ancestors}, '%');
- </if>
- <if test="archiveAutoType ==1 and archiveAutoGroupId != null">
- update m_archive_tree_contract
- set
- archive_auto_type= #{archiveAutoType}
- where
- is_deleted = 0 and ancestors like concat('', #{ancestors}, '%')
- and archive_auto_group_id = #{archiveAutoGroupId} and archive_auto_type = 2 and archive_auto_group_select = 0 ;
- </if>
- update m_archive_tree_contract
- set
- archive_auto_type= #{archiveAutoType}
- <if test="archiveAutoType ==2 ">
- ,archive_auto_group_id=#{archiveAutoGroupId},
- archive_auto_group_select=0
- </if>
- <if test="fileNumberPrefix != null and fileNumberPrefix != ''">
- ,file_number_prefix = #{fileNumberPrefix}
- </if>
- where
- is_deleted = 0 and ancestors like concat('', #{ancestors}, '%')
- /*最高并卷规则不能覆盖 分类并卷规则,单独组卷规则*/
- <if test="archiveAutoType ==1 ">
- and (archive_auto_type != 2 and archive_auto_type != 3 or archive_auto_type is null)
- </if>
- </update>
- <update id="updateByNodeName">
- update m_archive_tree_contract
- set node_name = #{name}
- where node_name = #{contractName} and contract_id = #{id}
- </update>
- <update id="updateBatchFileSortById">
- <foreach collection="list" item="item" index="index" separator=";">
- update u_archive_file
- <set>
- sort = #{item.sort},
- pdf_file_url = #{item.pdfFileUrl},
- e_visa_file = #{item.eVisaFile},
- file_page = #{item.filePage},
- file_size = #{item.fileSize},
- is_certification = 1,
- certification_time = #{item.certificationTime},
- file_time = #{item.fileTime}
- </set>
- where id = #{item.id}
- </foreach>
- </update>
- <!-- 批量添加归档合同树 -->
- <insert id="batchInsertArchiveTreeContract" parameterType="java.util.List">
- INSERT INTO m_archive_tree_contract (id, tenant_id, project_id, contract_id, parent_id, ancestors, node_name,
- full_name, tree_code, ext_type, ext_id, ext_key_id, ext_attach_id, sort, status, is_deleted, from_id, node_type,
- is_storage_node, post_type, major_data_type, project_type, storage_type, create_user, create_dept, create_time, tree_structure)
- VALUES
- <foreach collection="list" item="item" separator=",">
- (#{item.id}, #{item.tenantId}, #{item.projectId}, #{item.contractId}, #{item.parentId},#{item.ancestors},
- #{item.nodeName},#{item.fullName},#{item.treeCode},#{item.extType},#{item.extId},#{item.extKeyId},#{item.extAttachId},
- #{item.sort},#{item.status},#{item.isDeleted},#{item.fromId},#{item.nodeType},#{item.isStorageNode},#{item.postType},#{item.majorDataType}
- ,#{item.projectType},#{item.storageType},#{item.createUser},#{item.createDept},#{item.createTime}, #{item.treeStructure})
- </foreach>
- </insert>
- <!-- 批量删除归档合同树 -->
- <update id="batchDeleteArchiveTreeContractByIdList">
- update
- m_archive_tree_contract
- set
- is_deleted = #{isDeleted},
- update_time = NOW()
- where
- id in
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </update>
- <!-- 批量修改归档树 -->
- <update id="batchUpdateArchiveTreeContract">
- <foreach collection="list" item="item" index="index" separator=";">
- update
- m_archive_tree_contract
- <set>
- parent_id = #{item.parentId},
- ancestors = #{item.ancestors},
- node_name = #{item.nodeName},
- node_type = #{item.nodeType},
- full_name = #{item.fullName},
- tree_structure = #{item.treeStructure},
- update_time = NOW()
- </set>
- where id = #{item.id}
- </foreach>
- </update>
- <update id="updateAllChild">
- update
- m_archive_tree_contract
- <set>
- file_number_prefix = #{node.fileNumberPrefix},
- storage_time = #{node.storageTime},
- rollor = #{node.rollor},
- reviewer = #{node.reviewer},
- specification = #{node.specification},
- archive_name_suffix = #{node.archiveNameSuffix}
- </set>
- where is_deleted = 0 and project_id = #{node.projectId} and FIND_IN_SET(#{node.id},ancestors) > 0
- </update>
- <resultMap id="getArchiveTreeContractDtoMap" type="org.springblade.manager.dto.ArchiveTreeContractDTO">
- <id column="id" property="id"/>
- <result column="project_id" property="projectId"></result>
- <result column="contract_id" property="contractId"></result>
- <result column="parent_id" property="parentID"></result>
- <result column="node_name" property="nodeName"></result>
- <result column="update_time" property="updateUserTime"></result>
- <result column="real_name" property="updateUserName"></result>
- </resultMap>
- <select id="getArchiveTreeContractDto" resultMap="getArchiveTreeContractDtoMap">
- select a.id,a.project_id,a.parent_id,a.contract_id,a.node_name,b.real_name,a.update_time from m_archive_tree_contract AS a LEFT JOIN blade_user AS b
- on a.update_user=b.id where a.project_id=#{projectId}
- and (a.contract_id in
- <foreach collection="dtos" item="item" open="(" separator="," close=")">
- #{item.cqContractId}
- </foreach>
- or a.contract_id is null) and a.tenant_id!='000000';
- </select>
- <select id="getLogDict" resultType="org.springblade.system.entity.DictBiz">
- select * from blade_dict_biz where parent_id != 0 and code = 'contract_log_type' and is_deleted = 0
- </select>
- <select id="getAllTrialNode" resultType="org.springblade.manager.vo.ArchiveSyncTrialVO">
- select p_key_id,id,parent_id,node_name,full_name,node_type,sort
- from m_wbs_tree_private
- where wbs_type = 2 and project_id = #{projectId} and `type` = 1 and is_deleted = 0
- and node_type in (51,52,53)
- order by sort
- </select>
- <select id="getAllTrialRecord" resultType="org.springblade.business.entity.TrialSelfInspectionRecord">
- select *
- from u_trial_self_inspection_record
- where contract_id = #{contractId} and is_deleted = 0 and task_status = '已审批'
- </select>
- <select id="getAllTrialRecordFile"
- resultType="org.springblade.business.vo.TrialSelfInspectionRecordFileVO">
- select id,self_id,url,type,
- (select node_id from u_trial_self_inspection_record sir where sir.id = sirf.self_id) as nodeId
- from u_trial_self_inspection_record_file sirf
- where self_id in
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </select>
- <select id="getAllThreeTestNode"
- resultType="org.springblade.manager.entity.TrialClassificationConfiguration">
- select *
- from m_trial_classification_configuration
- where is_deleted = 0 and parent_id in
- (
- select id from m_trial_classification_configuration where is_deleted = 0 and parent_id = 0 and node_type in (1,2)
- )
- </select>
- <select id="getAllTrialTestRecord" resultType="org.springblade.business.entity.TrialDetectionData">
- select *
- from m_trial_detection_data
- where contract_id = #{contractId} and is_deleted = 0
- </select>
- <select id="getOutNodes" resultType="org.springblade.manager.entity.ArchiveTreeContract">
- select id,node_name,parent_id,out_id from m_archive_tree_contract
- WHERE project_id = #{projectId} and is_deleted = 0 and out_id is not null
- </select>
- <select id="getOutNodesByOutIds" resultType="org.springblade.manager.entity.ArchiveTreeContract">
- select id,node_name,parent_id,out_id
- from m_archive_tree_contract
- where project_id = #{projectId} and is_deleted = 0 and
- out_id in
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </select>
- </mapper>
|