From f826c3a057cb892c020de5694fee0854b16675e4 Mon Sep 17 00:00:00 2001
From: whycxzp <perryhsu@163.com>
Date: 星期一, 05 九月 2022 11:21:08 +0800
Subject: [PATCH] word预览

---
 src/main/java/com/whyc/service/ProductBomApprovingService.java |   33 ++++++++++++++++++++++++++-------
 1 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/whyc/service/ProductBomApprovingService.java b/src/main/java/com/whyc/service/ProductBomApprovingService.java
index c811e42..8f32d54 100644
--- a/src/main/java/com/whyc/service/ProductBomApprovingService.java
+++ b/src/main/java/com/whyc/service/ProductBomApprovingService.java
@@ -389,20 +389,39 @@
         return list;
     }
 
+    /**
+     *
+     * @param dwgUrl 棰勮dwg鍥剧焊鏂囦欢,鍚庤拷鍔犻瑙坵ord鏂囨。
+     * @return
+     * @throws IOException
+     */
     public Response dwgReview(String dwgUrl) throws IOException {
+        String fileSuffix = dwgUrl.substring(dwgUrl.lastIndexOf(".") + 1);
         //缁濆璺緞xxx/doc_file
         String rootFile = CommonUtil.getRootFile();
         String dwgSubFilePath = dwgUrl.substring(dwgUrl.indexOf("doc_file")+8);
         String dwgSubFileDirPath = dwgSubFilePath.substring(0,dwgSubFilePath.lastIndexOf(File.separator));
         File dwgFile = new File(rootFile + dwgSubFilePath);
-        String dwgPdfUrl = dwgFile.getParent() + File.separator + dwgFile.getName().substring(0, dwgFile.getName().lastIndexOf(".")) + "-dwg.pdf";
-        File dwgPdfFile = new File(dwgPdfUrl);
-        String pdfFileName = null;
-        if(!dwgPdfFile.exists()) {
-            pdfFileName = DwgToPdfUtil.dwg2Pdf(dwgFile);
-        }else{
-            pdfFileName = dwgPdfFile.getName();
+        String pdfUrl = "";
+        if(fileSuffix.equals("dwg")) {
+            pdfUrl = dwgFile.getParent() + File.separator + dwgFile.getName().substring(0, dwgFile.getName().lastIndexOf(".")) + "-dwg.pdf";
+        }else if(fileSuffix.contains("doc")){
+            pdfUrl = dwgFile.getParent() + File.separator + dwgFile.getName().substring(0, dwgFile.getName().lastIndexOf(".")) + "-doc.pdf";
         }
+        File pdfFile = new File(pdfUrl);
+        String pdfFileName = null;
+        if(!pdfFile.exists()) {
+            if(fileSuffix.equals("dwg")) {
+                //pdfFileName = DwgToPdfUtil.dwg2Pdf(dwgFile);
+                DwgToPdfUtil.dwg2Pdf(dwgFile);
+            }else if(fileSuffix.contains("doc")){
+                Word2PdfAsposeUtil.doc2pdf(dwgFile.getAbsolutePath(),pdfUrl);
+            }
+
+        }/*else{
+            pdfFileName = pdfFile.getName();
+        }*/
+        pdfFileName = pdfFile.getName();
         return new Response().set(1,"doc_file"+dwgSubFileDirPath+File.separator+pdfFileName);
     }
 

--
Gitblit v1.9.1