Browse Source

代码优化

gaodm 5 years ago
parent
commit
e0553aeba7
1 changed files with 29 additions and 23 deletions
  1. 29 23
      triage-service/src/main/java/com/diagbot/facade/AIFacade.java

+ 29 - 23
triage-service/src/main/java/com/diagbot/facade/AIFacade.java

@@ -9,6 +9,7 @@ import com.diagbot.dto.AIDTO;
 import com.diagbot.dto.FeatureRateDTO;
 import com.diagbot.dto.FeatureRateDTO;
 import com.diagbot.dto.HospitalDeptDTO;
 import com.diagbot.dto.HospitalDeptDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.RespDTO;
+import com.diagbot.enums.SysTypeEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.exception.CommonException;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.BeanUtil;
@@ -51,29 +52,7 @@ public class AIFacade {
      * @return AI接口返回结果
      * @return AI接口返回结果
      */
      */
     public AIDTO push(AIVO aivo, String type) {
     public AIDTO push(AIVO aivo, String type) {
-        SearchVO searchVO = new SearchVO();
-        searchVO.setAge(aivo.getAge());
-        searchVO.setHosCode(aivo.getHospitalCode());
-        searchVO.setSymptom(aivo.getSymptom());
-        switch (aivo.getSex()) {
-            case 1:
-            case 2:
-                searchVO.setSex(aivo.getSex());
-                break;
-            default:
-                throw new CommonException(CommonErrorCode.PARAM_ERROR, "不能输入男女以外的性别");
-        }
-        searchVO.setFeatureType(type);
-        searchVO.setSysCode("1");
-        switch (type) {
-            case "1":
-                searchVO.setLength(10);
-                break;
-            case "7":
-                searchVO.setLength(10);
-                break;
-        }
-        RespDTO<ResponseData> res = aiptServiceClient.aiptData(searchVO);
+        RespDTO<ResponseData> res = aiptServiceClient.aiptData(assembleData(aivo, type));
         RespDTOUtil.respNGDealCover(res, "中间层没有结果返回");
         RespDTOUtil.respNGDealCover(res, "中间层没有结果返回");
         AIDTO aidto = new AIDTO();
         AIDTO aidto = new AIDTO();
         switch (type) {
         switch (type) {
@@ -220,4 +199,31 @@ public class AIFacade {
         }
         }
         return items;
         return items;
     }
     }
+
+    private SearchVO assembleData(AIVO aivo, String type) {
+        SearchVO searchVO = new SearchVO();
+        searchVO.setAge(aivo.getAge());
+        searchVO.setHosCode(aivo.getHospitalCode());
+        searchVO.setSymptom(aivo.getSymptom());
+        switch (aivo.getSex()) {
+            case 1:
+            case 2:
+                searchVO.setSex(aivo.getSex());
+                break;
+            default:
+                throw new CommonException(CommonErrorCode.PARAM_ERROR, "不能输入男女以外的性别");
+        }
+        searchVO.setFeatureType(type);
+        searchVO.setSysCode("1");
+        switch (type) {
+            case "1":
+                searchVO.setLength(10);
+                break;
+            case "7":
+                searchVO.setLength(10);
+                break;
+        }
+        searchVO.setSysType(SysTypeEnum.TRIAGE_SERVICE.getKey());
+        return searchVO;
+    }
 }
 }