|
@@ -16,14 +16,14 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
|
|
|
//import org.apache.tomcat.util.http.fileupload.FileUtils;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.imageio.ImageIO;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileOutputStream;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.OutputStream;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
+import java.io.*;
|
|
|
//import java.sql.Timestamp;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -299,6 +299,7 @@ public class ImageManagerController {
|
|
|
zipFile.delete();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
@RequestMapping("/exportImage")
|
|
|
public void exportImage(HttpServletRequest request,HttpServletResponse response,@RequestParam(value="startDate",required = false) String startDate,@RequestParam(value="endDate",required = false) String endDate,@RequestParam(value="imageIds",required = false) String imageIds) throws Exception{
|
|
|
// if(imageIds == null || imageIds.trim().isEmpty()){
|
|
@@ -370,8 +371,51 @@ public class ImageManagerController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/exportOneImage",method = RequestMethod.GET)
|
|
|
- public void exportOneImage(@RequestParam(value = "type",required = true) String type){
|
|
|
+ /**
|
|
|
+ * @Method : exportOneImage
|
|
|
+ * @Description : 导出一张图片信息
|
|
|
+ * @Params : [imageId]
|
|
|
+ * @Return : byte[]
|
|
|
+ *
|
|
|
+ * @Author : ZhuoNing
|
|
|
+ * @Date : 2021/1/23
|
|
|
+ * @Time : 19:53
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/exportOneImage",method = RequestMethod.GET,produces = MediaType.IMAGE_JPEG_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public byte[] exportOneImage(@RequestParam(value = "imageId",required = true) String imageId) throws IOException {
|
|
|
+ // 读取
|
|
|
+ ImagePathEntity imagePathEntity = imageService.getOneImageDetail(imageId);
|
|
|
+ if(imagePathEntity == null){
|
|
|
+ log.error("imagePathEntity["+imagePathEntity.toString()+"]==null");
|
|
|
+ }
|
|
|
+ File file = new File(imagePathEntity.getImgPath());
|
|
|
+ FileInputStream inputStream = new FileInputStream(file);
|
|
|
+ byte[] bytes = new byte[inputStream.available()];
|
|
|
+ inputStream.read(bytes, 0, inputStream.available());
|
|
|
+ return bytes;
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * @Method : exportOneImage2
|
|
|
+ * @Description : 程序出错,不可用
|
|
|
+ * @Params : [imageId]
|
|
|
+ * @Return : java.awt.image.BufferedImage
|
|
|
+ *
|
|
|
+ * @Author : ZhuoNing
|
|
|
+ * @Date : 2021/1/23
|
|
|
+ * @Time : 19:54
|
|
|
+ */
|
|
|
+ @Deprecated
|
|
|
+ @RequestMapping(value = "/exportOneImage2",method = RequestMethod.GET,produces = MediaType.IMAGE_JPEG_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public BufferedImage exportOneImage2(@RequestParam(value = "imageId",required = true) String imageId) throws IOException {
|
|
|
+ // 读取
|
|
|
+ ImagePathEntity imagePathEntity = imageService.getOneImageDetail(imageId);
|
|
|
+ if(imagePathEntity == null){
|
|
|
+ log.error("imagePathEntity["+imagePathEntity.toString()+"]==null");
|
|
|
+ }
|
|
|
+ return ImageIO.read(new FileInputStream(new File(imagePathEntity.getImgPath())));
|
|
|
}
|
|
|
+
|
|
|
}
|