Browse Source

别名和静态知识检索

gaodm 6 years ago
parent
commit
01e1f093bf

+ 43 - 35
aipt-service/src/main/java/com/diagbot/facade/ConceptFacade.java

@@ -14,6 +14,7 @@ import com.diagbot.enums.LexiconTypeEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.ConceptServiceImpl;
+import com.diagbot.util.ArrayUtil;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.IntegerUtil;
 import com.diagbot.util.ListUtil;
@@ -27,6 +28,7 @@ import com.diagbot.vo.ConceptUsualVO;
 import com.diagbot.vo.ExistListByConceptIdsVO;
 import com.diagbot.vo.GetStaticKnowledgeVO;
 import com.diagbot.vo.RetrievalVO;
+import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -115,16 +117,16 @@ public class ConceptFacade extends ConceptServiceImpl {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "术语列表不能为空");
         }
 
-        if (IntegerUtil.isNull(conceptFindVO.getAge())){
+        if (IntegerUtil.isNull(conceptFindVO.getAge())) {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "年龄不能为空");
         }
 
-        if (IntegerUtil.isNull(conceptFindVO.getSexType())){
+        if (IntegerUtil.isNull(conceptFindVO.getSexType())) {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "性别不能为空");
         }
 
         //获取结构
-        List<ConceptBaseDTO>  concepts
+        List<ConceptBaseDTO> concepts
                 = this.getConceptConMap(conceptFindVO);
 
         //出参封装
