zhoutg 6 năm trước cách đây
mục cha
commit
657baa1744

+ 2 - 1
triage-service/src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -26,7 +26,8 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .csrf().disable()
                 .authorizeRequests()
                 .regexMatchers(".*swagger.*", ".*v2.*", ".*webjars.*", "/druid.*", "/actuator.*", "/hystrix.*").permitAll()
-                .antMatchers("/symptom/list").permitAll()
+                .antMatchers("/symptom/getUsual").permitAll()
+                .antMatchers("/symptom/search").permitAll()
                 .antMatchers("/part/getSymptomByPartIds").permitAll()
                 .antMatchers("/ai/pushSymptom").permitAll()
                 .antMatchers("/ai/pushDis").permitAll()

+ 2 - 1
triage-service/src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java

@@ -65,7 +65,8 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/druid/**", request)
                 || matchers("/actuator/**", request)
                 || matchers("/hystrix/**", request)
-                || matchers("/symptom/list", request)
+                || matchers("/symptom/getUsual", request)
+                || matchers("/symptom/search", request)
                 || matchers("/part/getSymptomByPartIds", request)
                 || matchers("/ai/pushSymptom", request)
                 || matchers("/ai/pushDis", request)

+ 20 - 0
triage-service/src/main/java/com/diagbot/dto/SymptomSearchDTO.java

@@ -0,0 +1,20 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description: 部位症状关联信息
+ * @Author: ztg
+ * @Date: 2018/10/24 16:11
+ */
+@Getter
+@Setter
+public class SymptomSearchDTO {
+
+    private Long id;// id
+    private String name;//症状名称
+    private String searchName;//检索名称
+    private Integer showType; //显示类型 1:本体,2:同义词
+    private String showTypeCn; //显示类型中文 1:本体,2:同义词
+}

+ 2 - 2
triage-service/src/main/java/com/diagbot/entity/Symptom.java

@@ -11,10 +11,10 @@ import java.util.Date;
 
 /**
  * <p>
- * 用户认证信息表
+ * 症状信息表
  * </p>
  *
- * @author zhaops
+ * @author zhoutg
  * @since 2018-09-17
  */
 @TableName("triage_symptom")

+ 2 - 2
triage-service/src/main/java/com/diagbot/entity/SymptomWrapper.java

@@ -11,10 +11,10 @@ import java.util.Date;
 
 /**
  * <p>
- * 用户认证信息
+ * 症状信息扩展
  * </p>
  *
- * @author zhaops
+ * @author zhoutg
  * @since 2018-09-17
  */
 @TableName("triage_symptom")

+ 50 - 0
triage-service/src/main/java/com/diagbot/enums/ShowTypeEnum.java

