Merge branch 'develop_migration' into 'develop_master'
Develop migration See merge request LiuChao/foton-slrs-system-rest!483
This commit is contained in:
+70
-64
@@ -3001,47 +3001,50 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
|
||||
String[] attidlist = String.valueOf(attrInfoMap.get("content")).split(" , ");
|
||||
StringBuilder content = new StringBuilder("");
|
||||
for (int i = 0; i < attidlist.length; i++) {
|
||||
if (org.apache.commons.lang.StringUtils.isNotEmpty(attidlist[i])) {
|
||||
if (StringUtils.isNotEmpty(attidlist[i]) && !"null".equals(attidlist[i]) && attidlist[i].contains("att_file")) {
|
||||
AttFileEO attFileEO = attFileEOService.getFileInfo(attidlist[i]);
|
||||
String readFilePath = filePath + "/" + attFileEO.getFilePath() + attFileEO.getFileName();
|
||||
// String readFilePath = "E:\\上汽企标流程总览.pdf";
|
||||
try {
|
||||
// 判断文件是docx还是PDF
|
||||
if (null != attFileEO.getFileSuffix() && (attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX") || attFileEO.getFileSuffix().equals("ppt") || attFileEO.getFileSuffix().equals("pptx"))) {
|
||||
if (attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX")) {
|
||||
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File(readFilePath)));
|
||||
if (FileMagic.valueOf(bis) == FileMagic.OOXML) {
|
||||
XWPFDocument doc = new XWPFDocument(bis);
|
||||
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
|
||||
File existsFile = new File(readFilePath);
|
||||
if(existsFile.exists()){
|
||||
// 判断文件是docx还是PDF
|
||||
if (null != attFileEO.getFileSuffix() && (attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX") || attFileEO.getFileSuffix().equals("ppt") || attFileEO.getFileSuffix().equals("pptx"))) {
|
||||
if (attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX")) {
|
||||
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File(readFilePath)));
|
||||
if (FileMagic.valueOf(bis) == FileMagic.OOXML) {
|
||||
XWPFDocument doc = new XWPFDocument(bis);
|
||||
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
|
||||
String txt = extractor.getText();
|
||||
content.append(txt);
|
||||
extractor.close();
|
||||
}else {
|
||||
WordExtractor wordExtractor = new WordExtractor(bis);
|
||||
String txt = wordExtractor.getText();
|
||||
content.append(txt);
|
||||
wordExtractor.close();
|
||||
}
|
||||
bis.close();
|
||||
} else {
|
||||
OPCPackage opcPackage = XWPFDocument.openPackage(readFilePath);
|
||||
XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage);
|
||||
String txt = extractor.getText();
|
||||
content.append(txt);
|
||||
extractor.close();
|
||||
}else {
|
||||
WordExtractor wordExtractor = new WordExtractor(bis);
|
||||
String txt = wordExtractor.getText();
|
||||
content.append(txt);
|
||||
wordExtractor.close();
|
||||
opcPackage.close();
|
||||
}
|
||||
bis.close();
|
||||
} else {
|
||||
OPCPackage opcPackage = XWPFDocument.openPackage(readFilePath);
|
||||
XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage);
|
||||
String txt = extractor.getText();
|
||||
content.append(txt);
|
||||
opcPackage.close();
|
||||
PDDocument document = PDDocument.load(new File(readFilePath));
|
||||
document.getClass();
|
||||
if (!document.isEncrypted()) {
|
||||
PDFTextStripperByArea stripper = new PDFTextStripperByArea();
|
||||
stripper.setSortByPosition(true);
|
||||
PDFTextStripper tStripper = new PDFTextStripper();
|
||||
String pdfFileInText = tStripper.getText(document);
|
||||
// String[] lines = pdfFileInText.split("\\r?\\n");
|
||||
content.append(pdfFileInText);
|
||||
}
|
||||
document.close();
|
||||
}
|
||||
} else {
|
||||
PDDocument document = PDDocument.load(new File(readFilePath));
|
||||
document.getClass();
|
||||
if (!document.isEncrypted()) {
|
||||
PDFTextStripperByArea stripper = new PDFTextStripperByArea();
|
||||
stripper.setSortByPosition(true);
|
||||
PDFTextStripper tStripper = new PDFTextStripper();
|
||||
String pdfFileInText = tStripper.getText(document);
|
||||
// String[] lines = pdfFileInText.split("\\r?\\n");
|
||||
content.append(pdfFileInText);
|
||||
}
|
||||
document.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("搜索中心新增数据读取文档内容时失败");
|
||||
@@ -3072,49 +3075,52 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
|
||||
String[] attidlist = String.valueOf(attrInfoMap.get("content")).split(",");
|
||||
StringBuilder content = new StringBuilder("");
|
||||
for (int i = 0; i < attidlist.length; i++) {
|
||||
if (StringUtils.isNotEmpty(attidlist[i]) && !"null".equals(attidlist[i])) {
|
||||
if (StringUtils.isNotEmpty(attidlist[i]) && !"null".equals(attidlist[i]) && attidlist[i].contains("att_file")) {
|
||||
AttFileEO attFileEO = attFileEOService.getFileInfo(attidlist[i]);
|
||||
if (null == attFileEO) {
|
||||
continue;
|
||||
}
|
||||
String readFilePath = filePath + "/" + attFileEO.getFilePath() + attFileEO.getFileName();
|
||||
try {
|
||||
// 判断文件是docx还是PDF
|
||||
if (null != attFileEO.getFileSuffix() && (attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX") || attFileEO.getFileSuffix().equals("ppt") || attFileEO.getFileSuffix().equals("pptx"))) {
|
||||
if (attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX")) {
|
||||
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File(readFilePath)));
|
||||
if (FileMagic.valueOf(bis) == FileMagic.OOXML) {
|
||||
XWPFDocument doc = new XWPFDocument(bis);
|
||||
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
|
||||
File existsFile = new File(readFilePath);
|
||||
if(existsFile.exists()){
|
||||
// 判断文件是docx还是PDF
|
||||
if (null != attFileEO.getFileSuffix() && (attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX") || attFileEO.getFileSuffix().equals("ppt") || attFileEO.getFileSuffix().equals("pptx"))) {
|
||||
if (attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX")) {
|
||||
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File(readFilePath)));
|
||||
if (FileMagic.valueOf(bis) == FileMagic.OOXML) {
|
||||
XWPFDocument doc = new XWPFDocument(bis);
|
||||
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
|
||||
String txt = extractor.getText();
|
||||
content.append(txt);
|
||||
extractor.close();
|
||||
}else {
|
||||
WordExtractor wordExtractor = new WordExtractor(bis);
|
||||
String txt = wordExtractor.getText();
|
||||
content.append(txt);
|
||||
wordExtractor.close();
|
||||
}
|
||||
bis.close();
|
||||
} else {
|
||||
OPCPackage opcPackage = XWPFDocument.openPackage(readFilePath);
|
||||
XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage);
|
||||
String txt = extractor.getText();
|
||||
content.append(txt);
|
||||
extractor.close();
|
||||
}else {
|
||||
WordExtractor wordExtractor = new WordExtractor(bis);
|
||||
String txt = wordExtractor.getText();
|
||||
content.append(txt);
|
||||
wordExtractor.close();
|
||||
opcPackage.close();
|
||||
}
|
||||
bis.close();
|
||||
} else {
|
||||
OPCPackage opcPackage = XWPFDocument.openPackage(readFilePath);
|
||||
XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage);
|
||||
String txt = extractor.getText();
|
||||
content.append(txt);
|
||||
opcPackage.close();
|
||||
PDDocument document = PDDocument.load(new File(readFilePath));
|
||||
document.getClass();
|
||||
if (!document.isEncrypted()) {
|
||||
PDFTextStripperByArea stripper = new PDFTextStripperByArea();
|
||||
stripper.setSortByPosition(true);
|
||||
PDFTextStripper tStripper = new PDFTextStripper();
|
||||
String pdfFileInText = tStripper.getText(document);
|
||||
// String[] lines = pdfFileInText.split("\\r?\\n");
|
||||
content.append(pdfFileInText);
|
||||
}
|
||||
document.close();
|
||||
}
|
||||
} else {
|
||||
PDDocument document = PDDocument.load(new File(readFilePath));
|
||||
document.getClass();
|
||||
if (!document.isEncrypted()) {
|
||||
PDFTextStripperByArea stripper = new PDFTextStripperByArea();
|
||||
stripper.setSortByPosition(true);
|
||||
PDFTextStripper tStripper = new PDFTextStripper();
|
||||
String pdfFileInText = tStripper.getText(document);
|
||||
// String[] lines = pdfFileInText.split("\\r?\\n");
|
||||
content.append(pdfFileInText);
|
||||
}
|
||||
document.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("搜索中心修改数据读取文档内容时失败");
|
||||
|
||||
Reference in New Issue
Block a user