123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 |
- <?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="com.diagbot.mapper.ConceptMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.diagbot.entity.Concept">
- <id column="id" property="id" />
- <result column="is_deleted" property="isDeleted" />
- <result column="gmt_create" property="gmtCreate" />
- <result column="gmt_modified" property="gmtModified" />
- <result column="creator" property="creator" />
- <result column="modifier" property="modifier" />
- <result column="lib_id" property="libId" />
- <result column="lib_name" property="libName" />
- <result column="lib_type" property="libType" />
- </resultMap>
- <select id="getConcept" resultType="com.diagbot.dto.ConceptRes" parameterType="com.diagbot.entity.wrapper.ConceptWrapper">
- SELECT
- t1.id AS startId,
- t1.lib_name AS startName,
- t3.id AS endId,
- t3.lib_name AS endName
- FROM
- `kl_concept` t1,
- `kl_relation` t2,
- <if test="startSex != null or startAge != null">
- kl_concept_common c1,
- </if>
- <if test="endSex != null or endAge != null">
- kl_concept_common c2,
- </if>
- `kl_concept` t3
- WHERE
- t1.is_deleted = 'N'
- AND t2.is_deleted = 'N'
- AND t3.is_deleted = 'N'
- AND t1.id = t2.start_id
- AND t3.id = t2.end_id
- <if test="startId != null">
- AND t2.start_id = #{startId}
- </if>
- <if test="startName != null and startName != ''">
- AND t1.lib_name = #{startName}
- </if>
- <if test="startSex != null or startAge != null">
- AND c1.is_deleted = 'N'
- <if test="startSex != null">
- <if test="startSex == 3">
- and c1.sex_type in ('1','2','3')
- </if>
- <if test="startSex != 3">
- and c1.sex_type in ('3',#{startSex})
- </if>
- </if>
- <if test="startAge != null">
- <![CDATA[ AND c1.min_age <= #{startAge} ]]>
- <![CDATA[ AND c1.max_age >= #{startAge} ]]>
- </if>
- AND t2.start_id = c1.concept_id
- </if>
- <if test="startType != null">
- AND t1.lib_type = #{startType}
- </if>
- <if test="relationType != null">
- AND t2.relation_id = #{relationType}
- </if>
- <if test="endId != null">
- AND t2.end_id = #{endId}
- </if>
- <if test="endName != null and endName != ''">
- AND t3.lib_name = #{endName}
- </if>
- <if test="endSex != null or endAge != null">
- AND c2.is_deleted = 'N'
- <if test="endSex != null">
- <if test="endSex == 3">
- and c2.sex_type in ('1','2','3')
- </if>
- <if test="endSex != 3">
- and c2.sex_type in ('3',#{endSex})
- </if>
- </if>
- <if test="endAge != null">
- <![CDATA[ AND c2.min_age <= #{endAge} ]]>
- <![CDATA[ AND c2.max_age >= #{endAge} ]]>
- </if>
- AND t2.end_id = c2.concept_id
- </if>
- <if test="endType != null">
- AND t3.lib_type = #{endType}
- </if>
- </select>
- <select id="getConceptWithOrder" resultType="com.diagbot.dto.ConceptWithOrderRes" parameterType="com.diagbot.entity.wrapper.ConceptWrapper">
- SELECT
- t1.id AS startId,
- t1.lib_name AS startName,
- t3.id AS endId,
- t3.lib_name AS endName,
- t4.order_no AS orderNo
- FROM
- `kl_concept` t1,
- `kl_relation` t2,
- <if test="startSex != null or startAge != null">
- kl_concept_common c1,
- </if>
- <if test="endSex != null or endAge != null">
- kl_concept_common c2,
- </if>
- `kl_concept` t3,
- `kl_relation_order` t4
- WHERE
- t1.is_deleted = 'N'
- AND t2.is_deleted = 'N'
- AND t3.is_deleted = 'N'
- AND t4.is_deleted = 'N'
- AND t1.id = t2.start_id
- AND t3.id = t2.end_id
- AND t2.id = t4.t_relation_id
- <if test="startId != null">
- AND t2.start_id = #{startId}
- </if>
- <if test="startName != null and startName != ''">
- AND t1.lib_name = #{startName}
- </if>
- <if test="startSex != null or startAge != null">
- AND c1.is_deleted = 'N'
- <if test="startSex != null">
- <if test="startSex == 3">
- and c1.sex_type in ('1','2','3')
- </if>
- <if test="startSex != 3">
- and c1.sex_type in ('3',#{startSex})
- </if>
- </if>
- <if test="startAge != null">
- <![CDATA[ AND c1.min_age <= #{startAge} ]]>
- <![CDATA[ AND c1.max_age >= #{startAge} ]]>
- </if>
- AND t2.start_id = c1.concept_id
- </if>
- <if test="startNameList != null and startNameList.size() > 0">
- AND t1.lib_name in
- <foreach collection="startNameList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="startType != null">
- AND t1.lib_type = #{startType}
- </if>
- <if test="relationType != null">
- AND t2.relation_id = #{relationType}
- </if>
- <if test="endId != null">
- AND t2.end_id = #{endId}
- </if>
- <if test="endName != null and endName != ''">
- AND t3.lib_name = #{endName}
- </if>
- <if test="endSex != null or endAge != null">
- AND c2.is_deleted = 'N'
- <if test="endSex != null">
- <if test="endSex == 3">
- and c2.sex_type in ('1','2','3')
- </if>
- <if test="endSex != 3">
- and c2.sex_type in ('3',#{endSex})
- </if>
- </if>
- <if test="endAge != null">
- <![CDATA[ AND c2.min_age <= #{endAge} ]]>
- <![CDATA[ AND c2.max_age >= #{endAge} ]]>
- </if>
- AND t2.end_id = c2.concept_id
- </if>
- <if test="endNameList != null and endNameList.size() > 0">
- AND t3.lib_name in
- <foreach collection="endNameList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="endType != null">
- AND t3.lib_type = #{endType}
- </if>
- ORDER BY t4.order_no
- </select>
- <select id="retrievalConcept" resultType="com.diagbot.dto.ConceptRetrievalDTO">
- SELECT a1.* from (
- (SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
- LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
- LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
- LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
- <if test="isStatic != null and isStatic == 1">
- LEFT JOIN kl_concept_detail t7 ON t7.concept_id = t1.id
- </if>
- WHERE
- t1.is_deleted = 'N'
- AND t2.is_deleted = 'N'
- AND t6.is_deleted = 'N'
- <if test="isStatic != null and isStatic == 1">
- AND t7.is_deleted = 'N'
- </if>
- <if test="type != null">
- AND t1.lib_type = #{type}
- </if>
- <if test="otherType != null and otherType.size > 0">
- and t1.lib_type in
- <foreach item="type" collection="otherType" open="(" separator="," close=")">
- #{type}
- </foreach>
- </if>
- <if test="sexType == 3">
- and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
- </if>
- <if test="sexType != 3">
- and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
- </if>
- <if test="age != null and age != ''">
- AND (( <![CDATA[ t3.min_age <= #{age} ]]>
- AND <![CDATA[ t3.max_age >= #{age} ]]>)
- or (t3.min_age is null and t3.max_age is null))
- </if>
- <if test="inputIds != null and inputIds.size > 0">
- and t1.id not in
- <foreach item="id" collection="inputIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- AND (t2.spell = UPPER(#{InputStr}) OR t2.name = #{InputStr})
- <if test="isStatic != null and isStatic == 1">
- GROUP BY t1.id
- </if>
- <if test="isStatic == null or isStatic != 1">
- LIMIT 100
- </if>)
- UNION
- (SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
- LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
- LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
- LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
- <if test="isStatic != null and isStatic == 1">
- LEFT JOIN kl_concept_detail t7 ON t7.concept_id = t1.id
- </if>
- WHERE
- t1.is_deleted = 'N'
- AND t2.is_deleted = 'N'
- AND t6.is_deleted = 'N'
- <if test="isStatic != null and isStatic == 1">
- AND t7.is_deleted = 'N'
- </if>
- <if test="type != null">
- AND t1.lib_type = #{type}
- </if>
- <if test="otherType != null and otherType.size > 0">
- and t1.lib_type in
- <foreach item="type" collection="otherType" open="(" separator="," close=")">
- #{type}
- </foreach>
- </if>
- <if test="sexType == 3">
- and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
- </if>
- <if test="sexType != 3">
- and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
- </if>
- <if test="age != null and age != ''">
- AND (( <![CDATA[ t3.min_age <= #{age} ]]>
- AND <![CDATA[ t3.max_age >= #{age} ]]>)
- or (t3.min_age is null and t3.max_age is null))
- </if>
- <if test="inputIds != null and inputIds.size > 0">
- and t1.id not in
- <foreach item="id" collection="inputIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- AND (t2.spell LIKE CONCAT( UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
- <if test="isStatic != null and isStatic == 1">
- GROUP BY t1.id
- </if>
- <if test="isStatic == null or isStatic != 1">
- LIMIT 100
- </if>)
- UNION
- (SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
- LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
- LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
- LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
- <if test="isStatic != null and isStatic == 1">
- LEFT JOIN kl_concept_detail t7 ON t7.concept_id = t1.id
- </if>
- WHERE
- t1.is_deleted = 'N'
- AND t2.is_deleted = 'N'
- AND t6.is_deleted = 'N'
- <if test="isStatic != null and isStatic == 1">
- AND t7.is_deleted = 'N'
- </if>
- <if test="type != null">
- AND t1.lib_type = #{type}
- </if>
- <if test="otherType != null and otherType.size > 0">
- and t1.lib_type in
- <foreach item="type" collection="otherType" open="(" separator="," close=")">
- #{type}
- </foreach>
- </if>
- <if test="sexType == 3">
- and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
- </if>
- <if test="sexType != 3">
- and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
- </if>
- <if test="age != null and age != ''">
- AND (( <![CDATA[ t3.min_age <= #{age} ]]>
- AND <![CDATA[ t3.max_age >= #{age} ]]>)
- or (t3.min_age is null and t3.max_age is null))
- </if>
- <if test="inputIds != null and inputIds.size > 0">
- and t1.id not in
- <foreach item="id" collection="inputIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- AND (t2.spell LIKE CONCAT('%',UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
- <if test="isStatic != null and isStatic == 1">
- GROUP BY t1.id
- </if>
- <if test="isStatic == null or isStatic != 1">
- LIMIT 100
- </if>)
- <if test="detilType != null and detilType != ''">
- UNION
- (SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t5.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
- LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
- LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
- LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
- LEFT JOIN kl_concept t5 on t5.id = t4.start_id
- LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
- <if test="isStatic != null and isStatic == 1">
- LEFT JOIN kl_concept_detail t7 ON t7.concept_id = t5.id
- </if>
- WHERE
- t1.is_deleted = 'N'
- AND t2.is_deleted = 'N'
- AND t4.is_deleted = 'N'
- AND t5.is_deleted = 'N'
- AND t6.is_deleted = 'N'
- <if test="isStatic != null and isStatic == 1">
- AND t7.is_deleted = 'N'
- </if>
- <if test="detilType != null">
- AND t1.lib_type = #{detilType}
- </if>
- <if test="sexType == 3">
- and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
- </if>
- <if test="sexType != 3">
- and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
- </if>
- <if test="age != null and age != ''">
- AND (( <![CDATA[ t3.min_age <= #{age} ]]>
- AND <![CDATA[ t3.max_age >= #{age} ]]>)
- or (t3.min_age is null and t3.max_age is null))
- </if>
- AND (t2.spell = UPPER(#{InputStr}) OR t2.name = #{InputStr})
- <if test="inputIds != null and inputIds.size > 0">
- and t1.id not in
- <foreach item="id" collection="inputIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- AND t4.relation_id = 18
- <if test="isStatic != null and isStatic == 1">
- GROUP BY t5.id
- </if>
- <if test="isStatic == null or isStatic != 1">
- LIMIT 100
- </if>)
- UNION
- (SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t5.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
- LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
- LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
- LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
- LEFT JOIN kl_concept t5 on t5.id = t4.start_id
- LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
- <if test="isStatic != null and isStatic == 1">
- LEFT JOIN kl_concept_detail t7 ON t7.concept_id = t5.id
- </if>
- WHERE
- t1.is_deleted = 'N'
- AND t2.is_deleted = 'N'
- AND t4.is_deleted = 'N'
- AND t5.is_deleted = 'N'
- AND t6.is_deleted = 'N'
- <if test="isStatic != null and isStatic == 1">
- AND t7.is_deleted = 'N'
- </if>
- <if test="detilType != null">
- AND t1.lib_type = #{detilType}
- </if>
- <if test="sexType == 3">
- and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
- </if>
- <if test="sexType != 3">
- and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
- </if>
- <if test="age != null and age != ''">
- AND (( <![CDATA[ t3.min_age <= #{age} ]]>
- AND <![CDATA[ t3.max_age >= #{age} ]]>)
- or (t3.min_age is null and t3.max_age is null))
- </if>
- AND (t2.spell LIKE CONCAT(UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
- <if test="inputIds != null and inputIds.size > 0">
- and t1.id not in
- <foreach item="id" collection="inputIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="isStatic != null and isStatic == 1">
- GROUP BY t5.id
- </if>
- AND t4.relation_id = 18
- <if test="isStatic == null or isStatic != 1">
- LIMIT 100
- </if>)
- UNION
- (SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t5.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
- LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
- LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
- LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
- LEFT JOIN kl_concept t5 on t5.id = t4.start_id
- LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
- <if test="isStatic != null and isStatic == 1">
- LEFT JOIN kl_concept_detail t7 ON t7.concept_id = t5.id
- </if>
- WHERE
- t1.is_deleted = 'N'
- AND t2.is_deleted = 'N'
- AND t4.is_deleted = 'N'
- AND t5.is_deleted = 'N'
- AND t6.is_deleted = 'N'
- <if test="isStatic != null and isStatic == 1">
- AND t7.is_deleted = 'N'
- </if>
- <if test="detilType != null">
- AND t1.lib_type = #{detilType}
- </if>
- <if test="sexType == 3">
- and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
- </if>
- <if test="sexType != 3">
- and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
- </if>
- <if test="age != null and age != ''">
- AND (( <![CDATA[ t3.min_age <= #{age} ]]>
- AND <![CDATA[ t3.max_age >= #{age} ]]>)
- or (t3.min_age is null and t3.max_age is null))
- </if>
- AND (t2.spell LIKE CONCAT('%',UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
- <if test="inputIds != null and inputIds.size > 0">
- and t1.id not in
- <foreach item="id" collection="inputIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="isStatic != null and isStatic == 1">
- GROUP BY t5.id
- </if>
- AND t4.relation_id = 18
- <if test="isStatic == null or isStatic != 1">
- LIMIT 100
- </if>)
- </if>
- ) a1
- <if test="isStatic == null or isStatic != 1">
- LIMIT 100
- </if>
- </select>
- </mapper>
|