@@ -260,14 +262,14 @@ public class ConceptFacade extends ConceptServiceImpl {
      * @param retrievalVO
      * @return
      */
-    public List<ConceptRetrievalDTO> retrivelConceptInfo(RetrievalVO retrievalVO){
+    public List<ConceptRetrievalDTO> retrivelConceptInfo(RetrievalVO retrievalVO) {
         Boolean bla = true;
-        if (null != retrievalVO.getType()){
-            if(retrievalVO.getType().intValue() == ConceptTypeEnum.Lis.getKey()){//如果是化验,添加化验子项类型
+        if (null != retrievalVO.getType()) {
+            if (retrievalVO.getType().intValue() == ConceptTypeEnum.Lis.getKey()) {//如果是化验,添加化验子项类型
                 retrievalVO.setDetilType(LexiconTypeEnum.LIS_DETAILS.getKey());
                 bla = true;
-            }else if(retrievalVO.getType().intValue() == ConceptTypeEnum.Past.getKey()
-                    || retrievalVO.getType().intValue() == ConceptTypeEnum.Other.getKey()){//如果是其他史设置其他史类型
+            } else if (retrievalVO.getType().intValue() == ConceptTypeEnum.Past.getKey()
+                    || retrievalVO.getType().intValue() == ConceptTypeEnum.Other.getKey()) {//如果是其他史设置其他史类型
                 List<Integer> typeList = new ArrayList<>();
                 typeList.add(LexiconTypeEnum.HISTORY_OF_PAST_DISEASES.getKey());
                 typeList.add(LexiconTypeEnum.HISTORY_OF_TRAUMA.getKey());
@@ -285,17 +287,23 @@ public class ConceptFacade extends ConceptServiceImpl {
                 retrievalVO.setOtherType(typeList);
                 bla = false;
             }
-            if(bla){
+            if (bla) {
                 retrievalVO.setType(ParamConvertUtil.conceptConvert2Lib(retrievalVO.getType()));
             }
         }
-        List<ConceptRetrievalDTO> conceptRetrievalDTOS = this.retrievalConcept(retrievalVO);
+        List<ConceptRetrievalDTO> conceptRetrievalDTOS = Lists.newArrayList();;
+        if (retrievalVO.getIsStatic().equals(1)) {
+            conceptRetrievalDTOS = this.staticKnowledge(retrievalVO);
+        } else {
+            conceptRetrievalDTOS = this.retrievalConcept(retrievalVO);
+        }
+
         List<ConceptRetrievalDTO> res = new ArrayList<>();
         List<Long> selfList = new ArrayList<>(); // 本体
         List<Long> subList = new ArrayList<>(); // 子项
         List<String> conceptNameList = new ArrayList<>();//名称结果集保证数据唯一
         for (ConceptRetrievalDTO bean : conceptRetrievalDTOS) {
-            if(StringUtil.isNotEmpty(bean.getParentName())) { // 重置showType
+            if (StringUtil.isNotEmpty(bean.getParentName())) { // 重置showType
                 bean.setShowType(2L);
             }
             if (bean.getShowType().intValue() == 1) { // 本体
@@ -306,17 +314,17 @@ public class ConceptFacade extends ConceptServiceImpl {
         }
         // 有本体,过滤同义词和子项;无本体,有子项,过滤同义词
         for (ConceptRetrievalDTO bean : conceptRetrievalDTOS) {
-            if(bean.getShowType().intValue() == 1) {
+            if (bean.getShowType().intValue() == 1) {
                 res.add(bean);
             } else if (bean.getShowType().intValue() == 2) {
-                if(!selfList.contains(bean.getParentId()) && !conceptNameList.contains(bean.getParentName()) && retrievalVO.getIsSonShow().intValue() == 0) {
+                if (!selfList.contains(bean.getParentId()) && !conceptNameList.contains(bean.getParentName()) && retrievalVO.getIsSonShow().intValue() == 0) {
                     conceptNameList.add(bean.getParentName());
                     res.add(bean);
-                }else {
+                } else {
                     res.add(bean);
                 }
             } else if (bean.getShowType().intValue() == 0) {
-                if(!selfList.contains(bean.getSelfId()) && !subList.contains(bean.getSelfId()) && !conceptNameList.contains(bean.getSelfName())) {
+                if (!selfList.contains(bean.getSelfId()) && !subList.contains(bean.getSelfId()) && !conceptNameList.contains(bean.getSelfName())) {
                     conceptNameList.add(bean.getSelfName());
                     res.add(bean);
                 }
@@ -324,7 +332,7 @@ public class ConceptFacade extends ConceptServiceImpl {
         }
         //把本体的sameName过滤掉
         for (ConceptRetrievalDTO conceptRetrievalDTO : res) {
-            if(conceptRetrievalDTO.getSameName() != null && conceptRetrievalDTO.getSameName().equals(conceptRetrievalDTO.getSelfName())){
+            if (conceptRetrievalDTO.getSameName() != null && conceptRetrievalDTO.getSameName().equals(conceptRetrievalDTO.getSelfName())) {
                 conceptRetrievalDTO.setSameName(null);
             }
             conceptRetrievalDTO.setType(ParamConvertUtil.libConvert2Concept(conceptRetrievalDTO.getLibTypeId().intValue()));
@@ -339,11 +347,11 @@ public class ConceptFacade extends ConceptServiceImpl {
      * @param getStaticKnowledgeVO
      * @return
      */
-    public List<RetrievalDTO> getStaticKnowledge(GetStaticKnowledgeVO getStaticKnowledgeVO){
+    public List<RetrievalDTO> getStaticKnowledge(GetStaticKnowledgeVO getStaticKnowledgeVO) {
         List<RetrievalDTO> retrievalDTOS = new ArrayList<>();
         RetrievalVO retrievalVO = new RetrievalVO();
         RetrievalDTO retrievalDTO = new RetrievalDTO();
-        BeanUtil.copyProperties(getStaticKnowledgeVO,retrievalVO);
+        BeanUtil.copyProperties(getStaticKnowledgeVO, retrievalVO);
         retrievalVO.setIsSonShow(1);
         retrievalVO.setIsStatic(1);
         List<Integer> types = new ArrayList<>();
@@ -365,7 +373,7 @@ public class ConceptFacade extends ConceptServiceImpl {
                 retrievalDTO = new RetrievalDTO();
                 retrievalDTO.setConceptId(conceptRetrievalDTO.getSelfId());
                 retrievalDTO.setName(conceptRetrievalDTO.getSelfName());
-                if(StringUtil.isEmpty(conceptRetrievalDTO.getParentName()) && conceptRetrievalDTO.getLibTypeId().intValue() == LexiconTypeEnum.LIS_PACKAGE.getKey()){
+                if (StringUtil.isEmpty(conceptRetrievalDTO.getParentName()) && conceptRetrievalDTO.getLibTypeId().intValue() == LexiconTypeEnum.LIS_PACKAGE.getKey()) {
                     retrievalDTO.setUniqueName(conceptRetrievalDTO.getSelfName());
                     uniqueNameList.add(conceptRetrievalDTO.getSelfName());
                 }
@@ -373,10 +381,10 @@ public class ConceptFacade extends ConceptServiceImpl {
                     retrievalDTO.setConceptId(conceptRetrievalDTO.getParentId());
                     retrievalDTO.setName(conceptRetrievalDTO.getParentName());
                     retrievalDTO.setRetrievalName(conceptRetrievalDTO.getSelfName());
-                    if(StringUtil.isNotEmpty(conceptRetrievalDTO.getSelfName())){//如果selfName不为空是:大项(小项)组合
-                        retrievalDTO.setUniqueName(conceptRetrievalDTO.getParentName()+"--"+conceptRetrievalDTO.getSelfName());
-                        uniqueNameList.add(conceptRetrievalDTO.getParentName()+"--"+conceptRetrievalDTO.getSelfName());
-                    }else {//如果selfName为空是:子项推出大项
+                    if (StringUtil.isNotEmpty(conceptRetrievalDTO.getSelfName())) {//如果selfName不为空是:大项(小项)组合
+                        retrievalDTO.setUniqueName(conceptRetrievalDTO.getParentName() + "--" + conceptRetrievalDTO.getSelfName());
+                        uniqueNameList.add(conceptRetrievalDTO.getParentName() + "--" + conceptRetrievalDTO.getSelfName());
+                    } else {//如果selfName为空是:子项推出大项
                         retrievalDTO.setUniqueName(conceptRetrievalDTO.getParentName());
                         uniqueNameList.add(conceptRetrievalDTO.getParentName());
                     }
@@ -393,11 +401,11 @@ public class ConceptFacade extends ConceptServiceImpl {
             }
         }
         List<Concept> conceptDetilList = new ArrayList<>();//化验公表项
-        if(ListUtil.isNotEmpty(uniqueNameList)){//如果有化验公表项,获取化验公表项id
+        if (ListUtil.isNotEmpty(uniqueNameList)) {//如果有化验公表项,获取化验公表项id
             QueryWrapper<Concept> conceptQueryWrapper = new QueryWrapper<>();
-            conceptQueryWrapper.eq("is_deleted",IsDeleteEnum.N.getKey())
-                    .eq("lib_type",LexiconTypeEnum.LIS_TABLES.getKey())
-                    .in("lib_name",uniqueNameList);
+            conceptQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq("lib_type", LexiconTypeEnum.LIS_TABLES.getKey())
+                    .in("lib_name", uniqueNameList);
             conceptDetilList = this.list(conceptQueryWrapper);
         }
 
@@ -405,7 +413,7 @@ public class ConceptFacade extends ConceptServiceImpl {
         List<Long> cenceptIdList = retrievalDTOS.stream().map(RetrievalDTO::getConceptId).collect(Collectors.toList());
         for (RetrievalDTO retrievalDTO1 : retrievalDTOS) {
             for (Concept concept : conceptDetilList) {
-                if(StringUtil.isNotEmpty(retrievalDTO1.getUniqueName()) && retrievalDTO1.getUniqueName().equals(concept.getLibName())){//添加公表项id
+                if (StringUtil.isNotEmpty(retrievalDTO1.getUniqueName()) && retrievalDTO1.getUniqueName().equals(concept.getLibName())) {//添加公表项id
                     retrievalDTO1.setUniqueId(concept.getId());
                     cenceptIdList.add(concept.getId());
                 }
@@ -414,21 +422,21 @@ public class ConceptFacade extends ConceptServiceImpl {
         ExistListByConceptIdsVO existListByConceptIdsVO = new ExistListByConceptIdsVO();
         existListByConceptIdsVO.setConceptIds(cenceptIdList);
         List<Long> existConceptIdList = conceptDetailFacade.existListByConceptIds(existListByConceptIdsVO);
-        if(ListUtil.isNotEmpty(existConceptIdList)){
+        if (ListUtil.isNotEmpty(existConceptIdList)) {
             for (RetrievalDTO retrievalDTOInfo : retrievalDTOS) {
-                if(StringUtil.isNotEmpty(retrievalDTOInfo.getUniqueName())){
+                if (StringUtil.isNotEmpty(retrievalDTOInfo.getUniqueName())) {
                     for (Long concept : existConceptIdList) {
-                        if (null != retrievalDTOInfo.getUniqueId() && retrievalDTOInfo.getUniqueId().intValue() == concept.intValue()){//如果是化验时返回化验公表项
+                        if (null != retrievalDTOInfo.getUniqueId() && retrievalDTOInfo.getUniqueId().intValue() == concept.intValue()) {//如果是化验时返回化验公表项
                             retrievalDTO = new RetrievalDTO();
-                            BeanUtil.copyProperties(retrievalDTOInfo,retrievalDTO);
+                            BeanUtil.copyProperties(retrievalDTOInfo, retrievalDTO);
                             staticRetrievalList.add(retrievalDTO);
                         }
                     }
-                }else {
+                } else {
                     for (Long concept : existConceptIdList) {
-                        if (retrievalDTOInfo.getConceptId().intValue() == concept.intValue()){
+                        if (retrievalDTOInfo.getConceptId().intValue() == concept.intValue()) {
                             retrievalDTO = new RetrievalDTO();
-                            BeanUtil.copyProperties(retrievalDTOInfo,retrievalDTO);
+                            BeanUtil.copyProperties(retrievalDTOInfo, retrievalDTO);
                             staticRetrievalList.add(retrievalDTO);
                         }
                     }

+ 8 - 0
aipt-service/src/main/java/com/diagbot/mapper/ConceptMapper.java

@@ -46,6 +46,14 @@ public interface ConceptMapper extends BaseMapper<Concept> {
      */
     List<ConceptRetrievalDTO> retrievalConcept(RetrievalVO retrievalVO);
 
+    /**
+     * 静态知识检索
+     *
+     * @param retrievalVO
+     * @return
+     */
+    List<ConceptRetrievalDTO> staticKnowledge(RetrievalVO retrievalVO);
+
     List<ConceptBaseDTO> getConceptConMap(ConceptFindVO conceptFindVO);
 
     /**

+ 8 - 0
aipt-service/src/main/java/com/diagbot/service/ConceptService.java

@@ -46,6 +46,14 @@ public interface ConceptService extends IService<Concept> {
      */
     List<ConceptRetrievalDTO> retrievalConcept(RetrievalVO retrievalVO);
 
+    /**
+     * 静态知识检索
+     *
+     * @param retrievalVO
+     * @return
+     */
+    List<ConceptRetrievalDTO> staticKnowledge(RetrievalVO retrievalVO);
+
     List<ConceptBaseDTO> getConceptConMap(ConceptFindVO conceptFindVO);
 
     /**

+ 11 - 0
aipt-service/src/main/java/com/diagbot/service/impl/ConceptServiceImpl.java

@@ -48,6 +48,17 @@ public class ConceptServiceImpl extends ServiceImpl<ConceptMapper, Concept> impl
         return baseMapper.retrievalConcept(retrievalVO);
     }
 
+    /**
+     * 静态知识检索
+     *
+     * @param retrievalVO
+     * @return
+     */
+    @Override
+    public List<ConceptRetrievalDTO> staticKnowledge(RetrievalVO retrievalVO){
+        return baseMapper.staticKnowledge(retrievalVO);
+    }
+
     /**
      * 获取带排序概念-关系-概念
      *

+ 294 - 0
aipt-service/src/main/resources/mapper/ConceptMapper.xml

@@ -187,6 +187,300 @@
     </select>
 
     <select id="retrievalConcept" resultType="com.diagbot.dto.ConceptRetrievalDTO">
+        SELECT a1.* from (
+        (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 t3.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>
+        <if test="otherType != null and otherType.size > 0">
+            and t1.lib_type in
+            <foreach item="type" collection="otherType" open="(" separator="," close=")">
+                #{type}
+            </foreach>
+        </if>
+        <if test="sexType == 3">
+            and t3.sex_type in ('1','2','3')
+        </if>
+        <if test="sexType != 3">
+            and t3.sex_type in ('3',#{sexType})
+        </if>
+        <if test="age != null and age != ''">
+            AND <![CDATA[ t3.min_age <= #{age} ]]>
+            AND <![CDATA[ t3.max_age >= #{age} ]]>
+        </if>
+        <if test="inputIds != null and inputIds.size > 0">
+            and t1.id not in
+            <foreach item="id" collection="inputIds" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        AND (t2.spell =  UPPER(#{InputStr}) OR t2.name =  #{InputStr})
+        <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 t3.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>
+        <if test="otherType != null and otherType.size > 0">
+            and t1.lib_type in
+            <foreach item="type" collection="otherType" open="(" separator="," close=")">
+                #{type}
+            </foreach>
+        </if>
+        <if test="sexType == 3">
+            and t3.sex_type in ('1','2','3')
+        </if>
+        <if test="sexType != 3">
+            and t3.sex_type in ('3',#{sexType})
+        </if>
+        <if test="age != null and age != ''">
+            AND <![CDATA[ t3.min_age <= #{age} ]]>
+            AND <![CDATA[ t3.max_age >= #{age} ]]>
+        </if>
+        <if test="inputIds != null and inputIds.size > 0">
+            and t1.id not in
+            <foreach item="id" collection="inputIds" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        AND (t2.spell LIKE CONCAT( UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
+        <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 t3.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>
+        <if test="otherType != null and otherType.size > 0">
+            and t1.lib_type in
+            <foreach item="type" collection="otherType" open="(" separator="," close=")">
+                #{type}
+            </foreach>
+        </if>
+        <if test="sexType == 3">
+            and t3.sex_type in ('1','2','3')
+        </if>
+        <if test="sexType != 3">
+            and t3.sex_type in ('3',#{sexType})
+        </if>
+        <if test="age != null and age != ''">
+            AND <![CDATA[ t3.min_age <= #{age} ]]>
+            AND <![CDATA[ t3.max_age >= #{age} ]]>
+        </if>
+        <if test="inputIds != null and inputIds.size > 0">
+            and t1.id not in
+            <foreach item="id" collection="inputIds" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        AND (t2.spell LIKE CONCAT('%',UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
+        <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
+            LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
+            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
+            LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
+            <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 t3.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>
+            <if test="sexType == 3">
+                and t3.sex_type in ('1','2','3')
+            </if>
+            <if test="sexType != 3">
+                and t3.sex_type in ('3',#{sexType})
+            </if>
+            <if test="age != null and age != ''">
+                AND <![CDATA[ t3.min_age <= #{age} ]]>
+                AND <![CDATA[ t3.max_age >= #{age} ]]>
+            </if>
+            AND (t2.spell =  UPPER(#{InputStr}) OR t2.name =  #{InputStr})
+            <if test="inputIds != null and inputIds.size > 0">
+                and t1.id not in
+                <foreach item="id" collection="inputIds" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+            AND t4.relation_id = 18
+            <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
+            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
+            LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
+            <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 t3.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>
+            <if test="sexType == 3">
+                and t3.sex_type in ('1','2','3')
+            </if>
+            <if test="sexType != 3">
+                and t3.sex_type in ('3',#{sexType})
+            </if>
+            <if test="age != null and age != ''">
+                AND <![CDATA[ t3.min_age <= #{age} ]]>
+                AND <![CDATA[ t3.max_age >= #{age} ]]>
+            </if>
+            AND (t2.spell LIKE CONCAT(UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
+            <if test="inputIds != null and inputIds.size > 0">
+                and t1.id not in
+                <foreach item="id" collection="inputIds" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+            <if test="isStatic != null and isStatic == 1">
+                GROUP BY t5.id
+            </if>
+            AND t4.relation_id = 18
+            <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
+            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
+            LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
+            <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 t3.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>
+            <if test="sexType == 3">
+                and t3.sex_type in ('1','2','3')
+            </if>
+            <if test="sexType != 3">
+                and t3.sex_type in ('3',#{sexType})
+            </if>
+            <if test="age != null and age != ''">
+                AND <![CDATA[ t3.min_age <= #{age} ]]>
+                AND <![CDATA[ t3.max_age >= #{age} ]]>
+            </if>
+            AND (t2.spell LIKE CONCAT('%',UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
+            <if test="inputIds != null and inputIds.size > 0">
+                and t1.id not in
+                <foreach item="id" collection="inputIds" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+            <if test="isStatic != null and isStatic == 1">
+                GROUP BY t5.id
+            </if>
+            AND t4.relation_id = 18
+            <if test="isStatic == null or isStatic != 1">
+                LIMIT 100
+            </if>)
+        </if>
+        ) a1
+        <if test="isStatic == null or isStatic != 1">
+            LIMIT 100
+        </if>
+    </select>
+
+    <select id="staticKnowledge" resultType="com.diagbot.dto.ConceptRetrievalDTO">
         SELECT a1.* from (
         (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