Browse Source

人体分诊图关系查询修改

rengb 5 years ago
parent
commit
6de70a7bb5

+ 7 - 0
knowledgeman-service/src/main/java/com/diagbot/vo/OnlyByRootListVO.java

@@ -41,6 +41,13 @@ public class OnlyByRootListVO extends Page {
     @ApiModelProperty(value="关系类型id")
     private Long relationId;
 
+    /**
+     * 仅有根时是否列出,1-是,0-否
+     */
+    @ApiModelProperty(value="仅有根时是否列出,1-是,0-否")
+    private Integer isOnlyHasRoot = 1;
+
+
     
     
 }

+ 46 - 2
knowledgeman-service/src/main/resources/mapper/RelationMapper.xml

@@ -143,7 +143,7 @@
     </select>
     
     <select id="onlyByRootList" resultType="com.diagbot.dto.OnlyByRootListDTO">
-    	SELECT
+    	<!--SELECT
 		c.id AS conceptId,
 		c.lib_name AS libName,
 		c.lib_type AS libTypeId,
@@ -171,7 +171,51 @@
 		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
+		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>