فهرست منبع

1.优化机器设备融资报告生成方法
2.优化DateToChinese的字符串日期转换方法
3.新增获取机器设备融资报告报告引用的测算信息接口

GouGengquan 7 ماه پیش
والد
کامیت
f118d4fbdf

+ 11 - 0
biz-base/src/main/java/com/dayou/controller/AssetsCalculateController.java

@@ -6,6 +6,7 @@ import com.dayou.dto.calculate.CalculateBaseInfoDTO;
 import com.dayou.result.Result;
 import com.dayou.result.Status;
 import com.dayou.vo.AssetsCalculateVO;
+import com.dayou.vo.EqptReportReferencesCalculateVO;
 import com.dayou.vo.calculate.AssetsCalculateProgressVO;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import lombok.extern.slf4j.Slf4j;
@@ -155,6 +156,16 @@ public class AssetsCalculateController {
         return Result.build(assetsCalculateService.getDropDownBoxData(projectId));
     }
 
+    /**
+     * 根据测算表id获取生成机器设备融资项目报告引用的测算表信息
+     * @param calculateId 测算表id
+     * @return EqptReportReferencesCalculateVO
+     */
+    @GetMapping("/getReferencesInfoById/{calculateId}")
+    public Result<EqptReportReferencesCalculateVO> getReferencesInfoById(@PathVariable Long calculateId) {
+       return Result.build(assetsCalculateService.getReferencesInfoById(calculateId));
+    }
+
 
 }
 

+ 2 - 0
biz-base/src/main/java/com/dayou/controller/AssetsReportController.java

@@ -1,5 +1,6 @@
 package com.dayou.controller;
 
+import cn.dev33.satoken.annotation.SaCheckLogin;
 import com.dayou.dto.report.ReportBaseInfoDTO;
 import com.dayou.result.Result;
 import com.dayou.vo.AssetsReportVO;
@@ -25,6 +26,7 @@ import java.util.List;
 @RestController
 @RequestMapping("assetsReport")
 @Slf4j
+@SaCheckLogin
 @CrossOrigin
 public class AssetsReportController {
 

+ 1 - 1
biz-base/src/test/java/com/dayou/WordSimpleTests.java

@@ -176,7 +176,7 @@ public class WordSimpleTests {
         // 需要插入的word文件
         Document subDoc = new Document("E:\\test\\word\\5_main_output.doc");
 
-        mainDoc = AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, subDoc, bookmark, false, true, false);
+        mainDoc = AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, subDoc, bookmark, false, true);
         // 保存文件
         mainDoc.save("E:\\test\\word\\2_framework_output.doc");
     }

+ 10 - 2
common/src/main/java/com/dayou/utils/DateToChinese.java

