Przeglądaj źródła

推理调中间层

Zhaops 6 lat temu
rodzic
commit
294fc0a4fd

+ 20 - 0
aipt-service/src/main/java/com/diagbot/client/AIServiceClient.java

@@ -0,0 +1,20 @@
+package com.diagbot.client;
+
+import com.diagbot.client.bean.Response;
+import com.diagbot.client.bean.ResponseData;
+import com.diagbot.vo.SearchVo;
+import com.diagbot.client.hystrix.AIServiceHystrix;
+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 = "AI", url = "${ai.server.address}", fallback = AIServiceHystrix.class)
+public interface AIServiceClient {
+    @PostMapping(value = "/push-web/algorithm/neural")
+    Response<ResponseData> bayesPageData(@RequestBody SearchVo searchVo);
+}

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

@@ -0,0 +1,23 @@
+package com.diagbot.client.hystrix;
+
+import com.diagbot.client.AIServiceClient;
+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;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2018/11/20 13:15
+ */
+@Component
+@Slf4j
+public class AIServiceHystrix implements AIServiceClient {
+    @Override
+    public Response<ResponseData> bayesPageData(SearchVo searchVo) {
+        log.error("【hystrix】调用{}异常", "bayesPageData");
+        return null;
+    }
+}

+ 8 - 6
icss-service/src/main/java/com/diagbot/facade/PushFacade.java

@@ -188,8 +188,8 @@ public class PushFacade {
      */
     public PushDTO pushInner(PushVO pushVO, Integer mode) {
         PushDTO pushDTO = new PushDTO();
-        //SearchData searchData = assembleData(pushVO);
-        ResponseData data = pushAI(pushVO);
+        SearchData aiSearchData = assembleData(pushVO);
+        ResponseData data = pushAipt(aiSearchData);
 
         //大数据返回内容
         List<FeatureRate> dis = data.getDis();
@@ -490,7 +490,7 @@ public class PushFacade {
         pushVO.setLis(lisResultVOList);
 
         SearchData searchData = assembleData(pushVO);
-        ResponseData responseData = pushAI(pushVO);
+        ResponseData responseData = pushAipt(searchData);
         PushKYJDTO pushKYJDTO = new PushKYJDTO();
         pushKYJDTO.setLabs(responseData.getLabs());
         pushKYJDTO.setDis(responseData.getDis());
@@ -649,7 +649,7 @@ public class PushFacade {
         }
 
         SearchData searchData = assembleData(pushVO);
-        ResponseData data = pushAI(pushVO);
+        ResponseData data = pushAipt(searchData);
         String featureType = pushVO.getFeatureType();
         String[] featureTypes = featureType.split(",|,");
         Set<String> featureTypeSet = new HashSet(Arrays.asList(featureTypes));
@@ -772,7 +772,8 @@ public class PushFacade {
                 }
             }
         }
-        ResponseData data = pushAI(pushVO);
+        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}," +
@@ -807,7 +808,8 @@ public class PushFacade {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "非慢病,不能获取管理评估内容");
         }
 
-        ResponseData data = pushAI(pushVO);
+        SearchData searchData = assembleData(pushVO);
+        ResponseData data = pushAipt(searchData);
         Map<String, JSONObject> managementEvaluationMap = data.getManagementEvaluation();
         if (managementEvaluationMap == null) {
             managementEvaluationMap = new LinkedHashMap<>();

+ 1 - 1
icss-service/src/main/java/com/diagbot/web/PushController.java

@@ -126,7 +126,7 @@ public class PushController {
     @SysLogger("pushAI")
     public RespDTO<ResponseData> pushAI(@RequestBody @Valid PushVO pushVO) {
         SearchData searchData = pushFacade.assembleData(pushVO);
-        return RespDTO.onSuc(pushFacade.pushAI(pushVO));
+        return RespDTO.onSuc(pushFacade.pushAipt(searchData));
     }
 
     @ApiOperation(value = "推理接口(快易检)[by:zhaops]",