ソースを参照

新增 归档压缩包

Administrator 1 年間 前
コミット
1131789b27

+ 1 - 1
ruoyi-admin/src/main/resources/application-prod.yml

@@ -9,7 +9,7 @@ ruoyi:
     # 实例演示开关
     demoEnabled: false
     # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
-    profile: /home/ruoyi/uploadPath
+    profile: /home/ruoyi/uploadPath/rongzidanbao
     # 获取ip地址开关
     addressEnabled: false
     # 验证码类型 math 数组计算 char 字符验证

+ 67 - 36
ruoyi-system/src/main/java/com/ruoyi/system/service/loan/impl/LoanApplicationServiceImpl.java

@@ -7,6 +7,7 @@ import com.ruoyi.common.core.domain.entity.SysRole;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.uuid.Seq;
 import com.ruoyi.system.domain.conference.SysUserConference;
 import com.ruoyi.system.domain.enterprise.SysUserEnterprise;
 import com.ruoyi.system.domain.loan.LoanApplication;
@@ -20,18 +21,15 @@ import com.ruoyi.system.service.loan.ILoanApplicationService;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-
-import java.io.File;
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.*;
 import java.util.stream.Collectors;
-
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
 import static com.ruoyi.common.constant.CommonConstants.*;
-
-import net.lingala.zip4j.ZipFile;
-import net.lingala.zip4j.exception.ZipException;
-import net.lingala.zip4j.model.ZipParameters;
-import net.lingala.zip4j.model.enums.EncryptionMethod;
-
 import javax.annotation.Resource;
 
 /**
@@ -410,7 +408,7 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
                 //给A角色发送待办提醒
                 waitRemind.setReadUserId(reviewComments.getaUserId().toString());
                 String enterpriseName = loanApplication.getEnterpriseName();
-                waitRemind.setRemindContent(enterpriseName+"有一条贷款申请需及时处理");
+                waitRemind.setRemindContent(enterpriseName + "有一条贷款申请需及时处理");
                 waitRemindMapper.insertWaitRemind(waitRemind);
             }
             //保存参会人员数据
@@ -422,11 +420,11 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
                 loanApplication.setLoanSchedule(THR);
                 loanApplication.setAuditSchedule(String.valueOf(Integer.parseInt(auditSchedule) + 1));
                 loanApplication.setAuditType(ONE);
-                if (auditSchedule.equals(TWO)){
+                if (auditSchedule.equals(TWO)) {
                     //给B角色发送待办提醒
                     waitRemind.setReadUserId(loanApplication.getbUserId().toString());
                     String enterpriseName = loanApplication.getEnterpriseName();
-                    waitRemind.setRemindContent(enterpriseName+"有一条贷款申请需及时处理");
+                    waitRemind.setRemindContent(enterpriseName + "有一条贷款申请需及时处理");
                     waitRemindMapper.insertWaitRemind(waitRemind);
                 }
                 //审核流程结束
@@ -516,7 +514,7 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
         String auditSchedule = loanApplication.getAuditSchedule();
         String loanApplicationType = loanApplication.getLoanApplicationType();
         String auditType = loanApplication.getAuditType();
-        reviewCommentsMapper.deleteReviewCommentsByLoanApplicationIdAndAuditSchedule(loanApplicationId,auditSchedule);
+        reviewCommentsMapper.deleteReviewCommentsByLoanApplicationIdAndAuditSchedule(loanApplicationId, auditSchedule);
         if (Integer.parseInt(loanSchedule) < 2 || Integer.parseInt(auditSchedule) < 1 || Integer.parseInt(loanApplicationType) != 2) {
             return AjaxResult.error("当前项目不可撤销");
         }
@@ -560,7 +558,7 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
         loanApplication.setLoanSchedule(TEN);
         loanApplication.setLoanApplicationType(FOR);
         loanApplication.setFileTime(DateUtils.getNowDate());
-        loanApplicationMapper.updateLoanApplication(loanApplication);
+
         //插入流程记录表
         LoanSchedule loanScheduleNew = new LoanSchedule();
         loanScheduleNew.setLoanApplicationId(loanApplication.getLoanApplicationId());
@@ -570,6 +568,8 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
         loanScheduleNew.setLoanApplicationNumber(loanApplication.getLoanApplicationNumber());
         loanScheduleMapper.insertLoanSchedule(loanScheduleNew);
         //todo 获取所有文件URL 进行打包zip,还有系统内的照片地址 往附件表中插入其他-归档类型的url地址
+        // 上传文件路径
+        String filePath = RuoYiConfig.getUploadPath() + "/";
         Long loanApplicationId = loanApplication.getLoanApplicationId();
         List<LoanApplicationFj> loanApplicationFjList = loanApplicationFjMapper.selectLoanApplicationFjByLoanApplicationId(loanApplicationId);
         //基础附件
@@ -579,7 +579,7 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
         List<File> fileList = new ArrayList<>();
         if (loanApplicationFjList != null && loanApplicationFjList.size() > 0) {
             for (LoanApplicationFj loanApplicationFj : loanApplicationFjList) {
-                fileList.add(new File(loanApplicationFj.getUrl()));
+                fileList.add(new File(loanApplicationFj.getUrl().replace("/profile", filePath)));
             }
         }
         String corporationFront = loanApplicationOld.getCorporationFront();
@@ -589,44 +589,47 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
         String guaranteeFront = loanApplicationOld.getGuaranteeFront();
         String guaranteeBack = loanApplicationOld.getGuaranteeBack();
         if (StringUtils.isNotEmpty(corporationFront)) {
-            fileList.add(new File(corporationFront));
+            fileList.add(new File(corporationFront.replace("/profile/upload/", filePath)));
         }
         if (StringUtils.isNotEmpty(corporationBack)) {
-            fileList.add(new File(corporationBack));
+            fileList.add(new File(corporationBack.replace("/profile/upload/", filePath)));
         }
         if (StringUtils.isNotEmpty(spouseFront)) {
-            fileList.add(new File(spouseFront));
+            fileList.add(new File(spouseFront.replace("/profile/upload/", filePath)));
         }
         if (StringUtils.isNotEmpty(spouseBack)) {
-            fileList.add(new File(spouseBack));
+            fileList.add(new File(spouseBack.replace("/profile/upload/", filePath)));
         }
         if (StringUtils.isNotEmpty(guaranteeFront)) {
-            fileList.add(new File(guaranteeFront));
+            fileList.add(new File(guaranteeFront.replace("/profile/upload/", filePath)));
         }
         if (StringUtils.isNotEmpty(guaranteeBack)) {
-            fileList.add(new File(guaranteeBack));
+            fileList.add(new File(guaranteeBack.replace("/profile/upload/", filePath)));
         }
         if (shareholderFjs != null && shareholderFjs.size() > 0) {
             for (ShareholderFj shareholderFj : shareholderFjs) {
-                fileList.add(new File(shareholderFj.getShareholderZxUrl()));
-                fileList.add(new File(shareholderFj.getShareholderFrontUrl()));
-                fileList.add(new File(shareholderFj.getShareholderBackUrl()));
+                fileList.add(new File(shareholderFj.getShareholderZxUrl().replace("/profile/upload/", filePath)));
+                fileList.add(new File(shareholderFj.getShareholderFrontUrl().replace("/profile/upload/", filePath)));
+                fileList.add(new File(shareholderFj.getShareholderBackUrl().replace("/profile/upload/", filePath)));
             }
         }
-        // 上传文件路径
-        String filePath = RuoYiConfig.getUploadPath() + "/";
-        String name = loanApplicationOld.getEnterpriseName() + loanApplicationOld.getLoanApplicationNumber() + "文档.zip";
-        zipEncryptExample(fileList, filePath + name, "123");
+
+
+        String name = StringUtils.format("{}_{}.{}",
+                loanApplicationOld.getEnterpriseName(), Seq.getId(Seq.uploadSeqType) + "文档", "zip");
+        //进行压缩
+        zipEncryptExample(fileList, filePath + loanApplicationOld.getLoanApplicationNumber(), name, "123");
         //把压缩包的url插入附件表
         LoanApplicationFj loanApplicationFj = new LoanApplicationFj();
         loanApplicationFj.setLoanApplicationId(loanApplicationId);
-        loanApplicationFj.setLoanApplicationNumber(loanApplicationOld.getEnterpriseName());
+        loanApplicationFj.setLoanApplicationNumber(loanApplicationOld.getLoanApplicationNumber());
         loanApplicationFj.setOldName(name);
         loanApplicationFj.setName(name);
-        loanApplicationFj.setUrl(filePath + name);
+        loanApplicationFj.setUrl("/profile/upload/"+name);
         loanApplicationFj.setBigType("e");
         loanApplicationFj.setCreateTime(DateUtils.getNowDate());
         loanApplicationFjMapper.insertLoanApplicationFj(loanApplicationFj);
+        loanApplicationMapper.updateLoanApplication(loanApplication);
         return AjaxResult.success();
     }
 
@@ -634,19 +637,47 @@ public class LoanApplicationServiceImpl implements ILoanApplicationService {
      * 压缩文件,返回地址
      *
      * @param fileList    源文件或目录路径
-     * @param zipFilePath ZIP文件输出路径
+     * @param zipPathDir  ZIP文件输出路径
+     * @param zipFileName ZIP文件名称
      * @param password    加密密码
      * @return
      */
