fix(缺陷管理): 修改缺陷管理导出的xlsx文件命名格式
--bug=1036464 --user=宋天阳 【缺陷管理】导出缺陷文件名称错误 https://www.tapd.cn/55049933/s/1467203
This commit is contained in:
parent
b6b7f45075
commit
67d56687c0
|
@ -14,6 +14,8 @@ import java.util.Map;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BugExportHeaderModel {
|
||||
//xlsx文件前缀
|
||||
private String xlsxFileNamePrefix;
|
||||
|
||||
/**
|
||||
* 导出的表头列
|
||||
|
|
|
@ -49,11 +49,11 @@ public class BugExportService {
|
|||
int index = 1;
|
||||
while (list.size() > BATCH_PROCESS_QUANTITY) {
|
||||
List<BugDTO> excelBugList = list.subList(0, BATCH_PROCESS_QUANTITY);
|
||||
this.generateExcelFile(excelBugList, index, filesFolder, headerModel);
|
||||
this.generateExcelFile(excelBugList, headerModel.getXlsxFileNamePrefix() + index + ".xlsx", filesFolder, headerModel);
|
||||
list.removeAll(excelBugList);
|
||||
index += 1;
|
||||
}
|
||||
this.generateExcelFile(list, index, filesFolder, headerModel);
|
||||
this.generateExcelFile(list, headerModel.getXlsxFileNamePrefix() + index + ".xlsx", filesFolder, headerModel);
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(e.getMessage());
|
||||
throw new MSException(e.getMessage());
|
||||
|
@ -61,7 +61,7 @@ public class BugExportService {
|
|||
return filesFolder;
|
||||
}
|
||||
|
||||
private void generateExcelFile(List<BugDTO> list, int fileIndex, String excelPath, BugExportHeaderModel headerModel) throws Exception {
|
||||
private void generateExcelFile(List<BugDTO> list, String xlsxFileName, String excelPath, BugExportHeaderModel headerModel) throws Exception {
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
// 准备数据 {评论, 内容, 关联用例数}
|
||||
boolean exportComment = this.exportComment(headerModel.getExportColumns());
|
||||
|
@ -84,7 +84,7 @@ public class BugExportService {
|
|||
|
||||
//生成excel文件
|
||||
List<List<String>> data = bugExportExcelModel.getData();
|
||||
File createFile = new File(excelPath + File.separatorChar + "bug_" + fileIndex + ".xlsx");
|
||||
File createFile = new File(excelPath + File.separatorChar + xlsxFileName);
|
||||
createFile.createNewFile();
|
||||
|
||||
EasyExcel.write(createFile).excelType(ExcelTypeEnum.XLSX).sheet("sheet").doWrite(data);
|
||||
|
|
|
@ -1334,8 +1334,13 @@ public class BugService {
|
|||
Map<String, String> statusMap = statusOption.stream().collect(Collectors.toMap(SelectOption::getValue, SelectOption::getText));
|
||||
// 表头自定义字段
|
||||
List<TemplateCustomFieldDTO> headerCustomFields = getHeaderCustomFields(request.getProjectId());
|
||||
ExportUtils exportUtils = new ExportUtils(bugs, BugExportHeaderModel.builder().exportColumns(request.getExportColumns()).headerCustomFields(headerCustomFields)
|
||||
.handleUserMap(handleUserMap).statusMap(statusMap).build());
|
||||
String xlsxFileNamePrefix = "MeterSphere_bug_" + project.getName() + "_";
|
||||
ExportUtils exportUtils = new ExportUtils(bugs,
|
||||
BugExportHeaderModel.builder()
|
||||
.exportColumns(request.getExportColumns())
|
||||
.headerCustomFields(headerCustomFields)
|
||||
.handleUserMap(handleUserMap).statusMap(statusMap)
|
||||
.xlsxFileNamePrefix(xlsxFileNamePrefix).build());
|
||||
// 导出
|
||||
byte[] bytes = exportUtils.exportToZipFile(bugExportService::generateExcelFiles);
|
||||
String zipName = "MeterSphere_bug_" + URLEncoder.encode(project.getName(), StandardCharsets.UTF_8) + ".zip";
|
||||
|
|
Loading…
Reference in New Issue