fei
4 天以前 2f1ae9c10a1751438d09b3d848677deb883631aa
修改了对应代码
9个文件已修改
1个文件已添加
392 ■■■■ 已修改文件
archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVo.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVoMid.java 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/service/IDocumentMaterialsService.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java 85 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveRecordsController.java 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheet.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVo.java
@@ -44,6 +44,8 @@
    private String publicity;
    private String fileStyle;
    private String retentionPeriod;
//    @Excel(name = "图片", cellType = Excel.ColumnType.IMAGE)
//    private String url;
archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVoMid.java
New file
@@ -0,0 +1,81 @@
package com.ruoyi.domain.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;
import org.apache.poi.ss.usermodel.IndexedColors;
import java.util.Date;
@Data
public class DocumentMaterialsVoMid {
    @Excel(name="序号", height = 10,width=8,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE)
    private Long num;
    @Excel(name = "文件编号", height = 10, width=8,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE)
    private String documentNumber;
    @Excel(name = "责任者", height = 10, width=8,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE)
    private String creator;
    @Excel(name = "文件题名", height = 8,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE)
    private String title;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "日期", width = 10, dateFormat = "yyyy-MM-dd", height = 10,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE)
    private Date date;
    // 页号(原始数值,用于计算)
    private Long pageNumber;
    // 格式化后的页号,用于显示范围,如"38-38"或"23-38"
    @TableField(exist = false)
    @Excel(name = "页号", height = 10,width = 10,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE)
    private String pageNumberFormatted;
    @Excel(name = "材料类型", width = 10,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE)
    private String fileStyle;
    /** $column.columnComment */
    @Excel(name = "所处阶段", width = 10,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE)
    private String stage;
    /** $column.columnComment */
    @Excel(name = "公开属性", height = 10,width=10,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE)
    private String publicity;
    /** $column.columnComment */
    @Excel(name = "是否为附件附图", width = 10,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE)
    private String isAttachment;
    /** $column.columnComment */
