fei
22 小时以前 af47b774448bfa3ece4741664ce4d24128c8f629
新增了代码
3个文件已添加
10个文件已修改
1423 ■■■■ 已修改文件
archiveManager/src/main/java/com/ruoyi/domain/DocumentMaterials.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialFileStyle.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVoLarge.java 330 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/mapper/ArchiveRecordsMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/service/IDocumentMaterialsService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/service/impl/pdfGenerateService.java 423 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java 309 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/annotation/NumberFormatHandler.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelExp.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java 229 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/domain/DocumentMaterials.java
@@ -7,6 +7,7 @@
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.NumberFormatHandler;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
@@ -25,7 +26,7 @@
    /** $column.columnComment */
    @TableId(type = IdType.AUTO)
    private Long materialId;
    @Excel(name = "文件材料序号")
    @Excel(name = "文件材料序号", handler = NumberFormatHandler.class)
    private Long fileNumber;
@@ -56,7 +57,7 @@
    private Date date;
    /** $column.columnComment */
    @Excel(name = "页号")
    @Excel(name = "页号", handler = NumberFormatHandler.class)
    private Long pageNumber;
    /** $column.columnComment */
@@ -72,11 +73,11 @@
    private String publicity;
    /** $column.columnComment */
    @Excel(name = "是否为附件")
    @Excel(name = "是否为附件附图")
    private String isAttachment;
    /** $column.columnComment */
    @Excel(name = "是否为附图")
//    @Excel(name = "是否为附图")
    private String isDiagram;
    /** $column.columnComment */
archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialFileStyle.java
New file
@@ -0,0 +1,14 @@
package com.ruoyi.domain.vo;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;
@Data
public class DocumentMaterialFileStyle {
    /** 档案号 */
//    @Excel(name = "档案号")
    private int cnt;
    /** 档案管(室)号 */
//    @Excel(name = "档案管(室)号")
    private String fileStyle;
}
archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVoLarge.java
New file
@@ -0,0 +1,330 @@
package com.ruoyi.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.NumberFormatHandler;
import lombok.Data;
import java.util.Date;
@Data
public class DocumentMaterialsVoLarge {
    public int getNum() {
        return num;
    }
    public void setNum(int num) {
        this.num = num;
    }
    public String getRecordId() {
        return recordId;
    }
    public void setRecordId(String recordId) {
        this.recordId = recordId;
    }
    public Long getFileNumber() {
        return fileNumber;
    }
    public void setFileNumber(Long fileNumber) {
        this.fileNumber = fileNumber;
    }
    public String getCreator() {
        return creator;
    }
    public void setCreator(String creator) {
        this.creator = creator;
    }
    public String getDocumentNumber() {
        return documentNumber;
    }
    public void setDocumentNumber(String documentNumber) {
        this.documentNumber = documentNumber;
    }
    public String getRemarks() {
        return remarks;
    }
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }
    public String getAttachmentHistoryNumbers() {
        return attachmentHistoryNumbers;
    }
    public void setAttachmentHistoryNumbers(String attachmentHistoryNumbers) {
        this.attachmentHistoryNumbers = attachmentHistoryNumbers;
    }
    public Double getFileSize() {
        return fileSize;
    }
    public void setFileSize(Double fileSize) {
        this.fileSize = fileSize;
    }
    public Long getHeight() {
        return height;
    }
    public void setHeight(Long height) {
        this.height = height;
    }
    public Long getWidth() {
        return width;
    }
    public void setWidth(Long width) {
        this.width = width;
    }
    public Long getVerticalResolution() {
        return verticalResolution;
    }
    public void setVerticalResolution(Long verticalResolution) {
        this.verticalResolution = verticalResolution;
    }
    public Long getHorizontalResolution() {
        return horizontalResolution;
    }
    public void setHorizontalResolution(Long horizontalResolution) {
        this.horizontalResolution = horizontalResolution;
    }
    public String getSizeType() {
        return sizeType;
    }
    public void setSizeType(String sizeType) {
        this.sizeType = sizeType;
    }
    public String getFormat() {
        return format;
    }
    public void setFormat(String format) {
        this.format = format;
    }
    public String getIsCanceled() {
        return isCanceled;
    }
    public void setIsCanceled(String isCanceled) {
        this.isCanceled = isCanceled;
    }
    public String getIsSensitive() {
        return isSensitive;
    }
    public void setIsSensitive(String isSensitive) {
        this.isSensitive = isSensitive;
    }
    public String getSecurityLevel() {
        return securityLevel;
    }
    public void setSecurityLevel(String securityLevel) {
        this.securityLevel = securityLevel;
    }
    public String getRetentionPeriod() {
        return retentionPeriod;
    }
    public void setRetentionPeriod(String retentionPeriod) {
        this.retentionPeriod = retentionPeriod;
    }
    public String getIsDiagram() {
        return isDiagram;
    }
    public void setIsDiagram(String isDiagram) {
        this.isDiagram = isDiagram;
    }
    public String getIsAttachment() {
        return isAttachment;
    }
    public void setIsAttachment(String isAttachment) {
        this.isAttachment = isAttachment;
    }
    public String getPublicity() {
        return publicity;
    }
    public void setPublicity(String publicity) {
        this.publicity = publicity;
    }
    public String getStage() {
        return stage;
    }
    public void setStage(String stage) {
        this.stage = stage;
    }
    public Long getPageOrder() {
        return pageOrder;
    }
    public void setPageOrder(Long pageOrder) {
        this.pageOrder = pageOrder;
    }
    public Long getPageNumber() {
        return pageNumber;
    }
    public void setPageNumber(Long pageNumber) {
        this.pageNumber = pageNumber;
    }
    public Date getDate() {
        return date;
    }
    public void setDate(Date date) {
        this.date = date;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    @Excel(name="序号")
    private int num;
    @Excel(name="档号")
    private String recordId;
    @Excel(name = "文件材料序号", handler = NumberFormatHandler.class)
    private Long fileNumber;
    @Excel(name = "文件编号")
    private String documentNumber;
    /** $column.columnComment */
    @Excel(name = "编任者")
    private String creator;
    /** $column.columnComment */
    @Excel(name = "文件题名")
    private String title;
    /** $column.columnComment */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date date;
    /** $column.columnComment */
    @Excel(name = "页号", handler = NumberFormatHandler.class)
    private Long pageNumber;
    /** $column.columnComment */
    @Excel(name = "页次")
    private Long pageOrder;
    /** $column.columnComment */
    @Excel(name = "所处阶段")
    private String stage;
    /** $column.columnComment */
    @Excel(name = "公开属性")
    private String publicity;
    /** $column.columnComment */
    @Excel(name = "是否为附件附图")
    private String isAttachment;
    /** $column.columnComment */
//    @Excel(name = "是否为附图")
    private String isDiagram;
    /** $column.columnComment */
    @Excel(name = "保管期限")
    private String retentionPeriod;
    /** $column.columnComment */
    @Excel(name = "密级")
    private String securityLevel;
    /** $column.columnComment */
    @Excel(name = "是否涉密及敏感信息")
    private String isSensitive;
    /** $column.columnComment */
    @Excel(name = "是否注销")
    private String isCanceled;
    /** $column.columnComment */
    @Excel(name = "格式")
    private String format;
    /** $column.columnComment */
    @Excel(name = "幅面")
    private String sizeType;
    /** $column.columnComment */
    @Excel(name = "水平分辨率")
    private Long horizontalResolution;
    /** $column.columnComment */
    @Excel(name = "垂直分辨率")
    private Long verticalResolution;
    /** $column.columnComment */
    @Excel(name = "宽度")
    private Long width;
    /** $column.columnComment */
    @Excel(name = "高度")
    private Long height;
    /** $column.columnComment */
    @Excel(name = "大小")
    private Double fileSize;
    /** $column.columnComment */
    @Excel(name = "附件及历史发文号")
    private String attachmentHistoryNumbers;
    /** $column.columnComment */
    @Excel(name = "备注")
    private String remarks;
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    private String url;
}
archiveManager/src/main/java/com/ruoyi/mapper/ArchiveRecordsMapper.java
@@ -19,7 +19,7 @@
    @Select({
            "<script>",
            "SELECT c.*,a.archive_records_id,b.user_id, if(a.user_id=#{userId}, TRUE, FALSE) as tst FROM archiverecordstouser a inner join sys_user b ON a.user_id = b.user_id right join archive_records c on c.record_id=a.archive_records_id ${ew.customSqlSegment} ",
            "SELECT distinct c.*,a.archive_records_id,b.user_id, if(a.user_id=#{userId}, TRUE, FALSE) as tst FROM archiverecordstouser a inner join sys_user b ON a.user_id = b.user_id right join archive_records c on c.record_id=a.archive_records_id ${ew.customSqlSegment} ",
            "<if test= \"userId !=1 \">",
            "order by tst desc",
            "</if>",
archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java
@@ -2,7 +2,9 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.domain.DocumentMaterials;
import com.ruoyi.domain.vo.DocumentMaterialFileStyle;
import com.ruoyi.domain.vo.DocumentMaterialsVo;
import com.ruoyi.domain.vo.DocumentMaterialsVoLarge;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@@ -12,8 +14,8 @@
@Mapper
public interface DocumentMaterialsMapper extends BaseMapper<DocumentMaterials> {
    @Select("update document_materials SET url = #{url},file_number=#{fileNumber},page_order=#{pageOrder},width=#{width},height=#{height},horizontal_resolution=#{horizontalResolution},vertical_resolution=#{verticalResolution},file_size=#{fileSize}, format=#{format} where page_number = #{pageNumber}")
    Long updateInfoByPageNumber(@Param("pageNumber") Long pageNumber,@Param("fileNumber") Long fileNumber,@Param("pageOrder") Long pageOrder,@Param("width") int width, @Param("height") int height,  @Param("horizontalResolution") int horizontalResolution, @Param("verticalResolution") int verticalResolution, @Param("fileSize") Double fileSize,@Param("url")  String url,@Param("format")  String format);
    @Select("update document_materials SET url = #{url},size_type=#{sizeType}, file_number=#{fileNumber},page_order=#{pageOrder},width=#{width},height=#{height},horizontal_resolution=#{horizontalResolution},vertical_resolution=#{verticalResolution},file_size=#{fileSize}, format=#{format} where page_number = #{pageNumber}")
    Long updateInfoByPageNumber(@Param("pageNumber") Long pageNumber,@Param("sizeType") String sizeType, @Param("fileNumber") Long fileNumber,@Param("pageOrder") Long pageOrder,@Param("width") int width, @Param("height") int height,  @Param("horizontalResolution") int horizontalResolution, @Param("verticalResolution") int verticalResolution, @Param("fileSize") Double fileSize,@Param("url")  String url,@Param("format")  String format);
    //根据题名拿到最大的pageOrder
@@ -32,4 +34,19 @@
            "            FROM document_materials where record_id=#{recordId}\n" +
            "             GROUP BY stage, title) and ar.id =#{recordId} order by page_number ;")
    List<DocumentMaterialsVo> getArchiveMatInfo(@Param("recordId") int recordId);
    @Select(  "select ROW_NUMBER() OVER (ORDER BY page_number) AS num,ar.record_id, file_number, \n" +
            "            document_number, creator, title, date, page_number, page_order, \n" +
            "            stage, publicity, is_attachment, dm.retention_period, security_level, is_sensitive,\n" +
            "            is_canceled, format, size_type, horizontal_resolution, vertical_resolution, width,\n" +
            "            height, file_size, attachment_history_numbers,url, dm.remarks\n" +
            "            from document_materials as dm, archive_records as ar WHERE dm.record_id=ar.id \n" +
            "and dm.record_id=#{recordId}")
    List<DocumentMaterialsVoLarge> getDocumentMaterialsvoLarge(@Param("recordId") int recordId);
    @Select("select count(*) as cnt, file_style from document_materials " +
            "where record_id=#{recordId} GROUP BY file_style")
    List<DocumentMaterialFileStyle> getFileStyleInfo(@Param("recordId") int recordId);
}
archiveManager/src/main/java/com/ruoyi/service/IDocumentMaterialsService.java
@@ -3,7 +3,9 @@
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.domain.Archiverecordstouser;
import com.ruoyi.domain.DocumentMaterials;
import com.ruoyi.domain.vo.DocumentMaterialFileStyle;
import com.ruoyi.domain.vo.DocumentMaterialsVo;
import com.ruoyi.domain.vo.DocumentMaterialsVoLarge;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -26,6 +28,9 @@
     * @return 【请填写功能名称】集合
     */
    public List<DocumentMaterials> selectDocumentMaterialsList(DocumentMaterials documentMaterials);
    public List<DocumentMaterialsVoLarge> selectDocumentMaterialsAllByRecordId(Long id);
    /**
     * 新增【请填写功能名称】
@@ -59,6 +64,9 @@
     */
    public int deleteDocumentMaterialsByMaterialId(String materialId);
    public Long getFiNum(Long pageNumber);
    public int updateByPageNumber(Long pageNumber,Long fileNumber, int wid, int hei, int wdpi, int hdpi, double sz,String url,String format);
    public int updateByPageNumber(Long pageNumber,String sizeType, Long fileNumber, int wid, int hei, int wdpi, int hdpi, double sz,String url,String format);
    public List<DocumentMaterialsVo> findArchMInfo(String recordId);
    public List<DocumentMaterialFileStyle> findFileStyleInfo(@Param("recordId") int recordId);
}
archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java
@@ -5,15 +5,13 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.MapUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.ArchiveRecords;
import com.ruoyi.domain.Archiverecordstouser;
import com.ruoyi.domain.DocumentMaterials;
import com.ruoyi.domain.vo.DocumentMaterialFileStyle;
import com.ruoyi.domain.vo.DocumentMaterialsVo;
import com.ruoyi.domain.vo.DocumentMaterialsVoLarge;
import com.ruoyi.mapper.DocumentMaterialsMapper;
import com.ruoyi.service.IArchiveCategoryService;
import com.ruoyi.service.IDocumentMaterialsService;
import com.ruoyi.util.ErrorcodeExceptionextends;
import org.springframework.stereotype.Service;
@@ -104,6 +102,12 @@
    }
    @Override
    public List<DocumentMaterialsVoLarge> selectDocumentMaterialsAllByRecordId(Long id) {
        return this.baseMapper.getDocumentMaterialsvoLarge(Math.toIntExact(id));
    }
    @Override
    public int insertDocumentMaterials(DocumentMaterials documentMaterials) {
        LocalDateTime time = LocalDateTime.now();
@@ -159,7 +163,7 @@
    }
    @Override
    public int updateByPageNumber(Long pageNumber, Long fileNumber, int width, int height, int horizontalResolution, int verticalResolution, double fileSize, String url, String format) {
    public int updateByPageNumber(Long pageNumber, String sizeType, Long fileNumber, int width, int height, int horizontalResolution, int verticalResolution, double fileSize, String url, String format) {
        //根据pageNumber拿到title,然后计算pageOrder
        LambdaQueryWrapper<DocumentMaterials> lqw = new LambdaQueryWrapper<>();
        lqw.eq(pageNumber!=null, DocumentMaterials::getPageNumber, pageNumber);
@@ -174,7 +178,7 @@
                pageOrder = maxPOrder + 1;
        }
        this.baseMapper.updateInfoByPageNumber(pageNumber, fileNumber,pageOrder, width, height, horizontalResolution, verticalResolution, fileSize, url,format);
        this.baseMapper.updateInfoByPageNumber(pageNumber, sizeType,fileNumber,pageOrder, width, height, horizontalResolution, verticalResolution, fileSize, url,format);
        return 0;
    }
