123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- <?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.RelationMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.diagbot.entity.Relation">
- <id column="id" property="id" />
- <result column="is_deleted" property="isDeleted" />
- <result column="gmt_created" property="gmtCreated" />
- <result column="gmt_modified" property="gmtModified" />
- <result column="creator" property="creator" />
- <result column="modifier" property="modifier" />
- <result column="start_id" property="startId" />
- <result column="relation_id" property="relationId" />
- <result column="end_id" property="endId" />
- </resultMap>
-
- <select id="getRelationInfoList" resultType="com.diagbot.dto.GetRelationInfoListDTO">
- SELECT * FROM
- (SELECT
- a.id,
- b.id AS startId,
- b.lib_name AS startName,
- (SELECT `name` FROM kl_lexicon WHERE id=b.lib_type) AS startType,
- c.id AS endId,
- c.lib_name AS endName,
- (SELECT `name` FROM kl_lexicon WHERE id=c.lib_type) AS endType,
- a.relation_id as relationId,
- (SELECT name FROM kl_lexicon_relationship where id=a.relation_id and is_deleted='N') as relationName,
- a.gmt_modified as operTime,
- a.modifier as operName,
- a.is_deleted as isDeleted
- FROM kl_relation a
- JOIN kl_concept b on a.start_id=b.id
- JOIN kl_concept c on a.end_id=c.id
- WHERE a.relation_id NOT IN(17,18)
- and b.is_deleted='N'
- and c.is_deleted='N') t
- where 1=1
- <if test="isDeleted!=null and isDeleted!=''">
- and isDeleted=#{isDeleted}
- </if>
- <if test="relationId!=null">
- and relationId=#{relationId}
- </if>
- <if test="startName!=null and startName!=''">
- and startName like concat('%',#{startName},'%')
- </if>
- <if test="endName!=null and endName!=''">
- and endName like concat('%',#{endName},'%')
- </if>
- ORDER BY isDeleted asc, operTime desc
- </select>
-
- <select id="getRelationNodeDTOs" resultType="com.diagbot.dto.RelationNodeDTO">
- SELECT
- d.id AS conceptId,
- d.lib_name AS conceptName,
- d.lib_type AS conceptTypeId,
- d.is_deleted AS isDeletedConcept,
- c.id AS parentConceptId,
- c.lib_name AS parentConceptName,
- c.lib_type AS parentConceptTypeId,
- e.id AS relationId,
- e.`name` AS relationName
- FROM kl_relation a LEFT JOIN kl_relation_order b ON a.id=b.t_relation_id
- JOIN kl_concept c ON a.start_id=c.id
- JOIN kl_concept d ON a.end_id=d.id
- JOIN kl_lexicon_relationship e ON a.relation_id=e.id
- WHERE 1=1
- AND a.is_deleted='N'
- AND e.is_deleted='N'
- AND a.start_id=#{conceptId}
- <if test="relationId!=null">
- AND a.relation_id=#{relationId}
- </if>
- <if test="endTypeId!=null">
- AND d.lib_type=#{endTypeId}
- </if>
- ORDER BY b.order_no ASC,a.gmt_modified DESC
- </select>
-
- <select id="lisSonContactList" resultType="com.diagbot.dto.LisSonContactListDTO">
- SELECT
- *
- FROM
- (SELECT
- t2.id AS conceptId,
- t2.lib_name AS libName,
- t4.name AS libType,
- CONCAT(t2.lib_name,'(',t4.name,')') AS libNameType,
- GROUP_CONCAT(t3.lib_name ORDER BY t5.order_no DESC,t1.gmt_modified DESC) AS otherNames,
- t1.modifier AS operName,
- MAX(t1.gmt_modified) AS operTime,
- t1.is_deleted AS isDeleted
- FROM kl_relation t1
- JOIN kl_concept t2 ON t1.start_id=t2.id
- JOIN kl_concept t3 ON t1.end_id=t3.id
- JOIN kl_lexicon t4 ON t3.lib_type=t4.id
- LEFT JOIN kl_relation_order t5 ON t1.id=t5.t_relation_id
- WHERE t2.is_deleted='N' AND t3.is_deleted='N' AND t4.is_deleted='N'
- AND t1.relation_id=18
- AND t2.lib_type = 12
- AND t3.lib_type = 13
- GROUP BY t2.id) tab
- where 1=1
- <if test="name!=null and name!=''">
- and libName like concat('%',#{name},'%')
- </if>
- ORDER BY isDeleted ASC,operTime DESC
- </select>
-
- <select id="singleRelationList" resultType="com.diagbot.dto.SingleRelationListDTO">
- SELECT
- d.id AS conceptId,
- d.lib_name AS libName,
- d.lib_type AS libTypeId,
- CONCAT(d.lib_type,"101",e.lib_type) AS relationModelTypeCode,
- GROUP_CONCAT(e.lib_name ORDER BY f.order_no ASC) AS otherNames,
- a.modifier AS operName,
- a.gmt_modified AS operTime,
- a.is_deleted AS isDeleted
- FROM
- (SELECT id,is_deleted,gmt_modified,modifier,start_id,end_id FROM kl_relation WHERE relation_id=#{relationId} AND is_deleted='N') a
- LEFT JOIN
- (SELECT end_id FROM kl_relation WHERE relation_id=#{relationId} AND is_deleted='N') b
- ON a.start_id=b.end_id
- LEFT JOIN
- (SELECT start_id FROM kl_relation WHERE relation_id=#{relationId} AND is_deleted='N') c
- ON a.end_id=c.start_id
- JOIN
- (SELECT id,lib_name,lib_type FROM kl_concept WHERE is_deleted='N' AND lib_type=#{startTypeId}
- <if test="name!=null and name!=''">
- AND lib_name LIKE CONCAT("%",#{name},"%")
- </if>
- ) d
- ON a.start_id=d.id
- JOIN
- (SELECT id,lib_name,lib_type FROM kl_concept WHERE lib_type=#{endTypeId}) e
- ON a.end_id=e.id
- LEFT JOIN kl_relation_order f ON a.id=f.t_relation_id
- WHERE b.end_id IS NULL AND c.start_id IS NULL
- GROUP BY d.id
- ORDER BY operTime DESC
- </select>
-
- <select id="onlyByRootList" resultType="com.diagbot.dto.OnlyByRootListDTO">
- <!--SELECT
- c.id AS conceptId,
- c.lib_name AS libName,
- c.lib_type AS libTypeId,
- GROUP_CONCAT(d.lib_name ORDER BY e.order_no ASC) AS otherNames,
- a.modifier AS operName,
- a.gmt_modified AS operTime,
- a.is_deleted AS isDeleted
- FROM
- (SELECT id,is_deleted,gmt_modified,modifier,start_id,end_id FROM kl_relation WHERE relation_id=#{relationId} AND is_deleted='N') a
- LEFT JOIN
- (SELECT end_id FROM kl_relation WHERE relation_id=#{relationId} AND is_deleted='N') b
- ON a.start_id=b.end_id
- JOIN
- (SELECT id,lib_name,lib_type FROM kl_concept WHERE is_deleted='N'
- AND lib_type in
- <foreach collection="startTypeIds" open="(" close=")" separator="," item="startTypeId">
- #{startTypeId}
- </foreach>
- <if test="name!=null and name!=''">
- AND lib_name LIKE CONCAT("%",#{name},"%")
- </if>
- ) c
- ON a.start_id=c.id
- JOIN kl_concept d ON a.end_id=d.id
- LEFT JOIN kl_relation_order e ON a.id=e.t_relation_id
- WHERE b.end_id IS NULL
- GROUP BY c.id
- ORDER BY operTime DESC-->
- SELECT
- t2.id AS conceptId,
- t2.lib_name AS libName,
- t2.lib_type AS libTypeId,
- GROUP_CONCAT(t3.lib_name ORDER BY t1.order_no ASC) AS otherNames,
- t1.modifier AS operName,
- t1.gmt_modified AS operTime,
- t1.is_deleted AS isDeleted
- FROM
- (
- SELECT
- a.*,c.order_no
- FROM
- (SELECT id,is_deleted,gmt_modified,modifier,start_id,end_id FROM kl_relation WHERE relation_id=#{relationId} AND is_deleted='N') a
- LEFT JOIN
- (SELECT end_id FROM kl_relation WHERE relation_id=#{relationId} AND is_deleted='N') b
- ON a.start_id=b.end_id
- LEFT JOIN kl_relation_order c ON a.id=c.t_relation_id
- WHERE b.end_id IS NULL
- ) t1
- <if test="isOnlyHasRoot==1">
- RIGHT
- </if>
- JOIN
- (
- SELECT id,lib_name,lib_type
- FROM kl_concept
- WHERE is_deleted='N'
- AND lib_type in
- <foreach collection="startTypeIds" open="(" close=")" separator="," item="startTypeId">
- #{startTypeId}
- </foreach>
- <if test="name!=null and name!=''">
- AND lib_name LIKE CONCAT("%",#{name},"%")
- </if>
- ) t2
- ON t1.start_id=t2.id
- <if test="isOnlyHasRoot==1">
- LEFT
- </if>
- JOIN
- kl_concept t3 ON t1.end_id=t3.id
- GROUP BY t2.id
- ORDER BY t1.gmt_modified DESC,t2.id DESC
- </select>
- <select id="pacsSonContactList" resultType="com.diagbot.dto.PacsSonContactListDTO">
- SELECT
- *
- FROM
- (SELECT
- t2.id AS conceptId,
- t2.lib_name AS libName,
- t4.name AS libType,
- CONCAT(t2.lib_name,'(',t4.name,')') AS libNameType,
- GROUP_CONCAT(t3.lib_name ORDER BY t5.order_no DESC,t1.gmt_modified DESC) AS otherNames,
- t1.modifier AS operName,
- MAX(t1.gmt_modified) AS operTime,
- t1.is_deleted AS isDeleted
- FROM kl_relation t1
- JOIN kl_concept t2 ON t1.start_id=t2.id
- JOIN kl_concept t3 ON t1.end_id=t3.id
- JOIN kl_lexicon t4 ON t3.lib_type=t4.id
- LEFT JOIN kl_relation_order t5 ON t1.id=t5.t_relation_id
- WHERE t2.is_deleted='N' AND t3.is_deleted='N' AND t4.is_deleted='N'
- AND t1.relation_id=18
- AND t2.lib_type = 16
- AND t3.lib_type = 16
- GROUP BY t2.id) tab
- where 1=1
- <if test="name!=null and name!=''">
- and libName like concat('%',#{name},'%')
- </if>
- ORDER BY isDeleted ASC,operTime DESC
- </select>
- </mapper>
|