Browse Source

量表推理,中间层合并

Zhaops 6 years ago
parent
commit
6e5ecfec5b
26 changed files with 260 additions and 210 deletions
  1. 11 2
      aipt-service/src/main/java/com/diagbot/client/AIServiceClient.java
  2. 1 1
      icss-service/src/main/java/com/diagbot/client/NLPServiceClient.java
  3. 18 0
      aipt-service/src/main/java/com/diagbot/client/bean/GdbResponse.java
  4. 16 0
      aipt-service/src/main/java/com/diagbot/client/hystrix/AIServiceHystrix.java
  5. 1 1
      icss-service/src/main/java/com/diagbot/client/hystrix/NLPServiceHystrix.java
  6. 36 5
      aipt-service/src/main/java/com/diagbot/facade/ClinicalFacade.java
  7. 36 0
      aipt-service/src/main/java/com/diagbot/facade/NLPFacade.java
  8. 2 0
      aipt-service/src/main/java/com/diagbot/vo/SearchVo.java
  9. 17 1
      aipt-service/src/main/java/com/diagbot/web/ClinicalController.java
  10. 36 0
      aipt-service/src/main/java/com/diagbot/web/NLPController.java
  11. 5 1
      config-server/src/main/resources/shared/aipt-service-dev.yml
  12. 5 1
      config-server/src/main/resources/shared/aipt-service-local.yml
  13. 5 1
      config-server/src/main/resources/shared/aipt-service-pro.yml
  14. 5 1
      config-server/src/main/resources/shared/aipt-service-test.yml
  15. 1 13
      config-server/src/main/resources/shared/icss-service-dev.yml
  16. 1 13
      config-server/src/main/resources/shared/icss-service-local.yml
  17. 0 12
      config-server/src/main/resources/shared/icss-service-pro.yml
  18. 1 13
      config-server/src/main/resources/shared/icss-service-test.yml
  19. 15 0
      icss-service/src/main/java/com/diagbot/client/AiptServiceClient.java
  20. 0 24
      icss-service/src/main/java/com/diagbot/client/BigDataServiceClient.java
  21. 0 20
      icss-service/src/main/java/com/diagbot/client/GraphServiceClient.java
  22. 25 1
      icss-service/src/main/java/com/diagbot/client/hystrix/AiptServiceHystrix.java
  23. 0 31
      icss-service/src/main/java/com/diagbot/client/hystrix/BigDataServiceHystrix.java
  24. 0 23
      icss-service/src/main/java/com/diagbot/client/hystrix/GraphServiceHystrix.java
  25. 3 3
      icss-service/src/main/java/com/diagbot/facade/FeatureFacade.java
  26. 20 43
      icss-service/src/main/java/com/diagbot/facade/PushFacade.java

+ 11 - 2
aipt-service/src/main/java/com/diagbot/client/AIServiceClient.java

@@ -1,13 +1,16 @@
 package com.diagbot.client;
 
+import com.diagbot.client.bean.GdbResponse;
 import com.diagbot.client.bean.Response;
 import com.diagbot.client.bean.ResponseData;
-import com.diagbot.vo.SearchVo;
 import com.diagbot.client.hystrix.AIServiceHystrix;
+import com.diagbot.vo.SearchVo;
 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
@@ -17,4 +20,10 @@ import org.springframework.web.bind.annotation.RequestBody;
 public interface AIServiceClient {
     @PostMapping(value = "/push-web/algorithm/neural")
     Response<ResponseData> bayesPageData(@RequestBody SearchVo searchVo);
-}
+
+    @PostMapping(value = "/push-web/graph/scale")
+    Map<String, Object> scale(@RequestBody SearchVo searchVo);
+
+    @PostMapping(value = "/push-web/graph/highRisk")
+    Response<GdbResponse> highRiskPageData(@RequestBody SearchVo searchVo);
+}

+ 1 - 1
icss-service/src/main/java/com/diagbot/client/NLPServiceClient.java

