|
@@ -6,6 +6,7 @@ package com.ruoyi.common.utils;
|
|
|
* @Describe:
|
|
|
*/
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.aliyun.cloudauth20190307.Client;
|
|
|
import com.aliyun.cloudauth20190307.models.*;
|
|
|
import com.aliyun.teaopenapi.models.Config;
|
|
@@ -794,7 +795,7 @@ public class IdCardUtil {
|
|
|
* @param filePath 本地文件路径
|
|
|
* @return
|
|
|
*/
|
|
|
- public static JSONObject accurateBasic(String filePath) {
|
|
|
+ public static Map<String,Object> accurateBasic(String filePath) {
|
|
|
String imgParam = getFileContentAsBase64(filePath, true);
|
|
|
String param = "image=" + imgParam+"&detect_direction=true";
|
|
|
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
|
|
@@ -807,129 +808,298 @@ public class IdCardUtil {
|
|
|
.addHeader("Accept", "application/json")
|
|
|
.build();
|
|
|
try {
|
|
|
- //{
|
|
|
- // "words_result": [
|
|
|
- // {
|
|
|
- // "words": "http:/10.0.175.74/ahlm/loan/Sv-2024.07.04/jbview.afx.html.print.printer.html?window页码,2024(w9"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "安徽农金"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "借据"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "ARCU"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "贷款单位:安徽潜山农村商业银行股份有限公司塔畈支行"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "借款人:潜山和沐物流有限公司"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "客户编号:200101281091"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "证件号码:913408243487083682"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "借据编号:860066291011"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "借款合同编号:2397591220240003"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "借款日期:2024年08月09日"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "借款到期日:2025年08月09日"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "借款金额(大写):人民币贰佰万元整"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "(小写):¥2,000,000.00"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "担保方式:保证"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "借款用途说明:进货"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "利率种类:年利率"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "贷款利率:6.09000000%"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "第一联银行贷款债权凭证"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "还款方式:按月结息、到期一次性还本法"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "还款账号:20010128109166600000032"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "以上款项已转入借款人指定账户"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "贷款单位(签章"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "分书·00010X022"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "借款人(签章或按指印):"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "负责人:"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "法定代表人(负责人)"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "孙慧"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "客户经理"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "或授权代理人(签章)"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": ".证件号码:"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "经办人:"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "网址:www.ahrcu.com"
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "words": "客服电话:96669"
|
|
|
- // }
|
|
|
- // ],
|
|
|
- // "words_result_num": 34,
|
|
|
- // "direction": 0,
|
|
|
- // "log_id": 1824253359437875000
|
|
|
- //}
|
|
|
+/* {
|
|
|
+ "words_result": [
|
|
|
+ {
|
|
|
+ "words": "http:/10.0.175.74/ahlm/loan/Sv-2024.07.04/jbview.afx.html.print.printer.html?window页码,2024(w9"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "安徽农金"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "借据"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "ARCU"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "贷款单位:安徽潜山农村商业银行股份有限公司塔畈支行"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "借款人:潜山和沐物流有限公司"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "客户编号:200101281091"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "证件号码:913408243487083682"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "借据编号:860066291011"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "借款合同编号:2397591220240003"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "借款日期:2024年08月09日"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "借款到期日:2025年08月09日"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "借款金额(大写):人民币贰佰万元整"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "(小写):¥2,000,000.00"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "担保方式:保证"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "借款用途说明:进货"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "利率种类:年利率"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "贷款利率:6.09000000%"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "第一联银行贷款债权凭证"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "还款方式:按月结息、到期一次性还本法"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "还款账号:20010128109166600000032"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "以上款项已转入借款人指定账户"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "贷款单位(签章"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "分书·00010X022"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "借款人(签章或按指印):"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "负责人:"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "法定代表人(负责人)"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "孙慧"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "客户经理"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "或授权代理人(签章)"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": ".证件号码:"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "经办人:"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "网址:www.ahrcu.com"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "words": "客服电话:96669"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "words_result_num": 34,
|
|
|
+ "direction": 0,
|
|
|
+ "log_id": 1824253359437875000
|
|
|
+ }*/
|
|
|
Response response = HTTP_CLIENT.newCall(request).execute();
|
|
|
String result = response.body().string();
|
|
|
if (StringUtils.isNotBlank(result)){
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
- return jsonObject;
|
|
|
+ JSONArray wordsResult = jsonObject.getJSONArray("words_result");
|
|
|
+ Map<String, Object> bankMap = bank(wordsResult);
|
|
|
+ return bankMap;
|
|
|
+
|
|
|
}
|
|
|
- System.out.println(response.body().string());
|
|
|
- return null;
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
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);
|
|
|
+ for (int i = 0; i < wordsResult.size(); i++) {
|
|
|
+ String o = wordsResult.get(i).toString();
|
|
|
+ if (o.contains("\"words\":\"中国银行\"")){
|
|
|
+ for (int p = 0; p < wordsResult.size(); p++) {
|
|
|
+ String b = wordsResult.get(p).toString();
|
|
|
+ if (b.contains("合同金额")){
|
|
|
+ String[] split = b.split(":");
|
|
|
+ String cny = split[1].replace("CNY", "").replace("\"}", "").replace(",","");
|
|
|
+ double actuallyAmount = Double.parseDouble(cny) / 10000;
|
|
|
+ map.put("actuallyAmount",actuallyAmount);
|
|
|
+ }
|
|
|
+ if (b.contains("起息日")){
|
|
|
+ String[] split = b.split(":");
|
|
|
+ String actuallyTime = split[1].replace("\"}", "").replace("/", "-");
|
|
|
+ map.put("actuallyTime",actuallyTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }else if (o.contains("\"words\":\"安徽农金\"")){
|
|
|
+ for (int p = 0; p < wordsResult.size(); p++) {
|
|
|
+ String b = wordsResult.get(p).toString();
|
|
|
+ if (b.contains("(小写)")){
|
|
|
+ String[] split = b.split(":");
|
|
|
+ String cny = split[1].replace("¥", "").replace("\"}", "").replace(",","");
|
|
|
+ double actuallyAmount = Double.parseDouble(cny) / 10000;
|
|
|
+ map.put("actuallyAmount",actuallyAmount);
|
|
|
+ }
|
|
|
+ if (b.contains("借款日期")){
|
|
|
+ String[] split = b.split(":");
|
|
|
+ String actuallyTime = split[1].replace("\"}", "").replace("年", "-").replace("月", "-").replace("日", "");
|
|
|
+ map.put("actuallyTime",actuallyTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
|
|
|
static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();
|
|
|
}
|