[测评系统]--测评系统核心代码库
linzhijie
2021-08-04 03f3d70b6770a889c3918d41951c27dfa08a21bf
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"));
    }
}