@@ -12,7 +12,7 @@ import java.util.Map;
 /**
  * @Description:调用NLP对接层服务
  * @Author:zhaops
- * @time: 2019/2/26 10:33
+ * @time: 2019/4/2 15:31
  */
 @FeignClient(name = "NLP", url = "${nlp.server.address}", fallback = NLPServiceHystrix.class)
 public interface NLPServiceClient {

+ 18 - 0
aipt-service/src/main/java/com/diagbot/client/bean/GdbResponse.java

@@ -0,0 +1,18 @@
+package com.diagbot.client.bean;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 图形数据库数据返回结构
+ * Created by Mark Huang on 2018/10/26.
+ */
+@Getter
+@Setter
+public class GdbResponse {
+    private String status = "";
+    private Map<String, String> Result = new HashMap<>();
+}

+ 16 - 0
aipt-service/src/main/java/com/diagbot/client/hystrix/AIServiceHystrix.java

@@ -1,11 +1,15 @@
 package com.diagbot.client.hystrix;
 
 import com.diagbot.client.AIServiceClient;
+import com.diagbot.client.bean.GdbResponse;
 import com.diagbot.client.bean.Response;
 import com.diagbot.client.bean.ResponseData;
 import com.diagbot.vo.SearchVo;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.Map;
 
 /**
  * @Description:
@@ -20,4 +24,16 @@ public class AIServiceHystrix implements AIServiceClient {
         log.error("【hystrix】调用{}异常", "bayesPageData");
         return null;
     }
+
+    @Override
+    public Map<String, Object> scale(@RequestBody SearchVo searchVo) {
+        log.error("【hystrix】调用{}异常", "scale");
+        return null;
+    }
+
+    @Override
+    public Response<GdbResponse> highRiskPageData(@RequestBody SearchVo searchVo) {
+        log.error("【hystrix】调用{}异常", "highRiskPageData");
+        return null;
+    }
 }

+ 1 - 1
icss-service/src/main/java/com/diagbot/client/hystrix/NLPServiceHystrix.java

@@ -12,7 +12,7 @@ import java.util.Map;
 /**
  * @Description:调用NLP对接层服务
  * @Author:zhaops
- * @time: 2019/2/26 10:33
+ * @time: 2019/4/2 15:36
  */
 @Component
 @Slf4j

+ 36 - 5
aipt-service/src/main/java/com/diagbot/facade/ClinicalFacade.java

@@ -1,15 +1,19 @@
 package com.diagbot.facade;
 
 import com.diagbot.client.AIServiceClient;
+import com.diagbot.client.bean.GdbResponse;
 import com.diagbot.client.bean.Response;
 import com.diagbot.client.bean.ResponseData;
 import com.diagbot.dto.LisResult;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.vo.SearchVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.bind.annotation.RequestBody;
-import com.diagbot.vo.SearchVo;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -44,19 +48,46 @@ public class ClinicalFacade {
 
         String Otherval = "";
 
-        for (int i=0; i<lisArr.size(); i++) {
+        for (int i = 0; i < lisArr.size(); i++) {
             LisResult lisres = lisArr.get(i);
 
-            Otherval = (lisres.getOtherValue().trim().length() > 0)? lisres.getOtherValue().trim()+"\n":"";
+            Otherval = (lisres.getOtherValue().trim().length() > 0) ? lisres.getOtherValue().trim() + "\n" : "";
 
             if (lisres.getMaxValue() != null && lisres.getValue() > lisres.getMaxValue()) {
                 lisres.setOtherValue(Otherval + "超出标准");
-            }
-            else if (lisres.getMinValue() != null && lisres.getValue() < lisres.getMinValue()) {
+            } else if (lisres.getMinValue() != null && lisres.getValue() < lisres.getMinValue()) {
                 lisres.setOtherValue(Otherval + "低于标准");
             }
         }
 
         return lisArr;
     }
+
+    /**
+     * 获取量表内容
+     *
+     * @param searchVo
+     * @return
+     */
+    public Map<String, Object> scale(SearchVo searchVo) {
+        Map<String, Object> response = aiServiceClient.scale(searchVo);
+        if (null == response) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "量表没有返回结果");
+        }
+        return response;
+    }
+
+    /**
+     * 高危诊断
+     *
+     * @param searchVo
+     * @return
+     */
+    public GdbResponse highRiskPageData(SearchVo searchVo) {
+        Response<GdbResponse> response = aiServiceClient.highRiskPageData(searchVo);
+        if (response == null || response.getData() == null) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "高危没有返回结果");
+        }
+        return response.getData();
+    }
 }

