fix:修复Bug【69857】

报告里只有xls文件,下载后压缩包名称应该不变化,只是打开是空的。
This commit is contained in:
2023-05-26 09:12:20 +08:00
parent e2ea085317
commit d7c6203393
@@ -44,6 +44,7 @@ import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import static com.adc.da.report.constant.ReportConstants.FILE_EXTENSIONS_PDF;
@@ -435,9 +436,10 @@ public class ReportManageConroller {
//待下载的文件id List
List<String> downLoadFileIds;
String reportName = reportDao.selectById(reportId).getName() + ".zip";
String reportName = reportDao.selectById(reportId).getName();
String folderName = reportName + ".zip";
// 获取编码后的文件名
String encodedZipName = URLEncoder.encode(reportName, "UTF-8");
String encodedZipName = URLEncoder.encode(folderName, "UTF-8");
//判断是从列表页面下载 还是预览页面下载
if (CollectionUtils.isEmpty(fileIdList)) {
@@ -445,7 +447,6 @@ public class ReportManageConroller {
downLoadFileIds = fileService.getDownloadFileIds(reportId);
if (CollectionUtils.isEmpty(downLoadFileIds)) {
log.info("无法下载,原因可能是无可下载文件(xls/xlsx文件无法下载)");
String zipFileName = "empty.zip"; // 压缩文件名
try {
// 设置响应头信息
response.setContentType("application/zip");
@@ -457,6 +458,9 @@ public class ReportManageConroller {
// 创建空的ZipOutputStream
ZipOutputStream zipOutputStream = new ZipOutputStream(response.getOutputStream());
// 添加空文件夹条目
ZipEntry emptyDirectoryEntry = new ZipEntry(reportName + "/");
zipOutputStream.putNextEntry(emptyDirectoryEntry);
zipOutputStream.close();
return;
} catch (IOException e) {