diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java index 330c07c..37da5a6 100644 --- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java +++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java @@ -192,7 +192,6 @@ public class ShiroConfig { filterChainDefinitionMap.put("/sys/sysDepart/queryDepartTreeSync4FaRen", "anon");//法人注册时,选择部门列表 filterChainDefinitionMap.put("/sys/sysDepart/getDepartList4Quxian", "anon");//法人注册时,获取区县级别部门列表 - filterChainDefinitionMap.put("/project/project/createXiangmushuWord", "anon");//测试word生成 diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/service/impl/Project4WordServiceImpl.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/service/impl/Project4WordServiceImpl.java index 6e9de4a..540c72b 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/service/impl/Project4WordServiceImpl.java +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/service/impl/Project4WordServiceImpl.java @@ -279,7 +279,9 @@ public class Project4WordServiceImpl extends ServiceImpl log.info("---------------------the basePath:{}", basePath); String modelFilePath = basePath + "baseInfoModel.docx"; log.info("---------------------the baseInfoModel path:{}", modelFilePath); - String mergeWordFileName = dto.getProjectName() + ".docx"; + String nameExt = "(" + dto.getId() + ")"; + //加上id用于区分,申报人上传以项目名称为文件名,出现重复文件问题 + String mergeWordFileName = dto.getProjectName() + nameExt + ".docx"; File outDir = new File(basePath + "pdf"); if (!outDir.exists()) { outDir.mkdirs(); @@ -297,10 +299,9 @@ public class Project4WordServiceImpl extends ServiceImpl .eq(ProjectFile::getFileType, "docx") .orderByDesc(ProjectFile::getCreateTime)); if (ObjectUtil.isNotEmpty(projectFile)) { - //windwos 下直接写回写路径 + //windwos 下直接写回路径 FileInputStream fis = new FileInputStream("F:\\opt\\upFiles\\temp\\" + projectFile.getFileName()); - //linux 环境下 // FileInputStream fis = new FileInputStream(basePath + projectFile.getFileName()); wordList.add(new XWPFDocument(fis)); @@ -313,17 +314,19 @@ public class Project4WordServiceImpl extends ServiceImpl FileInputStream fis2 = new FileInputStream(basePath + "yiJianModel.docx"); wordList.add(new XWPFDocument(fis2)); // 2.把集合里面的word文档全部合并在一个文档 - XWPFDocument mergeWordObj = WordUtils.mergeWord(wordList); - FileOutputStream fos = new FileOutputStream(new File(outDir, mergeWordFileName)); - //已合并过的文件,删除 - File oldMergeWord = new File(outDir + File.separator + dto.getProjectName() + ".docx"); - File oldPdf = new File(outDir + File.separator + dto.getProjectName() + ".pdf"); + //删除原文件 + File oldMergeWord = new File(outDir + File.separator + mergeWordFileName); if (oldMergeWord != null && oldMergeWord.isFile() && oldMergeWord.exists()) { oldMergeWord.delete(); } + File oldPdf = new File(outDir + File.separator + dto.getProjectName()+ nameExt + ".pdf"); if (oldPdf != null && oldPdf.isFile() && oldPdf.exists()) { oldPdf.delete(); } + + //生成word文件 + XWPFDocument mergeWordObj = WordUtils.mergeWord(wordList); + FileOutputStream fos = new FileOutputStream(new File(outDir, mergeWordFileName)); mergeWordObj.write(fos); fos.close(); } catch (Exception e) { @@ -331,7 +334,7 @@ public class Project4WordServiceImpl extends ServiceImpl } try { - String pdfName = dto.getProjectName() + ".pdf"; + String pdfName = dto.getProjectName()+ nameExt + ".pdf"; createPdf(outDir + File.separator + mergeWordFileName, outDir, pdfName); } catch (Exception e2) { e2.printStackTrace();