+ 36 - 0
aipt-service/src/main/java/com/diagbot/facade/NLPFacade.java

@@ -0,0 +1,36 @@
+package com.diagbot.facade;
+
+import com.diagbot.client.NLPServiceClient;
+import com.diagbot.client.bean.Response;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+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/4/2 15:37
+ */
+@Component
+public class NLPFacade {
+    @Autowired
+    private NLPServiceClient nlpServiceClient;
+
+    /**
+     * 症状特征词提取
+     *
+     * @param text
+     * @return
+     */
+    public List<Map<String, Object>> symptomFeaturePageData(String text) {
+        Response<List<Map<String, Object>>> response = nlpServiceClient.symptomFeaturePageData(text);
+        if (response == null || response.getData() == null) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "NLP没有返回结果");
+        }
+        return response.getData();
+    }
+}

+ 2 - 0
aipt-service/src/main/java/com/diagbot/vo/SearchVo.java

@@ -61,4 +61,6 @@ public class SearchVo {
     private List<Feature> diagFeatureList;
     private Map<String, Map<String, String>> inputs;
 
+    private String scaleName;
+
 }

+ 17 - 1
aipt-service/src/main/java/com/diagbot/web/ClinicalController.java

@@ -2,6 +2,7 @@ package com.diagbot.web;
 
 
 import com.diagbot.annotation.SysLogger;
+import com.diagbot.client.bean.GdbResponse;
 import com.diagbot.client.bean.ResponseData;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.ClinicalFacade;
@@ -12,10 +13,10 @@ 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.Map;
 
 /**
  * <p>
@@ -43,4 +44,19 @@ public class ClinicalController {
         return RespDTO.onSuc(data);
     }
 
+    @ApiOperation(value = "获取量表", notes = "")
+    @PostMapping("/scale")
+    @SysLogger("scale")
+    public RespDTO<Map<String, Object>> scale(@RequestBody SearchVo searchVo) {
+        Map<String, Object> data = clinicalFacade.scale(searchVo);
+        return RespDTO.onSuc(data);
+    }
+
+    @ApiOperation(value = "高危诊断", notes = "")
+    @PostMapping("/highRisk")
+    @SysLogger("highRisk")
+    public RespDTO<GdbResponse> highRisk(@RequestBody SearchVo searchVo) {
+        GdbResponse data = clinicalFacade.highRiskPageData(searchVo);
+        return RespDTO.onSuc(data);
+    }
 }

+ 36 - 0
aipt-service/src/main/java/com/diagbot/web/NLPController.java

@@ -0,0 +1,36 @@
+package com.diagbot.web;
+
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.NLPFacade;
+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;
+import java.util.Map;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/4/2 11:31
+ */
+@RestController
+@RequestMapping("/nlpService")
+@Api(value = "NLP相关API", tags = { "NLP相关API" })
+public class NLPController {
+    @Autowired
+    NLPFacade nlpFacade;
+
+    @ApiOperation(value = "症状特征词提取", notes = "")
+    @PostMapping("/symptomFeature")
+    @SysLogger("symptomFeature")
+    public RespDTO<List<Map<String, Object>>> symptomFeaturePageData(@RequestParam("text") String text) {
+        List<Map<String, Object>> data = nlpFacade.symptomFeaturePageData(text);
+        return RespDTO.onSuc(data);
+    }
+}

+ 5 - 1
config-server/src/main/resources/shared/aipt-service-dev.yml

@@ -94,4 +94,8 @@ mybatis-plus:
 
 ai:
   server:
-    address: http://192.168.2.234:5008
+    address: http://192.168.2.234:5008
+
+nlp:
+  server:
+    address: http://192.168.2.234:5002

