bc_zhang hace 4 años
padre
commit
4b090e0d78

+ 1 - 1
src/main/java/com/zglc/fm/controller/BookController.java

@@ -198,7 +198,7 @@ public class BookController {
 
     @ApiOperation("列出文档目录")
     @ApiResponses({        @ApiResponse(code = 0, message = "成功")})
-    @PostMapping("listAllDoccatalogue")
+    @GetMapping("listAllDoccatalogue")
     public Result<List<CatalogueEntity>> listAllDoccatalogue(Integer bookId) {
         return Result.success( bookService.listAllDoccatalogue(bookId));
     }

+ 81 - 63
src/main/java/com/zglc/fm/schedule/ScheduleTasks.java

@@ -95,17 +95,18 @@ public class ScheduleTasks {
         for (File f : files) {
             if (f.getName().endsWith(ExcelUtils.DOC) || f.getName().endsWith(ExcelUtils.DOCX)) {
                 MultipartFile mfile = transtTo(f);
-                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime() + f.getName());
-                //转为pdf
+                String extName = ""; // 扩展名格式:
+                extName = mfile.getOriginalFilename().substring(mfile.getOriginalFilename().lastIndexOf("."));
+                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime()  + extName);                //转为pdf
                 DocToPdf.convertDoc2Pdf(filePath, sourcePath1);
-                if (f.getName().endsWith(ExcelUtils.DOC))  {
-                    deleteDir1(new File(filePath));
-                    filePath = filePath.replaceAll( "doc","pdf");
-                }
-                if (f.getName().endsWith(ExcelUtils.DOCX))  {
-                    deleteDir1(new File(filePath));
-                    filePath = filePath.replaceAll( "docx","pdf");
-                }
+//                if (f.getName().endsWith(ExcelUtils.DOC))  {
+//                    deleteDir1(new File(filePath));
+//                    filePath = filePath.replaceAll( "doc","pdf");
+//                }
+//                if (f.getName().endsWith(ExcelUtils.DOCX))  {
+//                    deleteDir1(new File(filePath));
+//                    filePath = filePath.replaceAll( "docx","pdf");
+//                }
                 filePath = filePath.replaceAll( "d:","");
                 String name = null;
                 if (f.getName().endsWith(ExcelUtils.DOC)) {
@@ -125,7 +126,9 @@ public class ScheduleTasks {
             else
             {
                 MultipartFile mfile = transtTo(f);
-                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime() + f.getName());
+                String extName = ""; // 扩展名格式:
+                extName = mfile.getOriginalFilename().substring(mfile.getOriginalFilename().lastIndexOf("."));
+                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime()  + extName);
                 filePath = filePath.replaceAll( "d:","");
                 FaultEntity fault = new FaultEntity();
                 fault.setFault_name(f.getName().replace( ".pdf",""));
@@ -145,17 +148,18 @@ public class ScheduleTasks {
         for (File f : files) {
             if (f.getName().endsWith(ExcelUtils.DOC) || f.getName().endsWith(ExcelUtils.DOCX)) {
                 MultipartFile mfile = transtTo(f);
-                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime() + f.getName());
-                //转为pdf
+                String extName = ""; // 扩展名格式:
+                extName = mfile.getOriginalFilename().substring(mfile.getOriginalFilename().lastIndexOf("."));
+                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime()  + extName);                //转为pdf
                 DocToPdf.convertDoc2Pdf(filePath, sourcePath1);
-                if (f.getName().endsWith(ExcelUtils.DOC))  {
-                    deleteDir1(new File(filePath));
-                    filePath = filePath.replaceAll( "doc","pdf");
-                }
-                if (f.getName().endsWith(ExcelUtils.DOCX))  {
-                    deleteDir1(new File(filePath));
-                    filePath = filePath.replaceAll( "docx","pdf");
-                }
+//                if (f.getName().endsWith(ExcelUtils.DOC))  {
+//                    deleteDir1(new File(filePath));
+//                    filePath = filePath.replaceAll( "doc","pdf");
+//                }
+//                if (f.getName().endsWith(ExcelUtils.DOCX))  {
+//                    deleteDir1(new File(filePath));
+//                    filePath = filePath.replaceAll( "docx","pdf");
+//                }
                 filePath = filePath.replaceAll( "d:","");
                 String name = null;
                 if (f.getName().endsWith(ExcelUtils.DOC)) {
@@ -175,7 +179,9 @@ public class ScheduleTasks {
             else
             {
                 MultipartFile mfile = transtTo(f);
-                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime() + f.getName());
+                String extName = ""; // 扩展名格式:
+                extName = mfile.getOriginalFilename().substring(mfile.getOriginalFilename().lastIndexOf("."));
+                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime()  + extName);
                 filePath = filePath.replaceAll( "d:","");
                 BookEntity book = new BookEntity();
                 book.setBook_name(f.getName().replace( ".pdf",""));
@@ -195,17 +201,18 @@ public class ScheduleTasks {
         for (File f : files) {
             if (f.getName().endsWith(ExcelUtils.DOC) || f.getName().endsWith(ExcelUtils.DOCX)) {
                 MultipartFile mfile = transtTo(f);
-                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime() + f.getName());
-                //转为pdf
+                String extName = ""; // 扩展名格式:
+                extName = mfile.getOriginalFilename().substring(mfile.getOriginalFilename().lastIndexOf("."));
+                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime()  + extName);                //转为pdf
                 DocToPdf.convertDoc2Pdf(filePath, sourcePath1);
-                if (f.getName().endsWith(ExcelUtils.DOC))  {
-                    deleteDir1(new File(filePath));
-                    filePath = filePath.replaceAll( "doc","pdf");
-                }
-                if (f.getName().endsWith(ExcelUtils.DOCX))  {
-                    deleteDir1(new File(filePath));
-                    filePath = filePath.replaceAll( "docx","pdf");
-                }
+//                if (f.getName().endsWith(ExcelUtils.DOC))  {
+//                    deleteDir1(new File(filePath));
+//                    filePath = filePath.replaceAll( "doc","pdf");
+//                }
+//                if (f.getName().endsWith(ExcelUtils.DOCX))  {
+//                    deleteDir1(new File(filePath));
+//                    filePath = filePath.replaceAll( "docx","pdf");
+//                }
                 filePath = filePath.replaceAll( "d:","");
                 String name = null;
                 if (f.getName().endsWith(ExcelUtils.DOC)) {
@@ -224,17 +231,18 @@ public class ScheduleTasks {
             }
             else if (f.getName().endsWith(ExcelUtils.XLS) || f.getName().endsWith(ExcelUtils.XLSX)) {
                 MultipartFile mfile = transtTo(f);
-                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime() + f.getName());
-                //转为pdf
+                String extName = ""; // 扩展名格式:
+                extName = mfile.getOriginalFilename().substring(mfile.getOriginalFilename().lastIndexOf("."));
+                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime()  + extName);                //转为pdf
                 ExcelToPdf.convertExcel2Pdf(filePath, sourcePath1);
-                if (f.getName().endsWith(ExcelUtils.XLS))  {
-                    deleteDir1(new File(filePath));
-                    filePath = filePath.replaceAll( "xls","pdf");
-                }
-                if (f.getName().endsWith(ExcelUtils.XLSX))  {
-                    deleteDir1(new File(filePath));
-                    filePath = filePath.replaceAll( "xlsx","pdf");
-                }
+//                if (f.getName().endsWith(ExcelUtils.XLS))  {
+//                    deleteDir1(new File(filePath));
+//                    filePath = filePath.replaceAll( "xls","pdf");
+//                }
+//                if (f.getName().endsWith(ExcelUtils.XLSX))  {
+//                    deleteDir1(new File(filePath));
+//                    filePath = filePath.replaceAll( "xlsx","pdf");
+//                }
                 filePath = filePath.replaceAll( "d:","");
                 String name = null;
                 if (f.getName().endsWith(ExcelUtils.XLS)) {
@@ -253,7 +261,9 @@ public class ScheduleTasks {
             else
             {
                 MultipartFile mfile = transtTo(f);
-                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime() + f.getName());
+                String extName = ""; // 扩展名格式:
+                extName = mfile.getOriginalFilename().substring(mfile.getOriginalFilename().lastIndexOf("."));
+                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime()  + extName);
                 filePath = filePath.replaceAll( "d:","");
                 CardEntity card = new CardEntity();
                 card.setCard_name(f.getName().replace( ".pdf",""));
@@ -273,17 +283,19 @@ public class ScheduleTasks {
         for (File f : files) {
             if (f.getName().endsWith(ExcelUtils.DOC) || f.getName().endsWith(ExcelUtils.DOCX)) {
                 MultipartFile mfile = transtTo(f);
-                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime() + f.getName());
+                String extName = ""; // 扩展名格式:
+                extName = mfile.getOriginalFilename().substring(mfile.getOriginalFilename().lastIndexOf("."));
+                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime()  + extName);
                 //转为pdf
                 DocToPdf.convertDoc2Pdf(filePath, sourcePath1);
-                if (f.getName().endsWith(ExcelUtils.DOC))  {
-                    deleteDir1(new File(filePath));
-                    filePath = filePath.replaceAll( "doc","pdf");
-                }
-                if (f.getName().endsWith(ExcelUtils.DOCX))  {
-                    deleteDir1(new File(filePath));
-                    filePath = filePath.replaceAll( "docx","pdf");
-                }
+//                if (f.getName().endsWith(ExcelUtils.DOC))  {
+//                    deleteDir1(new File(filePath));
+//                    filePath = filePath.replaceAll( "doc","pdf");
+//                }
+//                if (f.getName().endsWith(ExcelUtils.DOCX))  {
+//                    deleteDir1(new File(filePath));
+//                    filePath = filePath.replaceAll( "docx","pdf");
+//                }
                 filePath = filePath.replaceAll( "d:","");
                 String name = null;
                 if (f.getName().endsWith(ExcelUtils.DOC)) {
@@ -303,7 +315,9 @@ public class ScheduleTasks {
             else
             {
                 MultipartFile mfile = transtTo(f);
-                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime() + f.getName());
+                String extName = ""; // 扩展名格式:
+                extName = mfile.getOriginalFilename().substring(mfile.getOriginalFilename().lastIndexOf("."));
+                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime()  + extName);
                 filePath = filePath.replaceAll( "d:","");
                 ManuelEntity manuel = new ManuelEntity();
                 manuel.setManuel_name(f.getName().replace( ".pdf",""));
@@ -323,17 +337,19 @@ public class ScheduleTasks {
         for (File f : files) {
             if (f.getName().endsWith(ExcelUtils.DOC) || f.getName().endsWith(ExcelUtils.DOCX)) {
                 MultipartFile mfile = transtTo(f);
-                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime() + f.getName());
+                String extName = ""; // 扩展名格式:
+                extName = mfile.getOriginalFilename().substring(mfile.getOriginalFilename().lastIndexOf("."));
+                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime()  + extName);
                 //转为pdf
                 DocToPdf.convertDoc2Pdf(filePath, sourcePath1);
-                if (f.getName().endsWith(ExcelUtils.DOC))  {
-                    deleteDir1(new File(filePath));
-                    filePath = filePath.replaceAll( "doc","pdf");
-                }
-                if (f.getName().endsWith(ExcelUtils.DOCX))  {
-                    deleteDir1(new File(filePath));
-                    filePath = filePath.replaceAll( "docx","pdf");
-                }
+//                if (f.getName().endsWith(ExcelUtils.DOC))  {
+//                    deleteDir1(new File(filePath));
+//                    filePath = filePath.replaceAll( "doc","pdf");
+//                }
+//                if (f.getName().endsWith(ExcelUtils.DOCX))  {
+//                    deleteDir1(new File(filePath));
+//                    filePath = filePath.replaceAll( "docx","pdf");
+//                }
                 filePath = filePath.replaceAll( "d:","");
                 String name = null;
                 if (f.getName().endsWith(ExcelUtils.DOC)) {
@@ -353,7 +369,9 @@ public class ScheduleTasks {
             else
             {
                 MultipartFile mfile = transtTo(f);
-                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime() + f.getName());
+                String extName = ""; // 扩展名格式:
+                extName = mfile.getOriginalFilename().substring(mfile.getOriginalFilename().lastIndexOf("."));
+                String filePath = FileTool.fileUp(mfile, sourcePath1, new Date().getTime()  + extName);
                 filePath = filePath.replaceAll( "d:","");
                 OutlineEntity outline = new OutlineEntity();
                 outline.setOutline_name(f.getName().replace( ".pdf",""));