Browse Source

优化解析身份证模块,在报错时提示手动输入。

lighter 4 years ago
parent
commit
3afae903ab

+ 4 - 0
src/main/java/thyyxxk/wxservice_server/service/IdCardAnalyzeService.java

@@ -64,6 +64,10 @@ public class IdCardAnalyzeService {
         byte[] file = Base64.getMimeDecoder().decode(param.getContent().split("base64,")[1]);
         JSONObject res = client.idcard(file, idCardSide, options);
         log.info("解析身份证图像结果:{}", res);
+        if (!res.toString().contains("idcard_number_type")) {
+            return CompletableFuture.completedFuture(ResultVoUtil
+                    .fail(ExceptionEnum.LOGICAL_ERROR, "解析身份证服务出现异常,预计明日恢复,请手动输入您的信息。"));
+        }
         if (1 == res.getInt("idcard_number_type")) {
             IdCardAnalyzeResult idCard = new IdCardAnalyzeResult();
             JSONObject result = res.getJSONObject("words_result");