fix(测试用例): 修复用例导出未生成日志问题
--bug=1045099 --user=王旭 【测试用例】用例导出为xmind/excel-未生成系统日志 https://www.tapd.cn/55049933/s/1562443
This commit is contained in:
parent
ccdd19d521
commit
a52a69a99e
|
@ -237,7 +237,7 @@ public class FunctionalCaseController {
|
||||||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||||
public FunctionalCaseImportResponse preCheckXMind(@RequestPart("request") FunctionalCaseImportRequest request, @RequestPart(value = "file", required = false) MultipartFile file) {
|
public FunctionalCaseImportResponse preCheckXMind(@RequestPart("request") FunctionalCaseImportRequest request, @RequestPart(value = "file", required = false) MultipartFile file) {
|
||||||
SessionUser user = SessionUtils.getUser();
|
SessionUser user = SessionUtils.getUser();
|
||||||
return functionalCaseFileService.preCheckXMind(request,user, file);
|
return functionalCaseFileService.preCheckXMind(request, user, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ public class FunctionalCaseController {
|
||||||
@Operation(summary = "用例管理-功能用例-excel导出")
|
@Operation(summary = "用例管理-功能用例-excel导出")
|
||||||
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_EXPORT)
|
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_EXPORT)
|
||||||
public String testCaseExport(@Validated @RequestBody FunctionalCaseExportRequest request) {
|
public String testCaseExport(@Validated @RequestBody FunctionalCaseExportRequest request) {
|
||||||
return functionalCaseFileService.export(SessionUtils.getUserId(), request);
|
return functionalCaseFileService.export(SessionUtils.getUserId(), request, SessionUtils.getCurrentOrganizationId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/stop/{taskId}")
|
@GetMapping("/stop/{taskId}")
|
||||||
|
@ -314,7 +314,7 @@ public class FunctionalCaseController {
|
||||||
@Operation(summary = "用例管理-功能用例-xmind导出")
|
@Operation(summary = "用例管理-功能用例-xmind导出")
|
||||||
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_EXPORT)
|
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_EXPORT)
|
||||||
public String caseExportXmind(@Validated @RequestBody FunctionalCaseExportRequest request) {
|
public String caseExportXmind(@Validated @RequestBody FunctionalCaseExportRequest request) {
|
||||||
return functionalCaseXmindService.exportFunctionalCaseXmind(request, SessionUtils.getUserId());
|
return functionalCaseXmindService.exportFunctionalCaseXmind(request, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/check/export-task")
|
@GetMapping(value = "/check/export-task")
|
||||||
|
|
|
@ -48,6 +48,8 @@ import io.metersphere.system.dto.sdk.TemplateCustomFieldDTO;
|
||||||
import io.metersphere.system.dto.sdk.TemplateDTO;
|
import io.metersphere.system.dto.sdk.TemplateDTO;
|
||||||
import io.metersphere.system.excel.domain.ExcelErrData;
|
import io.metersphere.system.excel.domain.ExcelErrData;
|
||||||
import io.metersphere.system.excel.utils.EasyExcelExporter;
|
import io.metersphere.system.excel.utils.EasyExcelExporter;
|
||||||
|
import io.metersphere.system.log.dto.LogDTO;
|
||||||
|
import io.metersphere.system.log.service.OperationLogService;
|
||||||
import io.metersphere.system.manager.ExportTaskManager;
|
import io.metersphere.system.manager.ExportTaskManager;
|
||||||
import io.metersphere.system.mapper.SystemParameterMapper;
|
import io.metersphere.system.mapper.SystemParameterMapper;
|
||||||
import io.metersphere.system.service.FileService;
|
import io.metersphere.system.service.FileService;
|
||||||
|
@ -111,6 +113,8 @@ public class FunctionalCaseFileService {
|
||||||
private ExportTaskMapper exportTaskMapper;
|
private ExportTaskMapper exportTaskMapper;
|
||||||
private static final String XLSX = "xlsx";
|
private static final String XLSX = "xlsx";
|
||||||
private static final String ZIP = "zip";
|
private static final String ZIP = "zip";
|
||||||
|
@Resource
|
||||||
|
private OperationLogService operationLogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载excel导入模板
|
* 下载excel导入模板
|
||||||
|
@ -403,10 +407,10 @@ public class FunctionalCaseFileService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String export(String userId, FunctionalCaseExportRequest request) {
|
public String export(String userId, FunctionalCaseExportRequest request, String orgId) {
|
||||||
try {
|
try {
|
||||||
exportCheck(request, userId);
|
exportCheck(request, userId);
|
||||||
ExportTask exportTask = exportTaskManager.exportAsyncTask(request.getProjectId(), request.getFileId(), userId, ExportConstants.ExportType.CASE.toString(), request, t -> exportFunctionalCaseZip(request, userId));
|
ExportTask exportTask = exportTaskManager.exportAsyncTask(request.getProjectId(), request.getFileId(), userId, ExportConstants.ExportType.CASE.toString(), request, t -> exportFunctionalCaseZip(request, userId, orgId));
|
||||||
return exportTask.getId();
|
return exportTask.getId();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
LogUtils.error("导出失败:" + e);
|
LogUtils.error("导出失败:" + e);
|
||||||
|
@ -427,7 +431,7 @@ public class FunctionalCaseFileService {
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
*/
|
*/
|
||||||
public String exportFunctionalCaseZip(FunctionalCaseExportRequest request, String userId) {
|
public String exportFunctionalCaseZip(FunctionalCaseExportRequest request, String userId, String orgId) {
|
||||||
File tmpDir = null;
|
File tmpDir = null;
|
||||||
String fileType = "";
|
String fileType = "";
|
||||||
try {
|
try {
|
||||||
|
@ -454,7 +458,8 @@ public class FunctionalCaseFileService {
|
||||||
fileType = XLSX;
|
fileType = XLSX;
|
||||||
uploadFileToMinio(fileType, singeFile, request.getFileId());
|
uploadFileToMinio(fileType, singeFile, request.getFileId());
|
||||||
}
|
}
|
||||||
functionalCaseLogService.exportExcelLog(request);
|
LogDTO logDTO = functionalCaseLogService.exportExcelLog(request, "excel", userId, orgId);
|
||||||
|
operationLogService.add(logDTO);
|
||||||
List<ExportTask> exportTasks = getExportTasks(request.getProjectId(), userId);
|
List<ExportTask> exportTasks = getExportTasks(request.getProjectId(), userId);
|
||||||
String taskId;
|
String taskId;
|
||||||
if (CollectionUtils.isNotEmpty(exportTasks)) {
|
if (CollectionUtils.isNotEmpty(exportTasks)) {
|
||||||
|
|
|
@ -17,7 +17,6 @@ import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.system.log.constants.OperationLogModule;
|
import io.metersphere.system.log.constants.OperationLogModule;
|
||||||
import io.metersphere.system.log.constants.OperationLogType;
|
import io.metersphere.system.log.constants.OperationLogType;
|
||||||
import io.metersphere.system.log.dto.LogDTO;
|
import io.metersphere.system.log.dto.LogDTO;
|
||||||
import io.metersphere.system.mapper.CustomFieldMapper;
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -429,18 +428,17 @@ public class FunctionalCaseLogService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public LogDTO exportExcelLog(FunctionalCaseExportRequest request, String url, String userId, String orgId) {
|
||||||
public LogDTO exportExcelLog(FunctionalCaseExportRequest request) {
|
|
||||||
LogDTO dto = new LogDTO(
|
LogDTO dto = new LogDTO(
|
||||||
request.getProjectId(),
|
request.getProjectId(),
|
||||||
null,
|
orgId,
|
||||||
request.getFileId(),
|
request.getFileId(),
|
||||||
null,
|
userId,
|
||||||
OperationLogType.EXPORT.name(),
|
OperationLogType.EXPORT.name(),
|
||||||
OperationLogModule.FUNCTIONAL_CASE,
|
OperationLogModule.FUNCTIONAL_CASE,
|
||||||
"");
|
"");
|
||||||
dto.setHistory(true);
|
dto.setHistory(true);
|
||||||
dto.setPath("/functional/case/export/excel");
|
dto.setPath("/functional/case/export/" + url);
|
||||||
dto.setMethod(HttpMethodConstants.POST.name());
|
dto.setMethod(HttpMethodConstants.POST.name());
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ import io.metersphere.sdk.util.Translator;
|
||||||
import io.metersphere.system.constants.ExportConstants;
|
import io.metersphere.system.constants.ExportConstants;
|
||||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||||
import io.metersphere.system.dto.sdk.TemplateCustomFieldDTO;
|
import io.metersphere.system.dto.sdk.TemplateCustomFieldDTO;
|
||||||
|
import io.metersphere.system.log.dto.LogDTO;
|
||||||
|
import io.metersphere.system.log.service.OperationLogService;
|
||||||
import io.metersphere.system.manager.ExportTaskManager;
|
import io.metersphere.system.manager.ExportTaskManager;
|
||||||
import io.metersphere.system.uid.IDGenerator;
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
@ -61,6 +63,8 @@ public class FunctionalCaseXmindService {
|
||||||
@Resource
|
@Resource
|
||||||
private FunctionalCaseLogService functionalCaseLogService;
|
private FunctionalCaseLogService functionalCaseLogService;
|
||||||
private static final String XMIND = "xmind";
|
private static final String XMIND = "xmind";
|
||||||
|
@Resource
|
||||||
|
private OperationLogService operationLogService;
|
||||||
|
|
||||||
public void downloadXmindTemplate(String projectId, HttpServletResponse response) {
|
public void downloadXmindTemplate(String projectId, HttpServletResponse response) {
|
||||||
List<TemplateCustomFieldDTO> customFields = functionalCaseFileService.getCustomFields(projectId);
|
List<TemplateCustomFieldDTO> customFields = functionalCaseFileService.getCustomFields(projectId);
|
||||||
|
@ -96,10 +100,10 @@ public class FunctionalCaseXmindService {
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
*/
|
*/
|
||||||
public String exportFunctionalCaseXmind(FunctionalCaseExportRequest request, String userId) {
|
public String exportFunctionalCaseXmind(FunctionalCaseExportRequest request, String userId, String orgId) {
|
||||||
try {
|
try {
|
||||||
functionalCaseFileService.exportCheck(request, userId);
|
functionalCaseFileService.exportCheck(request, userId);
|
||||||
ExportTask exportTask = exportTaskManager.exportAsyncTask(request.getProjectId(), request.getFileId(), userId, ExportConstants.ExportType.CASE.toString(), request, t -> exportXmind(request, userId));
|
ExportTask exportTask = exportTaskManager.exportAsyncTask(request.getProjectId(), request.getFileId(), userId, ExportConstants.ExportType.CASE.toString(), request, t -> exportXmind(request, userId, orgId));
|
||||||
return exportTask.getId();
|
return exportTask.getId();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
LogUtils.error("导出失败:" + e);
|
LogUtils.error("导出失败:" + e);
|
||||||
|
@ -108,7 +112,7 @@ public class FunctionalCaseXmindService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String exportXmind(FunctionalCaseExportRequest request, String userId) {
|
private String exportXmind(FunctionalCaseExportRequest request, String userId, String orgId) {
|
||||||
//获取导出的ids集合
|
//获取导出的ids集合
|
||||||
List<String> ids = functionalCaseService.doSelectIds(request, request.getProjectId());
|
List<String> ids = functionalCaseService.doSelectIds(request, request.getProjectId());
|
||||||
if (CollectionUtils.isEmpty(ids)) {
|
if (CollectionUtils.isEmpty(ids)) {
|
||||||
|
@ -128,7 +132,8 @@ public class FunctionalCaseXmindService {
|
||||||
XmindExportUtil.export(xmindData, request, tmpFile, templateCustomFields);
|
XmindExportUtil.export(xmindData, request, tmpFile, templateCustomFields);
|
||||||
functionalCaseFileService.uploadFileToMinio(XMIND, tmpFile, request.getFileId());
|
functionalCaseFileService.uploadFileToMinio(XMIND, tmpFile, request.getFileId());
|
||||||
|
|
||||||
functionalCaseLogService.exportExcelLog(request);
|
LogDTO logDTO = functionalCaseLogService.exportExcelLog(request, "xmind", userId, orgId);
|
||||||
|
operationLogService.add(logDTO);
|
||||||
List<ExportTask> exportTasks = functionalCaseFileService.getExportTasks(request.getProjectId(), userId);
|
List<ExportTask> exportTasks = functionalCaseFileService.getExportTasks(request.getProjectId(), userId);
|
||||||
String taskId;
|
String taskId;
|
||||||
if (CollectionUtils.isNotEmpty(exportTasks)) {
|
if (CollectionUtils.isNotEmpty(exportTasks)) {
|
||||||
|
|
Loading…
Reference in New Issue