Kaynağa Gözat

Merge remote-tracking branch 'origin/dev1.0' into dev1.0

liutao 5 ay önce
ebeveyn
işleme
791f1ccd95

+ 28 - 0
src/main/java/com/sunxung/factoring/entity/financing/sop/QuotaDisburseReport.java

@@ -1,6 +1,7 @@
 package com.sunxung.factoring.entity.financing.sop;
 
 import com.sunxung.factoring.entity.financing.review.ReviewBasicContract;
+import com.sunxung.factoring.entity.financing.review.ReviewMortgageBasicInfo;
 
 import java.util.List;
 
@@ -45,6 +46,12 @@ public class QuotaDisburseReport extends BaseEcommerceApiSearch {
      */
     private Integer respRepay;
 
+    /**
+     * 有无抵质押
+     * 0:无,1:有
+     */
+    private Integer mortgageInfo;
+
     /**
      * 账户上报方式 1:A类,0:B类
      */
@@ -96,6 +103,11 @@ public class QuotaDisburseReport extends BaseEcommerceApiSearch {
      */
     private List<ReviewBasicContract> reviewBasicContractList;
 
+    /**
+     * 抵质押信息
+     */
+    private List<ReviewMortgageBasicInfo> mortgageBasicInfoList;
+
     public String getBusinessNo() {
         return businessNo;
     }
@@ -223,4 +235,20 @@ public class QuotaDisburseReport extends BaseEcommerceApiSearch {
     public void setReviewBasicContractList(List<ReviewBasicContract> reviewBasicContractList) {
         this.reviewBasicContractList = reviewBasicContractList;
     }
+
+    public Integer getMortgageInfo() {
+        return mortgageInfo;
+    }
+
+    public void setMortgageInfo(Integer mortgageInfo) {
+        this.mortgageInfo = mortgageInfo;
+    }
+
+    public List<ReviewMortgageBasicInfo> getMortgageBasicInfoList() {
+        return mortgageBasicInfoList;
+    }
+
+    public void setMortgageBasicInfoList(List<ReviewMortgageBasicInfo> mortgageBasicInfoList) {
+        this.mortgageBasicInfoList = mortgageBasicInfoList;
+    }
 }

+ 1 - 0
src/main/java/com/sunxung/factoring/entity/financing/sop/RltRepay.java

@@ -190,6 +190,7 @@ public class RltRepay {
         this.propertyList = reviewRltRepay.getPropertyList();
         this.guaranteeClassify = reviewRltRepay.getGuaranteeClassify();
         this.legalRepresentative = reviewRltRepay.getLegalRepresentative();
+        this.arlpAmt = reviewRltRepay.getArlpAmt();
     }
 
     public String getGuaranteeType() {

+ 9 - 0
src/main/java/com/sunxung/factoring/service/financing/contract/ContractMakingService.java

@@ -4,6 +4,7 @@ import com.sunxung.factoring.entity.financing.contract.ContractInfo;
 import com.sunxung.factoring.entity.financing.contract.UploadContractSignatory;
 import com.sunxung.factoring.entity.sys.Dictionary;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 import java.util.Set;
 
@@ -52,4 +53,12 @@ public interface ContractMakingService {
      * @return
      */
     ContractInfo getView(Long id);
+
+    /**
+     * 合同制作页面下载合同模板
+     *
+     * @param contractInfo
+     * @param response
+     */
+    void downloadContractTemplate(ContractInfo contractInfo, HttpServletResponse response);
 }

+ 1 - 2
src/main/java/com/sunxung/factoring/service/financing/contract/INewContractMakingService.java

@@ -18,7 +18,6 @@ public interface INewContractMakingService {
      * @param type         合同类型
      * @param id           主表id
      * @param contractInfo 合同制作信息
-     * @param list         文件集合
      */
-    void createContractDocument(String type, Long id, ContractInfo contractInfo, List<File> list);
+    File createContractDocument(String type, Long id, ContractInfo contractInfo);
 }

+ 118 - 23
src/main/java/com/sunxung/factoring/service/financing/contract/impl/ContractMakingServiceImpl.java

@@ -6,7 +6,6 @@ import com.sunxung.factoring.component.enums.FinancingCurrentStageEnum;
 import com.sunxung.factoring.component.exception.BusinessException;
 import com.sunxung.factoring.component.exception.ValidatorException;
 import com.sunxung.factoring.component.util.*;
-import com.sunxung.factoring.component.util.onlineConverter.OfficeConverterUtil;
 import com.sunxung.factoring.dict.impl.FileModuleDict;
 import com.sunxung.factoring.entity.customerinformation.ElectronicSignaturePersonal;
 import com.sunxung.factoring.entity.entprise.Enterprise;
@@ -35,10 +34,12 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.io.File;
-import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
 
 /**
  * @Description : 合同制作业务层实现类
@@ -635,12 +636,11 @@ public class ContractMakingServiceImpl implements ContractMakingService {
         List<ContractBasicContract> oldBasicContractList = contractBasicContractService.list(new QueryWrapper<ContractBasicContract>()
                 .eq("contract_info_id", contractInfo.getId()));
         if (CollectionUtil.isNotEmpty(oldBasicContractList)) {
-            oldBasicContractList.stream().forEach(contractBasicContract -> {
-
-                contractBasicContractChangeContentService.remove(new QueryWrapper<ContractBasicContractChangeContent>()
-                        .eq("contract_info_id", contractInfo.getId())
-                        .eq("contract_basic_contract_id", contractBasicContract.getId()));
-            });
+            oldBasicContractList.stream().forEach(contractBasicContract ->
+                    contractBasicContractChangeContentService.remove(new QueryWrapper<ContractBasicContractChangeContent>()
+                            .eq("contract_info_id", contractInfo.getId())
+                            .eq("contract_basic_contract_id", contractBasicContract.getId()))
+            );
         }
         //生成新的三方协议变更内容
         List<ContractBasicContract> basicContractList = contractInfo.getContractBasicContractList();
@@ -671,12 +671,12 @@ public class ContractMakingServiceImpl implements ContractMakingService {
         contractLoanConditionSettingService.remove(new QueryWrapper<ContractLoanConditionSetting>().eq("contract_info_id", contractInfo.getId()));
         List<ContractLoanConditionSetting> conditionSettingList = contractInfo.getConditionSettingList();
         if (CollectionUtil.isNotEmpty(conditionSettingList)) {
-            conditionSettingList.stream().forEach(conditionSetting -> {
-                if (conditionSetting.getFixedCondition() != null && conditionSetting.getFixedCondition()) {
-                    conditionSetting.setContractInfoId(contractInfo.getId());
-                    conditionSetting.setConditionType(ConstantConversionUtil.CONTRACT_LOAN_CONDITION_SETTING_CONDITION);
-                }
-            });
+            int i = 0;
+            for (ContractLoanConditionSetting conditionSetting : conditionSettingList) {
+                conditionSetting.setOrderNumber(i++);
+                conditionSetting.setContractInfoId(contractInfo.getId());
+                conditionSetting.setConditionType(ConstantConversionUtil.CONTRACT_LOAN_CONDITION_SETTING_CONDITION);
+            }
             contractLoanConditionSettingService.saveBatch(conditionSettingList);
 
             List<ContractLoanConditionSetting> checkedList = conditionSettingList.stream().filter(conditionSetting -> conditionSetting.getChecked() != null && conditionSetting.getChecked())
@@ -808,6 +808,103 @@ public class ContractMakingServiceImpl implements ContractMakingService {
         return contractInfo;
     }
 
+    @Override
+    public void downloadContractTemplate(ContractInfo contractInfo, HttpServletResponse response) {
+        List<String> electronicSigns = contractInfo.getElectronicSign();
+
+        if (CollectionUtil.isEmpty(electronicSigns)) {
+            throw new BusinessException(CodeUtil.FAIL, "未选择任何合同模板!");
+        }
+        List<File> fileList = new ArrayList<>();
+        for (String electronicSign : electronicSigns) {
+            String[] split = electronicSign.split("_");
+            String type = split[0];
+            Long id = null;
+            if (split.length == 2) {
+                id = Long.parseLong(split[1]);
+            }
+            File newFile = newContractMakingService.createContractDocument(type, id, contractInfo);
+            fileList.add(newFile);
+//            File renameFile = null;
+//            for (File file : fileList) {
+//                if (file.getName().equals(newFile.getName())) {
+//                    String fileName = newFile.getName().substring(0, newFile.getName().lastIndexOf("."));
+//                    String extension = newFile.getName().substring(newFile.getName().lastIndexOf("."));
+//                    renameFile = new File(newFile.getParentFile(), fileName + UUID.randomUUID() + extension);
+//                    newFile.renameTo(renameFile);
+//                }
+//            }
+//            if (renameFile != null && renameFile.exists()) {
+//                fileList.add(renameFile);
+//            } else {
+//
+//            }
+        }
+        if (CollectionUtil.isNotEmpty(fileList)) {
+            // 打包成zip文件
+            File file = downloadZip(fileList, "线上签署合同模板", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
+
+            fileStorageService.downloadFile(response, file);
+        }
+    }
+
+    /**
+     * 打包ZIP文件
+     */
+    public File downloadZip(List<File> fileList, String contractName, FileModuleDict.ChildEnum moduleType) {
+        try {
+            contractName = new String(contractName.getBytes("UTF-8"));
+        } catch (UnsupportedEncodingException e1) {
+            throw new BusinessException(CodeUtil.FAIL, "下载合同附件转码失败:" + e1.getMessage());
+        }
+        String desPath = FileUtil.getAbsolutePath(contractName, ".zip", moduleType);
+        File zipFile = new File(desPath);
+        if (!zipFile.getParentFile().exists()) {
+            zipFile.getParentFile().mkdirs();
+        }
+        ZipOutputStream zipStream = null;
+        FileInputStream zipSource = null;
+        BufferedInputStream bufferStream = null;
+        try {
+            // 构造最终压缩包的输出流
+            zipStream = new ZipOutputStream(new FileOutputStream(zipFile));
+            for (File file : fileList) {
+                // 将需要压缩的文件格式化为输入流
+                zipSource = new FileInputStream(file);
+                // 压缩条目不是具体独立的文件,而是压缩包文件列表中的列表项,称为条目,就像索引一样
+                ZipEntry zipEntry = new ZipEntry(file.getName());
+                // 定位该压缩条目位置,开始写入文件到压缩包中
+                zipStream.putNextEntry(zipEntry);
+                // 输入缓冲流
+                bufferStream = new BufferedInputStream(zipSource, 1024 * 10);
+                int read = 0;
+                // 创建读写缓冲区
+                byte[] buf = new byte[1024 * 10];
+                while ((read = bufferStream.read(buf, 0, 1024 * 10)) != -1) {
+                    zipStream.write(buf, 0, read);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            // 关闭流
+            try {
+                if (null != bufferStream) {
+                    bufferStream.close();
+                }
+                if (null != zipStream) {
+                    zipStream.close();
+                }
+                if (null != zipSource) {
+                    zipSource.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return zipFile;
+    }
+
     /**
      * 制作电子签文件
      *
@@ -825,9 +922,7 @@ public class ContractMakingServiceImpl implements ContractMakingService {
             }
             ContractTemplate contractTemplate = contractTemplateService.lambdaQuery().eq(ContractTemplate::getTemplateCode, type).eq(ContractTemplate::getVisible, 1).one();
             String templateName = contractTemplate.getName();
-
-            List<File> list = new ArrayList<>();
-            newContractMakingService.createContractDocument(type, id, contractInfo, list);
+            File file = newContractMakingService.createContractDocument(type, id, contractInfo);
             List<ContractElectronicCustomerInfo> contractElectronicCustomerInfos = new ArrayList<>();
             //国际的不需要电子签  国内的才电子签
             TAXSignCustomer(electronicSign, contractElectronicCustomerInfos, contractInfo);
@@ -837,9 +932,9 @@ public class ContractMakingServiceImpl implements ContractMakingService {
                     || type.equals(ConstantConversionUtil.FACTORING_CONTRACT_NUMBER_GUARANTEE_COMPANY) ||
                     type.equals(ConstantConversionUtil.FACTORING_CONTRACT_NUMBER_GUARANTEE_PERSON) ||
                     type.equals(ConstantConversionUtil.GENERAL_GUARANTEE_COMPANY_M2) || type.equals(ConstantConversionUtil.GENERAL_GUARANTEE_PERSONAL_M2)) {
-                doNotAutoSign(contractInfo, templateName, contractElectronicCustomerInfos, list.get(0));
+                doNotAutoSign(contractInfo, templateName, contractElectronicCustomerInfos, file);
             } else {
-                doAutoSign(contractInfo, autoSignKeyword, templateName, contractElectronicCustomerInfos, list.get(0));
+                doAutoSign(contractInfo, autoSignKeyword, templateName, contractElectronicCustomerInfos, file);
             }
         }
     }
@@ -849,7 +944,7 @@ public class ContractMakingServiceImpl implements ContractMakingService {
         String suffix = FileUtil.getSuffix(file.getName());
         String newPath = file.getAbsolutePath().replace(suffix, ".pdf");
         //新方式将合同转为pdf
-        File pdfFile = ASopUtil.doc2pdf(file.getAbsolutePath(),newPath);
+        File pdfFile = ASopUtil.doc2pdf(file.getAbsolutePath(), newPath);
         String originalName = pdfFile.getName();
         FileStorage fileStorage = new FileStorage(originalName, pdfFile.getAbsolutePath(),
                 FileModuleDict.ChildEnum.ELECTRONIC_FILE);
@@ -1444,7 +1539,7 @@ public class ContractMakingServiceImpl implements ContractMakingService {
             }
             if (basic.getDebtorSocialCreditCode() != null && !basic.getDebtorSocialCreditCode().equals("")) {
                 Platform platform = platformService.lambdaQuery().eq(Platform::getSocialCreditCode, basic.getDebtorSocialCreditCode()).one();
-                SysCustomer debtorSysCustomer = sysCustomerService.lambdaQuery().eq(SysCustomer::getPlatformId,platform.getId()).one();
+                SysCustomer debtorSysCustomer = sysCustomerService.lambdaQuery().eq(SysCustomer::getPlatformId, platform.getId()).one();
                 if (debtorSysCustomer != null && debtorSysCustomer.getFddCustomerId() != null) {
                     ContractElectronicCustomerInfo contractElectronicCustomerInfo = new ContractElectronicCustomerInfo("dbqz", debtorSysCustomer.getFddCustomerId());
                     contractElectronicCustomerInfo.setSysCustomerId(debtorSysCustomer.getId());
@@ -1560,7 +1655,7 @@ public class ContractMakingServiceImpl implements ContractMakingService {
         String suffix = FileUtil.getSuffix(file.getName());
         String newPath = file.getAbsolutePath().replace(suffix, ".pdf");
         //新方式将合同转为pdf
-        File pdfFile = ASopUtil.doc2pdf(file.getAbsolutePath(),newPath);
+        File pdfFile = ASopUtil.doc2pdf(file.getAbsolutePath(), newPath);
         String originalName = pdfFile.getName();
         FileStorage fileStorage = new FileStorage(originalName, pdfFile.getAbsolutePath(),
                 FileModuleDict.ChildEnum.ELECTRONIC_FILE);

+ 124 - 81
src/main/java/com/sunxung/factoring/service/financing/contract/impl/NewContractMakingServiceImpl.java

@@ -129,7 +129,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
     private IDepartmentService departmentService;
 
     @Override
-    public void createContractDocument(String type, Long id, ContractInfo contractInfo, List<File> list) {
+    public File createContractDocument(String type, Long id, ContractInfo contractInfo) {
         ContractTemplate contractTemplate = contractTemplateService.lambdaQuery().eq(ContractTemplate::getTemplateCode, type).eq(ContractTemplate::getVisible, 1).one();
         AttachmentDto attachmentDto = AttachmentDto.builder()
                 .setEntityId(contractTemplate.getId())
@@ -139,62 +139,65 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
         FileStorage fileStorage = files.get(0);
         String absolutePath = fileStorage.getAbsolutePath();
         String name = contractTemplate.getName();
+
+        File file = null;
         if (type.equals(ConstantConversionUtil.TRIPARTITE_AGREEMENT_FACTORING)) {
             // 下载(贸理通)三方协议
-            dealNewtTripartiteAgreementFactoringDownload(contractInfo, list, id, absolutePath);
+            file = dealNewtTripartiteAgreementFactoringDownload(contractInfo, id, absolutePath);
         } else if (type.equals(ConstantConversionUtil.TRIPARTITE_AGREEMENT)) {
             //下载三方协议
-            dealNewtTripartiteAgreementDownload(contractInfo, list, id, absolutePath);
+            file = dealNewtTripartiteAgreementDownload(contractInfo, id, absolutePath);
         } else if (type.equals(ConstantConversionUtil.POOL_FACTORING_BUSINESS_CONTRACT) ||
                 type.equals(ConstantConversionUtil.FACTORING_BUSINESS_CONTRACT)) {
             //下载池保理业务合同
-            dealNewPoolFactoringBusinessContract(contractInfo, list, absolutePath, type);
+            file = dealNewPoolFactoringBusinessContract(contractInfo, absolutePath, type);
         } else if (type.equals(ConstantConversionUtil.POOL_FACTORING_FINANCING_CONFIRM) ||
                 type.equals(ConstantConversionUtil.POOL_FACTORING_INFORMATION_DOMESTIC) ||
                 type.equals(ConstantConversionUtil.FACTORING_SERVICE_CONFIRMATION)) {
             // 注意事项:设置excel表格的时,一定要设置ss:ExpandedRowCount行数,建议其值设置较大,如500,防止创建excel行数不够导致失败
             // 下载保理信息表或保理融资确认书
-            dealNewFactoringInfo(contractInfo, list, absolutePath, type);
+            file = dealNewFactoringInfo(contractInfo, absolutePath, type);
         } else if (type.equals(ConstantConversionUtil.ACCOUNT_RECEIVABLE_TRANSFER_NOTICE) ||
                 type.equals(ConstantConversionUtil.DOMESTIC_ACCOUNT_RECEIVABLE_TRANSFER_NOTICE_BRIGHT)) {
             // 应收账款转让通知书
-            dealNewNoticeDownloadAll(contractInfo, list, absolutePath, type);
+            file = dealNewNoticeDownloadAll(contractInfo, absolutePath, type);
         } else if (type.equals(ConstantConversionUtil.POOL_FACTORING_ACCOUNT_RECEIVABLE) ||
                 type.equals(ConstantConversionUtil.DOMESTIC_ACCOUNT_RECEIVABLE_TRANSFER_CONFIRM) ||
                 type.equals(ConstantConversionUtil.ACCOUNTS_RECEIVABLE_ASSIGNMENT_AGREEMENT)) {
             // 应收账款入池确认书 应收账款转让协议
-            dealNewConfirmDownload(contractInfo, list, absolutePath, type);
+            file = dealNewConfirmDownload(contractInfo, absolutePath, type);
         } else if (type.equals(ConstantConversionUtil.SPOUSE_STATEMENT_GUARANTEE_SPOUSE)) {
             // 配偶声明
-            dealNewSpouseStatement(id, contractInfo, list, absolutePath, name);
+            file = dealNewSpouseStatement(id, contractInfo, absolutePath, name);
         } else if (type.equals(ConstantConversionUtil.FACTORING_CONTRACT_NUMBER_GUARANTEE_COMPANY) ||
                 type.equals(ConstantConversionUtil.FACTORING_CONTRACT_NUMBER_GUARANTEE_PERSON)) {
             // 财产清单
-            dealNewDssetsDetail(id, contractInfo, list, absolutePath);
+            file = dealNewDssetsDetail(id, absolutePath);
         } else if (type.equals(ConstantConversionUtil.MOVABLE_MORTGAGE_CONTRACT_NUMBER_GUARANTEE_COMPANY) ||
                 type.equals(ConstantConversionUtil.MOVABLE_MORTGAGE_CONTRACT_NUMBER_GUARANTEE_PERSONAL)) {
             // 动产抵押合同
-            dealNewChattelMortgageContract(id, contractInfo, list, absolutePath);
+            file = dealNewChattelMortgageContract(id, contractInfo, absolutePath);
         } else if (type.equals(ConstantConversionUtil.STOCK_RIGHT_CONTRACT_NUMBER_PLEDGOR_COMPANY) ||
                 type.equals(ConstantConversionUtil.STOCK_RIGHT_CONTRACT_NUMBER_PLEDGOR_PERSONAL)) {
             // 股权质押合同
-            dealNewEquityPledgeContract(id, contractInfo, list, absolutePath);
+            file = dealNewEquityPledgeContract(id, contractInfo, absolutePath);
         } else if (type.equals(ConstantConversionUtil.MAXIMUM_GUARANTEE_CULVER_COMPANY) ||
                 type.equals(ConstantConversionUtil.MAXIMUM_GUARANTEE_CULVER_PERSONAL) ||
                 type.equals(ConstantConversionUtil.MAXIMUM_GUARANTEE_CULVER_COMPANY_M2) ||
                 type.equals(ConstantConversionUtil.MAXIMUM_GUARANTEE_CULVER_PERSONAL_M2)) {
             // 担保涵 最高额保证 2023.3.20 新增m2的最高额保障合同
-            dealMaximumGuaranteeCulevert(id, contractInfo, list, absolutePath);
+            file = dealMaximumGuaranteeCulevert(id, contractInfo, absolutePath);
         } else if (type.equals(ConstantConversionUtil.GENERAL_GUARANTEE_COMPANY) ||
                 type.equals(ConstantConversionUtil.GENERAL_GUARANTEE_PERSONAL) ||
                 type.equals(ConstantConversionUtil.GENERAL_GUARANTEE_COMPANY_M2) ||
                 type.equals(ConstantConversionUtil.GENERAL_GUARANTEE_PERSONAL_M2)) {
             // 担保涵 常规担保函 2023.3.20 新增m2的常规担保函
-            dealNewGuaranteeCulevert(id, contractInfo, list, absolutePath, name);
+            file = dealNewGuaranteeCulevert(id, contractInfo, absolutePath, name);
         } else if (type.equals(ConstantConversionUtil.TRADING_INFO)) {
             // 下载交易信息表
-            dealNewTradingInfoDownload(contractInfo, list, id, absolutePath);
+            file = dealNewTradingInfoDownload(contractInfo, id, absolutePath);
         }
+        return file;
     }
 
     /**
@@ -202,11 +205,10 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
      *
      * @param reviewRltRepayId
      * @param contractInfo
-     * @param list
      * @param absolutePath
      * @param contractName
      */
-    private void dealNewSpouseStatement(Long reviewRltRepayId, ContractInfo contractInfo, List<File> list, String absolutePath, String contractName) {
+    private File dealNewSpouseStatement(Long reviewRltRepayId, ContractInfo contractInfo, String absolutePath, String contractName) {
         try {
             // 主合同信息
             ReviewMasterContract masterContract = reviewMasterContractService.lambdaQuery().eq(ReviewMasterContract::getReviewQuotaDisburseId, contractInfo.getReviewQuotaDisburseId()).one();
@@ -306,7 +308,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                             FileUtils.createParentDirectories(file);
                         }
                         template.writeToFile(path);
-                        list.add(file);
+                        return file;
                     }
                 }
             }
@@ -314,17 +316,16 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
             e.printStackTrace();
             throw new BusinessException(CodeUtil.FAIL, "下载配偶声明出错" + e.getMessage());
         }
+        return null;
     }
 
     /**
      * 财产清单
      *
      * @param reviewRltRepayId
-     * @param contractInfo
-     * @param list
      * @param absolutePath
      */
-    private void dealNewDssetsDetail(Long reviewRltRepayId, ContractInfo contractInfo, List<File> list, String absolutePath) {
+    private File dealNewDssetsDetail(Long reviewRltRepayId, String absolutePath) {
         try {
             ReviewRltRepay rltRepay = reviewRltRepayService.getById(reviewRltRepayId);
             if (null != rltRepay && rltRepay.getArlpIdType() != null) {
@@ -515,7 +516,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                             FileUtils.createParentDirectories(estateFile);
                         }
                         template.writeToFile(path);
-                        list.add(estateFile);
+                        return estateFile;
                     }
                 } else if (type.equals(ConstantConversionUtil.IDENTITY_TYPE2)) {
                     // 公司
@@ -700,13 +701,13 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 .bind("vehicleList", policy).bind("equityList", policy)
                                 .bind("otherList", policy).build();
                         XWPFTemplate template = XWPFTemplate.compile(absolutePath, config).render(propertyMap);
-                        String path = FileUtil.getAbsolutePath("财产清单(公司)" + guarantorName, ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
+                        String path = FileUtil.getAbsolutePath("财产清单(公司)" + guarantorName + UUID.randomUUID(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
                         File estateFile = new File(path);
                         if (!estateFile.exists()) {
                             FileUtils.createParentDirectories(estateFile);
                         }
                         template.writeToFile(path);
-                        list.add(estateFile);
+                        return estateFile;
                     }
                 }
             }
@@ -714,6 +715,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
             e.printStackTrace();
             throw new BusinessException(CodeUtil.FAIL, "下载财产清单出错" + e.getMessage());
         }
+        return null;
     }
 
     /**
@@ -721,10 +723,9 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
      *
      * @param chattelMortgageId
      * @param contractInfo
-     * @param list
      * @param absolutePath
      */
-    private void dealNewChattelMortgageContract(Long chattelMortgageId, ContractInfo contractInfo, List<File> list, String absolutePath) {
+    private File dealNewChattelMortgageContract(Long chattelMortgageId, ContractInfo contractInfo, String absolutePath) {
         try {
             // 主合同信息
             ReviewMasterContract masterContract = reviewMasterContractService.lambdaQuery().eq(ReviewMasterContract::getReviewQuotaDisburseId, contractInfo.getReviewQuotaDisburseId()).one();
@@ -875,20 +876,26 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     map.put("financingAmountEname", financingAmount_en);
                     map.put("financingAmount", NumberFormatUtil.convertDecimal(financingAmount,
                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL));
-                    String path = FileUtil.getAbsolutePath(UUID.randomUUID().toString(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
+                    String path = null;
+                    if (type.equals(ConstantConversionUtil.IDENTITY_TYPE1)) {
+                        path = FileUtil.getAbsolutePath("动产抵押合同(个人)" + mortgagorName + UUID.randomUUID(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
+                    } else if (type.equals(ConstantConversionUtil.IDENTITY_TYPE2)) {
+                        path = FileUtil.getAbsolutePath("动产抵押合同(公司)" + mortgagorName + UUID.randomUUID(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
+                    }
                     XWPFTemplate template = XWPFTemplate.compile(absolutePath, config).render(map);
                     File file = new File(path);
                     if (!file.exists()) {
                         FileUtils.createParentDirectories(file);
                     }
                     template.writeToFile(path);
-                    list.add(file);
+                    return file;
                 }
             }
         } catch (Exception e) {
             e.printStackTrace();
             throw new BusinessException(CodeUtil.FAIL, "下载动产股权抵押合同错误错误" + e.getMessage());
         }
+        return null;
     }
 
     /**
@@ -896,10 +903,9 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
      *
      * @param chattelMortgageId
      * @param contractInfo
-     * @param list
      * @param absolutePath
      */
-    private void dealNewEquityPledgeContract(Long chattelMortgageId, ContractInfo contractInfo, List<File> list, String absolutePath) {
+    private File dealNewEquityPledgeContract(Long chattelMortgageId, ContractInfo contractInfo, String absolutePath) {
         try {
             // 币种中文名称
             String currency_cn = "人民币";
@@ -989,21 +995,26 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     }
                     map.put("financingAmount", financingAmount.toString());
                     map.put("financingAmountCname", financingAmountCname);
-
-                    String path = FileUtil.getAbsolutePath(UUID.randomUUID().toString(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
+                    String path = null;
+                    if (type.equals(ConstantConversionUtil.IDENTITY_TYPE1)) {
+                        path = FileUtil.getAbsolutePath("股权质押合同(个人)" + mortgageBasicInfo.getMortgagorName() + UUID.randomUUID(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
+                    } else if (type.equals(ConstantConversionUtil.IDENTITY_TYPE2)) {
+                        path = FileUtil.getAbsolutePath("股权质押合同(公司)" + mortgageBasicInfo.getMortgagorName() + UUID.randomUUID(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
+                    }
                     File file = new File(path);
                     if (!file.exists()) {
                         FileUtils.createParentDirectories(file);
                     }
                     XWPFTemplate template = XWPFTemplate.compile(absolutePath).render(map);
                     template.writeToFile(path);
-                    list.add(file);
+                    return file;
                 }
             }
         } catch (Exception e) {
             e.printStackTrace();
             throw new BusinessException(CodeUtil.FAIL, "下载股权质押合同出错" + e.getMessage());
         }
+        return null;
     }
 
     /**
@@ -1011,10 +1022,9 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
      *
      * @param reviewRltRepayId
      * @param contractInfo
-     * @param list
      * @param absolutePath
      */
-    private void dealMaximumGuaranteeCulevert(Long reviewRltRepayId, ContractInfo contractInfo, List<File> list, String absolutePath) {
+    private File dealMaximumGuaranteeCulevert(Long reviewRltRepayId, ContractInfo contractInfo, String absolutePath) {
         try {
             // 主合同信息
             ReviewMasterContract masterContract = reviewMasterContractService.lambdaQuery().eq(ReviewMasterContract::getReviewQuotaDisburseId, contractInfo.getReviewQuotaDisburseId()).one();
@@ -1084,7 +1094,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
             String guarantorEmail = rltRepay.getResponsibleEmail();
 
             Map<String, Object> map = new HashMap<>();
-            ;
+            String path = null;
             if (null != rltRepay && rltRepay.getArlpIdType() != null) {
                 String type = rltRepay.getArlpIdType();
                 // 个人
@@ -1133,7 +1143,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     map.put("currency_en", currency_en);
                     map.put("creditLineCname", creditLineCname);
                     map.put("currency_cn", currency_cn);
-
+                    path = FileUtil.getAbsolutePath("最高额保证合同(个人)" + rltRepay.getArlpName(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
                 } else {
                     // 公司
                     map.put("guaranteeContractNo", guaranteeContractNo);
@@ -1164,21 +1174,21 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     map.put("currency_en", currency_en);
                     map.put("creditLineCname", creditLineCname);
                     map.put("currency_cn", currency_cn);
-
+                    path = FileUtil.getAbsolutePath("最高额保证合同(公司)" + guarantorName, ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
                 }
                 XWPFTemplate template = XWPFTemplate.compile(absolutePath).render(map);
-                String path = FileUtil.getAbsolutePath(UUID.randomUUID().toString(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
                 File file = new File(path);
                 if (!file.exists()) {
                     FileUtils.createParentDirectories(file);
                 }
                 template.writeToFile(path);
-                list.add(file);
+                return file;
             }
         } catch (Exception e) {
             e.printStackTrace();
             throw new BusinessException(CodeUtil.FAIL, "下载担保函错误" + e.getMessage());
         }
+        return null;
     }
 
     /**
@@ -1186,11 +1196,10 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
      *
      * @param reviewRltRepayId
      * @param contractInfo
-     * @param list
      * @param absolutePath
      * @param contractName
      */
-    private void dealNewGuaranteeCulevert(Long reviewRltRepayId, ContractInfo contractInfo, List<File> list, String absolutePath, String contractName) {
+    private File dealNewGuaranteeCulevert(Long reviewRltRepayId, ContractInfo contractInfo, String absolutePath, String contractName) {
         try {
             // 主合同信息
             ReviewMasterContract masterContract = reviewMasterContractService.lambdaQuery().eq(ReviewMasterContract::getReviewQuotaDisburseId, contractInfo.getReviewQuotaDisburseId()).one();
@@ -1242,6 +1251,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
             String legalRepresentative = rltRepay.getLegalRepresentative();
             //责任人邮箱
             String guarantorEmail = rltRepay.getResponsibleEmail();
+            String path = null;
             if (null != rltRepay && rltRepay.getArlpIdType() != null) {
                 String type = rltRepay.getArlpIdType();
                 // 个人
@@ -1280,7 +1290,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     // 债务人公司名称
                     map.put("debtorCompanyName", debtorCompanyName);
                     map.put("guarantorEmail", guarantorEmail);
-
+                    path = FileUtil.getAbsolutePath("担保函(个人)" + guarantorName, ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
                 } else {
                     // 公司
                     map.put("guaranteeContractNo", guaranteeContractNo);
@@ -1301,27 +1311,27 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     map.put("year", DateUtil.getYear(date));
                     // 债务人公司名称
                     map.put("debtorCompanyName", debtorCompanyName);
-
+                    path = FileUtil.getAbsolutePath("担保函(公司)" + guarantorName, ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
                 }
                 XWPFTemplate template = XWPFTemplate.compile(absolutePath).render(map);
-                String path = FileUtil.getAbsolutePath(UUID.randomUUID().toString(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
                 File file = new File(path);
                 if (!file.exists()) {
                     FileUtils.createParentDirectories(file);
                 }
                 template.writeToFile(path);
-                list.add(file);
+                return file;
             }
         } catch (Exception e) {
             e.printStackTrace();
             throw new BusinessException(CodeUtil.FAIL, "下载担保函错误" + e.getMessage());
         }
+        return null;
     }
 
     /**
      * 下载(贸理通)三方协议
      */
-    public void dealNewtTripartiteAgreementFactoringDownload(ContractInfo contractInfo, List<File> list, Long basicContractId, String absolutePath) {
+    public File dealNewtTripartiteAgreementFactoringDownload(ContractInfo contractInfo, Long basicContractId, String absolutePath) {
         try {
             Map<String, Object> map = new HashMap<>();
             // 主合同信息
@@ -1343,7 +1353,11 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
             map.put("managementFeeAmount", financingInfo.getManagementFeeAmount());
             // 国内有追索权(正向、反向)、国内无追索权(正向,目前没有反向业务)、池保理(出口和国内)均有三方协议和交易信息表
             //贸理通默认国内池保理
-            List<ContractBasicContract> basicContractList = contractBasicContractService.list(new QueryWrapper<ContractBasicContract>().eq("contract_info_id", contractInfo.getId()));
+            List<ContractBasicContract> basicContractList = contractInfo.getContractBasicContractList();
+            if (CollectionUtil.isEmpty(basicContractList)) {
+                basicContractList = contractBasicContractService.list(new QueryWrapper<ContractBasicContract>()
+                        .eq("contract_info_id", contractInfo.getId()));
+            }
             String path;
             XWPFTemplate template;
             if (null != basicContractList && basicContractList.size() > 0) {
@@ -1432,18 +1446,19 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     FileUtils.createParentDirectories(file);
                 }
                 template.writeToFile(path);
-                list.add(file);
+                return file;
             }
         } catch (Exception e) {
             e.printStackTrace();
             throw new BusinessException(CodeUtil.FAIL, "下载三方协议(贸理通)出错" + e.getMessage());
         }
+        return null;
     }
 
     /**
      * 下载三方协议
      */
-    public void dealNewtTripartiteAgreementDownload(ContractInfo contractInfo, List<File> list, Long basicContractId, String absolutePath) {
+    public File dealNewtTripartiteAgreementDownload(ContractInfo contractInfo, Long basicContractId, String absolutePath) {
         try {
             // 主合同信息
             ReviewMasterContract masterContract = reviewMasterContractService.getOne(new QueryWrapper<ReviewMasterContract>()
@@ -1452,7 +1467,11 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
             String factoringContractNo = masterContract.getContractNo();
             String path;
             XWPFTemplate template;
-            List<ContractBasicContract> basicContractList = contractBasicContractService.list(new QueryWrapper<ContractBasicContract>().eq("contract_info_id", contractInfo.getId()));
+            List<ContractBasicContract> basicContractList = contractInfo.getContractBasicContractList();
+            if (CollectionUtil.isEmpty(basicContractList)) {
+                basicContractList = contractBasicContractService.list(new QueryWrapper<ContractBasicContract>()
+                        .eq("contract_info_id", contractInfo.getId()));
+            }
             if (null != basicContractList && basicContractList.size() > 0) {
                 // 表示有三方协议
                 Map<String, Object> map = new HashMap<>();
@@ -1515,18 +1534,19 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     FileUtils.createParentDirectories(file);
                 }
                 template.writeToFile(path);
-                list.add(file);
+                return file;
             }
         } catch (Exception e) {
             e.printStackTrace();
             throw new BusinessException(CodeUtil.FAIL, "下载三方协议出错" + e.getMessage());
         }
+        return null;
     }
 
     /**
      * 下载池保理业务合同 保理业务合同
      */
-    private void dealNewPoolFactoringBusinessContract(ContractInfo contractInfo, List<File> list, String absolutePath, String type) {
+    private File dealNewPoolFactoringBusinessContract(ContractInfo contractInfo, String absolutePath, String type) {
         XWPFTemplate template;
         String path;
         try {
@@ -1583,7 +1603,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     FileUtils.createParentDirectories(file);
                 }
                 template.writeToFile(path);
-                list.add(file);
+                return file;
             } else {
                 template = XWPFTemplate.compile(absolutePath).render(dataMap);
                 path = FileUtil.getAbsolutePath("保理业务合同" + applicantCompanyName, ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
@@ -1592,7 +1612,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     FileUtils.createParentDirectories(file);
                 }
                 template.writeToFile(path);
-                list.add(file);
+                return file;
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -1603,15 +1623,18 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
     /**
      * 下载保理信息表或保理融资确认书
      */
-    private void dealNewFactoringInfo(ContractInfo contractInfo, List<File> fileAllList, String absolutePath, String type) {
+    private File dealNewFactoringInfo(ContractInfo contractInfo, String absolutePath, String type) {
         String path;
         XWPFTemplate template;
         try {
             // 主合同信息
             ReviewMasterContract master = reviewMasterContractService.getOne(new QueryWrapper<ReviewMasterContract>()
                     .eq("review_quota_disburse_id", contractInfo.getReviewQuotaDisburseId()));
-            ContractMasterContract contractMasterContract = contractMasterContractService.getOne(new QueryWrapper<ContractMasterContract>()
-                    .eq("contract_info_id", contractInfo.getId()));
+            ContractMasterContract contractMasterContract = contractInfo.getContractMasterContract();
+            if (contractMasterContract == null) {
+                contractMasterContract = contractMasterContractService.getOne(new QueryWrapper<ContractMasterContract>()
+                        .eq("contract_info_id", contractInfo.getId()));
+            }
             if (null != master) {
                 Map<String, Object> dataMap = new HashMap<>();
                 // 保理合同编号
@@ -1816,8 +1839,11 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                 int loanConditionListLength = 0;
                 ReviewFinancingInfo financingInfo = reviewFinancingInfoService.getOne(new QueryWrapper<ReviewFinancingInfo>()
                         .eq("review_quota_disburse_id", contractInfo.getReviewQuotaDisburseId()));
-                ContractFinancingInfo contractFinancingInfo = contractFinancingInfoService.getOne(new QueryWrapper<ContractFinancingInfo>()
-                        .eq("contract_info_id", contractInfo.getId()));
+                ContractFinancingInfo contractFinancingInfo = contractInfo.getContractFinancingInfo();
+                if (contractFinancingInfo == null) {
+                    contractFinancingInfo = contractFinancingInfoService.getOne(new QueryWrapper<ContractFinancingInfo>()
+                            .eq("contract_info_id", contractInfo.getId()));
+                }
                 if (null != financingInfo) {
                     // 池保理
                     if (isPool.equals(ConstantConversionUtil.POOL_FACTORING)) {
@@ -1927,7 +1953,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     // 管理费金额
                     manageFeeAmount = financingInfo.getManagementFeeAmount();
                     // 管理费率
-                    manageFeeRate = StringUtil.subZeroAndDot(PercentageUtil.convertPercentage(financingInfo.getManagementFeeRatio().doubleValue()).split("%")[0]+ "%");
+                    manageFeeRate = StringUtil.subZeroAndDot(PercentageUtil.convertPercentage(financingInfo.getManagementFeeRatio().doubleValue()).split("%")[0] + "%");
                     // 管理费金额大写
                     if (null != manageFeeAmount) {
                         manageFeeAmountName = MoneyToCNFormatUtil.formatToCN(manageFeeAmount.doubleValue());
@@ -1999,8 +2025,13 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                         String supplementaryConditionNo = null;
                         // 付款条件
                         String paymentCondition = null;
-                        List<ContractLoanConditionSetting> loanConditionSetList = contractLoanConditionSettingService.list(new QueryWrapper<ContractLoanConditionSetting>()
-                                .eq("contract_info_id", contractInfo.getId()).eq("is_checked", true));
+                        List<ContractLoanConditionSetting> loanConditionSetList = contractInfo.getConditionSettingList();
+                        if (CollectionUtil.isEmpty(loanConditionSetList)) {
+                            loanConditionSetList = contractLoanConditionSettingService.list(new QueryWrapper<ContractLoanConditionSetting>()
+                                    .eq("contract_info_id", contractInfo.getId()).eq("is_checked", true));
+                        } else {
+                            loanConditionSetList = loanConditionSetList.stream().filter(setting -> setting.getChecked() != null && setting.getChecked()).collect(Collectors.toList());
+                        }
                         if (null != loanConditionSetList && loanConditionSetList.size() > 0) {
                             // 固定条件序号
                             List<Integer> fixedConditionList = loanConditionSetList.stream()
@@ -2048,9 +2079,16 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                 }
                 loanConditionListLength = loanConditionListMap.size() * 2;
 
-                List<ContractLoanConditionSetting> loanConditionSetList = contractLoanConditionSettingService.list(new QueryWrapper<ContractLoanConditionSetting>()
-                        .eq("contract_info_id", contractInfo.getId())
-                        .eq("condition_type", ConstantConversionUtil.CONTRACT_LOAN_CONDITION_SETTING_CONDITION));
+
+                List<ContractLoanConditionSetting> loanConditionSetList = contractInfo.getConditionSettingList();
+                if (CollectionUtil.isEmpty(loanConditionSetList)) {
+                    loanConditionSetList = contractLoanConditionSettingService.list(new QueryWrapper<ContractLoanConditionSetting>()
+                            .eq("contract_info_id", contractInfo.getId())
+                            .eq("condition_type", ConstantConversionUtil.CONTRACT_LOAN_CONDITION_SETTING_CONDITION));
+                } else {
+                    loanConditionSetList = loanConditionSetList.stream().filter(setting -> setting.getChecked() != null && setting.getChecked()
+                            && ConstantConversionUtil.CONTRACT_LOAN_CONDITION_SETTING_CONDITION.equals(setting.getConditionType())).collect(Collectors.toList());
+                }
                 if (null != loanConditionSetList && loanConditionSetList.size() > 0) {
                     List<ContractLoanConditionSetting> list2 = loanConditionSetList.stream()
                             .filter(e -> !e.getFixedCondition()).collect(Collectors.toList());
@@ -2278,7 +2316,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                         FileUtils.createParentDirectories(file);
                     }
                     template.writeToFile(path);
-                    fileAllList.add(file);
+                    return file;
                 } else if (type.equals(ConstantConversionUtil.POOL_FACTORING_INFORMATION_DOMESTIC)) {
                     LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
                     Configure configure = Configure.builder().bind("listMap2", policy)
@@ -2294,7 +2332,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                         FileUtils.createParentDirectories(file);
                     }
                     template.writeToFile(path);
-                    fileAllList.add(file);
+                    return file;
                 } else if (type.equals(ConstantConversionUtil.FACTORING_SERVICE_CONFIRMATION)) {
                     LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
                     Configure configure = Configure.builder().bind("listMap2", policy)
@@ -2307,13 +2345,14 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                         FileUtils.createParentDirectories(file);
                     }
                     template.writeToFile(path);
-                    fileAllList.add(file);
+                    return file;
                 }
             }
         } catch (Exception e) {
             e.printStackTrace();
             throw new BusinessException(CodeUtil.FAIL, "下载保理信息表出错" + e.getMessage());
         }
+        return null;
     }
 
     /**
@@ -2354,7 +2393,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
     /**
      * 下载应收账款转让通知书
      */
-    private void dealNewNoticeDownloadAll(ContractInfo contractInfo, List<File> fileAllList, String absolutePath, String type) {
+    private File dealNewNoticeDownloadAll(ContractInfo contractInfo, String absolutePath, String type) {
         String path;
         XWPFTemplate template;
         try {
@@ -2546,7 +2585,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                         file.getParentFile().mkdirs();
                     }
                     template.writeToFile(file.getPath());
-                    fileAllList.add(file);
+                    return file;
                 } else if (type.equals(ConstantConversionUtil.DOMESTIC_ACCOUNT_RECEIVABLE_TRANSFER_NOTICE_BRIGHT)) {
                     LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
                     Configure configure = Configure.builder().bind("changeList", policy).build();
@@ -2557,20 +2596,20 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                         file.getParentFile().mkdirs();
                     }
                     template.writeToFile(file.getPath());
-                    fileAllList.add(file);
+                    return file;
                 }
-
             }
         } catch (Exception e) {
             e.printStackTrace();
             throw new BusinessException(CodeUtil.FAIL, "应收账款转让通知书" + e.getMessage());
         }
+        return null;
     }
 
     /**
      * 下载池保理应收账款入池确认书
      */
-    private void dealNewConfirmDownload(ContractInfo contractInfo, List<File> fileAllList, String absolutePath, String type) {
+    private File dealNewConfirmDownload(ContractInfo contractInfo, String absolutePath, String type) {
         try {
             // 主合同信息
             ReviewMasterContract masterContract = reviewMasterContractService.getOne(new QueryWrapper<ReviewMasterContract>()
@@ -2649,7 +2688,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                 //融资本金
                 BigDecimal financingAmmount = financingInfo.getFinancingAmount() == null ? BigDecimal.ZERO : financingInfo.getFinancingAmount();
                 BigDecimal financingDays = new BigDecimal(Integer.parseInt(financingInfo.getFinancingPeriod().toString()));
-                if (financingInfo.getOccupation() != null && financingInfo.getOccupation() == 0){
+                if (financingInfo.getOccupation() != null && financingInfo.getOccupation() == 0) {
                     //那如果综合考虑的话,这个公式改成:融资本金+融资本金*(12%-管理费率)/360*融资期限
                     BigDecimal balanceLong = financingAmmount
                             .add(financingAmmount
@@ -2657,7 +2696,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                     .divide(new BigDecimal("360"), 8, BigDecimal.ROUND_HALF_UP).multiply(financingDays));
                     BigDecimal balance = balanceLong.setScale(3, RoundingMode.HALF_UP);
                     confirmMap.put("balance", balance);
-                }else {
+                } else {
                     confirmMap.put("balance", BigDecimal.ZERO);
                 }
 
@@ -2750,21 +2789,21 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                 if (!file.exists()) {
                     FileUtils.createParentDirectories(file);
                 }
-                fileAllList.add(file);
+                return file;
             }
         } catch (Exception e) {
             e.printStackTrace();
             throw new BusinessException(CodeUtil.FAIL, "下载应收账款转让确认书错误" + e.getMessage());
         }
+        return null;
     }
 
     /**
      * 下载交易信息表
      *
      * @param contractInfo
-     * @param list
      */
-    private void dealNewTradingInfoDownload(ContractInfo contractInfo, List<File> list, Long basicId, String absolutePath) {
+    private File dealNewTradingInfoDownload(ContractInfo contractInfo, Long basicId, String absolutePath) {
         try {
             // 主合同信息
             ReviewMasterContract masterContract = reviewMasterContractService.getOne(new QueryWrapper<ReviewMasterContract>()
@@ -2782,8 +2821,11 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
             String path;
             XWPFTemplate template;
             ContractBasicContract basic = null;
-            List<ContractBasicContract> basicContractList = contractBasicContractService.list(new QueryWrapper<ContractBasicContract>()
-                    .eq("contract_info_id", contractInfo.getId()));
+            List<ContractBasicContract> basicContractList = contractInfo.getContractBasicContractList();
+            if (CollectionUtil.isEmpty(basicContractList)) {
+                basicContractList = contractBasicContractService.list(new QueryWrapper<ContractBasicContract>()
+                        .eq("contract_info_id", contractInfo.getId()));
+            }
             for (ContractBasicContract basicContract : basicContractList) {
                 if (basicContract.getId().equals(basicId)) {
                     basic = basicContract;
@@ -2844,11 +2886,12 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     FileUtils.createParentDirectories(file);
                 }
                 template.writeToFile(path);
-                list.add(file);
+                return file;
             }
         } catch (Exception e) {
             e.printStackTrace();
             throw new BusinessException(CodeUtil.FAIL, "下载交易信息表出错" + e.getMessage());
         }
+        return null;
     }
 }

+ 18 - 0
src/main/java/com/sunxung/factoring/service/financing/payment/impl/PaymentApplyServiceImpl.java

@@ -506,6 +506,9 @@ public class PaymentApplyServiceImpl extends ServiceImpl<PaymentApplyMapper, Pay
         List<ReviewRltRepay> rltRepayList = reviewRltRepayService.list(new QueryWrapper<ReviewRltRepay>()
                 .eq("review_quota_disburse_id", reviewQuotaDisburse.getId()));
         autoRltRepay(rltRepayList, quotaDisburseReport);
+        //抵质押信息
+        List<ReviewMortgageBasicInfo> reviewMortgageBasicInfoList = reviewMortgageBasicInfoService.findByQuotaDisburseId(reviewQuotaDisburse.getId());
+        autoMortgageBasicInfoList(reviewMortgageBasicInfoList, quotaDisburseReport);
         //应收账款转让
         ReviewTransferReceivable transferReceivable = reviewTransferReceivableService
                 .getOne(new QueryWrapper<ReviewTransferReceivable>().eq("review_quota_disburse_id", reviewQuotaDisburse.getId()));
@@ -526,6 +529,21 @@ public class PaymentApplyServiceImpl extends ServiceImpl<PaymentApplyMapper, Pay
         }
     }
 
+    /**
+     * 填充抵质押信息
+     *
+     * @param reviewMortgageBasicInfoList
+     * @param quotaDisburseReport
+     */
+    private void autoMortgageBasicInfoList(List<ReviewMortgageBasicInfo> reviewMortgageBasicInfoList, QuotaDisburseReport quotaDisburseReport) {
+        if (CollectionUtil.isNotEmpty(reviewMortgageBasicInfoList)) {
+            quotaDisburseReport.setMortgageInfo(1);
+            quotaDisburseReport.setMortgageBasicInfoList(reviewMortgageBasicInfoList);
+        } else {
+            quotaDisburseReport.setMortgageInfo(0);
+        }
+    }
+
     /**
      * 填充相关还款责任人
      *

+ 9 - 1
src/main/java/com/sunxung/factoring/service/financing/review/impl/ReviewQuotaDisburseServiceImpl.java

@@ -674,7 +674,15 @@ public class ReviewQuotaDisburseServiceImpl extends ServiceImpl<ReviewQuotaDisbu
             //贸理通默认池保理
             UpdateWrapper<ReviewMasterContract> updateWrapper = new UpdateWrapper<>();
             updateWrapper.eq("id", masterContract.getId());
-            updateWrapper.set("contract_name", "池保理业务合同");
+            if (quotaDisburse.getReviewFinancingInfo() != null
+                    && quotaDisburse.getReviewFinancingInfo().getOccupation() != null && quotaDisburse.getReviewFinancingInfo().getOccupation() == 0
+                    && quotaDisburse.getReviewFinancingInfo().getRisk() != null && quotaDisburse.getReviewFinancingInfo().getRisk() == 1) {
+                //不占用公司资金且公司承险
+                updateWrapper.set("contract_name", "保理业务合同");
+            } else {
+                updateWrapper.set("contract_name", "池保理业务合同");
+            }
+
             reviewMasterContractService.update(updateWrapper);
         }
     }

+ 21 - 6
src/main/java/com/sunxung/factoring/service/sys/FileStorageService.java

@@ -124,20 +124,22 @@ public interface FileStorageService {
      * @param downUrl
      * @return
      */
-    FileStorage addFileStorageWithBelongAndName(String contractId, FileModuleDict.ChildEnum moduleType, String downUrl,Long supplemementId);
+    FileStorage addFileStorageWithBelongAndName(String contractId, FileModuleDict.ChildEnum moduleType, String downUrl, Long supplemementId);
 
     List<FileStorage> findByBelongIdAndBelongType(String belongId, String belongType);
 
     /**
      * 保存附件关系到中间表
+     *
      * @param fileStorage
      * @param moduleType
      * @param entityId
      */
-    void saveAttachmentRefByFileStorage(FileStorage fileStorage,FileModuleDict.ChildEnum moduleType,Long entityId);
+    void saveAttachmentRefByFileStorage(FileStorage fileStorage, FileModuleDict.ChildEnum moduleType, Long entityId);
 
     /**
      * 上传附件
+     *
      * @param req
      * @param moudleName
      * @return
@@ -146,31 +148,42 @@ public interface FileStorageService {
 
     /**
      * 删除无用文件id集合
+     *
      * @return
      */
     void deleteInvalidFileStorage();
 
     /**
      * 删除文件 只删除fileStorage
+     *
      * @param id
      */
     Boolean deleteFileStorage(Long id);
 
     /**
      * 文件打包下载 zip
+     *
      * @param fileStorageList 文件合集
-     * @param name 文件名
-     * @param moduleType 文件所在的模块名
+     * @param name            文件名
+     * @param moduleType      文件所在的模块名
      * @param response
      */
-   void downloadZipFile(List<FileStorage> fileStorageList, String name, FileModuleDict.ChildEnum moduleType,HttpServletResponse response);
+    void downloadZipFile(List<FileStorage> fileStorageList, String name, FileModuleDict.ChildEnum moduleType, HttpServletResponse response);
+
+    /**
+     * 文件下载
+     *
+     * @param res
+     * @param file
+     */
+    void downloadFile(HttpServletResponse res, File file);
 
     /**
      * 给文件夹中重名的文件重命名
      *
      * @param fileStorageList
      */
-   void renameFileStorageList(List<FileStorage> fileStorageList);
+    void renameFileStorageList(List<FileStorage> fileStorageList);
 
     /**
      * 文件下载
@@ -182,6 +195,7 @@ public interface FileStorageService {
 
     /**
      * 保存文件
+     *
      * @param fileIds c端文件表id
      * @return
      */
@@ -191,6 +205,7 @@ public interface FileStorageService {
 
     /**
      * 通过绝对路径查询文件信息
+     *
      * @param absolutePath
      * @return
      */

+ 2 - 2
src/main/java/com/sunxung/factoring/service/sys/impl/FileStorageServiceImpl.java

@@ -456,7 +456,7 @@ public class FileStorageServiceImpl implements FileStorageService {
     @Override
     public void downloadZipFile(List<FileStorage> fileStorageList, String name, FileModuleDict.ChildEnum moduleType, HttpServletResponse response) {
         File zipFile = downloadZip(fileStorageList, name, moduleType);
-        doDownloadZip(response, zipFile);
+        downloadFile(response, zipFile);
     }
 
     @Override
@@ -557,7 +557,7 @@ public class FileStorageServiceImpl implements FileStorageService {
      * @param res
      * @param file
      */
-    public void doDownloadZip(HttpServletResponse res, File file) {
+    public void downloadFile(HttpServletResponse res, File file) {
         try {
             if (file.exists()) {
                 String fileName = file.getName();

+ 10 - 0
src/main/java/com/sunxung/factoring/web/financing/ContractMakingController.java

@@ -9,6 +9,8 @@ import com.sunxung.factoring.service.sys.flowable.FlowableService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
+
 /**
  * @Description : 合同制作Controller
  * @Author : L.Jia
@@ -44,6 +46,14 @@ public class ContractMakingController {
         return contractMakingService.editContractInfo(contractInfo);
     }
 
+    /**
+     * 下载合同模板
+     */
+    @PostMapping(value = "/exportContractMarking")
+    public void downloadContractTemplate(@RequestBody ContractInfo contractInfo, HttpServletResponse response) {
+        contractMakingService.downloadContractTemplate(contractInfo, response);
+    }
+
     /**
      * 获取上传的签署合同文件
      */