fix(测试计划): 修复文件名称过长问题

This commit is contained in:
WangXu10 2024-08-13 11:41:06 +08:00 committed by Craftsman
parent 579e032de2
commit 9357d86adc
4 changed files with 13 additions and 10 deletions

View File

@ -28,5 +28,7 @@ public class TestPlanCaseExecuteHistoryDTO extends TestPlanCaseExecuteHistory {
@Schema(description = "测试计划id")
private String testPlanId;
@Schema(description = "编辑模式")
private String caseEditType;
}

View File

@ -119,9 +119,11 @@
ux.avatar as userLogo,
tp.name as testPlanName,
tp.id as testPlanId,
u.email as email
u.email as email,
functional_case.case_edit_type as caseEditType
FROM
test_plan_case_execute_history tpceh
left join functional_case on tpceh.case_id = functional_case.id
left join user u on tpceh.create_user = u.id
left join user_extend ux on tpceh.create_user = ux.id
left join test_plan tp on tpceh.test_plan_id = tp.id

View File

@ -429,7 +429,6 @@ public class FunctionalCaseFileService {
*/
public String exportFunctionalCaseZip(FunctionalCaseExportRequest request, String userId) {
File tmpDir = null;
Project project = projectMapper.selectByPrimaryKey(request.getProjectId());
String fileType = "";
try {
tmpDir = new File(LocalRepositoryDir.getSystemTempDir() + File.separatorChar + EXPORT_CASE_TMP_DIR + "_" + IDGenerator.nextStr());
@ -443,10 +442,10 @@ public class FunctionalCaseFileService {
return null;
}
// 生成EXCEL
batchExcels = generateCaseExportExcel(batchExcels, ids, tmpDir.getPath(), request, project);
batchExcels = generateCaseExportExcel(batchExcels, ids, tmpDir.getPath(), request);
if (batchExcels.size() > 1) {
// EXCEL -> ZIP (EXCEL数目大于1)
File zipFile = CompressUtils.zipFilesToPath(tmpDir.getPath() + File.separatorChar + "Metersphere_case_" + project.getName() + ".zip", batchExcels);
File zipFile = CompressUtils.zipFilesToPath(tmpDir.getPath() + File.separatorChar + request.getFileId() + ".zip", batchExcels);
fileType = ZIP;
uploadFileToMinio(fileType, zipFile, request.getFileId());
} else {
@ -467,12 +466,12 @@ public class FunctionalCaseFileService {
ExportMsgDTO exportMsgDTO = new ExportMsgDTO(request.getFileId(), taskId, ids.size(), true, MsgType.EXEC_RESULT.name());
ExportWebSocketHandler.sendMessageSingle(exportMsgDTO);
} catch (Exception e) {
ExportMsgDTO exportMsgDTO = new ExportMsgDTO(request.getFileId(), "", 0, false, MsgType.EXEC_RESULT.name());
ExportWebSocketHandler.sendMessageSingle(exportMsgDTO);
List<ExportTask> exportTasks = getExportTasks(request.getProjectId(), userId);
if (CollectionUtils.isNotEmpty(exportTasks)) {
updateExportTask(ExportConstants.ExportState.ERROR.name(), exportTasks.getFirst().getId(), fileType);
}
ExportMsgDTO exportMsgDTO = new ExportMsgDTO(request.getFileId(), "", 0, false, MsgType.EXEC_RESULT.name());
ExportWebSocketHandler.sendMessageSingle(exportMsgDTO);
LogUtils.error(e);
throw new MSException(e);
} finally {
@ -511,7 +510,7 @@ public class FunctionalCaseFileService {
}
}
private List<File> generateCaseExportExcel(List<File> tmpExportExcelList, List<String> ids, String tmpZipPath, FunctionalCaseExportRequest request, Project project) {
private List<File> generateCaseExportExcel(List<File> tmpExportExcelList, List<String> ids, String tmpZipPath, FunctionalCaseExportRequest request) {
//excel表头
List<List<String>> headList = getFunctionalCaseExportHeads(request);
//获取导出的ids集合
@ -540,7 +539,7 @@ public class FunctionalCaseFileService {
List<FunctionalCaseExcelData> excelData = parseCaseData2ExcelData(subIds, rowMergeInfo, request, customFields, moduleMap, parameter.getParamValue());
List<List<Object>> data = parseExcelData2List(headList, excelData);
File createFile = new File(tmpZipPath + File.separatorChar + "Metersphere_case_" + project.getName() + count.get() + ".xlsx");
File createFile = new File(tmpZipPath + File.separatorChar + request.getFileId() + count.get() + ".xlsx");
if (!createFile.exists()) {
try {
createFile.createNewFile();

View File

@ -140,12 +140,12 @@ public class FunctionalCaseXmindService {
ExportMsgDTO exportMsgDTO = new ExportMsgDTO(request.getFileId(), taskId, ids.size(), true, MsgType.EXEC_RESULT.name());
ExportWebSocketHandler.sendMessageSingle(exportMsgDTO);
} catch (Exception e) {
ExportMsgDTO exportMsgDTO = new ExportMsgDTO(request.getFileId(), "", 0, false, MsgType.EXEC_RESULT.name());
ExportWebSocketHandler.sendMessageSingle(exportMsgDTO);
List<ExportTask> exportTasks = functionalCaseFileService.getExportTasks(request.getProjectId(), userId);
if (CollectionUtils.isNotEmpty(exportTasks)) {
functionalCaseFileService.updateExportTask(ExportConstants.ExportState.ERROR.name(), exportTasks.getFirst().getId(), XMIND);
}
ExportMsgDTO exportMsgDTO = new ExportMsgDTO(request.getFileId(), "", 0, false, MsgType.EXEC_RESULT.name());
ExportWebSocketHandler.sendMessageSingle(exportMsgDTO);
LogUtils.error(e);
throw new MSException(e);
} finally {