Commit 756e43aa authored by wangqiang's avatar wangqiang

删除卷内临时文件

parent 177f4914
...@@ -12,6 +12,7 @@ import com.inet.dcs.document.core.service.ExtFilesDocLinkService; ...@@ -12,6 +12,7 @@ import com.inet.dcs.document.core.service.ExtFilesDocLinkService;
import com.inet.dcs.document.core.service.ExtFilesService; import com.inet.dcs.document.core.service.ExtFilesService;
import com.inet.dcs.document.core.service.ExtTransferDocLinkService; import com.inet.dcs.document.core.service.ExtTransferDocLinkService;
import com.inet.dcs.document.core.util.DateUtils; import com.inet.dcs.document.core.util.DateUtils;
import com.inet.dcs.document.core.util.FileUtils;
import com.inet.dcs.document.core.util.SearchUtil; 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;
...@@ -44,6 +45,7 @@ import org.apache.commons.collections4.CollectionUtils; ...@@ -44,6 +45,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
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;
...@@ -329,7 +331,7 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic ...@@ -329,7 +331,7 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
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/"; String targetPath = System.getProperty("user.dir") + "/TEMP/";
File wordFile = new File(targetPath + modelName); File wordFile = new File(targetPath + modelName);
File pdfFile2 = new File("TEMP/" + pdfFileName + "_" + UUID.randomUUID() + ".pdf"); File pdfFile2 = new File("TEMP/JNDir/" + pdfFileName + "_" + UUID.randomUUID() + ".pdf");
try { try {
InputStream tempStream2 = Files.newInputStream(wordFile.toPath()); InputStream tempStream2 = Files.newInputStream(wordFile.toPath());
OutputStream outputStream = Files.newOutputStream(pdfFile2.toPath()); OutputStream outputStream = Files.newOutputStream(pdfFile2.toPath());
...@@ -361,6 +363,7 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic ...@@ -361,6 +363,7 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
* 生成卷内目录 * 生成卷内目录
* @param id * @param id
*/ */
@Transactional(rollbackFor = Exception.class)
@Override @Override
public void generateJNDirectory(Long id) { public void generateJNDirectory(Long id) {
MultipartFile[] multipartFiles = new MultipartFile[2]; MultipartFile[] multipartFiles = new MultipartFile[2];
...@@ -376,16 +379,15 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic ...@@ -376,16 +379,15 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
.setPropName("target").setPropName("source").build(); .setPropName("target").setPropName("source").build();
List<ExtFilesDocLinkVO> extFilesDocLinkVOList = extFilesDocLinkService.findRecursion(searchQueryCondition).getContent(); List<ExtFilesDocLinkVO> extFilesDocLinkVOList = extFilesDocLinkService.findRecursion(searchQueryCondition).getContent();
ExtFilesVO extFilesVO = extFilesDocLinkVOList.get(0).getTarget(); ExtFilesVO extFilesVO = extFilesDocLinkVOList.get(0).getTarget();
//1.获取案卷下所有的档案(doc模型)数据并填充到模板中 //1.获取案卷下所有的档案(doc模型)数据并填充到模板中
Map<String,Object> wordFillDataForJN = getJNDirectoryFillData(extFilesDocLinkVOList,extFilesVO); Map<String,Object> wordFillDataForJN = getJNDirectoryFillData(extFilesDocLinkVOList,extFilesVO);
//填充卷内文档目录数据并转pdf
String JNDirectoryPdfPath = fillWordAndConvertPdf("卷内目录模板.docx", wordFillDataForJN,getJNMLFileName(extFilesVO)); String JNDirectoryPdfPath = fillWordAndConvertPdf("卷内目录模板.docx", wordFillDataForJN,getJNMLFileName(extFilesVO));
//2.获取备考表需要填充的数据并填充数据到模板中 //2.获取备考表需要填充的数据并填充数据到模板中
Map<String,Object> wordFillDataForBK = getJNBKTableFillData(extFilesDocLinkVOList,extFilesVO); Map<String,Object> wordFillDataForBK = getJNBKTableFillData(extFilesDocLinkVOList,extFilesVO);
String BKPdfPath = fillWordAndConvertPdf("卷内备考表模板.docx", wordFillDataForBK,getBKFileName(extFilesVO)); String BKPdfPath = fillWordAndConvertPdf("卷内备考表模板.docx", wordFillDataForBK,getBKFileName(extFilesVO));
//3.上传卷内文档目录文件 //3.上传卷内文档目录文件
MultipartFile multipartFileForJN = DxObjFileUtils.createFile(JNDirectoryPdfPath); MultipartFile multipartFileForJN = DxObjFileUtils.createFile(JNDirectoryPdfPath);
multipartFiles[0]=multipartFileForJN; multipartFiles[0]=multipartFileForJN;
...@@ -397,7 +399,7 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic ...@@ -397,7 +399,7 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
Assert.notNull(modelApp.getBucketId(), String.format("当前应用%s未绑定桶!", modelApp.getName())); Assert.notNull(modelApp.getBucketId(), String.format("当前应用%s未绑定桶!", modelApp.getName()));
List<RepoFileVO> fileVos = fileManagerFeignService.uploadFiles(multipartFiles, Long.parseLong(modelApp.getBucketId())); List<RepoFileVO> fileVos = fileManagerFeignService.uploadFiles(multipartFiles, Long.parseLong(modelApp.getBucketId()));
for(RepoFileVO repoFileVO:fileVos){ for(RepoFileVO repoFileVO:fileVos){
if(repoFileVO.getRepoFileName().contains("卷内目录")){ //卷内 if(repoFileVO.getOriginalFileName().contains("卷内目录")){ //卷内
//5.将生成的卷内目录pdf文件挂载到案卷上 //5.将生成的卷内目录pdf文件挂载到案卷上
DxObjFileUtils.replaceFile(extFilesVO, repoFileVO, FileTypeEnum.MASTER_FILE); DxObjFileUtils.replaceFile(extFilesVO, repoFileVO, FileTypeEnum.MASTER_FILE);
}else { //备考 }else { //备考
...@@ -407,6 +409,8 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic ...@@ -407,6 +409,8 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
} }
extFilesVO.setOperator(OperatorType.MODIFY); extFilesVO.setOperator(OperatorType.MODIFY);
this.saveRecursion((V) extFilesVO); this.saveRecursion((V) extFilesVO);
//删除目录下所有的文件
FileUtils.deleteDirectory("TEMP/JNDir/");
} }
} }
...@@ -441,7 +445,11 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic ...@@ -441,7 +445,11 @@ public class ExtFilesServiceImpl<V extends ExtFilesVO> implements ExtFilesServic
resultDatas.put("filerMonth",extFilesVO.getCreateTime().getMonthValue()); resultDatas.put("filerMonth",extFilesVO.getCreateTime().getMonthValue());
resultDatas.put("filerDay",extFilesVO.getCreateTime().getDayOfMonth()); resultDatas.put("filerDay",extFilesVO.getCreateTime().getDayOfMonth());
//检查人 =暂时不取(见业务需求书) //检查人 =暂时不取(见业务需求书)
resultDatas.put("cheacker","");
//检查时间=暂时不取(见业务需求书) //检查时间=暂时不取(见业务需求书)
resultDatas.put("checkerYear","");
resultDatas.put("checkerMonth","");
resultDatas.put("checkerDay","");
return resultDatas; return resultDatas;
} }
......
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