소스 검색

excel模板下载,放置二维码

LIVE_YE 1 년 전
부모
커밋
3806114a6d

+ 9 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/loan/LoanApplicationFjController.java

@@ -43,6 +43,15 @@ public class LoanApplicationFjController extends BaseController {
         return getDataTable(list);
     }
 
+    /**
+     * 查询贷款申请_附件列表(二维码)
+     */
+    //@PreAuthorize("@ss.hasPermi('system:fj:list')")
+    @GetMapping("/ewmList")
+    public AjaxResult ewmList(LoanApplicationFj loanApplicationFj) {
+        return loanApplicationFjService.ewmList(loanApplicationFj);
+    }
+
     /**
      * 导出贷款申请_附件列表
      */

+ 21 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/QRCodeUtils.java

@@ -123,6 +123,27 @@ public class QRCodeUtils {
     }
 
 
+    /**
+     * 生成二维码(内嵌LOGO) 返回传入的地址
+     *
+     * @param content      内容
+     * @param imgPath      LOGO地址
+     * @param destPath     存放目录
+     * @param needCompress 是否压缩LOGO
+     * @throws Exception
+     */
+    public static String encodeNodate(String content, String imgPath, String destPath,
+                                boolean needCompress) throws Exception {
+        BufferedImage image = QRCodeUtils.createImage(content, imgPath,
+                needCompress);
+        mkdirs(destPath);
+        String file = UUID.randomUUID() + ".jpg";
+        File fileQR = new File(destPath + "/" + file);
+        ImageIO.write(image, FORMAT_NAME, fileQR);
+        return destPath+"/"+file;
+    }
+
+
     /**
      * 当文件夹不存在时,mkdirs会自动创建多层目录,区别于mkdir.(mkdir如果父目录不存在则会抛出异常)
      *

+ 1 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelFillUtils.java

@@ -139,6 +139,7 @@ public class ExcelFillUtils {
             Row row = sheet.getRow(i);
             for( int j = 0 ;j< row.getPhysicalNumberOfCells() ;j++){
                 Cell cell = row.getCell(j);
+                cell.setCellType(CellType.STRING);
                 if( !Objects.isNull(cell) && isFillExpression(cell.getStringCellValue()) ){//判断该单元格是否是填充公式
                     expressionCellMap.put(getColNameFromEx(cell.getStringCellValue()),cell);
                 }

+ 7 - 7
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/FileUtils.java

@@ -24,7 +24,7 @@ public class FileUtils {
 
 
     /**
-     * 给定一个目录和文件,若该目录存在名称相同的文件,则返回一个可用的副本文件名,否则直接返回输入的文件名
+     * 给定一个目录和文件,若该目录存在名称相同的文件,则覆盖原先的文件
      * @param path 文件的目录
      * @param fileName 文件名
      * @return 可用的文件名
@@ -42,11 +42,11 @@ public class FileUtils {
             fileNameSet.add(file.getName().substring(0 , file.getName().lastIndexOf(".")));
         }
 
-        boolean isExist = true;
-        int count = 1;
+        //boolean isExist = true;
+        //int count = 1;
         String tempFileName = fileName.substring(0,fileName.lastIndexOf("."));
         String tempFileName1 = tempFileName;
-        while(isExist){
+       /* while(isExist){
 
             if (fileNameSet.contains(tempFileName)){
                 tempFileName = tempFileName1 + COPY_FILE_SUFFIX + count++;
@@ -54,14 +54,14 @@ public class FileUtils {
                 isExist = false;
             }
 
-        }
+        }*/
 
         return tempFileName + suffix;
     }
 
 
     /**
-     * 给定一个文件的完整路径,若该文件已经存在,则返回一个可用的副本文件名,否则直接返回输入的文件名
+     * 给定一个文件的完整路径,若该文件已经存在,则覆盖原先的文件
      * @param fullPath 文件的完整路径
      * @return 可用的文件名
      * */
@@ -73,7 +73,7 @@ public class FileUtils {
     }
 
     /**
-     * 给定一个文件的完整路径,若该文件已经存在,则返回一个完整可用的副本文件名,否则直接返回输入的文件名
+     * 给定一个文件的完整路径,若该文件已经存在,则覆盖原先的文件
      * @param fullPath 文件的完整路径
      * @return 完整可用的文件名
      * */

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/LoanApplicationFjMapper.java

@@ -87,4 +87,7 @@ public interface LoanApplicationFjMapper
 
     public int deleteLoanApplicationFjByLoanApplicationIdAndType(@Param("loanApplicationId") Long loanApplicationId,@Param("type") String[] type);
     public List<LoanApplicationFj> selectLoanApplicationFjByLoanApplicationIdAndType(@Param("loanApplicationId") Long loanApplicationId,@Param("type") String[] type);
+
+
+    LoanApplicationFj ewmList(LoanApplicationFj loanApplicationFj);
 }

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/loan/ILoanApplicationFjService.java

@@ -1,5 +1,6 @@
 package com.ruoyi.system.service.loan;
 
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.system.domain.loan.LoanApplicationFj;
 
 import java.util.List;
