update 更改模块名称

This commit is contained in:
lijiarao
2023-09-05 09:10:12 +08:00
parent 248a2dbe8a
commit 8522fc6f34
1501 changed files with 4 additions and 47397 deletions
@@ -0,0 +1,37 @@
package com.jero.modules.document.utils;
import com.jero.common.exception.JeroBootException;
import com.jero.common.util.MinioUtil;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
import org.apache.pdfbox.text.PDFTextStripperByArea;
import java.io.IOException;
import java.io.InputStream;
/**
* @description
* @date 2022/3/21 17:04
* @auth zhn
*/
public class ReadPdfUtil {
public static String readPdf(String path) {
if(MinioUtil.doesObjectExist(path)){
try (InputStream in = MinioUtil.download(path);
PDDocument document = PDDocument.load(in)) {
document.getClass();
PDFTextStripperByArea stripper = new PDFTextStripperByArea();
stripper.setSortByPosition(true);
PDFTextStripper tStripper = new PDFTextStripper();
String pdfFileInText = tStripper.getText(document);
return pdfFileInText;
}catch (IOException e) {
throw new JeroBootException("文件内容读取失败");
}
}
return null;
}
}
@@ -0,0 +1,96 @@
package com.jero.modules.document.utils;
import com.jero.common.exception.JeroBootException;
import com.jero.common.util.MinioUtil;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.ooxml.POIXMLDocument;
import org.apache.poi.ooxml.extractor.POIXMLTextExtractor;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import java.io.File;
import java.io.InputStream;
import static com.jero.modules.document.service.impl.BussDocumentLibraryEOServiceImpl.copyFile;
/**
* @description
* @date 2022/3/21 17:04
* @auth zhn
*/
public class ReadWordUtil {
public static String readWord(String path,String uploadpath) {
// String path = "E:\\DeskTop\\1111.doc";
// path = "E:\\DeskTop\\22222.docx";
// String path = "E:\\DeskTop\\标准所ISO-用户手册.doc";
String str = "";
try {
if (path.endsWith(".doc")) {
if(MinioUtil.doesObjectExist(path)){
InputStream in = MinioUtil.download(path);
WordExtractor ex = new WordExtractor(in);
str = ex.getText();
ex.close();
in.close();
}
} else if (path.endsWith("docx")) {
//先把文件存到本地, 用完后在删除
if(MinioUtil.doesObjectExist(path)){
InputStream in = MinioUtil.download(path);
String fileNowPath = uploadpath + "/tempZip/" ;
File file = new File(fileNowPath);
if (file.exists()) {
file.delete();
}
file.mkdirs();
File fileOld = new File(path);
long currentTime = System.currentTimeMillis();
copyFile(in, fileNowPath + File.separator + currentTime + fileOld.getName());
File fileTemp = new File(fileNowPath + File.separator + currentTime + fileOld.getName());
String pathTemp = fileTemp.getPath();
OPCPackage opcPackage = POIXMLDocument.openPackage(pathTemp);
POIXMLTextExtractor extractor = new XWPFWordExtractor(opcPackage);
str = extractor.getText().trim();
extractor.close();
fileTemp.delete();
in.close();
}
} else {
throw new JeroBootException("此文件不是word文件");
}
return str;
} catch (Exception e) {
e.printStackTrace();
throw new JeroBootException("文件内容读取失败");
}catch (NoSuchFieldError e){
e.printStackTrace();
throw new JeroBootException("文件内容读取失败");
}
}
// public static String readWord(String path) {
//// String path = "E:\\DeskTop\\1111.doc";
//// path = "E:\\DeskTop\\22222.docx";
//// String path = "E:\\DeskTop\\标准所ISO-用户手册.doc";
// String str = "";
// try {
// if (path.endsWith(".doc")) {
// InputStream is = new FileInputStream(new File(path));
// WordExtractor ex = new WordExtractor(is);
// str = ex.getText();
// ex.close();
// } else if (path.endsWith("docx")) {
// OPCPackage opcPackage = POIXMLDocument.openPackage(path);
// POIXMLTextExtractor extractor = new XWPFWordExtractor(opcPackage);
// str = extractor.getText();
// extractor.close();
// } else {
// throw new JeroBootException("此文件不是word文件");
// }
// return str;
// } catch (Exception e) {
// throw new JeroBootException("文件内容读取失败");
// }catch (NoSuchFieldError e){
// throw new JeroBootException("文件内容读取失败");
// }
// }
}