@@ -183,4 +187,9 @@
    public List<DocumentMaterialsVo> findArchMInfo(String recordId) {
        return this.baseMapper.getArchiveMatInfo(Integer.parseInt(recordId));
    }
    @Override
    public List<DocumentMaterialFileStyle> findFileStyleInfo(int recordId) {
        return this.baseMapper.getFileStyleInfo(recordId);
    }
}
archiveManager/src/main/java/com/ruoyi/service/impl/pdfGenerateService.java
@@ -11,18 +11,31 @@
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.domain.vo.DocumentMaterialFileStyle;
import com.ruoyi.domain.vo.DocumentMaterialsVo;
import com.ruoyi.domain.vo.DocumentMaterialsVoSmall;
import com.ruoyi.service.IDocumentMaterialsService;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.*;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.List;
@Service
public class pdfGenerateService {
    @Autowired
    private BarcodeService barcodeService;
    @Autowired
    private IDocumentMaterialsService documentMaterialsService;
    //生产二维码
    public byte[] createQrCodeN(String content, int width, int height) throws IOException {
        QrConfig config = new QrConfig(width, height);
@@ -50,7 +63,417 @@
        return os.toByteArray();
    }
    private void handleXSSFImages(XSSFSheet sheet, Document pdfDoc) throws Exception {
        XSSFDrawing drawing = sheet.getDrawingPatriarch();
        if (drawing == null) return;
        for (XSSFShape shape : drawing.getShapes()) {
            if (shape instanceof XSSFPicture) {
                XSSFPicture pic = (XSSFPicture)shape;
                XSSFClientAnchor anchor = pic.getPreferredSize();
                // 获取图片数据
                byte[] bytes = pic.getPictureData().getData();
                Image pdfImage = Image.getInstance(bytes);
                // 设置图片位置和大小
                float imageWidth = pdfImage.getWidth();
                float imageHeight = pdfImage.getHeight();
                float scale = Math.min(
                        (PageSize.A4.getWidth() - 100) / imageWidth,
                        (PageSize.A4.getHeight() - 100) / imageHeight
                );
                pdfImage.scaleAbsolute(imageWidth * scale, imageHeight * scale);
                // 添加图片到PDF
                pdfDoc.add(pdfImage);
                pdfDoc.add(Chunk.NEWLINE);
            }
        }
    }
    private static String getCellValue(Cell cell,FormulaEvaluator evaluator) {
        //  System.out.println(cell);
        if (cell == null) return "";
        CellValue cellValue = evaluator.evaluate(cell);
        if(cellValue==null)
            return "";
        //  System.out.println(cellValue.getCellType());
        switch (cellValue.getCellType()) {
            case STRING:
                return cell.getStringCellValue();
            case NUMERIC:
                // 获取数值并转为整型
                double numericValue = cell.getNumericCellValue();
                // 判断是否为整数
                if (numericValue == (int)numericValue) {
                    if((int)numericValue==0)
                        return "";
                    else
                        return String.valueOf((int)numericValue);
                } else {
                    return String.valueOf(numericValue); // 或者根据需要返回四舍五入的整型
                }
            case BOOLEAN:
                return String.valueOf(cell.getBooleanCellValue());
            case FORMULA:
                return cell.getCellFormula()+"";
            case BLANK:
                return "";
            default:
                return "";
        }
    }
    private int getRealLastCellNum(Row row) {
        int lastCellNum = 0;
        for (int i = 0; i < row.getLastCellNum(); i++) {
            Cell cell = row.getCell(i);
            if (cell != null && cell.getCellType() != CellType.BLANK) {
                lastCellNum = i + 1;
            }
        }
        return lastCellNum;
    }
    //
    void generateSimpleExample()
    {
//        try {
//            // 1. 读取Excel文件
//            String excelPath = RuoYiConfig.getProfile() + "/download/"+"卷內目录.xls";
//            String pdfPath = RuoYiConfig.getProfile() + "/download/"+"1.pdf";
//
//            Workbook workbook = WorkbookFactory.create(new File(excelPath));
//            FileOutputStream fos = new FileOutputStream(pdfPath);
//            FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
//
//
//            // 获取第一个工作表
//            Sheet sheet = workbook.getSheetAt(1);
//
//            // 创建PDF文档对象
//            Document document = new Document(PageSize.A2, 50, 50, 50, 50);
//
//            // 创建PDF输出流
//            PdfWriter writer = PdfWriter.getInstance(document, fos);
//            // 4. 处理工作表中的图片
//            if (workbook instanceof XSSFWorkbook) {
//                handleXSSFImages((XSSFSheet)sheet, document);
//            }
//            // 打开PDF文档
//            document.open();
//
//            // 创建PDF表格对象
//            System.out.println(sheet.getRow(0).getLastCellNum()+"--00");
//            PdfPTable table = new PdfPTable(sheet.getRow(0).getLastCellNum());
//            table.setHeaderRows(1);
//
//            // 设置表格宽度
//            table.setWidthPercentage(100);
//
//            // 设置表格标题
//            Paragraph title = new Paragraph(sheet.getSheetName(), new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 16, Font.BOLD));
//            title.setAlignment(Element.ALIGN_CENTER);
//            document.add(title);
//            // System.out.println(sheet.)
//            // 添加表格内容
//            for (Row row : sheet) {
//                {
//                    if (row == null) continue;
//                    System.out.println(getRealLastCellNum(row)+"---987");
////                            if(row.getRowNum()==0)
////                                continue;
//                    if(row.getRowNum()==2)
//                    {
//                        PdfPCell pdfCell = ImageSet(100);
//                        pdfCell.setColspan(7);
//                        pdfCell.setRowspan(3);
//                        pdfCell.setBorderWidth(1f);
//                        pdfCell.setBorderColor(BaseColor.BLACK);
//                        pdfCell.setPadding(5f);
//                        pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
//                        pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
//                        table.addCell(pdfCell);
//                        System.out.println("{{{{{{{{{{{{{");
//                        continue;
//                    }
//                    for (int i = 0; i < 7; i++)
//                    {
//
//                        Cell cell = row.getCell(i);
//                        if(row.getRowNum()==3)
//                        {
//                            PdfPCell pdfCell = new PdfPCell(new Paragraph("卷内目录", new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 12)));
//                            pdfCell.setColspan(7);
//                            pdfCell.setBorderWidth(1f);
//                            pdfCell.setBorderColor(BaseColor.BLACK);
//                            pdfCell.setPadding(5f);
//                            pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
//                            pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
//                            table.addCell(pdfCell);
//                            System.out.println("{{{{{{{{{{{{{");
//                            break;
//                        }
//                        if(cell==null) {
//
//                            table.addCell("");
//                            continue;
//                        }
//                        PdfPCell pdfCell = new PdfPCell(new Paragraph(getCellValue(cell, evaluator), new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 12)));
//
//                        if(row.getRowNum()!=1) {
//                            pdfCell.setBorderWidth(1f);
//                            pdfCell.setBorderColor(BaseColor.BLACK);
//                            pdfCell.setPadding(5f);
//                            pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
//                            pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
//                        }
//                        if (cell.getRowIndex() == 5) {
//                            pdfCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
//                        }
//
//                        table.addCell(pdfCell);
//
//                    }
//                }
//            }
//
//            // 添加表格到PDF文档
//            table.setSpacingBefore(20f);
//            table.setSpacingAfter(20f);
//            table.setKeepTogether(true);
//            document.add(table);
//
//            // 关闭PDF文档
//            document.close();
//
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
    }
    //导出卷内目录的pdf
    public void generateFileDirectoryPdf(String pdfPath,List<DocumentMaterialsVo> dvss) throws DocumentException, IOException {
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(pdfPath));
        document.open();
        // 创建表格(5列)
        PdfPTable table = new PdfPTable(7);
        // 设置表格宽度(占页面宽度的100%)
        table.setWidthPercentage(100);
        //添加条形码
        String volumeNumber = dvss.get(0).getRecordId();
        Image img = Image.getInstance(barcodeService.generateBarcodeImage(volumeNumber));
        // 设置图片在PDF中的位置(可选)
//        img.setAbsolutePosition(100, 100);
        // 将图片添加到PDF文档中
        PdfPCell pdfPCell = new PdfPCell(img);
        pdfPCell.setBorder(Rectangle.NO_BORDER); // 移除单元格边框
        pdfPCell.setMinimumHeight(40);
        pdfPCell.setUseAscender(true); // 设置可以居中
        pdfPCell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); // 设置水平居中
        pdfPCell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); // 设置垂直居中
        pdfPCell.setColspan(2);
        pdfPCell.setPaddingBottom(30);
