|
@@ -1,5 +1,6 @@
|
|
|
package com.taais.biz.service.impl;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.util.Arrays;
|
|
@@ -32,6 +33,10 @@ import com.taais.system.service.ISysOssService;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.core.io.FileSystemResource;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -269,4 +274,27 @@ public class ToInfraredServiceImpl extends BaseServiceImpl<ToInfraredMapper, ToI
|
|
|
updateById(toInfrared);
|
|
|
return CommonResult.success();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseEntity<org.springframework.core.io.Resource> zipImages(Long id) {
|
|
|
+ ToInfrared toInfrared = this.getById(id);
|
|
|
+ if (ObjectUtil.isNull(toInfrared)) {
|
|
|
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ String sourceFolderPath = toInfrared.getOutputPath();
|
|
|
+ String zipFilePath = Paths.get(sourceFolderPath).resolveSibling(toInfrared.getName() + ".zip").toString();
|
|
|
+
|
|
|
+ File file = new File(zipFilePath);
|
|
|
+
|
|
|
+ if (!file.exists() || !file.isFile()) {
|
|
|
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ org.springframework.core.io.Resource resource = new FileSystemResource(file);
|
|
|
+ return ResponseEntity.ok()
|
|
|
+ .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\"")
|
|
|
+ .header(HttpHeaders.CONTENT_TYPE, "application/octet-stream")
|
|
|
+ .body(resource);
|
|
|
+ }
|
|
|
}
|