@@ -60,4 +61,6 @@ public interface ILoanApplicationFjService
      * @return 结果
      */
     public int deleteLoanApplicationFjByFjId(Long fjId);
+
+    AjaxResult ewmList(LoanApplicationFj loanApplicationFj);
 }

+ 11 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/loan/impl/LoanApplicationFjServiceImpl.java

@@ -1,6 +1,8 @@
 package com.ruoyi.system.service.loan.impl;
 
 import java.util.List;
+
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.system.domain.loan.LoanApplicationFj;
 import com.ruoyi.system.service.loan.ILoanApplicationFjService;
@@ -97,4 +99,13 @@ public class LoanApplicationFjServiceImpl implements ILoanApplicationFjService
     {
         return loanApplicationFjMapper.deleteLoanApplicationFjByFjId(fjId);
     }
+
+    @Override
+    public AjaxResult ewmList(LoanApplicationFj loanApplicationFj) {
+        LoanApplicationFj applicationFj = loanApplicationFjMapper.ewmList(loanApplicationFj);
+        if(applicationFj==null){
+            return AjaxResult.error("请上传文件或保存后扫码查看");
+        }
+        return AjaxResult.success(applicationFj);
+    }
 }

+ 37 - 22
ruoyi-system/src/main/java/com/ruoyi/system/service/loan/impl/LoanApplicationServiceImpl.java

@@ -2,17 +2,18 @@ package com.ruoyi.system.service.loan.impl;
 
 
 import cn.hutool.extra.qrcode.QrCodeUtil;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.deepoove.poi.data.PictureRenderData;
+import com.deepoove.poi.data.Pictures;
 import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysRole;
 import com.ruoyi.common.core.redis.RedisCache;
-import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.common.utils.SendSmsUtils;
+import com.ruoyi.common.utils.*;
 import com.ruoyi.common.utils.file.FileUploadUtils;
 import com.ruoyi.common.utils.poi.ExcelFillUtils;
 import com.ruoyi.common.utils.poi.WordUtil;
-import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.uuid.Seq;
 import com.ruoyi.common.utils.uuid.IdUtils;
 import com.ruoyi.common.utils.uuid.UUID;
@@ -26,6 +27,7 @@ import com.ruoyi.system.domain.remind.WaitRemind;
 import com.ruoyi.system.domain.review.ReviewComments;
 import com.ruoyi.system.mapper.*;
 import com.ruoyi.system.service.loan.ILoanApplicationService;
+import lombok.SneakyThrows;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -756,6 +758,7 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
     /**
      * 导出模板附件
      */
