فهرست منبع

检索代码修改

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

+ 32 - 10
aipt-service/src/main/java/com/diagbot/facade/ConceptFacade.java

@@ -216,25 +216,47 @@ public class ConceptFacade extends ConceptServiceImpl {
     public List<ConceptRetrievalDTO> retrivelConceptInfo(RetrievalVO retrievalVO){
         List<Integer> typeList = new ArrayList<>();
         if (null != retrievalVO.getType()){
-            for (Integer type: retrievalVO.getType()) {
-                if(type.intValue() == ConceptTypeEnum.Lis.getKey()){//如果是化验,检索类型包括套餐和明细项
-                    typeList.add(LexiconTypeEnum.LIS_PACKAGE.getKey());
-                    typeList.add(LexiconTypeEnum.LIS_DETAILS.getKey());
-                } else{
-                    typeList.add(ParamConvertUtil.conceptConvert2Lib(type));//标签类型
-                }
+            if(retrievalVO.getType().intValue() == ConceptTypeEnum.Lis.getKey()){
+                retrievalVO.setDetilType(LexiconTypeEnum.LIS_DETAILS.getKey());
             }
-            retrievalVO.setType(typeList);
+            retrievalVO.setType(ParamConvertUtil.conceptConvert2Lib(retrievalVO.getType()));
         }
         List<ConceptRetrievalDTO> conceptRetrievalDTOS = this.retrievalConcept(retrievalVO);
+        List<ConceptRetrievalDTO> res = new ArrayList<>();
+        List<Long> selfList = new ArrayList<>(); // 本体
+        List<Long> subList = new ArrayList<>(); // 子项
+        for (ConceptRetrievalDTO bean : conceptRetrievalDTOS) {
+            if(StringUtil.isNotEmpty(bean.getParentName())) { // 重置showType
+                bean.setShowType(2L);
+            }
+            if (bean.getShowType().intValue() == 1) { // 本体
+                selfList.add(bean.getSelfId());
+            } else if (bean.getShowType().intValue() == 2) { // 子项
+                subList.add(bean.getSelfId());
+            }
+        }
+        // 有本体,过滤同义词和子项;无本体,有子项,过滤同义词
+        for (ConceptRetrievalDTO bean : conceptRetrievalDTOS) {
+            if(bean.getShowType().intValue() == 1) {
+                res.add(bean);
+            } else if (bean.getShowType().intValue() == 2) {
+                if(!selfList.contains(bean.getParentId())) {
+                    res.add(bean);
+                }
+            } else if (bean.getShowType().intValue() == 0) {
+                if(!selfList.contains(bean.getSelfId()) && !subList.contains(bean.getSelfId())) {
+                    res.add(bean);
+                }
+            }
+        }
         //把本体的sameName过滤掉
-        for (ConceptRetrievalDTO conceptRetrievalDTO : conceptRetrievalDTOS) {
+        for (ConceptRetrievalDTO conceptRetrievalDTO : res) {
             if(conceptRetrievalDTO.getSameName() != null && conceptRetrievalDTO.getSameName().equals(conceptRetrievalDTO.getSelfName())){
                 conceptRetrievalDTO.setSameName(null);
             }
             conceptRetrievalDTO.setType(ParamConvertUtil.libConvert2Concept(conceptRetrievalDTO.getLibTypeId().intValue()));
         }
-        return conceptRetrievalDTOS;
+        return res;
     }
 
 

+ 3 - 1
aipt-service/src/main/java/com/diagbot/vo/RetrievalVO.java

@@ -14,11 +14,13 @@ import java.util.List;
 @Getter
 @Setter
 public class RetrievalVO {
-    private List<Integer> type;
+    private Integer type;
     private Integer age;
     @NotNull(message = "请输入症状")
     private String InputStr;
     private Integer sexType;
     //需要去重的id
     private List<Long> inputIds;
+    //获取子项时需要用到的type类型
+    private Integer detilType;
 }

+ 128 - 145
aipt-service/src/main/resources/mapper/ConceptMapper.xml

@@ -188,123 +188,6 @@
 
     <select id="retrievalConcept" resultType="com.diagbot.dto.ConceptRetrievalDTO">
         SELECT a1.* from (
-        SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null 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_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 = t1.lib_type
-        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'
-        AND t2.is_concept = 1
-        <if test="type != null">
-            AND t1.lib_type in
-            <foreach item="type" collection="type" 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>
-        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
-        UNION
-        SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null 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_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 = t1.lib_type
-        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'
-        AND t2.is_concept = 1
-        <if test="type != null">
-            AND t1.lib_type in
-            <foreach item="type" collection="type" 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>
-        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>
-        AND t4.relation_id = 18
-        UNION
-        SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null 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_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 = t1.lib_type
-        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'
-        AND t2.is_concept = 1
-        <if test="type != null">
-            AND t1.lib_type in
-            <foreach item="type" collection="type" 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>
-        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>
-        AND t4.relation_id = 18
-        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
@@ -312,23 +195,20 @@
         WHERE
         t1.is_deleted = 'N'
         AND t2.is_deleted = 'N'
-        AND t3.is_deleted = 'N'
         AND t6.is_deleted = 'N'
         <if test="type != null">
-            AND t1.lib_type in
-            <foreach item="type" collection="type" open="(" separator="," close=")">
-                #{type}
-            </foreach>
+            AND t1.lib_type = #{type}
         </if>
         <if test="sexType == 3">
-        and t3.sex_type in ('1','2','3')
+            and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
         </if>
         <if test="sexType != 3">
-            and t3.sex_type in ('3',#{sexType})
+            and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
         </if>
         <if test="age != null and age != ''">
-            AND <![CDATA[ t3.min_age <= #{age} ]]>
-            AND <![CDATA[ t3.max_age >= #{age} ]]>
+            AND (( <![CDATA[ t3.min_age <= #{age} ]]>
+            AND <![CDATA[ t3.max_age >= #{age} ]]>)
+            or (t3.min_age is null and t3.max_age is null))
         </if>
         <if test="inputIds != null and inputIds.size > 0">
             and t1.id not in
@@ -345,23 +225,20 @@
         WHERE
         t1.is_deleted = 'N'
         AND t2.is_deleted = 'N'
-        AND t3.is_deleted = 'N'
         AND t6.is_deleted = 'N'
         <if test="type != null">
-            AND t1.lib_type in
-            <foreach item="type" collection="type" open="(" separator="," close=")">
-                #{type}
-            </foreach>
+            AND t1.lib_type = #{type}
         </if>
         <if test="sexType == 3">
-            and t3.sex_type in ('1','2','3')
+            and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
         </if>
         <if test="sexType != 3">
-            and t3.sex_type in ('3',#{sexType})
+            and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
         </if>
         <if test="age != null and age != ''">
-            AND <![CDATA[ t3.min_age <= #{age} ]]>
-            AND <![CDATA[ t3.max_age >= #{age} ]]>
+            AND (( <![CDATA[ t3.min_age <= #{age} ]]>
+            AND <![CDATA[ t3.max_age >= #{age} ]]>)
+            or (t3.min_age is null and t3.max_age is null))
         </if>
         <if test="inputIds != null and inputIds.size > 0">
             and t1.id not in
@@ -378,23 +255,20 @@
         WHERE
         t1.is_deleted = 'N'
         AND t2.is_deleted = 'N'
-        AND t3.is_deleted = 'N'
         AND t6.is_deleted = 'N'
         <if test="type != null">
-            AND t1.lib_type in
-            <foreach item="type" collection="type" open="(" separator="," close=")">
-                #{type}
-            </foreach>
+            AND t1.lib_type = #{type}
         </if>
         <if test="sexType == 3">
-            and t3.sex_type in ('1','2','3')
+            and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
         </if>
         <if test="sexType != 3">
-            and t3.sex_type in ('3',#{sexType})
+            and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
         </if>
         <if test="age != null and age != ''">
-            AND <![CDATA[ t3.min_age <= #{age} ]]>
-            AND <![CDATA[ t3.max_age >= #{age} ]]>
+            AND (( <![CDATA[ t3.min_age <= #{age} ]]>
+            AND <![CDATA[ t3.max_age >= #{age} ]]>)
+            or (t3.min_age is null and t3.max_age is null))
         </if>
         <if test="inputIds != null and inputIds.size > 0">
             and t1.id not in
@@ -403,7 +277,116 @@
             </foreach>
         </if>
         AND (t2.spell LIKE CONCAT('%',UPPER(#{InputStr}),'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
+        <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_concept_common t3 ON t1.id = t3.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
+            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'
+            AND t2.is_concept = 1
+            <if test="type != null">
+                AND t1.lib_type = #{detilType}
+            </if>
+            <if test="sexType == 3">
+                and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
+            </if>
+            <if test="sexType != 3">
+                and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
+            </if>
+            <if test="age != null and age != ''">
+                AND (( <![CDATA[ t3.min_age <= #{age} ]]>
+                AND <![CDATA[ t3.max_age >= #{age} ]]>)
+                or (t3.min_age is null and t3.max_age is null))
+            </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
+            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_concept_common t3 ON t1.id = t3.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
+            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'
+            AND t2.is_concept = 1
+            <if test="type != null">
+                AND t1.lib_type = #{detilType}
+            </if>
+            <if test="sexType == 3">
+                and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
+            </if>
+            <if test="sexType != 3">
+                and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
+            </if>
+            <if test="age != null and age != ''">
+                AND (( <![CDATA[ t3.min_age <= #{age} ]]>
+                AND <![CDATA[ t3.max_age >= #{age} ]]>)
+                or (t3.min_age is null and t3.max_age is null))
+            </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>
+            AND t4.relation_id = 18
+            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_concept_common t3 ON t1.id = t3.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
+            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'
+            AND t2.is_concept = 1
+            <if test="type != null">
+                AND t1.lib_type = #{detilType}
+            </if>
+            <if test="sexType == 3">
+                and (t3.sex_type in ('1','2','3') or t3.sex_type is null)
+            </if>
+            <if test="sexType != 3">
+                and (t3.sex_type in ('3',#{sexType}) or t3.sex_type is null)
+            </if>
+            <if test="age != null and age != ''">
+                AND (( <![CDATA[ t3.min_age <= #{age} ]]>
+                AND <![CDATA[ t3.max_age >= #{age} ]]>)
+                or (t3.min_age is null and t3.max_age is null))
+            </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>
+            AND t4.relation_id = 18
+        </if>
         ) a1
-        GROUP BY a1.selfId,a1.showType
     </select>
 </mapper>

+ 1 - 0
icss-service/src/main/java/com/diagbot/facade/RetrievalFacade.java

@@ -74,6 +74,7 @@ public class RetrievalFacade {
                     if(null != questionInfoMap.get(conceptRetrievalDTO.getParentName())){//如果匹配到就添加questionId
                         retrievalDTO.setQuestionId(questionInfoMap.get(conceptRetrievalDTO.getParentName()).getId());
                     }
+                    retrievalDTO.setConceptId(conceptRetrievalDTO.getParentId());
                     retrievalDTO.setName(conceptRetrievalDTO.getParentName());
                     retrievalDTO.setRetrievalName(conceptRetrievalDTO.getSelfName());
                 } else {//parent为空时说明没有子项返回本体id

+ 1 - 1
icss-service/src/main/java/com/diagbot/vo/RetrievalVO.java

@@ -16,7 +16,7 @@ import java.util.List;
 public class RetrievalVO {
 
     @NotNull(message = "请输入标签类型")
-    private List<Integer> type;
+    private Integer type;
     @NotNull(message = "请输入病人年龄")
     private Integer age;
     @NotNull(message = "请输入症状")