From 5d91a329768a2a86e01e4b9b6bc6a2b939b87adb Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期五, 16 一月 2026 22:48:51 +0800
Subject: [PATCH] 修改了对应代码
---
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java | 69 ++++++
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java | 72 ++++++
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheet.java | 81 +++++++
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java | 140 ++++++++++---
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java | 65 ++++++
archiveManager/src/main/java/com/ruoyi/domain/ArchiveRecords.java | 2
archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java | 19 +
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java | 52 +++-
ruoyi-admin/src/main/resources/application.yml | 3
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetThird.java | 70 ++++++
archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java | 12
11 files changed, 505 insertions(+), 80 deletions(-)
diff --git a/archiveManager/src/main/java/com/ruoyi/domain/ArchiveRecords.java b/archiveManager/src/main/java/com/ruoyi/domain/ArchiveRecords.java
index 8c1c218..efcfbd9 100644
--- a/archiveManager/src/main/java/com/ruoyi/domain/ArchiveRecords.java
+++ b/archiveManager/src/main/java/com/ruoyi/domain/ArchiveRecords.java
@@ -47,7 +47,7 @@
}
// @Excel(name = "椤圭洰鍚嶇О", headerColor = IndexedColors.BLACK)
-
+ @Excel(name = "椤圭洰鍚嶇О", type = Excel.Type.IMPORT)
private String everyProjectName;
/** 妗堝嵎棰樺悕 */
@Excel(name = "妗堝嵎棰樺悕", headerColor = IndexedColors.RED, width = 10)
diff --git a/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java b/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java
index 56c7345..62fdbef 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java
@@ -96,11 +96,12 @@
if (StringUtils.isEmpty(categoryNumberStart) || StringUtils.isEmpty(categoryNumberEnd)) {
lqw.like(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId, archiveRecords.getRecordId());
}
- else {
+ // else {
lqw.
like(!StringUtils.isEmpty(archiveRecords.getInquiryNumber()), ArchiveRecords::getInquiryNumber, archiveRecords.getInquiryNumber())
.like(!StringUtils.isEmpty(archiveRecords.getCaseTitle()), ArchiveRecords::getCaseTitle, archiveRecords.getCaseTitle())
- .like(!StringUtils.isEmpty(archiveRecords.getPublicAttribute()), ArchiveRecords::getPublicAttribute, archiveRecords.getPublicAttribute())
+
+ .like(!StringUtils.isEmpty(archiveRecords.getPublicAttribute()), ArchiveRecords::getPublicAttribute, archiveRecords.getPublicAttribute())
.like(!StringUtils.isEmpty(archiveRecords.getPreparationUnit()), ArchiveRecords::getPreparationUnit, archiveRecords.getPreparationUnit())
.like(!StringUtils.isEmpty(archiveRecords.getRetentionPeriod()), ArchiveRecords::getRetentionPeriod, archiveRecords.getRetentionPeriod())
.like(!StringUtils.isEmpty(archiveRecords.getSecurityClassification()), ArchiveRecords::getSecurityClassification, archiveRecords.getSecurityClassification())
@@ -117,7 +118,7 @@
.like(!StringUtils.isEmpty(archiveRecords.getEveryProjectName()), ArchiveRecords::getEveryProjectName, archiveRecords.getEveryProjectName())
.like(!StringUtils.isEmpty(archiveRecords.getRemarks()), ArchiveRecords::getRemarks, archiveRecords.getRemarks());
- }
+ // }
if(archiveRecords.getIds()!=null)
lqw.in(ArchiveRecords::getId,new ArrayList<>(Arrays.asList(archiveRecords.getIds())));
@@ -387,8 +388,16 @@
for (ArchiveRecords archiveRecords : dataList) {
// physcialService.mySave(physcial);
archiveRecords.setRecordStatus("鏈綍鍏�");
+ System.out.println(archiveRecords.getProjectName());
LocalDateTime time = LocalDateTime.now();
-
+ String title = "";
+ if(archiveRecords.getConstructionUnit()!=null)
+ title = title +archiveRecords.getConstructionUnit();
+ if(archiveRecords.getConstructionAddress()!=null)
+ title = title + archiveRecords.getConstructionAddress();
+ if(archiveRecords.getProjectName()!=null)
+ title = title + archiveRecords.getProjectName();
+ archiveRecords.setCaseTitle(title);
Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant());
archiveRecords.setCreateTime(date);
this.mySave(archiveRecords);
@@ -410,7 +419,7 @@
// 鑾峰彇褰撳墠鐢ㄦ埛ID
Long userId = SecurityUtils.getUserId();
// 鍙互鍦ㄨ繖閲屼娇鐢╱serId杩涜鎺堟潈鎿嶄綔
- if(operator.equals("閫�鍥炵鐞嗗憳"))
+ if(operator.equals("閫�鍥炵鐞嗗憳")||status.equals("褰曞叆瀹屾垚"))
archiverecordstouserService.deleteArchiverecordstouserByRecordId(id, userId);
this.baseMapper.updateStatusById(status, id, date);
return 0;
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 6332a9e..94c885f 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java
@@ -26,10 +26,10 @@
public byte[] generateBarcodeImage(String barcodeText) {
try {
// 浣跨敤 BitMatrix 鐢熸垚绾潯鐮侊紝涓嶅寘鍚换浣曟枃瀛�
- BarcodeFormat format = BarcodeFormat.CODE_39; // 鏍规嵁鎮ㄧ殑鏉$爜绫诲瀷
+ BarcodeFormat format = BarcodeFormat.CODE_128; // 鏍规嵁鎮ㄧ殑鏉$爜绫诲瀷
// 鍒涘缓缂栫爜鍣�
- Code39Writer writer = new Code39Writer();
+ Code128Writer writer = new Code128Writer();
// 缂栫爜鍙傛暟
Map<EncodeHintType, Object> hints = new HashMap<>();
@@ -68,10 +68,12 @@
}
// 娣诲姞鑷畾涔夋枃瀛�
- g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
- RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
- Font font = new Font("Tahoma", Font.BOLD, 18);
+ Font font = new Font("Tahoma", Font.PLAIN, 20);
g2d.setFont(font);
FontMetrics fm = g2d.getFontMetrics();
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java
index 37b083b..9880289 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/DocumentMaterialsController.java
@@ -31,6 +31,7 @@
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.poi.ExcelExp;
@@ -509,7 +510,29 @@
System.out.println(compName+"--+"+sh_person);
// pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), id);
//鎷垮埌鐩稿叧鏁版嵁
- List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id));
+ // List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id));
+
+
+ List<DocumentMaterials> docAllInfo = documentMaterialsService.SelectAllRecordsByPageNumbersToList(id, archiveRecords.getPageCount());
+ if (docAllInfo==null||docAllInfo.isEmpty())
+ {
+ throw new RuntimeException("璇疯ˉ鍏呭畬鏁翠俊鎭紝鐒跺悗瀵煎嚭ISO鍖咃紒");
+ }
+ //鎶奃ocumentMaterils杞埌docs
+ // List<DocumentMaterialsVoLarge> docs = new ArrayList<>();
+ int texPages = 0;
+ int patPages = 0;
+ int picPages = 0;
+ for (DocumentMaterials mater : docAllInfo) {
+
+ if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("鏂囧瓧鏉愭枡"))
+ texPages++;
+ if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("鍥炬牱鏉愭枡"))
+ patPages++;
+ if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("鐓х墖鏉愭枡"))
+ picPages++;
+ }
+
LocalDate currentDate = LocalDate.now();
@@ -518,21 +541,8 @@
HashMap<String, Object> hs = new HashMap<String, Object>();
int allPages = 0;
- int texPages = 0;
- int picPages = 0;
- int patPages = 0;
- if(!dmfs.isEmpty())
- {
- for(DocumentMaterialFileStyle documentMaterialFileStyle:dmfs)
- {
- if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鏂囧瓧鏉愭枡"))
- texPages = documentMaterialFileStyle.getCnt();
- if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鍥炬牱鏉愭枡"))
- patPages = documentMaterialFileStyle.getCnt();
- if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鐓х墖鏉愭枡"))
- picPages = documentMaterialFileStyle.getCnt();
- }
- }
+
+
allPages = texPages + picPages + patPages;
hs.put("pages", allPages);
hs.put("patPages", patPages);
@@ -597,16 +607,24 @@
@PostMapping("/exportJuan/{id}")
public void exportJuanInfo(HttpServletResponse response, @PathVariable Long id) throws IOException {
+ System.out.println("+++++++++++++aaaaaaaaaaaaaaaaaa");
ArchiveRecords archiveRecords = iArchiveRecordsService.selectArchiveRecordsById(id);
+ System.out.println("+++++++++++++aaaaaaaaaaaaaaaaaa");
+
if(archiveRecords.getPageCount()==null)
return;
List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString(), archiveRecords.getPageCount());
+ System.out.println("+++++++++++++aaaaaaaaaaaaaaaaaa");
//鎷垮埌鍗峰唴鐩綍鐨別xcel
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());
+ System.out.println("+++++++++++++aaaaaaaaaaaaaaaaaa");
+
if(!dsvs.isEmpty()) {
+ System.out.println("+++++++++++++aaaaaaaaaaaaaaaaaa");
+
String recordId = dsvs.get(0).getRecordId();
byte[] imgr = barcodeService.generateBarcodeImage(recordId);
ExcelExp e1 = new ExcelExp("鍗峰唴鐩綍鏁版嵁", dsvs, DocumentMaterialsVo.class);
@@ -620,7 +638,7 @@
// System.out.println(dsvs);
// zos.putNextEntry(entr);
ByteOutputStream bos8 = new ByteOutputStream();
-
+ System.out.println("+++++++++++++aaaaaaaaaaaaaaaaaa");
util2.exportExcelManySheet(bos8, mysheet);
bos8.writeTo( response.getOutputStream());
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 d3900de..e461f45 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
@@ -527,6 +527,11 @@
//鎶奃ocumentMaterils杞埌docs
List<DocumentMaterialsVoLarge> docs = new ArrayList<>();
int nstar = 1;
+
+ //缁熻3涓潗鏂欑殑涓暟
+ int texPages = 0;
+ int picPages = 0;
+ int patPages = 0;
for (DocumentMaterials mater : docAllInfo) {
// physcialService.mySave(physcial);
DocumentMaterialsVoLarge docum = new DocumentMaterialsVoLarge();
@@ -534,6 +539,12 @@
docum.setRecordId(archiveRecords1.getRecordId());
docum.setNum(nstar++);
docs.add(docum);
+ if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("鏂囧瓧鏉愭枡"))
+ texPages++;
+ if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("鍥炬牱鏉愭枡"))
+ patPages++;
+ if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("鐓х墖鏉愭枡"))
+ picPages++;
}
@@ -623,7 +634,7 @@
dc.setHorizontalResolution((long) wdpi);
dc.setVerticalResolution((long) hdpi);
dc.setSizeType(sizeType);
- fileMap.put(dc.getPageNumber()+"", fp);
+ fileMap.put(dc.getPageNumber()+"", fileName1);
// dc.set
// 鏇存柊鏁版嵁搴�
// documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber, wid, hei, wdpi, hdpi, sz, fileName1, "jpg", recordId);
@@ -641,6 +652,11 @@
System.out.println(dc.getPageNumber());
String fip = fileMap.get(dc.getPageNumber().toString());
// 鍒涘缓 File 瀵硅薄
+ if (fip == null) {
+ // 琛ラ浂鍒�4浣嶏紙鏍规嵁浣犵殑闇�姹傝皟鏁翠綅鏁帮級
+ String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue());
+ fip = fileMap.get(paddedKey);
+ }
File fils = new File(fip);
// 浣跨敤 ImageIO 璇诲彇鍥剧墖
@@ -761,21 +777,21 @@
HashMap<String, Object> hs = new HashMap<String, Object>();
int allPages = 0;
- int texPages = 0;
- int picPages = 0;
- int patPages = 0;
- if(!dmfs.isEmpty())
- {
- for(DocumentMaterialFileStyle documentMaterialFileStyle:dmfs)
- {
- if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鏂囧瓧鏉愭枡"))
- texPages = documentMaterialFileStyle.getCnt();
- if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鍥炬牱鏉愭枡"))
- patPages = documentMaterialFileStyle.getCnt();
- if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鐓х墖鏉愭枡"))
- picPages = documentMaterialFileStyle.getCnt();
- }
- }
+// int texPages = 0;
+// int picPages = 0;
+// int patPages = 0;
+// if(!dmfs.isEmpty())
+// {
+// for(DocumentMaterialFileStyle documentMaterialFileStyle:dmfs)
+// {
+// if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鏂囧瓧鏉愭枡"))
+// texPages = documentMaterialFileStyle.getCnt();
+// if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鍥炬牱鏉愭枡"))
+// patPages = documentMaterialFileStyle.getCnt();
+// if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鐓х墖鏉愭枡"))
+// picPages = documentMaterialFileStyle.getCnt();
+// }
+// }
String compName = "骞垮窞鐩堝妗f绠$悊鏈夐檺鍏徃";
@@ -938,6 +954,9 @@
// 鍒涘缓PDF淇濆瓨閫夐」
com.aspose.cells.PdfSaveOptions pdfSaveOptions = new com.aspose.cells.PdfSaveOptions();
pdfSaveOptions.setCompliance(com.aspose.cells.PdfCompliance.PDF_A_1_B);
+ // 纭繚瀛椾綋宓屽叆鍒癙DF涓�
+
+
// 鍒涘缓涓存椂瀛楄妭杈撳嚭娴�
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -1090,11 +1109,21 @@
byte[] buf = new byte[1024];
for (DocumentMaterialsVoLarge dc : docs) {
String filePath = fileMap.get(dc.getPageNumber().toString());
- if(filePath==null)
- continue;
+
// filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/");
System.out.println(filePath);
+ if (filePath == null) {
+ // 琛ラ浂鍒�4浣嶏紙鏍规嵁浣犵殑闇�姹傝皟鏁翠綅鏁帮級
+ String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue());
+ filePath = fileMap.get(paddedKey);
+ }
+ if(filePath==null)
+ continue;
+
+ if(filePath.contains("profile"))
+ filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/");
+
File tempFile = new File(filePath);
//鍦ㄥ帇缂╁寘涓坊鍔犳枃浠跺す
@@ -1195,6 +1224,9 @@
//鎶奃ocumentMaterils杞埌docs
List<DocumentMaterialsVoLarge> docs = new ArrayList<>();
int nstar = 1;
+ int texPages = 0;
+ int patPages = 0;
+ int picPages = 0;
for (DocumentMaterials mater : docAllInfo) {
// physcialService.mySave(physcial);
DocumentMaterialsVoLarge docum = new DocumentMaterialsVoLarge();
@@ -1202,6 +1234,12 @@
docum.setRecordId(aIV.getRecordId());
docum.setNum(nstar++);
docs.add(docum);
+ if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("鏂囧瓧鏉愭枡"))
+ texPages++;
+ if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("鍥炬牱鏉愭枡"))
+ patPages++;
+ if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("鐓х墖鏉愭枡"))
+ picPages++;
}
System.out.println(docs.size()+"----009");
@@ -1293,7 +1331,9 @@
dc.setHorizontalResolution((long) wdpi);
dc.setVerticalResolution((long) hdpi);
dc.setSizeType(sizeType);
- fileMap.put(dc.getPageNumber()+"", fp);
+ System.out.println(fileName1);
+ System.out.println("gggggggggggggggg999999999999");
+ fileMap.put(dc.getPageNumber()+"", fileName1);
// dc.set
// 鏇存柊鏁版嵁搴�
// documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber, wid, hei, wdpi, hdpi, sz, fileName1, "jpg", recordId);
@@ -1310,6 +1350,12 @@
//鎷垮埌鍥惧儚灞炴��
System.out.println(dc.getPageNumber());
String fip = fileMap.get(dc.getPageNumber().toString());
+ // 濡傛灉鐩存帴鍖归厤澶辫触锛屽皾璇曡ˉ闆跺尮閰�
+ if (fip == null) {
+ // 琛ラ浂鍒�4浣嶏紙鏍规嵁浣犵殑闇�姹傝皟鏁翠綅鏁帮級
+ String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue());
+ fip = fileMap.get(paddedKey);
+ }
// 鍒涘缓 File 瀵硅薄
if(fip==null||fip.equals(""))
{
@@ -1317,6 +1363,7 @@
}
+
File file = new File(fip);
// 浣跨敤 ImageIO 璇诲彇鍥剧墖
@@ -1375,7 +1422,7 @@
//鍘嬬缉鏂囦欢
List<String> filePathList = paths;
//鎶奷ocmentMaterial杞负
- File file = compressedFileToZip(docs, dsvs, aIV, id, fileMap);
+ File file = compressedFileToZip(docs, dsvs, aIV, id, fileMap, texPages, patPages, picPages);
System.out.println(file.getName());
String fileName =aIV.getRecordId()+".zip";
@@ -1469,7 +1516,10 @@
// 鍘嬬缉鏂囦欢
- private File compressedFileToZip(List<DocumentMaterialsVoLarge> docs, List<DocumentMaterialsVo> dsvs, ArchiveInfoVo aIV, Long id, Map<String, String> fileMap) throws Exception {
+ private File compressedFileToZip(List<DocumentMaterialsVoLarge> docs, List<DocumentMaterialsVo> dsvs, ArchiveInfoVo aIV, Long id, Map<String, String> fileMap,
+ int texPages,
+ int patPages,
+ int picPages) throws Exception {
//鍘嬬缉鍖呭叿浣撳悕绉帮紙鎷兼帴鏃堕棿鎴抽槻姝㈤噸鍚嶏級
String datumName = "";
String zipFileName =dsvs.get(0).getDocumentNumber()+aIV.getRecordId()+ ".zip";
@@ -1493,7 +1543,7 @@
String pdf09Path = "09-澶囪�冭〃.pdf";
// pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), id);
//鎷垮埌鐩稿叧鏁版嵁
- List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id));
+ // List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id));
LocalDate currentDate = LocalDate.now();
@@ -1502,21 +1552,21 @@
HashMap<String, Object> hs = new HashMap<String, Object>();
int allPages = 0;
- int texPages = 0;
- int picPages = 0;
- int patPages = 0;
- if(!dmfs.isEmpty())
- {
- for(DocumentMaterialFileStyle documentMaterialFileStyle:dmfs)
- {
- if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鏂囧瓧鏉愭枡"))
- texPages = documentMaterialFileStyle.getCnt();
- if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鍥炬牱鏉愭枡"))
- patPages = documentMaterialFileStyle.getCnt();
- if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鐓х墖鏉愭枡"))
- picPages = documentMaterialFileStyle.getCnt();
- }
- }
+// int texPages = 0;
+// int picPages = 0;
+// int patPages = 0;
+// if(!docs.isEmpty())
+// {
+// for(DocumentMaterialsVoLarge documentMaterialFileStyle:docs)
+// {
+// if(documentMaterialFileStyle!=null&&documentMaterialFileStyle.getFileStyle().equals("鏂囧瓧鏉愭枡"))
+// texPages = documentMaterialFileStyle.getCnt();
+// if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鍥炬牱鏉愭枡"))
+// patPages = documentMaterialFileStyle.getCnt();
+// if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鐓х墖鏉愭枡"))
+// picPages = documentMaterialFileStyle.getCnt();
+// }
+// }
String compName = "骞垮窞鐩堝妗f绠$悊鏈夐檺鍏徃";
String li_person = "浠囩縺";
@@ -1850,8 +1900,7 @@
byte[] buf = new byte[1024];
for (DocumentMaterialsVoLarge dc : docs) {
String filePath = fileMap.get(dc.getPageNumber().toString());
- if(filePath==null)
- continue;
+
// else {
// // 鏂囦欢鍚嶇О
@@ -1883,7 +1932,20 @@
//
+ if (filePath == null) {
+ // 琛ラ浂鍒�4浣嶏紙鏍规嵁浣犵殑闇�姹傝皟鏁翠綅鏁帮級
+ String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue());
+ filePath = fileMap.get(paddedKey);
+ System.out.println(paddedKey);
+ }
+ System.out.println(filePath);
+
+ if(filePath==null)
+ continue;
+
+ if(filePath.contains("profile"))
+ filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/");
File tempFile = new File(filePath);
System.out.println(filePath);
diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml
index a2b9d8d..b28e398 100644
--- a/ruoyi-admin/src/main/resources/application.yml
+++ b/ruoyi-admin/src/main/resources/application.yml
@@ -25,6 +25,9 @@
uri-encoding: UTF-8
# 杩炴帴鏁版弧鍚庣殑鎺掗槦鏁帮紝榛樿涓�100
accept-count: 1000
+ connection-timeout: 150000 # 20绉�
+ keep-alive-timeout: 150000 # 闀胯繛鎺ヨ秴鏃�
+ max-keep-alive-requests: 100
threads:
# tomcat鏈�澶х嚎绋嬫暟锛岄粯璁や负200
max: 800
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
index 9880129..ba968f0 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
@@ -1149,7 +1149,7 @@
try
{
// 璁剧疆琛岄珮涓鸿嚜鍔ㄨ皟鏁�
- row.setHeight((short) -1);
+ // row.setHeight((short) -1);
// 鏍规嵁Excel涓缃儏鍐靛喅瀹氭槸鍚﹀鍑�,鏈変簺鎯呭喌闇�瑕佷繚鎸佷负绌�,甯屾湜鐢ㄦ埛濉啓杩欎竴鍒�.
if (attr.isExport())
{
@@ -1162,8 +1162,14 @@
sheet.addMergedRegion(new CellRangeAddress(subMergedFirstRowNum, subMergedLastRowNum, column, column));
}
}
- cell.setCellStyle(styles.get(StringUtils.format("data_{}_{}_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor(), attr.cellType(), attr.wrapText())));
-
+ // cell.setCellStyle(styles.get(StringUtils.format("data_{}_{}_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor(), attr.cellType(), attr.wrapText())));
+ // 鑾峰彇骞朵慨鏀规牱寮�
+ CellStyle style = styles.get(StringUtils.format("data_{}_{}_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor(), attr.cellType(), attr.wrapText()));
+ Workbook workbook = row.getSheet().getWorkbook();
+ CellStyle newStyle = workbook.createCellStyle();
+ newStyle.cloneStyleFrom(style);
+ newStyle.setWrapText(true); // 鍏抽敭锛氬惎鐢ㄨ嚜鍔ㄦ崲琛�
+ cell.setCellStyle(newStyle);
// 鐢ㄤ簬璇诲彇瀵硅薄涓殑灞炴��
Object value = getTargetValue(vo, field, attr);
String dateFormat = attr.dateFormat();
@@ -1201,6 +1207,8 @@
// 璁剧疆鍒楃被鍨�
setCellVo(value, attr, cell);
}
+ adjustRowHeightAfterSetValue(row, cell, value);
+
addStatisticsData(column, Convert.toStr(value), attr);
}
}
@@ -1210,7 +1218,65 @@
}
return cell;
}
+ /**
+ * 璁剧疆鍊煎悗璋冩暣琛岄珮
+ */
+ private void adjustRowHeightAfterSetValue(Row row, Cell cell, Object value) {
+ if (value == null) return;
+ String text = value.toString();
+ Sheet sheet = row.getSheet();
+
+ // 1. 璁$畻鑷姩楂樺害锛堝熀浜庡唴瀹癸級
+ short autoHeight = calculateSimpleAutoHeight(text, cell);
+
+ // 2. 鑾峰彇褰撳墠琛岄珮
+ short currentHeight = row.getHeight();
+ if (currentHeight == -1) {
+ currentHeight = sheet.getDefaultRowHeight();
+ }
+
+ // 3. 浣跨敤杈冨ぇ鐨勯珮搴︼紙鑷姩璁$畻鐨勯珮搴︽垨褰撳墠楂樺害锛�
+ short baseHeight = (short) Math.max(currentHeight, autoHeight);
+ System.out.println(baseHeight+"aaaaaaaaatttttttt");
+ // 4. 鍦ㄥ熀纭�涓婂鍔犻澶栭珮搴︼紙100鍗曚綅 = 5鐐癸級
+ short extraHeight = 80;
+ short newHeight = (short) (baseHeight + extraHeight);
+
+ // 5. 闄愬埗鏈�澶ч珮搴�
+ short maxHeight = (short) 4000; // 100鐐�
+ row.setHeight((short) Math.min(maxHeight,newHeight));
+ }
+
+ /**
+ * 绠�鍖栫殑鑷姩楂樺害璁$畻
+ */
+ private short calculateSimpleAutoHeight(String text, Cell cell) {
+ if (text == null || text.isEmpty()) return 0;
+
+ Sheet sheet = cell.getSheet();
+ int colIndex = cell.getColumnIndex();
+
+ // 鑾峰彇鍒楀锛堝瓧绗︽暟锛�
+ int colWidthChars = sheet.getColumnWidth(colIndex) / 256;
+ if (colWidthChars <= 0) colWidthChars = 10;
+
+ // 璁$畻鏂囨湰琛屾暟
+ int lines = 1;
+ if (text.contains("\n")) {
+ // 鏈夋樉寮忔崲琛�
+ String[] parts = text.split("\n");
+ for (String part : parts) {
+ lines += Math.max(1, (int) Math.ceil(part.length() * 1.5 / colWidthChars));
+ }
+ } else {
+ // 鑷姩鎹㈣
+ lines = (int) Math.ceil(text.length() * 1.5 / colWidthChars);
+ }
+
+ // 姣忚楂樺害锛氬亣璁�18鐐癸紙360 POI鍗曚綅锛�
+ return (short) (lines * 360);
+ }
/**
* 璁剧疆 POI XSSFSheet 鍗曞厓鏍兼彁绀烘垨閫夋嫨妗�
*
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheet.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheet.java
index 822c066..04a1881 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheet.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheet.java
@@ -325,7 +325,7 @@
// 濡傛灉鏄痠ndex涓�1鐨剆heet锛岃缃《绔爣棰樿
// 灏嗙1琛岋紙绱㈠紩涓�0锛夎缃负姣忛〉閲嶅鐨勬爣棰樿
- sheet.setRepeatingRows(CellRangeAddress.valueOf("$1:$4"));
+ sheet.setRepeatingRows(CellRangeAddress.valueOf("$1:$5"));
row = sheet.createRow(0);
row.setHeight((short) (37*20));
@@ -532,6 +532,10 @@
row = sheet.createRow(i + 5 );
else
row = sheet.createRow(i + 1 );
+ // 绗竴姝ワ細璁㏄OI鑷姩璁$畻閫傞厤鍐呭鐨勮楂�
+ // sheet.autoSizeRow(0);
+ // 绗簩姝ワ細鑾峰彇鑷姩璁$畻鍚庣殑琛岄珮
+
// 寰楀埌瀵煎嚭瀵硅薄.
T vo = (T) list.get(i);
@@ -542,7 +546,9 @@
// 璁剧疆瀹炰綋绫荤鏈夊睘鎬у彲璁块棶
field.setAccessible(true);
this.addCell(excel, row, vo, field, column++);
+
}
+
}
}
@@ -730,7 +736,7 @@
Cell cell = null;
try {
// 璁剧疆琛岄珮涓鸿嚜鍔ㄨ皟鏁�
- row.setHeight((short) -1);
+ // row.setHeight((short) -1);
// 鏍规嵁Excel涓缃儏鍐靛喅瀹氭槸鍚﹀鍑�,鏈変簺鎯呭喌闇�瑕佷繚鎸佷负绌�,甯屾湜鐢ㄦ埛濉啓杩欎竴鍒�.
if (attr.isExport()) {
// 鍒涘缓cell
@@ -745,7 +751,13 @@
} else if (align == HorizontalAlignment.RIGHT) {
styleKey = "data3";
}
- cell.setCellStyle(styles.get(styleKey));
+ // 鑾峰彇骞朵慨鏀规牱寮�
+ CellStyle style = styles.get(styleKey);
+ Workbook workbook = row.getSheet().getWorkbook();
+ CellStyle newStyle = workbook.createCellStyle();
+ newStyle.cloneStyleFrom(style);
+ newStyle.setWrapText(true); // 鍏抽敭锛氬惎鐢ㄨ嚜鍔ㄦ崲琛�
+ cell.setCellStyle(newStyle);
// 鐢ㄤ簬璇诲彇瀵硅薄涓殑灞炴��
Object value = getTargetValue(vo, field, attr);
@@ -762,6 +774,9 @@
// 璁剧疆鍒楃被鍨�
setCellVo(value, attr, cell);
}
+
+ adjustRowHeightAfterSetValue(row, cell, value);
+
addStatisticsData(column, Convert.toStr(value), attr);
}
} catch (Exception e) {
@@ -769,7 +784,65 @@
}
return cell;
}
+ /**
+ * 璁剧疆鍊煎悗璋冩暣琛岄珮
+ */
+ private void adjustRowHeightAfterSetValue(Row row, Cell cell, Object value) {
+ if (value == null) return;
+ String text = value.toString();
+ Sheet sheet = row.getSheet();
+
+ // 1. 璁$畻鑷姩楂樺害锛堝熀浜庡唴瀹癸級
+ short autoHeight = calculateSimpleAutoHeight(text, cell);
+
+ // 2. 鑾峰彇褰撳墠琛岄珮
+ short currentHeight = row.getHeight();
+ if (currentHeight == -1) {
+ currentHeight = sheet.getDefaultRowHeight();
+ }
+
+ // 3. 浣跨敤杈冨ぇ鐨勯珮搴︼紙鑷姩璁$畻鐨勯珮搴︽垨褰撳墠楂樺害锛�
+ short baseHeight = (short) Math.max(currentHeight, autoHeight);
+ System.out.println(baseHeight+"aaaaaaaaatttttttt");
+ // 4. 鍦ㄥ熀纭�涓婂鍔犻澶栭珮搴︼紙100鍗曚綅 = 5鐐癸級
+ short extraHeight = 80;
+ short newHeight = (short) (baseHeight + extraHeight);
+
+ // 5. 闄愬埗鏈�澶ч珮搴�
+ short maxHeight = (short) 4000; // 100鐐�
+ row.setHeight((short) Math.min(maxHeight,newHeight));
+ }
+
+ /**
+ * 绠�鍖栫殑鑷姩楂樺害璁$畻
+ */
+ private short calculateSimpleAutoHeight(String text, Cell cell) {
+ if (text == null || text.isEmpty()) return 0;
+
+ Sheet sheet = cell.getSheet();
+ int colIndex = cell.getColumnIndex();
+
+ // 鑾峰彇鍒楀锛堝瓧绗︽暟锛�
+ int colWidthChars = sheet.getColumnWidth(colIndex) / 256;
+ if (colWidthChars <= 0) colWidthChars = 10;
+
+ // 璁$畻鏂囨湰琛屾暟
+ int lines = 1;
+ if (text.contains("\n")) {
+ // 鏈夋樉寮忔崲琛�
+ String[] parts = text.split("\n");
+ for (String part : parts) {
+ lines += Math.max(1, (int) Math.ceil(part.length() * 1.5 / colWidthChars));
+ }
+ } else {
+ // 鑷姩鎹㈣
+ lines = (int) Math.ceil(text.length() * 1.5 / colWidthChars);
+ }
+
+ // 姣忚楂樺害锛氬亣璁�18鐐癸紙360 POI鍗曚綅锛�
+ return (short) (lines * 360);
+ }
/**
* 璁剧疆 POI HSSFSheet 鍗曞厓鏍兼彁绀�
*
@@ -1101,7 +1174,7 @@
// header.setFontName("瀹嬩綋");4
// header.setFontSize((short) 10);
// 璁剧疆椤电湁鍐呭
- hssfSheet.setMargin(Sheet.HeaderMargin, 1.34);
+ hssfSheet.setMargin(Sheet.HeaderMargin, 1.43);
header.setRight("&\"瀹嬩綋,Bold\"鍏� &N 椤� 绗� &P 椤�");
}
// 濡傛灉鏄痠ndex涓�1鐨剆heet锛岃缃《绔爣棰樿
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 99871c7..772777f 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
@@ -872,7 +872,7 @@
Cell cell = null;
try {
// 璁剧疆琛岄珮涓鸿嚜鍔ㄨ皟鏁�
- row.setHeight((short) -1);
+ // row.setHeight((short) -1);
// 鏍规嵁Excel涓缃儏鍐靛喅瀹氭槸鍚﹀鍑�,鏈変簺鎯呭喌闇�瑕佷繚鎸佷负绌�,甯屾湜鐢ㄦ埛濉啓杩欎竴鍒�.
if (attr.isExport()) {
// 鍒涘缓cell
@@ -887,7 +887,13 @@
} else if (align == HorizontalAlignment.RIGHT) {
styleKey = "data3";
}
- cell.setCellStyle(styles.get(styleKey));
+ // 鑾峰彇骞朵慨鏀规牱寮�
+ CellStyle style = styles.get(styleKey);
+ Workbook workbook = row.getSheet().getWorkbook();
+ CellStyle newStyle = workbook.createCellStyle();
+ newStyle.cloneStyleFrom(style);
+ newStyle.setWrapText(true); // 鍏抽敭锛氬惎鐢ㄨ嚜鍔ㄦ崲琛�
+ cell.setCellStyle(newStyle);
// 鐢ㄤ簬璇诲彇瀵硅薄涓殑灞炴��
Object value = getTargetValue(vo, field, attr);
@@ -904,6 +910,7 @@
// 璁剧疆鍒楃被鍨�
setCellVo(value, attr, cell);
}
+ adjustRowHeightAfterSetValue(row, cell, value);
addStatisticsData(column, Convert.toStr(value), attr);
}
} catch (Exception e) {
@@ -911,7 +918,65 @@
}
return cell;
}
+ /**
+ * 璁剧疆鍊煎悗璋冩暣琛岄珮
+ */
+ private void adjustRowHeightAfterSetValue(Row row, Cell cell, Object value) {
+ if (value == null) return;
+ String text = value.toString();
+ Sheet sheet = row.getSheet();
+
+ // 1. 璁$畻鑷姩楂樺害锛堝熀浜庡唴瀹癸級
+ short autoHeight = calculateSimpleAutoHeight(text, cell);
+
+ // 2. 鑾峰彇褰撳墠琛岄珮
+ short currentHeight = row.getHeight();
+ if (currentHeight == -1) {
+ currentHeight = sheet.getDefaultRowHeight();
+ }
+
+ // 3. 浣跨敤杈冨ぇ鐨勯珮搴︼紙鑷姩璁$畻鐨勯珮搴︽垨褰撳墠楂樺害锛�
+ short baseHeight = (short) Math.max(currentHeight, autoHeight);
+ System.out.println(baseHeight+"aaaaaaaaatttttttt");
+ // 4. 鍦ㄥ熀纭�涓婂鍔犻澶栭珮搴︼紙100鍗曚綅 = 5鐐癸級
+ short extraHeight = 80;
+ short newHeight = (short) (baseHeight + extraHeight);
+
+ // 5. 闄愬埗鏈�澶ч珮搴�
+ short maxHeight = (short) 4000; // 100鐐�
+ row.setHeight((short) Math.min(maxHeight,newHeight));
+ }
+
+ /**
+ * 绠�鍖栫殑鑷姩楂樺害璁$畻
+ */
+ private short calculateSimpleAutoHeight(String text, Cell cell) {
+ if (text == null || text.isEmpty()) return 0;
+
+ Sheet sheet = cell.getSheet();
+ int colIndex = cell.getColumnIndex();
+
+ // 鑾峰彇鍒楀锛堝瓧绗︽暟锛�
+ int colWidthChars = sheet.getColumnWidth(colIndex) / 256;
+ if (colWidthChars <= 0) colWidthChars = 10;
+
+ // 璁$畻鏂囨湰琛屾暟
+ int lines = 1;
+ if (text.contains("\n")) {
+ // 鏈夋樉寮忔崲琛�
+ String[] parts = text.split("\n");
+ for (String part : parts) {
+ lines += Math.max(1, (int) Math.ceil(part.length() * 1.5 / colWidthChars));
+ }
+ } else {
+ // 鑷姩鎹㈣
+ lines = (int) Math.ceil(text.length() * 1.5 / colWidthChars);
+ }
+
+ // 姣忚楂樺害锛氬亣璁�18鐐癸紙360 POI鍗曚綅锛�
+ return (short) (lines * 360);
+ }
/**
* 璁剧疆鍗曞厓鏍兼彁绀�
*
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 06cfcbc..909e88e 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
@@ -419,7 +419,7 @@
System.out.println(declaredFields.length);
int i = 0;
for (Field field : declaredFields) {
- if(i==8)
+ if(i==9)
break;
// 璁剧疆瀛楁鐨勮闂潈闄愶紝浠ヤ究浜庤闂鏈夊瓧娈�
field.setAccessible(true);
@@ -902,7 +902,7 @@
Cell cell = null;
try {
// 璁剧疆琛岄珮涓鸿嚜鍔ㄨ皟鏁�
- row.setHeight((short) -1);
+ // row.setHeight((short) -1);
// 鏍规嵁Excel涓缃儏鍐靛喅瀹氭槸鍚﹀鍑�,鏈変簺鎯呭喌闇�瑕佷繚鎸佷负绌�,甯屾湜鐢ㄦ埛濉啓杩欎竴鍒�.
if (attr.isExport()) {
// 鍒涘缓cell
@@ -946,6 +946,9 @@
// 璁剧疆鍒楃被鍨�
setCellVo(value, attr, cell);
}
+
+ adjustRowHeightAfterSetValue(row, cell, value);
+
addStatisticsData(column, Convert.toStr(value), attr);
}
} catch (Exception e) {
@@ -953,7 +956,65 @@
}
return cell;
}
+ /**
+ * 璁剧疆鍊煎悗璋冩暣琛岄珮
+ */
+ private void adjustRowHeightAfterSetValue(Row row, Cell cell, Object value) {
+ if (value == null) return;
+ String text = value.toString();
+ Sheet sheet = row.getSheet();
+
+ // 1. 璁$畻鑷姩楂樺害锛堝熀浜庡唴瀹癸級
+ short autoHeight = calculateSimpleAutoHeight(text, cell);
+
+ // 2. 鑾峰彇褰撳墠琛岄珮
+ short currentHeight = row.getHeight();
+ if (currentHeight == -1) {
+ currentHeight = sheet.getDefaultRowHeight();
+ }
+
+ // 3. 浣跨敤杈冨ぇ鐨勯珮搴︼紙鑷姩璁$畻鐨勯珮搴︽垨褰撳墠楂樺害锛�
+ short baseHeight = (short) Math.max(currentHeight, autoHeight);
+ System.out.println(baseHeight+"aaaaaaaaatttttttt");
+ // 4. 鍦ㄥ熀纭�涓婂鍔犻澶栭珮搴︼紙100鍗曚綅 = 5鐐癸級
+ short extraHeight = 80;
+ short newHeight = (short) (baseHeight + extraHeight);
+
+ // 5. 闄愬埗鏈�澶ч珮搴�
+ short maxHeight = (short) 4000; // 100鐐�
+ row.setHeight((short) Math.min(maxHeight,newHeight));
+ }
+
+ /**
+ * 绠�鍖栫殑鑷姩楂樺害璁$畻
+ */
+ private short calculateSimpleAutoHeight(String text, Cell cell) {
+ if (text == null || text.isEmpty()) return 0;
+
+ Sheet sheet = cell.getSheet();
+ int colIndex = cell.getColumnIndex();
+
+ // 鑾峰彇鍒楀锛堝瓧绗︽暟锛�
+ int colWidthChars = sheet.getColumnWidth(colIndex) / 256;
+ if (colWidthChars <= 0) colWidthChars = 10;
+
+ // 璁$畻鏂囨湰琛屾暟
+ int lines = 1;
+ if (text.contains("\n")) {
+ // 鏈夋樉寮忔崲琛�
+ String[] parts = text.split("\n");
+ for (String part : parts) {
+ lines += Math.max(1, (int) Math.ceil(part.length() * 1.5 / colWidthChars));
+ }
+ } else {
+ // 鑷姩鎹㈣
+ lines = (int) Math.ceil(text.length() * 1.5 / colWidthChars);
+ }
+
+ // 姣忚楂樺害锛氬亣璁�18鐐癸紙360 POI鍗曚綅锛�
+ return (short) (lines * 360);
+ }
/**
* 璁剧疆 POI HSSFSheet 鍗曞厓鏍兼彁绀�
*
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetThird.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetThird.java
index 842daf6..f2404ff 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetThird.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetThird.java
@@ -628,7 +628,7 @@
Cell cell = null;
try {
// 璁剧疆琛岄珮涓鸿嚜鍔ㄨ皟鏁�
- row.setHeight((short) -1);
+ // row.setHeight((short) -1);
// 鏍规嵁Excel涓缃儏鍐靛喅瀹氭槸鍚﹀鍑�,鏈変簺鎯呭喌闇�瑕佷繚鎸佷负绌�,甯屾湜鐢ㄦ埛濉啓杩欎竴鍒�.
if (attr.isExport()) {
// 鍒涘缓cell
@@ -643,7 +643,13 @@
} else if (align == HorizontalAlignment.RIGHT) {
styleKey = "data3";
}
- cell.setCellStyle(styles.get(styleKey));
+ // 鑾峰彇骞朵慨鏀规牱寮�
+ CellStyle style = styles.get(styleKey);
+ Workbook workbook = row.getSheet().getWorkbook();
+ CellStyle newStyle = workbook.createCellStyle();
+ newStyle.cloneStyleFrom(style);
+ newStyle.setWrapText(true); // 鍏抽敭锛氬惎鐢ㄨ嚜鍔ㄦ崲琛�
+ cell.setCellStyle(newStyle);
// 鐢ㄤ簬璇诲彇瀵硅薄涓殑灞炴��
Object value = getTargetValue(vo, field, attr);
@@ -660,6 +666,8 @@
// 璁剧疆鍒楃被鍨�
setCellVo(value, attr, cell);
}
+ adjustRowHeightAfterSetValue(row, cell, value);
+
addStatisticsData(column, Convert.toStr(value), attr);
}
} catch (Exception e) {
@@ -667,7 +675,65 @@
}
return cell;
}
+ /**
+ * 璁剧疆鍊煎悗璋冩暣琛岄珮
+ */
+ private void adjustRowHeightAfterSetValue(Row row, Cell cell, Object value) {
+ if (value == null) return;
+ String text = value.toString();
+ Sheet sheet = row.getSheet();
+
+ // 1. 璁$畻鑷姩楂樺害锛堝熀浜庡唴瀹癸級
+ short autoHeight = calculateSimpleAutoHeight(text, cell);
+
+ // 2. 鑾峰彇褰撳墠琛岄珮
+ short currentHeight = row.getHeight();
+ if (currentHeight == -1) {
+ currentHeight = sheet.getDefaultRowHeight();
+ }
+
+ // 3. 浣跨敤杈冨ぇ鐨勯珮搴︼紙鑷姩璁$畻鐨勯珮搴︽垨褰撳墠楂樺害锛�
+ short baseHeight = (short) Math.max(currentHeight, autoHeight);
+ System.out.println(baseHeight+"aaaaaaaaatttttttt");
+ // 4. 鍦ㄥ熀纭�涓婂鍔犻澶栭珮搴︼紙100鍗曚綅 = 5鐐癸級
+ short extraHeight = 80;
+ short newHeight = (short) (baseHeight + extraHeight);
+
+ // 5. 闄愬埗鏈�澶ч珮搴�
+ short maxHeight = (short) 4000; // 100鐐�
+ row.setHeight((short) Math.min(maxHeight,newHeight));
+ }
+
+ /**
+ * 绠�鍖栫殑鑷姩楂樺害璁$畻
+ */
+ private short calculateSimpleAutoHeight(String text, Cell cell) {
+ if (text == null || text.isEmpty()) return 0;
+
+ Sheet sheet = cell.getSheet();
+ int colIndex = cell.getColumnIndex();
+
+ // 鑾峰彇鍒楀锛堝瓧绗︽暟锛�
+ int colWidthChars = sheet.getColumnWidth(colIndex) / 256;
+ if (colWidthChars <= 0) colWidthChars = 10;
+
+ // 璁$畻鏂囨湰琛屾暟
+ int lines = 1;
+ if (text.contains("\n")) {
+ // 鏈夋樉寮忔崲琛�
+ String[] parts = text.split("\n");
+ for (String part : parts) {
+ lines += Math.max(1, (int) Math.ceil(part.length() * 1.5 / colWidthChars));
+ }
+ } else {
+ // 鑷姩鎹㈣
+ lines = (int) Math.ceil(text.length() * 1.5 / colWidthChars);
+ }
+
+ // 姣忚楂樺害锛氬亣璁�18鐐癸紙360 POI鍗曚綅锛�
+ return (short) (lines * 360);
+ }
/**
* 璁剧疆 POI HSSFSheet 鍗曞厓鏍兼彁绀�
*
--
Gitblit v1.9.1