+    @SneakyThrows
     @Override
     public AjaxResult exportMb(LoanApplication loanApplication) {
         Map<String, Object> map = new HashMap<>();
@@ -792,6 +795,21 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
         String fileName = "";
         String fileNameHz = "";
         String wordPath = "";
+        String sheet ="";
+        //生成二维码
+        String ewmPath = RuoYiConfig.getProfile()+"/mb/ewm";
+        JSONObject json = new JSONObject();
+        json.put("type","2");
+        json.put("loanApplicationNumber",loanApplication.getLoanApplicationNumber());
+        json.put("bigType",bigType);
+        json.put("fileType",fileType);
+        String imagePath = QRCodeUtils.encodeNodate(json.toString(), null, ewmPath, true);
+        if (StringUtils.isNotEmpty(imagePath)) {
+            PictureRenderData picture = Pictures.ofLocal(imagePath).size(70, 70).create();//本地图片地址
+            params.put("signPicture", picture);
+        }
+        // 创建一个列表,用来存储要填充到Excel中的数据
+        List<Map<String, Object>> list = new ArrayList<>();
         switch (type) {
             case "1":
                 //params.put("enterpriseName", loanApplication.getEnterpriseName());
@@ -917,8 +935,6 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
                 break;
             case "12":
 
-                // 创建一个列表,用来存储要填充到Excel中的数据
-                List<Map<String, Object>> list = new ArrayList<>();
                 // 向列表中添加数据
 /*                list.add( Map.of("name","zou" ,"age" ,18) );
                 list.add( Map.of("name","li" ,"age" ,28) );
@@ -930,50 +946,49 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
                 fileName = loanApplication.getEnterpriseName() + "-项目评审意见签批表";
                 fileNameHz = fileName + ".xlsx";
                 templatePath = RuoYiConfig.getProfile() + "/mb/项目评审意见签批表.xlsx";
-                ExcelFillUtils.fillOneSheet(templatePath, fileName, list);
+                fileDir = RuoYiConfig.getProfile() + "/mb/temporarily/" + loanApplicationNumber + "/"+fileNameHz;
+                sheet = ExcelFillUtils.fillOneSheet(templatePath, fileDir, "Sheet1", list);
 
-                //templatePath = RuoYiConfig.getProfile() + "/mb/项目评审意见签批表.docx";
-                //fileDir = RuoYiConfig.getProfile() + "/mb/temporarily";
-                //fileName = loanApplication.getEnterpriseName() + "-项目评审意见签批表";
-                //wordPath = WordUtil.createWord(templatePath, fileDir, fileName, params);
-                path = path + "/" + fileName + ".xlsx";
+                path = sheet;
                 break;
             case "13":
                 //params.put("enterpriseName", loanApplication.getEnterpriseName());
                 //path = path + "/委托担保申请书.doc";
-                templatePath = RuoYiConfig.getProfile() + "/mb/担保项目合法合规表企业.docx";
-                fileDir = RuoYiConfig.getProfile() + "/mb/temporarily";
+                templatePath = RuoYiConfig.getProfile() + "/mb/担保项目合法合规表企业.xlsx";
                 //fileName = FileUploadUtils.extractFilenameLoanApplicationNumberNoHzm("担保项目合法合规表企业");
                 fileName = loanApplication.getEnterpriseName() + "-担保项目合法合规表企业";
                 if ("2".equals(loanApplication.getApplicationType())) {
-                    templatePath = RuoYiConfig.getProfile() + "/mb/担保项目合法合规表个人个体户.docx";
-                    fileDir = RuoYiConfig.getProfile() + "/mb/temporarily";
+                    templatePath = RuoYiConfig.getProfile() + "/mb/担保项目合法合规表个人个体户.xlsx";
                     //fileName = FileUploadUtils.extractFilenameLoanApplicationNumberNoHzm("担保项目合法合规表个人个体户");
                     fileName = loanApplication.getEnterpriseName() + "-担保项目合法合规表个人个体户";
                 }
                 fileNameHz = fileName + ".xlsx";
-                path = path + "/" + fileName + ".docx";
+                fileDir = RuoYiConfig.getProfile() + "/mb/temporarily/" + loanApplicationNumber + "/"+fileNameHz;
+                sheet = ExcelFillUtils.fillOneSheet(templatePath, fileDir, "Sheet1", list);
+                path = sheet;
                 break;
             case "14":
                 //params.put("enterpriseName", loanApplication.getEnterpriseName());
                 //path = path + "/委托担保申请书.doc";
                 templatePath = RuoYiConfig.getProfile() + "/mb/放款审批合规表企业.xlsx";
-                fileDir = RuoYiConfig.getProfile() + "/mb/temporarily";
                 //fileName = FileUploadUtils.extractFilenameLoanApplicationNumberNoHzm("放款审批合规表企业");
                 fileName = loanApplication.getEnterpriseName() + "-放款审批合规表企业";
                 if ("2".equals(loanApplication.getApplicationType())) {
-                    templatePath = RuoYiConfig.getProfile() + "/mb/放款审批合规表个人个体户.docx";
-                    fileDir = RuoYiConfig.getProfile() + "/mb/temporarily";
+                    templatePath = RuoYiConfig.getProfile() + "/mb/放款审批合规表个人个体户.xlsx";
                     //fileName = FileUploadUtils.extractFilenameLoanApplicationNumberNoHzm("放款审批合规表个人个体户");
                     fileName = loanApplication.getEnterpriseName() + "-放款审批合规表个人个体户";
                 }
                 fileNameHz = fileName + ".xlsx";
-                wordPath = WordUtil.createWord(templatePath, fileDir, fileName, params);
-                path = path + "/" + fileName + ".docx";
+                fileDir = RuoYiConfig.getProfile() + "/mb/temporarily/" + loanApplicationNumber + "/"+fileNameHz;
+                sheet = ExcelFillUtils.fillOneSheet(templatePath, fileDir, "Sheet1", list);
+                path = sheet;
                 break;
             default:
                 break;
         }
+        //删除二维码
+        File file = new File(imagePath);
+        file.delete();
 
         LoanApplicationFj applicationFj = new LoanApplicationFj();
         applicationFj.setLoanApplicationId(loanApplication.getLoanApplicationId());

+ 15 - 0
ruoyi-system/src/main/resources/mapper/system/LoanApplicationFjMapper.xml

@@ -73,6 +73,21 @@
             #{type}
         </foreach>
     </select>
+    <select id="ewmList" resultMap="LoanApplicationFjResult" parameterType="LoanApplicationFj">
+        <include refid="selectLoanApplicationFjVo"/>
+        <where>
+            <if test="loanApplicationId != null ">and loan_application_id = #{loanApplicationId}</if>
+            <if test="loanApplicationNumber != null  and loanApplicationNumber != ''">and loan_application_number =
+                #{loanApplicationNumber}
+            </if>
+            <if test="oldName != null  and oldName != ''">and old_name like concat('%', #{oldName}, '%')</if>
+            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
+            <if test="url != null  and url != ''">and url = #{url}</if>
+            <if test="type != null  and type != ''">and type = #{type}</if>
+            <if test="bigType != null  and bigType != ''">and big_type = #{bigType}</if>
+        </where>
+        order by create_time desc limit 1
+    </select>
 
     <insert id="insertLoanApplicationFj" parameterType="LoanApplicationFj" useGeneratedKeys="true" keyProperty="fjId">
         insert into loan_application_fj