Переглянути джерело

fix:"证照识别功能增加开户许可证"

soobin 4 місяців тому
батько
коміт
a03d4f8ffa

+ 1 - 3
src/main/java/com/szwl/controller/PurseController.java

@@ -162,9 +162,7 @@ public class PurseController {
             } else {
                 userLicenseService.save(userLicense);
             }
-            if (!imageType.equals("accountLicense")) {
-                licenseDTO = userLicenseService.recognize(imageType, file);
-            }
+            licenseDTO = userLicenseService.recognize(imageType, file);
         } catch (Exception e) {
             e.printStackTrace();
         }

+ 12 - 0
src/main/java/com/szwl/model/dto/LicenseDTO.java

@@ -41,4 +41,16 @@ public class LicenseDTO {
 
     @ApiModelProperty(value = "营业执照地址")
     private String businessLicenseAddress;
+
+    @ApiModelProperty(value = "对公账号")
+    private String accountNo;
+
+    @ApiModelProperty(value = "对公账号开户行")
+    private String accountBank;
+
+    @ApiModelProperty(value = "法定代表人")
+    private String legalPerson;
+
+    @ApiModelProperty(value = "开户公司名称")
+    private String accountName;
 }

+ 28 - 0
src/main/java/com/szwl/model/utils/OcrUtil.java

@@ -142,6 +142,33 @@ public class OcrUtil {
         return licenseDTO;
     }
 
+    // 开户许可证识别
+    public static LicenseDTO getAccountLicense(MultipartFile file) {
+        LicenseDTO licenseDTO = new LicenseDTO();
+        try {
+            AsyncClient client = OcrUtil.getAsyncClient();
+
+            RecognizeBankAccountLicenseRequest recognizeBankAccountLicenseRequest = RecognizeBankAccountLicenseRequest.builder()
+                    .body(file.getInputStream())
+                    .build();
+            CompletableFuture<RecognizeBankAccountLicenseResponse> response = client.recognizeBankAccountLicense(recognizeBankAccountLicenseRequest);
+            RecognizeBankAccountLicenseResponse resp = response.get();
+            RecognizeBankAccountLicenseResponseBody body = resp.getBody();
+            String result = new Gson().toJson(body);
+            client.close();
+            JSONObject data = OcrUtil.getData(result);
+            if (data != null) {
+                licenseDTO.setAccountNo(data.getString("bankAccount"));
+                licenseDTO.setAccountBank(data.getString("depositaryBank"));
+                licenseDTO.setLegalPerson(data.getString("legalRepresentative"));
+                licenseDTO.setAccountName(data.getString("customerName"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return licenseDTO;
+    }
+
     // 提取json的data内容
     public static JSONObject getData(String json) {
         JSONObject jsonObject = JSONObject.parseObject(json);
@@ -165,4 +192,5 @@ public class OcrUtil {
     }
 
 
+
 }

+ 7 - 0
src/main/java/com/szwl/service/impl/UserLicenseServiceImpl.java

@@ -31,14 +31,21 @@ public class UserLicenseServiceImpl extends ServiceImpl<UserLicenseMapper, UserL
                     licenseDTO = OcrUtil.getIdCardInfo(file);
                     break;
                 case "idCardBack":
+                    // 身份证反面
                     licenseDTO = OcrUtil.getIdCardInfo(file);
                     break;
                 case "bankCard":
+                    // 银行卡
                     licenseDTO = OcrUtil.getBankCardInfo(file);
                     break;
                 case "businessLicense":
+                    // 营业执照
                     licenseDTO = OcrUtil.getBusinessLicense(file);
                     break;
+                case "accountLicense":
+                    // 开户许可证
+                    licenseDTO = OcrUtil.getAccountLicense(file);
+                    break;
                 default:
                     break;
             }