Pārlūkot izejas kodu

添加固定部位信息

zhoutg 6 gadi atpakaļ
vecāks
revīzija
6ed287ccf0

+ 10 - 0
triage-service/src/main/java/com/diagbot/client/AiptServiceClient.java

@@ -1,7 +1,14 @@
 package com.diagbot.client;
 
 import com.diagbot.client.hystrix.AiptServiceHystrix;
+import com.diagbot.dto.PartSymptomDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.vo.PartSymptomVO;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.List;
 
 /**
  * @Description: 调用知识库服务
@@ -11,4 +18,7 @@ import org.springframework.cloud.openfeign.FeignClient;
 @FeignClient(value = "aipt-service", fallback = AiptServiceHystrix.class)
 public interface AiptServiceClient {
 
+    @PostMapping(value = "/part/getSymptomByPartName")
+    RespDTO<List<PartSymptomDTO>> getSymptomByPartName(@RequestBody PartSymptomVO partSymptomVO);
+
 }

+ 10 - 0
triage-service/src/main/java/com/diagbot/client/hystrix/AiptServiceHystrix.java

@@ -1,9 +1,14 @@
 package com.diagbot.client.hystrix;
 
 import com.diagbot.client.AiptServiceClient;
+import com.diagbot.dto.PartSymptomDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.vo.PartSymptomVO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 
+import java.util.List;
+
 /**
  * @Description: 调用知识库服务
  * @author: gaodm
@@ -12,4 +17,9 @@ import org.springframework.stereotype.Component;
 @Component
 @Slf4j
 public class AiptServiceHystrix implements AiptServiceClient {
+    @Override
+    public RespDTO<List<PartSymptomDTO>> getSymptomByPartName(PartSymptomVO partSymptomVO) {
+        log.error("【hystrix】调用{}异常", "getSymptomByPartName");
+        return null;
+    }
 }

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

@@ -0,0 +1,16 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description: 概念出参基础实体类
+ * @author: gaodm
+ * @time: 2019/5/7 9:44
+ */
+@Getter
+@Setter
+public class ConceptBaseDTO {
+    private Long conceptId; // 概念id
+    private String name;    //概念名称
+}

+ 3 - 7
triage-service/src/main/java/com/diagbot/dto/PartDTO.java

@@ -1,6 +1,6 @@
 package com.diagbot.dto;
 
-import com.diagbot.entity.SymptomWrapper;
+import com.diagbot.entity.Symptom;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -14,10 +14,6 @@ import java.util.List;
  */
 @Getter
 @Setter
