Browse Source

aipt-service标签检索

wangyu 6 years ago
parent
commit
bcbaf5dac5

+ 20 - 0
aipt-service/src/main/java/com/diagbot/dto/RetrievalDTO.java

@@ -0,0 +1,20 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: wangyu
+ * @time: 2019/5/10 10:20
+ */
+@Getter
+@Setter
+public class RetrievalDTO {
+    private Long selfId;//本身概念id
+    private String selfName;//本身名称
+    private Long parentId;//父级id
+    private String parentName;//父级名称
+    private String sameName;//同义词名称
+    private Integer showType;//显示类型(1本体,2同义词)
+}

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

@@ -3,6 +3,7 @@ package com.diagbot.facade;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.dto.ConceptBaseDTO;
 import com.diagbot.dto.ConceptWithOrderRes;
+import com.diagbot.dto.RetrievalDTO;
 import com.diagbot.entity.Concept;
 import com.diagbot.entity.wrapper.ConceptWrapper;
 import com.diagbot.enums.ConceptTypeEnum;
@@ -15,6 +16,7 @@ import com.diagbot.service.impl.ConceptServiceImpl;
 import com.diagbot.util.ParamConvertUtil;
 import com.diagbot.vo.ConceptBaseVO;
 import com.diagbot.vo.ConceptUsualVO;
+import com.diagbot.vo.RetrievalVO;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
@@ -100,4 +102,22 @@ public class ConceptFacade extends ConceptServiceImpl {
         }
         return list;
     }
+
+    /**
+     * 概念id检索
+     *
+     * @param retrievalVO
+     * @return
+     */
+    public List<RetrievalDTO> retrivelConceptInfo(RetrievalVO retrievalVO){
+        List<RetrievalDTO> retrievalDTOS = this.retrievalConcept(retrievalVO);
+        //把本体的sameName过滤掉
+        for (RetrievalDTO retrievalDTO: retrievalDTOS) {
+            if(retrievalDTO.getSameName() != null && retrievalDTO.getSameName().equals(retrievalDTO.getSelfName())){
+                retrievalDTO.setSameName(null);
+            }
+        }
+        return retrievalDTOS;
+    }
+
 }

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

@@ -3,8 +3,10 @@ package com.diagbot.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.diagbot.dto.ConceptRes;
 import com.diagbot.dto.ConceptWithOrderRes;
+import com.diagbot.dto.RetrievalDTO;
 import com.diagbot.entity.Concept;
 import com.diagbot.entity.wrapper.ConceptWrapper;
+import com.diagbot.vo.RetrievalVO;
 
 import java.util.List;
 
@@ -33,4 +35,12 @@ public interface ConceptMapper extends BaseMapper<Concept> {
      * @return 起点术语和终点术语以及排序号
      */
     List<ConceptWithOrderRes> getConceptWithOrder(ConceptWrapper conceptWrapper);
+
+    /**
+     * 概念检索
+     *
+     * @param retrievalVO
+     * @return
+     */
+    List<RetrievalDTO> retrievalConcept(RetrievalVO retrievalVO);
 }

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

@@ -3,8 +3,10 @@ package com.diagbot.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.diagbot.dto.ConceptRes;
 import com.diagbot.dto.ConceptWithOrderRes;
+import com.diagbot.dto.RetrievalDTO;
 import com.diagbot.entity.Concept;
 import com.diagbot.entity.wrapper.ConceptWrapper;
+import com.diagbot.vo.RetrievalVO;
 
 import java.util.List;
 
@@ -34,4 +36,11 @@ public interface ConceptService extends IService<Concept> {
      */
     List<ConceptWithOrderRes> getConceptWithOrder(ConceptWrapper conceptWrapper);
 
+    /**
+     * 概念检索
+     *
+     * @param retrievalVO
+     * @return
+     */
+    List<RetrievalDTO> retrievalConcept(RetrievalVO retrievalVO);
 }

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

@@ -3,10 +3,12 @@ package com.diagbot.service.impl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.diagbot.dto.ConceptRes;
 import com.diagbot.dto.ConceptWithOrderRes;
+import com.diagbot.dto.RetrievalDTO;
 import com.diagbot.entity.Concept;
 import com.diagbot.entity.wrapper.ConceptWrapper;
 import com.diagbot.mapper.ConceptMapper;
 import com.diagbot.service.ConceptService;
