Browse Source

智能分诊推理

Zhaops 6 years ago
parent
commit
4dc5725067

+ 0 - 3
config-server/src/main/resources/shared/triage-service-dev.yml

@@ -94,6 +94,3 @@ mybatis-plus:
   configuration:
     map-underscore-to-camel-case: true
     cache-enabled: false
-ai:
-  server:
-    address: http://192.168.2.234:8080

+ 0 - 3
config-server/src/main/resources/shared/triage-service-local.yml

@@ -94,6 +94,3 @@ mybatis-plus:
   configuration:
     map-underscore-to-camel-case: true
     cache-enabled: false
-ai:
-  server:
-    address: http://192.168.2.234:8080

+ 0 - 3
config-server/src/main/resources/shared/triage-service-pro.yml

@@ -94,6 +94,3 @@ mybatis-plus:
   configuration:
     map-underscore-to-camel-case: true
     cache-enabled: false
-ai:
-  server:
-    address: http://192.168.2.234:8080

+ 0 - 3
config-server/src/main/resources/shared/triage-service-test.yml

@@ -94,6 +94,3 @@ mybatis-plus:
   configuration:
     map-underscore-to-camel-case: true
     cache-enabled: false
-ai:
-  server:
-    address: http://192.168.2.234:8080

+ 3 - 3
triage-service/src/main/java/com/diagbot/client/AIServiceClient.java

@@ -13,11 +13,11 @@ import org.springframework.web.bind.annotation.RequestBody;
  * @author: gaodm
  * @time: 2018/10/25 9:56
  */
-@FeignClient(name = "AI", url = "${ai.server.address}", fallback = AIServiceHystrix.class)
+//@FeignClient(name = "AI", url = "${ai.server.address}", fallback = AIServiceHystrix.class)
 public interface AIServiceClient {
 
-    @PostMapping(value = "/web/doc/algorithm/neural")
-    Response<ResponseData> bayesPageData(@RequestBody SearchData searchData);
+   /* @PostMapping(value = "/web/doc/algorithm/neural")
+    Response<ResponseData> bayesPageData(@RequestBody SearchData searchData);*/
 }
 
 

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

@@ -1,5 +1,7 @@
 package com.diagbot.client;
 
+import com.diagbot.client.bean.ResponseData;
+import com.diagbot.client.bean.SearchData;
 import com.diagbot.client.hystrix.AiptServiceHystrix;
 import com.diagbot.dto.ConceptBaseDTO;
 import com.diagbot.dto.ConceptRetrievalDTO;
@@ -44,4 +46,7 @@ public interface AiptServiceClient {
     @PostMapping("/concept/retrivelConceptInfo")
     RespDTO<List<ConceptRetrievalDTO>> retrivelConceptInfo(@RequestBody @Valid RetrievalVO retrievalVO);
 
+    @PostMapping(value = "/clinicaldata/processData")
+    RespDTO<ResponseData> aiptData(@RequestBody SearchData searchData);
+
 }

+ 2 - 2
triage-service/src/main/java/com/diagbot/client/hystrix/AIServiceHystrix.java

@@ -16,9 +16,9 @@ import org.springframework.stereotype.Component;
 @Component
 @Slf4j
 public class AIServiceHystrix implements AIServiceClient {
-    @Override
+   /* @Override
     public Response<ResponseData> bayesPageData(SearchData searchData) {
         log.error("【hystrix】调用{}异常", "bayesPageData");
         return null;
-    }
+    }*/
 }

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

@@ -1,6 +1,8 @@
 package com.diagbot.client.hystrix;
 
 import com.diagbot.client.AiptServiceClient;
+import com.diagbot.client.bean.ResponseData;
+import com.diagbot.client.bean.SearchData;
 import com.diagbot.dto.ConceptBaseDTO;
 import com.diagbot.dto.ConceptRetrievalDTO;
 import com.diagbot.dto.PartSymptomDTO;
@@ -39,4 +41,11 @@ public class AiptServiceHystrix implements AiptServiceClient {
         log.error("【hystrix】调用{}异常", "retrivelConceptInfo");
         return null;
     }
+
+    @Override
+    public RespDTO<ResponseData> aiptData(SearchData searchData) {
+        log.error("【hystrix】调用{}异常", "aiptData");
+        return null;
+    }
+
 }

+ 26 - 27
triage-service/src/main/java/com/diagbot/facade/AIFacade.java

@@ -1,14 +1,15 @@
 package com.diagbot.facade;
 
