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) 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 = "责任者", height = 10, width=8,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE) @Excel(name = "责任者", width=8,headerColor = IndexedColors.BLACK, headerBackgroundColor = IndexedColors.WHITE) private String creator; @Excel(name = "文件题名", height = 8,headerColor = IndexedColors.RED, headerBackgroundColor = IndexedColors.WHITE) 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>", 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); } 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()); //根据档号查询,是否已经有档号,有的话,就不让插入 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); } } 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(); ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveRecordsController.java
@@ -356,10 +356,11 @@ //拿到caseTitle和inquiryNumber 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); } 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; /** * 【请填写功能名称】Controller * 【签名的接口】Controller * * @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) 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); // 先设为自动,由addCell计算后覆盖 // 得到导出对象. 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 单元格提示 * 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. 限制最大高度 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. 限制最大高度