@@ -46,9 +46,8 @@ public class DateToChinese {
      * @return 汉字日 13==>十三
      */
     public static String getStrDay(String day) {
-        int dayLength = day.length();
         String strDay = "";
-        if (dayLength < 2) {
+        if (Integer.parseInt(day) < 10) {
             strDay = numToStr(day);
             return strDay;
         } else {
@@ -113,22 +112,31 @@ public class DateToChinese {
             case "0":
                 return "〇";
             case "1":
+            case "01":
                 return "一";
             case "2":
+            case "02":
                 return "二";
             case "3":
+            case "03":
                 return "三";
             case "4":
+            case "04":
                 return "四";
             case "5":
+            case "05":
                 return "五";
             case "6":
+            case "06":
                 return "六";
             case "7":
+            case "07":
                 return "七";
             case "8":
+            case "08":
                 return "八";
             case "9":
+            case "09":
                 return "九";
             case "10":
                 return "十";

+ 9 - 0
dao/src/main/java/com/dayou/mapper/AssetsCalculateMapper.java

@@ -4,6 +4,7 @@ import com.dayou.common.DropDownBoxData;
 import com.dayou.entity.AssetsCalculate;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.dayou.vo.AssetsCalculateVO;
+import com.dayou.vo.EqptReportReferencesCalculateVO;
 import com.dayou.vo.calculate.AssetsCalculateProgressVO;
 import org.apache.ibatis.annotations.Param;
 
@@ -70,4 +71,12 @@ public interface AssetsCalculateMapper extends BaseMapper<AssetsCalculate> {
      * @return List<DropDownBoxData>
      */
     List<DropDownBoxData> getDropDownBoxData(@Param("projectId") Long projectId);
+
+    /**
+     * 根据测算表id获取生成机器设备融资项目报告引用的测算表信息
+     * @param calculateId 测算表id
+     * @return EqptReportReferencesCalculateVO
+     */
+    EqptReportReferencesCalculateVO getReferencesInfoById(@Param("calculateId") Long calculateId);
+
 }

+ 7 - 0
dao/src/main/java/com/dayou/mapper/AssetsReportMapper.java

@@ -63,4 +63,11 @@ public interface AssetsReportMapper extends BaseMapper<AssetsReport> {
      */
     EqptReportFillBO geteqptReportFillBO(@Param("reportId") Long reportId);
 
+    /**
+     * 获取新增DocumentProduction所需的报告信息
+     * @param reportId 报告id
+     * @return AssetsReportVO
+     */
+    AssetsReportVO getReportInfoForDoc(@Param("reportId") Long reportId);
+
 }

+ 15 - 0
dao/src/main/resources/mapper/AssetsCalculateMapper.xml

@@ -98,5 +98,20 @@
         AND project_id = #{projectId}
     </select>
 
+    <!--根据测算表id获取生成机器设备融资项目报告引用的测算表信息-->
+    <select id="getReferencesInfoById" resultType="com.dayou.vo.EqptReportReferencesCalculateVO">
+        SELECT valuation_basis_date,
+               (SELECT COUNT(id) FROM assets_calculate_eqpt_data WHERE assets_calculate_id = #{calculateId} AND delete_status = 0) AS assetCount,
+               (SELECT GROUP_CONCAT( equipment.equipment_name SEPARATOR '、' ) AS concatenated_string
+                FROM ( SELECT equipment_name FROM assets_calculate_eqpt_data WHERE assets_calculate_id = 2 AND delete_status = 0 LIMIT 3 ) AS equipment) AS majorEquipmentAssets,
+               MIN(YEAR(purchase_date)) AS minPurchaseYear,
+               MAX(YEAR(purchase_date)) AS maxPurchaseYear
+        FROM assets_calculate AS calculate
+        LEFT JOIN assets_calculate_eqpt_data AS data ON calculate.id = data.assets_calculate_id AND data.delete_status = 0
+        WHERE calculate.id = #{calculateId}
+        AND calculate.delete_status = 0
+
+    </select>
+
 
 </mapper>

+ 23 - 1
dao/src/main/resources/mapper/AssetsReportMapper.xml

@@ -35,7 +35,8 @@
                report.create_time,
                doc.doc_name,
                doc.doc_url,
-               report.progress
+               report.progress,
+               calculate_id
         FROM assets_report AS report
         LEFT JOIN assets_project AS project ON project.id = report.project_id AND project.delete_status = 0
         LEFT JOIN assets_calculate AS calculate ON calculate.id = report.calculate_id AND calculate.delete_status = 0
@@ -92,4 +93,25 @@
         AND report.id = #{reportId}
     </select>
 
+    <!--获取新增DocumentProduction所需的报告信息-->
+    <select id="getReportInfoForDoc" resultType="com.dayou.vo.AssetsReportVO">
+        SELECT report.id AS id,
+               report.project_id,
+               report_name,
+               valuation_basis_date,
+               principal,
+               dict_data.name AS projectTypeName,
+               report.create_time,
+               doc.doc_name,
+               doc.doc_url,
+               report.progress
+        FROM assets_report AS report
+                 LEFT JOIN assets_project AS project ON project.id = report.project_id AND project.delete_status = 0
+                 LEFT JOIN assets_calculate AS calculate ON calculate.id = report.calculate_id AND calculate.delete_status = 0
+                 LEFT JOIN sys_dict_data AS dict_data ON dict_data.id = project.project_type_id
+                 LEFT JOIN document_production AS doc ON doc.business_id = project.id AND doc.business_sub_id = report.id
+        WHERE report.delete_status = 0
+          AND report.id = #{reportId}
+    </select>
+
 </mapper>

+ 1 - 1
domain/src/main/java/com/dayou/dto/report/equipment/EqptReportBaseInfoDTO.java

@@ -55,7 +55,7 @@ public class EqptReportBaseInfoDTO {
     /**
      * 是否包含增值税
      */
-    private Boolean hasVAT;
+    private String hasVAT;
 
     /**
      * 评估报告日

+ 3 - 1
domain/src/main/java/com/dayou/enums/DocumentType.java

@@ -16,7 +16,9 @@ public enum DocumentType {
 
     FOLDER("FOLDER","文件夹"),
 
-    EQPT_CALCULATE("EQPT_CALCULATE","机器设备测算表")
+    EQPT_CALCULATE("EQPT_CALCULATE","机器设备测算表"),
+
+    EQPT_REPORT("EQPT_REPORT","机器设备融资报告")
     ;
 
     private String name;

+ 10 - 0
domain/src/main/java/com/dayou/vo/AssetsReportVO.java

@@ -23,6 +23,16 @@ public class AssetsReportVO {
     private String reportName;
 
     /**
+     * 委托人
+     */
+    private String principal;
+
+    /**
+     * 项目类型
+     */
+    private String projectTypeName;
+
+    /**
      * 基础报告信息
      */
     private String baseInfo;

+ 43 - 0
domain/src/main/java/com/dayou/vo/EqptReportReferencesCalculateVO.java

@@ -0,0 +1,43 @@
+package com.dayou.vo;
+
+import lombok.Data;
+
+import java.time.LocalDate;
+
+/**
+ * 机器设备融资项目报告引用的机器设备测算表信息
+ */
+@Data
+public class EqptReportReferencesCalculateVO {
+
+    /**
+     * 评估基准日
+     */
+    private LocalDate valuationBasisDate;
+
+    /**
+     * 资产项数
+     */
+    private String assetCount;
+
+    /**
+     * 主要设备资产
+     */
+    private String majorEquipmentAssets;
+
+    /**
+     * 购置期间
+     */
+    private String purchasePeriod;
+
+    /**
+     * 最早购置年份
+     */
+    private String minPurchaseYear;
+
+    /**
+     * 最晚购置年份
+     */
+    private String maxPurchaseYear;
+
+}

+ 8 - 0
service/src/main/java/com/dayou/service/AssetsCalculateService.java

@@ -4,6 +4,7 @@ import com.dayou.entity.AssetsCalculate;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.dayou.vo.AssetsCalculateVO;
+import com.dayou.vo.EqptReportReferencesCalculateVO;
 import com.dayou.vo.calculate.AssetsCalculateProgressVO;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import org.springframework.web.multipart.MultipartFile;
@@ -92,4 +93,11 @@ public interface AssetsCalculateService extends IService<AssetsCalculate> {
          */
         List<DropDownBoxData> getDropDownBoxData(Long projectId);
 
+        /**
+         * 根据测算表id获取生成机器设备融资项目报告引用的测算表信息
+         * @param calculateId 测算表id
+         * @return EqptReportReferencesCalculateVO
+         */
+        EqptReportReferencesCalculateVO getReferencesInfoById(Long calculateId);
+
 }

+ 19 - 0
service/src/main/java/com/dayou/service/impl/AssetsCalculateServiceImpl.java

@@ -22,6 +22,7 @@ import com.dayou.utils.EasyExcelUtil;
 import com.dayou.vo.AssetsCalculateEqptImpDataVO;
 import com.dayou.vo.AssetsCalculateEqptNonsDataVO;
 import com.dayou.vo.AssetsCalculateVO;
+import com.dayou.vo.EqptReportReferencesCalculateVO;
 import com.dayou.vo.calculate.AssetsCalculateProgressVO;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.poi.ss.usermodel.*;
@@ -409,4 +410,22 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
     public List<DropDownBoxData> getDropDownBoxData(Long projectId) {
         return assetsCalculateMapper.getDropDownBoxData(projectId);
     }
+
+    /**
+     * 根据测算表id获取生成机器设备融资项目报告引用的测算表信息
+     * @param calculateId 测算表id
+     * @return EqptReportReferencesCalculateVO
+     */
+    @Override
+    public EqptReportReferencesCalculateVO getReferencesInfoById(Long calculateId) {
+        EqptReportReferencesCalculateVO referencesVO = assetsCalculateMapper.getReferencesInfoById(calculateId);
+        // 判断最大年份是否等于最小年份
+        if (referencesVO.getMinPurchaseYear().equals(referencesVO.getMaxPurchaseYear())) {
+            referencesVO.setPurchasePeriod(referencesVO.getMinPurchaseYear() + "年");
+        } else {
+            referencesVO.setPurchasePeriod(referencesVO.getMinPurchaseYear() + "年至" + referencesVO.getMaxPurchaseYear() + "年");
+        }
+        return referencesVO;
+
+    }
 }

+ 86 - 103
service/src/main/java/com/dayou/service/impl/AssetsReportServiceImpl.java

@@ -5,48 +5,41 @@ import cn.hutool.core.util.ObjectUtil;
 import com.aspose.words.Document;
 import com.aspose.words.DocumentBuilder;
 import com.aspose.words.ImportFormatMode;
-import com.aspose.words.Paragraph;
 import com.dayou.bo.EqptReportFillBO;
 import com.dayou.config.FileNetConfig;
 import com.dayou.dto.report.ReportBaseInfoDTO;
 import com.dayou.dto.report.equipment.EqptReportBaseInfoDTO;
 import com.dayou.entity.AssetsReport;
+import com.dayou.entity.DocumentProduction;
 import com.dayou.entity.TmplAssetReport;
 import com.dayou.entity.TmplAssetReportSection;
-import com.dayou.enums.EqptReportTmplCode;
 import com.dayou.mapper.AssetsReportMapper;
 import com.dayou.mapper.TmplAssetReportMapper;
 import com.dayou.mapper.TmplAssetReportSectionMapper;
 import com.dayou.service.AssetsReportService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dayou.service.DocumentProductionService;
 import com.dayou.utils.ArabicToChineseUtil;
 import com.dayou.utils.AsposeWordUtil;
 import com.dayou.utils.DataUtil;
 import com.dayou.utils.DateToChinese;
 import com.dayou.vo.AssetsReportVO;
 import com.dayou.vo.report.AssetsReportProgressVO;
-import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 
 import java.io.*;
 import java.math.RoundingMode;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.List;
-import java.util.ArrayList;
 import java.util.stream.Collectors;
 
 import org.springframework.transaction.annotation.Transactional;
 
+import static com.dayou.enums.DocumentType.EQPT_CALCULATE;
+import static com.dayou.enums.DocumentType.EQPT_REPORT;
 import static com.dayou.enums.EqptReportTmplCode.*;
 
 /**
@@ -70,6 +63,9 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
     private TmplAssetReportSectionMapper reportSectionMapper;
 
     @Autowired
+    private DocumentProductionService documentProductionService;
+
+    @Autowired
     private FileNetConfig fileNetConfig;
 
     /**
@@ -151,9 +147,10 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
      * @return Boolean
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Boolean generateEquipmentReport(Long reportId) throws Exception {
 
-        // 获取基础报告信息
+        // 获取与设置基础报告信息
         ObjectMapper objectMapper = new ObjectMapper();
         EqptReportFillBO eqptReportFillBO = assetsReportMapper.geteqptReportFillBO(reportId);
         // 设置增值率(评估净值 - 账面净值) / 账面净值,保留两位小数
@@ -174,75 +171,58 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
         // 将评估报告日转换为中文并设置到中文评估报告日中
         eqptReportFillBO.setChineseReportDate(DateToChinese.dateStrConvertChinese(eqptReportFillBO.getEqptReportBaseInfo().getReportDate()));
 
+
         // 第一步:设置封面
         // 获取封面模板
         TmplAssetReportSection coverTmpl = reportSectionMapper.getTmplByCode(COVER.getCode());
-        // 封面生成后文件位置
-        String coverPath = fileNetConfig.getBaseDir() + fileNetConfig.getAssetOutputReportPath() + System.currentTimeMillis() + "_COVER.docx";
         // 封面模板文件位置
         String coverTmplPath = fileNetConfig.getBaseDir() + coverTmpl.getSectionFileUrl() + coverTmpl.getSectionFileName();
-
         // 读取模板文件
         byte[] coverTmplByte = Files.readAllBytes(Paths.get(coverTmplPath));
         // 获取填充数据后的文件
         byte[] resultCoverByte = AsposeWordUtil.fillWordDataByMap(coverTmplByte, DataUtil.objToMap(eqptReportFillBO));
+        // 将封面的字节流转成输入流以供后续使用
+        InputStream coverIs = new ByteArrayInputStream(resultCoverByte);
 
-        // 处理该二进制文件并保存
-        File resultFile = new File(coverPath);
-        FileOutputStream fos = new FileOutputStream(resultFile);
-        fos.write(resultCoverByte);
-        fos.close();
 
         // 第二步:设置摘要内容
         // 获取正文
         TmplAssetReportSection digestTmpl = reportSectionMapper.getTmplByCode(DIGEST.getCode());
-        // 封面生成后文件位置
-        String digestPath = fileNetConfig.getBaseDir() + fileNetConfig.getAssetOutputReportPath() + System.currentTimeMillis() + "_DIGEST.docx";
         // 封面模板文件位置
         String digestTmplPath = fileNetConfig.getBaseDir() + digestTmpl.getSectionFileUrl() + digestTmpl.getSectionFileName();
-
         // 读取模板文件
         byte[] digestTmplByte = Files.readAllBytes(Paths.get(digestTmplPath));
         // 获取填充数据后的文件
         byte[] resultdigestByte = AsposeWordUtil.fillWordDataByMap(digestTmplByte, DataUtil.objToMap(eqptReportFillBO));
-
-        // 处理该二进制文件并保存
-        File digestFile = new File(digestPath);
-        FileOutputStream digestOs = new FileOutputStream(digestFile);
-        digestOs.write(resultdigestByte);
-        digestOs.close();
-        Document digestDoc = new Document(digestPath);
+        // 将摘要的字节流转成输入流以供后续使用
+        InputStream digestIs = new ByteArrayInputStream(resultdigestByte);
 
         // 第三步:设置正文内容
         // 获取正文
         TmplAssetReportSection detailTmpl = reportSectionMapper.getTmplByCode(DETAIL.getCode());
-        // 封面生成后文件位置
-        String detailPath = fileNetConfig.getBaseDir() + fileNetConfig.getAssetOutputReportPath() + System.currentTimeMillis() + "_DETAIL.docx";
         // 封面模板文件位置
         String detailTmplPath = fileNetConfig.getBaseDir() + detailTmpl.getSectionFileUrl() + detailTmpl.getSectionFileName();
-
         // 读取模板文件
         byte[] detailTmplByte = Files.readAllBytes(Paths.get(detailTmplPath));
         // 获取填充数据后的文件
         byte[] resultDetailByte = AsposeWordUtil.fillWordDataByMap(detailTmplByte, DataUtil.objToMap(eqptReportFillBO));
-
-        // 处理该二进制文件并保存
-        File detailFile = new File(detailPath);
-        FileOutputStream detailOs = new FileOutputStream(detailFile);
-        detailOs.write(resultDetailByte);
-        detailOs.close();
-
+        // 将正文的字节流转成输入流以供后续使用
+        InputStream detailIs = new ByteArrayInputStream(resultDetailByte);
         // 将正文读取出来
-        Document detailDoc = new Document(detailPath);
+        Document detailDoc = new Document(detailIs);
+        // 判断是否需要 质保期 注意事项段落,不需要就通过提前设置的书签移除掉
+        DocumentBuilder detailBuilder = new DocumentBuilder(detailDoc);
+        if (!eqptReportFillBO.getEqptReportBaseInfo().getAssetsInfo().getUnderWarranty()) {
+            detailBuilder.moveToBookmark("underWarranty");
+            detailBuilder.getCurrentParagraph().remove();
+        }
 
-        // 第四步:设置委托人概况
+        // 第四步:设置委托人概况到正文
         // 获取委托人概况模板
         TmplAssetReportSection consignorTmpl = reportSectionMapper.getTmplByCode(CONSIGNOR.getCode());
-        // 委托人概况生成后文件位置
-        String consignorPath = fileNetConfig.getBaseDir() + fileNetConfig.getAssetOutputReportPath() + System.currentTimeMillis() + "_CONSIGNOR.docx";
         // 委托人概况模板文件位置
         String consignorTmplPath = fileNetConfig.getBaseDir() + consignorTmpl.getSectionFileUrl() + consignorTmpl.getSectionFileName();
-
+        // 插入时会导致先插入的排在后插入的后面,所以把顺序反转一下
         for (int i = eqptReportFillBO.getEqptReportBaseInfo().getConsignorInfos().size(); i > 0; i--) {
             EqptReportBaseInfoDTO.ConsignorInfo consignorInfo = eqptReportFillBO.getEqptReportBaseInfo().getConsignorInfos().get(i -1);
             consignorInfo.setSort(i);
@@ -251,61 +231,34 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
             byte[] consignorTmplByte = Files.readAllBytes(Paths.get(consignorTmplPath));
             // 获取填充数据后的文件
             byte[] resultConsignorByte = AsposeWordUtil.fillWordDataByDomain(consignorTmplByte, consignorInfo);
-            // 处理该二进制文件并保存
-            File consignorFile = new File(consignorPath);
-            FileOutputStream consignorOs = new FileOutputStream(consignorFile);
-            consignorOs.write(resultConsignorByte);
-            consignorOs.close();
-
-            Document consignorDoc = new Document(consignorPath);
-            detailDoc = AsposeWordUtil.insertDocumentAfterBookMark(detailDoc, consignorDoc, "insertConsignor", false, false);
+            InputStream consignorIs = new ByteArrayInputStream(resultConsignorByte);
+            detailDoc = AsposeWordUtil.insertDocumentAfterBookMark(detailDoc, new Document(consignorIs), "insertConsignor", false, false);
+            consignorIs.close();
         }
 
-        // 第五步:设置产权持有人概况
+        // 第五步:设置产权持有人概况到正文
         // 获取产权持有人概况模板
         TmplAssetReportSection ownerTmpl = reportSectionMapper.getTmplByCode(PROPERTY_OWNER.getCode());
-        // 产权持有人概况生成后文件位置
-        String ownerPath = fileNetConfig.getBaseDir() + fileNetConfig.getAssetOutputReportPath() + System.currentTimeMillis() + "_PROPERTY_OWNER.docx";
         // 产权持有人概况模板文件位置
         String ownerTmplPath = fileNetConfig.getBaseDir() + ownerTmpl.getSectionFileUrl() + ownerTmpl.getSectionFileName();
-
         for (int i = eqptReportFillBO.getEqptReportBaseInfo().getPropertyOwnerInfos().size(); i > 0; i--) {
             EqptReportBaseInfoDTO.PropertyOwnerInfo propertyOwnerInfo = eqptReportFillBO.getEqptReportBaseInfo().getPropertyOwnerInfos().get(i - 1);
             propertyOwnerInfo.setSort(i);
             propertyOwnerInfo.setSortUppercase(ArabicToChineseUtil.int2chineseNum(i));
             // 读取模板文件
-            byte[] consignorTmplByte = Files.readAllBytes(Paths.get(ownerTmplPath));
+            byte[] propertyOwnerTmplByte = Files.readAllBytes(Paths.get(ownerTmplPath));
             // 获取填充数据后的文件
-            byte[] resultConsignorByte = AsposeWordUtil.fillWordDataByDomain(consignorTmplByte, propertyOwnerInfo);
-            // 处理该二进制文件并保存
-            File ownerFile = new File(ownerPath);
-            FileOutputStream consignorOs = new FileOutputStream(ownerFile);
-            consignorOs.write(resultConsignorByte);
-            consignorOs.close();
-
-            Document ownerDoc = new Document(ownerPath);
-            detailDoc = AsposeWordUtil.insertDocumentAfterBookMark(detailDoc, ownerDoc, "insertPropertyOwner", false, false);
+            byte[] propertyOwnerByte = AsposeWordUtil.fillWordDataByDomain(propertyOwnerTmplByte, propertyOwnerInfo);
+            InputStream propertyOwnerIs = new ByteArrayInputStream(propertyOwnerByte);
+            detailDoc = AsposeWordUtil.insertDocumentAfterBookMark(detailDoc, new Document(propertyOwnerIs), "insertPropertyOwner", false, false);
+            propertyOwnerIs.close();
         }
 
-        // 删除两个书签所在的空白行
-        DocumentBuilder builder = new DocumentBuilder(detailDoc);
-        builder.moveToBookmark("insertConsignor");
-        // 获取当前光标所在的段落
-        Paragraph currentParagraph1 = builder.getCurrentParagraph();
-        currentParagraph1.remove();
-        builder.moveToBookmark("insertPropertyOwner");
-        // 获取当前光标所在的段落
-        Paragraph currentParagraph2 = builder.getCurrentParagraph();
-        currentParagraph2.remove();
-
-        // 保存正文文件
-        detailDoc.save(detailPath);
-
         // 第六步:设置主体框架
         // 获取框架模板
         TmplAssetReport mainTmpl = tmplAssetReportMapper.getTmplByCode(MAIN.getCode());
         // 框架生成后文件位置
-        String mainPath = fileNetConfig.getBaseDir() + fileNetConfig.getAssetOutputReportPath() + System.currentTimeMillis() + "_MAIN.docx";
+        String mainPath = fileNetConfig.getBaseDir() + fileNetConfig.getAssetOutputReportPath() + System.currentTimeMillis() + "_设备融资报告.docx";
         // 框架模板文件位置
         String mainTmplPath = fileNetConfig.getBaseDir() + mainTmpl.getFileUrl() + mainTmpl.getFileName();
 
@@ -317,7 +270,7 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
         // 将框架读取出来
         Document mainDoc = new Document(mainIs);
         // 将摘要插入到框架
-        AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, digestDoc, "insertDigest", false, false);
+        AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, new Document(digestIs), "insertDigest", false, false);
         // 将正文插入到框架
         AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, detailDoc, "insertDetail", false, false);
 
@@ -345,36 +298,66 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
         // 将目录插入到框架
         AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, catalogueDoc, "insertCatalogue", false, false);
 
-        // 删除书签所在的空白行
+        // 第七步:删除预留书签插入位置的空白行
         DocumentBuilder mainBuilder = new DocumentBuilder(mainDoc);
-
+        // 移除正文的书签所在段落
         mainBuilder.moveToBookmark("insertDetail");
-        // 获取当前光标所在的段落
-        Paragraph mainCurrentParagraph1 = mainBuilder.getCurrentParagraph();
-        mainCurrentParagraph1.remove();
-
+        mainBuilder.getCurrentParagraph().remove();
+        // 移除摘要的书签所在段落
         mainBuilder.moveToBookmark("insertDigest");
-        // 获取当前光标所在的段落
-        Paragraph mainCurrentParagraph2 = mainBuilder.getCurrentParagraph();
-        mainCurrentParagraph2.remove();
-
+        mainBuilder.getCurrentParagraph().remove();
+        // 移除目录的书签所在段落
         mainBuilder.moveToBookmark("insertCatalogue");
-        // 获取当前光标所在的段落
-        Paragraph mainCurrentParagraph3 = mainBuilder.getCurrentParagraph();
-        mainCurrentParagraph3.remove();
-
+        mainBuilder.getCurrentParagraph().remove();
+        // 移除附件的书签所在段落
         mainBuilder.moveToBookmark("insertAttachments");
-        // 获取当前光标所在的段落
-        Paragraph mainCurrentParagraph4 = mainBuilder.getCurrentParagraph();
-        mainCurrentParagraph4.remove();
-
+        mainBuilder.getCurrentParagraph().remove();
+        // 移除委托人概况的书签所在段落
+        mainBuilder.moveToBookmark("insertConsignor");
+        mainBuilder.getCurrentParagraph().remove();
+        // 移除产权持有人概况的书签所在段落
+        mainBuilder.moveToBookmark("insertPropertyOwner");
+        mainBuilder.getCurrentParagraph().remove();
+
+        // 第八步:生成并保存文档
         // 将封面和文档进行拼接
-        Document coverDoc = new Document(coverPath);
+        Document coverDoc = new Document(coverIs);
         coverDoc.appendDocument(mainDoc, ImportFormatMode.KEEP_SOURCE_FORMATTING);
         // 更新目录页码
         AsposeWordUtil.updateCatalogueLink(coverDoc);
         coverDoc.save(mainPath);
 
-        return null;
+        // 关闭各个段落的流
+        coverIs.close();
+        digestIs.close();
+        detailIs.close();
+        mainIs.close();
+        attachmentsIs.close();
+
+        // 更新报告进度
+        assetsReportMapper.updateReportProgress(reportId,"FINISHED");
+
+        // 保存文档信息到数据库
+        // 设置文档信息
+        AssetsReportVO assetsReportVO = assetsReportMapper.getReportInfoForDoc(reportId);
+        DocumentProduction documentProduction = documentProductionService.getDocProdByBusinessId(assetsReportVO.getProjectId(), reportId);
+
+        if (ObjectUtil.isNotNull(documentProduction)) { // 判断文档信息是否为空,不为空说明以前生成过文档,则更新文档版本号
+            documentProduction.setDocVersion(documentProduction.getDocVersion() + 1);
+        } else { // 为空重新new对象
+            documentProduction = new DocumentProduction();
+        }
+        // 设置文档信息
+        documentProduction.setBusinessType("ASSETS")
+                .setBusinessId(assetsReportVO.getProjectId())
+                .setDocType(EQPT_REPORT.getName())
+                .setDocName(assetsReportVO.getReportName() + ".docx")
+                .setConsignor(assetsReportVO.getPrincipal())
+                .setDocUrl(mainPath)
+                .setCreateUserId(StpUtil.getLoginIdAsLong())
+                .setBusinessCate(assetsReportVO.getProjectTypeName())
+                .setDocNo(eqptReportFillBO.getProductionNo())
+                .setBusinessSubId(reportId);
+        return documentProductionService.saveDocumentProduction(documentProduction);
     }
 }