refactor(性能测试): 下载zip报错信息优化
This commit is contained in:
parent
b27e21f082
commit
ff083f6545
|
@ -48,7 +48,7 @@ public class JmeterFileController {
|
|||
@RequestParam("ratio") String ratio,
|
||||
@RequestParam("reportId") String reportId, @RequestParam("resourceIndex") int resourceIndex) {
|
||||
double[] ratios = Arrays.stream(ratio.split(",")).mapToDouble(Double::parseDouble).toArray();
|
||||
byte[] bytes = jmeterFileService.downloadZip(testId, ratios, reportId, resourceIndex);
|
||||
byte[] bytes = jmeterFileService.downloadZip(reportId, ratios, resourceIndex);
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.parseMediaType("application/octet-stream"))
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + testId + ".zip\"")
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package io.metersphere.performance.service;
|
||||
|
||||
|
||||
import com.alibaba.excel.util.CollectionUtils;
|
||||
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
|
||||
import io.metersphere.base.mapper.LoadTestMapper;
|
||||
import io.metersphere.base.mapper.LoadTestReportMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
|
@ -25,18 +23,17 @@ import java.util.zip.ZipOutputStream;
|
|||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class JmeterFileService {
|
||||
|
||||
@Resource
|
||||
private LoadTestMapper loadTestMapper;
|
||||
@Resource
|
||||
private ExtLoadTestReportMapper extLoadTestReportMapper;
|
||||
@Resource
|
||||
private LoadTestReportMapper loadTestReportMapper;
|
||||
|
||||
public byte[] downloadZip(String testId, double[] ratios, String reportId, int resourceIndex) {
|
||||
public byte[] downloadZip(String reportId, double[] ratios, int resourceIndex) {
|
||||
try {
|
||||
LoadTestReportWithBLOBs loadTestReport = loadTestReportMapper.selectByPrimaryKey(reportId);
|
||||
|
||||
if (loadTestReport == null) {
|
||||
MSException.throwException("测试报告不存在或还没产生");
|
||||
}
|
||||
EngineContext context = EngineFactory.createContext(loadTestReport, ratios, reportId, resourceIndex);
|
||||
return zipFilesToByteArray(context);
|
||||
} catch (MSException e) {
|
||||
|
|
Loading…
Reference in New Issue