From a5edca4c62ea99418dcaa5d792947b1bab7fe8b2 Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期三, 17 十二月 2025 23:08:36 +0800
Subject: [PATCH] 修改了对应代码

---
 ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java          |    2 
 archiveManager/src/main/java/com/ruoyi/service/impl/pdfGenerateService.java                |  208 ++++++++++++++++++++--------
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java |    2 
 ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java        |  139 ++++++++++---------
 archiveManager/src/main/java/com/ruoyi/domain/vo/ArchiveInfoVo.java                        |   19 +-
 archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java                    |    1 
 6 files changed, 232 insertions(+), 139 deletions(-)

diff --git a/archiveManager/src/main/java/com/ruoyi/domain/vo/ArchiveInfoVo.java b/archiveManager/src/main/java/com/ruoyi/domain/vo/ArchiveInfoVo.java
index 2bdfc18..d962331 100644
--- a/archiveManager/src/main/java/com/ruoyi/domain/vo/ArchiveInfoVo.java
+++ b/archiveManager/src/main/java/com/ruoyi/domain/vo/ArchiveInfoVo.java
@@ -3,6 +3,7 @@
 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;
 
@@ -11,40 +12,40 @@
 
 
     /** 妗f鍙� */
-    @Excel(name = "妗f鍙�")
+    @Excel(name = "妗f鍙�",width = 8, headerColor = IndexedColors.BLACK)
     private String recordId;
     /** 妗f绠�(瀹�)鍙� */
-    @Excel(name = "妗f绠�(瀹�)鍙�")
+    @Excel(name = "妗f绠�(瀹�)鍙�",width = 6, headerColor = IndexedColors.BLACK)
     private String archiveRoomNumber;
     /** 缂╁井鍙� */
-    @Excel(name = "缂╁井鍙�")
+    @Excel(name = "缂╁井鍙�",width = 8, headerColor = IndexedColors.BLACK)
     private String microfilmNumber;
     /** 鍙戦棶鍙� */
-    @Excel(name = "鍙戞枃鍙�")
+    @Excel(name = "鍙戞枃鍙�",width = 8, headerColor = IndexedColors.RED)
     private String inquiryNumber;
 
 
 
     /** 妗堝嵎棰樺悕 */
-    @Excel(name = "妗堝嵎棰樺悕")
+    @Excel(name = "妗堝嵎棰樺悕",width = 20, headerColor = IndexedColors.RED)
     private String caseTitle;
 
 
 
     /** 缂栧埗鏃ユ湡 */
     @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "缂栧埗鏃ユ湡", width = 30, dateFormat = "yyyy-MM-dd")
+    @Excel(name = "缂栧埗鏃ユ湡", width = 12, dateFormat = "yyyy-MM-dd", headerColor = IndexedColors.RED)
     private Date preparationDate;
     /** 缂栧埗鍗曚綅 */
-    @Excel(name = "缂栧埗鍗曚綅")
+    @Excel(name = "缂栧埗鍗曚綅",width = 8, headerColor = IndexedColors.RED)
     private String preparationUnit;
 
     /** 淇濈鏈熼檺 */
-    @Excel(name = "淇濈鏈熼檺")
+    @Excel(name = "淇濈鏈熼檺", width = 8,headerColor = IndexedColors.RED)
     private String retentionPeriod;
 
     /** 瀵嗙骇 */
-    @Excel(name = "瀵嗙骇")
+    @Excel(name = "瀵嗙骇", width = 8,headerColor = IndexedColors.RED)
     private String securityClassification;
 
 
diff --git a/archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java b/archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java
index 794a26d..29255b6 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java
@@ -16,6 +16,7 @@
             Code128Bean barcodeGenerator = new Code128Bean();
             final int dpi = 160;
             barcodeGenerator.setModuleWidth(0.21);
+            barcodeGenerator.setBarHeight(4.0); // 璁剧疆鏉″舰鐮侀珮搴︿负64
             barcodeGenerator.doQuietZone(false);
 
             ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
