|
@@ -4477,7 +4477,7 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
simulationManualProjectTaskMapper.updateTaksResult(manualProjectTaskPo);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ throw new RuntimeException(e);
|
|
|
} finally {
|
|
|
try {
|
|
|
if (fileInputStream != null) {
|
|
@@ -4495,15 +4495,17 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
* }
|
|
|
*/
|
|
|
} catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
-
|
|
|
+ log.error(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 标准化测试 - 下载 - 任务文件
|
|
|
+ */
|
|
|
@Override
|
|
|
public void exportProjectTaskFileById(SimulationManualProjectParam param) {
|
|
|
String id = param.getId();
|
|
@@ -4521,40 +4523,39 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
sp.setId(id);
|
|
|
SimulationManualProjectPO spo = simulationManualProjectMapper.selectProjectBaseById(sp);
|
|
|
String rootPath = spo.getProjectName();
|
|
|
- // FileUtil.createDirectory(rootPath);
|
|
|
|
|
|
int len;
|
|
|
byte[] buffer = new byte[1024];
|
|
|
- // BufferedInputStream in = null;
|
|
|
ZipOutputStream zos = null;
|
|
|
- // InputStream inputStream = null;
|
|
|
File pdfFile = null;
|
|
|
try {
|
|
|
HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
|
|
|
response.setContentType("multipart/form-data");
|
|
|
response.setHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode("运行任务包.zip", "UTF-8"));
|
|
|
zos = new ZipOutputStream(response.getOutputStream());
|
|
|
+ // 下载所有任务的数据文件
|
|
|
+ log.info("项目 {} 共有 {} 个任务。", id, manualProjectTaskVos.size());
|
|
|
int i = 1;
|
|
|
- // ArrayList<String> fileList = CollectionUtil.createArrayList("Ego.csv",
|
|
|
- // "evaluation.csv");
|
|
|
for (ManualProjectTaskVo task : manualProjectTaskVos) {
|
|
|
+ log.info("当前下载进度为 {}/{}。", i++, manualProjectTaskVos.size());
|
|
|
String taskId = task.getId();
|
|
|
String runResultFilePath = task.getRunResultFilePath();
|
|
|
if (!isEmpty(runResultFilePath)) {
|
|
|
-
|
|
|
// 获取场景名
|
|
|
SceneBaseInfoVo sceneBaseInfoVo = getSceneNameAndOther(task.getSceneId(), task.getSceneType());
|
|
|
String sceneName = sceneBaseInfoVo.getCommonSceneName();
|
|
|
-
|
|
|
// 任务包路径
|
|
|
- // String taskPagePath = rootPath + File.separator + sceneName + "(" + i + ")";
|
|
|
String taskPagePath = rootPath + File.separator + sceneName + "- " + taskId.substring(0, 8);
|
|
|
-
|
|
|
// 视频文件路径
|
|
|
MinioParameter minioParameter1 = new MinioParameter();
|
|
|
minioParameter1.setObjectName(runResultFilePath);
|
|
|
ResponseBodyVO<List<String>> list = fileDownService.list(minioParameter1);
|
|
|
List<String> info = list.getInfo();
|
|
|
+ // 防止下载两次,因为结果目录里有测试用的同名文件
|
|
|
+ boolean mp4_done = false;
|
|
|
+ boolean Ego_csv_done = false;
|
|
|
+ boolean evaluation_csv_done = false;
|
|
|
+
|
|
|
for (String s : info) {
|
|
|
String fileName;
|
|
|
String zipPath;
|
|
@@ -4568,6 +4569,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
// 文件后缀
|
|
|
String substring = s.substring(s.lastIndexOf(".") + 1);
|
|
|
if ("mp4".equals(substring)) {
|
|
|
+ if (mp4_done) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
// mp4视频文件导出
|
|
|
MinioParameter minioParameter2 = new MinioParameter();
|
|
|
minioParameter2.setObjectName(s);
|
|
@@ -4580,8 +4584,36 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
zos.write(buffer, 0, len);
|
|
|
}
|
|
|
in.close();
|
|
|
- } else if ("Ego.csv".equals(fileName) || "evaluation.csv".equals(fileName)) {
|
|
|
+ mp4_done = true;
|
|
|
+ } else if ("Ego.csv".equals(fileName)) {
|
|
|
+ if (Ego_csv_done) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ MinioParameter minioParameter = new MinioParameter();
|
|
|
+ if (s.contains("/")) {
|
|
|
+ minioParameter.setObjectName(runResultFilePath + "/" + fileName);
|
|
|
+ } else {
|
|
|
+ minioParameter.setObjectName(runResultFilePath + "\\" + fileName);
|
|
|
+ }
|
|
|
+
|
|
|
+ Response download = fileDownService.download(minioParameter);
|
|
|
+ Response.Body body = download.body();
|
|
|
+
|
|
|
+ // 任务文件路径
|
|
|
+ String taskFilePath = taskPagePath + File.separator + fileName;
|
|
|
|
|
|
+ ZipEntry entry = new ZipEntry(taskFilePath);
|
|
|
+ zos.putNextEntry(entry);
|
|
|
+ BufferedInputStream in = new BufferedInputStream(body.asInputStream());
|
|
|
+ while ((len = in.read(buffer)) != -1) {
|
|
|
+ zos.write(buffer, 0, len);
|
|
|
+ }
|
|
|
+ in.close();
|
|
|
+ Ego_csv_done = true;
|
|
|
+ } else if ("evaluation.csv".equals(fileName)) {
|
|
|
+ if (evaluation_csv_done) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
MinioParameter minioParameter = new MinioParameter();
|
|
|
if (s.contains("/")) {
|
|
|
minioParameter.setObjectName(runResultFilePath + "/" + fileName);
|
|
@@ -4602,9 +4634,9 @@ public class SimulationProjectServiceImpl implements SimulationProjectService {
|
|
|
zos.write(buffer, 0, len);
|
|
|
}
|
|
|
in.close();
|
|
|
+ evaluation_csv_done = true;
|
|
|
}
|
|
|
}
|
|
|
- i++;
|
|
|
}
|
|
|
}
|
|
|
|