// 创建表格并设置列宽比例
        float[] columnWidths = {35f, 65f}; // 第一列30%,第二列70%
        PdfPTable table1 = new PdfPTable(columnWidths);
//        PdfPTable table = new PdfPTable(2);
        table1.setWidthPercentage(80); // 增大表格宽度百分比
        table1.setHorizontalAlignment(Element.ALIGN_LEFT); // 设置表格整体居中
        table1.setSpacingBefore(30f); // 设置表格前间距
        table1.addCell(pdfPCell);
        document.add(table1);
        // 添加表头
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        Font chineseFont = new Font(bfChinese, 12);
        Font chineseFont1 = new Font(bfChinese, 16, Font.BOLD);
        // 添加标题
        Paragraph title = new Paragraph("卷    内    目    录", chineseFont1);
        title.setAlignment(Element.ALIGN_CENTER);
        document.add(title);
        Paragraph withNewLine = new Paragraph("\n");
        document.add(withNewLine);
        document.add(withNewLine);
        //添加卷号
        Paragraph recordInfo = new Paragraph("卷号:" + volumeNumber, chineseFont);
        recordInfo.setAlignment(Element.ALIGN_RIGHT);
        document.add(recordInfo);
        document.add(withNewLine);
        document.add(withNewLine);
        String[] headers = {"序号", "文件编号", "责任者", "文件题名", "日期", "页号", "备注"};
        for (String header : headers) {
            PdfPCell cell = new PdfPCell(new Paragraph(header,
                    chineseFont1));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBackgroundColor(new BaseColor(200, 200, 200));
            table.addCell(cell);
        }
        // 添加表格数据
//        Object[][] data = {
//              //  {1, "商品A", 2, 100.00, 200.00},
//             //   {2, "商品B", 1, 250.50, 250.50},
//             //   {3, "商品C", 3, 80.00, 240.00}
//        };
//        data.
      //  for (Object[] row : data) {
            for (DocumentMaterialsVo cellData : dvss) {
                //序号
                PdfPCell cell = new PdfPCell(new Paragraph(cellData.getNum().toString(),
                        chineseFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                table.addCell(cell);
                //序号
                PdfPCell cell1 = new PdfPCell(new Paragraph(cellData.getDocumentNumber()==null?"":cellData.getDocumentNumber().toString(),
                        chineseFont));
                cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
                table.addCell(cell1);
                //序号
                PdfPCell cell2 = new PdfPCell(new Paragraph(cellData.getCreator()==null?"":cellData.getCreator().toString(),
                        chineseFont));
                cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                table.addCell(cell2);
                //序号
                PdfPCell cell3 = new PdfPCell(new Paragraph(cellData.getTitle()==null?"":cellData.getTitle().toString(),
                        chineseFont));
                cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cell3);
                //序号
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
               // String dateString = sdf.format(date);
                PdfPCell cell4 = new PdfPCell(new Paragraph(cellData.getDate()==null?"":sdf.format(cellData.getDate()),
                        chineseFont));
                cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cell4);
                //序号
                PdfPCell cell5 = new PdfPCell(new Paragraph(cellData.getPageNumber()==null?"": cellData.getPageNumber().toString(),
                        chineseFont));
                cell5.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);
                table.addCell(cell5);
                //序号
                PdfPCell cell6 = new PdfPCell(new Paragraph(cellData.getRemarks()==null?"":cellData.getRemarks().toString(),
                        chineseFont));
                cell6.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell6.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(cell6);
            }
      //  }
        document.add(table);
        document.close();
    }
    //设置备考表
   public void generateFileStyleInfo(String pdfPath, String volumeNumber, Long id) throws IOException, DocumentException {
       Document document = new Document();
       PdfWriter.getInstance(document, new FileOutputStream(pdfPath));
       document.open();
// 创建PDF文档
       List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id));
       PdfWriter.getInstance(document, new FileOutputStream("09-备考表"+".pdf"));
       document.open();
       // 设置中文字体
       BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
       Font chineseFont = new Font(bfChinese, 16, Font.BOLD);
       // 添加标题
       Paragraph title = new Paragraph("卷内备考表", chineseFont);
       title.setAlignment(Element.ALIGN_CENTER);
       document.add(title);
       // 添加内容
     //  String volumeNumber = "D3.4.1-05-2024-0002";
       Paragraph recordInfo = new Paragraph("卷号:" + volumeNumber, chineseFont);
       recordInfo.setAlignment(Element.ALIGN_RIGHT);
       document.add(recordInfo);
       int allCnt = dmfs.get(0).getCnt() + dmfs.get(1).getCnt() + dmfs.get(2).getCnt();
       document.add(new Paragraph("          本 案 卷 共 有 文 件 材 料 " + allCnt + " 页"+",其中:文字材料 " +
               dmfs.get(1).getCnt() + " 页"+",图样材料 " + dmfs.get(2).getCnt() + " 页"+",照片 " + dmfs.get(0).getCnt() + " 张", chineseFont));
       document.add(new Paragraph("说明: ", chineseFont));
       // 方法2:使用带换行符的Paragraph
       for(int i = 0; i < 10; i++) {
           Paragraph withNewLine = new Paragraph("\n");
           document.add(withNewLine);
       }
       String tis1 = "立卷人:仇翀(广州盈家档案管理有限公司)";
       Paragraph par1 = new Paragraph(tis1, chineseFont);
       par1.setAlignment(Element.ALIGN_RIGHT);
       document.add(par1);
       //拿到当前时间
       // 获取当前日期
       LocalDate currentDate = LocalDate.now();
       // 打印年、月、日