diff --git a/archiveManager/src/main/java/com/ruoyi/service/impl/pdfGenerateService.java b/archiveManager/src/main/java/com/ruoyi/service/impl/pdfGenerateService.java
index 8c8e306..d8cc7b7 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/impl/pdfGenerateService.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/impl/pdfGenerateService.java
@@ -7,10 +7,7 @@
 import com.itextpdf.text.Font;
 import com.itextpdf.text.Image;
 import com.itextpdf.text.Rectangle;
-import com.itextpdf.text.pdf.BaseFont;
-import com.itextpdf.text.pdf.PdfPCell;
-import com.itextpdf.text.pdf.PdfPTable;
-import com.itextpdf.text.pdf.PdfWriter;
+import com.itextpdf.text.pdf.*;
 import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.domain.ArchiveRecords;
 import com.ruoyi.domain.vo.DocumentMaterialFileStyle;
@@ -18,6 +15,7 @@
 import com.ruoyi.domain.vo.DocumentMaterialsVoSmall;
 import com.ruoyi.service.IArchiveRecordsService;
 import com.ruoyi.service.IDocumentMaterialsService;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.usermodel.*;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,6 +30,7 @@
 import java.time.LocalDate;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 
@@ -268,10 +267,79 @@
     }
 
 
+    // 鑷畾涔夐〉闈簨浠剁被锛岀敤浜庡湪姣忎釜鏂伴〉闈㈡坊鍔犲嵎鍐呭皝闈㈠唴瀹�
+    private class DirectoryHeaderPageEvent extends PdfPageEventHelper {
+        private String volumeNumber;
+        private byte[] barcodeImageBytes;
+        
+        public DirectoryHeaderPageEvent(String volumeNumber, byte[] barcodeImageBytes) {
+            this.volumeNumber = volumeNumber;
+            this.barcodeImageBytes = barcodeImageBytes;
+        }
+        
+        @Override
+        public void onStartPage(PdfWriter writer, Document document) {
+            try {
+                // 璁剧疆涓枃瀛椾綋
+                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);
+                
+                // 娣诲姞鏉″舰鐮�
+                Image img = Image.getInstance(barcodeImageBytes);
+                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[] columnWidths1 = {35f, 65f};
+                PdfPTable table1 = new PdfPTable(columnWidths1);
+                table1.setWidthPercentage(80);
+                table1.setHorizontalAlignment(Element.ALIGN_LEFT);
+                table1.setSpacingBefore(30f);
+                table1.addCell(pdfPCell);
+                
+                PdfContentByte canvas = writer.getDirectContent();
+                ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(" ", chineseFont), 
+                        document.left(), document.top() - 50, 0);
+                document.add(table1);
+                
+                // 娣诲姞鏍囬
+                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);
+                
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+    
     //瀵煎嚭鍗峰唴鐩綍鐨刾df
     public void generateFileDirectoryPdf(String pdfPath,List<DocumentMaterialsVo> dvss) throws DocumentException, IOException {
         Document document = new Document();
-        PdfWriter.getInstance(document, new FileOutputStream(pdfPath));
+        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(pdfPath));
+        
+        // 娣诲姞椤甸潰浜嬩欢锛屽湪姣忎釜鏂伴〉闈㈣嚜鍔ㄦ坊鍔犲嵎鍐呭皝闈㈠唴瀹�
+        String volumeNumber = dvss.get(0).getRecordId();
+        byte[] barcodeImageBytes = barcodeService.generateBarcodeImage(volumeNumber);
+        writer.setPageEvent(new DirectoryHeaderPageEvent(volumeNumber, barcodeImageBytes));
+        
         document.open();
 
         // 鍒涘缓琛ㄦ牸锛�5鍒楋級
@@ -279,56 +347,19 @@
 
         // 璁剧疆琛ㄦ牸瀹藉害锛堝崰椤甸潰瀹藉害鐨�100%锛�
         table.setWidthPercentage(100);
