From e1f105ebd4bd6b6fa17a667fa3c4a9bcf7d8febf Mon Sep 17 00:00:00 2001 From: gongzhenkun <1658878546@qq.com> Date: Tue, 28 Mar 2023 09:56:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96zip=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/pc/TRecordController.java | 2 +- .../ruoyi/common/utils/file/FileUtils.java | 24 ++++++++++--------- .../com/ruoyi/system/domain/TDownloadZip.java | 3 ++- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TRecordController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TRecordController.java index c91fd61..e54fb24 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TRecordController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TRecordController.java @@ -155,7 +155,7 @@ public class TRecordController extends BaseController exportInfo.add(map); }); } - response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); +// response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); try { // FileUtils.setAttachmentResponseHeader(response, "舌面舌下图片下载"); // FileUtils.urlResourceWriteBytes(exportInfo, response.getOutputStream()); diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java index c43f430..c48d6bf 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java @@ -163,11 +163,12 @@ public class FileUtils bufIn = new BufferedInputStream(file.openStream()); zipEntry = new ZipEntry(filePath.get("downloadPath").toString()); zipOutputStream.putNextEntry(zipEntry); - int length = 0; - while ((length = bufIn.read()) != -1) - { - zipOutputStream.write(length); - } +// int length = 0; +// while ((length = bufIn.read()) != -1) +// { +// zipOutputStream.write(length); +// } + IOUtils.copy(bufIn,zipOutputStream); } } catch (IOException e) @@ -213,12 +214,13 @@ public class FileUtils bufIn = new BufferedInputStream(file.openStream()); zipEntry = new ZipEntry(filePath.get("downloadPath").toString()); zipOutputStream.putNextEntry(zipEntry); - byte[] b = new byte[1024*4]; - int length; - while ((length = bufIn.read(b)) > 0) - { - zipOutputStream.write(b, 0, length); - } +// byte[] b = new byte[1024*4]; +// int length; +// while ((length = bufIn.read(b)) > 0) +// { +// zipOutputStream.write(b, 0, length); +// } + IOUtils.copy(bufIn,zipOutputStream); } } catch (IOException e) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TDownloadZip.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TDownloadZip.java index a0cb053..cf684da 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TDownloadZip.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TDownloadZip.java @@ -1,6 +1,6 @@ package com.ruoyi.system.domain; -import com.ruoyi.common.annotation.Excel; +import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.core.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -42,6 +42,7 @@ public class TDownloadZip extends BaseEntity /** 创建时间 */ @ApiModelProperty("创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; public void setId(Long id) {