Sfoglia il codice sorgente

1.机器设备融资报告word文档生成开发(开发中),以及其他相关接口开发
2.新增Obj数据转Map工具类
3.新增阿拉伯数字转汉字工具类

GouGengquan 7 mesi fa
parent
commit
931a3e2973

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

@@ -13,6 +13,7 @@ import com.dayou.service.AssetsReportService;
 import com.dayou.entity.AssetsReport;
 import org.springframework.web.bind.annotation.*;
 
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -107,5 +108,15 @@ public class AssetsReportController {
         return Result.build(assetsReportService.getReportBaseInfo(reportId));
     }
 
+    /**
+     * 生成机器设备报告word文件
+     * @param reportId 报告id
+     * @return Boolean
+     */
+    @GetMapping("/generateEquipmentReport/{reportId}")
+    public Result<Boolean> generateEquipmentReport(@PathVariable Long reportId) throws Exception {
+        return Result.build(assetsReportService.generateEquipmentReport(reportId));
+    }
+
 }
 

+ 2 - 2
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);
+        mainDoc = AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, subDoc, bookmark, false, true);
         // 保存文件
         mainDoc.save("E:\\test\\word\\2_framework_output.doc");
     }
@@ -235,7 +235,7 @@ public class WordSimpleTests {
         // 需要插入的word文件
         Document subDoc = new Document("E:\\test\\word\\1730712433605.docx");
 
-        mainDoc = AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, subDoc, bookmark, false);
+        mainDoc = AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, subDoc, bookmark, false, true);
         // 保存文件
         mainDoc.save("E:\\test\\word\\createTable.docx");
     }

+ 99 - 0
common/src/main/java/com/dayou/utils/ArabicToChineseUtil.java

@@ -0,0 +1,99 @@
+package com.dayou.utils;
+
+import java.math.BigDecimal;
+
+public class ArabicToChineseUtil {
+
+    /**
+     * 中文数字
+     */
+    private static final String[] CN_NUM = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
+
+    /**
+     * 中文数字单位
+     */
+    private static final String[] CN_UNIT = {"", "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千"};
+
+    /**
+     * 特殊字符:负
+     */
+    private static final String CN_NEGATIVE = "负";
+
+    /**
+     * 特殊字符:点
+     */
+    private static final String CN_POINT = "点";
+
+
+    /**
+     * int 转 中文数字
+     * 支持到int最大值
+     *
+     * @param intNum 要转换的整型数
+     * @return 中文数字
+     */
+    public static String int2chineseNum(int intNum) {
+        StringBuffer sb = new StringBuffer();
+        boolean isNegative = false;
+        if (intNum < 0) {
+            isNegative = true;
+            intNum *= -1;
+        }
+        int count = 0;
+        while(intNum > 0) {
+            sb.insert(0, CN_NUM[intNum % 10] + CN_UNIT[count]);
+            intNum = intNum / 10;
+            count++;
+        }
+
+        if (isNegative)
+            sb.insert(0, CN_NEGATIVE);
+
+
+        return sb.toString().replaceAll("零[千百十]", "零").replaceAll("零+万", "万")
+                .replaceAll("零+亿", "亿").replaceAll("亿万", "亿零")
+                .replaceAll("零+", "零").replaceAll("零$", "");
+    }
+
+    /**
+     * bigDecimal 转 中文数字
+     * 整数部分只支持到int的最大值
+     *
+     * @param bigDecimalNum 要转换的BigDecimal数
+     * @return 中文数字
+     */
+    public static String bigDecimal2chineseNum(BigDecimal bigDecimalNum) {
+        if (bigDecimalNum == null)
+            return CN_NUM[0];
+
+        StringBuffer sb = new StringBuffer();
+
+        //将小数点后面的零给去除
+        String numStr = bigDecimalNum.abs().stripTrailingZeros().toPlainString();
+
+        String[] split = numStr.split("\\.");
+        String integerStr = int2chineseNum(Integer.parseInt(split[0]));
+
+        sb.append(integerStr);
+
+        //如果传入的数有小数,则进行切割,将整数与小数部分分离
+        if (split.length == 2) {
+            //有小数部分
+            sb.append(CN_POINT);
+            String decimalStr = split[1];
+            char[] chars = decimalStr.toCharArray();
+            for (int i = 0; i < chars.length; i++) {
+                int index = Integer.parseInt(String.valueOf(chars[i]));
+                sb.append(CN_NUM[index]);
+            }
+        }
+
+        //判断传入数字为正数还是负数
+        int signum = bigDecimalNum.signum();
+        if (signum == -1) {
+            sb.insert(0, CN_NEGATIVE);
+        }
+
+        return sb.toString();
+    }
+}

