From 9357d86adcb0d44de82611bed2a75beae2313304 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Tue, 13 Aug 2024 11:41:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6=E5=90=8D=E7=A7=B0=E8=BF=87?= =?UTF-8?q?=E9=95=BF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/TestPlanCaseExecuteHistoryDTO.java | 2 ++ .../mapper/ExtFunctionalCaseTestMapper.xml | 4 +++- .../service/FunctionalCaseFileService.java | 13 ++++++------- .../service/FunctionalCaseXmindService.java | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/TestPlanCaseExecuteHistoryDTO.java b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/TestPlanCaseExecuteHistoryDTO.java index 49443a7df8..d05796e4e1 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/TestPlanCaseExecuteHistoryDTO.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/TestPlanCaseExecuteHistoryDTO.java @@ -28,5 +28,7 @@ public class TestPlanCaseExecuteHistoryDTO extends TestPlanCaseExecuteHistory { @Schema(description = "测试计划id") private String testPlanId; + @Schema(description = "编辑模式") + private String caseEditType; } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseTestMapper.xml b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseTestMapper.xml index 6820ac6551..41f3abc337 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseTestMapper.xml +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseTestMapper.xml @@ -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 diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseFileService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseFileService.java index cc6527b881..436d6298de 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseFileService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseFileService.java @@ -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 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 generateCaseExportExcel(List tmpExportExcelList, List ids, String tmpZipPath, FunctionalCaseExportRequest request, Project project) { + private List generateCaseExportExcel(List tmpExportExcelList, List ids, String tmpZipPath, FunctionalCaseExportRequest request) { //excel表头 List> headList = getFunctionalCaseExportHeads(request); //获取导出的ids集合 @@ -540,7 +539,7 @@ public class FunctionalCaseFileService { List excelData = parseCaseData2ExcelData(subIds, rowMergeInfo, request, customFields, moduleMap, parameter.getParamValue()); List> 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(); diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseXmindService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseXmindService.java index f378ec9c25..acfd15338d 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseXmindService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseXmindService.java @@ -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 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 {