Преглед на файлове

fix:修复外部jar包导致的部署报错

chillqi преди 3 години
родител
ревизия
03bc43d150

+ 0 - 92
pom.xml

@@ -164,98 +164,6 @@
                 <scope>runtime</scope>
             </dependency>
 
-            <dependency>
-                <groupId>org.apache.poi</groupId>
-                <artifactId>poi</artifactId>
-                <version>4.1.2</version>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.poi</groupId>
-                <artifactId>poi-ooxml</artifactId>
-                <version>4.1.2</version>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.poi</groupId>
-                <artifactId>poi-scratchpad</artifactId>
-                <version>4.1.2</version>
-            </dependency>
-
-            <dependency>
-                <groupId>com.itextpdf</groupId>
-                <artifactId>itextpdf</artifactId>
-                <version>5.4.3</version>
-            </dependency>
-
-            <dependency>
-                <groupId>com.itextpdf</groupId>
-                <artifactId>itext-asian</artifactId>
-                <version>5.2.0</version>
-            </dependency>
-
-            <dependency>
-                <groupId>org.docx4j</groupId>
-                <artifactId>docx4j</artifactId>
-                <version>3.2.2</version>
-            </dependency>
-
-            <!-- 从外面导包进来 项目的myJar com.aspose -->
-
-            <!-- 下面的依赖是为了报其他错误的 -->
-            <dependency>
-                <groupId>org.apache.xmlbeans</groupId>
-                <artifactId>xmlbeans</artifactId>
-                <version>5.0.3</version>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.poi</groupId>
-                <artifactId>poi-ooxml-schemas</artifactId>
-                <version>4.1.2</version>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.commons</groupId>
-                <artifactId>commons-compress</artifactId>
-                <version>1.19</version>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.commons</groupId>
-                <artifactId>commons-collections4</artifactId>
-                <version>4.1</version>
-            </dependency>
-
-            <dependency>
-                <groupId>com.zaxxer</groupId>
-                <artifactId>SparseBitSet</artifactId>
-                <version>1.2</version>
-            </dependency>
-            <dependency>
-                <groupId>cn.hutool</groupId>
-                <artifactId>hutool-all</artifactId>
-                <version>5.6.0</version>
-            </dependency>
-
-            <!-- 修改com.aspose.cells专用包 -->
-            <!--<dependency>-->
-            <!--<groupId>org.javassist</groupId>-->
-            <!--<artifactId>javassist</artifactId>-->
-            <!--<version>3.26.0-GA</version>-->
-            <!--</dependency>-->
-            <dependency>
-                <groupId>org.apache.pdfbox</groupId>
-                <artifactId>fontbox</artifactId>
-                <version>2.0.18</version>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.pdfbox</groupId>
-                <artifactId>pdfbox</artifactId>
-                <version>2.0.18</version>
-            </dependency>
-            <dependency>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-dependencies</artifactId>
-                <type>pom</type>
-                <version>2.4.4</version>
-                <scope>import</scope>
-            </dependency>
         </dependencies>
     </dependencyManagement>
 

+ 72 - 73
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/serviceImpl/CourseWareServiceImpl.java

@@ -10,14 +10,13 @@ import cn.seecoder.seecoderportalserver.repository.CourseRepository;
 import cn.seecoder.seecoderportalserver.repository.CourseWareRepository;
 import cn.seecoder.seecoderportalserver.service.CourseWareService;
 import cn.seecoder.seecoderportalserver.utility.OssUtil;
-import com.itextpdf.text.Document;
-import com.itextpdf.text.Image;
-import com.itextpdf.text.pdf.PdfPCell;
-import com.itextpdf.text.pdf.PdfPTable;
-import com.itextpdf.text.pdf.PdfWriter;
+//import com.itextpdf.text.Document;
+//import com.itextpdf.text.Image;
+//import com.itextpdf.text.pdf.PdfPCell;
+//import com.itextpdf.text.pdf.PdfPTable;
+//import com.itextpdf.text.pdf.PdfWriter;
 //import org.apache.poi.hslf.usermodel.*;
 //import org.apache.poi.xslf.usermodel.*;
-import org.apache.poi.hslf.usermodel.*;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -113,74 +112,74 @@ public class CourseWareServiceImpl implements CourseWareService {
         }
     }
 
