From 84ea2ba899a2a82c48a51a3ea0f76b0d0475c947 Mon Sep 17 00:00:00 2001 From: sunxiqing <2240398334@qq.com> Date: Mon, 30 Dec 2024 16:29:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=88=E5=B9=B6=E7=9B=B8?= =?UTF-8?q?=E5=90=8C=E5=86=85=E5=AE=B9=E7=9A=84=E5=8D=95=E5=85=83=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataset/DatasetQuestionController.java | 39 +++++++------------ 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/dataset/DatasetQuestionController.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/dataset/DatasetQuestionController.java index 693b6e55c..3e0f42522 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/dataset/DatasetQuestionController.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/dataset/DatasetQuestionController.java @@ -80,6 +80,7 @@ public class DatasetQuestionController { row.createCell(0).setCellValue("问题内容"); row.createCell(1).setCellValue("标注内容"); count++; + List id = new ArrayList<>(); pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); List list = datasetQuestionService.getDatasetQuestionPage(pageReqVO).getList(); for (DatasetQuestionRespVO item : list){ @@ -90,37 +91,23 @@ public class DatasetQuestionController { row = sheet.createRow(count); row.createCell(0).setCellValue(question); row.createCell(1).setCellValue(""); + id.add(count); count++; - } - for (String s : collect){ - row = sheet.createRow(count); - row.createCell(0).setCellValue(question); - row.createCell(1).setCellValue(s); - count++; + }else { + for (String s : collect) { + row = sheet.createRow(count); + row.createCell(0).setCellValue(question); + row.createCell(1).setCellValue(s); + count++; + } + id.add(count-1); } } //合并相同内容的单元格 - int startRow = 0; - // 上一次的值 - String lastValue = null; - for (int i = 0; i < count; i++) { - HSSFRow row1 = sheet.getRow(i); - String question = row1.getCell(0).getStringCellValue(); - if (!question.equals(lastValue)) { - // 如果当前值与上一次值不同,并且不是第一行,则合并之前的区域 - // 确保合并区域至少有两个单元格 - if (i > 0 && startRow != i - 1) { - sheet.addMergedRegion(new CellRangeAddress(startRow, i - 1, 0, 0)); - } - startRow = i; + for (int i = 0; i < id.size() - 1; i++){ + if (id.get(i+1)-id.get(i)>1) { + sheet.addMergedRegion(new CellRangeAddress(id.get(i)+1, id.get(i + 1), 0, 0)); } - - lastValue = question; - } - - // 处理最后一段合并区域,确保最后一段合并区域至少有两个单元格 - if (count > 0 && startRow != count - 1) { - sheet.addMergedRegion(new CellRangeAddress(startRow, count - 1, 0, 0)); } // 导出 Excel try {