//    @Excel(name = "是否为附图")
    private String isDiagram;
    /** $column.columnComment */
    @Excel(name = "保管期限", width = 10,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE)
    private String retentionPeriod;
    /** $column.columnComment */
    @Excel(name = "密级", width = 10,headerColor = IndexedColors.BLACK,readConverterExp = "该页另存=普通,普通=普通,内部用图=内部用图,内部用途=内部用途,秘密=秘密", headerBackgroundColor = IndexedColors.WHITE)
    private String securityLevel;
    /** $column.columnComment */
    @Excel(name = "是否涉密及敏感信息",headerColor = IndexedColors.BLACK, width = 10, headerBackgroundColor = IndexedColors.WHITE)
    private String isSensitive;
    /** $column.columnComment */
    @Excel(name = "是否注销" ,headerColor = IndexedColors.BLACK,width = 10, headerBackgroundColor = IndexedColors.WHITE)
    private String isCanceled;
    @Excel(name = "备注", height = 20,width=10,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE)
    private String remarks;
   // private String retentionPeriod;
}
archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java
@@ -2,10 +2,7 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.domain.DocumentMaterials;
import com.ruoyi.domain.vo.DocumentMaterialFileStyle;
import com.ruoyi.domain.vo.DocumentMaterialsFileList;
import com.ruoyi.domain.vo.DocumentMaterialsVo;
import com.ruoyi.domain.vo.DocumentMaterialsVoLarge;
import com.ruoyi.domain.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@@ -37,13 +34,20 @@
    //查询卷内目录
    @Select(
            "select ROW_NUMBER() OVER (ORDER BY page_number) AS num, document_number, creator,title, date, page_number,dm.remarks, ar.record_id, publicity from document_materials as dm, archive_records as ar \n" +
            "select ROW_NUMBER() OVER (ORDER BY page_number) AS num, document_number, creator,title, date, page_number,dm.remarks, ar.record_id, publicity, file_style, dm.retention_period from document_materials as dm, archive_records as ar \n" +
            "            WHERE ar.id = dm.record_id and page_number  IN (\n" +
            "            SELECT MIN(page_number)\n" +
            "            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, document_number, creator,title, date, page_number, publicity, file_style, stage,is_attachment,is_diagram, dm.retention_period,is_sensitive,is_canceled,dm.remarks from document_materials as dm, archive_records as ar \n" +
                    "            WHERE ar.id = dm.record_id and page_number  IN (\n" +
                    "            SELECT MIN(page_number)\n" +
                    "            FROM document_materials where record_id=#{recordId}\n" +
                    "             GROUP BY stage, title) and ar.id =#{recordId} order by page_number ;")
    List<DocumentMaterialsVoMid> getArchiveMatInfoAll(@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" +
archiveManager/src/main/java/com/ruoyi/service/IDocumentMaterialsService.java
@@ -4,10 +4,7 @@
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.DocumentMaterialsFileList;
import com.ruoyi.domain.vo.DocumentMaterialsVo;
import com.ruoyi.domain.vo.DocumentMaterialsVoLarge;
import com.ruoyi.domain.vo.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.multipart.MultipartFile;
@@ -78,7 +75,7 @@
    public int updateByPageNumber(Long pageNumber,String sizeType, Long fileNumber, int wid, int hei, int wdpi, int hdpi, double sz,String url,String format, Long recordId);
    public List<DocumentMaterialsVo> findArchMInfo(String recordId, long pageCount);
    public List<DocumentMaterialsVoMid> findArchMInfoAll(String recordId, long pageCount);
    public List<DocumentMaterialFileStyle> findFileStyleInfo(@Param("recordId") int recordId);
archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java
@@ -1,34 +1,97 @@
package com.ruoyi.service.impl;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.oned.Code128Writer;
import com.google.zxing.oned.Code39Writer;
import org.krysalis.barcode4j.impl.code128.Code128Bean;
import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;
import org.springframework.stereotype.Service;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@Service
public class BarcodeService {
    public byte[] generateBarcodeImage(String barcodeText) {
        try {
            Code128Bean barcodeGenerator = new Code128Bean();
            final int dpi = 160;
            barcodeGenerator.setModuleWidth(0.58);
            barcodeGenerator.setBarHeight(14.2); // 设置条形码高度为64
            barcodeGenerator.doQuietZone(false);
           // 使用 BitMatrix 生成纯条码,不包含任何文字
            BarcodeFormat format = BarcodeFormat.CODE_39; // 根据您的条码类型
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            BitmapCanvasProvider canvas = new BitmapCanvasProvider(
                    outputStream, "image/png", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0);
            // 创建编码器
            Code39Writer writer = new Code39Writer();
            barcodeGenerator.generateBarcode(canvas, barcodeText);
            canvas.finish();
            // 编码参数
            Map<EncodeHintType, Object> hints = new HashMap<>();
            hints.put(EncodeHintType.MARGIN, 0); // 无边框
            return outputStream.toByteArray();
            // 生成 BitMatrix(纯条码,无文字)
            BitMatrix matrix = writer.encode(barcodeText, format, 0, 63, hints);
            int width = matrix.getWidth();
            int height = matrix.getHeight();
            // 计算文字区域
            int textAreaHeight = 30 + 10;
            // 创建最终图像
            BufferedImage finalImage = new BufferedImage(
                    width,
                    height + textAreaHeight,
                    BufferedImage.TYPE_BYTE_BINARY
            );
            Graphics2D g2d = finalImage.createGraphics();
            // 白色背景
            g2d.setColor(Color.WHITE);
            g2d.fillRect(0, 0, width, height + textAreaHeight);
            // 绘制条码(从 BitMatrix)
            g2d.setColor(Color.BLACK);
            for (int x = 0; x < width; x++) {
                for (int y = 0; y < height; y++) {
                    if (matrix.get(x, y)) {
                        g2d.fillRect(x, y, 1, 1);
                    }
                }
            }
            // 添加自定义文字
            g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                    RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
            Font font = new Font("Tahoma", Font.BOLD, 18);
            g2d.setFont(font);
            FontMetrics fm = g2d.getFontMetrics();
            int textWidth = fm.stringWidth(barcodeText);
            int x = (width - textWidth) / 2;
            int y = height + 30 - 5; // 调整垂直位置
            g2d.drawString(barcodeText, x, y);
            g2d.dispose();
            // 保存
            ByteArrayOutputStream resultStream = new ByteArrayOutputStream();
            ImageIO.write(finalImage, "png", resultStream);
            return resultStream.toByteArray();
         //   return outputStream.toByteArray();
        } catch (IOException e) {
            throw new RuntimeException("Error generating barcode", e);
        } catch (WriterException e) {
            throw new RuntimeException(e);
        }
    }
}
archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java
@@ -333,6 +333,37 @@
    }
    @Override
    public List<DocumentMaterialsVoMid> findArchMInfoAll(String recordId, long pageCount) {
        // 获取原始数据列表
        List<DocumentMaterialsVoMid> dataList = this.baseMapper.getArchiveMatInfoAll(Integer.parseInt(recordId));
        // 获取该案卷的最大页号(总页数)
        Long totalPages = (long) pageCount;
        //this.baseMapper.getMaxPageNumber(Integer.parseInt(recordId));
        // 如果数据列表不为空
        if (dataList != null && !dataList.isEmpty() && totalPages != null) {
            int size = dataList.size();
            // 遍历所有条目,设置pageNumberFormatted
            for (int i = 0; i < size; i++) {
                DocumentMaterialsVoMid item = dataList.get(i);
                Long pageNumber = item.getPageNumber();
                if (i == size - 1) {
                    // 最后一行:格式化页号为"最后一页页号-总页数"的形式
                    item.setPageNumberFormatted(pageNumber + "-" + totalPages);
                } else {
                    // 其他行:直接使用pageNumber的值
                    item.setPageNumberFormatted(pageNumber != null ? pageNumber.toString() : "");
                }
            }
        }
        return dataList;
    }
    @Override
    public List<DocumentMaterialFileStyle> findFileStyleInfo(int recordId) {
        return this.baseMapper.getFileStyleInfo(recordId);
    }
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveRecordsController.java
@@ -1,10 +1,10 @@
package com.ruoyi.web.controller.archive;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.bean.BeanUtil;
@@ -172,7 +172,64 @@
        System.out.println("090sdfsdf");
        return new AjaxResult(0, archiveRecordsService.updateStatusByIds(ids) + "");
    }
    /**
     *
     */
    @PreAuthorize("@ss.hasPermi('system:records:list')")
    @Log(title = "档案记录", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/getAllFilesCounts")
    public AjaxResult getAllFileCounts(@RequestBody Long[] ids) {
// 1. 初始化Map,用于存储recordId和对应的文件数
        Map<Long, Integer> recordFileCountMap = new HashMap<>();
// 2. 获取基础上传路径
        String filePath = RuoYiConfig.getUploadPath();
// 3. 遍历每个recordId,计算文件数并放入Map
        for (Long recordId : ids) {
            // 拼接当前recordId的目录路径
            File desc = new File(filePath + File.separator + recordId);
            int fileCount = 0;
            try {
                // 判断目录是否存在且是目录
                if (desc.exists() && desc.isDirectory()) {
                    // 过滤出仅文件(排除子目录)
                    File[] files = desc.listFiles(new FileFilter() {
                        @Override
                        public boolean accept(File file) {
                            return file.isFile(); // 只统计文件,不统计目录
                        }
                    });
                    // 避免空指针(空目录时listFiles返回null)
                    if (files != null) {
                        fileCount = files.length;
                    }
                } else {
                    // 目录不存在/不是目录,文件数为0
                    fileCount = 0;
                    // 可选:日志提示
                    // log.warn("目录不存在或非目录:{}", desc.getAbsolutePath());
                }
            } catch (SecurityException e) {
                // 权限不足等异常,文件数置0
                fileCount = 0;
                // 可选:日志记录异常
                // log.error("获取目录[{}]文件数失败:{}", recordId, e.getMessage(), e);
            }
            // 4. 将recordId和对应的文件数放入Map
            recordFileCountMap.put(recordId, fileCount);
        }
        return new AjaxResult(200,"拿到所有对应的数据", recordFileCountMap);
    }
    /**
     * 删除档案记录
     */
@@ -259,11 +316,19 @@
        List<DocumentMaterialsFileList> arsi = new ArrayList<>();
//        DocumentMaterials documentMaterials = new DocumentMaterials();
//        documentMaterials.setRecordId(recordId);
        List<DocumentMaterialsFileList> lst = iDocumentMaterialsService.selectDocumentMaterialsFileList(searSigAnn.getRecordId());
                ArchiveRecords archiveRecords = archiveRecordsService.selectArchiveRecordsById(searSigAnn.getRecordId());
        List<DocumentMaterialsVo> lst = iDocumentMaterialsService.findArchMInfo(searSigAnn.getRecordId().toString(), archiveRecords.getPageCount());
       // List<DocumentMaterialsFileList> lst =
        //拿到卷内目录的excel
//        List<DocumentMaterialsVoSmall> lst = dsvs.stream().map(res1 -> new DocumentMaterialsVoSmall(res1.getNum(), res1.getDocumentNumber(),res1.getCreator(),
//                res1.getTitle(), res1.getDate(), res1.getPageNumberFormatted(), res1.getRemarks())).collect(Collectors.toList());
        //iDocumentMaterialsService.selectDocumentMaterialsFileList(searSigAnn.getRecordId());
        // 复制属性到SmallObject列表
        for (DocumentMaterialsFileList bigObject : lst) {
        for (DocumentMaterialsVo bigObject : lst) {
            DocumentMaterialsFileList smallObject = new DocumentMaterialsFileList();
            BeanUtil.copyProperties(bigObject, smallObject); // 复制属性
            System.out.println(bigObject);
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java
@@ -189,10 +189,10 @@
    public void exportDir(HttpServletResponse response, DocumentMaterials documentMaterials, @RequestParam(value = "ids", required = false) Long[] ids)
    {
        ArchiveRecords archiveRecords = iArchiveRecordsService.selectArchiveRecordsById(documentMaterials.getRecordId());
        List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(documentMaterials.getRecordId().toString(), archiveRecords.getPageCount());
        List<DocumentMaterialsVoMid> dsvs = documentMaterialsService.findArchMInfoAll(documentMaterials.getRecordId().toString(), archiveRecords.getPageCount());
        List<DocumentMaterialsVoSmall> list2 = dsvs.stream().map(res1 -> new DocumentMaterialsVoSmall(res1.getNum(), res1.getDocumentNumber(),res1.getCreator(),
                res1.getTitle(), res1.getDate(), res1.getPageNumberFormatted(), res1.getRemarks())).collect(Collectors.toList());
//        List<DocumentMaterialsVoSmall> list2 = dsvs.stream().map(res1 -> new DocumentMaterialsVoSmall(res1.getNum(), res1.getDocumentNumber(),res1.getCreator(),
//                res1.getTitle(), res1.getDate(), res1.getPageNumberFormatted(), res1.getRemarks())).collect(Collectors.toList());
//        List<DocumentMaterials> list;
//        System.out.println(ids);
@@ -227,8 +227,8 @@
//            return vo;
//        }).collect(Collectors.toList());
        
        ExcelUtil<DocumentMaterialsVoSmall> util = new ExcelUtil<DocumentMaterialsVoSmall>(DocumentMaterialsVoSmall.class);
        util.exportExcel(response, list2, "卷内目录");
        ExcelUtil<DocumentMaterialsVoMid> util = new ExcelUtil<DocumentMaterialsVoMid>(DocumentMaterialsVoMid.class);
        util.exportExcel(response, dsvs, "卷内目录");
    }
   // List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString());
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheet.java
@@ -336,17 +336,22 @@
                      //  if (Files.exists(Paths.get(imagePath))) {
                          //  byte[] imageBytes = Files.readAllBytes(Paths.get(imagePath));
                            // 将byte数组转换成inputstream,以便插入到Excel中
                            ClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 100, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 5),
                                    cell.getRow().getRowNum() + 1);
                            ClientAnchor anchor = new HSSFClientAnchor(813, 0, 787, 71, (short) 2, 0, (short) 4,
                                    1);
//                    ClientAnchor anchor = new HSSFClientAnchor(813, 0, 787, 71, (short) 2, 0, (short) 4,
//                            2);
                            // 设置锚点类型为MOVE_AND_RESIZE,使图片可以随单元格调整大小
                            anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
                                    // 计算居中位置
                    int col1 = 3; // 中间列
                    int col2 = col1 + 2;
                    anchor.setCol1(col1);
                    anchor.setCol2(col2);
                    anchor.setRow1(0);
                    anchor.setRow2(1);
//                    int col1 = 3; // 中间列
//                    int col2 = col1 + 2;
//                    anchor.setCol1(col1);
//                    anchor.setCol2(col2);
//                    anchor.setRow1(0);
//                    anchor.setRow2(1);
//                            anchor.set
//                            anchor.setHorizontallyCenter(true);
@@ -1093,10 +1098,10 @@
            HSSFSheet hssfSheet = hssfWb.getSheetAt(index);
            HSSFHeader header = hssfSheet.getHeader();
            // 设置页眉字体
           // header.setFontName("宋体");
           // header.setFontName("宋体");4
           // header.setFontSize((short) 10);
            // 设置页眉内容
            hssfSheet.setMargin(Sheet.HeaderMargin, 2.1);
            hssfSheet.setMargin(Sheet.HeaderMargin, 1.34);
            header.setRight("&\"宋体,Bold\"共 &N 页   第 &P 页");
        }
        // 如果是index为1的sheet,设置顶端标题行
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java
@@ -307,7 +307,6 @@
                int column = 0;
                if(index == 0) {
                    // 合并第一行的前5个单元格
                    sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 8));
                    // 必须先设置为true
                    // 页面布局设置
