fix(测试计划): 修复文件名称过长问题
This commit is contained in:
parent
579e032de2
commit
9357d86adc
|
@ -28,5 +28,7 @@ public class TestPlanCaseExecuteHistoryDTO extends TestPlanCaseExecuteHistory {
|
||||||
@Schema(description = "测试计划id")
|
@Schema(description = "测试计划id")
|
||||||
private String testPlanId;
|
private String testPlanId;
|
||||||
|
|
||||||
|
@Schema(description = "编辑模式")
|
||||||
|
private String caseEditType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,9 +119,11 @@
|
||||||
ux.avatar as userLogo,
|
ux.avatar as userLogo,
|
||||||
tp.name as testPlanName,
|
tp.name as testPlanName,
|
||||||
tp.id as testPlanId,
|
tp.id as testPlanId,
|
||||||
u.email as email
|
u.email as email,
|
||||||
|
functional_case.case_edit_type as caseEditType
|
||||||
FROM
|
FROM
|
||||||
test_plan_case_execute_history tpceh
|
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 u on tpceh.create_user = u.id
|
||||||
left join user_extend ux on tpceh.create_user = ux.id
|
left join user_extend ux on tpceh.create_user = ux.id
|
||||||
left join test_plan tp on tpceh.test_plan_id = tp.id
|
left join test_plan tp on tpceh.test_plan_id = tp.id
|
||||||
|
|
|
@ -429,7 +429,6 @@ public class FunctionalCaseFileService {
|
||||||
*/
|
*/
|
||||||
public String exportFunctionalCaseZip(FunctionalCaseExportRequest request, String userId) {
|
public String exportFunctionalCaseZip(FunctionalCaseExportRequest request, String userId) {
|
||||||
File tmpDir = null;
|
File tmpDir = null;
|
||||||
Project project = projectMapper.selectByPrimaryKey(request.getProjectId());
|
|
||||||
String fileType = "";
|
String fileType = "";
|
||||||
try {
|
try {
|
||||||
tmpDir = new File(LocalRepositoryDir.getSystemTempDir() + File.separatorChar + EXPORT_CASE_TMP_DIR + "_" + IDGenerator.nextStr());
|
tmpDir = new File(LocalRepositoryDir.getSystemTempDir() + File.separatorChar + EXPORT_CASE_TMP_DIR + "_" + IDGenerator.nextStr());
|
||||||
|
@ -443,10 +442,10 @@ public class FunctionalCaseFileService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// 生成EXCEL
|
// 生成EXCEL
|
||||||
batchExcels = generateCaseExportExcel(batchExcels, ids, tmpDir.getPath(), request, project);
|
batchExcels = generateCaseExportExcel(batchExcels, ids, tmpDir.getPath(), request);
|
||||||
if (batchExcels.size() > 1) {
|
if (batchExcels.size() > 1) {
|
||||||
// EXCEL -> ZIP (EXCEL数目大于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;
|
fileType = ZIP;
|
||||||
uploadFileToMinio(fileType, zipFile, request.getFileId());
|
uploadFileToMinio(fileType, zipFile, request.getFileId());
|
||||||
} else {
|
} else {
|
||||||
|
@ -467,12 +466,12 @@ public class FunctionalCaseFileService {
|
||||||
ExportMsgDTO exportMsgDTO = new ExportMsgDTO(request.getFileId(), taskId, ids.size(), true, MsgType.EXEC_RESULT.name());
|
ExportMsgDTO exportMsgDTO = new ExportMsgDTO(request.getFileId(), taskId, ids.size(), true, MsgType.EXEC_RESULT.name());
|
||||||
ExportWebSocketHandler.sendMessageSingle(exportMsgDTO);
|
ExportWebSocketHandler.sendMessageSingle(exportMsgDTO);
|
||||||
} catch (Exception e) {
|
} 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);
|
List<ExportTask> exportTasks = getExportTasks(request.getProjectId(), userId);
|
||||||
if (CollectionUtils.isNotEmpty(exportTasks)) {
|
if (CollectionUtils.isNotEmpty(exportTasks)) {
|
||||||
updateExportTask(ExportConstants.ExportState.ERROR.name(), exportTasks.getFirst().getId(), fileType);
|
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);
|
LogUtils.error(e);
|
||||||
throw new MSException(e);
|
throw new MSException(e);
|
||||||
} finally {
|
} 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表头
|
//excel表头
|
||||||
List<List<String>> headList = getFunctionalCaseExportHeads(request);
|
List<List<String>> headList = getFunctionalCaseExportHeads(request);
|
||||||
//获取导出的ids集合
|
//获取导出的ids集合
|
||||||
|
@ -540,7 +539,7 @@ public class FunctionalCaseFileService {
|
||||||
List<FunctionalCaseExcelData> excelData = parseCaseData2ExcelData(subIds, rowMergeInfo, request, customFields, moduleMap, parameter.getParamValue());
|
List<FunctionalCaseExcelData> excelData = parseCaseData2ExcelData(subIds, rowMergeInfo, request, customFields, moduleMap, parameter.getParamValue());
|
||||||
List<List<Object>> data = parseExcelData2List(headList, excelData);
|
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()) {
|
if (!createFile.exists()) {
|
||||||
try {
|
try {
|
||||||
createFile.createNewFile();
|
createFile.createNewFile();
|
||||||
|
|
|
@ -140,12 +140,12 @@ public class FunctionalCaseXmindService {
|
||||||
ExportMsgDTO exportMsgDTO = new ExportMsgDTO(request.getFileId(), taskId, ids.size(), true, MsgType.EXEC_RESULT.name());
|
ExportMsgDTO exportMsgDTO = new ExportMsgDTO(request.getFileId(), taskId, ids.size(), true, MsgType.EXEC_RESULT.name());
|
||||||
ExportWebSocketHandler.sendMessageSingle(exportMsgDTO);
|
ExportWebSocketHandler.sendMessageSingle(exportMsgDTO);
|
||||||
} catch (Exception e) {
|
} 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);
|
List<ExportTask> exportTasks = functionalCaseFileService.getExportTasks(request.getProjectId(), userId);
|
||||||
if (CollectionUtils.isNotEmpty(exportTasks)) {
|
if (CollectionUtils.isNotEmpty(exportTasks)) {
|
||||||
functionalCaseFileService.updateExportTask(ExportConstants.ExportState.ERROR.name(), exportTasks.getFirst().getId(), XMIND);
|
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);
|
LogUtils.error(e);
|
||||||
throw new MSException(e);
|
throw new MSException(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue