This commit is contained in:
@jyuhsin
2025-08-25 10:26:01 +08:00
parent fcd57ead6c
commit dde0dc9610
70 changed files with 1863 additions and 2739 deletions
@@ -187,33 +187,20 @@ public class YearPlanController {
try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())) {
for (String url : urlList) {
String fileId = extractFileId(url);
if(StrUtil.isNotBlank(fileId)) {
Sys_file file = dao.fetch(Sys_file.class, fileId);
byte[] bytes = SysFileMinIoUtil.getFileBytes(file.getBucket(), file.getStoragePath());
if(bytes == null || bytes.length == 0){
continue;
}
String entryName = file.getName();
zos.putNextEntry(new ZipEntry(entryName));
zos.write(bytes);
zos.closeEntry();
Sys_file file = dao.fetch(Sys_file.class, Cnd.where(Sys_file::getDownloadPath, "=", url));
byte[] bytes = SysFileMinIoUtil.getFileBytes(file.getBucket(), file.getStoragePath());
if(bytes == null || bytes.length == 0){
continue;
}
String entryName = file.getName();
zos.putNextEntry(new ZipEntry(entryName));
zos.write(bytes);
zos.closeEntry();
}
} catch (Exception e) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "生成ZIP文件失败");
e.printStackTrace();
}
}
public static String extractFileId(String url) {
if (url == null) return null;
Pattern pattern = Pattern.compile("[?&]id=([^&]*)");
Matcher matcher = pattern.matcher(url);
if (matcher.find()) {
return matcher.group(1);
}
return null;
}
}
@@ -168,33 +168,20 @@ public class YearSummaryController {
try (ZipOutputStream zos = new ZipOutputStream(response.getOutputStream())) {
for (String url : urlList) {
String fileId = extractFileId(url);
if(StrUtil.isNotBlank(fileId)) {
Sys_file file = dao.fetch(Sys_file.class, fileId);
byte[] bytes = SysFileMinIoUtil.getFileBytes(file.getBucket(), file.getStoragePath());
if(bytes == null || bytes.length == 0){
continue;
}
String entryName = file.getName();
zos.putNextEntry(new ZipEntry(entryName));
zos.write(bytes);
zos.closeEntry();
Sys_file file = dao.fetch(Sys_file.class, Cnd.where(Sys_file::getDownloadPath, "=", url));
byte[] bytes = SysFileMinIoUtil.getFileBytes(file.getBucket(), file.getStoragePath());
if(bytes == null || bytes.length == 0){
continue;
}
String entryName = file.getName();
zos.putNextEntry(new ZipEntry(entryName));
zos.write(bytes);
zos.closeEntry();
}
} catch (Exception e) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "生成ZIP文件失败");
e.printStackTrace();
}
}
public static String extractFileId(String url) {
if (url == null) return null;
Pattern pattern = Pattern.compile("[?&]id=([^&]*)");
Matcher matcher = pattern.matcher(url);
if (matcher.find()) {
return matcher.group(1);
}
return null;
}
}