+import com.diagbot.vo.RetrievalVO;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -33,6 +35,17 @@ public class ConceptServiceImpl extends ServiceImpl<ConceptMapper, Concept> impl
         return baseMapper.getConcept(conceptWrapper);
     }
 
+    /**
+     * 概念检索
+     *
+     * @param retrievalVO
+     * @return
+     */
+    @Override
+    public List<RetrievalDTO> retrievalConcept(RetrievalVO retrievalVO) {
+        return baseMapper.retrievalConcept(retrievalVO);
+    }
+
     /**
      * 获取带排序概念-关系-概念
      *

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

@@ -0,0 +1,27 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: wangyu
+ * @time: 2019/5/10 10:24
+ */
+@Getter
+@Setter
+public class RetrievalVO {
+    @NotNull(message = "请输入标签类型")
+    private Integer type;
+    @NotNull(message = "请输入病人年龄")
+    private Integer age;
+    @NotNull(message = "请输入症状")
+    private String InputStr;
+    @NotNull(message = "请输入病人性别")
+    private Integer sexType;
+    //需要去重的id
+    private List<Long> inputIds;
+}

+ 15 - 0
aipt-service/src/main/java/com/diagbot/web/ConceptController.java

@@ -4,8 +4,10 @@ package com.diagbot.web;
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.ConceptBaseDTO;
 import com.diagbot.dto.RespDTO;
+import com.diagbot.dto.RetrievalDTO;
 import com.diagbot.facade.ConceptFacade;
 import com.diagbot.vo.ConceptUsualVO;
+import com.diagbot.vo.RetrievalVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -44,4 +46,17 @@ public class ConceptController {
         List<ConceptBaseDTO> data = conceptFacade.getConceptUsual(conceptUsualVO);
         return RespDTO.onSuc(data);
     }
+
+    @ApiOperation(value = "知识库标准化-标签检索[by:wangyu]",
+            notes = "type:类型(1:症状 3:其他史 4:查体,5:化验 6:辅检 7:诊断),必填<br>" +
+                    "age:年龄,必填<br>" +
+                    "inputStr:检索内容,必填<br>" +
+                    "sexType:性别,必填<br>" +
+                    "inputIds:需要去重的id<br>")
+    @PostMapping("/retrivelConceptInfo")
+    @SysLogger("retrivelConceptInfo")
+    public RespDTO<List<RetrievalDTO>> retrivelConceptInfo(@RequestBody @Valid RetrievalVO retrievalVO) {
+        List<RetrievalDTO> data = conceptFacade.retrivelConceptInfo(retrievalVO);
+        return RespDTO.onSuc(data);
+    }
 }

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

@@ -186,4 +186,179 @@
         ORDER BY t4.order_no
     </select>
 
+    <select id="retrievalConcept" resultType="com.diagbot.dto.RetrievalDTO">
+        SELECT a1.* from (
+        SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType 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 = 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
+        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 t1.lib_type = #{type}
+        <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 =  #{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 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 = 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
+        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 t1.lib_type = #{type}
+        <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( #{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 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 = 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
+        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 t1.lib_type = #{type}
+        <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('%',#{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 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 = t2.concept_id
+        WHERE
+        t1.is_deleted = 'N'
+        AND t2.is_deleted = 'N'
+        AND t3.is_deleted = 'N'
+        AND t1.lib_type = #{type}
+        <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 =  #{InputStr} OR t2.name =  #{InputStr})
+        UNION
+        SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType 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 = t2.concept_id
+        WHERE
+        t1.is_deleted = 'N'
+        AND t2.is_deleted = 'N'
+        AND t3.is_deleted = 'N'
+        AND t1.lib_type = #{type}
+        <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( #{InputStr},'%') OR t2.name LIKE CONCAT( #{InputStr},'%'))
+        UNION
+        SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType 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 = t2.concept_id
+        WHERE
+        t1.is_deleted = 'N'
+        AND t2.is_deleted = 'N'
+        AND t3.is_deleted = 'N'
+        AND t1.lib_type = #{type}
+        <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('%',#{InputStr},'%') OR t2.name LIKE CONCAT('%',#{InputStr},'%'))
+        ) a1
+        GROUP BY a1.selfId,a1.showType  
+    </select>
 </mapper>