-    public static boolean pptToPdf(InputStream inputStream, OutputStream outputStream) {
-
-        Document document = null;
-        HSLFSlideShow hslfSlideShow = null;
-        PdfWriter pdfWriter = null;
-
-        try {
-            hslfSlideShow = new HSLFSlideShow(inputStream);
-
-            // 获取ppt文件页面
-            Dimension dimension = hslfSlideShow.getPageSize();
-
-            document = new Document();
-
-            // pdfWriter实例
-            pdfWriter = PdfWriter.getInstance(document, outputStream);
-
-            document.open();
-
-            PdfPTable pdfPTable = new PdfPTable(1);
-
-            List<HSLFSlide> hslfSlideList = hslfSlideShow.getSlides();
-
-            for (int i=0; i < hslfSlideList.size(); i++) {
-                HSLFSlide hslfSlide = hslfSlideList.get(i);
-//                // 设置字体, 解决中文乱码
-//                for (HSLFShape shape : hslfSlide.getShapes()) {
-//                    HSLFTextShape textShape = (HSLFTextShape) shape;
+//    public static boolean pptToPdf(InputStream inputStream, OutputStream outputStream) {
 //
-//                    for (HSLFTextParagraph textParagraph : textShape.getTextParagraphs()) {
-//                        for (HSLFTextRun textRun : textParagraph.getTextRuns()) {
-//                            textRun.setFontFamily("宋体");
-//                        }
-//                    }
-//                }
-                BufferedImage bufferedImage = new BufferedImage((int)dimension.getWidth(), (int)dimension.getHeight(), BufferedImage.TYPE_INT_RGB);
-
-                Graphics2D graphics2d = bufferedImage.createGraphics();
-
-                graphics2d.setPaint(Color.white);
-                graphics2d.setFont(new java.awt.Font("宋体", java.awt.Font.PLAIN, 12));
-
-                hslfSlide.draw(graphics2d);
-
-                graphics2d.dispose();
-
-                Image image = Image.getInstance(bufferedImage, null);
-                image.scalePercent(50f);
-
-                // 写入单元格
-                pdfPTable.addCell(new PdfPCell(image, true));
-                document.add(image);
-
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        } finally {
-            if (document != null) {
-                document.close();
-            }
-            if (pdfWriter != null) {
-                pdfWriter.close();
-            }
-        }
-        System.out.println("ppt转换完毕");
-        return true;
-    }
+//        Document document = null;
+//        HSLFSlideShow hslfSlideShow = null;
+//        PdfWriter pdfWriter = null;
+//
+//        try {
+//            hslfSlideShow = new HSLFSlideShow(inputStream);
+//
+//            // 获取ppt文件页面
+//            Dimension dimension = hslfSlideShow.getPageSize();
+//
+//            document = new Document();
+//
+//            // pdfWriter实例
+//            pdfWriter = PdfWriter.getInstance(document, outputStream);
+//
+//            document.open();
+//
+//            PdfPTable pdfPTable = new PdfPTable(1);
+//
+//            List<HSLFSlide> hslfSlideList = hslfSlideShow.getSlides();
+//
+//            for (int i=0; i < hslfSlideList.size(); i++) {
+//                HSLFSlide hslfSlide = hslfSlideList.get(i);
+////                // 设置字体, 解决中文乱码
+////                for (HSLFShape shape : hslfSlide.getShapes()) {
+////                    HSLFTextShape textShape = (HSLFTextShape) shape;
+////
+////                    for (HSLFTextParagraph textParagraph : textShape.getTextParagraphs()) {
+////                        for (HSLFTextRun textRun : textParagraph.getTextRuns()) {
+////                            textRun.setFontFamily("宋体");
+////                        }
+////                    }
+////                }
+//                BufferedImage bufferedImage = new BufferedImage((int)dimension.getWidth(), (int)dimension.getHeight(), BufferedImage.TYPE_INT_RGB);
+//
+//                Graphics2D graphics2d = bufferedImage.createGraphics();
+//
+//                graphics2d.setPaint(Color.white);
+//                graphics2d.setFont(new java.awt.Font("宋体", java.awt.Font.PLAIN, 12));
+//
+//                hslfSlide.draw(graphics2d);
+//
+//                graphics2d.dispose();
+//
+//                Image image = Image.getInstance(bufferedImage, null);
+//                image.scalePercent(50f);
+//
+//                // 写入单元格
+//                pdfPTable.addCell(new PdfPCell(image, true));
+//                document.add(image);
+//
+//            }
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//            return false;
+//        } finally {
+//            if (document != null) {
+//                document.close();
+//            }
+//            if (pdfWriter != null) {
+//                pdfWriter.close();
+//            }
+//        }
+//        System.out.println("ppt转换完毕");
+//        return true;
+//    }
 
     @Override
     public String changeCourseWareName(Long id, String newName) {

+ 0 - 118
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/utility/FilePdfUtil.java

@@ -1,118 +0,0 @@
-package cn.seecoder.seecoderportalserver.utility;
-
-import com.artofsolving.jodconverter.DocumentConverter;
-import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
-import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
-import com.artofsolving.jodconverter.openoffice.converter.StreamOpenOfficeDocumentConverter;
-//import com.ruoyi.common.utils.StringUtils;
-
-import java.io.*;
-import java.net.ConnectException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-public class FilePdfUtil {
-//    /**
-//     * 转换文件成pdf
-//     *
-//     * @param fromFileInputStream:
-//     * @throws IOException
-//     */
-//    public static String file2pdf(InputStream fromFileInputStream, String type,String pdfPath) throws IOException {
-//        Date date = new Date();
-//        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
-//        String timesuffix = sdf.format(date);
-//        String docFileName = null;
-//        String htmFileName = null;
-//        if("doc".equals(type)){
-//            docFileName = "doc_" + timesuffix + ".doc";
-//            htmFileName = "doc_" + timesuffix + ".pdf";
-//        }else if("docx".equals(type)){
-//            docFileName = "docx_" + timesuffix + ".docx";
-//            htmFileName = "docx_" + timesuffix + ".pdf";
-//        }else if("xls".equals(type)){
-//            docFileName = "xls_" + timesuffix + ".xls";
-//            htmFileName = "xls_" + timesuffix + ".pdf";
-//        }else if("ppt".equals(type)){
-//            docFileName = "ppt_" + timesuffix + ".ppt";
-//            htmFileName = "ppt_" + timesuffix + ".pdf";
-//        }else if("xlsx".equals(type)){
-//            docFileName = "xlsx_" + timesuffix + ".xlsx";
-//            htmFileName = "xlsx_" + timesuffix + ".pdf";
-//        }else if("pptx".equals(type)){
-//            docFileName = "pptx_" + timesuffix + ".pptx";
-//            htmFileName = "pptx_" + timesuffix + ".pdf";
-//        }else{
-//            return null;
-//        }
-//
-//
-//        check_folder(pdfPath);
-//
-//        File htmlOutputFile = new File(pdfPath + File.separatorChar + htmFileName);
-//        File docInputFile = new File(pdfPath + File.separatorChar + docFileName);
-//        if (htmlOutputFile.exists())
-//            htmlOutputFile.delete();
-//        htmlOutputFile.createNewFile();
-//        if (docInputFile.exists())
-//            docInputFile.delete();
-//        docInputFile.createNewFile();
-//        /**
-//         * 由fromFileInputStream构建输入文件
-//         */
-//        try {
-//            OutputStream os = new FileOutputStream(docInputFile);
-//            int bytesRead = 0;
-//            byte[] buffer = new byte[1024 * 8];
-//            while ((bytesRead = fromFileInputStream.read(buffer)) != -1) {
-//                os.write(buffer, 0, bytesRead);
-//            }
-//
-//            os.close();
-//            fromFileInputStream.close();
-//        } catch (IOException e) {
-//        }
-//
-//        OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
-//        try {
-//            connection.connect();
-//        } catch (ConnectException e) {
-//            System.err.println("文件转换出错,请检查OpenOffice服务是否启动。");
-//        }
-//
-//        DocumentConverter converter = new StreamOpenOfficeDocumentConverter(connection);
-//        converter.convert(docInputFile, htmlOutputFile);
-//        connection.disconnect();
-//        // 转换完之后删除word文件
-//        docInputFile.delete();
-//        System.out.println(htmFileName);
-//        return htmFileName;
-//    }
-//
-//    public static void check_folder(String path) {
-//        File dir = new File(path);
-//        // 判断文件夹是否存在
-//        if (dir.isDirectory()) {
-//        } else {
-//            dir.mkdirs();
-//        }
-//    }
-//
-//    public static void copyFile(String oldPath, String newPath) throws IOException {
-//        File oldFile = new File(oldPath);//获取旧的文件File对象
-//        File file = new File(newPath + oldFile.separator + StringUtils.substringAfterLast(oldPath, "/"));  //获取新的文件File对象并生成文件
-//        FileInputStream in = new FileInputStream(oldFile);  //
-//        FileOutputStream out = new FileOutputStream(file);
-//
-//        byte[] buffer=new byte[2097152];
-//        int readByte = 0;
-//        //读取旧文件的流写入新文件里
-//        while((readByte = in.read(buffer)) != -1){
-//            out.write(buffer, 0, readByte);
-//        }
-//
-//        in.close();
-//        out.close();
-//    }
-
-}