-
-
-        //娣诲姞鏉″舰鐮�
-        String volumeNumber = dvss.get(0).getRecordId();
-        Image img = Image.getInstance(barcodeService.generateBarcodeImage(volumeNumber));
-        // 璁剧疆鍥剧墖鍦≒DF涓殑浣嶇疆锛堝彲閫夛級
-//        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);
-
-
-        // 娣诲姞琛ㄥご
+        
+        // 璁剧疆鍒楀姣斾緥锛岀4鍒楋紙鏂囦欢棰樺悕锛夎缃緱鏇村
+        float[] columnWidths = {8f, 14f, 12f, 30f, 10f, 10f, 10f}; // 璋冩暣鍒楀姣斾緥锛岀4鍒楁枃浠堕鍚嶅崰40%
+        table.setWidths(columnWidths);
+        
+        // 璁剧疆涓枃瀛椾綋
         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);
+        // 璁剧疆琛ㄥご琛屾暟锛岃繖鏍峰垎椤垫椂姣忛〉閮戒細鑷姩閲嶅琛ㄥご
+        table.setHeaderRows(1);
+        
+        // 娣诲姞琛ㄥご
         String[] headers = {"搴忓彿", "鏂囦欢缂栧彿", "璐d换鑰�", "鏂囦欢棰樺悕", "鏃ユ湡", "椤靛彿", "澶囨敞"};
         for (String header : headers) {
             PdfPCell cell = new PdfPCell(new Paragraph(header,
@@ -496,8 +527,8 @@
         PdfWriter.getInstance(document, new FileOutputStream(pdfPath));
         document.open();
 
-        String [] tits = {"妗�        鍙�:","妗f棣�(瀹�)鍙�:","缂�  寰�  鍙�: ","鍙�  鏂�  鍙�:",
-                "妗�  鍗�  棰�  鍚�:","缂�  鍒�  鏃�  鏈�:","缂�  鍒�  鍗�  浣�:","淇�  绠�  鏈�  闄�:","瀵�     绾�:"};
+        String [] tits = {"妗e彿锛�","妗f棣�(瀹�)鍙凤細","缂╁井鍙凤細","鍙戞枃鍙凤細",
+                "妗堝嵎棰樺悕锛�","缂栧埗鏃ユ湡锛�","缂栧埗鍗曚綅锛�","淇濈鏈熼檺锛�","瀵嗙骇锛�"};
         ArchiveRecords ard = iArchiveRecordsService.selectArchiveRecordsById(id);
 
 
@@ -509,7 +540,7 @@
             ;
             System.out.println("褰撳墠鏃ユ湡: " + date);
 
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
       formattedDate = date.format(formatter);
         }
 
@@ -535,7 +566,7 @@
         float[] columnWidths = {35f, 65f}; // 绗竴鍒�30%锛岀浜屽垪70%
         PdfPTable table = new PdfPTable(columnWidths);
 //        PdfPTable table = new PdfPTable(2);
-        table.setWidthPercentage(80); // 澧炲ぇ琛ㄦ牸瀹藉害鐧惧垎姣�
+        table.setWidthPercentage(78); // 鍑忓皬琛ㄦ牸瀹藉害鐧惧垎姣斾娇涓ゅ垪鏇寸揣鍑�
         table.setHorizontalAlignment(Element.ALIGN_LEFT); // 璁剧疆琛ㄦ牸鏁翠綋灞呬腑
         table.setSpacingBefore(30f); // 璁剧疆琛ㄦ牸鍓嶉棿璺�
         table.setSpacingAfter(90f); // 璁剧疆琛ㄦ牸鍚庨棿璺�
@@ -559,12 +590,64 @@
 
 
 
+        // 鍏堣绠楁墍鏈夋爣棰樼殑鏈�闀块暱搴�
+        int maxTitleLength = 0;
+        for (String tit : tits) {
+            maxTitleLength = Math.max(maxTitleLength, tit.length()-1);
+        }
+        
         for(int i = 0; i < tits.length; i++) {
             // 浣跨敤PdfPTable瀹炵幇绮剧‘瀵归綈
 
             // 绗竴琛岋細妗e彿
-            PdfPCell labelCell1 = new PdfPCell(new Phrase(tits[i], chineseFont));
-            labelCell1.setHorizontalAlignment(Element.ALIGN_RIGHT); // 璁剧疆鍙冲榻�
+            // 瀹炵幇瀵归綈锛氬湪鏂囧瓧涔嬮棿濉厖绌烘牸锛屼娇鎵�鏈夋爣棰樻�婚暱搴︾浉鍚�
+            String originalText = tits[i];
+            
+            // 璁$畻闇�瑕佹坊鍔犵殑绌烘牸鏁�
+            int spacesToAdd = maxTitleLength - originalText.length();
+            
+            String formattedText = originalText;
+            if (spacesToAdd > 0) {
+                // 鍦ㄥ啋鍙峰墠鐨勬枃瀛椾箣闂村潎鍖�鍒嗛厤濉厖绌烘牸
+                if (originalText.contains("锛�")) {
+                    int colonIndex = originalText.indexOf("锛�");
+                    String textBeforeColon = originalText.substring(0, colonIndex);
+                    String textAfterColon = originalText.substring(colonIndex);
+                    
+                    // 濡傛灉鍐掑彿鍓嶅彧鏈変竴涓瓧绗︼紝鐩存帴鍦ㄥ悗闈㈠姞绌烘牸
+                    if (textBeforeColon.length() == 1) {
+                        String fullWidthSpaces = StringUtils.repeat("銆�", spacesToAdd);
+                        formattedText = textBeforeColon + fullWidthSpaces + textAfterColon;
+                    } else if (textBeforeColon.length() > 1) {
+                        // 鍦ㄦ枃瀛椾箣闂村潎鍖�鍒嗛厤绌烘牸
+                        StringBuilder sb = new StringBuilder();
+                        int chars = textBeforeColon.length();
+                        int spacesPerGap = spacesToAdd / (chars - 1);
+                        int extraSpaces = spacesToAdd % (chars - 1);
+                        
+                        for (int j = 0; j < chars; j++) {
+                            sb.append(textBeforeColon.charAt(j));
+                            if (j < chars - 1) {
+                                // 娣诲姞鍩烘湰绌烘牸
+                                sb.append(StringUtils.repeat("銆�", spacesPerGap));
+                                // 鍒嗛厤鍓╀綑绌烘牸
+                                if (j < extraSpaces) {
+                                    sb.append("銆�");
+                                }
+                            }
+                        }
+                        sb.append(textAfterColon);
+                        formattedText = sb.toString();
+                    }
+                } else {
+                    // 濡傛灉娌℃湁鍐掑彿锛岀洿鎺ュ湪鏈熬鍔犵┖鏍硷紙搴旇涓嶄細鍑虹幇杩欑鎯呭喌锛�
+                    String fullWidthSpaces = StringUtils.repeat("銆�", spacesToAdd);
+                    formattedText = originalText + fullWidthSpaces;
+                }
+            }
+            
+            PdfPCell labelCell1 = new PdfPCell(new Phrase(formattedText, chineseFont));
+            labelCell1.setHorizontalAlignment(Element.ALIGN_RIGHT); // 鍗曞厓鏍煎彸瀵归綈
 
             labelCell1.setBorder(Rectangle.NO_BORDER);
 //            PdfPCell valueCell1 = new PdfPCell(new Phrase(cons[i], chineseFont));
@@ -573,17 +656,18 @@
             labelCell1.setPaddingTop(10f);    // 涓婂唴杈硅窛10鍗曚綅
             labelCell1.setPaddingBottom(10f); // 涓嬪唴杈硅窛10鍗曚綅
             labelCell1.setPaddingLeft(15f);   // 宸﹀唴杈硅窛15鍗曚綅
-            labelCell1.setPaddingRight(15f);  // 鍙冲唴杈硅窛15鍗曚綅
+            labelCell1.setPaddingRight(0f);  // 鍙冲唴杈硅窛15鍗曚綅
 
 
             PdfPCell valueCell1 = new PdfPCell(new Phrase(cons[i], chineseFont));
             valueCell1.setBorder(Rectangle.NO_BORDER);
-            valueCell1.setUseBorderPadding(true);
+            valueCell1.setUseBorderPadding(false); // 绂佺敤杈规鍐呰竟璺濊绠�
             valueCell1.setBorderWidthBottom(0.5f); // 璁剧疆搴曢儴杈规浣滀负涓嬪垝绾�
             valueCell1.setMinimumHeight(30);
             valueCell1.setPaddingTop(10f);    // 涓婂唴杈硅窛10鍗曚綅
             valueCell1.setPaddingBottom(10f); // 涓嬪唴杈硅窛10鍗曚綅
-            valueCell1.setPaddingLeft(15f);   // 宸﹀唴杈硅窛15鍗曚綅
+            valueCell1.setPaddingLeft(0f);   // 宸﹀唴杈硅窛0鍗曚綅
+            valueCell1.setExtraParagraphSpace(0f); // 绉婚櫎娈佃惤棰濆绌洪棿
             valueCell1.setPaddingRight(15f);  // 鍙冲唴杈硅窛15鍗曚綅
             table.addCell(labelCell1);
             table.addCell(valueCell1);
@@ -598,7 +682,7 @@
                 PdfPCell pdfPCell1 = new PdfPCell(img1);
                 pdfPCell1.setBorder(Rectangle.NO_BORDER); // 绉婚櫎鍗曞厓鏍艰竟妗�
 
-                pdfPCell1.setMinimumHeight(40);
+                pdfPCell1.setMinimumHeight(20);
                 pdfPCell1.setUseAscender(true); // 璁剧疆鍙互灞呬腑
                 pdfPCell1.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); // 璁剧疆姘村钩灞呬腑
                 pdfPCell1.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); // 璁剧疆鍨傜洿灞呬腑
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java
index d3b1239..039f191 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java
@@ -599,7 +599,7 @@
 
             //pdf鐩綍灏侀潰
             String pdfPathF = "07-妗堝嵎灏侀潰.pdf";
-            pdfGenerateService.generatePdf(pdfPathF, 55L);
+            pdfGenerateService.generatePdf(pdfPathF, id);
             // 2. 鍘嬬缉PDF鍒癦IP鏂囦欢
                 // 娣诲姞PDF鏂囦欢鍒癦IP
                 ZipEntry zipEntry = new ZipEntry(pdfPathF);
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java
index 4daa4a4..eb1d918 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java
@@ -689,7 +689,7 @@
             sheet.setColumnWidth(column, 6000);
         } else {
             // 璁剧疆鍒楀
-            sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 200));
+            sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256));
         }
         // 濡傛灉璁剧疆浜嗘彁绀轰俊鎭垯榧犳爣鏀句笂鍘绘彁绀�.
         if (StringUtils.isNotEmpty(attr.prompt())) {
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java
index 53de95f..aa097a8 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java
@@ -302,42 +302,31 @@
 //sheet.setColumnWidth(1, 15 * 256); // 绗簩鍒楀搴�15瀛楃
 //sheet.setColumnWidth(2, 25 * 256); // 绗笁鍒楀搴�25瀛楃 // 璁剧疆绗竴鍒楀搴︿负20涓瓧绗�
 
-                    ClientAnchor anchor = new HSSFClientAnchor(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)));
+                    if (data != null && data.length > 0) {
+                        // 鍒涘缓鍗曞厓鏍�
+                        Cell qrCell = sheet.createRow(2).createCell(1);
+                        // 璁剧疆琛岄珮瓒冲楂樹互鏄剧ず浜岀淮鐮�
+                        sheet.getRow(2).setHeightInPoints(120);
+                        // 浜岀淮鐮侀渶瑕佽緝澶х殑鍒楀鏉ユ樉绀猴紝璁剧疆涔嬪墠鍏堜繚瀛樺綋鍓嶅垪瀹�
+                        int currentColumnWidth = sheet.getColumnWidth(1);
+                        // 璁剧疆瓒冲瀹界殑鍒楀浠ユ樉绀轰簩缁寸爜
+                        sheet.setColumnWidth(1, 60 * 256);
+                        
+                        // 鍒涘缓鍥剧墖閿氱偣锛岃缃湪绗�2琛岀2鍒�
+                        // 浜岀淮鐮佹樉绀哄湪鍙充笂瑙掍笖涓嶅~婊℃暣涓牸瀛�
+                        // 缂╁皬鍥剧墖鑼冨洿锛氬彧鍗犵敤閮ㄥ垎鍗曞厓鏍肩┖闂�
+                        ClientAnchor anchor = new HSSFClientAnchor(600, 20, 1000, 200, (short) 1, 2, (short) 1, 2);
+                        // 璁剧疆鍥剧墖浣嶇疆鍜屽ぇ灏�
+                        anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_DONT_RESIZE);
+                        
+                        // 娣诲姞鍥剧墖鍒板伐浣滆〃
+                        getDrawingPatriarch(sheet).createPicture(anchor,
+                                wb.addPicture(data, getImageType(data)));
+                        // 浜岀淮鐮佹坊鍔犲畬鎴愬悗锛屾仮澶嶅師鏉ョ殑鍒楀璁剧疆
+                        sheet.setColumnWidth(1, currentColumnWidth);
+                    }
 
 
 
