Commit a2c204be authored by wangqiang's avatar wangqiang

卷内目录批量下载功能(暂未调试)

parent bb4470f4
...@@ -11,6 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -11,6 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List; import java.util.List;
/** /**
...@@ -49,6 +51,20 @@ public class ExtFilesController<V extends ExtFilesVO, S extends ExtFilesService< ...@@ -49,6 +51,20 @@ public class ExtFilesController<V extends ExtFilesVO, S extends ExtFilesService<
return ApiResult.ok("生成成功"); return ApiResult.ok("生成成功");
} }
/**
* 批量下载卷内目录
*
* @param response
* @param ids 案卷id集合
* @throws IOException
*/
@ApiOperation(value = "批量下载卷内目录", notes = "批量下载", httpMethod = "GET")
@GetMapping(value = "/batchDownloadJNDirDoc")
public void batchDownloadJNDirDoc(HttpServletResponse response, @RequestParam("ids") List<Long> ids) throws IOException {
extFilesService.batchDownloadJNDirDoc(response, ids);
}
} }
...@@ -4,6 +4,8 @@ import com.inet.dcs.document.common.vo.ExtFilesVO; ...@@ -4,6 +4,8 @@ import com.inet.dcs.document.common.vo.ExtFilesVO;
import com.inet.dcs.document.common.vo.archivesOtherVO.ExtFilesUpdateVO; import com.inet.dcs.document.common.vo.archivesOtherVO.ExtFilesUpdateVO;
import com.inet.dcs.document.core.service.shadow.ExtFilesServiceShadow; import com.inet.dcs.document.core.service.shadow.ExtFilesServiceShadow;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List; import java.util.List;
/** /**
...@@ -51,4 +53,15 @@ public interface ExtFilesService<V extends ExtFilesVO> extends ExtFilesServiceSh ...@@ -51,4 +53,15 @@ public interface ExtFilesService<V extends ExtFilesVO> extends ExtFilesServiceSh
List<Long> getChildList(Long partId, List<Long> list); List<Long> getChildList(Long partId, List<Long> list);
/**
* 批量下载卷内目录附件
*
* @param response
* @param ids
* @throws IOException
*/
void batchDownloadJNDirDoc(HttpServletResponse response, List<Long> ids) throws IOException;
} }
package com.inet.dcs.document.core.service.impl; package com.inet.dcs.document.core.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ZipUtil;
import com.inet.dcs.document.common.vo.ExtFilesDocLinkVO; import com.inet.dcs.document.common.vo.ExtFilesDocLinkVO;
import com.inet.dcs.document.common.vo.ExtFilesVO; import com.inet.dcs.document.common.vo.ExtFilesVO;
import com.inet.dcs.document.common.vo.ExtTransferDocLinkVO; import com.inet.dcs.document.common.vo.ExtTransferDocLinkVO;
...@@ -17,6 +19,7 @@ import com.inet.dcs.document.core.util.SearchUtil; ...@@ -17,6 +19,7 @@ import com.inet.dcs.document.core.util.SearchUtil;
import com.inet.dcs.document.core.util.WordUtils; import com.inet.dcs.document.core.util.WordUtils;
import com.inet.dcs.document.entity.po.ExtFiles; import com.inet.dcs.document.entity.po.ExtFiles;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO; import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dcs.plan.common.utils.ResourceHelper;
import com.yonde.dex.basedata.data.search.SearchItem; import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchItems; import com.yonde.dex.basedata.data.search.SearchItems;
import com.yonde.dex.basedata.data.search.SearchQueryBuilder; import com.yonde.dex.basedata.data.search.SearchQueryBuilder;
...@@ -31,7 +34,9 @@ import com.yonde.dex.dao.service.DxDaoPluginExpander; ...@@ -31,7 +34,9 @@ import com.yonde.dex.dao.service.DxDaoPluginExpander;
import com.yonde.dex.dfs.feign.FileManagerFeignService; import com.yonde.dex.dfs.feign.FileManagerFeignService;
import com.yonde.dex.dfs.objfilelink.enums.FileTypeEnum; import com.yonde.dex.dfs.objfilelink.enums.FileTypeEnum;
import com.yonde.dex.dfs.objfilelink.plugin.core.util.DxObjFileUtils; import com.yonde.dex.dfs.objfilelink.plugin.core.util.DxObjFileUtils;
import com.yonde.dex.dfs.vo.ObjFileLinkVO;
import com.yonde.dex.dfs.vo.RepoFileVO; import com.yonde.dex.dfs.vo.RepoFileVO;
import com.yonde.dex.dfs.vo.view.FileDownLoadInfoVO;
import com.yonde.dex.dict.feign.DictDataFeignService; import com.yonde.dex.dict.feign.DictDataFeignService;
import com.yonde.dex.dict.service.vo.DictDataVO; import com.yonde.dex.dict.service.vo.DictDataVO;
import com.yonde.dex.feign.applink.DxAppModelDefLinkFeignService; import com.yonde.dex.feign.applink.DxAppModelDefLinkFeignService;
...@@ -49,6 +54,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -49,6 +54,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.*; import java.util.*;
...@@ -589,6 +595,70 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic ...@@ -589,6 +595,70 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
return extFilesVO.getVolumeNumber() + "_备考表(" + secretCode + ")"; return extFilesVO.getVolumeNumber() + "_备考表(" + secretCode + ")";
} }
/**
* 批量下载卷内目录
* @param response
* @param ids
* @throws IOException
*/
@Override
public void batchDownloadJNDirDoc(HttpServletResponse response, List<Long> ids) throws IOException {
if(CollUtil.isEmpty(ids)){
throw new DxBusinessException("500","必须要选中一条案卷");
}
//临时文件目录
String tempDir = ResourceHelper.createTempDir().getPath();
//文件id集合
List<Long> fileIds = new ArrayList<>();
//查询所有案卷下所有的附件并展开
SearchQueryCondition queryCondition = SearchUtil.buildQueryWithOpenAttr("id", SearchItem.Operator.IN, ids, "objFileLinks.target");
List<ExtFilesVO> content = (List<ExtFilesVO>) this.findRecursion(queryCondition).getContent();
if(CollUtil.isNotEmpty(content)){
for(ExtFilesVO extFilesVO:content){
List<ObjFileLinkVO> objFileLinks = extFilesVO.getObjFileLinks();
if(CollUtil.isNotEmpty(extFilesVO.getObjFileLinks())){
//遍历取出文件id
objFileLinks.stream().forEach(o -> {
fileIds.add(o.getTargetId());
});
}
}
}
if(fileIds.size() > 0 ){
fileIds.stream().forEach(fileId -> {
try {
//通过fileId下载文件
FileDownLoadInfoVO fileDownLoadInfoVO = fileManagerFeignService.download(fileId);
com.yonde.dcs.plan.common.utils.FileUtils.base64ToFile(fileDownLoadInfoVO.getFileBase64(), fileDownLoadInfoVO.getFileName(), tempDir);
} catch (Exception e) {
throw new DxBusinessException("-1", "批量下载文件失败" + e.getMessage());
}
});
//压缩文件
downloadDataZip(response, tempDir);
//删除生成后的临时文件
FileUtils.deleteDirectory(tempDir);
}
}
/**
* 批量下载季报报表文件
*
* @param response
* @param dir
* @throws IOException
*/
private void downloadDataZip(HttpServletResponse response, String dir) throws IOException {
File zip = ZipUtil.zip(dir);
InputStream inputStream = FileUtils.fileToInputStream(zip);
com.yonde.dcs.plan.common.utils.FileUtils.downloadFile(response, inputStream, "卷内目录");
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment