|
|
|
@ -3,6 +3,7 @@ package com.docus.sw.fenpan;
|
|
|
|
|
import com.alibaba.excel.util.FileUtils;
|
|
|
|
|
import com.docus.sw.Config;
|
|
|
|
|
import com.docus.sw.word.GetPicsDocx;
|
|
|
|
|
import com.docus.sw.word.MyFileUtil;
|
|
|
|
|
import com.docus.sw.word.PdfBoxUtils;
|
|
|
|
|
import com.docus.sw.word.ReadImgDoc;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -107,21 +108,17 @@ public class FenpanService {
|
|
|
|
|
if (piece.getFileTypeEnum() == FileTypeEnum.DOC) {
|
|
|
|
|
//从word 直接提取图片
|
|
|
|
|
//提取图片为document ,然后用于后面判断
|
|
|
|
|
File file = new File("temp");
|
|
|
|
|
String teamName = "temp/"+UUID.randomUUID();
|
|
|
|
|
File file = new File(teamName);
|
|
|
|
|
if(!file.exists()){
|
|
|
|
|
file.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReadImgDoc.readPicture(piece.getAbsolutePath(),file.getAbsolutePath());
|
|
|
|
|
List<Document> documentList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
PdfBoxUtils.pdf2image(piece.getAbsolutePath(),file.getAbsolutePath());
|
|
|
|
|
File[] files = file.listFiles();
|
|
|
|
|
for(File pdfImg:files){
|
|
|
|
|
getDocumentList(documentList, pdfImg);
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
log.error(e.getMessage(),e);
|
|
|
|
|
ReadImgDoc.readPicture(piece.getAbsolutePath(),file.getAbsolutePath());
|
|
|
|
|
File[] files = file.listFiles();
|
|
|
|
|
for(File pdfImg:files){
|
|
|
|
|
getDocumentList(documentList, pdfImg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
piece.put(documentList);
|
|
|
|
@ -130,21 +127,17 @@ public class FenpanService {
|
|
|
|
|
} else if (piece.getFileTypeEnum() == FileTypeEnum.DOCX) {
|
|
|
|
|
//从word 直接提取图片
|
|
|
|
|
//提取图片为document ,然后用于后面判断
|
|
|
|
|
File file = new File("temp");
|
|
|
|
|
String teamName = "temp/"+UUID.randomUUID();
|
|
|
|
|
File file = new File(teamName);
|
|
|
|
|
if(!file.exists()){
|
|
|
|
|
file.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GetPicsDocx.getPics(piece.getAbsolutePath(),file.getAbsolutePath());
|
|
|
|
|
List<Document> documentList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
PdfBoxUtils.pdf2image(piece.getAbsolutePath(),file.getAbsolutePath());
|
|
|
|
|
File[] files = file.listFiles();
|
|
|
|
|
for(File pdfImg:files){
|
|
|
|
|
getDocumentList(documentList, pdfImg);
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
log.error(e.getMessage(),e);
|
|
|
|
|
GetPicsDocx.getPics(piece.getAbsolutePath(),file.getAbsolutePath());
|
|
|
|
|
File[] files = file.listFiles();
|
|
|
|
|
for(File pdfImg:files){
|
|
|
|
|
getDocumentList(documentList, pdfImg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
piece.put(documentList);
|
|
|
|
@ -153,7 +146,8 @@ public class FenpanService {
|
|
|
|
|
} else if (piece.getFileTypeEnum() == FileTypeEnum.PDF) {
|
|
|
|
|
// 从pdf 提取图片,
|
|
|
|
|
//提取图片为document ,然后用于后面判断
|
|
|
|
|
File file = new File("temp");
|
|
|
|
|
String teamName = "temp/"+UUID.randomUUID();
|
|
|
|
|
File file = new File(teamName);
|
|
|
|
|
if(!file.exists()){
|
|
|
|
|
file.mkdirs();
|
|
|
|
|
}
|
|
|
|
@ -162,7 +156,9 @@ public class FenpanService {
|
|
|
|
|
try {
|
|
|
|
|
PdfBoxUtils.pdf2image(piece.getAbsolutePath(),file.getAbsolutePath());
|
|
|
|
|
File[] files = file.listFiles();
|
|
|
|
|
System.out.println("件名:"+file.getName());
|
|
|
|
|
for(File pdfImg:files){
|
|
|
|
|
System.out.println("图片名"+pdfImg.getName());
|
|
|
|
|
getDocumentList(documentList, pdfImg);
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
@ -171,7 +167,7 @@ public class FenpanService {
|
|
|
|
|
|
|
|
|
|
piece.put(documentList);
|
|
|
|
|
//删除对应的temp 文件
|
|
|
|
|
FileUtils.delete(file);
|
|
|
|
|
// FileUtils.delete(file);
|
|
|
|
|
} else {
|
|
|
|
|
//是图片,直接从图片提取
|
|
|
|
|
List<Document> documentList = new ArrayList<>();
|
|
|
|
@ -203,6 +199,9 @@ public class FenpanService {
|
|
|
|
|
zongMap.put(zongName, zong);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileUtils.delete(new File("temp"));
|
|
|
|
|
|
|
|
|
|
for (String zongName : zongMap.keySet()) {
|
|
|
|
|
Zong zong = zongMap.get(zongName);
|
|
|
|
|
File zongfile = new File(zong.getAbsolutePath());
|
|
|
|
|