|
@@ -553,7 +553,7 @@ public class IdCardUtil {
|
|
|
map.put("establishData", establishData);
|
|
|
map.put("businessTerm", businessTerm);
|
|
|
map.put("businessScope", businessScope);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return AjaxResult.error("营业执照识别失败,请检查。");
|
|
|
}
|
|
|
return AjaxResult.success(map);
|
|
@@ -675,7 +675,7 @@ public class IdCardUtil {
|
|
|
// 请输入场景ID+L。1000009979场景id固定值
|
|
|
request.setSceneId(1000009979L);
|
|
|
// 设置商户请求的唯一标识。
|
|
|
- request.setOuterOrderNo(UUID.randomUUID().toString().replaceAll("-",""));
|
|
|
+ request.setOuterOrderNo(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
// 认证方案。
|
|
|
request.setProductCode("ID_PRO");
|
|
|
// 模式。要进行活体检测的类型。取值:
|
|
@@ -695,7 +695,7 @@ public class IdCardUtil {
|
|
|
request.setMetaInfo(sysUserIdcardVo.getMetaInfo());
|
|
|
//业务页面回跳的目标地址。
|
|
|
String returnUrl = sysUserIdcardVo.getReturnUrl();
|
|
|
- if (StringUtils.isNotEmpty(returnUrl)){
|
|
|
+ if (StringUtils.isNotEmpty(returnUrl)) {
|
|
|
//H5的model不一样
|
|
|
request.setModel("MULTI_ACTION");
|
|
|
request.setReturnUrl(returnUrl);
|
|
@@ -792,12 +792,13 @@ public class IdCardUtil {
|
|
|
|
|
|
/**
|
|
|
* 图片文字识别
|
|
|
- * @param filePath 本地文件路径
|
|
|
+ *
|
|
|
+ * @param filePath 本地文件路径
|
|
|
* @return
|
|
|
*/
|
|
|
- public static Map<String,Object> accurateBasic(String filePath) {
|
|
|
+ public static Map<String, Object> accurateBasic(String filePath) {
|
|
|
String imgParam = getFileContentAsBase64(filePath, true);
|
|
|
- String param = "image=" + imgParam+"&detect_direction=true";
|
|
|
+ String param = "image=" + imgParam + "&detect_direction=true";
|
|
|
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
|
|
|
// image 可以通过 getFileContentAsBase64("C:\fakepath\zhizhao.jpg") 方法获取,如果Content-Type是application/x-www-form-urlencoded时,第二个参数传true
|
|
|
RequestBody body = RequestBody.create(mediaType, param);
|
|
@@ -919,7 +920,7 @@ public class IdCardUtil {
|
|
|
}*/
|
|
|
Response response = HTTP_CLIENT.newCall(request).execute();
|
|
|
String result = response.body().string();
|
|
|
- if (StringUtils.isNotBlank(result)){
|
|
|
+ if (StringUtils.isNotBlank(result)) {
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
JSONArray wordsResult = jsonObject.getJSONArray("words_result");
|
|
|
Map<String, Object> bankMap = bank(wordsResult);
|
|
@@ -931,168 +932,66 @@ public class IdCardUtil {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
- /**
|
|
|
- * {
|
|
|
- * "words_result": [
|
|
|
- * {
|
|
|
- * "words": "-20230822-287806450001.pdf-Adobe Reader"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "文档(D)"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "工具①"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "窗口(W)"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "帮助H)"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "/1"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "125%"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "查找"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "中国银行"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "贷款放款回单"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "BANK OF CHINA"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "客户号:572904279"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "日期:2023年08月22日"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "收款人账号:178257778412"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "贷款账号:181273443198"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "收款人名称:潜山县永杰竹业有限公司"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "收款人开户行:中国银行潜山支行"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "金额:CNY1,000,000.00"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "人民币壹佰万元整"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "合同金额:CNY1,000,000.00"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "合同编号:15003616890"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "起息日:2023/08/22"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "到期日:2024/08/22"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "借款人名称:潜山县永杰竹业有限公司"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "收款人卡号:"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "附言:"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "中国银行股份有限公司"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "电子回单专用章"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "如您已通过银行网点取得相应纸质回单,请注意核对,勿重复记账!"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "交易机构:08731"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "交易渠道:柜台"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "交易流水号:80114160-996"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "经办:"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "回单编号:2308220801141608"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "回单验证码:24BN8WT36FM2"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "打印时间:"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "打印次数:"
|
|
|
- * },
|
|
|
- * {
|
|
|
- * "words": "次"
|
|
|
- * }
|
|
|
- * ],
|
|
|
- * "words_result_num": 38,
|
|
|
- * "direction": 0,
|
|
|
- * "log_id": 1825789540967617800
|
|
|
- * }
|
|
|
- */
|
|
|
|
|
|
/**
|
|
|
* 从图片识别中提取数据
|
|
|
+ *
|
|
|
* @param wordsResult
|
|
|
* @return
|
|
|
*/
|
|
|
- public static Map<String,Object> bank(JSONArray wordsResult){
|
|
|
- Map<String,Object> map = new HashMap<>(2);
|
|
|
+ public static Map<String, Object> bank(JSONArray wordsResult) {
|
|
|
+ Map<String, Object> map = new HashMap<>(2);
|
|
|
for (int i = 0; i < wordsResult.size(); i++) {
|
|
|
String o = wordsResult.get(i).toString();
|
|
|
- if (o.contains("\"words\":\"中国银行\"")){
|
|
|
+ if (o.contains("\"words\":\"中国银行\"")) {
|
|
|
for (int p = 0; p < wordsResult.size(); p++) {
|
|
|
String b = wordsResult.get(p).toString();
|
|
|
- if (b.contains("合同金额")){
|
|
|
+ if (b.contains("合同金额")) {
|
|
|
String[] split = b.split(":");
|
|
|
- String cny = split[1].replace("CNY", "").replace("\"}", "").replace(",","");
|
|
|
+ String cny = split[1].replace("CNY", "").replace("\"}", "").replace(",", "");
|
|
|
double actuallyAmount = Double.parseDouble(cny) / 10000;
|
|
|
- map.put("actuallyAmount",actuallyAmount);
|
|
|
+ map.put("actuallyAmount", actuallyAmount);
|
|
|
}
|
|
|
- if (b.contains("起息日")){
|
|
|
+ if (b.contains("起息日")) {
|
|
|
String[] split = b.split(":");
|
|
|
String actuallyTime = split[1].replace("\"}", "").replace("/", "-");
|
|
|
- map.put("actuallyTime",actuallyTime);
|
|
|
+ map.put("actuallyTime", actuallyTime);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
- }else if (o.contains("\"words\":\"安徽农金\"")){
|
|
|
+ } else if (o.contains("\"words\":\"安徽农金\"")) {
|
|
|
for (int p = 0; p < wordsResult.size(); p++) {
|
|
|
String b = wordsResult.get(p).toString();
|
|
|
- if (b.contains("(小写)")){
|
|
|
+ if (b.contains("(小写)")) {
|
|
|
String[] split = b.split(":");
|
|
|
- String cny = split[1].replace("¥", "").replace("\"}", "").replace(",","");
|
|
|
+ String cny = split[1].replace("¥", "").replace("\"}", "").replace(",", "");
|
|
|
double actuallyAmount = Double.parseDouble(cny) / 10000;
|
|
|
- map.put("actuallyAmount",actuallyAmount);
|
|
|
+ map.put("actuallyAmount", actuallyAmount);
|
|
|
}
|
|
|
- if (b.contains("借款日期")){
|
|
|
+ if (b.contains("借款日期")) {
|
|
|
String[] split = b.split(":");
|
|
|
String actuallyTime = split[1].replace("\"}", "").replace("年", "-").replace("月", "-").replace("日", "");
|
|
|
- map.put("actuallyTime",actuallyTime);
|
|
|
+ map.put("actuallyTime", actuallyTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ } else if (o.contains("\"words\":\"中国建设银行\"")) {
|
|
|
+ //[{"words":"中国建设银行"},{"words":"China Construction Bank"},{"words":"贷款开户放款复核单"},{"words":"交易日期:"},{"words":"20240808"},{"words":"交易流水号:"},{"words":"102015LN21723106881097611"},{"words":"客户编号:"},{"words":"033811000008657356"},{"words":"产品编码:"},{"words":"00000082"},{"words":"客户名称:"},{"words":"潜山县华达实业有限公司"},{"words":"产品名称:"},{"words":"流动资金贷款"},{"words":"币种名称:人民币"},{"words":"币种代码:156"},{"words":"贷款账号:"},{"words":"34050368430800000726"},{"words":"放款金额:"},{"words":"1000000.00"},{"words":"内部账号:"},{"words":"贷转存账号:"},{"words":"中建设银行股份有限公司"},{"words":"34050168480800000976"},{"words":"利率(%):3.750000"},{"words":"贷款放款日期:20240808"},{"words":"到期日期:"},{"words":"潜山支行"},{"words":"20250807"},{"words":"业务专用章"},{"words":"授权:"},{"words":"复核:"},{"words":"经办:"},{"words":"53596089vM"}]
|
|
|
+ for (int p = 0; p < wordsResult.size(); p++) {
|
|
|
+ String b = wordsResult.get(p).toString();
|
|
|
+ if (b.contains("交易日期")) {
|
|
|
+ String result = wordsResult.get(p+1).toString();
|
|
|
+ String[] split = result.split(":");
|
|
|
+ String actuallyTime = split[1].replace("}", "").replace("\"","");
|
|
|
+ map.put("actuallyTime", actuallyTime);
|
|
|
+ }
|
|
|
+ if (b.contains("放款金额")) {
|
|
|
+ String result = wordsResult.get(p+1).toString();
|
|
|
+ String[] split = result.split(":");
|
|
|
+ //"20240808"}
|
|
|
+ String cny = split[1].replace("}", "").replace("\"","");
|
|
|
+ double actuallyAmount = Double.parseDouble(cny) / 10000;
|
|
|
+ map.put("actuallyAmount", actuallyAmount);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -1101,5 +1000,30 @@ public class IdCardUtil {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+/* public static void main(String[] args) {
|
|
|
+ String imgParam = getFileContentAsBase64("D:\\jianhang.jpg", true);
|
|
|
+ String param = "image=" + imgParam + "&detect_direction=true";
|
|
|
+ MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
|
|
|
+ // image 可以通过 getFileContentAsBase64("C:\fakepath\zhizhao.jpg") 方法获取,如果Content-Type是application/x-www-form-urlencoded时,第二个参数传true
|
|
|
+ RequestBody body = RequestBody.create(mediaType, param);
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url("https://aip.baidubce.com/rest/2.0/ocr/v1/accurate_basic?access_token=" + getAccessToken("TvvuZOOh7MgnlDFnw11ln67n", "CY47OI0eKAzYBD2LO55SM3OITzsyq6DK"))
|
|
|
+ .method("POST", body)
|
|
|
+ .addHeader("Content-Type", "application/x-www-form-urlencoded")
|
|
|
+ .addHeader("Accept", "application/json")
|
|
|
+ .build();
|
|
|
+ try {
|
|
|
+ Response response = HTTP_CLIENT.newCall(request).execute();
|
|
|
+ String result = response.body().string();
|
|
|
+ if (StringUtils.isNotBlank(result)) {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
+ JSONArray wordsResult = jsonObject.getJSONArray("words_result");
|
|
|
+ Map<String, Object> bankMap = bank(wordsResult);
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }*/
|
|
|
static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();
|
|
|
}
|