LIVE_YE 8 ay önce
ebeveyn
işleme
2eccc3344e

+ 5 - 0
ruoyi-admin/pom.xml

@@ -78,6 +78,11 @@
             <version>5.2.3</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.pdfbox</groupId>
+            <artifactId>pdfbox</artifactId>
+            <version>2.0.24</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 13 - 0
ruoyi-common/pom.xml

@@ -236,6 +236,19 @@
             <artifactId>jiguang-common</artifactId>
             <version>1.1.7</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.itextpdf</groupId>
+            <artifactId>itext-asian</artifactId>
+            <version>5.2.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.itextpdf</groupId>
+            <artifactId>itextpdf</artifactId>
+            <version>5.5.13</version>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 7 - 1
ruoyi-common/src/main/java/com/ruoyi/common/utils/IdCardUtil.java

@@ -1311,6 +1311,7 @@ public class IdCardUtil {
         for (int i = 0; i < wordsResult.size(); i++) {
             String o = wordsResult.get(i).toString();
             if (o.contains("\"words\":\"中国银行\"")) {
+                map.put("zh", "中国银行");
                 for (int p = 0; p < wordsResult.size(); p++) {
                     String b = wordsResult.get(p).toString();
                     if (b.contains("收款人开户行")) {
@@ -1332,15 +1333,17 @@ public class IdCardUtil {
                     if (b.contains("起息日")) {
                         String[] split = b.split(":");
                         strTime = split[1].replace("\"}", "").replace("/", "-");
+                        map.put("qxr", strTime);
                     }
                     if (b.contains("到期日")) {
                         String[] split = b.split(":");
                         endTime = split[1].replace("\"}", "").replace("/", "-");
+                        map.put("dqr", endTime);
                     }
                 }
                 break;
             } else if (o.contains("\"words\":\"安徽农金\"")) {
-
+                map.put("zh", "安徽农金");
                 for (int p = 0; p < wordsResult.size(); p++) {
                     String b = wordsResult.get(p).toString();
                     if (b.contains("贷款单位")) {
@@ -1368,16 +1371,19 @@ public class IdCardUtil {
                     if (b.contains("借款日期")) {
                         String[] split = b.split(":");
                         strTime = split[1].replace("\"}", "").replace("年", "-").replace("月", "-").replace("日", "");
+                        map.put("qxr", strTime);
                     }
                     if (b.contains("借款到日期")) {
                         String[] split = b.split(":");
                         endTime = split[1].replace("\"}", "").replace("年", "-").replace("月", "-").replace("日", "");
+                        map.put("dqr", endTime);
                     }
                 }
 
                 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"}]
+                map.put("zh", "中国建设银行");
                 map.put("dkdw", "中国建设银行");
                 for (int p = 0; p < wordsResult.size(); p++) {
                     String b = wordsResult.get(p).toString();

+ 86 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/Text2PdfUtil.java

@@ -0,0 +1,86 @@
+package com.ruoyi.common.utils;
+
+import com.itextpdf.text.Document;
+import com.itextpdf.text.DocumentException;
+import com.itextpdf.text.Font;
+import com.itextpdf.text.Paragraph;
+import com.itextpdf.text.pdf.BaseFont;
+import com.itextpdf.text.pdf.PdfReader;
+import com.itextpdf.text.pdf.PdfWriter;
+import com.itextpdf.text.pdf.parser.PdfTextExtractor;
+
+import java.io.*;
+import java.nio.charset.Charset;
+
+/**
+ * 需要引入的依赖
+ *
+ * <dependency>
+ *             <groupId>com.itextpdf</groupId>
+ *             <artifactId>itext-asian</artifactId>
+ *             <version>5.2.0</version>
+ *         </dependency>
+ *
+ *         <dependency>
+ *             <groupId>com.itextpdf</groupId>
+ *             <artifactId>itextpdf</artifactId>
+ *             <version>5.5.13</version>
+ *         </dependency>
+ *
+ */
+public class Text2PdfUtil {
+
+    /**
+     * txt文本文件  转pdf文件
+     * @param text   F:/data/te616.txt
+     * @param pdf  F:/data/aet618.pdf
+     * @throws DocumentException
+     * @throws IOException
+     */
+    public static void text2pdf(String text,String pdf) throws DocumentException, IOException {
+        Document doc = new Document();
+        OutputStream os = new FileOutputStream(new File(pdf));
+        PdfWriter.getInstance(doc, os);
+        doc.open();
+        //指定 使用内置的中文字体
+        BaseFont baseFont =
+                BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.EMBEDDED);
+        Font font = new Font(baseFont,12,Font.NORMAL);
+        //指定输出编码为UTF-8
+        InputStreamReader isr = new InputStreamReader(
+                new FileInputStream(new File(text)), Charset.forName("UTF-8"));
+        BufferedReader br = new BufferedReader(isr);
+        String str = "";
+        while((str = br.readLine()) != null){
+            doc.add(new Paragraph(str,font));
+        }
+        isr.close();
+        br.close();
+        doc.close();
+    }
+
+
+    /**
+     * 读取pdf文件的内容
+     * @param filename  F:/data/aet618.pdf
+     * @return  String
+     */
+    public static String readPDF(String filename){
+        StringBuilder result = new StringBuilder();
+        try {
+            PdfReader reader = new PdfReader(filename);
+            int countPage = reader.getNumberOfPages();
+            for(int i=1;i<=countPage;i++){
+                result.append(PdfTextExtractor.getTextFromPage(reader, i));
+            }
+            reader.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return result.toString();
+    }
+
+}
+
+
+

+ 96 - 3
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/LoanApplicationServiceImpl.java

@@ -4,6 +4,7 @@ package com.ruoyi.framework.web.service;
 import com.alibaba.fastjson2.JSONObject;
 import com.deepoove.poi.data.PictureRenderData;
 import com.deepoove.poi.data.Pictures;
+import com.itextpdf.text.DocumentException;
 import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysRole;
@@ -53,6 +54,13 @@ import java.io.IOException;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
 import org.apache.poi.xwpf.usermodel.XWPFParagraph;
 
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.text.PDFTextStripper;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
 
 
 import static com.ruoyi.common.constant.CommonConstants.*;
@@ -1867,6 +1875,11 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
             PictureRenderData picture = Pictures.ofLocal(imagePath).size(70, 70).create();//本地图片地址
             params.put("signPicture", picture);
         }
+
+        SysUserConference userConference = new SysUserConference();
+
+        LoanApplicationFj loanApplicationFjTzs = new LoanApplicationFj();
+
         // 创建一个列表,用来存储要填充到Excel中的数据
         List<Map<String, Object>> list = new ArrayList<>();
         switch (type) {
@@ -1906,13 +1919,20 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
                 break;
             case "4":
                 //查询借据附件
-                LoanApplicationFj loanApplicationFjTzs = new LoanApplicationFj();
                 loanApplicationFjTzs.setLoanApplicationId(loanApplication.getLoanApplicationId());
                 loanApplicationFjTzs.setType("jj");
                 List<LoanApplicationFj> loanApplicationFjs = loanApplicationFjMapper.selectLoanApplicationFjList(loanApplicationFjTzs);
                 if(loanApplicationFjs!=null && loanApplicationFjs.size()>0){
                     loanApplicationFjTzs = loanApplicationFjs.get(0);
                 }
+
+                //查询最新的一条投票数据
+                userConference = sysUserConferenceMapper.selectSysUserConferenceNew(loanApplication.getLoanApplicationId());
+                //将贷款金额转成中文
+                if (ObjectUtils.isNotEmpty(userConference.getLineGuarantee())) {
+                    chineseNum = userConference.getLineGuarantee();
+                }
+                params.put("chineseNum", chineseNum);
                 if(StringUtils.isNotEmpty(loanApplicationFjTzs.getUrl())){
                     // 上传文件路径
                     String filePath = RuoYiConfig.getUploadPath();
@@ -1923,7 +1943,7 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
                     if (map != null || map.size() != 0) {
                         params.put("dkdw", imgMap.get("dkdw"));
                         params.put("jkr", imgMap.get("jkr"));
-                        params.put("jkje", imgMap.get("jkje"));
+                        //params.put("jkje", imgMap.get("jkje"));
                         params.put("jkytsm", imgMap.get("jkytsm"));
                         params.put("hksj", imgMap.get("hksj"));
                     }
@@ -2113,7 +2133,7 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
                 int ty = 0;
                 int fj = 0;
                 int qx = 0;
-                SysUserConference userConference = new SysUserConference();
+
                 userConference.setConferenceTime(loanApplication.getReviewTime());
                 userConference.setLoanApplicationId(loanApplication.getLoanApplicationId());
                 List<SysUserConference> userConferences = sysUserConferenceMapper.selectSysUserConferenceList(userConference);
@@ -2277,6 +2297,73 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
                 fileDir = RuoYiConfig.getProfile() + "/mb/temporarily/" + loanApplicationNumber + "/" + fileNameHz;
                 sheet = ExcelFillUtils.fillOneSheet(templatePath, fileDir, "Sheet1", list);
 
+                path = path + "/" + fileNameHz;
+                break;
+                //todo  担保业务备案表
+            case "21":
+
+                //分支行
+                excelMap.put("fzh", "");
+                //总行
+                excelMap.put("zh", "");
+                //起始日期
+                excelMap.put("qsrq", "");
+                //到期日期
+                excelMap.put("dqrq", "");
+                //贷款利率
+                excelMap.put("dklv", "");
+                //所属行业
+                excelMap.put("sshy", "");
+                excelMap.put("zzqje", "");
+
+                //查询借据附件
+                loanApplicationFjTzs.setLoanApplicationId(loanApplication.getLoanApplicationId());
+                loanApplicationFjTzs.setType("jj");
+                List<LoanApplicationFj> loanApplicationFjList = loanApplicationFjMapper.selectLoanApplicationFjList(loanApplicationFjTzs);
+                if(loanApplicationFjList!=null && loanApplicationFjList.size()>0){
+                    loanApplicationFjTzs = loanApplicationFjList.get(0);
+                }
+
+                if(StringUtils.isNotEmpty(loanApplicationFjTzs.getUrl())){
+                    // 上传文件路径
+                    String filePath = RuoYiConfig.getUploadPath();
+                    //服务器路径
+                    String urlOnline = filePath + loanApplicationFjTzs.getUrl().replace("/profile/upload", "");
+                    //百度图片识别
+                    Map<String, Object> imgMap = IdCardUtil.accurateBasicCj(urlOnline);
+                    if (map != null || map.size() != 0) {
+
+                        //分支行
+                        excelMap.put("fzh", imgMap.get("dkdw"));
+                        //总行
+                        excelMap.put("zh", imgMap.get("zh"));
+                        //起始日期
+                        excelMap.put("qsrq", imgMap.get("qxr"));
+                        //到期日期
+                        excelMap.put("dqrq", imgMap.get("dqr"));
+                        //贷款利率
+                        excelMap.put("dklv", imgMap.get("dklv"));
+                    }
+                }
+
+                //所属行业
+                excelMap.put("sshy", loanApplication.getCategoryType());
+                //主债权金额
+                //查询最新的一条投票数据
+                userConference = sysUserConferenceMapper.selectSysUserConferenceNew(loanApplication.getLoanApplicationId());
+
+                excelMap.put("zzqje", userConference.getLineGuarantee());
+
+
+
+                list.add(excelMap);
+                //fileName = FileUploadUtils.extractFilenameLoanApplicationNumberNoHzm("项目评审意见签批表");
+                fileName = loanApplication.getEnterpriseName() + "-担保业务备案表";
+                fileNameHz = fileName + ".xlsx";
+                templatePath = RuoYiConfig.getProfile() + "/mb/担保业务备案表.xlsx";
+                fileDir = RuoYiConfig.getProfile() + "/mb/temporarily/" + loanApplicationNumber + "/" + fileNameHz;
+                sheet = ExcelFillUtils.fillOneSheet(templatePath, fileDir, "Sheet1", list);
+
                 path = path + "/" + fileNameHz;
                 break;
             default:
@@ -2381,4 +2468,10 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
 
     }*/
 
+    public static void main(String[] args) {
+        Map<String, Object> imgMap = IdCardUtil.accurateBasicCj("D:\\当期财务报表_20240709162743A128.pdf");
+        System.out.println(imgMap.toString());
+    }
+
+
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserConferenceMapper.java

@@ -72,4 +72,6 @@ public interface SysUserConferenceMapper
     void updateSysUserConferenceByUserId(SysUserConference sysUserConference);
 
     void deleteSysUserConferenceByTime(@Param("reviewTime") String reviewTime, @Param("loanApplicationId")Long loanApplicationId);
+
+    SysUserConference selectSysUserConferenceNew(@Param("loanApplicationId")Long loanApplicationId);
 }

+ 6 - 1
ruoyi-system/src/main/resources/mapper/system/SysUserConferenceMapper.xml

@@ -50,7 +50,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectSysUserConferenceVo"/>
         where conference_id = #{conferenceId}
     </select>
-        
+    <select id="selectSysUserConferenceNew" parameterType="Long" resultMap="SysUserConferenceResult">
+        <include refid="selectSysUserConferenceVo"/>
+        where loan_application_id = #{loanApplicationId}
+        order by create_time desc limit 1
+    </select>
+
     <insert id="insertSysUserConference" parameterType="SysUserConference" useGeneratedKeys="true" keyProperty="conferenceId">
         insert into sys_user_conference
         <trim prefix="(" suffix=")" suffixOverrides=",">