From ca4b62abd2560b6dcffbf3ff43da1b04427b494b Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期二, 20 一月 2026 12:36:47 +0800
Subject: [PATCH] 增加了签名和注解
---
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java | 6
archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveSignatureServiceImpl.java | 78 +++++++++-
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheet.java | 246 ++++++++++++++++++++++++++--------
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetSecond.java | 8
archiveManager/src/main/java/com/ruoyi/mapper/ArchiveRecordsMapper.java | 2
archiveManager/src/main/java/com/ruoyi/domain/ArchiveRecords.java | 12 +
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveRecordsController.java | 7
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveSignatureController.java | 14 +-
archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java | 2
archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVo.java | 6
archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java | 10
11 files changed, 292 insertions(+), 99 deletions(-)
diff --git a/archiveManager/src/main/java/com/ruoyi/domain/ArchiveRecords.java b/archiveManager/src/main/java/com/ruoyi/domain/ArchiveRecords.java
index efcfbd9..4eeb80b 100644
--- a/archiveManager/src/main/java/com/ruoyi/domain/ArchiveRecords.java
+++ b/archiveManager/src/main/java/com/ruoyi/domain/ArchiveRecords.java
@@ -22,6 +22,18 @@
{
private static final long serialVersionUID = 1L;
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ @TableField(exist = false)
+
+ private String userName;
+
/** $column.columnComment */
@TableId(type = IdType.AUTO)
diff --git a/archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVo.java b/archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVo.java
index a57d577..bbaabc2 100644
--- a/archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVo.java
+++ b/archiveManager/src/main/java/com/ruoyi/domain/vo/DocumentMaterialsVo.java
@@ -12,11 +12,11 @@
public class DocumentMaterialsVo {
- @Excel(name="搴忓彿", height = 10,width=8,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE)
+ @Excel(name="搴忓彿", width=8,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE)
private Long num;
- @Excel(name = "鏂囦欢缂栧彿", height = 10, width=8,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE)
+ @Excel(name = "鏂囦欢缂栧彿", width=8,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE)
private String documentNumber;
- @Excel(name = "璐d换鑰�", height = 10, width=8,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE)
+ @Excel(name = "璐d换鑰�", width=8,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE)
private String creator;
@Excel(name = "鏂囦欢棰樺悕", height = 8,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE)
diff --git a/archiveManager/src/main/java/com/ruoyi/mapper/ArchiveRecordsMapper.java b/archiveManager/src/main/java/com/ruoyi/mapper/ArchiveRecordsMapper.java
index 85eba54..657a572 100644
--- a/archiveManager/src/main/java/com/ruoyi/mapper/ArchiveRecordsMapper.java
+++ b/archiveManager/src/main/java/com/ruoyi/mapper/ArchiveRecordsMapper.java
@@ -31,7 +31,7 @@
@Select({
"<script>",
- "SELECT distinct c.*,a.archive_records_id, if(a.user_id=#{userId}, TRUE, FALSE) as tst,b.user_id FROM archiverecordstouser a inner join sys_user b ON a.user_id = b.user_id right join archive_records c on c.id=a.archive_records_id ${ew.customSqlSegment} ",
+ "SELECT distinct c.*,a.archive_records_id, if(a.user_id=#{userId}, TRUE, FALSE) as tst,b.user_id,b.user_name FROM archiverecordstouser a inner join sys_user b ON a.user_id = b.user_id right join archive_records c on c.id=a.archive_records_id ${ew.customSqlSegment} ",
"<if test= \"userId !=1 \">",
"order by tst desc",
"</if>",
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 fe99738..a63f8e4 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveRecordsServiceImpl.java
@@ -76,7 +76,7 @@
List<String> recordIds = new ArrayList<>();
for (int i = startNum; i <= endNum; i++) {
// 浣跨敤String.format灏嗘暟瀛楁牸寮忓寲涓�5浣嶏紝涓嶈冻鍓嶉潰琛�0
- String formattedNumber = String.format("%05d", i);
+ String formattedNumber = String.format("%04d", i);
recordIds.add(prefixStart + formattedNumber);
}
diff --git a/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveSignatureServiceImpl.java b/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveSignatureServiceImpl.java
index e326d78..9cd91b5 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveSignatureServiceImpl.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveSignatureServiceImpl.java
@@ -1,23 +1,24 @@
package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.MapUtils;
import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.domain.ArchiveCategory;
-import com.ruoyi.domain.ArchiveSignature;
-import com.ruoyi.domain.Archiverecordstouser;
+import com.ruoyi.domain.*;
import com.ruoyi.mapper.ArchiveSignatureMapper;
import com.ruoyi.mapper.ArchiverecordstouserMapper;
import com.ruoyi.service.IArchiveSignatureService;
import com.ruoyi.service.IArchiverecordstouserService;
+import com.ruoyi.util.ErrorcodeExceptionextends;
import org.springframework.stereotype.Service;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.*;
+
@Service
public class ArchiveSignatureServiceImpl extends ServiceImpl<ArchiveSignatureMapper, ArchiveSignature> implements IArchiveSignatureService {
@@ -54,7 +55,13 @@
@Override
public ArchiveSignature selectArchiveSignatureById(Long id) {
- return null;
+ LambdaQueryWrapper<ArchiveSignature> lqw = new LambdaQueryWrapper<>();
+ lqw.eq(id!=null, ArchiveSignature::getId, id);
+ List<ArchiveSignature> lists = this.list(lqw);
+ if(!lists.isEmpty())
+ return lists.get(0);
+ else
+ return null;
}
@Override
@@ -64,21 +71,70 @@
@Override
public int insertArchiveSignature(ArchiveSignature archiveSignature) {
- return 0;
+ LocalDateTime time = LocalDateTime.now();
+ if(archiveSignature.getSigaName()==null||StringUtils.isEmpty(archiveSignature.getSigaName()))
+ throw new RuntimeException("绛惧悕淇℃伅涓嶈兘涓虹┖锛�");
+ Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant());
+ archiveSignature.setCreateTime(date);
+ // System.out.println(archiveRecords.getRecordId());
+ //鏍规嵁妗e彿鏌ヨ锛屾槸鍚﹀凡缁忔湁妗e彿锛屾湁鐨勮瘽锛屽氨涓嶈鎻掑叆
+ LambdaQueryWrapper<ArchiveSignature> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+ lambdaQueryWrapper.eq(!StringUtils.isEmpty(archiveSignature.getSigaName()), ArchiveSignature::getSigaName,
+ archiveSignature.getSigaName());
+ List<ArchiveSignature> lis = list(lambdaQueryWrapper);
+ if(!lis.isEmpty())
+ {
+ return 0;
+ }
+ // archiveRecords.setRecordStatus("鏈綍鍏�");
+ // archiveRecords
+ boolean res = this.save(archiveSignature);
+
+ //0琛ㄧず澶辫触锛�1琛ㄧず鎴愬姛
+ if(res)
+ return 1;
+ else
+ return 0;
}
@Override
public int updateArchiveSignature(ArchiveSignature archiveSignature) {
- return 0;
+
+ boolean result = false;
+ try {
+ // 浣跨敤LambdaUpdateWrapper鏋勯�犳洿鏂版潯浠讹紝纭繚null鍊间篃鑳芥洿鏂板埌鏁版嵁搴�
+ LambdaUpdateWrapper<ArchiveSignature> updateWrapper = new LambdaUpdateWrapper<>();
+ updateWrapper.eq(ArchiveSignature::getId, archiveSignature.getId());
+
+ // 鏄庣‘璁剧疆闇�瑕佹洿鏂扮殑瀛楁
+ updateWrapper.set(ArchiveSignature::getSigaName, archiveSignature.getSigaName());
+ updateWrapper.set(ArchiveSignature::getCreateTime, archiveSignature.getCreateTime());
+
+ // 鎵ц鏇存柊鎿嶄綔
+ result = update(updateWrapper);
+ } catch (Exception e) {
+ System.out.println(e);
+ throw new ErrorcodeExceptionextends(500, "涓嶅厑璁哥鍚嶄俊鎭噸澶嶏紒");
+ }
+ if(result)
+ return 1;
+ else
+ return 0;
+
}
@Override
public int deleteArchiveSignatureByIds(Long[] ids) {
- return 0;
+ if (this.removeByIds(Arrays.asList(ids))) {
+ return 1;
+ }
+ else
+ return 0;
+
}
@Override
public int deleteArchiveSignatureById(Long id) {
- return 0;
+ return this.baseMapper.deleteById(id);
}
}
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 86f8bf1..a717baf 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java
@@ -26,17 +26,17 @@
public byte[] generateBarcodeImage(String barcodeText) {
try {
// 浣跨敤 BitMatrix 鐢熸垚绾潯鐮侊紝涓嶅寘鍚换浣曟枃瀛�
- BarcodeFormat format = BarcodeFormat.CODE_128; // 鏍规嵁鎮ㄧ殑鏉$爜绫诲瀷
+ BarcodeFormat format = BarcodeFormat.CODE_39; // 鏍规嵁鎮ㄧ殑鏉$爜绫诲瀷
// 鍒涘缓缂栫爜鍣�
- Code128Writer writer = new Code128Writer();
+ Code39Writer writer = new Code39Writer();
// 缂栫爜鍙傛暟
Map<EncodeHintType, Object> hints = new HashMap<>();
hints.put(EncodeHintType.MARGIN, 0); // 鏃犺竟妗�
// 鐢熸垚 BitMatrix锛堢函鏉$爜锛屾棤鏂囧瓧锛�
- BitMatrix matrix = writer.encode(barcodeText, format, 0, 63, hints);
+ BitMatrix matrix = writer.encode(barcodeText, format, 230, 63, hints);
int width = matrix.getWidth();
int height = matrix.getHeight();
@@ -73,7 +73,7 @@
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.PLAIN, 20);
+ Font font = new Font("Tahoma", Font.PLAIN, 18);
g2d.setFont(font);
FontMetrics fm = g2d.getFontMetrics();
@@ -150,7 +150,7 @@
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.PLAIN, 20);
+ Font font = new Font("Tahoma", Font.PLAIN, 18);
g2d.setFont(font);
FontMetrics fm = g2d.getFontMetrics();
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveRecordsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveRecordsController.java
index b8122fa..0750e84 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveRecordsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveRecordsController.java
@@ -356,10 +356,11 @@
//鎷垮埌caseTitle鍜宨nquiryNumber
String inquiryNumber = "";
String caseTitle = "";
- if (!arsi.isEmpty()) {
- inquiryNumber = arsi.get(0).getInquiryNumber();
- caseTitle = arsi.get(0).getCaseTitle();
+ if (archiveRecords!=null) {
+ inquiryNumber = archiveRecords.getInquiryNumber();
+ caseTitle = archiveRecords.getCaseTitle();
}
+ System.out.println(inquiryNumber+"---"+caseTitle);
util3.exportExcelManySheet(response, mysheet1, searSigAnn.getIncludeQrCode(), bt, arrLis, arrAn, inquiryNumber, caseTitle);
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveSignatureController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveSignatureController.java
index c4f2f81..d370152 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveSignatureController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveSignatureController.java
@@ -30,7 +30,7 @@
import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE;
/**
- * 銆愯濉啓鍔熻兘鍚嶇О銆慍ontroller
+ * 銆愮鍚嶇殑鎺ュ彛銆慍ontroller
*
* @author ruoyi
* @date 2026-01-19
@@ -43,7 +43,7 @@
private IArchiveSignatureService archiveSignatureService;
/**
- * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛�
+ * 鏌ヨ绛惧悕鍒楄〃
*/
@PreAuthorize("@ss.hasPermi('system:signature:list')")
@GetMapping("/list")
@@ -57,7 +57,7 @@
}
/**
- * 瀵煎嚭銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛�
+ * 瀵煎嚭绛惧悕鍒楄〃
*/
@PreAuthorize("@ss.hasPermi('system:signature:export')")
@Log(title = "銆愯濉啓鍔熻兘鍚嶇О銆�", businessType = BusinessType.EXPORT)
@@ -70,7 +70,7 @@
}
/**
- * 鑾峰彇銆愯濉啓鍔熻兘鍚嶇О銆戣缁嗕俊鎭�
+ * 鑾峰彇绛惧悕璇︾粏淇℃伅
*/
@PreAuthorize("@ss.hasPermi('system:signature:query')")
@GetMapping(value = "/{id}")
@@ -80,7 +80,7 @@
}
/**
- * 鏂板銆愯濉啓鍔熻兘鍚嶇О銆�
+ * 鏂板绛惧悕
*/
@PreAuthorize("@ss.hasPermi('system:signature:add')")
@Log(title = "銆愯濉啓鍔熻兘鍚嶇О銆�", businessType = BusinessType.INSERT)
@@ -91,7 +91,7 @@
}
/**
- * 淇敼銆愯濉啓鍔熻兘鍚嶇О銆�
+ * 淇敼绛惧悕
*/
@PreAuthorize("@ss.hasPermi('system:signature:edit')")
@Log(title = "銆愯濉啓鍔熻兘鍚嶇О銆�", businessType = BusinessType.UPDATE)
@@ -102,7 +102,7 @@
}
/**
- * 鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆�
+ * 鍒犻櫎绛惧悕
*/
@PreAuthorize("@ss.hasPermi('system:signature:remove')")
@Log(title = "銆愯濉啓鍔熻兘鍚嶇О銆�", businessType = BusinessType.DELETE)
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 04a1881..1a6397a 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
@@ -527,6 +527,8 @@
public void fillExcelData(int index, Row row) {
// int startNo = index * sheetSize;
// int endNo = Math.min(startNo + sheetSize, list.size());
+
+ int startRow = (index == 1) ? 5 : 1;
for (int i = 0; i < list.size(); i++) {
if(index==1)
row = sheet.createRow(i + 5 );
@@ -536,6 +538,7 @@
// sheet.autoSizeRow(0);
// 绗簩姝ワ細鑾峰彇鑷姩璁$畻鍚庣殑琛岄珮
+ // row.setHeight((short) -1); // 鍏堣涓鸿嚜鍔紝鐢盿ddCell璁$畻鍚庤鐩�
// 寰楀埌瀵煎嚭瀵硅薄.
T vo = (T) list.get(i);
@@ -548,10 +551,180 @@
this.addCell(excel, row, vo, field, column++);
}
-
+ // 鎵归噺璋冩暣琛岄珮锛堟暟鎹~鍏呭畬鎴愬悗锛�
+ if (list.size() > 0) {
+ int lastRow = startRow + list.size() - 1;
+ batchAdjustRowHeights(sheet, startRow, lastRow);
+ }
}
}
+ /**
+ * 鎵归噺澶勭悊琛岄珮锛堝湪鏁版嵁濉厖瀹屾垚鍚庣粺涓�璁$畻锛�
+ */
+ /**
+ * 鎵归噺澶勭悊琛岄珮锛堝湪鏁版嵁濉厖瀹屾垚鍚庣粺涓�璁$畻锛�
+ */
+ private String getCellStringValue(Cell cell) {
+ if (cell == null) return null;
+ switch (cell.getCellType()) {
+ case STRING:
+ return cell.getStringCellValue();
+ case NUMERIC:
+ return String.valueOf(cell.getNumericCellValue());
+ case BOOLEAN:
+ return String.valueOf(cell.getBooleanCellValue());
+ case FORMULA:
+ try {
+ return cell.getStringCellValue();
+ } catch (Exception e) {
+ return String.valueOf(cell.getNumericCellValue());
+ }
+ default:
+ return null;
+ }
+ }
+ private void batchAdjustRowHeights(Sheet sheet, int startRow, int endRow) {
+ Workbook workbook = sheet.getWorkbook();
+
+
+ for (int rowNum = startRow; rowNum <= endRow; rowNum++) {
+ Row row = sheet.getRow(rowNum);
+ if (row == null) continue;
+
+ int maxLinesInRow = 1; // 璁板綍璇ヨ鎵�鏈夊崟鍏冩牸涓殑鏈�澶ц鏁�
+
+ // 绗竴姝ワ細閬嶅巻璇ヨ鐨勬墍鏈夊崟鍏冩牸锛屾壘鍒版渶澶ц鏁伴渶姹�
+ for (int colNum = 0; colNum < row.getLastCellNum(); colNum++) {
+ Cell cell = row.getCell(colNum);
+ if (cell == null) continue;
+
+ // 鑾峰彇鍗曞厓鏍煎唴瀹�
+ String content = getCellStringValue(cell);
+ if (content == null || content.isEmpty()) continue;
+
+ // 鑾峰彇鍒楀
+ int columnWidth = sheet.getColumnWidth(colNum) / 256;
+ if (columnWidth <= 0) columnWidth = 10; // 榛樿鍒楀
+
+ // 璁$畻璇ュ崟鍏冩牸鍐呭闇�瑕佺殑琛屾暟
+ int contentLines = calculateContentLines(content, columnWidth);
+
+ // 鏇存柊鏈�澶ц鏁�
+ maxLinesInRow = Math.max(maxLinesInRow, contentLines);
+ }
+
+ // 绗簩姝ワ細鏍规嵁鏈�澶ц鏁拌缃楂橈紙鍏抽敭淇锛�
+ if (maxLinesInRow > 1) {
+ // 鍩虹琛岄珮锛氫竴琛屾枃鏈殑楂樺害
+ int baseHeightPerLine = 400; // 20鐐� = 400鍗曚綅锛堝缓璁�硷級
+
+ // 璁$畻鎬婚珮搴� = 琛屾暟 脳 姣忚楂樺害
+ int newHeight = maxLinesInRow * baseHeightPerLine + 600;
+
+ // 闄愬埗鏈�灏忓拰鏈�澶ч珮搴�
+ int minHeight = 300; // 15鐐�
+ int maxHeight = 10000; // 500鐐�
+ newHeight = Math.max(minHeight, Math.min(newHeight, maxHeight));
+
+ // 璁剧疆琛岄珮
+ row.setHeight((short) newHeight);
+
+ // 鍙�夛細璁板綍璋冩暣淇℃伅鐢ㄤ簬璋冭瘯
+ log.debug("Row {} adjusted: maxLines={}, height={}",
+ rowNum, maxLinesInRow, newHeight);
+ }
+ }
+ }
+ /**
+ * 璁$畻鏂囨湰鐨勬湁鏁堝瓧绗﹀搴�
+ */
+ private double calculateEffectiveWidth(String text) {
+ if (text == null || text.isEmpty()) {
+ return 0;
+ }
+
+ double totalWidth = 0;
+
+ for (char c : text.toCharArray()) {
+ if (isChineseChar(c)) {
+ // 涓枃瀛楃锛�1.0瀹藉害
+ totalWidth += 2.0;
+ } else if (Character.isDigit(c)) {
+ // 鏁板瓧锛�0.6瀹藉害
+ totalWidth += 0.6;
+ } else if (Character.isUpperCase(c)) {
+ // 澶у啓瀛楁瘝锛�0.7瀹藉害
+ totalWidth += 0.7;
+ } else if (Character.isLowerCase(c)) {
+ // 灏忓啓瀛楁瘝锛�0.5瀹藉害
+ totalWidth += 0.5;
+ } else if (c == '.' || c == ',') {
+ // 鐐瑰彿銆侀�楀彿锛�0.3瀹藉害
+ totalWidth += 0.3;
+ } else if (c == '-' || c == '_') {
+ // 杩炲瓧绗︺�佷笅鍒掔嚎锛�0.35瀹藉害
+ totalWidth += 0.35;
+ } else if (c == ' ') {
+ // 绌烘牸锛�0.3瀹藉害
+ totalWidth += 0.3;
+ } else if (c == '\t') {
+ // 鍒惰〃绗︼細4.0瀹藉害
+ totalWidth += 4.0;
+ } else {
+ // 鍏朵粬瀛楃锛氶粯璁�0.6瀹藉害
+ totalWidth += 0.6;
+ }
+ }
+
+ return totalWidth;
+ }
+ /**
+ * 璁$畻鍗曞厓鏍煎唴瀹规墍闇�琛屾暟锛堟洿绮剧‘鐨勭増鏈級
+ */
+ private int calculateContentLines(String content, int columnWidthChars) {
+ if (content == null || content.isEmpty() || columnWidthChars <= 0) {
+ return 1;
+ }
+
+ int totalLines = 0;
+ String[] lines = content.split("\n");
+
+ for (String line : lines) {
+ if (line.trim().isEmpty()) {
+ totalLines++; // 绌鸿涔熺畻涓�琛�
+ continue;
+ }
+
+ // 璁$畻璇ヨ闇�瑕佺殑瀛楃瀹藉害
+ // 鑰冭檻涓嫳鏂囧瓧绗﹀搴﹀樊寮�
+ double effectiveLength = 0;
+
+
+ effectiveLength += calculateEffectiveWidth(line); // 涓枃瀛楃鍗�1涓搴�
+
+
+
+ // 璁$畻闇�瑕佺殑琛屾暟
+ int linesForText = (int) Math.ceil(effectiveLength / columnWidthChars);
+ totalLines += Math.max(1, linesForText);
+ }
+
+ return Math.max(totalLines, 1);
+ }
+
+ /**
+ * 鍒ゆ柇鏄惁涓轰腑鏂囧瓧绗�
+ */
+ private boolean isChineseChar(char c) {
+ Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
+ return ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
+ || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
+ || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
+ || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
+ || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
+ || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS;
+ }
/**
* 鍒涘缓琛ㄦ牸鏍峰紡
*
@@ -736,7 +909,7 @@
Cell cell = null;
try {
// 璁剧疆琛岄珮涓鸿嚜鍔ㄨ皟鏁�
- // row.setHeight((short) -1);
+ row.setHeight((short) -1);
// 鏍规嵁Excel涓缃儏鍐靛喅瀹氭槸鍚﹀鍑�,鏈変簺鎯呭喌闇�瑕佷繚鎸佷负绌�,甯屾湜鐢ㄦ埛濉啓杩欎竴鍒�.
if (attr.isExport()) {
// 鍒涘缓cell
@@ -751,6 +924,7 @@
} else if (align == HorizontalAlignment.RIGHT) {
styleKey = "data3";
}
+ System.out.println(styleKey);
// 鑾峰彇骞朵慨鏀规牱寮�
CellStyle style = styles.get(styleKey);
Workbook workbook = row.getSheet().getWorkbook();
@@ -775,8 +949,16 @@
setCellVo(value, attr, cell);
}
- adjustRowHeightAfterSetValue(row, cell, value);
+ System.out.println(row.getHeight());
+// // adjustRowHeightAfterSetValue(row, cell, value);
+// int defaultRowHeight = row.getHeight() / 20; // 鍘熷琛岄珮锛堣浆鎴愮偣鏁帮級
+// if(value==null)
+// value="";
+// System.out.println(sheet.getColumnWidth(column));
+// int contentLines = getContentLines(value.toString(), sheet.getColumnWidth(column), style); // 璁$畻鎹㈣鍚庣殑琛屾暟
+// int newHeight = defaultRowHeight * contentLines; // 鎸夎鏁拌皟鏁磋楂橈紙鍙姞灏戦噺鍐椾綑锛�
+// row.setHeightInPoints((short) (newHeight)); // 鎻愰珮琛岄珮锛�+2 鏄啑浣欙紝閬垮厤鍐呭琚埅鏂級
addStatisticsData(column, Convert.toStr(value), attr);
}
} catch (Exception e) {
@@ -784,65 +966,7 @@
}
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/ExcelUtilManySheetFour.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java
index 772777f..48b3263 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
@@ -893,7 +893,7 @@
CellStyle newStyle = workbook.createCellStyle();
newStyle.cloneStyleFrom(style);
newStyle.setWrapText(true); // 鍏抽敭锛氬惎鐢ㄨ嚜鍔ㄦ崲琛�
- cell.setCellStyle(newStyle);
+ cell.setCellStyle(style);
// 鐢ㄤ簬璇诲彇瀵硅薄涓殑灞炴��
Object value = getTargetValue(vo, field, attr);
@@ -910,7 +910,7 @@
// 璁剧疆鍒楃被鍨�
setCellVo(value, attr, cell);
}
- adjustRowHeightAfterSetValue(row, cell, value);
+ adjustRowHeightAfterSetValue(row, cell, value);
addStatisticsData(column, Convert.toStr(value), attr);
}
} catch (Exception e) {
@@ -940,7 +940,7 @@
short baseHeight = (short) Math.max(currentHeight, autoHeight);
System.out.println(baseHeight+"aaaaaaaaatttttttt");
// 4. 鍦ㄥ熀纭�涓婂鍔犻澶栭珮搴︼紙100鍗曚綅 = 5鐐癸級
- short extraHeight = 80;
+ short extraHeight = 20;
short newHeight = (short) (baseHeight + extraHeight);
// 5. 闄愬埗鏈�澶ч珮搴�
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 909e88e..1268870 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
@@ -347,7 +347,7 @@
printSetup.setLandscape(false); // 绾靛悜鎵撳嵃
sheet.setMargin(Sheet.LeftMargin, 1.04);
sheet.setMargin(Sheet.RightMargin, 1.04);
- sheet.setMargin(Sheet.TopMargin, 0.97);
+ sheet.setMargin(Sheet.TopMargin, 1.18);
sheet.setMargin(Sheet.BottomMargin, 0.97);
//鎷垮埌鍥剧墖
// 鍒涘缓鍗曞厓鏍煎苟娣诲姞鍥剧墖
@@ -702,7 +702,7 @@
else
row = sheet.createRow(i + 1 );
- row.setHeightInPoints(40); // 璁剧疆琛岄珮涓�20纾�
+ // row.setHeightInPoints(40); // 璁剧疆琛岄珮涓�20纾�
// row.createCell(0)
// 寰楀埌瀵煎嚭瀵硅薄.
@@ -976,9 +976,9 @@
// 3. 浣跨敤杈冨ぇ鐨勯珮搴︼紙鑷姩璁$畻鐨勯珮搴︽垨褰撳墠楂樺害锛�
short baseHeight = (short) Math.max(currentHeight, autoHeight);
- System.out.println(baseHeight+"aaaaaaaaatttttttt");
+ System.out.println(autoHeight+"-----"+currentHeight+"-----"+baseHeight+"aaaaaaaaatttttttt");
// 4. 鍦ㄥ熀纭�涓婂鍔犻澶栭珮搴︼紙100鍗曚綅 = 5鐐癸級
- short extraHeight = 80;
+ short extraHeight = (short) 20;
short newHeight = (short) (baseHeight + extraHeight);
// 5. 闄愬埗鏈�澶ч珮搴�
--
Gitblit v1.9.1