فهرست منبع

检索结果去重,最终结果只留一个

wangyu 6 سال پیش
والد
کامیت
aba8ceebc6

+ 1 - 0
aipt-service/src/main/java/com/diagbot/facade/ConceptFacade.java

@@ -295,6 +295,7 @@ public class ConceptFacade extends ConceptServiceImpl {
         RetrievalVO retrievalVO = new RetrievalVO();
         RetrievalDTO retrievalDTO = new RetrievalDTO();
         BeanUtil.copyProperties(getStaticKnowledgeVO,retrievalVO);
+        retrievalVO.setIsStatic(1);
         List<Integer> types = new ArrayList<>();
         for (Integer type : getStaticKnowledgeVO.getTypes()) {
             types.add(ParamConvertUtil.conceptConvert2Lib(type));

+ 2 - 0
aipt-service/src/main/java/com/diagbot/vo/RetrievalVO.java

@@ -25,4 +25,6 @@ public class RetrievalVO {
     private Integer detilType;
     //类型为其他史时用到的type类型
     private List<Integer> otherType;
+    //是否是静态搜索
+    private Integer isStatic;
 }

+ 75 - 7
aipt-service/src/main/resources/mapper/ConceptMapper.xml

@@ -192,10 +192,16 @@
         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>
@@ -223,16 +229,27 @@
             </foreach>
         </if>
         AND (t2.spell =  UPPER(#{InputStr}) OR t2.name =  #{InputStr})
-        LIMIT 100)
+        <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>
@@ -260,16 +277,27 @@
             </foreach>
         </if>
         AND (t2.spell LIKE CONCAT( UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
-        LIMIT 100)
+        <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>
@@ -297,7 +325,12 @@
             </foreach>
         </if>
         AND (t2.spell LIKE CONCAT('%',UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
-        LIMIT 100)
+        <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
@@ -306,12 +339,18 @@
             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>
@@ -334,7 +373,12 @@
                 </foreach>
             </if>
             AND t4.relation_id = 18
-            LIMIT 100)
+            <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
@@ -342,12 +386,18 @@
             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>
@@ -369,8 +419,13 @@
                     #{id}
                 </foreach>
             </if>
+            <if test="isStatic != null and isStatic == 1">
+                GROUP BY t5.id
+            </if>
             AND t4.relation_id = 18
-            LIMIT 100)
+            <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
@@ -378,12 +433,18 @@
             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>
@@ -405,10 +466,17 @@
                     #{id}
                 </foreach>
             </if>
+            <if test="isStatic != null and isStatic == 1">
+                GROUP BY t5.id
+            </if>
             AND t4.relation_id = 18
-            LIMIT 100)
+            <if test="isStatic == null or isStatic != 1">
+                LIMIT 100
+            </if>)
         </if>
         ) a1
-        LIMIT 100
+        <if test="isStatic == null or isStatic != 1">
+            LIMIT 100
+        </if>
     </select>
 </mapper>