代码优化

This commit is contained in:
gaojiabao
2023-06-02 09:54:08 +08:00
parent 08b16ff16b
commit 87c0e43dd1
2 changed files with 11 additions and 5 deletions
@@ -601,15 +601,19 @@ public class AttFileEOServiceImpl extends ServiceImpl<AttFileEODao, AttFileEO> i
AttFileVo attFileVoPdf = null;
if(fileInfo != null){
File fileWord = new File(src+fileInfo.getFilePath()+fileInfo.getFileName());
logger.info("==================================fileWord文件路径========================"+src+fileInfo.getFilePath()+fileInfo.getFileName());
AttFileVo attFileVo = saveFileInfo(fileWord);
// 保存后 开始转换为 pdf版本
File inputWord = new File(src+attFileVo.getFilePath()+attFileVo.getFileName());
logger.info("==================================inputWord文件路径========================"+src+attFileVo.getFilePath()+attFileVo.getFileName());
String filePdfName = "";
if(StringUtils.isNotBlank(attFileVo.getFileName())){
String[] split = attFileVo.getFileName().split("\\.");
filePdfName = split[0]+".pdf";
}
File outputFile = new File(src+fileInfo.getFilePath(),filePdfName);
File outputFile = new File(src+fileInfo.getFilePath()+filePdfName);
logger.info("==================================outputFile文件路径========================"+src+fileInfo.getFilePath()+filePdfName);
try {
InputStream docxInputStream = new FileInputStream(inputWord);
OutputStream outputStream = new FileOutputStream(outputFile);
@@ -627,6 +631,10 @@ public class AttFileEOServiceImpl extends ServiceImpl<AttFileEODao, AttFileEO> i
deleteById(attFileVo.getId());
logger.info("==================================word.docx删除成功========================");
}
if (outputFile.exists()) {
outputFile.delete();
logger.info("==================================word.pdf删除成功========================");
}
}
}