//       System.out.println("Year: " + currentDate.getYear());
//       System.out.println("Month: " + currentDate.getMonthValue()); // 月份是从1开始的
//       System.out.println("Day of Month: " + currentDate.getDayOfMonth());
       Paragraph withNewLine = new Paragraph("\n");
       document.add(withNewLine);
       String cdt = currentDate.getYear()+"年"+currentDate.getMonthValue()+"月"+currentDate.getDayOfMonth()+"日";
       Paragraph par3 = new Paragraph(cdt, chineseFont);
       par3.setAlignment(Element.ALIGN_RIGHT);
       document.add(par3);
       String tis2 = "审核人:曾瑞莹(广州盈家档案管理有限公司)";
       document.add(withNewLine);
       Paragraph par2 = new Paragraph(tis2, chineseFont);
       par2.setAlignment(Element.ALIGN_RIGHT);
       document.add(par2);
       document.add(withNewLine);
       document.add(par3);
       document.close();
   }
    public void generatePdf(String pdfPath) throws IOException, DocumentException {
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java
@@ -133,6 +133,19 @@
        return toAjax(documentMaterialsService.deleteDocumentMaterialsByMaterialIds(materialIds));
    }
    public String getPageSize(double du)
    {
        if(du <= 8699840)
            return "A4";
        else if(du <= 17403188)
            return "A3";
        else if(du <= 34811347)
            return "A2";
        else if(du <= 69622674)
            return "A1";
        else
            return "A0";
    }
    @PostMapping("/upload")
    public AjaxResult uploadFile(MultipartFile file) throws Exception
@@ -173,8 +186,10 @@
            System.out.println("DPI: " + info.getPhysicalWidthDpi());
            //计算fileNumber
            Long fileNumber = documentMaterialsService.getFiNum(nam);
            //计算sizeType
            String sizeType = getPageSize(wid*hei);
            //插入数据库对应的url当中
            documentMaterialsService.updateByPageNumber(nam, fileNumber,wid, hei,wdpi, hdpi,  sz, fileName, pname);
            documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber,wid, hei,wdpi, hdpi,  sz, fileName, pname);
//            System.out.println(url);
//            System.out.println(fileName);
            ajax.put("fileName", fileName);
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java
@@ -15,6 +15,7 @@
import com.ruoyi.domain.DocumentMaterials;
import com.ruoyi.domain.vo.ArchiveInfoVo;
import com.ruoyi.domain.vo.DocumentMaterialsVo;
import com.ruoyi.domain.vo.DocumentMaterialsVoLarge;
import com.ruoyi.domain.vo.DocumentMaterialsVoSmall;
import com.ruoyi.framework.web.domain.server.Sys;
import com.ruoyi.service.IArchiveRecordsService;
@@ -78,15 +79,19 @@
        ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(55L);
        List<ArchiveInfoVo> arsi = new ArrayList<>();
        arsi.add(aIV);
        String recordId = aIV.getRecordId();
        byte[] imgr = barcodeService.generateBarcodeImage(recordId);
        byte[] sedcode = pdfGenerateService.createQrCodeN(recordId, 30, 30);
        ExcelExp e1 = new ExcelExp("案卷封面数据",arsi, ArchiveInfoVo.class);
        ExcelExp e2 = new ExcelExp("提取方法…",  arsi, ArchiveInfoVo.class);
        ExcelExp e2 = new ExcelExp("案卷封面",  arsi, recordId, imgr,sedcode, ArchiveInfoVo.class);
        List<ExcelExp> mysheet = new ArrayList<ExcelExp>();
        mysheet.add(e1);
        mysheet.add(e2);
        ByteOutputStream bos1 = new ByteOutputStream();
        ExcelUtilManySheetSecond<List<ExcelExp>> util2 = new ExcelUtilManySheetSecond<List<ExcelExp>>(mysheet);
        util2.exportExcelManySheet(response, mysheet);
      //  util2.exportExcelManySheet(response, mysheet);
@@ -134,7 +139,11 @@
        // 获取文件的保存位置,读取数据库,
        DocumentMaterials documentMaterials = new DocumentMaterials();
        documentMaterials.setRecordId(id);
        List<DocumentMaterials> docs = documentMaterialsService.selectDocumentMaterialsList(documentMaterials);
        List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(id);
       System.out.println(docs.size()+"----009");
                //.selectDocumentMaterialsList(documentMaterials);
        List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString());
        ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(id);
@@ -157,8 +166,10 @@
            String datumName = "user";
            //压缩文件
            List<String> filePathList = paths;
            File file = compressedFileToZip(docs, dsvs, aIV);
            File file = compressedFileToZip(docs, dsvs, aIV, id);
            System.out.println(file.getName());
            String fileName =aIV.getRecordId()+".zip";
            //输出文件流
            writeFileToRes(response, file.getName(), file);
            //删除压缩包
@@ -178,26 +189,7 @@
        response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
        FileUtils.setAttachmentResponseHeader(response, realFileName);
        FileUtils.writeBytes(filePath, response.getOutputStream());
        //        FileInputStream inputStream = new FileInputStream(file);