@@ -0,0 +1,50 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @Description:检索显示类型枚举类
+ * @author: zhoutg
+ * @Date: 2018/10/26 10:35
+ */
+public enum ShowTypeEnum implements KeyedNamed {
+
+    ITSELF(1, "本体"),
+    SYNONYMS(2, "同义词");
+
+    @Setter
+    private Integer key;
+
+    @Setter
+    private String name;
+
+    ShowTypeEnum(Integer key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static ShowTypeEnum getEnum(Integer key) {
+        for (ShowTypeEnum item : ShowTypeEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(Integer key) {
+        ShowTypeEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+}

+ 46 - 6
triage-service/src/main/java/com/diagbot/facade/SymptomFacade.java

@@ -1,11 +1,15 @@
 package com.diagbot.facade;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.dto.SymptomSearchDTO;
 import com.diagbot.entity.Symptom;
 import com.diagbot.entity.SymptomWrapper;
+import com.diagbot.enums.ShowTypeEnum;
 import com.diagbot.service.impl.SymptomServiceImpl;
+import com.diagbot.vo.SymptomSearchVO;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -16,11 +20,12 @@ import java.util.Map;
  */
 @Component
 public class SymptomFacade extends SymptomServiceImpl{
-
-    public List<Symptom> getList() {
-        QueryWrapper<Symptom> qw1 = new QueryWrapper<>();
-        List<Symptom> list = this.list(qw1);
-        return list;
+    /**
+     *  获取常用症状
+     * @return
+     */
+    public List<Symptom> getUsualFac() {
+        return this.getUsual();
     }
 
 
@@ -33,4 +38,39 @@ public class SymptomFacade extends SymptomServiceImpl{
         return this.getByPartIds(map);
     }
 
+
+    /**
+     * 症状检索
+     * @param symptomSearchVO
+     * @return 检索的症状
+     */
+    public List<SymptomSearchDTO> searchFac(SymptomSearchVO symptomSearchVO) {
+        List<SymptomSearchDTO> res = new ArrayList<>();
+        Map paramMap = new HashMap();
+        paramMap.put("name", symptomSearchVO.getName());
+        paramMap.put("sexType", symptomSearchVO.getSexType());
+        paramMap.put("age", symptomSearchVO.getAge());
+        List<SymptomSearchDTO> symptomSearchDTOList = this.search(paramMap);
+        List<Long> ids = new ArrayList<>();
+        //获取所有的本体,添加返回结果,因为sql语句返回时同义词有可能排前面,而本体排后面
+        for(SymptomSearchDTO bean : symptomSearchDTOList) {
+            if(ShowTypeEnum.ITSELF.getKey() == bean.getShowType()) { //本体
+                ids.add(bean.getId());
+            }
+        }
+        for(SymptomSearchDTO bean : symptomSearchDTOList) {
+            //如果是本体,直接返回
+            if(ShowTypeEnum.ITSELF.getKey() == bean.getShowType()) {
+                res.add(bean);
+            } else {
+                //如果是同义词,判断是否已添加,有多个同义词任意取一个
+                if(!ids.contains(bean.getId())) {
+                    ids.add(bean.getId());
+                    res.add(bean);
+                }
+            }
+        }
+        return res;
+    }
+
 }

+ 16 - 0
triage-service/src/main/java/com/diagbot/mapper/SymptomMapper.java

@@ -1,6 +1,7 @@
 package com.diagbot.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.diagbot.dto.SymptomSearchDTO;
 import com.diagbot.entity.Symptom;
 import com.diagbot.entity.SymptomWrapper;
 
@@ -20,4 +21,19 @@ public interface SymptomMapper extends BaseMapper<Symptom> {
      * @return
      */
     public List<SymptomWrapper> getByPartIds(Map map);
+
+
+    /**
+     * 获取常用症状
+     * @return 常用症状
+     */
+    public List<Symptom> getUsual();
+
+
+    /**
+     * 检索
+     * @param map
+     * @return
+     */
+    public List<SymptomSearchDTO> search(Map map);
 }

+ 16 - 0
triage-service/src/main/java/com/diagbot/service/SymptomService.java

@@ -1,6 +1,7 @@
 package com.diagbot.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.dto.SymptomSearchDTO;
 import com.diagbot.entity.Symptom;
 import com.diagbot.entity.SymptomWrapper;
 
@@ -25,4 +26,19 @@ public interface SymptomService extends IService<Symptom> {
      */
     public List<SymptomWrapper> getByPartIds(Map map);
 
+
+    /**
+     * 获取常用症状
+     * @return
+     */
+    public List<Symptom> getUsual();
+
+
+    /**
+     * 检索
+     * @param map
+     * @return 症状检索的信息
+     */
+    public List<SymptomSearchDTO> search(Map map);
+
 }

+ 11 - 0
triage-service/src/main/java/com/diagbot/service/impl/SymptomServiceImpl.java

@@ -1,6 +1,7 @@
 package com.diagbot.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.dto.SymptomSearchDTO;
 import com.diagbot.entity.Symptom;
 import com.diagbot.entity.SymptomWrapper;
 import com.diagbot.mapper.SymptomMapper;
@@ -25,4 +26,14 @@ public class SymptomServiceImpl extends ServiceImpl<SymptomMapper, Symptom> impl
     public List<SymptomWrapper> getByPartIds(Map map) {
         return baseMapper.getByPartIds(map);
     }
+
+    @Override
+    public List<Symptom> getUsual() {
+        return baseMapper.getUsual();
+    }
+
+    @Override
+    public List<SymptomSearchDTO> search(Map map) {
+        return baseMapper.search(map);
+    }
 }

+ 0 - 14
triage-service/src/main/java/com/diagbot/vo/PartSymptomVO.java

@@ -14,21 +14,7 @@ import java.util.List;
 @Setter
 public class PartSymptomVO {
 
-
-    /**
-     * 部位ids
-     */
     private List<Long> partIds;
-
-
-    /**
-     * 性别
-     */
     private Integer sexType;
-
-
-    /**
-     * 年龄
-     */
     private Integer age;
 }

+ 24 - 0
triage-service/src/main/java/com/diagbot/vo/SymptomSearchVO.java

@@ -0,0 +1,24 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @Description: 部位搜索参数
+ * @Author: ztg
+ * @Date: 2018/10/10 13:17
+ */
+@Getter
+@Setter
+public class SymptomSearchVO {
+
+    @NotBlank(message = "请输入检索内容")
+    private String name;
+    @NotNull(message = "请输入性别")
+    private Integer sexType;
+    @NotNull(message = "请输入年龄")
+    private Integer age;
+}

+ 15 - 10
triage-service/src/main/java/com/diagbot/web/SymptomController.java

@@ -2,14 +2,18 @@ package com.diagbot.web;
 
 
 import com.diagbot.dto.RespDTO;
+import com.diagbot.dto.SymptomSearchDTO;
 import com.diagbot.entity.Symptom;
 import com.diagbot.facade.SymptomFacade;
+import com.diagbot.vo.SymptomSearchVO;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.validation.Valid;
 import java.util.List;
 
 /**
@@ -25,16 +29,17 @@ public class SymptomController {
     SymptomFacade symptomFacade;
 
 
-    /**
-     * 症状列表
-     *
-     * @param
-     * @return 列表
-     */
-    @ApiOperation(value = "测试接口", notes = "测试接口")
-    @PostMapping("/list")
-    public RespDTO<List<Symptom>> list() {
-        return RespDTO.onSuc(symptomFacade.getList());
+    @ApiOperation(value = "获取常用症状", notes = "")
+    @PostMapping("/getUsual")
+    public RespDTO<List<Symptom>> getUsual() {
+        return RespDTO.onSuc(symptomFacade.getUsualFac());
+    }
+
+
+    @ApiOperation(value = "搜索症状", notes = "")
+    @PostMapping("/search")
+    public RespDTO<List<SymptomSearchDTO>> search(@RequestBody @Valid SymptomSearchVO symptomSearchVO) {
+        return RespDTO.onSuc(symptomFacade.searchFac(symptomSearchVO));
     }
 
 }

+ 30 - 0
triage-service/src/main/resources/mapper/SymptomMapper.xml

@@ -34,5 +34,35 @@
         order by b.part_id, b.order_no
     </select>
 
+    <select id="getUsual"  resultMap="BaseResultMap">
+        SELECT a.*  FROM `triage_symptom` a, triage_symptom_usual b where a.is_deleted = 'N' and b.is_deleted = 'N'
+        and b.symptom_id = a.id
+        order by b.order_no
+    </select>
+
+
+    <select id="search" parameterType="java.util.Map" resultType="com.diagbot.dto.SymptomSearchDTO">
+        select c.*,b.show_type,if(show_type=1, '本体', '同义词') show_type_cn,a.name search_name
+        from triage_retrieval a, triage_retrieval_mapping b, triage_symptom c
+        where a.is_deleted = 'N' and b.is_deleted = 'N' and c.is_deleted = 'N'
+        and a.id = b.retrieval_id and b.item_id = c.id
+        and (a.`name` = #{name} or a.spell = #{name})
+        and c.sex_type in (3, #{sexType})
+        <if test="age != null">
+            <![CDATA[ and c.age_begin <= #{age} ]]>
+            <![CDATA[ and c.age_end >= #{age} ]]>
+        </if>
+
+        union
 
+        select c.*,b.show_type,if(show_type=1, '本体', '同义词') show_type_cn, a.name search_name from triage_retrieval a, triage_retrieval_mapping b, triage_symptom c
+        where a.is_deleted = 'N' and b.is_deleted = 'N' and c.is_deleted = 'N'
+        and a.id = b.retrieval_id and b.item_id = c.id
+        and (a.`name` like concat('%',#{name} , '%') or a.spell like concat('%',#{name} , '%'))
+        and c.sex_type in (3, #{sexType})
+        <if test="age != null">
+            <![CDATA[ and c.age_begin <= #{age} ]]>
+            <![CDATA[ and c.age_end >= #{age} ]]>
+        </if>
+    </select>
 </mapper>