From 3ac0b7f54a4a3d747ff43eb9e7ca619e5ef0f8d0 Mon Sep 17 00:00:00 2001 From: zhijie <1003392067@qq.com> Date: 星期日, 22 十月 2023 23:44:41 +0800 Subject: [PATCH] bugfix --- src/main/java/com/ots/common/utils/poi/WordUtil.java | 2 +- src/main/java/com/ots/project/tool/PdfUtil.java | 32 +++++++++++--------------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/ots/common/utils/poi/WordUtil.java b/src/main/java/com/ots/common/utils/poi/WordUtil.java index dea980f..9f7b117 100644 --- a/src/main/java/com/ots/common/utils/poi/WordUtil.java +++ b/src/main/java/com/ots/common/utils/poi/WordUtil.java @@ -1185,7 +1185,7 @@ || ReportTypeEnum.CIAQ.getCode().equals(reportType)){ PdfUtil.convertPDF(EssConfig.getProfile() + "/" + reportName); }else if(ReportTypeEnum.LAQ.getCode().equals(reportType)){ - PdfUtil.convertPythonPDF(EssConfig.getDocx2pdfPath(),EssConfig.getProfile() + "/" + reportName); + PdfUtil.dockerConvertPDF(EssConfig.getProfile(),EssConfig.getDocx2pdfPath(),reportName); }else{ ShellTool.execLibreofficeCommand("pdf", EssConfig.getProfile() + "/" + reportName, EssConfig.getProfile() + "/"); // ShellTool shellTool = ShellTool.builder(); diff --git a/src/main/java/com/ots/project/tool/PdfUtil.java b/src/main/java/com/ots/project/tool/PdfUtil.java index e7d60a2..20b8711 100644 --- a/src/main/java/com/ots/project/tool/PdfUtil.java +++ b/src/main/java/com/ots/project/tool/PdfUtil.java @@ -5,6 +5,7 @@ import java.io.*; import java.lang.reflect.Constructor; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -47,31 +48,20 @@ } /** - * 鎵цpython鑴氭湰 docx杞琾df - * @param filePath + * docker word杞琾df + * @param profile + * @param docx2pdfPath + * @param fileName */ - public static void convertPythonPDF(String pythonScript,String filePath){ + public static void dockerConvertPDF(String profile,String docx2pdfPath,String fileName){ try { - File file = new File(filePath); - if(!file.exists()){ - file.mkdirs(); - } - //鎵嬪姩鏇挎崲杈撳嚭pdf鍚嶇О - String output = filePath.replaceAll(".docx", ".pdf"); - - String os = System.getProperty("os.name"); - String[] args1; - if (os.contains("Windows")){ - args1 = new String[] { "python", pythonScript, filePath, output }; - } else { - args1 = new String[] { "python3", pythonScript, filePath, output }; - } - // 鎵цpy鏂囦欢 - Process proc = Runtime.getRuntime().exec(args1); + String command = MessageFormat.format(docx2pdfPath,profile,fileName); + // 鎵цdocker 鍛戒护 + Process proc = Runtime.getRuntime().exec(command); BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream(), "GBK")); String line = null; - log.info("python鎵ц鍛戒护:{}", Arrays.toString(args1)); - log.info("python鎵ц杩斿洖"); + log.info("docker鎵ц鍛戒护:{}", command); + log.info("docker鎵ц杩斿洖"); while ((line = in.readLine()) != null) { log.info(line); } -- Gitblit v1.9.1