|
@@ -1,6 +1,8 @@
|
|
|
package com.taais.biz.controller;
|
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.nio.file.DirectoryStream;
|
|
|
import java.nio.file.Files;
|
|
@@ -13,6 +15,7 @@ import java.util.stream.Stream;
|
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
|
import com.taais.biz.domain.DataAugmentation;
|
|
|
import com.taais.biz.domain.bo.DataAugmentationBo;
|
|
|
+import com.taais.biz.domain.bo.DataAugmentationResultBo;
|
|
|
import com.taais.biz.domain.bo.VideoStableStartResultBo;
|
|
|
import com.taais.biz.domain.vo.DataAugmentationVo;
|
|
|
import com.taais.biz.service.IVideoStableService;
|
|
@@ -23,7 +26,10 @@ import jakarta.validation.Valid;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -96,7 +102,7 @@ public class DataAugmentationController extends BaseController {
|
|
|
String fileName = imagePath.getFileName().toString();
|
|
|
Map<String, List<String>> images = new HashMap<>();
|
|
|
//图像拼接算法有多个输入图片
|
|
|
- if ("图像拼接_sift".equals(dataAugmentation.getTaskType()) || "图像拼接_coordinate".equals(dataAugmentation.getTaskType())) {
|
|
|
+ if ("侦察图像拼接算法_sift".equals(dataAugmentation.getTaskType()) || "侦察图像拼接算法_coordinate".equals(dataAugmentation.getTaskType())) {
|
|
|
String lastDirectoryName = imagePath.getFileName().toString();
|
|
|
outputPath = outputPath.resolve(lastDirectoryName); //得到推理结果目录
|
|
|
Stream<Path> stream = Files.list(outputPath);
|
|
@@ -156,8 +162,8 @@ public class DataAugmentationController extends BaseController {
|
|
|
}
|
|
|
|
|
|
@PostMapping("/get_result")
|
|
|
- public CommonResult getResult(@Valid @RequestBody VideoStableStartResultBo videoStableStartResultBo) {
|
|
|
- return dataAugmentationService.getResult(videoStableStartResultBo);
|
|
|
+ public CommonResult getResult(@Valid @RequestBody DataAugmentationResultBo dataAugmentationResultBo) {
|
|
|
+ return dataAugmentationService.getResult(dataAugmentationResultBo);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/start/{id}")
|
|
@@ -185,9 +191,30 @@ public class DataAugmentationController extends BaseController {
|
|
|
@SaCheckPermission("demo:dataAugmentation:export")
|
|
|
@Log(title = "数据增强", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/export")
|
|
|
- public void export(HttpServletResponse response, DataAugmentationBo dataAugmentationBo) {
|
|
|
- List<DataAugmentationVo> list = dataAugmentationService.selectList(dataAugmentationBo);
|
|
|
- ExcelUtil.exportExcel(list, "数据增强", DataAugmentationVo.class, response);
|
|
|
+ public void export(HttpServletResponse response, @RequestBody String zipDirPath) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 假设你已经知道ZIP文件的路径
|
|
|
+// String zipFilePath = dataAugmentationVo.getOutputPath() + ".zip";
|
|
|
+// System.out.println(dataAugmentationVo.toString());
|
|
|
+
|
|
|
+ String zipFilePath = zipDirPath.substring(1, zipDirPath.length() - 1) + ".zip";
|
|
|
+ System.out.println( zipFilePath);
|
|
|
+ File zipFile = new File(zipFilePath);
|
|
|
+ String fileName = zipFile.getName();
|
|
|
+ // 设置响应头
|
|
|
+ response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
+ response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + fileName);
|
|
|
+ // 读取ZIP文件并写入响应流
|
|
|
+ try (FileInputStream fis = new FileInputStream(zipFilePath)) {
|
|
|
+ IOUtils.copy(fis, response.getOutputStream());
|
|
|
+ }
|
|
|
+ // 刷新输出流
|
|
|
+ response.flushBuffer();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|