Explorar o código

症状特征词提取

Zhaops %!s(int64=6) %!d(string=hai) anos
pai
achega
cdd9ba9107

+ 4 - 0
config-server/src/main/resources/shared/icss-service-dev.yml

@@ -106,6 +106,10 @@ graph:
   server:
     address: http://192.168.2.234:5003
 
+symptom:
+  server:
+    address: http://192.168.2.234:5002
+
 treat:
   server:
     address: http://192.168.3.112:8080

+ 4 - 0
config-server/src/main/resources/shared/icss-service-local.yml

@@ -106,6 +106,10 @@ graph:
   server:
     address: http://192.168.2.234:5003
 
+symptom:
+  server:
+    address: http://192.168.2.234:5002
+
 treat:
   server:
     address: http://192.168.3.112:8080

+ 4 - 0
config-server/src/main/resources/shared/icss-service-pro.yml

@@ -106,6 +106,10 @@ graph:
   server:
     address: http://192.168.2.234:5003
 
+symptom:
+  server:
+    address: http://192.168.2.234:5002
+
 treat:
   server:
     address: http://192.168.3.112:8080

+ 4 - 0
config-server/src/main/resources/shared/icss-service-test.yml

@@ -106,6 +106,10 @@ graph:
   server:
     address: http://192.168.2.234:5003
 
+symptom:
+  server:
+    address: http://192.168.2.234:5002
+
 treat:
   server:
     address: http://192.168.3.112:8080

+ 0 - 2
icss-service/src/main/java/com/diagbot/client/HighRiskServiceClient.java

@@ -8,8 +8,6 @@ import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 
-import java.util.Map;
-
 /**
  * @Description:
  * @Author:zhaops

+ 21 - 0
icss-service/src/main/java/com/diagbot/client/SymptomFeatureClient.java

@@ -0,0 +1,21 @@
+package com.diagbot.client;
+
+import com.diagbot.client.bean.Response;
+import com.diagbot.client.hystrix.SymptomFeatureHystrix;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/2/26 10:33
+ */
+@FeignClient(name = "SymptomFeature", url = "${symptom.server.address}", fallback = SymptomFeatureHystrix.class)
+public interface SymptomFeatureClient {
+    @PostMapping(value = "/nlp-web/feature/find_symptom_feature")
+    Response<List<Map<String, Object>>> symptomFeaturePageData(@RequestParam("text") String text);
+}

+ 0 - 2
icss-service/src/main/java/com/diagbot/client/hystrix/HighRiskServiceHystrix.java

@@ -7,8 +7,6 @@ import com.diagbot.client.bean.SearchData;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 
-import java.util.Map;
-
 /**
  * @Description:
  * @Author:zhaops

+ 26 - 0
icss-service/src/main/java/com/diagbot/client/hystrix/SymptomFeatureHystrix.java

@@ -0,0 +1,26 @@
+package com.diagbot.client.hystrix;
+
+import com.diagbot.client.SymptomFeatureClient;
+import com.diagbot.client.bean.Response;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/2/26 10:33
+ */
+@Component
+@Slf4j
+public class SymptomFeatureHystrix implements SymptomFeatureClient {
+
+    @Override
+    public  Response<List<Map<String, Object>>> symptomFeaturePageData(@RequestParam("text") String text) {
+        log.error("【hystrix】调用{}异常", "symptomFeaturePageData");
+        return null;
+    }
+}

+ 17 - 0
icss-service/src/main/java/com/diagbot/dto/SymptomFeatureDTO.java

@@ -0,0 +1,17 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/2/26 11:49
+ */
+@Getter
+@Setter
+public class SymptomFeatureDTO {
+    private Long id;
+    private String tagName;
+    private String name;
+}

+ 65 - 0
icss-service/src/main/java/com/diagbot/facade/FeatureFacade.java

@@ -0,0 +1,65 @@
+package com.diagbot.facade;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.client.SymptomFeatureClient;
+import com.diagbot.client.bean.Response;
+import com.diagbot.dto.SymptomFeatureDTO;
+import com.diagbot.entity.QuestionInfo;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.enums.QuestionTypeEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.google.common.collect.Lists;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/2/26 13:27
+ */
+@Component
+public class FeatureFacade {
+    @Autowired
+    private SymptomFeatureClient symptomFeatureClient;
+    @Autowired
+    private QuestionFacade questionFacade;
+
+    /**
+     * 症状关键词提取
+     *
+     * @param text
+     * @return
+     */
+    public List<SymptomFeatureDTO> getSymptomFeature(String text) {
+        List<SymptomFeatureDTO> symptomFeatureDTOList = Lists.newLinkedList();
+        Response<List<Map<String, Object>>> res = symptomFeatureClient.symptomFeaturePageData(text);
+        if (null == res || null == res.getData()) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "AI没有返回结果");
+        }
+        List<Map<String, Object>> symptomFeatureList = res.getData();
+        List<String> symptomNameList = Lists.newLinkedList();
+        for (Map<String, Object> symptomFeature : symptomFeatureList) {
+            if (symptomFeature != null) {
+                symptomNameList.add(symptomFeature.get("feature_name").toString());
+            }
+        }
+        QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
+        questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
+                in("tag_name", symptomNameList).
+                eq("type", QuestionTypeEnum.Symptom.getKey()).
+                eq("item_type", 0);
+        List<QuestionInfo> questionInfoList = questionFacade.list(questionInfoQueryWrapper);
+        for (QuestionInfo questionInfo : questionInfoList) {
+            SymptomFeatureDTO symptomFeatureDTO = new SymptomFeatureDTO();
+            symptomFeatureDTO.setId(questionInfo.getId());
+            symptomFeatureDTO.setTagName(questionInfo.getTagName());
+            symptomFeatureDTO.setName(questionInfo.getName());
+            symptomFeatureDTOList.add(symptomFeatureDTO);
+        }
+        return symptomFeatureDTOList;
+    }
+}

+ 37 - 0
icss-service/src/main/java/com/diagbot/web/FeatureController.java

@@ -0,0 +1,37 @@
+package com.diagbot.web;
+
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.dto.SymptomFeatureDTO;
+import com.diagbot.facade.FeatureFacade;
+import io.swagger.annotations.Api;
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/2/26 13:25
+ */
+@RestController
+@RequestMapping("/feature")
+@Api(value = "特征词提取相关API", tags = { "特征词提取相关API" })
+public class FeatureController {
+
+    @Autowired
+    FeatureFacade featureFacade;
+
+    @ApiOperation(value = "症状文本解析[by:zhaops]",
+            notes = "text: 症状文本描述(必填)<br>")
+    @PostMapping("/getSymptomFeature")
+    @SysLogger("getSymptomFeature")
+    public RespDTO<List<SymptomFeatureDTO>> getSymptomFeature(@RequestParam("text") String text) {
+        return RespDTO.onSuc(featureFacade.getSymptomFeature(text));
+    }
+}