@@ -370,9 +359,12 @@
                         row.setHeightInPoints(40); // 璁剧疆琛岄珮涓�20纾�
                        // row.createCell(0)
                         cell = row.createCell(0);
-                        //璁剧疆cell鐨勫搴�
-                        sheet.setColumnWidth(0, 20 * 256);
-                        sheet.setColumnWidth(1, 60 * 256); // 绗簩鍒楀搴�15瀛楃
+                        // 鏍规嵁鐢ㄦ埛闇�姹傝缃浜屽瓙琛ㄦ牸鐨勫垪瀹�
+                        // 绗竴鍒楀搴﹁缃负27
+                        // 绗簩鍒楀搴﹁缃负51
+                        // 浣跨敤涓巃ddCell鏂规硶鐩稿悓鐨勮绠楀叕寮忚缃垪瀹�
+                        sheet.setColumnWidth(0, (int) ((27 + 0.72) * 256)); // 绗竴鍒楋細瀹藉害27
+                        sheet.setColumnWidth(1, (int) ((51 + 0.72) * 256)); // 绗簩鍒楋細瀹藉害51
 
                         CellStyle style = wb.createCellStyle();
                         style.setAlignment(HorizontalAlignment.RIGHT);
@@ -391,7 +383,15 @@
                         style1.setWrapText(true); // 璁剧疆鑷姩鎹㈣
                         style1.setVerticalAlignment(VerticalAlignment.CENTER);
                         cel.setCellStyle(style1);
