Browse Source

返回结果统一

gaodm 6 years atrás
parent
commit
563a608fc6

+ 4 - 2
common/src/main/java/com/diagbot/util/RespDTOUtil.java

@@ -17,7 +17,8 @@ public class RespDTOUtil {
      * @return 是否成功
      */
     public static <T> boolean respIsOK(RespDTO<T> respDTO){
-        if (respDTO == null
+        if (null == respDTO
+                || null == respDTO.data
                 || !CommonErrorCode.OK.getCode().equals(respDTO.code)) {
             return false;
         }
@@ -32,7 +33,8 @@ public class RespDTOUtil {
      * @return 是否成功
      */
     public static <T> boolean respIsNG(RespDTO<T> respDTO){
-        if (respDTO == null
+        if (null == respDTO
+                || null == respDTO.data
                 || !CommonErrorCode.OK.getCode().equals(respDTO.code)) {
             return true;
         }

+ 5 - 6
icss-service/src/main/java/com/diagbot/client/AiptServiceClient.java

@@ -2,7 +2,6 @@ package com.diagbot.client;
 
 import com.diagbot.client.bean.CalculateData;
 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;
@@ -30,19 +29,19 @@ import java.util.Map;
 @FeignClient(value = "aipt-service", fallback = AiptServiceHystrix.class)
 public interface AiptServiceClient {
     @PostMapping(value = "/clinicaldata/processData")
-    Response<ResponseData> aiptData(@RequestBody SearchData searchData);
+    RespDTO<ResponseData> aiptData(@RequestBody SearchData searchData);
 
     @PostMapping(value = "/clinicaldata/scale")
-    Response<Map<String, Object>> scale(@RequestBody SearchData searchData);
+    RespDTO<Map<String, Object>> scale(@RequestBody SearchData searchData);
 
     @PostMapping(value = "/nlpService/symptomFeature")
-    Response<List<Map<String, Object>>> symptomFeaturePageData(@RequestParam("text") String text);
+    RespDTO<List<Map<String, Object>>> symptomFeaturePageData(@RequestParam("text") String text);
 
     @PostMapping("/clinicaldata/highRisk")
-    Response<GdbResponse> highRisk(@RequestBody SearchData searchData);
+    RespDTO<GdbResponse> highRisk(@RequestBody SearchData searchData);
 
     @PostMapping(value = "/clinicaldata/scaleCalc")
-    Response<Map<String, Object>> scaleCalc(@RequestBody CalculateData calculateData);
+    RespDTO<Map<String, Object>> scaleCalc(@RequestBody CalculateData calculateData);
 
     @PostMapping(value = "/scale/getList")
     RespDTO<List<DisScaleDTO>> getList(@RequestBody DisScaleVO scaleVO);

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

@@ -31,31 +31,31 @@ import java.util.Map;
 @Slf4j
 public class AiptServiceHystrix implements AiptServiceClient {
     @Override
-    public Response<ResponseData> aiptData(SearchData searchData) {
+    public RespDTO<ResponseData> aiptData(SearchData searchData) {
         log.error("【hystrix】调用{}异常", "aiptData");
         return null;
     }
 
     @Override
-    public Response<Map<String, Object>> scale(@RequestBody SearchData searchData) {
+    public RespDTO<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) {
+    public RespDTO<List<Map<String, Object>>> symptomFeaturePageData(@RequestParam("text") String text) {
         log.error("【hystrix】调用{}异常", "symptomFeaturePageData");
         return null;
     }
 
     @Override
-    public Response<GdbResponse> highRisk(@RequestBody SearchData searchData) {
+    public RespDTO<GdbResponse> highRisk(@RequestBody SearchData searchData) {
         log.error("【hystrix】调用{}异常", "highRisk");
         return null;
     }
 
     @Override
-    public Response<Map<String, Object>> scaleCalc(@RequestBody CalculateData calculateData) {
+    public RespDTO<Map<String, Object>> scaleCalc(@RequestBody CalculateData calculateData) {
         log.error("【hystrix】调用{}异常", "scaleCalc");
         return null;
     }

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

@@ -2,8 +2,10 @@ package com.diagbot.facade;
 
 import com.diagbot.client.AiptServiceClient;
 import com.diagbot.client.bean.Response;
+import com.diagbot.dto.RespDTO;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
+import com.diagbot.util.RespDTOUtil;
 import com.diagbot.vo.CalculateVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -21,11 +23,11 @@ public class CalculateFacade {
     AiptServiceClient aiptServiceClient;
 
     public Map<String, Object> calculate(CalculateVO calculateVO) {
-        Response<Map<String, Object>> res = aiptServiceClient.scaleCalc(calculateVO);
-        if (res == null || res.getData() == null) {
+        RespDTO<Map<String, Object>> res = aiptServiceClient.scaleCalc(calculateVO);
+        if (RespDTOUtil.respIsNG(res)) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "计算没有结果返回");
         }
-        Map<String, Object> map = res.getData();
+        Map<String, Object> map = res.data;
         return map;
     }
 }

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

@@ -3,6 +3,7 @@ package com.diagbot.facade;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.client.AiptServiceClient;
 import com.diagbot.client.bean.Response;
+import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.SymptomFeatureDTO;
 import com.diagbot.entity.QuestionInfo;
 import com.diagbot.enums.DisTypeEnum;
@@ -11,6 +12,7 @@ import com.diagbot.enums.QuestionTypeEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.util.ListUtil;
+import com.diagbot.util.RespDTOUtil;
 import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -40,11 +42,11 @@ public class FeatureFacade {
      */
     public List<SymptomFeatureDTO> getSymptomFeature(String text) {
         List<SymptomFeatureDTO> symptomFeatureDTOList = Lists.newLinkedList();
-        Response<List<Map<String, Object>>> res = aiptServiceClient.symptomFeaturePageData(text);
-        if (null == res || null == res.getData()) {
+        RespDTO<List<Map<String, Object>>> res = aiptServiceClient.symptomFeaturePageData(text);
+        if (RespDTOUtil.respIsNG(res)) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "AI没有返回结果");
         }
-        List<Map<String, Object>> symptomFeatureList = res.getData();
+        List<Map<String, Object>> symptomFeatureList = res.data;
         List<String> symptomNameList = Lists.newLinkedList();
         for (Map<String, Object> symptomFeature : symptomFeatureList) {
             if (symptomFeature != null) {

+ 14 - 12
icss-service/src/main/java/com/diagbot/facade/PushFacade.java

@@ -19,6 +19,7 @@ import com.diagbot.dto.PushDTO;
 import com.diagbot.dto.PushEMRDTO;
 import com.diagbot.dto.PushKYJDTO;
 import com.diagbot.dto.QuestionDTO;
+import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.DeptInfo;
 import com.diagbot.entity.DeptVital;
 import com.diagbot.entity.QuestionInfo;
@@ -36,6 +37,7 @@ import com.diagbot.util.BeanUtil;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.FastJsonUtils;
 import com.diagbot.util.ListUtil;
+import com.diagbot.util.RespDTOUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.vo.EMRPushVO;
 import com.diagbot.vo.HosCodeVO;
@@ -155,13 +157,13 @@ public class PushFacade {
      * @return ResponseData
      */
     public ResponseData pushAipt(SearchData searchData) {
-        Response<ResponseData> res = aiptServiceClient.aiptData(searchData);
+        RespDTO<ResponseData> res = aiptServiceClient.aiptData(searchData);
         if (null == res) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "中间层没有返回结果");
-        } else if (null == res.getData()) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, res.getMsg());
+        } else if (null == res.data) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, res.msg);
         }
-        return res.getData();
+        return res.data;
     }
 
     /**
@@ -171,11 +173,11 @@ public class PushFacade {
      * @return
      */
     public Map<String, Object> scale(SearchData searchData) {
-        Response<Map<String, Object>> res = aiptServiceClient.scale(searchData);
-        if (null == res || null == res.getData()) {
+        RespDTO<Map<String, Object>> res = aiptServiceClient.scale(searchData);
+        if (RespDTOUtil.respIsNG(res)) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "量表数据暂无内容");
         }
-        return res.getData();
+        return res.data;
     }
 
     /**
@@ -288,9 +290,9 @@ public class PushFacade {
                 highRiskMap.put("disease", String.join(",", nameList));
                 SearchData searchData = new SearchData();
                 searchData.setDiag(String.join(",", nameList));
-                Response<GdbResponse> graphRes = aiptServiceClient.highRisk(searchData);
-                if (graphRes != null && graphRes.getData() != null) {
-                    Map<String, String> graphResult = graphRes.getData().getResult();
+                RespDTO<GdbResponse> graphRes = aiptServiceClient.highRisk(searchData);
+                if (RespDTOUtil.respIsOK(graphRes)) {
+                    Map<String, String> graphResult = graphRes.data.getResult();
                     if (graphResult.size() > 0) {
                         List<String> hrNameList = Lists.newLinkedList();
                         for (Map.Entry<String, String> entry : graphResult.entrySet()) {
@@ -756,8 +758,8 @@ public class PushFacade {
             //警惕
             searchData = new SearchData();
             searchData.setDiag(String.join(",", disNameList));
-            Response<GdbResponse> graphRes = aiptServiceClient.highRisk(searchData);
-            Map<String, String> graphResult = graphRes.getData().getResult();
+            RespDTO<GdbResponse> graphRes = aiptServiceClient.highRisk(searchData);
+            Map<String, String> graphResult = graphRes.data.getResult();
             if (graphResult.size() > 0) {
                 List<EMRQuestionDTO> highRiskDisList = Lists.newLinkedList();
                 for (Map.Entry<String, String> entry : graphResult.entrySet()) {

+ 0 - 2
icss-service/src/main/java/com/diagbot/web/BuriedSomeStatisticalController.java

@@ -33,9 +33,7 @@ public class BuriedSomeStatisticalController {
     @SysLogger("saveBuriedSomeStatisticals")
     @Transactional
     public RespDTO<Boolean> saveBuriedSomeStatisticals(@Valid @RequestBody BuriedSomeStatisticalVO buriedSomeStatisticalVO) {
-
         mySender.outputPointSend(buriedSomeStatisticalVO);
-
         return RespDTO.onSuc(true);
     }
 

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

@@ -1,7 +1,6 @@
 package com.diagbot.web;
 
 import com.diagbot.annotation.SysLogger;
-import com.diagbot.dto.CalculateDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.CalculateFacade;
 import com.diagbot.vo.CalculateVO;