Commit 698b0388 authored by wangqiang's avatar wangqiang

删除卷内临时文件

parent d6584662
......@@ -262,23 +262,22 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
int jjNumber = 0;
int sbNumber = 0;
int jsNumber = 0;
int countNumber=0;
for (ExtFilesDocLinkVO extFilesDocLinkVO:extFilesDocLinkVOList){
int countNumber = 0;
for (ExtFilesDocLinkVO extFilesDocLinkVO : extFilesDocLinkVOList) {
Map<String, Object> datas = new HashMap<>();
ExtFilesVO target = extFilesDocLinkVO.getTarget();
datas.put("serialNumber",ifNull(serialNumber));
datas.put("categoryNumber",ifNull(categoryNumber(target.getCategoryNumber(),zhNumber,jjNumber,sbNumber,jsNumber,countNumber)));
datas.put("volumeNumber",ifNull(target.getVolumeNumber()));
datas.put("caseName",ifNull(target.getCaseName()));
datas.put("pageNumber",ifNull(target.getPageNumber()));
datas.put("remarks",ifNull(target.getRemarks()));
datas.put("number",countNumber);
datas.put("contextName", dxContextProjectVO.getName());
datas.put("serialNumber", serialNumber);
datas.put("categoryNumber", categoryNumber(target.getCategoryNumber(), zhNumber, jjNumber, sbNumber, jsNumber, countNumber));
datas.put("volumeNumber", target.getVolumeNumber());
datas.put("caseName", target.getCaseName());
datas.put("pageNumber", target.getPageNumber());
datas.put("remarks", target.getRemarks());
datas.put("number", countNumber);
extFilesMap.add(datas);
serialNumber++;
}
resultDatas.put("data", extFilesMap);
resultDatas.put("contextName", ifNull(dxContextProjectVO.getName()));
String string = convertPdf("案卷目录模板.docx", resultDatas);
/*File pdfFile = new File(string);*/
MultipartFile multipartFile = DxObjFileUtils.createFile(string);
......@@ -290,27 +289,23 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
extDxContextProjectServiceFeign.saveRecursion(dxContextProjectVO);
}
public static String ifNull(Object obj) {
return null == obj ? "" : obj.toString();
}
public String categoryNumber(String categoryNumber,int zhNumber,int jjNumber,int sbNumber,int jsNumber,int countNumber){
if (categoryNumber.contains("ZH")){
public String categoryNumber(String categoryNumber, int zhNumber, int jjNumber, int sbNumber, int jsNumber, int countNumber) {
if (categoryNumber.contains("ZH")) {
categoryNumber = "综合";
countNumber= zhNumber + 1;
countNumber = zhNumber + 1;
}
if (categoryNumber.contains("JJ")){
if (categoryNumber.contains("JJ")) {
categoryNumber = "基建";
countNumber= jjNumber+1;
countNumber = jjNumber + 1;
}
if (categoryNumber.contains("SB")){
if (categoryNumber.contains("SB")) {
categoryNumber = "设备";
countNumber= sbNumber+1;
countNumber = sbNumber + 1;
}
if (categoryNumber.contains("JS")){
if (categoryNumber.contains("JS")) {
categoryNumber = "技术";
countNumber = jsNumber+1;
countNumber = jsNumber + 1;
}
return categoryNumber;
}
......@@ -332,7 +327,7 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
return pdfFile2.getAbsolutePath();
}
public String fillWordAndConvertPdf(String modelName, Map<String, Object> dataMap,String pdfFileName) {
public String fillWordAndConvertPdf(String modelName, Map<String, Object> dataMap, String pdfFileName) {
String targetPath = System.getProperty("user.dir") + "/TEMP/";
File wordFile = new File(targetPath + modelName);
File pdfFile2 = new File("TEMP/JNDir/" + pdfFileName + "_" + UUID.randomUUID() + ".pdf");
......@@ -350,12 +345,11 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
}
//递归根据项目群查询项目子项
@Override
public List<Long> getChildList(Long partId, List<Long> list) {
SearchQueryCondition build = SearchQueryBuilder.openBuild().openFilterBuilder().setEq("parentId", partId).closeFilterBuilder().build();
List<DxContextProjectVO> dxContextProjectVOS= extDxContextProjectServiceFeign.findRecursion(build).getContent();
List<DxContextProjectVO> dxContextProjectVOS = extDxContextProjectServiceFeign.findRecursion(build).getContent();
for (DxContextProjectVO dxContextProjectVO : dxContextProjectVOS) {
list.add(dxContextProjectVO.getId());
getChildList(dxContextProjectVO.getId(), list);
......@@ -365,6 +359,7 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
/**
* 生成卷内目录
*
* @param id
*/
@Transactional(rollbackFor = Exception.class)
......@@ -377,36 +372,37 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
List<Long> extFilesIdList = content.stream().map(v -> v.getId()).collect(Collectors.toList());
//查询案卷下文件清单
for(Long filesId : extFilesIdList){
for (Long filesId : extFilesIdList) {
SearchQueryCondition searchQueryCondition = SearchQueryBuilder.openBuild().openFilterBuilder()
.setItem("targetId", SearchItem.Operator.EQ,filesId).closeFilterBuilder()
.setItem("targetId", SearchItem.Operator.EQ, filesId).closeFilterBuilder()
.setPropName("target").setPropName("source").build();
List<ExtFilesDocLinkVO> extFilesDocLinkVOList = extFilesDocLinkService.findRecursion(searchQueryCondition).getContent();
if (CollectionUtils.isNotEmpty(extFilesDocLinkVOList)) {
ExtFilesVO extFilesVO = extFilesDocLinkVOList.get(0).getTarget();
//1.获取案卷下所有的档案(doc模型)数据并填充到模板中
Map<String,Object> wordFillDataForJN = getJNDirectoryFillData(extFilesDocLinkVOList,extFilesVO);
String JNDirectoryPdfPath = fillWordAndConvertPdf("卷内目录模板.docx", wordFillDataForJN,getJNMLFileName(extFilesVO));
Map<String, Object> wordFillDataForJN = getJNDirectoryFillData(extFilesDocLinkVOList, extFilesVO);
String JNDirectoryPdfPath = fillWordAndConvertPdf("卷内目录模板.docx", wordFillDataForJN, getJNMLFileName(extFilesVO));
//2.获取备考表需要填充的数据并填充数据到模板中
Map<String,Object> wordFillDataForBK = getJNBKTableFillData(extFilesDocLinkVOList,extFilesVO);
String BKPdfPath = fillWordAndConvertPdf("卷内备考表模板.docx", wordFillDataForBK,getBKFileName(extFilesVO));
Map<String, Object> wordFillDataForBK = getJNBKTableFillData(extFilesDocLinkVOList, extFilesVO);
String BKPdfPath = fillWordAndConvertPdf("卷内备考表模板.docx", wordFillDataForBK, getBKFileName(extFilesVO));
//3.上传卷内文档目录文件
MultipartFile multipartFileForJN = DxObjFileUtils.createFile(JNDirectoryPdfPath);
multipartFiles[0]=multipartFileForJN;
multipartFiles[0] = multipartFileForJN;
//4.上传备考文件
MultipartFile multipartFileForBK = DxObjFileUtils.createFile(BKPdfPath);
multipartFiles[1]=multipartFileForBK;
multipartFiles[1] = multipartFileForBK;
DxApplicationVO modelApp = dxAppModelDefLinkFeignService.findAppByModelName("ExtFiles");
Assert.notNull(modelApp.getBucketId(), String.format("当前应用%s未绑定桶!", modelApp.getName()));
List<RepoFileVO> fileVos = fileManagerFeignService.uploadFiles(multipartFiles, Long.parseLong(modelApp.getBucketId()));
for(RepoFileVO repoFileVO:fileVos){
if(repoFileVO.getOriginalFileName().contains("卷内目录")){ //卷内
for (RepoFileVO repoFileVO : fileVos) {
if (repoFileVO.getOriginalFileName().contains("卷内目录")) { //卷内
//5.将生成的卷内目录pdf文件挂载到案卷上
DxObjFileUtils.replaceFile(extFilesVO, repoFileVO, FileTypeEnum.MASTER_FILE);
}else { //备考
} else { //备考
//6.将生成的备考表pdf文件挂载到案卷上
DxObjFileUtils.replaceFile(extFilesVO, repoFileVO, FileTypeEnum.ATTACH_FILE);
}
......@@ -416,91 +412,98 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
//删除目录下所有的文件
FileUtils.deleteDirectory("TEMP/JNDir/");
}
}
}
/**
* 获取卷内备考表填充的数据
*
* @param extFilesDocLinkVOList
* @param extFilesVO
* @return
*/
public Map<String,Object> getJNBKTableFillData(List<ExtFilesDocLinkVO> extFilesDocLinkVOList,ExtFilesVO extFilesVO){
public Map<String, Object> getJNBKTableFillData(List<ExtFilesDocLinkVO> extFilesDocLinkVOList, ExtFilesVO extFilesVO) {
Map<String, Object> resultDatas = new HashMap<>();
//档号
resultDatas.put("DH",extFilesVO.getVolumeNumber());
resultDatas.put("DH", extFilesVO.getVolumeNumber());
//互见号
resultDatas.put("HJH",extFilesVO.getMutualNumber()==null?"":extFilesVO.getMutualNumber());
resultDatas.put("HJH", extFilesVO.getMutualNumber() == null ? "" : extFilesVO.getMutualNumber());
//文件共几件 =案卷下所有文档的个数
resultDatas.put("fileNumber",extFilesDocLinkVOList == null?0:extFilesDocLinkVOList.size());
resultDatas.put("fileNumber", extFilesDocLinkVOList == null ? 0 : extFilesDocLinkVOList.size());
//文件共几页 =案卷下所有文档中的附件个数相加
Integer totalPage = getJNBKTableTotalPage(extFilesDocLinkVOList);
resultDatas.put("filePage",getJNBKTableTotalPage(extFilesDocLinkVOList));
resultDatas.put("filePage", getJNBKTableTotalPage(extFilesDocLinkVOList));
//文字材料页 = 文件类型除图册、图纸之外的文件的总页数(见业务需求书)
Integer totalTextPage = getJNBKTableTotalTextPage(extFilesDocLinkVOList);
resultDatas.put("textPage",getJNBKTableTotalTextPage(extFilesDocLinkVOList));
resultDatas.put("textPage", getJNBKTableTotalTextPage(extFilesDocLinkVOList));
//图纸几张 = 文件总页数 - 文字材料页)
resultDatas.put("imagePiece",totalPage - totalTextPage);
resultDatas.put("imagePiece", totalPage - totalTextPage);
//立卷人 = 创建人
DxUserInfoVO userVO = (DxUserInfoVO) userService.get(extFilesVO.getCreatorId());
resultDatas.put("filer",userVO.getName());
resultDatas.put("filer", userVO.getName());
//立卷时间 = 创建时间
resultDatas.put("filerYear",extFilesVO.getCreateTime().getYear());
resultDatas.put("filerMonth",extFilesVO.getCreateTime().getMonthValue());
resultDatas.put("filerDay",extFilesVO.getCreateTime().getDayOfMonth());
resultDatas.put("filerYear", extFilesVO.getCreateTime().getYear());
resultDatas.put("filerMonth", extFilesVO.getCreateTime().getMonthValue());
resultDatas.put("filerDay", extFilesVO.getCreateTime().getDayOfMonth());
//检查人 =暂时不取(见业务需求书)
resultDatas.put("cheacker","");
resultDatas.put("cheacker", "");
//检查时间=暂时不取(见业务需求书)
resultDatas.put("checkerYear","");
resultDatas.put("checkerMonth","");
resultDatas.put("checkerDay","");
resultDatas.put("checkerYear", "");
resultDatas.put("checkerMonth", "");
resultDatas.put("checkerDay", "");
return resultDatas;
}
/**
* 计算文件类型除图册、图纸之外的文件的总页数(见业务需求书)
*
* @param extFilesDocLinkVOList
* @return
*/
public Integer getJNBKTableTotalTextPage(List<ExtFilesDocLinkVO> extFilesDocLinkVOList){
public Integer getJNBKTableTotalTextPage(List<ExtFilesDocLinkVO> extFilesDocLinkVOList) {
//DesignAtlas(设计图册)、InstallAtlas(安装图册)、DesignDrawings(设计图纸) 排除这三种类型的
// 定义一个数组
String[] array = {"DesignAtlas","InstallAtlas","DesignDrawings"};
List<String> subTypeNameList = Arrays.asList(array) ;
String[] array = {"DesignAtlas", "InstallAtlas", "DesignDrawings"};
List<String> subTypeNameList = Arrays.asList(array);
//获取所有文档对象集合
List<DxDocumentVO> documentVOList = extFilesDocLinkVOList.stream().map(linkVO -> linkVO.getSource()).collect(Collectors.toList());
//除DesignAtlas(设计图册)、InstallAtlas(安装图册)、DesignDrawings(设计图纸) 的文档对象
List<DxDocumentVO> docList = new ArrayList<>();
for (DxDocumentVO documentVO:documentVOList){
if(!subTypeNameList.contains(documentVO.getSubSystem())){
for (DxDocumentVO documentVO : documentVOList) {
if (!subTypeNameList.contains(documentVO.getSubSystem())) {
docList.add(documentVO);
}
}
return docList.stream().mapToInt(doc ->doc.getAttachPages() == null?0:Integer.parseInt(doc.getAttachPages())).sum();
return docList.stream().mapToInt(doc -> doc.getAttachPages() == null ? 0 : Integer.parseInt(doc.getAttachPages())).sum();
}
/**
* 计算案卷中挂载的文档中附件个数总和
*
* @param extFilesDocLinkVOList
* @return
*/
public Integer getJNBKTableTotalPage(List<ExtFilesDocLinkVO> extFilesDocLinkVOList){
public Integer getJNBKTableTotalPage(List<ExtFilesDocLinkVO> extFilesDocLinkVOList) {
List<DxDocumentVO> documentVoList = extFilesDocLinkVOList.stream().map(linkVO -> linkVO.getSource()).collect(Collectors.toList());
return documentVoList.stream().mapToInt(doc ->doc.getAttachPages() == null?0:Integer.parseInt(doc.getAttachPages())).sum();
return documentVoList.stream().mapToInt(doc -> doc.getAttachPages() == null ? 0 : Integer.parseInt(doc.getAttachPages())).sum();
}
/**
* 获取卷内目录需要填充的数据
*
* @param extFilesDocLinkVOList
* @param extFilesVO
* @return
*/
public Map<String,Object> getJNDirectoryFillData(List<ExtFilesDocLinkVO> extFilesDocLinkVOList,ExtFilesVO extFilesVO){
public Map<String, Object> getJNDirectoryFillData(List<ExtFilesDocLinkVO> extFilesDocLinkVOList, ExtFilesVO extFilesVO) {
List<Map<String, Object>> extFilesMap = new ArrayList<>();
Map<String, Object> resultDatas = new HashMap<>();
int serialNumber = 1;
for (ExtFilesDocLinkVO extFilesDocLinkVO:extFilesDocLinkVOList){
for (ExtFilesDocLinkVO extFilesDocLinkVO : extFilesDocLinkVOList) {
//文档对象
DxDocumentVO source = extFilesDocLinkVO.getSource();
......@@ -508,33 +511,33 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
//档号
//datas.put("DH",extFilesVO.getVolumeNumber() == null?"":extFilesVO.getVolumeNumber());
//序号
datas.put("serialNumber",serialNumber);
datas.put("serialNumber", serialNumber);
//文件编号
datas.put("fileNumber",source.getNumber()== null?"":source.getNumber());
datas.put("fileNumber", source.getNumber() == null ? "" : source.getNumber());
//责任责 ---文件创建部门
DxUserInfoVO userVO = (DxUserInfoVO) userService.get(source.getCreatorId());
//通过orgId获取组织名称
DxOrganizationVO organizationVO = (DxOrganizationVO) organizationService.get(userVO.getDxOrganizationId());
datas.put("author",organizationVO.getName()== null?"":organizationVO.getName());
datas.put("author", organizationVO.getName() == null ? "" : organizationVO.getName());
//文件题目 -- 文件名称
datas.put("fileName",source.getName()== null?"":source.getName());
datas.put("fileName", source.getName() == null ? "" : source.getName());
//日期 -- 文件发布日期,有流程的文件取流程结束时间,无流程的文件取文件创建时间
datas.put("date",source.getCreateTime()== null?"": DateUtils.converLocalDateToString(source.getCreateTime()));
datas.put("date", source.getCreateTime() == null ? "" : DateUtils.converLocalDateToString(source.getCreateTime()));
//页数 --文件页数
datas.put("pageNumber",extFilesDocLinkVO.getSource().getAttachPages() == null?"":extFilesDocLinkVO.getSource().getAttachPages());
datas.put("pageNumber", extFilesDocLinkVO.getSource().getAttachPages() == null ? "" : extFilesDocLinkVO.getSource().getAttachPages());
//密级 --文件密级
datas.put("secret",searchDictDataValueByDictCode(Constants.SECRET_CODE,extFilesDocLinkVO.getSource().getSecretCode()));
datas.put("secret", searchDictDataValueByDictCode(Constants.SECRET_CODE, extFilesDocLinkVO.getSource().getSecretCode()));
//备注 -- 文件本身的备注
datas.put("note",source.getNote() == null?"":source.getNote());
datas.put("note", source.getNote() == null ? "" : source.getNote());
//档号 -- 文件档号 --在移交单文档关联中
String fileDH = getFileDH(source);
datas.put("fileDH",fileDH == null?"":fileDH);
datas.put("fileDH", fileDH == null ? "" : fileDH);
extFilesMap.add(datas);
serialNumber++;
}
resultDatas.put("data", extFilesMap);
//档号
resultDatas.put("DH",extFilesVO.getVolumeNumber() == null?"":extFilesVO.getVolumeNumber());
resultDatas.put("DH", extFilesVO.getVolumeNumber() == null ? "" : extFilesVO.getVolumeNumber());
return resultDatas;
}
......@@ -566,24 +569,24 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
return "";
}
public String getFileDH(DxDocumentVO source){
public String getFileDH(DxDocumentVO source) {
List content = extTransferDocLinkService.findRecursion(SearchUtil.buildQuery("sourceId", SearchItem.Operator.EQ, source.getId())).getContent();
if(ObjectUtils.isNotEmpty(content)){
ExtTransferDocLinkVO extTransferDocLinkVO = (ExtTransferDocLinkVO)content.get(0);
if (ObjectUtils.isNotEmpty(content)) {
ExtTransferDocLinkVO extTransferDocLinkVO = (ExtTransferDocLinkVO) content.get(0);
return extTransferDocLinkVO.getArchiveNumber();
}
return "";
}
public String getJNMLFileName(ExtFilesVO extFilesVO){
public String getJNMLFileName(ExtFilesVO extFilesVO) {
String secretCode = searchDictDataValueByDictCode(Constants.SECRET_CODE, extFilesVO.getSecretCode());
return extFilesVO.getVolumeNumber()+"_卷内目录("+secretCode+")";
return extFilesVO.getVolumeNumber() + "_卷内目录(" + secretCode + ")";
}
public String getBKFileName(ExtFilesVO extFilesVO){
public String getBKFileName(ExtFilesVO extFilesVO) {
String secretCode = searchDictDataValueByDictCode(Constants.SECRET_CODE, extFilesVO.getSecretCode());
return extFilesVO.getVolumeNumber()+"_备考表("+secretCode+")";
return extFilesVO.getVolumeNumber() + "_备考表(" + secretCode + ")";
}
}
......
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