+ 5 - 1
config-server/src/main/resources/shared/aipt-service-local.yml

@@ -94,4 +94,8 @@ mybatis-plus:
 
 ai:
   server:
-    address: http://192.168.2.234:5008
+    address: http://192.168.2.234:5008
+
+nlp:
+  server:
+    address: http://192.168.2.234:5002

+ 5 - 1
config-server/src/main/resources/shared/aipt-service-pro.yml

@@ -94,4 +94,8 @@ mybatis-plus:
 
 ai:
   server:
-    address: http://192.168.2.234:5008
+    address: http://192.168.2.234:5008
+
+nlp:
+  server:
+    address: http://192.168.2.234:5002

+ 5 - 1
config-server/src/main/resources/shared/aipt-service-test.yml

@@ -94,4 +94,8 @@ mybatis-plus:
 
 ai:
   server:
-    address: http://192.168.2.234:5008
+    address: http://192.168.2.234:5008
+
+nlp:
+  server:
+    address: http://192.168.2.234:5002

+ 1 - 13
config-server/src/main/resources/shared/icss-service-dev.yml

@@ -96,16 +96,4 @@ mybatis-plus:
       #sql-injector: com.baomidou.springboot.xxx
   configuration:
     map-underscore-to-camel-case: true
-    cache-enabled: false
-
-bigdata:
-  server:
-    address: http://192.168.2.234:5008
-
-graph:
-  server:
-    address: http://192.168.2.234:5003
-
-nlp:
-  server:
-    address: http://192.168.2.234:5002
+    cache-enabled: false

+ 1 - 13
config-server/src/main/resources/shared/icss-service-local.yml

@@ -96,16 +96,4 @@ mybatis-plus:
       #sql-injector: com.baomidou.springboot.xxx
   configuration:
     map-underscore-to-camel-case: true
-    cache-enabled: false
-
-bigdata:
-  server:
-    address: http://192.168.2.234:5008
-
-graph:
-  server:
-    address: http://192.168.2.234:5003
-
-nlp:
-  server:
-    address: http://192.168.2.234:5002
+    cache-enabled: false

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

@@ -97,15 +97,3 @@ mybatis-plus:
   configuration:
     map-underscore-to-camel-case: true
     cache-enabled: false
-
-bigdata:
-  server:
-    address: http://192.168.2.234:5008
-
-graph:
-  server:
-    address: http://192.168.2.234:5003
-
-nlp:
-  server:
-    address: http://192.168.2.234:5002

+ 1 - 13
config-server/src/main/resources/shared/icss-service-test.yml

@@ -96,16 +96,4 @@ mybatis-plus:
       #sql-injector: com.baomidou.springboot.xxx
   configuration:
     map-underscore-to-camel-case: true
-    cache-enabled: false
-
-bigdata:
-  server:
-    address: http://192.168.2.234:5008
-
-graph:
-  server:
-    address: http://192.168.2.234:5003
-
-nlp:
-  server:
-    address: http://192.168.2.234:5002
+    cache-enabled: false

+ 15 - 0
icss-service/src/main/java/com/diagbot/client/AiptServiceClient.java

@@ -1,12 +1,18 @@
 package com.diagbot.client;
 
+import com.diagbot.client.bean.GdbResponse;
 import com.diagbot.client.bean.Response;
 import com.diagbot.client.bean.ResponseData;
 import com.diagbot.client.bean.SearchData;
 import com.diagbot.client.hystrix.AiptServiceHystrix;
+import com.diagbot.dto.RespDTO;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * @Description:调用中间层服务
@@ -17,4 +23,13 @@ import org.springframework.web.bind.annotation.RequestBody;
 public interface AiptServiceClient {
     @PostMapping(value = "/clinicaldata/processData")
     Response<ResponseData> aiptData(@RequestBody SearchData searchData);
+
+    @PostMapping(value = "/clinicaldata/scale")
+    Response<Map<String, Object>> scale(@RequestBody SearchData searchData);
+
+    @PostMapping(value = "/nlpService/symptomFeature")
+    Response<List<Map<String, Object>>> symptomFeaturePageData(@RequestParam("text") String text);
+
+    @PostMapping("/clinicaldata/highRish")
+    Response<GdbResponse> highRisk(@RequestBody SearchData searchData);
 }

