|
|
@@ -187,48 +187,50 @@ public class EntProjectController extends BaseController {
|
|
|
|
|
|
@ApiOperation(value = "打包下载指定项目附件")
|
|
|
@GetMapping("/download/{projectId}")
|
|
|
- public void download(HttpServletResponse response, @PathVariable Integer projectId) throws IOException {
|
|
|
+ public void download(HttpServletResponse response, @PathVariable("projectId") Integer[] projectIds) throws IOException {
|
|
|
String downloadFileName = "";
|
|
|
- if (projectId == null || projectId == 0) throw new ServiceException("项目ID不能为空");
|
|
|
+ if (projectIds == null || projectIds.length == 0) throw new ServiceException("项目ID不能为空");
|
|
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
|
|
|
|
|
- EnterpriseProject pro = enterpriseProjectService.getById(projectId);
|
|
|
- if (pro != null) {
|
|
|
- downloadFileName += pro.getProjectName() + "_";
|
|
|
- // 企业项目申报上传文件
|
|
|
- List<Attach> attachEntList = attachService.lambdaQuery()
|
|
|
- .eq(Attach::getAttachType, AttachTypeEnum.FINACIAL)
|
|
|
- .eq(Attach::getDataId, pro.getId())
|
|
|
- .in(Attach::getFileType, "file1", "file2", "file3", "file4", "file5",
|
|
|
- "file6", "file7", "file8", "file9", "file10")
|
|
|
- .list();
|
|
|
-
|
|
|
- if (!CollectionUtil.isEmpty(attachEntList)) {
|
|
|
- logger.info("打包企业资料");
|
|
|
- ArrayList<String> fileList = new ArrayList<>();
|
|
|
- for (Attach attach : attachEntList) {
|
|
|
- File file = new File(YccrcConfig.getUploadPath() + attach.getFileKey());
|
|
|
- if (file.exists()) {
|
|
|
- logger.info(file.getName());
|
|
|
- try {
|
|
|
- String fileName = attach.getFileName();
|
|
|
- if (fileList.contains(fileName)) {
|
|
|
- fileName = FileUtil.getPrefix(fileName) + "_" + RandomUtil.randomString(3) + "." + FileUtil.getSuffix(fileName);
|
|
|
+ for (Integer projectId : projectIds) {
|
|
|
+ EnterpriseProject pro = enterpriseProjectService.getById(projectId);
|
|
|
+ if (pro != null) {
|
|
|
+ downloadFileName += pro.getProjectName() + "_";
|
|
|
+ // 企业项目申报上传文件
|
|
|
+ List<Attach> attachEntList = attachService.lambdaQuery()
|
|
|
+ .eq(Attach::getAttachType, AttachTypeEnum.FINACIAL)
|
|
|
+ .eq(Attach::getDataId, pro.getId())
|
|
|
+ .in(Attach::getFileType, "file1", "file2", "file3", "file4", "file5",
|
|
|
+ "file6", "file7", "file8", "file9", "file10")
|
|
|
+ .list();
|
|
|
+
|
|
|
+ if (!CollectionUtil.isEmpty(attachEntList)) {
|
|
|
+ logger.info("打包企业资料");
|
|
|
+ ArrayList<String> fileList = new ArrayList<>();
|
|
|
+ for (Attach attach : attachEntList) {
|
|
|
+ File file = new File(YccrcConfig.getUploadPath() + attach.getFileKey());
|
|
|
+ if (file.exists()) {
|
|
|
+ logger.info(file.getName());
|
|
|
+ try {
|
|
|
+ String fileName = attach.getFileName();
|
|
|
+ if (fileList.contains(fileName)) {
|
|
|
+ fileName = FileUtil.getPrefix(fileName) + "_" + RandomUtil.randomString(3) + "." + FileUtil.getSuffix(fileName);
|
|
|
+ }
|
|
|
+ fileList.add(fileName);
|
|
|
+
|
|
|
+ ZipEntry e = new ZipEntry(pro.getProjectName() + "/企业/" + fileName);
|
|
|
+ logger.info(e.getName());
|
|
|
+ zip.putNextEntry(e);
|
|
|
+ IOUtils.write(FileUtils.getBytes(file), zip);
|
|
|
+ zip.flush();
|
|
|
+ zip.closeEntry();
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("文件写入压缩包失败:" + attach.getFileName(), e);
|
|
|
}
|
|
|
- fileList.add(fileName);
|
|
|
-
|
|
|
- ZipEntry e = new ZipEntry(pro.getProjectName() + "/企业/" + fileName);
|
|
|
- logger.info(e.getName());
|
|
|
- zip.putNextEntry(e);
|
|
|
- IOUtils.write(FileUtils.getBytes(file), zip);
|
|
|
- zip.flush();
|
|
|
- zip.closeEntry();
|
|
|
- } catch (IOException e) {
|
|
|
- logger.error("文件写入压缩包失败:" + attach.getFileName(), e);
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|