-    public String zipEncryptExample(List<File> fileList, String zipFilePath, String password) {
+    public String zipEncryptExample(List<File> fileList, String zipPathDir, String zipFileName, String password) {
+        String zipFilePath = zipPathDir +"/"+ zipFileName;
         try {
-            ZipParameters zipParameters = new ZipParameters();
+
+/*            ZipParameters zipParameters = new ZipParameters();
             zipParameters.setEncryptFiles(true);
             zipParameters.setEncryptionMethod(EncryptionMethod.ZIP_STANDARD); // 标准AES加密
-            ZipFile zipFile = new ZipFile(zipFilePath, password.toCharArray());
-            zipFile.addFiles(fileList, zipParameters);
+            ZipFile zipFile = new ZipFile(zipPathDir, password.toCharArray());
+            zipFile.addFiles(fileList, zipParameters);*/
+
+            ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(new File(zipFilePath)));
+            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(zos));
+            File zipFile = new File(zipPathDir);
+            if (!zipFile.exists()) {
+                zipFile.mkdirs();
+            }
+            for (File file : fileList) {
+                if (file.exists()) {
+                    ZipEntry zipEntry = new ZipEntry(file.getName());
+                    zos.putNextEntry(zipEntry);
+                    Path path = Paths.get(file.getAbsolutePath());
+                    BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(path)));
+                    while (reader.ready()) {
+                        writer.write(reader.readLine());
+                    }
+                    writer.flush();
+                    reader.close();
+                    zos.closeEntry();
+                } else {
+                    //文件路径异常filePath:filePath
+                }
+            }
+            zos.flush();
+            writer.close();
             System.out.println("文件加密成功,保存位置:" + zipFilePath);
-        } catch (ZipException e) {
+        } catch (Exception e) {
             e.printStackTrace();
         }
         return zipFilePath;

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

@@ -39,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isRead != null  and isRead != ''"> and is_read = #{isRead}</if>
             <if test="status != null  and status != ''"> and status = #{status}</if>
         </where>
-        order by create_time
+        order by remind_time
     </select>
     
     <select id="selectWaitRemindByRemindId" parameterType="Integer" resultMap="WaitRemindResult">