@@ -333,33 +332,49 @@
                    {
                        row.setHeight((short)(55.8 * 20));
                        Cell cell = row.createCell(6);
                        Cell cell = row.createCell(0);
//                        for(int cl = 1 ; cl <=8; cl++)
//                            cell = row.createCell(cl);
//
//
//                        for (int col = 4; col <= 7; col++) {
//                            row.getSheet().setColumnWidth(col, 15 * 256); // 每列15字符宽
                //        }
                        int margin = -40* 9525;
                        int mary = -11 * 9525;
                        XSSFClientAnchor anchor = new XSSFClientAnchor(
                                0,          // dx1
                                0,          // dy1
                                margin,     // dx2:右边界左移10像素
                                mary,          // dy2
                                (short)5,   // col1
                                0,          // row1
                                (short)9,   // col2
                                1          // row2
                        );
                        // 设置图片大小和位置
                        ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) (cell.getColumnIndex()+1), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() +2),
                                cell.getRow().getRowNum() + 1);
                     //   ClientAnchor anchor = new XSSFClientAnchor(0, 0, 600, 150, (short)0, 0, (short)6, 1);
                    //   anchor.setDx2(488);
                    //   anchor.setDy2(10);
                   //     anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
                        // 计算居中位置
//                    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.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
                        // 计算居中位置
                        int col1 = 4; // 中间列
                        int col2 = col1 + 3;
                        anchor.setCol1(col1);
                        anchor.setCol2(col2);
                        anchor.setRow1(0);
                        anchor.setRow2(1);
//                        int col1 = 4; // 中间列
//                        int col2 = col1 + 3;
//                        anchor.setCol1(col1);
//                        anchor.setCol2(col2);
//                        anchor.setRow1(0);
//                        anchor.setRow2(1);
                        byte[] data = bt;
                 
                        // 获取图片原始尺寸
                        BufferedImage image = ImageIO.read(new ByteArrayInputStream(data));
                        double widthInEMU = image.getWidth() * 9525 * 0.2;
                        double heightInEMU = image.getHeight() * 9525;
//                        double widthInEMU = image.getWidth() * 9525 * 0.2;
//                        double heightInEMU = image.getHeight() * 9525;
                        // 设置图片原始尺寸
                    //    anchor.setDx2(-100000); // 原始宽度
@@ -378,6 +393,7 @@
                    }
                    else
                        row.setHeight((short)(33 * 20));
                  //  sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 8));
                    //  sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 7));
                    if(firow==1)