+ 0 - 24
icss-service/src/main/java/com/diagbot/client/BigDataServiceClient.java

@@ -1,24 +0,0 @@
-package com.diagbot.client;
-
-import com.diagbot.client.bean.GdbResponse;
-import com.diagbot.client.bean.Response;
-import com.diagbot.client.bean.ResponseData;
-import com.diagbot.client.bean.SearchData;
-import com.diagbot.client.hystrix.BigDataServiceHystrix;
-import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-
-/**
- * @Description:调用大数据对接层服务
- * @Author:zhaops
- * @time: 2018/11/20 13:15
- */
-@FeignClient(name = "BigData", url = "${bigdata.server.address}", fallback = BigDataServiceHystrix.class)
-public interface BigDataServiceClient {
-    @PostMapping(value = "/push-web/algorithm/neural")
-    Response<ResponseData> bayesPageData(@RequestBody SearchData searchData);
-
-    @PostMapping(value = "/push-web/graph/highRisk")
-    Response<GdbResponse> highRiskPageData(@RequestBody SearchData searchData);
-}

+ 0 - 20
icss-service/src/main/java/com/diagbot/client/GraphServiceClient.java

@@ -1,20 +0,0 @@
-package com.diagbot.client;
-
-import com.diagbot.client.bean.GdbResponse;
-import com.diagbot.client.bean.Response;
-import com.diagbot.client.bean.SearchData;
-import com.diagbot.client.hystrix.GraphServiceHystrix;
-import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-
-/**
- * @Description:调用知识图谱对接层服务
- * @Author:zhaops
- * @time: 2018/12/21 11:38
- */
-@FeignClient(name = "Graph", url = "${graph.server.address}", fallback = GraphServiceHystrix.class)
-public interface GraphServiceClient {
-    @PostMapping(value = "/graph-web/graph/highRisk")
-    Response<GdbResponse> highRiskPageData(@RequestBody SearchData searchData);
-}

+ 25 - 1
icss-service/src/main/java/com/diagbot/client/hystrix/AiptServiceHystrix.java

@@ -1,11 +1,17 @@
 package com.diagbot.client.hystrix;
 
 import com.diagbot.client.AiptServiceClient;
+import com.diagbot.client.bean.GdbResponse;
 import com.diagbot.client.bean.Response;
 import com.diagbot.client.bean.ResponseData;
 import com.diagbot.client.bean.SearchData;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * @Description:调用中间层服务
@@ -20,4 +26,22 @@ public class AiptServiceHystrix implements AiptServiceClient {
         log.error("【hystrix】调用{}异常", "aiptData");
         return null;
     }
-}
+
+    @Override
+    public Response<Map<String, Object>> scale(@RequestBody SearchData searchData) {
+        log.error("【hystrix】调用{}异常", "scale");
+        return null;
+    }
+
+    @Override
+    public Response<List<Map<String, Object>>> symptomFeaturePageData(@RequestParam("text") String text) {
+        log.error("【hystrix】调用{}异常", "symptomFeaturePageData");
+        return null;
+    }
+
+    @Override
+    public Response<GdbResponse> highRisk(@RequestBody SearchData searchData) {
+        log.error("【hystrix】调用{}异常", "highRisk");
+        return null;
+    }
+}

+ 0 - 31
icss-service/src/main/java/com/diagbot/client/hystrix/BigDataServiceHystrix.java