//        //1.设置文件ContentType类型,这样设置,会自动判断下载文件类型.
//        response.setContentType("application/octet-stream");
//        //2.设置文件头:最后一个参数是设置下载文件名
//        response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
//        response.addHeader("Content-Length", "" + file.length());
//
//        //3.通过response获取ServletOutputStream对象(out)
//        ServletOutputStream out = response.getOutputStream();
//
//        int b = 0;
//        byte[] buffer = new byte[1024];
//        while (b != -1) {
//            b = inputStream.read(buffer);
//            //4.写到输出流(out)中
//            out.write(buffer, 0, b);
//        }
//        out.flush();
//        out.close();
//        inputStream.close();
    }
    public String frontCompWithZore(int formatLength,int formatNumber){
        /**
@@ -210,82 +202,7 @@
        return newString;
    }
    private void handleXSSFImages(XSSFSheet sheet, Document pdfDoc) throws Exception {
        XSSFDrawing drawing = sheet.getDrawingPatriarch();
        if (drawing == null) return;
        for (XSSFShape shape : drawing.getShapes()) {
            if (shape instanceof XSSFPicture) {
                XSSFPicture pic = (XSSFPicture)shape;
                XSSFClientAnchor anchor = pic.getPreferredSize();
                // 获取图片数据
                byte[] bytes = pic.getPictureData().getData();
                Image pdfImage = Image.getInstance(bytes);
                // 设置图片位置和大小
                float imageWidth = pdfImage.getWidth();
                float imageHeight = pdfImage.getHeight();
                float scale = Math.min(
                        (PageSize.A4.getWidth() - 100) / imageWidth,
                        (PageSize.A4.getHeight() - 100) / imageHeight
                );
                pdfImage.scaleAbsolute(imageWidth * scale, imageHeight * scale);
                // 添加图片到PDF
                pdfDoc.add(pdfImage);
                pdfDoc.add(Chunk.NEWLINE);
            }
        }
    }
    private static String getCellValue(Cell cell,FormulaEvaluator evaluator) {
      //  System.out.println(cell);
        if (cell == null) return "";
        CellValue cellValue = evaluator.evaluate(cell);
        if(cellValue==null)
            return "";
      //  System.out.println(cellValue.getCellType());
        switch (cellValue.getCellType()) {
            case STRING:
                return cell.getStringCellValue();
            case NUMERIC:
                // 获取数值并转为整型
                double numericValue = cell.getNumericCellValue();
                // 判断是否为整数
                if (numericValue == (int)numericValue) {
                    if((int)numericValue==0)
                        return "";
                    else
                        return String.valueOf((int)numericValue);
                } else {
                    return String.valueOf(numericValue); // 或者根据需要返回四舍五入的整型
                }
            case BOOLEAN:
                return String.valueOf(cell.getBooleanCellValue());
            case FORMULA:
                return cell.getCellFormula()+"";
            case BLANK:
                return "";
            default:
                return "";
        }
    }
    private int getRealLastCellNum(Row row) {
        int lastCellNum = 0;
        for (int i = 0; i < row.getLastCellNum(); i++) {
            Cell cell = row.getCell(i);
            if (cell != null && cell.getCellType() != CellType.BLANK) {
                lastCellNum = i + 1;
            }
        }
        return lastCellNum;
    }
@@ -316,10 +233,10 @@
    // 压缩文件
    private File compressedFileToZip(List<DocumentMaterials> docs, List<DocumentMaterialsVo> dsvs,   ArchiveInfoVo aIV) throws Exception {
    private File compressedFileToZip(List<DocumentMaterialsVoLarge> docs, List<DocumentMaterialsVo> dsvs,   ArchiveInfoVo aIV, Long id) throws Exception {
        //压缩包具体名称(拼接时间戳防止重名)
        String datumName = "";
        String zipFileName = datumName + "-" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".zip";
        String zipFileName =dsvs.get(0).getDocumentNumber()+aIV.getRecordId()+ ".zip";
        //生成压缩包存储地址(最后会删掉)
        String fileZip = RuoYiConfig.getProfile() + "/download/" + zipFileName;
        OutputStream os=null;
@@ -350,20 +267,75 @@
                        zos.write(buffer, 0, len);
                    }
                }
            //08-卷内卷内目录的pdf
            String pdf08Path= "08-卷内目录.pdf";
            List<DocumentMaterialsVo> list3 = dsvs;
            pdfGenerateService.generateFileDirectoryPdf(pdf08Path, list3);
            ZipEntry zipEntry2 = new ZipEntry(pdf08Path);
            zos.putNextEntry(zipEntry2);
            // 读取PDF文件内容并写入ZIP
            try (FileInputStream fis = new FileInputStream(pdf08Path)) {
                byte[] buffer = new byte[1024];
                int len;
                while ((len = fis.read(buffer)) > 0) {
                    zos.write(buffer, 0, len);
                }
            }
                //09-备考表.pdf
            String pdf09Path = "09-备考表.pdf";
            pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), id);
            // 2. 压缩PDF到ZIP文件
            // 添加PDF文件到ZIP
            ZipEntry zipEntry1 = new ZipEntry(pdf09Path);
            zos.putNextEntry(zipEntry1);
            // 读取PDF文件内容并写入ZIP
            try (FileInputStream fis = new FileInputStream(pdf09Path)) {
                byte[] buffer = new byte[1024];
                int len;
                while ((len = fis.read(buffer)) > 0) {
                    zos.write(buffer, 0, len);
                }
            }
                //excel 卷内封面导出zip
            ZipEntry entryiv = new ZipEntry("卷内封面" + ".xls");
            ExcelUtil<ArchiveInfoVo> utilsv = new ExcelUtil<ArchiveInfoVo>(ArchiveInfoVo.class);
            List<ArchiveInfoVo> arsi = new ArrayList<>();
            arsi.add(aIV);
            String recordId1 = aIV.getRecordId();
            byte[] imgr1 = barcodeService.generateBarcodeImage(recordId1);
            byte[] sedcode = pdfGenerateService.createQrCodeN(recordId1, 30, 30);
            ExcelExp e3 = new ExcelExp("案卷封面数据",arsi, ArchiveInfoVo.class);
            ExcelExp e4 = new ExcelExp("案卷封面",  arsi, recordId1, imgr1,sedcode, ArchiveInfoVo.class);
            List<ExcelExp> mysheet1 = new ArrayList<ExcelExp>();
            mysheet1.add(e3);
            mysheet1.add(e4);
            ByteOutputStream bos2 = new ByteOutputStream();
            ExcelUtilManySheetSecond<List<ExcelExp>> util3 = new ExcelUtilManySheetSecond<List<ExcelExp>>(mysheet1);
            util3.exportExcelManySheet(bos2, mysheet1);
          //  System.out.println(bos2);
            zos.putNextEntry(entryiv);
            ByteOutputStream boss = new ByteOutputStream();
            List<ArchiveInfoVo> aivs = new ArrayList<>();
            aivs.add(aIV);
            utilsv.byteOutputStreamExcel(boss, aivs,"Date List", "");
            boss.writeTo(zos);
//            ExcelUtil<ArchiveInfoVo> utilsv = new ExcelUtil<ArchiveInfoVo>(ArchiveInfoVo.class);
//
//
//            ByteOutputStream boss = new ByteOutputStream();
//            List<ArchiveInfoVo> aivs = new ArrayList<>();
//            aivs.add(aIV);
//            utilsv.byteOutputStreamExcel(boss, aivs,"Date List", "");
            bos2.writeTo(zos);
                //写入电子目录  xsxl
            ZipEntry entry = new ZipEntry("电子文件目录" + ".xls");
            ExcelUtil<DocumentMaterials> util = new ExcelUtil<DocumentMaterials>(DocumentMaterials.class);
            ExcelUtil<DocumentMaterialsVoLarge> util = new ExcelUtil<DocumentMaterialsVoLarge>(DocumentMaterialsVoLarge.class);
            zos.putNextEntry(entry);
            ByteOutputStream bos = new ByteOutputStream();
@@ -382,11 +354,6 @@
            mysheet.add(e1);
            mysheet.add(e2);
            ExcelUtilManySheet<List<ExcelExp>> util2 = new ExcelUtilManySheet<List<ExcelExp>>(mysheet);
            ZipEntry entr = new ZipEntry("卷内目录" + ".xls");
            ExcelUtil<DocumentMaterialsVo> util1 = new ExcelUtil<DocumentMaterialsVo>(DocumentMaterialsVo.class);
            System.out.println(dsvs);
@@ -400,126 +367,12 @@
            //把excel转为pdf
            try {
                // 1. 读取Excel文件
                String excelPath = RuoYiConfig.getProfile() + "/download/"+"卷內目录.xls";
                String pdfPath = RuoYiConfig.getProfile() + "/download/"+"1.pdf";
                Workbook workbook = WorkbookFactory.create(new File(excelPath));
                FileOutputStream fos = new FileOutputStream(pdfPath);
                FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
                // 获取第一个工作表
                    Sheet sheet = workbook.getSheetAt(1);
                    // 创建PDF文档对象
                    Document document = new Document(PageSize.A2, 50, 50, 50, 50);
                    // 创建PDF输出流
                    PdfWriter writer = PdfWriter.getInstance(document, fos);
                // 4. 处理工作表中的图片
                if (workbook instanceof XSSFWorkbook) {
                    handleXSSFImages((XSSFSheet)sheet, document);
                }
                    // 打开PDF文档
                    document.open();
                    // 创建PDF表格对象
                System.out.println(sheet.getRow(0).getLastCellNum()+"--00");
                    PdfPTable table = new PdfPTable(sheet.getRow(0).getLastCellNum());
                    table.setHeaderRows(1);
                    // 设置表格宽度
                    table.setWidthPercentage(100);
                    // 设置表格标题
                    Paragraph title = new Paragraph(sheet.getSheetName(), new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 16, Font.BOLD));
                    title.setAlignment(Element.ALIGN_CENTER);
                    document.add(title);
                   // System.out.println(sheet.)
                    // 添加表格内容
                    for (Row row : sheet) {
                        {
                            if (row == null) continue;
                            System.out.println(getRealLastCellNum(row)+"---987");
//                            if(row.getRowNum()==0)
//                                continue;
                            if(row.getRowNum()==2)
                            {
                                PdfPCell pdfCell = ImageSet(100);
                                pdfCell.setColspan(7);
                                pdfCell.setRowspan(3);
                                pdfCell.setBorderWidth(1f);
                                pdfCell.setBorderColor(BaseColor.BLACK);
                                pdfCell.setPadding(5f);
                                pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                                pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                                table.addCell(pdfCell);
                                System.out.println("{{{{{{{{{{{{{");
                                continue;
                            }
                            for (int i = 0; i < 7; i++)
                            {
                                Cell cell = row.getCell(i);
                                if(row.getRowNum()==3)
                                {
                                    PdfPCell pdfCell = new PdfPCell(new Paragraph("卷内目录", new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 12)));
                                    pdfCell.setColspan(7);
                                    pdfCell.setBorderWidth(1f);
                                    pdfCell.setBorderColor(BaseColor.BLACK);
                                    pdfCell.setPadding(5f);
                                    pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                                    pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                                    table.addCell(pdfCell);
                                    System.out.println("{{{{{{{{{{{{{");
                                    break;
                                }
                                if(cell==null) {
                                    table.addCell("");
                                    continue;
                                }
                                PdfPCell pdfCell = new PdfPCell(new Paragraph(getCellValue(cell, evaluator), new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 12)));
                                if(row.getRowNum()!=1) {
                                    pdfCell.setBorderWidth(1f);
                                    pdfCell.setBorderColor(BaseColor.BLACK);
                                    pdfCell.setPadding(5f);
                                    pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                                    pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                                }
                                if (cell.getRowIndex() == 5) {
                                    pdfCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
                                }
                                table.addCell(pdfCell);
                            }
                        }
                    }
                    // 添加表格到PDF文档
                    table.setSpacingBefore(20f);
                    table.setSpacingAfter(20f);
                    table.setKeepTogether(true);
                    document.add(table);
                    // 关闭PDF文档
                    document.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
            boolean res = true;
            byte[] buf = new byte[1024];
            for (DocumentMaterials dc : docs) {
            for (DocumentMaterialsVoLarge dc : docs) {
                String filePath = dc.getUrl();
                filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/");
ruoyi-common/src/main/java/com/ruoyi/common/annotation/NumberFormatHandler.java
New file
@@ -0,0 +1,15 @@
package com.ruoyi.common.annotation;
import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Workbook;
public class NumberFormatHandler implements ExcelHandlerAdapter {
    @Override
    public Object format(Object value, String[] args, Cell cell, Workbook workbook) {
        if (value instanceof Number) {
            return String.format("%04d", ((Number)value).intValue());
        }
        return value;
    }
}
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelExp.java
@@ -13,13 +13,22 @@
    private String recordId;  //档案号
    private byte[] imgr; //条形码
    public byte[] getSedcode() {
        return sedcode;
    }
    public void setSedcode(byte[] sedcode) {
        this.sedcode = sedcode;
    }
    private byte[] sedcode; //二维码
    public ExcelExp(String fileName, List dataset, Class clazz) {
        this.fileName = fileName;
        this.dataset = dataset;
        this.clazz = clazz;
    }
    public ExcelExp(String fileName, List dataset, String recordId, byte[] imgr,Class clazz) {
    public ExcelExp(String fileName, List dataset, String recordId, byte[] imgr, Class clazz) {
        this.fileName = fileName;
        this.dataset = dataset;
@@ -28,6 +37,16 @@
        this.imgr = imgr;
    }
    public ExcelExp(String fileName, List dataset, String recordId, byte[] imgr,byte[] sedcode, Class clazz) {
        this.fileName = fileName;
        this.dataset = dataset;
        this.clazz = clazz;
        this.recordId = recordId;
        this.imgr = imgr;
        this.sedcode = sedcode;
    }
    public String getFileName() {
        return fileName;
    }
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java
@@ -22,7 +22,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -267,9 +270,9 @@
     * @return 结果
     * @throws IOException
     */
    public void exportExcelManySheet(HttpServletResponse response, List<ExcelExp> list) throws IOException {
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
    public void exportExcelManySheet(ByteOutputStream response, List<ExcelExp> list) throws IOException {
//        response.setContentType("application/vnd.ms-excel");
//        response.setCharacterEncoding("utf-8");
        try {
            createWorkbook();
            for (int index = 0; index <list.size(); index++) {
@@ -278,22 +281,185 @@
                // 取出一共有多少个sheet.
//                    double sheetNo = Math.ceil(list.size() / sheetSize);
                createSheetManySheet(index);
                // 产生一行
                Row row = sheet.createRow(0);
                int column = 0;
                // 写入各个字段的列头名称
                for (Object[] os : fields) {
                    Excel excel = (Excel) os[1];
                    this.createCell(excel, row, column++);
                // 产生一行    if(index == 1) {
                if(index==1)
                {
                    Row row = sheet.createRow(0);
                    row.setHeightInPoints(20); // 设置行高为20磅
                    int column = 0;
                    row = sheet.createRow(0);
                    sheet.addMergedRegion(new CellRangeAddress(2, 3, 0, 1));
                    row = sheet.createRow(2);
                    row.setHeightInPoints(120); // 设置行高为20磅
                    //拿到图片
                    // 创建单元格并添加图片
                    Cell cell = row.createCell(0);
//sheet.setColumnWidth(0, 20 * 256); // 第一列宽度20字符
//sheet.setColumnWidth(1, 15 * 256); // 第二列宽度15字符
//sheet.setColumnWidth(2, 25 * 256); // 第三列宽度25字符 // 设置第一列宽度为20个字符
                    ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) (cell.getColumnIndex()+1), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() +2),
                            cell.getRow().getRowNum() + 1);
                    // 计算居中位置
//                    int col1 = 0; // 中间列
//                    int col2 = col1 + 2;
//                    anchor.setCol1(col1);
//                    anchor.setCol2(col2);
//                    anchor.setDx1(100);
//                    anchor.setDy1(0);
//                    anchor.setDx2(255); // 宽度
//                    anchor.setDy2(255); // 高度
                    anchor.setRow1(2);
                    anchor.setRow2(3);
                    byte[] data = list.get(index).getSedcode();
// 设置图片大小和位置
                    anchor.setDx1(2400000);
                    anchor.setDy1(100);
                    anchor.setDy2(-600000);
                    // 获取图片原始尺寸
                    BufferedImage image = ImageIO.read(new ByteArrayInputStream(data));
                    double widthInEMU = image.getWidth() * 9525 * 0.2;
                    double heightInEMU = image.getHeight() * 9525;
                    // 设置图片原始尺寸
                    anchor.setDx2(-100000); // 原始宽度
                 //   anchor.setDy2((int)heightInEMU); // 原始高度
//anchor.setCol1(5); // 从第6列开始显示
//anchor.setCol2(10); // 到第11列结束
                    //Files.readAllBytes(Paths.get(RuoYiConfig.getProfile() + "/upload/2025/08/14/30_20250814212128A031.jpg"));
//
//
//                    System.out.println(data.length);
                    getDrawingPatriarch(cell.getSheet()).createPicture(anchor,
                            cell.getSheet().getWorkbook().addPicture(data, getImageType(data)));
                    String [] tits = {"档        号:","档案馆(室)号:","缩  微  号: ","发  文  号:",
                            "案  卷  题  名:","编  制  日  期:","编  制  单  位:","保  管  期  限:","密     级:"};
                    List tmp = list.get(index).getDataset();
                    Object obj = tmp.get(0);
                    Field[] declaredFields = this.clazz.getDeclaredFields();
                    System.out.println(declaredFields.length);
                    int i = 0;
                    for (Field field : declaredFields) {
                        // 设置字段的访问权限,以便于访问私有字段
                        field.setAccessible(true);
                        // 获取字段的名称和值
                        String fieldName = field.getName();
                    //    Object fieldValue = field.get(person);
                         Class<?> clazz = obj.getClass();
                         Field field1 =clazz.getDeclaredField(fieldName);
                         field1.setAccessible(true);
                         Object fieldValue = field1.get(obj);
                         if(fieldValue==null)
                             fieldValue="";
                         if(i <= 3)
                            row = sheet.createRow(i+4);
                         if(i > 3)
                             row = sheet.createRow(i+7);
                       // row.setHeight((short) 30);
                        row.setHeightInPoints(40); // 设置行高为20磅
                       // row.createCell(0)
                        cell = row.createCell(0);
                        //设置cell的宽度
                        sheet.setColumnWidth(0, 20 * 256);
                        sheet.setColumnWidth(1, 60 * 256); // 第二列宽度15字符
                        CellStyle style = wb.createCellStyle();
                        style.setAlignment(HorizontalAlignment.RIGHT);
                        style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER); // 设置垂直居中
                      //  style.setAlignment(VerticalAlignment.CENTER);
                        Font font = wb.createFont();
                        font.setBold(true);
                        style.setFont(font);
style.setWrapText(true); // 设置自动换行
                        cell.setCellStyle(style);
                        cell.setCellValue(tits[i]);
                        Cell cel = row.createCell(1);
                        CellStyle style1 = wb.createCellStyle();
                        style1.setBorderBottom(BorderStyle.THIN); // 添加下划线
                        style1.setWrapText(true); // 设置自动换行
                        style1.setVerticalAlignment(VerticalAlignment.CENTER);
                        cel.setCellStyle(style1);
                        cel.setCellValue(fieldValue.toString());
                      //  sheet.setColumnWidth(0, 60 * 256);
                        i++;
                        if(i==3)
                        {
                            row = sheet.createRow(8);
                            // row.setHeight((short) 30);
                            row.setHeightInPoints(40); // 设置行高为20磅
                            row = sheet.createRow(9);
                            //设置条形码
                            Cell cell1 = row.createCell(0);
//sheet.setColumnWidth(0, 20 * 256); // 第一列宽度20字符
//sheet.setColumnWidth(1, 15 * 256); // 第二列宽度15字符
//sheet.setColumnWidth(2, 25 * 256); // 第三列宽度25字符 // 设置第一列宽度为20个字符
                            ClientAnchor anchor1 = new XSSFClientAnchor(0, 0, 0, 0, (short) (cell1.getColumnIndex()), cell1.getRow().getRowNum(), (short) (cell1.getColumnIndex() +2),
                                    cell1.getRow().getRowNum() + 1);
                            // 计算居中位置
//// 设置图片大小和位置
anchor1.setDx1(600000);
anchor1.setDy1(0);
anchor1.setDx2(-600000); // 宽度
anchor1.setDy2(255); // 高度
//anchor1.setCol1(0.5); // 从第6列开始显示
//anchor1.setCol2(10); // 到第11列结束
                            anchor1.setRow1(9);
                            anchor1.setRow2(10);
                            byte[] dat = list.get(index).getImgr();
                            //Files.readAllBytes(Paths.get(RuoYiConfig.getProfile() + "/upload/2025/08/14/30_20250814212128A031.jpg"));
//
//
//                    System.out.println(data.length);
                            getDrawingPatriarch(cell1.getSheet()).createPicture(anchor1,
                                    cell.getSheet().getWorkbook().addPicture(dat, getImageType(dat)));
                            row.setHeightInPoints(70); // 设置行高为20磅
                            row = sheet.createRow(10);
                            row.setHeightInPoints(40); // 设置行高为20磅
                        }
                        // 打印字段名称和值
                        System.out.println(fieldName + ": " + fieldValue);
                    }
                }
                if (Excel.Type.EXPORT.equals(type)) {
                    fillExcelData(index, row);
                    addStatisticsRow();
                else {
                    Row row = sheet.createRow(0);
                    int column = 0;
                    // 写入各个字段的列头名称
                    for (Object[] os : fields) {
                        Excel excel = (Excel) os[1];
                        this.createCell(excel, row, column++);
                    }
                    if (Excel.Type.EXPORT.equals(type)) {
                        fillExcelData(index, row);
                        addStatisticsRow();
                    }
                }
            }
            wb.write(response.getOutputStream());
            wb.write(response);
        } catch (IOException e) {
            log.error("导出Excel异常{}", e.getMessage());
        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } finally {
            if (wb != null) {
                try {
@@ -302,13 +468,13 @@
                    e1.printStackTrace();
                }
            }
            if (response.getOutputStream() != null) {
                try {
                    response.getOutputStream().close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
//            if (response.getOutputStream() != null) {
//                try {
//                    response.getOutputStream().close();
//                } catch (IOException e1) {
//                    e1.printStackTrace();
//                }
//            }
        }
//        exportExcel(response.getOutputStream());
    }
@@ -388,6 +554,10 @@
                row = sheet.createRow(i + 4 );
            else
                row = sheet.createRow(i + 1 );
            row.setHeightInPoints(40); // 设置行高为20磅
            // row.createCell(0)
            // 得到导出对象.
            T vo = (T) list.get(i);
            int column = 0;
@@ -557,11 +727,26 @@
        Cell cell = null;
        try {
            // 设置行高
            row.setHeight(maxHeight);
            row.setHeight((short) 2000);
            // 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列.
            if (attr.isExport()) {
                // 创建cell
                cell = row.createCell(column);
                //设置cell的宽度
                sheet.setColumnWidth(0, 20 * 256);
                sheet.setColumnWidth(1, 60 * 256); // 第二列宽度15字符
                CellStyle style = wb.createCellStyle();
//                style.setAlignment(HorizontalAlignment.RIGHT);
                style.setVerticalAlignment(VerticalAlignment.CENTER);
                style.setVerticalAlignment(VerticalAlignment.CENTER); // 设置垂直居中
                //  style.setAlignment(VerticalAlignment.CENTER);
                Font font = wb.createFont();
                font.setBold(true);
                style.setFont(font);
                style.setWrapText(true); // 设置自动换行
                cell.setCellStyle(style);
//                attr.align();
//                int align = attr.align().value;
//                cell.setCellStyle(styles.get("data" + (align >= 1 && align <= 3 ? align : "")));