From 617da85eade46df83e7a14efd546955876cc8ca5 Mon Sep 17 00:00:00 2001 From: chenxudong Date: Thu, 20 Nov 2025 19:15:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=9C=A8Windows=E4=B8=8BWord?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=8F=AF=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/config/ElePropertyConfig.java | 1 + .../service/serviceimpl/ChatService.java | 2 +- .../serviceimpl/EdFileInfoServiceImpl.java | 7 ++- .../software/common/util/OfficeFileUtil.java | 50 +++++++++---------- 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/config/ElePropertyConfig.java b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/config/ElePropertyConfig.java index 76acba6..1f21526 100644 --- a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/config/ElePropertyConfig.java +++ b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/config/ElePropertyConfig.java @@ -68,6 +68,7 @@ public class ElePropertyConfig { @Value("${backup.remote.port}") private int remotePort; + @Getter @Value("${winPrefix}") private String winPrefix = ""; diff --git a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/ChatService.java b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/ChatService.java index be3830e..f4b5e48 100644 --- a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/ChatService.java +++ b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/ChatService.java @@ -128,7 +128,7 @@ public class ChatService { } else { FileUtil.writeFromStream(file.getInputStream(), srcPath); if (Arrays.asList("doc", "docx").contains(fileType)) { - OfficeFileUtil.doc2pdf(srcPath, pdfPath); + OfficeFileUtil.doc2pdf(srcPath, pdfPath, elePropertyConfig.getWinPrefix()); } else { OfficeFileUtil.ppt2pdf(srcPath, pdfPath); } diff --git a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java index 29169ca..0b0326d 100644 --- a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java +++ b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java @@ -1344,18 +1344,20 @@ public class EdFileInfoServiceImpl extends ServiceImpl preview(String id, HttpServletResponse response, int dataOwnCode) { String fileSaveTmpPath = null; + String wordPath = null; try { EdFileInfo fileInfo = this.baseMapper.selectById(id); Assert.isTrue(Objects.nonNull(fileInfo), "文件不存在"); String fileDbPath = commonService.getDbPath(fileInfo.getFilePath()); String fileSysPath = commonService.getFileSysPath(fileInfo.getId()); fileSaveTmpPath = elePropertyConfig.getEleTmpPath() + File.separator + IdUtil.fastSimpleUUID() + "." + fileInfo.getFileType(); + wordPath = new String(fileSaveTmpPath); FileUtil.copy(fileSysPath, fileSaveTmpPath, true); EleCommonUtil.decryptFile(fileSaveTmpPath, SecureUtil.aes(elePropertyConfig.getFileEncPasswd().getBytes())); if (Arrays.asList("doc", "docx").contains(fileInfo.getFileType())) { String pdfTmpPath = elePropertyConfig.getEleTmpPath() + File.separator + fileInfo.getId() + ".pdf"; - OfficeFileUtil.doc2pdf(fileSaveTmpPath, pdfTmpPath); + OfficeFileUtil.doc2pdf(fileSaveTmpPath, pdfTmpPath, elePropertyConfig.getWinPrefix()); fileSaveTmpPath = pdfTmpPath; } @@ -1385,6 +1387,9 @@ public class EdFileInfoServiceImpl extends ServiceImpl