-import com.diagbot.client.AIServiceClient;
+import com.diagbot.client.AiptServiceClient;
 import com.diagbot.client.bean.FeatureRate;
-import com.diagbot.client.bean.Response;
 import com.diagbot.client.bean.ResponseData;
 import com.diagbot.client.bean.SearchData;
 import com.diagbot.dto.AIDTO;
+import com.diagbot.dto.RespDTO;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.util.ListUtil;
+import com.diagbot.util.RespDTOUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.vo.AIVO;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,7 +30,7 @@ import java.util.Map;
 @Component
 public class AIFacade {
     @Autowired
-    private AIServiceClient aiServiceClient;
+    private AiptServiceClient aiptServiceClient;
 
     /**
      * 调用ai接口业务逻辑
@@ -61,24 +62,22 @@ public class AIFacade {
                 searchData.setLength(10);
                 break;
         }
-        Response<ResponseData> res = aiServiceClient.bayesPageData(searchData);
-        if (null == res || null == res.getData()) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "AI没有返回结果");
-        }
+        RespDTO<ResponseData> res = aiptServiceClient.aiptData(searchData);
+        RespDTOUtil.respNGDealCover(res, "中间层没有结果返回");
         AIDTO aidto = new AIDTO();
         switch (type) {
             case "1":
-                aidto.setItems(res.getData().getSymptom());
+                aidto.setItems(res.data.getSymptom());
                 break;
             case "7":
                 List<FeatureRate> items = new ArrayList<>();
-                if (ListUtil.isNotEmpty(res.getData().getDis())){
+                if (ListUtil.isNotEmpty(res.data.getDis())) {
                     Double rate;
                     Map<String, Double> map = new HashMap<>();
-                    for (FeatureRate featureRate: res.getData().getDis()){
-                        if (Double.valueOf(featureRate.getRate()) > 0.1d){
-                            if (StringUtil.isNotBlank(featureRate.getExtraProperty())){
-                                if (null != map.get(featureRate.getExtraProperty())){
+                    for (FeatureRate featureRate : res.data.getDis()) {
+                        if (Double.valueOf(featureRate.getRate()) > 0.1d) {
+                            if (StringUtil.isNotBlank(featureRate.getExtraProperty())) {
+                                if (null != map.get(featureRate.getExtraProperty())) {
                                     rate = map.get(featureRate.getExtraProperty())
                                             + Double.valueOf(featureRate.getRate());
                                     map.replace(featureRate.getExtraProperty(), rate);
@@ -89,31 +88,31 @@ public class AIFacade {
                         }
                     }
 
-                    List<Map.Entry<String,Double>> list = new ArrayList<Map.Entry<String,Double>>(map.entrySet());
-                    Collections.sort(list,new Comparator<Map.Entry<String,Double>>() {
-                                //降序排序
-                                public int compare(Map.Entry<String, Double> o1,
-                                                   Map.Entry<String, Double> o2) {
-                                    return o2.getValue().compareTo(o1.getValue());
-                                }
+                    List<Map.Entry<String, Double>> list = new ArrayList<Map.Entry<String, Double>>(map.entrySet());
+                    Collections.sort(list, new Comparator<Map.Entry<String, Double>>() {
+                        //降序排序
+                        public int compare(Map.Entry<String, Double> o1,
+                                           Map.Entry<String, Double> o2) {
+                            return o2.getValue().compareTo(o1.getValue());
+                        }
                     });
                     FeatureRate item;
-                    for (Map.Entry<String,Double> entry: list){
-                        if (items.size() < 2){
+                    for (Map.Entry<String, Double> entry : list) {
+                        if (items.size() < 2) {
                             item = new FeatureRate();
                             item.setExtraProperty(entry.getKey());
                             items.add(item);
                         }
                     }
-                    if (ListUtil.isEmpty(items)){
+                    if (ListUtil.isEmpty(items)) {
                         item = new FeatureRate();
-                        item.setExtraProperty(res.getData().getDis().get(0).getExtraProperty());
+                        item.setExtraProperty(res.data.getDis().get(0).getExtraProperty());
                         items.add(item);
                     }
                 }
-//                if (ListUtil.isEmpty(items)){
-//                    throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "暂时无法推理出结果");
-//                }
+                //                if (ListUtil.isEmpty(items)){
+                //                    throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "暂时无法推理出结果");
+                //                }
                 aidto.setItems(items);
                 break;
         }