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