-                        cel.setCellValue(fieldValue.toString());
+                        
+                        // 澶勭悊鏃ユ湡鏍煎紡鍖栵紝鐗瑰埆鏄�"缂�  鍒�  鏃�  鏈�:"杩欎竴琛�
+                        if (i == 5 && fieldValue instanceof Date) {
+                            // 璁剧疆鏃ユ湡鏍煎紡涓簓yyy-MM-dd
+                            String dateStr = DateUtils.parseDateToStr("yyyy-MM-dd", (Date) fieldValue);
+                            cel.setCellValue(dateStr);
+                        } else {
+                            cel.setCellValue(fieldValue.toString());
+                        }
                       //  sheet.setColumnWidth(0, 60 * 256);
                         i++;
                         if(i==3)
@@ -403,30 +403,32 @@
                             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 HSSFClientAnchor(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)));
+                            if (dat != null && dat.length > 0) {
+                                // 鍒涘缓鍗曞厓鏍�
+                                Cell barcodeCell = sheet.createRow(9).createCell(0);
+                                // 璁剧疆琛岄珮瓒冲楂樹互鏄剧ず鏉″舰鐮�
+                                sheet.getRow(9).setHeightInPoints(70);
+                                // 璁剧疆鍒楀瓒冲瀹戒互鏄剧ず鏉″舰鐮侊紝鍏堜繚瀛樺綋鍓嶅垪瀹�
+                                int currentColumnWidth0 = sheet.getColumnWidth(0);
+                                sheet.setColumnWidth(0, 40 * 256);
+                                
+                                // 鍒涘缓鍥剧墖閿氱偣锛岃缃湪绗�10琛岀1鍒�
+                                // 鏉″舰鐮佸眳涓笖涓嶈秴鍑虹浜屼釜鏍煎瓙
+                                // 璋冩暣缁撴潫鍒楃储寮曞拰浣嶇疆鍙傛暟
+                                // 澧炲姞dx1鍊硷紝浣挎潯褰㈢爜鏁翠綋鍚戝彸绉诲姩
+                                ClientAnchor anchor1 = new HSSFClientAnchor(300, 50, 900, 200, (short) 0, 9, (short) 1, 10);
+                                // 璁剧疆鍥剧墖浣嶇疆鍜屽ぇ灏�
+                                anchor1.setAnchorType(ClientAnchor.AnchorType.MOVE_DONT_RESIZE);
+                                
+                                // 娣诲姞鍥剧墖鍒板伐浣滆〃
+                                getDrawingPatriarch(sheet).createPicture(anchor1,
+                                        wb.addPicture(dat, getImageType(dat)));
+                                
+                                // 鏉″舰鐮佹坊鍔犲畬鎴愬悗锛屾仮澶嶅師鏉ョ殑鍒楀璁剧疆
+                                sheet.setColumnWidth(0, currentColumnWidth0);
+                            }
 
 
 
