123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <?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) 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
- c.id AS conceptId,
- c.lib_name AS conceptName,
- d.id AS parentConceptId,
- d.lib_name AS parentConceptName,
- 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 b.is_deleted='N'
- AND c.is_deleted='N'
- AND d.is_deleted='N'
- AND e.is_deleted='N'
- AND a.end_id=#{conceptId}
- <if test="relationId!=null">
- AND a.relation_id=#{relationId}
- </if>
- ORDER BY b.order_no DESC,a.id ASC
- </select>
-
- <select id="relationContactList" resultType="com.diagbot.dto.RelationContactListDTO">
- SELECT
- *
- FROM
- (SELECT
- t3.id AS conceptId,
- t3.lib_name AS libName,
- t4.name AS libType,
- CONCAT(t3.lib_name,'(',t4.name,')') AS libNameType,
- GROUP_CONCAT(t2.lib_name ORDER BY t1.gmt_modified DESC) AS otherNames,
- t1.modifier AS operName,
- MAX(t1.gmt_modified) AS operTime,
- t1.is_deleted AS isDeleted
- FROM
- (SELECT
- a.*
- FROM
- (SELECT * FROM kl_relation WHERE relation_id=17) a
- LEFT JOIN kl_relation_order b ON a.id=b.t_relation_id
- LEFT JOIN (SELECT * FROM kl_relation WHERE relation_id=17) c
- ON a.start_id=c.end_id
- LEFT JOIN (SELECT * FROM kl_relation WHERE relation_id=17) d
- ON a.end_id=d.start_id
- WHERE b.id IS NULL AND c.id IS NULL AND d.id IS NULL) 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
- where t2.is_deleted='N' AND t3.is_deleted='N' AND t4.is_deleted='N'
- GROUP BY t3.id) tab
- where 1=1
- <if test="name!=null and name!=''">
- and libNameType like concat('%',#{name},'%')
- </if>
- ORDER BY isDeleted ASC,operTime DESC
- </select>
-
- <select id="multContactList" resultType="com.diagbot.dto.MultContactListDTO">
- SELECT
- *
- FROM
- (SELECT
- t3.id AS conceptId,
- t3.lib_name AS libName,
- t4.name AS libType,
- CONCAT(t3.lib_name,'(',t4.name,')') AS libNameType,
- GROUP_CONCAT(t2.lib_name ORDER BY t1.gmt_modified DESC) AS otherNames,
- t1.modifier AS operName,
- MAX(t1.gmt_modified) AS operTime,
- t1.is_deleted AS isDeleted
- FROM
- (SELECT
- a.*
- FROM
- (SELECT * FROM kl_relation WHERE relation_id=17) a
- JOIN kl_relation_order b ON a.id=b.t_relation_id
- LEFT JOIN (SELECT * FROM kl_relation WHERE relation_id=17) c
- ON a.end_id=c.start_id
- WHERE c.id IS NULL) 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
- where t2.is_deleted='N' AND t3.is_deleted='N' AND t4.is_deleted='N'
- GROUP BY t3.id) tab
- where 1=1
- <if test="name!=null and name!=''">
- and libNameType like concat('%',#{name},'%')
- </if>
- ORDER BY isDeleted ASC,operTime DESC
- </select>
-
- <select id="lisSonContactList" resultType="com.diagbot.dto.LisSonContactListDTO">
- SELECT
- *
- FROM
- (SELECT
- t3.id AS conceptId,
- t3.lib_name AS libName,
- t4.name AS libType,
- CONCAT(t3.lib_name,'(',t4.name,')') AS libNameType,
- GROUP_CONCAT(t2.lib_name ORDER BY 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
- WHERE t2.is_deleted='N' AND t3.is_deleted='N' AND t4.is_deleted='N'
- AND t1.relation_id=18
- GROUP BY t3.id) tab
- where 1=1
- <if test="name!=null and name!=''">
- and libNameType like concat('%',#{name},'%')
- </if>
- ORDER BY isDeleted ASC,operTime DESC
- </select>
-
- </mapper>
|