From a9ba4c39d89c42c5ecd8ff99653747fca9ad5c83 Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 29 Dec 2025 08:44:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E8=AE=AE=E8=B5=84=E6=96=99=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...sCongressMaterialStatisticsController.java | 51 +++++++++++++++---- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/budwk/app/zhgh/democratic/grassrootscongress/controller/material/GrassrootsCongressMaterialStatisticsController.java b/src/main/java/com/budwk/app/zhgh/democratic/grassrootscongress/controller/material/GrassrootsCongressMaterialStatisticsController.java index 8d992fb..02fe5d1 100644 --- a/src/main/java/com/budwk/app/zhgh/democratic/grassrootscongress/controller/material/GrassrootsCongressMaterialStatisticsController.java +++ b/src/main/java/com/budwk/app/zhgh/democratic/grassrootscongress/controller/material/GrassrootsCongressMaterialStatisticsController.java @@ -8,8 +8,10 @@ import com.budwk.app.base.utils.CommonDownloadUtil; import com.budwk.app.flow.enums.ProcessInstanceStateEnum; import com.budwk.app.sys.models.Sys_file; import com.budwk.app.sys.utils.SysFileMinIoUtil; +import com.budwk.app.zhgh.democratic.grassrootscongress.models.GrassrootsCongressMaterialsInfo; import com.budwk.app.zhgh.democratic.grassrootscongress.models.GrassrootsCongressMeetingInfo; import com.budwk.app.zhgh.democratic.grassrootscongress.param.GrassrootsCongressPageForm; +import com.budwk.app.zhgh.democratic.grassrootscongress.service.GrassrootsCongressMeetingService; import com.budwk.app.zhgh.democratic.grassrootscongress.service.GrassrootsCongressService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -20,6 +22,7 @@ import org.nutz.dao.Sqls; import org.nutz.dao.sql.Sql; import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.lang.Lang; import org.nutz.lang.util.NutMap; import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.Ok; @@ -27,6 +30,7 @@ import org.nutz.mvc.annotation.Ok; import javax.servlet.http.HttpServletResponse; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -41,6 +45,9 @@ public class GrassrootsCongressMaterialStatisticsController { @Inject private GrassrootsCongressService grassrootsCongressService; + @Inject + private GrassrootsCongressMeetingService grassrootsCongressMeetingService; + @At("") @Ok("beetl:/platform/zhgh/democratic/grassrootscongress/material/statistics/index.html") @SaCheckPermission("grassrootsCongress.material.statistics") @@ -92,25 +99,47 @@ public class GrassrootsCongressMaterialStatisticsController { cnd.andEX("YEAR(info.createdTime)", "=", pageForm.getYear()); cnd.desc("info.createdTime"); sql.setCondition(cnd); - List list = grassrootsCongressService.listEntity(sql); + List list = grassrootsCongressMeetingService.listEntity(sql); try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ZipOutputStream zipOutputStream = new ZipOutputStream(bos); - for (GrassrootsCongressMeetingInfo info : list) { - // 循环下载文件 - List files = info.getFiles(); - for (JSONObject file : files) { - Sys_file sysFile = grassrootsCongressService.dao().fetch(Sys_file.class, Cnd.where(Sys_file::getDownloadPath, "=", file.get("url"))); - byte[] bytes = SysFileMinIoUtil.getFileBytes(sysFile.getBucket(), sysFile.getStoragePath()); - ZipEntry zipEntry = new ZipEntry(sysFile.getName()); - zipOutputStream.putNextEntry(zipEntry); + List fileNames = new ArrayList<>(); - zipOutputStream.write(bytes); - zipOutputStream.closeEntry(); + List fileJsonList = list.stream().map(GrassrootsCongressMaterialsInfo::getFiles).flatMap(v -> v.stream().map(item -> item)).toList(); + + for (JSONObject file : fileJsonList) { + if (Lang.isEmpty(file)) { + continue; } + + // 人才,非常人才,优秀人才 666 + Sys_file sysFile = grassrootsCongressMeetingService.dao().fetch(Sys_file.class, Cnd.where(Sys_file::getDownloadPath, "=", file.get("url"))); + + if (Lang.isEmpty(sysFile)) { + continue; + } + + byte[] bytes = SysFileMinIoUtil.getFileBytes(sysFile.getBucket(), sysFile.getStoragePath()); + + String fileName = sysFile.getName(); + + if (fileNames.contains(fileName)) { + String finalFileName = fileName; + long count = fileNames.stream().filter(name -> name.equals(finalFileName)).count(); + fileName = count + fileName; + } + + ZipEntry zipEntry = new ZipEntry(fileName); + zipOutputStream.putNextEntry(zipEntry); + + zipOutputStream.write(bytes); + zipOutputStream.closeEntry(); + + fileNames.add(fileName); } + zipOutputStream.close(); CommonDownloadUtil.download("资料汇总压缩包.zip", bos.toByteArray(), response); } catch (Exception e) {