From 03f3d70b6770a889c3918d41951c27dfa08a21bf Mon Sep 17 00:00:00 2001
From: linzhijie <19970921lzj>
Date: 星期三, 04 八月 2021 17:59:51 +0800
Subject: [PATCH] PAQ 改为python转换pdf

---
 src/main/java/com/ots/project/tool/ShellTool.java    |   26 +++++++++++++++++++++++++-
 src/main/java/com/ots/common/utils/poi/WordUtil.java |   11 ++++++++---
 2 files changed, 33 insertions(+), 4 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 961d8e8..029f035 100644
--- a/src/main/java/com/ots/common/utils/poi/WordUtil.java
+++ b/src/main/java/com/ots/common/utils/poi/WordUtil.java
@@ -767,7 +767,12 @@
             setChageWord(fileName, out, textMap, tReportTemplate.getReportType(), templateType, autoTableMap);
             out.flush();
             changColorIfJAQ(textMap, out, reportName, tReportTemplate.getReportType());
-            ShellTool.execLibreofficeCommand("pdf", EssConfig.getProfile() + "/" + reportName, EssConfig.getProfile() + "/");
+            //PAQ閲囩敤鏂扮殑doc杞琾df
+            if(!ReportTypeEnum.PAQ.getCode().equals(reportType)){
+                ShellTool.execLibreofficeCommand("pdf", EssConfig.getProfile() + "/" + reportName, EssConfig.getProfile() + "/");
+            }else{
+                ShellTool.execPythonCommand(1,EssConfig.getProfile() + "/" + reportName);
+            }
             zipFilePath = getPdfPath(reportName);
             
             deleteFileStrList.add(EssConfig.getProfile() + "/" + reportName);
@@ -857,7 +862,7 @@
         changeTextBox(document, textMap);
 
         //璁剧疆鍥捐〃
-        if (Objects.equals(reportType, ReportTypeEnum.SAQ.getCode())) {
+        if (Objects.equals(reportType, ReportTypeEnum.SAQ.getCode()) || Objects.equals(reportType, ReportTypeEnum.PAQ.getCode())) {
             SAQChart.changeChart(document, textMap);
         }
 
@@ -868,7 +873,7 @@
         changeTable(document, textMap);
 
         //璁剧疆鍥捐〃鎺т欢
-        changChar(textMap, document, reportType, templateType);
+        //changChar(textMap, document, reportType, templateType);
         document.write(out);
     }
     private static void changeTextBox(XWPFDocument document, Map<String, Object> textMap) throws DocumentException {
diff --git a/src/main/java/com/ots/project/tool/ShellTool.java b/src/main/java/com/ots/project/tool/ShellTool.java
index de464dd..5f65299 100644
--- a/src/main/java/com/ots/project/tool/ShellTool.java
+++ b/src/main/java/com/ots/project/tool/ShellTool.java
@@ -28,6 +28,29 @@
         }
         return exec(builder.toString());
     }
+
+    public static String execPythonCommand(Integer type,String sourcePath) {
+        String os = System.getProperty("os.name");
+        StringBuilder builder = new StringBuilder();
+        if(type == 0){
+            //鏈嶅姟鍣�
+            builder.append("python /bin/doc2pdf.py ");
+        }else{
+            //鏈湴娴嬭瘯
+            builder.append("python D:\\Project\\yaohuo\\doc2pdf.py ");
+        }
+        builder.append(sourcePath).append(" ");
+
+        try {
+            File file = new File(sourcePath.replaceAll(".docx", ".pdf"));
+            if (file.exists()) {
+                file.delete();
+            }
+        } catch (Exception e) {
+        }
+        return exec(builder.toString());
+    }
+
     private static String exec(String command) {
         String returnString = "";
         Runtime runTime = Runtime.getRuntime();
@@ -51,6 +74,7 @@
         return returnString;
     }
     public static void main(String[] args) {
-        System.out.println(exec("soffice.exe --headless --invisible --convert-to  D:/ots/uploadPath/upload/2021/02/28/01e01cf7e372ba8b1c5d24b8d69a46f8.docx 01e01cf7e372ba8b1c5d24b8d69a46f8.pdf "));
+        //System.out.println(exec("soffice.exe --headless --invisible --convert-to  D:/ots/uploadPath/upload/2021/02/28/01e01cf7e372ba8b1c5d24b8d69a46f8.docx 01e01cf7e372ba8b1c5d24b8d69a46f8.pdf "));
+        System.out.println(execPythonCommand(1,"D:\\娴嬭瘎绯荤粺\\home\\鏋梍PAQ_IA_CN.docx"));
     }
 }

--
Gitblit v1.9.1