瀏覽代碼

新增保后列表,图片识别完成,需要更多借据来调整参数

Administrator 10 月之前
父節點
當前提交
a50d650209

+ 9 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java

@@ -4,9 +4,11 @@ import java.io.File;
 import java.time.temporal.TemporalUnit;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.ruoyi.common.utils.IdCardUtil;
 import com.ruoyi.common.utils.ThumbnailUtil;
@@ -140,19 +142,23 @@ public class CommonController {
             //服务器路径
             String urlOnline = filePath + fileName.replace("/profile/upload", "");
             //百度图片识别
-            JSONObject result = IdCardUtil.accurateBasic(urlOnline);
-            System.out.println(result);
+            Map<String, Object> map = IdCardUtil.accurateBasic(urlOnline);
+            if (map == null || map.size() == 0) {
+                return AjaxResult.error("当前图片不是借据或者无法识别");
+            }
             ajax.put("url", url);
             ajax.put("urlOnline", urlOnline);
             ajax.put("fileName", fileName);
             ajax.put("newFileName", FileUtils.getName(fileName));
             ajax.put("originalFilename", file.getOriginalFilename());
-            ajax.put("OCR", result);
+            ajax.put("actuallyAmount", map.get("actuallyAmount"));
+            ajax.put("actuallyTime", map.get("actuallyTime"));
             return ajax;
         } catch (Exception e) {
             return AjaxResult.error(e.getMessage());
         }
     }
+
     /**
      * 通用上传请求(多个)
      */

+ 12 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/loan/LoanApplicationController.java

@@ -129,6 +129,18 @@ public class LoanApplicationController extends BaseController {
         return loanApplicationService.updateLoanApplication(loanApplication);
     }
 
+
+    /**
+     * 修改贷款申请主新只新增实际放款金额(万元)实际放款时间
+     */
+    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
+    @PreAuthorize("@ss.hasPermi('system:application:editActually')")
+    @Log(title = "贷款申请主", businessType = BusinessType.UPDATE)
+    @PostMapping("/putActually")
+    public AjaxResult editActually(@RequestBody LoanApplication loanApplication) {
+        return loanApplicationService.updateLoanApplicationActually(loanApplication);
+    }
+
     /**
      * 删除贷款申请主
      */

+ 283 - 113
ruoyi-common/src/main/java/com/ruoyi/common/utils/IdCardUtil.java

@@ -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();
 }

+ 8 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/LoanApplicationServiceImpl.java

@@ -415,6 +415,14 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
         int rows = loanApplicationMapper.updateLoanApplication(loanApplication);
         return rows > 0 ? AjaxResult.success() : AjaxResult.error();
     }
+    /**
+     * 修改贷款申请主新只新增实际放款金额(万元)实际放款时间
+     */
+    @Override
+    public AjaxResult updateLoanApplicationActually(LoanApplication loanApplication) {
+        int rows = loanApplicationMapper.updateLoanApplication(loanApplication);
+        return rows > 0 ? AjaxResult.success() : AjaxResult.error();
+    }
 
     /**
      * 暂存

+ 1 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/loan/LoanApplication.java

@@ -38,6 +38,7 @@ public class LoanApplication extends BaseEntity
     /**
      * 实际放款时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date actuallyTime;
 
     /** 申请银行 */

+ 4 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/loan/ILoanApplicationService.java

@@ -54,6 +54,10 @@ public interface ILoanApplicationService
      * @return 结果
      */
     public AjaxResult updateLoanApplication(LoanApplication loanApplication);
+    /**
+     * 修改贷款申请主新只新增实际放款金额(万元)实际放款时间
+     */
+    public AjaxResult updateLoanApplicationActually(LoanApplication loanApplication);
 
     /**
      * 暂存

+ 1 - 0
ruoyi-system/src/main/resources/mapper/system/LoanApplicationMapper.xml

@@ -530,6 +530,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="applicationType != null and applicationType != ''">application_type = #{applicationType},</if>
             <if test="applicationAmount != null">application_amount = #{applicationAmount},</if>
             <if test="actuallyAmount != null">actually_amount = #{actuallyAmount},</if>
+            <if test="actuallyTime != null">actually_time = #{actuallyTime},</if>
             <if test="applicationBank != null and applicationBank != ''">application_bank = #{applicationBank},</if>
             <if test="usagePeriod != null and usagePeriod != ''">usage_period = #{usagePeriod},</if>
             <if test="purposeFunds != null and purposeFunds != ''">purpose_funds = #{purposeFunds},</if>