refactor(yudao-module-llm): 重构数据集导出 Excel 功能
- 修改表格列标题,增加 "system" 列,调整 "question" 和 "answer" 列的位置 - 更新单元格合并逻辑,确保 "system" 列和 "question" 列正确合并 - 优化代码结构,提高可读性和可维护性
This commit is contained in:
parent
64f5c3fe93
commit
af72c50150
@ -80,33 +80,40 @@ public class DatasetQuestionController {
|
||||
int count = 0;
|
||||
List<Integer> id = new ArrayList<>();
|
||||
HSSFRow row = sheet.createRow(count);
|
||||
row.createCell(0).setCellValue("问题内容");
|
||||
row.createCell(0).setCellValue("system");
|
||||
row.getCell(0).setCellStyle(cellStyle);
|
||||
row.createCell(1).setCellValue("标注内容");
|
||||
row.createCell(1).setCellValue("question");
|
||||
row.getCell(1).setCellStyle(cellStyle);
|
||||
row.createCell(2).setCellValue("answer");
|
||||
row.getCell(2).setCellStyle(cellStyle);
|
||||
id.add(count);
|
||||
count++;
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DatasetQuestionRespVO> list = datasetQuestionService.getDatasetQuestionPage(pageReqVO).getList();
|
||||
for (DatasetQuestionRespVO item : list){
|
||||
String system = item.getSystem();
|
||||
String question = item.getQuestion();
|
||||
List<DatasetAnswerRespVO> datasetAnswerRespVO = item.getDatasetAnswerRespVO();
|
||||
List<String> collect = datasetAnswerRespVO.stream().map(DatasetAnswerRespVO::getAnswer).collect(Collectors.toList());
|
||||
if (collect.size() == 0){
|
||||
row = sheet.createRow(count);
|
||||
row.createCell(0).setCellValue(question);
|
||||
row.createCell(0).setCellValue(system);
|
||||
row.getCell(0).setCellStyle(cellStyle);
|
||||
row.createCell(1).setCellValue("");
|
||||
row.createCell(1).setCellValue(question);
|
||||
row.getCell(1).setCellStyle(cellStyle);
|
||||
row.createCell(2).setCellValue("");
|
||||
row.getCell(2).setCellStyle(cellStyle);
|
||||
id.add(count);
|
||||
count++;
|
||||
}else {
|
||||
for (String s : collect) {
|
||||
row = sheet.createRow(count);
|
||||
row.createCell(0).setCellValue(question);
|
||||
row.createCell(0).setCellValue(system);
|
||||
row.getCell(0).setCellStyle(cellStyle);
|
||||
row.createCell(1).setCellValue(s);
|
||||
row.createCell(1).setCellValue(question);
|
||||
row.getCell(1).setCellStyle(cellStyle);
|
||||
row.createCell(2).setCellValue(s);
|
||||
row.getCell(2).setCellStyle(cellStyle);
|
||||
count++;
|
||||
}
|
||||
id.add(count-1);
|
||||
@ -115,7 +122,7 @@ public class DatasetQuestionController {
|
||||
//合并相同内容的单元格
|
||||
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));
|
||||
sheet.addMergedRegion(new CellRangeAddress(id.get(i)+1, id.get(i + 1), 0, 1));
|
||||
}
|
||||
}
|
||||
// 导出 Excel
|
||||
|
Loading…
x
Reference in New Issue
Block a user