@@ -1,31 +0,0 @@
-package com.diagbot.client.hystrix;
-
-import com.diagbot.client.BigDataServiceClient;
-import com.diagbot.client.bean.GdbResponse;
-import com.diagbot.client.bean.Response;
-import com.diagbot.client.bean.ResponseData;
-import com.diagbot.client.bean.SearchData;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-import org.springframework.web.bind.annotation.RequestBody;
-
-/**
- * @Description:调用大数据对接层服务
- * @Author:zhaops
- * @time: 2018/11/20 13:15
- */
-@Component
-@Slf4j
-public class BigDataServiceHystrix implements BigDataServiceClient {
-    @Override
-    public Response<ResponseData> bayesPageData(SearchData searchData) {
-        log.error("【hystrix】调用{}异常", "bayesPageData");
-        return null;
-    }
-
-    @Override
-    public Response<GdbResponse> highRiskPageData(@RequestBody SearchData searchData) {
-        log.error("【hystrix】调用{}异常", "highRiskPageData");
-        return null;
-    }
-}

+ 0 - 23
icss-service/src/main/java/com/diagbot/client/hystrix/GraphServiceHystrix.java

@@ -1,23 +0,0 @@
-package com.diagbot.client.hystrix;
-
-import com.diagbot.client.GraphServiceClient;
-import com.diagbot.client.bean.GdbResponse;
-import com.diagbot.client.bean.Response;
-import com.diagbot.client.bean.SearchData;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-/**
- * @Description:调用知识图谱对接层服务
- * @Author:zhaops
- * @time: 2018/12/21 11:48
- */
-@Component
-@Slf4j
-public class GraphServiceHystrix implements GraphServiceClient {
-    @Override
-    public Response<GdbResponse> highRiskPageData(SearchData searchData) {
-        log.error("【hystrix】调用{}异常", "highRiskPageData");
-        return null;
-    }
-}

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

@@ -1,7 +1,7 @@
 package com.diagbot.facade;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.diagbot.client.NLPServiceClient;
+import com.diagbot.client.AiptServiceClient;
 import com.diagbot.client.bean.Response;
 import com.diagbot.dto.SymptomFeatureDTO;
 import com.diagbot.entity.QuestionInfo;
@@ -25,7 +25,7 @@ import java.util.Map;
 @Component
 public class FeatureFacade {
     @Autowired
-    private NLPServiceClient NLPServiceClient;
+    private AiptServiceClient aiptServiceClient;
     @Autowired
     private QuestionFacade questionFacade;
 
@@ -37,7 +37,7 @@ public class FeatureFacade {
      */
     public List<SymptomFeatureDTO> getSymptomFeature(String text) {
         List<SymptomFeatureDTO> symptomFeatureDTOList = Lists.newLinkedList();
-        Response<List<Map<String, Object>>> res = NLPServiceClient.symptomFeaturePageData(text);
+        Response<List<Map<String, Object>>> res = aiptServiceClient.symptomFeaturePageData(text);
         if (null == res || null == res.getData()) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "AI没有返回结果");
         }

+ 20 - 43
icss-service/src/main/java/com/diagbot/facade/PushFacade.java

@@ -1,9 +1,9 @@
 package com.diagbot.facade;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.client.AiptServiceClient;
-import com.diagbot.client.BigDataServiceClient;
 import com.diagbot.client.TranServiceClient;
 import com.diagbot.client.bean.FeatureRate;
 import com.diagbot.client.bean.GdbResponse;
@@ -65,8 +65,6 @@ import java.util.stream.Collectors;
  */
 @Component
 public class PushFacade {
-    @Autowired
-    private BigDataServiceClient bigDataServiceClient;
     @Autowired
     private QuestionFacade questionFacade;
     @Autowired
@@ -151,29 +149,27 @@ public class PushFacade {
     }
 
     /**
-     * 推理接口
+     * 中间层接口
      *
-     * @param pushVO
-     * @return
+     * @param searchData
+     * @return ResponseData
      */
-    public ResponseData pushAI(PushVO pushVO) {
-        SearchData searchData = assembleData(pushVO);
-        Response<ResponseData> res = bigDataServiceClient.bayesPageData(searchData);
+    public ResponseData pushAipt(SearchData searchData) {
+        Response<ResponseData> res = aiptServiceClient.aiptData(searchData);
         if (null == res || null == res.getData()) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "AI没有返回结果");
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "中间层没有返回结果");
         }
-        System.out.println(res.getData().getTreat());
         return res.getData();
     }
 
     /**
-     * 中间层接口
+     * 获取量表
      *
      * @param searchData
-     * @return ResponseData
+     * @return
      */
