Browse Source

项目档案文件下载

master
CMM 1 year ago
parent
commit
eae974cf14
1 changed files with 13 additions and 14 deletions
  1. +13
    -14
      pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java

+ 13
- 14
pmapi/src/main/java/com/ningdatech/pmapi/filemanage/manage/ProjectFileManage.java View File

@@ -250,7 +250,7 @@ public class ProjectFileManage {
return instanceId; return instanceId;
} }


public void downloadFile(Long projectId,HttpServletResponse response) {
public void downloadFile(Long projectId, HttpServletResponse response) {
Project project = projectService.getById(projectId); Project project = projectService.getById(projectId);
// 获取项目各阶段上传文件ID // 获取项目各阶段上传文件ID
List<Long> fileIdList = Lists.newArrayList(); List<Long> fileIdList = Lists.newArrayList();
@@ -260,23 +260,24 @@ public class ProjectFileManage {


// 设置response的header // 设置response的header
response.setContentType("application/zip"); response.setContentType("application/zip");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + ExcelDownUtil.encodeName(zipFileName) + ".zip");
//response.setHeader("Content-Disposition", "attachment;filename=" + zipFileName);
response.setHeader("Content-disposition",
"attachment;filename*=utf-8''" + ExcelDownUtil.encodeName(zipFileName) + ".zip");


try { try {
// 创建ZipOutputStream // 创建ZipOutputStream
ZipOutputStream zos = new ZipOutputStream(response.getOutputStream()); ZipOutputStream zos = new ZipOutputStream(response.getOutputStream());
if (CollUtil.isNotEmpty(fileIdList)){
if (CollUtil.isNotEmpty(fileIdList)) {
// 获取文件输入流 // 获取文件输入流
for (Long fileId : fileIdList) { for (Long fileId : fileIdList) {
File file = fileService.getById(fileId); File file = fileService.getById(fileId);
// 文件不存在,跳过 // 文件不存在,跳过
if (Objects.isNull(file)){
if (Objects.isNull(file)) {
continue; continue;
} }
String originalFileName = file.getOriginalFileName(); String originalFileName = file.getOriginalFileName();
String name = originalFileName.substring(0, originalFileName.indexOf(StrPool.DOT)); String name = originalFileName.substring(0, originalFileName.indexOf(StrPool.DOT));
String fileName = name + StrPool.UNDERSCORE + fileId + originalFileName.substring(originalFileName.indexOf(StrPool.DOT));
String fileName = name + StrPool.UNDERSCORE + fileId
+ originalFileName.substring(originalFileName.indexOf(StrPool.DOT));
InputStream fileInputStream = fileService.getFileInputStream(file); InputStream fileInputStream = fileService.getFileInputStream(file);
// 文件 // 文件
ZipEntry zipEntry = new ZipEntry(fileName); ZipEntry zipEntry = new ZipEntry(fileName);
@@ -351,7 +352,7 @@ public class ProjectFileManage {
for (Comment comment : commentList) { for (Comment comment : commentList) {
ProcessComment processComment = JSONObject.parseObject(comment.getFullMessage(), ProcessComment.class); ProcessComment processComment = JSONObject.parseObject(comment.getFullMessage(), ProcessComment.class);
List<FileBasicInfo> attachments = processComment.getAttachments(); List<FileBasicInfo> attachments = processComment.getAttachments();
if (CollUtil.isNotEmpty(attachments)){
if (CollUtil.isNotEmpty(attachments)) {
List<Long> idList = attachments.stream().map(FileBasicInfo::getFileId).collect(Collectors.toList()); List<Long> idList = attachments.stream().map(FileBasicInfo::getFileId).collect(Collectors.toList());
fileIdList.addAll(idList); fileIdList.addAll(idList);
} }
@@ -361,7 +362,7 @@ public class ProjectFileManage {
// 预审申报阶段 // 预审申报阶段
// 预审申报上级条线主管单位审核意见 // 预审申报上级条线主管单位审核意见
String higherLineSuperOrgReviewComments = project.getHigherLineSuperOrgReviewComments(); String higherLineSuperOrgReviewComments = project.getHigherLineSuperOrgReviewComments();
if (StringUtils.isNotBlank(higherLineSuperOrgReviewComments)){
if (StringUtils.isNotBlank(higherLineSuperOrgReviewComments)) {
List<Long> highSuperOrgFileIdList = getFileIdList(higherLineSuperOrgReviewComments); List<Long> highSuperOrgFileIdList = getFileIdList(higherLineSuperOrgReviewComments);
fileIdList.addAll(highSuperOrgFileIdList); fileIdList.addAll(highSuperOrgFileIdList);
} }
@@ -382,9 +383,8 @@ public class ProjectFileManage {
fileIdList.add(Long.valueOf(approvedConstructionPlanFile)); fileIdList.add(Long.valueOf(approvedConstructionPlanFile));


// 采购结果备案阶段 // 采购结果备案阶段
Purchase purchase = purchaseService.getOne(Wrappers.lambdaQuery(Purchase.class)
.eq(Purchase::getProjectId, projectId)
.last(BizConst.LIMIT_1));
Purchase purchase = purchaseService
.getOne(Wrappers.lambdaQuery(Purchase.class).eq(Purchase::getProjectId, projectId).last(BizConst.LIMIT_1));
// 获取投标文件 // 获取投标文件
String biddingDoc = purchase.getBiddingDoc(); String biddingDoc = purchase.getBiddingDoc();
List<Long> biddingFileIdList = getFileIdList(biddingDoc); List<Long> biddingFileIdList = getFileIdList(biddingDoc);
@@ -399,9 +399,8 @@ public class ProjectFileManage {
fileIdList.addAll(acceptFileIdList); fileIdList.addAll(acceptFileIdList);


// 合同备案阶段 // 合同备案阶段
Contract contract = contractService.getOne(Wrappers.lambdaQuery(Contract.class)
.eq(Contract::getProjectId, projectId)
.last(BizConst.LIMIT_1));
Contract contract = contractService
.getOne(Wrappers.lambdaQuery(Contract.class).eq(Contract::getProjectId, projectId).last(BizConst.LIMIT_1));
// 获取合同附件 // 获取合同附件
String attachment = contract.getAttachment(); String attachment = contract.getAttachment();
List<Long> contractFileIdList = getFileIdList(attachment); List<Long> contractFileIdList = getFileIdList(attachment);


Loading…
Cancel
Save