@@ -765,9 +767,14 @@
             if (attr.isExport()) {
                 // 鍒涘缓cell
                 cell = row.createCell(column);
-                //璁剧疆cell鐨勫搴�
-                sheet.setColumnWidth(0, 20 * 256);
-                sheet.setColumnWidth(1, 60 * 256); // 绗簩鍒楀搴�15瀛楃
+                // 璁剧疆鍒楀锛屼娇鐢ˊExcel娉ㄨВ涓厤缃殑瀹藉害
+                if (column == 0) {
+                    // 绗竴鍒椾娇鐢ㄥ浐瀹氬搴�
+                    sheet.setColumnWidth(0, 20 * 256);
+                } else if (column == 1) {
+                    // 绗簩鍒椾娇鐢ˊExcel娉ㄨВ涓厤缃殑瀹藉害
+                    sheet.setColumnWidth(1, (int) ((attr.width() + 0.72) * 256));
+                }
 
                 CellStyle style = wb.createCellStyle();
 //                style.setAlignment(HorizontalAlignment.RIGHT);
@@ -775,7 +782,7 @@
                 style.setVerticalAlignment(VerticalAlignment.CENTER); // 璁剧疆鍨傜洿灞呬腑
                 //  style.setAlignment(VerticalAlignment.CENTER);
                 Font font = wb.createFont();
-                font.setBold(true);
+              //  font.setBold(true);
                 style.setFont(font);
                 style.setWrapText(true); // 璁剧疆鑷姩鎹㈣
 

--
Gitblit v1.9.1