+ 44 - 3
common/src/main/java/com/dayou/utils/AsposeWordUtil.java

@@ -238,15 +238,56 @@ public class AsposeWordUtil {
     }
 
     /**
+     * @Description 向书签后插入文档
+     * @param mainDoc 主文档
+     * @param tobeInserted 拼接的文档
+     * @param isPortrait 纸张方向
+     * @param bookmark 书签
+     * @param writeln 插入时是否换行(段落分隔符)
+     */
+    public static Document insertDocumentAfterBookMark(Document mainDoc, Document tobeInserted, String bookmark, boolean isPortrait, boolean writeln)
+            throws Exception {
+        if (mainDoc == null) {
+            return null;
+        } else if (tobeInserted == null) {
+            return mainDoc;
+        } else {
+            //构建新文档
+            DocumentBuilder mainDocBuilder = new DocumentBuilder(mainDoc);
+            // 判断书签是否为空
+            if (bookmark != null && !bookmark.isEmpty()) { // 书签位置插入
+                //获取到书签
+                BookmarkCollection bms = mainDoc.getRange().getBookmarks();
+                Bookmark bm = bms.get(bookmark);
+                if (bm != null) {
+                    // 移动光标到书签
+                    mainDocBuilder.moveToBookmark(bookmark, true, false);
+                    // 在文档中插入段落分隔符
+                    if (writeln) {
+                        mainDocBuilder.writeln();
+                    }
+                    //获取到插入的位置
+                    Node insertAfterNode = mainDocBuilder.getCurrentParagraph().getPreviousSibling();
+
+                    insertDocumentAfterNode(insertAfterNode, mainDoc, tobeInserted);
+                }
+            } else { // 文档末尾拼接
+                appendDoc(mainDoc, tobeInserted, true);
+            }
+            return mainDoc;
+        }
+    }
+
+    /**
      * @Description 在指定节点后插入word文档
      * @param insertAfterNode 插入的位置
      * @param mainDoc 主word文件
      * @param srcDoc 引用的word文件
      */
     public static void insertDocumentAfterNode(Node insertAfterNode, Document mainDoc, Document srcDoc) throws Exception {
-        // Aspose定义的nodeType 8 和 5 指的是段落或者表格,插入word应该只能在这两个位置插入,具体没测试
-        if (insertAfterNode.getNodeType() != 8 & insertAfterNode.getNodeType() != 5) {
-            throw new Exception("The destination node should be either a paragraph or table.");
+        // Aspose定义的nodeType 8 和 5 指的是段落或者表格,插入word应该只能在这两个位置插入,具体没测试(官网案例只有8和5,我这里多加了10)
+        if (insertAfterNode.getNodeType() != 8 & insertAfterNode.getNodeType() != 5 & insertAfterNode.getNodeType() != 10) {
+            throw new Exception("The destination node should be either a paragraph or table. NodeType:" + insertAfterNode.getNodeType());
         } else {
             CompositeNode dstStory = insertAfterNode.getParentNode();
 

+ 56 - 0
common/src/main/java/com/dayou/utils/DataUtil.java

@@ -0,0 +1,56 @@
+package com.dayou.utils;
+
+import cn.hutool.core.util.ClassUtil;
+
+import java.beans.IntrospectionException;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class DataUtil {
+
+    /**
+     * 将Object对象类型的数据转为Map(支持嵌套对象的情况)
+     * @param objData 对象数据
+     * @return Map<String, Object>
+     * @throws IntrospectionException
+     * @throws InvocationTargetException
+     * @throws IllegalAccessException
+     */
+    public static Map<String, Object> objToMap(Object objData) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+        Class<?> aClass = objData.getClass();
+        java.lang.reflect.Field[] fields = aClass.getDeclaredFields();
+        Map<String, Object> data = new HashMap<>(fields.length);
+        // 循环对象中的属性
+        for (java.lang.reflect.Field field : fields) {
+            PropertyDescriptor pd = new PropertyDescriptor(field.getName(), aClass);
+            Method method = pd.getReadMethod();
+            String key = field.getName();
+            Object value = method.invoke(objData);
+            if (value != null) {
+                // 判断属性类型是否为基本类型(包括包装类和原始类)或集合(包括Collection和Map)以及其他类型等
+                // TODO:类型只判断了一部分,后面看情况补充
+                if (
+                        ClassUtil.isBasicType(field.getType()) ||
+                        String.class.isAssignableFrom(field.getType()) ||
+                        Collection.class.isAssignableFrom(field.getType()) ||
+                        Map.class.isAssignableFrom(field.getType()) ||
+                        BigDecimal.class.isAssignableFrom(field.getType()) ||
+                        Date.class.isAssignableFrom(field.getType())
+                ) {
+                    data.put(key, value);
+                }else {
+                    // 属性为对象继续转换
+                    data.putAll(objToMap(value));
+                }
+            }
+        }
+        return data;
+    }
+
+}

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

@@ -1,5 +1,6 @@
 package com.dayou.mapper;
 
+import com.dayou.bo.EqptReportFillBO;
 import com.dayou.dto.report.ReportBaseInfoDTO;
 import com.dayou.entity.AssetsReport;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -55,4 +56,11 @@ public interface AssetsReportMapper extends BaseMapper<AssetsReport> {
      */
     String getReportBaseInfo(@Param("reportId") Long reportId);
 
+    /**
+     * 根据报告id获取生成机器设备报告word文档所需信息
+     * @param reportId 报告id
+     * @return EqptReportFillBO
+     */
+    EqptReportFillBO geteqptReportFillBO(@Param("reportId") Long reportId);
+
 }

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

@@ -32,4 +32,11 @@ public interface TmplAssetReportMapper extends BaseMapper<TmplAssetReport> {
      */
     TmplAssetReportDetailVO getTmplAssetReportDetailById(@Param("templateReportId") Long templateReportId);
 
+    /**
+     * 根据模板code获取报告主模板
+     * @param tmplCode 模板code
+     * @return TmplAssetReport
+     */
+    TmplAssetReport getTmplByCode(@Param("tmplCode") String tmplCode);
+
 }

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

@@ -19,4 +19,11 @@ public interface TmplAssetReportSectionMapper extends BaseMapper<TmplAssetReport
      * @return Boolean
      */
     Boolean updateDeleteStatusByTRId(@Param("TRId") Long TRId);
+
+    /**
+     * 根据模板code获取报告段落模板
+     * @param tmplCode 模板code
+     * @return TmplAssetReportSection
+     */
+    TmplAssetReportSection getTmplByCode(@Param("tmplCode") String tmplCode);
 }

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

@@ -47,7 +47,7 @@
 
     <!--根据项目id获取未完成报告的进度信息-->
     <select id="getUnFinishedReportProgress" resultType="com.dayou.vo.report.AssetsReportProgressVO">
-        SELECT id, project_id, report_name, progress, calculate_id
+        SELECT id, project_id, report_name, progress, calculate_id, production_no
         FROM assets_report
         WHERE delete_status = 0
           AND progress != 'FINISHED'
@@ -78,4 +78,18 @@
         AND id = #{reportId}
     </select>
 
+    <!--根据报告id获取生成机器设备报告word文档所需信息-->
+    <select id="geteqptReportFillBO" resultType="com.dayou.bo.EqptReportFillBO">
+        SELECT production_no AS productionNo,
+               SUM(eqptData.book_original_value) AS bookOriginalValue,
+               SUM(eqptData.book_net_value) AS bookNetValue,
+               SUM(eqptData.evaluate_original_value) AS evaluateOriginalValue,
+               SUM(eqptData.evaluate_net_value) AS evaluateNetValue
+        FROM assets_report AS report
+        LEFT JOIN assets_calculate AS calculate ON calculate.id = report.calculate_id AND calculate.delete_status = 0
+        LEFT JOIN assets_calculate_eqpt_data AS eqptData ON eqptData.assets_calculate_id = calculate.id
+        WHERE report.delete_status = 0
+        AND report.id = #{reportId}
+    </select>
+
 </mapper>

+ 8 - 0
dao/src/main/resources/mapper/TmplAssetReportMapper.xml

@@ -42,4 +42,12 @@
           AND id = #{templateReportId}
     </select>
 
+    <!--根据模板code获取报告主模板-->
+    <select id="getTmplByCode" resultType="com.dayou.entity.TmplAssetReport">
+        SELECT id, report_name, file_name, file_url, report_type, report_sec_type, create_time, update_time, delete_status, has_section, tmpl_code
+        FROM tmpl_asset_report
+        WHERE delete_status = 0
+        AND tmpl_code = #{tmplCode}
+    </select>
+
 </mapper>

+ 8 - 0
dao/src/main/resources/mapper/TmplAssetReportSectionMapper.xml

@@ -32,4 +32,12 @@
           AND template_report_id = #{TRId}
     </update>
 
+    <!--根据模板code获取报告段落模板-->
+    <select id="getTmplByCode" resultType="com.dayou.entity.TmplAssetReportSection">
+        SELECT id, template_report_id, section_file_name, section_file_url, create_time, update_time, delete_status, section_name, tmpl_code
+        FROM tmpl_asset_report_section
+        WHERE delete_status = 0
+        AND tmpl_code = #{tmplCode}
+    </select>
+
 </mapper>

+ 10 - 0
domain/src/main/java/com/dayou/bo/EqptReportFillBO.java

@@ -43,6 +43,16 @@ public class EqptReportFillBO {
      */
     private String startWorkMonth;
 
+    /**
+     * 委托人拼接后的字符串(多个的情况)
+     */
+    private String consignorCompanyName;
+
+    /**
+     * 产权持有人拼接后的字符串(多个的情况)
+     */
+    private String ownerCompanyName;
+
     private EqptReportBaseInfoDTO eqptReportBaseInfo;
 
 }

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

@@ -94,6 +94,16 @@ public class EqptReportBaseInfoDTO {
     public static class ConsignorInfo {
 
         /**
+         * 序号
+         */
+        private Integer sort;
+
+        /**
+         * 序号(大写汉字)
+         */
+        private String sortUppercase;
+
+        /**
          * 公司名称
          */
         private String consignorCompanyName;

+ 13 - 0
domain/src/main/java/com/dayou/entity/AssetsCalculateEqptData.java

@@ -99,6 +99,19 @@ public class AssetsCalculateEqptData extends BaseEntity implements Serializable
     @ExcelProperty("账面净值")
     private Float bookNetValue;
 
+
+    /**
+     * 评估原值
+     */
+    @ExcelIgnore
+    private BigDecimal evaluateOriginalValue;
+
+    /**
+     * 评估净值
+     */
+    @ExcelIgnore
+    private BigDecimal evaluateNetValue;
+
     /**
      * 含税单价
      */

+ 4 - 0
domain/src/main/java/com/dayou/entity/AssetsReport.java

@@ -49,5 +49,9 @@ public class AssetsReport extends BaseEntity implements Serializable {
      */
     private Long calculateId;
 
+    /**
+     * 报告号(产品号)
+     */
+    private String productionNo;
 
 }

+ 4 - 0
domain/src/main/java/com/dayou/vo/report/AssetsReportProgressVO.java

@@ -33,4 +33,8 @@ public class AssetsReportProgressVO {
      */
     private Long calculateId;
 
+    /**
+     * 报告号(产品号)
+     */
+    private String productionNo;
 }

+ 9 - 0
service/src/main/java/com/dayou/service/AssetsReportService.java

@@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.dayou.vo.AssetsReportVO;
 import com.dayou.vo.report.AssetsReportProgressVO;
+import com.fasterxml.jackson.core.JsonProcessingException;
 
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -56,4 +58,11 @@ public interface AssetsReportService extends IService<AssetsReport> {
          */
         String getReportBaseInfo(Long reportId);
 
+        /**
+         * 生成机器设备报告word文件
+         * @param reportId 报告id
+         * @return Boolean
+         */
+        Boolean generateEquipmentReport(Long reportId) throws Exception;
+
 }

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

@@ -181,10 +181,10 @@ public class AssetsCalculateServiceImpl extends ServiceImpl<AssetsCalculateMappe
         // 生成后文件的位置
         String mainDetailPath = fileNetConfig.getBaseDir() + fileNetConfig.getAssetOutputCalculatePath() + System.currentTimeMillis() + "_MAIN_DETAIL.xlsx";
         // 模板文件的位置
-        String mainDetailTMplPath = fileNetConfig.getBaseDir() + mainDetail.getSectionFileUrl() + mainDetail.getSectionFileName();
+        String mainDetailTmplPath = fileNetConfig.getBaseDir() + mainDetail.getSectionFileUrl() + mainDetail.getSectionFileName();
         // 写入
         EasyExcel.write(mainDetailPath)
-                .withTemplate(mainDetailTMplPath)
+                .withTemplate(mainDetailTmplPath)
                 .sheet()
                 .doFill(dataService.getAllByAssetsCalculateId(calculateId, null));
 

+ 131 - 0
service/src/main/java/com/dayou/service/impl/AssetsReportServiceImpl.java

@@ -2,13 +2,27 @@ package com.dayou.service.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.util.ObjectUtil;
+import com.aspose.words.Document;
+import com.aspose.words.DocumentBuilder;
+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.TmplAssetReportSection;
+import com.dayou.enums.EqptReportTmplCode;
 import com.dayou.mapper.AssetsReportMapper;
+import com.dayou.mapper.TmplAssetReportSectionMapper;
 import com.dayou.service.AssetsReportService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dayou.utils.ArabicToChineseUtil;
+import com.dayou.utils.AsposeWordUtil;
+import com.dayou.utils.DataUtil;
 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;
@@ -19,11 +33,20 @@ 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.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+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.EqptReportTmplCode.*;
+
 /**
  * <p>
  * 资产项目报告信息表 服务实现类
@@ -38,6 +61,12 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
     @Autowired
     private AssetsReportMapper assetsReportMapper;
 
+    @Autowired
+    private TmplAssetReportSectionMapper reportSectionMapper;
+
+    @Autowired
+    private FileNetConfig fileNetConfig;
+
     /**
      * 根据项目id查询所有报告信息
      *
@@ -110,4 +139,106 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
     public String getReportBaseInfo(Long reportId) {
         return assetsReportMapper.getReportBaseInfo(reportId);
     }
+
+    /**
+     * 生成机器设备报告word文件
+     * @param reportId 报告id
+     * @return Boolean
+     */
+    @Override
+    public Boolean generateEquipmentReport(Long reportId) throws Exception {
+
+        // 获取基础报告信息
+        ObjectMapper objectMapper = new ObjectMapper();
+        EqptReportFillBO eqptReportFillBO = assetsReportMapper.geteqptReportFillBO(reportId);
+        // 设置增值率(评估净值 - 账面净值) / 账面净值,保留两位小数
+        eqptReportFillBO.setValueAddedRate(((eqptReportFillBO.getEvaluateNetValue().subtract(eqptReportFillBO.getBookNetValue())).divide(eqptReportFillBO.getBookNetValue(), 2, RoundingMode.HALF_UP)).doubleValue() * 100);
+        // 设置其他的信息
+        eqptReportFillBO.setEqptReportBaseInfo(objectMapper.readValue(getReportBaseInfo(reportId), EqptReportBaseInfoDTO.class));
+        // 设置委托人和产权持有人的名字
+        eqptReportFillBO.setConsignorCompanyName(eqptReportFillBO.getEqptReportBaseInfo().getConsignorInfos().stream() // 将集合转换为流
+                .map(EqptReportBaseInfoDTO.ConsignorInfo::getConsignorCompanyName) // 提取每个对象的consignorCompanyName属性
+                .collect(Collectors.joining("、")));
+        eqptReportFillBO.setOwnerCompanyName(eqptReportFillBO.getEqptReportBaseInfo().getPropertyOwnerInfos().stream() // 将集合转换为流
+                .map(EqptReportBaseInfoDTO.PropertyOwnerInfo::getOwnerCompanyName) // 提取每个对象的ownerCompanyName属性
+                .collect(Collectors.joining("、")));
+
+        // 第一步:设置封面
+        // 获取封面模板
+        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.fillWordDataByDomain(coverTmplByte, eqptReportFillBO);
+
+        // 处理该二进制文件并保存
+        File resultFile = new File(coverPath);
+        FileOutputStream fos = new FileOutputStream(resultFile);
+        fos.write(resultCoverByte);
+        fos.close();
+
+        // 第二步:设置正文内容
+        // 获取正文
+        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[] mainTmplByte = Files.readAllBytes(Paths.get(detailTmplPath));
+        // 获取填充数据后的文件
+        byte[] resultMainByte = AsposeWordUtil.fillWordDataByMap(mainTmplByte, DataUtil.objToMap(eqptReportFillBO));
+
+        // 处理该二进制文件并保存
+        File detailFile = new File(detailPath);
+        FileOutputStream detailOs = new FileOutputStream(detailFile);
+        detailOs.write(resultMainByte);
+        detailOs.close();
+
+        // 第三步:设置委托人概况
+        // 获取委托人概况模板
+        TmplAssetReportSection consignorTmpl = reportSectionMapper.getTmplByCode(CONSIGNOR.getCode());
+        // 委托人概况生成后文件位置
+        String consignorPath = fileNetConfig.getBaseDir() + fileNetConfig.getAssetOutputReportPath() + System.currentTimeMillis() + "_CONSIGNOR.docx";
+        // 委托人概况模板文件位置
+        String consignorTmplPath = fileNetConfig.getBaseDir() + consignorTmpl.getSectionFileUrl() + consignorTmpl.getSectionFileName();
+
+        Document detailDoc = new Document(detailPath);
+        for (int i = 0; i < eqptReportFillBO.getEqptReportBaseInfo().getConsignorInfos().size() ; i++) {
+            EqptReportBaseInfoDTO.ConsignorInfo consignorInfo = eqptReportFillBO.getEqptReportBaseInfo().getConsignorInfos().get(i);
+            consignorInfo.setSort(i + 1);
+            consignorInfo.setSortUppercase(ArabicToChineseUtil.int2chineseNum(i + 1));
+            // 读取模板文件
+            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);
+        }
+
+        DocumentBuilder builder = new DocumentBuilder(detailDoc);
+
+        builder.moveToBookmark("insertConsignor");
+
+        // 获取当前光标所在的段落
+        Paragraph currentParagraph = builder.getCurrentParagraph();
+
+        currentParagraph.remove();
+
+        detailDoc.save(detailPath);
+
+        return null;
+    }
 }

+ 8 - 0
sql/update_sql.sql

@@ -603,3 +603,11 @@ ALTER TABLE tmpl_asset_report_section ADD COLUMN tmpl_code VARCHAR(50) NOT NULL
  */
 ALTER TABLE assets_report ADD COLUMN calculate_id BIGINT(20) NULL COMMENT '关联的测算表id';
 
+/**
+  日期:2024-12-09
+  修改人:苟耕铨
+  未更新到test-env
+ */
+ALTER TABLE assets_report ADD COLUMN production_no VARCHAR(255) NULL COMMENT '报告号(产品号)';
+ALTER TABLE assets_calculate_eqpt_data ADD COLUMN evaluate_original_value DECIMAL(11,2) NULL COMMENT '评估原值';
+ALTER TABLE assets_calculate_eqpt_data ADD COLUMN evaluate_net_value DECIMAL(11,2) NULL COMMENT '评估净值';