-    public ResponseData pushAipt(SearchData searchData) {
-        Response<ResponseData> res = aiptServiceClient.aiptData(searchData);
+    public Map<String, Object> scale(SearchData searchData) {
+        Response<Map<String, Object>> res = aiptServiceClient.scale(searchData);
         if (null == res || null == res.getData()) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "中间层没有返回结果");
         }
@@ -275,7 +271,7 @@ public class PushFacade {
                 highRiskMap.put("disease", String.join(",", nameList));
                 SearchData searchData = new SearchData();
                 searchData.setDiag(String.join(",", nameList));
-                Response<GdbResponse> graphRes = bigDataServiceClient.highRiskPageData(searchData);
+                Response<GdbResponse> graphRes = aiptServiceClient.highRisk(searchData);
                 if (graphRes != null) {
                     Map<String, String> graphResult = graphRes.getData().getResult();
                     if (graphResult.size() > 0) {
@@ -325,22 +321,10 @@ public class PushFacade {
 
         //量表内容 featuretype=21
         if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Scale.getKey()))) {
-            Map<String, JSONObject> scale = data.getScale();
-            /***********************测试数据********************************/
-            if (scale == null) {
-                scale = new LinkedHashMap<>();
-                String scaleStr = "{\"type\":\"checkbox\",\"details\":[{\"name\":\"轻度\",\"isSelected\":0}," +
-                        "{\"name\":\"中度\",\"isSelected\":1},{\"name\":\"重度\",\"isSelected\":0}]}";
-                JSONObject scaleJson = JSONObject.parseObject(scaleStr);
-                scale.put("高血压量表1", scaleJson);
-            }
-            /***********************正式流程********************************/
+            Map<String, Object> scale = scale(aiSearchData);
             String scaleContent = "";
-            if (scale != null && scale.get(pushVO.getScaleName()) != null) {
-                JSONObject scaleJson = scale.get(pushVO.getScaleName());
-                if (scaleJson != null) {
-                    scaleContent = scaleJson.toJSONString();
-                }
+            if (scale != null && scale.size() > 0) {
+                scaleContent = JSON.toJSONString(scale);
             }
             List<ScaleContent> scaleContentList = scaleContentFacade.getContent(pushVO.getScaleId(), scaleContent);
             pushDTO.setScale(scaleContentList);
@@ -730,7 +714,7 @@ public class PushFacade {
             //警惕
             searchData = new SearchData();
             searchData.setDiag(String.join(",", disNameList));
-            Response<GdbResponse> graphRes = bigDataServiceClient.highRiskPageData(searchData);
+            Response<GdbResponse> graphRes = aiptServiceClient.highRisk(searchData);
             Map<String, String> graphResult = graphRes.getData().getResult();
             if (graphResult.size() > 0) {
                 List<EMRQuestionDTO> highRiskDisList = Lists.newLinkedList();
@@ -773,18 +757,11 @@ public class PushFacade {
             }
         }
         SearchData searchData = assembleData(pushVO);
-        ResponseData data = pushAipt(searchData);
-        Map<String, JSONObject> scale = data.getScale();
-        if (scale == null) {
-            String scaleStr = "{\"type\":\"checkbox\",\"details\":[{\"name\":\"轻度\",\"isSelected\":0}," +
-                    "{\"name\":\"中度\",\"isSelected\":1},{\"name\":\"重度\",\"isSelected\":0}]}";
-            JSONObject scaleJson = JSONObject.parseObject(scaleStr);
-            scale = new LinkedHashMap<>();
-            scale.put("高血压量表1", scaleJson);
-        }
+        Map<String, Object> scale = scale(searchData);
+
         String scaleContent = "";
-        if (scale.get(pushVO.getScaleName()) != null) {
-            scaleContent = scale.get(pushVO.getScaleName()).toJSONString();
+        if (scale != null && scale.size() > 0) {
+            scaleContent = JSON.toJSONString(scale);
         }
         return scaleContent;
     }