123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- <?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="getAllLisConcept" parameterType="com.diagbot.vo.GetAllLisConceptVO" resultType="com.diagbot.dto.GetAllLisConceptDTO">
- SELECT
- conceptName
- FROM
- ((SELECT
- lib_name as conceptName
- FROM kl_concept
- WHERE is_deleted='N' AND lib_type=12
- ORDER BY gmt_modified DESC)
- UNION
- (SELECT
- CONCAT(t1.conceptName,'-',t3.conceptName) as conceptName
- FROM
- (SELECT
- id as conceptId,
- lib_name as conceptName
- FROM kl_concept
- WHERE is_deleted='N' AND lib_type=12) t1
- JOIN
- kl_relation t2
- ON t1.conceptId=t2.end_id
- JOIN
- (SELECT
- id as conceptId,
- lib_name as conceptName
- FROM kl_concept
- WHERE is_deleted='N' AND lib_type=13) t3
- ON t2.start_id=t3.conceptId
- LEFT JOIN kl_relation_order t4
- ON t2.id=t4.t_relation_id
- WHERE t2.is_deleted='N' AND t2.relation_id=3
- ORDER BY t4.order_no DESC)) t
- WHERE 1=1
- <if test="conceptName!=null and conceptName!=''">
- and (conceptName LIKE CONCAT('%',#{conceptName},'%'))
- </if>
- <if test="excludedConceptNames!=null and excludedConceptNames.size>0">
- and (conceptName not in
- <foreach collection="excludedConceptNames" open="(" close=")" separator="," item="excludedConceptName">
- #{excludedConceptName}
- </foreach>
- )
- </if>
- </select>
- <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="index" resultType="com.diagbot.dto.ConceptBaseDTO">
- SELECT b.id conceptId, b.lib_name name
- FROM `kl_library_info` a, kl_concept b
- where b.is_deleted = 'N' and a.is_deleted = 'N' and a.concept_id = b.id and a.is_concept = 1
- <if test="libType != null">
- and b.lib_type = #{libType}
- </if>
- and (a.name like concat('%',#{name},'%')
- or a.spell like concat('%',#{name},'%'))
- </select>
- </mapper>
|