|
@@ -142,6 +142,33 @@ public class OcrUtil {
|
|
return licenseDTO;
|
|
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内容
|
|
// 提取json的data内容
|
|
public static JSONObject getData(String json) {
|
|
public static JSONObject getData(String json) {
|
|
JSONObject jsonObject = JSONObject.parseObject(json);
|
|
JSONObject jsonObject = JSONObject.parseObject(json);
|
|
@@ -165,4 +192,5 @@ public class OcrUtil {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
}
|
|
}
|