Ver código fonte

优化psnNo查询

lighter 1 ano atrás
pai
commit
07d15c31b4

+ 14 - 1
src/main/java/thyyxxk/webserver/controller/medicalinsurance/SiQueryController.java

@@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import thyyxxk.webserver.config.auth.PassToken;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.InHspPsnInfo;
 import thyyxxk.webserver.entity.medicalinsurance.outpatient.SpcChrDiseAcct;
@@ -12,6 +13,8 @@ import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
 import thyyxxk.webserver.entity.medicalinsurance.setlinfo.TimesList;
 import thyyxxk.webserver.entity.inpatient.ZyActpatient;
 import thyyxxk.webserver.service.medicalinsurance.SiQueryService;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.StringUtil;
 
 import java.util.List;
 import java.util.Map;
@@ -39,7 +42,17 @@ public class SiQueryController {
     @GetMapping("/fetchPsnNo")
     public ResultVo<String> fetchPsnNo(@RequestParam("socialNo") String socialNo,
                                        @RequestParam("admdvs") String admdvs) {
-        return service.fetchPsnNo(socialNo, admdvs);
+        if (StringUtil.isBlank(socialNo)) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者的身份证不能为空,请补充!");
+        }
+        if (StringUtil.isBlank(admdvs)) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者的参保地区不能为空,请补充!");
+        }
+        String response = service.fetchPsnNo(socialNo, admdvs);
+        if (response.startsWith("SUCCESS")) {
+            return ResultVoUtil.success(response.split(":")[1]);
+        }
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, response);
     }
 
     @PassToken

+ 5 - 11
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiQueryService.java

@@ -59,13 +59,7 @@ public class SiQueryService {
         return ResultVoUtil.success(siPatInfo);
     }
 
-    public ResultVo<String> fetchPsnNo(String socialNo, String admdvs) {
-        if (StringUtil.isBlank(socialNo)) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者的身份证不能为空,请补充!");
-        }
-        if (StringUtil.isBlank(admdvs)) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者的参保地区不能为空,请补充!");
-        }
+    public String fetchPsnNo(String socialNo, String admdvs) {
         JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.OBTAIN_BASIC_PERSON_INFO, admdvs);
         JSONObject data = new JSONObject();
         data.put("mdtrt_cert_type", MdtrtCertType.RESIDENT_IDENTITY_CARD.getCode());
@@ -78,20 +72,20 @@ public class SiQueryService {
         JSONObject result = exec.executeTrade(input, SiFunction.OBTAIN_BASIC_PERSON_INFO);
         log.info("【操作员:{}】,人员基本信息获取:\n参数:{},\n结果:{}", TokenUtil.getInstance().getTokenUserId(), input, result);
         if (null == result) {
-            return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
+            return ExceptionEnum.NETWORK_ERROR.getMessage();
         }
         if (null == result.getInteger(RESULT_CODE)) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
+            return "医保中心报错:" + result.getString("message");
         }
         if (result.getIntValue(RESULT_CODE) == 0) {
             JSONObject output = result.getJSONObject(OUTPUT);
             JSONObject baseinfo = output.getJSONObject("baseinfo");
             String psnNo = baseinfo.getString("psn_no");
             if (StringUtil.notBlank(psnNo)) {
-                return ResultVoUtil.success(psnNo);
+                return "SUCCESS:" + psnNo;
             }
         }
-        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "无法查询到患者的医保个人编码。");
+        return "无法查询到患者的医保个人编码。";
     }
 
     public ResultVo<PsnBaseInfo> obtainBasicPersonInfo(QryPsnBsInfo qryPsnBsInfo) {