-public class PartDTO {
-
-    private Long id;// 部位id
-    private String name;//部位名称
-    private Long parentId;// 上级id
-    private List<SymptomWrapper> symptomList = new ArrayList<>(); //症状列表
+public class PartDTO extends ConceptBaseDTO{
+    private List<Symptom> symptomList = new ArrayList<>(); //症状列表
 }

+ 1 - 5
triage-service/src/main/java/com/diagbot/dto/PartSymptomDTO.java

@@ -13,10 +13,6 @@ import java.util.List;
  */
 @Getter
 @Setter
-public class PartSymptomDTO {
-
-    private Long id;// 部位id
-    private String name;//部位名称
-    private Long parentId;// 上级id
+public class PartSymptomDTO extends ConceptBaseDTO{
     private List<PartDTO> partDTO = new ArrayList<>(); //部位信息
 }

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

@@ -1,80 +1,22 @@
 package com.diagbot.entity;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
+import com.diagbot.dto.ConceptBaseDTO;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import lombok.Getter;
 import lombok.Setter;
 
-import java.io.Serializable;
-import java.util.Date;
-
 /**
  * <p>
- * 症状信息表
+ * 症状信息扩展表
  * </p>
  *
  * @author zhoutg
  * @since 2018-09-17
  */
-@TableName("triage_symptom")
 @Getter
 @Setter
-public class Symptom implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
-
-    /**
-     * 是否删除 N:未删除,Y:删除
-     */
-    private String isDeleted;
-
-    /**
-     * 记录创建时间
-     */
-    private Date gmtCreate;
-
-    /**
-     * 记录修改时间
-     */
-    private Date gmtModified;
-
-    /**
-     * 创建人,0表示无创建人值
-     */
-    private String creator;
-
-    /**
-     * 修改人,如果为0则表示纪录未修改
-     */
-    private String modifier;
-
-    /**
-     * 名称
-     */
-    private String name;
-
-    /**
-     * 性别(1:男,2:女,3:共用)
-     */
-    private Integer sexType;
-
-    /**
-     * 最小年龄
-     */
-    private Integer ageBegin;
-
-    /**
-     * 最大年龄
-     */
-    private Integer ageEnd;
-
-    /**
-     * 备注
-     */
-    private String remark;
+public class Symptom extends ConceptBaseDTO {
 
+    @JsonIgnore
+    private Long partConceptId;
 }

+ 34 - 0
triage-service/src/main/java/com/diagbot/enums/FixPartEnum.java

@@ -0,0 +1,34 @@
+package com.diagbot.enums;
+
+import lombok.Setter;
+
+/**
+ * 
+ * @author zhoutg
+ * @Description: 诊断类型
+ * @date 2018年11月21日 下午2:31:42
+ */
+public enum FixPartEnum {
+    PART("全身");
+
+    @Setter
+    private String partName;
+
+    FixPartEnum(String partName) {
+        this.partName = partName;
+    }
+
+    public static FixPartEnum getEnum(String partName) {
+        for (FixPartEnum item : FixPartEnum.values()) {
+            if (item.partName.equals(partName)) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public String getPartName() {
+        return this.partName;
+    }
+}
+

+ 18 - 52
triage-service/src/main/java/com/diagbot/facade/PartFacade.java

@@ -1,23 +1,19 @@
 package com.diagbot.facade;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.diagbot.dto.PartDTO;
+import com.diagbot.client.AiptServiceClient;
 import com.diagbot.dto.PartSymptomDTO;
-import com.diagbot.entity.Part;
-import com.diagbot.entity.SymptomWrapper;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.enums.FixPartEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.PartServiceImpl;
-import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
+import com.diagbot.util.RespDTOUtil;
 import com.diagbot.vo.PartSymptomVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 /**
  * @Description: 部位facade
@@ -29,6 +25,8 @@ public class PartFacade extends PartServiceImpl {
 
     @Autowired
     SymptomFacade symptomFacade;
+    @Autowired
+    AiptServiceClient aiptServiceClient;
 
     /**
      * 根据已选部位返回对应的症状
@@ -36,65 +34,33 @@ public class PartFacade extends PartServiceImpl {
      * @param partSymptomVO 参数
      * @return 部位症状关联信息
      */
-    public List<PartSymptomDTO> getSymptomByPartIds(PartSymptomVO partSymptomVO) {
-        List<Long> partIds = partSymptomVO.getPartIds();
-        if(ListUtil.isEmpty(partIds)) {
+    public List<PartSymptomDTO> getSymptomByPartName(PartSymptomVO partSymptomVO) {
+        List<String> partList = partSymptomVO.getPartList();
+        if (ListUtil.isEmpty(partList)) {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
                     "请选择部位");
         }
-        if(partSymptomVO.getSexType() == null) {
+        if (partSymptomVO.getSexType() == null) {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
                     "请选择性别");
         }
-        if(partSymptomVO.getAge() == null) {
+        if (partSymptomVO.getAge() == null) {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
                     "请选择年龄");
         }
-        if(partSymptomVO.getAge().intValue() < 0 || partSymptomVO.getAge().intValue() > 200) {
+        if (partSymptomVO.getAge().intValue() < 0 || partSymptomVO.getAge().intValue() > 200) {
             throw new CommonException(CommonErrorCode.PARAM_IS_ERROR,
                     "超出年龄范围【0 — 200】");
         }
-        //添加默认部位-全身
-        QueryWrapper wrapper = new QueryWrapper();
-        wrapper.eq("name", "全身");
-        Part part = this.getOne(wrapper);
-        partIds.add(part.getId());
-        Map paramMap = new HashMap<>();
-        paramMap.put("ids", partIds);
-        List<PartSymptomDTO> res = this.getByPartId(paramMap);
-        List<PartDTO> partList = this.getByParentId(paramMap);
-
-        //添加二级部位信息
-        Map<Long, List<PartDTO>> keyMap = EntityUtil.makeEntityListMap(partList, "parentId");
-        for(PartSymptomDTO bean : res) {
-            bean.setPartDTO(keyMap.get(bean.getId()));
+        if (!partList.contains(FixPartEnum.PART.getPartName())) {
+            partList.add(FixPartEnum.PART.getPartName());
         }
-
-        //添加部位和症状的关联信息
-        List<Long> idList = new ArrayList<>();
-        for(PartDTO bean : partList) {
-            idList.add(bean.getId());
-        }
-        Map paramMap1 = new HashMap<>();
-        paramMap1.put("ids", idList);
-        paramMap1.put("sexType", partSymptomVO.getSexType());
-        paramMap1.put("age", partSymptomVO.getAge());
-        List<SymptomWrapper> symptomList = symptomFacade.getByPartIdsFac(paramMap1);
-        Map<Long, List<SymptomWrapper>> partSymptomMap = EntityUtil.makeEntityListMap(symptomList, "partId");
-        for(PartDTO bean : partList) {
-            bean.setSymptomList(partSymptomMap.get(bean.getId()));
+        RespDTO<List<PartSymptomDTO>> res = aiptServiceClient.getSymptomByPartName(partSymptomVO);
+        if (RespDTOUtil.respIsNG(res)) {
+            throw new CommonException(CommonErrorCode.RPC_ERROR, "远程调用部位关联的症状失败");
         }
 
-        // 如二级部位无关联的症状,删除二级部位
-        for(int i = 0; i < res.size(); i++) {
-            List<PartDTO> partDTO = res.get(i).getPartDTO();
-            for(int j = 0; j < partDTO.size(); j++) {
-                if(ListUtil.isEmpty(partDTO.get(j).getSymptomList())) {
-                    partDTO.remove(j--);
-                }
-            }
-        }
-        return res;
+        return res.data;
     }
 
 

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

@@ -14,7 +14,7 @@ import java.util.List;
 @Setter
 public class PartSymptomVO {
 
-    private List<Long> partIds;
+    private List<String> partList;
     private Integer sexType;
     private Integer age;
 }

+ 4 - 4
triage-service/src/main/java/com/diagbot/web/PartController.java

@@ -31,12 +31,12 @@ public class PartController {
 
 
     @ApiOperation(value = "知识库标准化-根据已选部位返回对应的症状[by:zhoutg]",
-            notes = "partIds: 部位的id,数组<br>" +
+            notes = "partIds: 部位列表,数组<br>" +
                     "sexType:性别,1:男,2:女<br>" +
                     "age:年龄")
-    @PostMapping("/getSymptomByPartIds")
-    public RespDTO<List<PartSymptomDTO>> getSymptomByPartIds(@RequestBody PartSymptomVO partSymptomVO) {
-        return RespDTO.onSuc(partFacade.getSymptomByPartIds(partSymptomVO));
+    @PostMapping("/getSymptomByPartName")
+    public RespDTO<List<PartSymptomDTO>> getSymptomByPartName(@RequestBody PartSymptomVO partSymptomVO) {
+        return RespDTO.onSuc(partFacade.getSymptomByPartName(partSymptomVO));
     }
 
 }