Source/UBCS/ubcs-service/ubcs-code/src/main/resources/mapper/CodeCLassifyMapper.xml
@@ -2,6 +2,201 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.vci.ubcs.code.mapper.CodeClassifyMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="plCodeClassifyResultMap" type="com.vci.ubcs.code.entity.CodeClassify">
        <result column="OID" property="oid"/>
        <result column="REVISIONOID" property="revisionOid"/>
        <result column="NAMEOID" property="nameOid"/>
        <result column="BTMNAME" property="btmname"/>
        <result column="LASTR" property="lastR"/>
        <result column="FIRSTR" property="firstR"/>
        <result column="LASTV" property="lastV"/>
        <result column="FIRSTV" property="firstV"/>
        <result column="CREATOR" property="creator"/>
        <result column="CREATETIME" property="createTime"/>
        <result column="LASTMODIFIER" property="lastModifier"/>
        <result column="LASTMODIFYTIME" property="lastModifyTime"/>
        <result column="REVISIONRULE" property="revisionRule"/>
        <result column="VERSIONRULE" property="versionRule"/>
        <result column="REVISIONSEQ" property="revisionSeq"/>
        <result column="REVISIONVALUE" property="revisionValue"/>
        <result column="VERSIONSEQ" property="versionSeq"/>
        <result column="VERSIONVALUE" property="versionValue"/>
        <result column="LCTID" property="lctid"/>
        <result column="LCSTATUS" property="lcStatus"/>
        <result column="TS" property="ts"/>
        <result column="ID" property="id"/>
        <result column="NAME" property="name"/>
        <result column="DESCRIPTION" property="description"/>
        <result column="OWNER" property="owner"/>
        <result column="COPYFROMVERSION" property="copyFromVersion"/>
        <result column="PARENTCODECLASSIFYOID" property="parentCodeClassifyOid"/>
        <result column="ORDERNUM" property="orderNum"/>
        <result column="BTMTYPEID" property="btmTypeId"/>
        <result column="BTMTYPENAME" property="btmTypeName"/>
        <result column="CODERULEOID" property="codeRuleOid"/>
        <result column="CODEKEYATTRREPEATOID" property="codeKeyAttrRepeatOid"/>
        <result column="CODERESEMBLERULEOID" property="codeResembleRuleOid"/>
    </resultMap>
    <select id="selectPlCodeClassifyPage" resultMap="plCodeClassifyResultMap">
        select * from PL_CODE_CLASSIFY where is_deleted = 0
    </select>
    <select id="selectAllLevelChildOid" resultType="java.util.HashMap">
        select oid, level
        from PL_CODE_CLASSIFY
                 START WITH parentCodeClassifyOid = #{oid} CONNECT BY
            PRIOR OID = parentCodeClassifyOid
    </select>
    <select id="checkHasChild" resultType="java.lang.Boolean">
        <![CDATA[select count(oid)
        from PL_CODE_CLASSIFY
        where parentCodeClassifyOid = #{oid}]]>
    </select>
    <select id="selectCodeClassifyVOByTree" resultMap="plCodeClassifyResultMap">
        select codeclassify0.OWNER                 as owner,
               codeclassify0.BTMTYPEID             as btmtypeid,
               codeclassify0.CREATOR               as creator,
               codeclassify0.CREATETIME            as createtime,
               codeclassify0.LASTMODIFIER          as lastmodifier,
               codeclassify0.DESCRIPTION           as description,
               codeclassify0.ORDERNUM              as ordernum,
               codeclassify0.CODERULEOID           as coderuleoid,
               codeclassify0.OID                   as oid,
               codeclassify0.BTMNAME               as btmname,
               codeclassify0.BTMTYPENAME           as btmtypename,
               codeclassify0.CODEKEYATTRREPEATOID  as codekeyattrrepeatoid,
               codeclassify0.PARENTCODECLASSIFYOID as parentcodeclassifyoid,
               codeclassify0.NAME                  as name,
               codeclassify0.LASTMODIFYTIME        as lastmodifytime,
               codeclassify0.ID                    as id,
               codeclassify0.CODERESEMBLERULEOID   as coderesembleruleoid,
               codeclassify0.LCSTATUS              as lcstatus,
               codeclassify0.TS                    as ts,
               coderuleoid.name                    as codeRuleOidName,
               codekeyattrrepeatoid.name           as codeKeyAttrRepeatOidName,
               coderesembleruleoid.name            as codeResembleRuleOidName
        from pl_code_classify codeclassify0
                 left join pl_code_rule coderuleoid
                           on codeclassify0.codeRuleOid = coderuleoid.oid
                 left join pl_code_keyattrrepeat codekeyattrrepeatoid
                           on codeclassify0.codeKeyAttrRepeatOid = codekeyattrrepeatoid.oid
                 left join pl_code_resemblerule coderesembleruleoid
                           on codeclassify0.codeResembleRuleOid = coderesembleruleoid.oid
        <where>
            <if test="oid != null and oid != ''">
                codeclassify0.parentcodeclassifyoid = '${oid}'
            </if>
            <if test="oid = null">
                codeclassify0.parentcodeclassifyoid is null
            </if>
        </where>
        order by id asc
    </select>
    <select id="selectAllLevelChildHasPath" resultMap="plCodeClassifyResultMap">
        select codeclassify0.OWNER as owner,
               codeclassify0.BTMTYPEID as btmtypeid,
               codeclassify0.CREATOR as creator,
               codeclassify0.CREATETIME as createtime,
               codeclassify0.LASTMODIFIER as lastmodifier,
               codeclassify0.DESCRIPTION as description,
               codeclassify0.ORDERNUM as ordernum,
               codeclassify0.CODERULEOID as coderuleoid,
               codeclassify0.OID as oid,
               codeclassify0.BTMNAME as btmname,
               codeclassify0.BTMTYPENAME as btmtypename,
               codeclassify0.CODEKEYATTRREPEATOID as codekeyattrrepeatoid,
               codeclassify0.PARENTCODECLASSIFYOID as parentcodeclassifyoid,
               codeclassify0.NAME as name,
               codeclassify0.LASTMODIFYTIME as lastmodifytime,
               codeclassify0.ID as id,
               codeclassify0.CODERESEMBLERULEOID as coderesembleruleoid,
               codeclassify0.LCSTATUS as lcstatus,
               codeclassify0.TS as ts,
               coderuleoid.name as codeRuleOidName,
               codekeyattrrepeatoid.name as codeKeyAttrRepeatOidName,
               coderesembleruleoid.name as codeResembleRuleOidName,
               level as datalevel,
               SYS_CONNECT_BY_PATH(codeclassify0.id, '#') as path
        from pl_code_classify codeclassify0
                 left join pl_code_rule coderuleoid
                           on codeclassify0.codeRuleOid = coderuleoid.oid
                 left join pl_code_keyattrrepeat codekeyattrrepeatoid
                           on codeclassify0.codeKeyAttrRepeatOid = codekeyattrrepeatoid.oid
                 left join pl_code_resemblerule coderesembleruleoid
                           on codeclassify0.codeResembleRuleOid = coderesembleruleoid.oid
            START WITH
            <if test="oid != null ">
                codeclassify0.parentCodeClassifyOid = '${oid}'
            </if>
            <if test="oid = null ">
                codeclassify0.parentCodeClassifyOid is null
            </if>
        CONNECT BY PRIOR codeclassify0.OID = codeclassify0.parentCodeClassifyOid
    </select>
    <select id="selectAllLevelParentByOid" resultType="java.util.HashMap">
        select oid,
               level from pl_code_classify start with oid= #{oid} connect by prior PARENTCODECLASSIFYOID = oid
    </select>
    <select id="selectByFieldNamePath"  resultMap="plCodeClassifyResultMap">
        select codeclassify0.OWNER                 as owner,
               codeclassify0.BTMTYPEID             as btmtypeid,
               codeclassify0.CREATOR               as creator,
               codeclassify0.CREATETIME            as createtime,
               codeclassify0.LASTMODIFIER          as lastmodifier,
               codeclassify0.DESCRIPTION           as description,
               codeclassify0.ORDERNUM              as ordernum,
               codeclassify0.CODERULEOID           as coderuleoid,
               codeclassify0.OID                   as oid,
               codeclassify0.BTMNAME               as btmname,
               codeclassify0.BTMTYPENAME           as btmtypename,
               codeclassify0.CODEKEYATTRREPEATOID  as codekeyattrrepeatoid,
               codeclassify0.PARENTCODECLASSIFYOID as parentcodeclassifyoid,
               codeclassify0.NAME                  as name,
               codeclassify0.LASTMODIFYTIME        as lastmodifytime,
               codeclassify0.ID                    as id,
               codeclassify0.CODERESEMBLERULEOID   as coderesembleruleoid,
               codeclassify0.LCSTATUS              as lcstatus,
               codeclassify0.TS                    as ts,
               codeclassify0.paths                 as paths
        from (select plcodeclassify.*,
                <choose>
                     <when test='fieldName=="name"'>
                         SUBSTR(SYS_CONNECT_BY_PATH(name, '##'),3)   as paths
                     </when>
                    <otherwise>
                        SUBSTR(SYS_CONNECT_BY_PATH(id, '##'),3)   as paths
                    </otherwise>
                </choose>
        from pl_code_classify  plcodeclassify
                  START WITH parentCodeClassifyOid is null
              CONNECT BY PRIOR OID = parentCodeClassifyOid) codeclassify0
        where codeclassify0.paths =#{fieldPath}
    </select>
    <select id="selectByFieldPath" resultType="java.util.HashMap">
        select *
        from (select oid, SYS_CONNECT_BY_PATH(id, '/') as paths
              from pl_code_classify
                       START WITH parentCodeClassifyOid is null
              CONNECT BY PRIOR OID = parentCodeClassifyOid) a
        where a.paths = #{fieldPath}
    </select>
    <select id="selectAllLevelParents" resultType="java.util.HashMap">
        select oid, id, name, btmtypeid, btmtypename
            from PL_CODE_CLASSIFY
            where btmtypeid is not null
                start with oid = #{oid}
            connect by prior PARENTCODECLASSIFYOID = oid
    </select>
</mapper>