Merge remote-tracking branch 'origin/master'
This commit is contained in:
+4
-4
@@ -1729,7 +1729,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
|
||||
String wordContent = null;
|
||||
try {
|
||||
wordContent = ReadWordUtil.readWord(ossFile.getUrl());
|
||||
wordContent = ReadWordUtil.readWord(ossFile.getUrl(),uploadpath);
|
||||
} catch (Exception e) {
|
||||
log.error("文档库: 读取word内容失败");
|
||||
}
|
||||
@@ -1872,7 +1872,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
|| ossFile.getFileName().endsWith(".DOCX")) {
|
||||
String wordContent = null;
|
||||
try {
|
||||
wordContent = ReadWordUtil.readWord(ossFile.getUrl());
|
||||
wordContent = ReadWordUtil.readWord(ossFile.getUrl(),uploadpath);
|
||||
} catch (Exception e) {
|
||||
log.error("文档库:读取word内容失败");
|
||||
}
|
||||
@@ -2665,7 +2665,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
|| ossFile.getFileName().endsWith(".DOCX")) {
|
||||
String wordContent = null;
|
||||
try {
|
||||
wordContent = ReadWordUtil.readWord(ossFile.getUrl());
|
||||
wordContent = ReadWordUtil.readWord(ossFile.getUrl(),uploadpath);
|
||||
} catch (Exception e) {
|
||||
log.error("文档库:读取word文件内容失败");
|
||||
}
|
||||
@@ -5715,7 +5715,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
public String getTitle(String id,String cut) {
|
||||
LambdaQueryWrapper<BussDocumentLibraryEO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(BussDocumentLibraryEO::getId,id);
|
||||
List<Map<String, Object>> mapList = this.listMaps();
|
||||
List<Map<String, Object>> mapList = this.listMaps(wrapper);
|
||||
String title = "";
|
||||
if(mapList.size() != 0){
|
||||
if(CutEnum.CN.getValue().equals(cut)){
|
||||
|
||||
+36
-12
@@ -1,13 +1,13 @@
|
||||
package com.jero.modules.document.utils;
|
||||
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.oss.CosBootUtil;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;
|
||||
import org.apache.pdfbox.text.PDFTextStripper;
|
||||
import org.apache.pdfbox.text.PDFTextStripperByArea;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @description
|
||||
@@ -17,24 +17,48 @@ import java.io.IOException;
|
||||
public class ReadPdfUtil {
|
||||
|
||||
public static String readPdf(String path) {
|
||||
// path="E:\\DeskTop\\4444.pdf";
|
||||
try (PDDocument document = PDDocument.load(new File(path))) {
|
||||
document.getClass();
|
||||
if(CosBootUtil.doesObjectExist(path)){
|
||||
InputStream in = CosBootUtil.download(path);
|
||||
try (PDDocument document = PDDocument.load(in)) {
|
||||
document.getClass();
|
||||
// if(!document.isEncrypted()) {
|
||||
PDFTextStripperByArea stripper = new PDFTextStripperByArea();
|
||||
stripper.setSortByPosition(true);
|
||||
PDFTextStripper tStripper = new PDFTextStripper();
|
||||
PDFTextStripperByArea stripper = new PDFTextStripperByArea();
|
||||
stripper.setSortByPosition(true);
|
||||
PDFTextStripper tStripper = new PDFTextStripper();
|
||||
|
||||
String pdfFileInText = tStripper.getText(document);
|
||||
return pdfFileInText;
|
||||
String pdfFileInText = tStripper.getText(document);
|
||||
return pdfFileInText;
|
||||
|
||||
// String[] lines = pdfFileInText.split("\\r?\\n");
|
||||
// for(String line : lines) {
|
||||
// System.out.println(line);
|
||||
// }
|
||||
// }
|
||||
}catch (IOException e) {
|
||||
throw new JeroBootException("文件内容读取失败");
|
||||
}catch (IOException e) {
|
||||
throw new JeroBootException("文件内容读取失败");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// public static String readPdf(String path) {
|
||||
//// path="E:\\DeskTop\\4444.pdf";
|
||||
// try (PDDocument document = PDDocument.load(new File(path))) {
|
||||
// document.getClass();
|
||||
//// if(!document.isEncrypted()) {
|
||||
// PDFTextStripperByArea stripper = new PDFTextStripperByArea();
|
||||
// stripper.setSortByPosition(true);
|
||||
// PDFTextStripper tStripper = new PDFTextStripper();
|
||||
//
|
||||
// String pdfFileInText = tStripper.getText(document);
|
||||
// return pdfFileInText;
|
||||
//
|
||||
//// String[] lines = pdfFileInText.split("\\r?\\n");
|
||||
//// for(String line : lines) {
|
||||
//// System.out.println(line);
|
||||
//// }
|
||||
//// }
|
||||
// }catch (IOException e) {
|
||||
// throw new JeroBootException("文件内容读取失败");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
+56
-11
@@ -1,6 +1,7 @@
|
||||
package com.jero.modules.document.utils;
|
||||
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.oss.CosBootUtil;
|
||||
import org.apache.poi.POIXMLDocument;
|
||||
import org.apache.poi.POIXMLTextExtractor;
|
||||
import org.apache.poi.hwpf.extractor.WordExtractor;
|
||||
@@ -8,32 +9,50 @@ import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
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) {
|
||||
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")) {
|
||||
InputStream is = new FileInputStream(new File(path));
|
||||
WordExtractor ex = new WordExtractor(is);
|
||||
str = ex.getText();
|
||||
ex.close();
|
||||
if(CosBootUtil.doesObjectExist(path)){
|
||||
InputStream in = CosBootUtil.download(path);
|
||||
WordExtractor ex = new WordExtractor(in);
|
||||
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();
|
||||
//先把文件存到本地, 用完后在删除
|
||||
if(CosBootUtil.doesObjectExist(path)){
|
||||
InputStream in = CosBootUtil.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();
|
||||
}
|
||||
} else {
|
||||
throw new JeroBootException("此文件不是word文件");
|
||||
}
|
||||
@@ -44,4 +63,30 @@ public class ReadWordUtil {
|
||||
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("文件内容读取失败");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
-1
@@ -231,7 +231,6 @@ public class DummyInventoryInfoEOEn implements Serializable {
|
||||
private String verifyDeliverableType;
|
||||
|
||||
/**验证符合性确认-交付物模板*/
|
||||
|
||||
@ApiModelProperty(value = "验证符合性确认-交付物模板")
|
||||
private String verifyDeliverableTemplate;
|
||||
|
||||
|
||||
+22
-2
@@ -5322,7 +5322,6 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
|
||||
*/
|
||||
@Override
|
||||
public void downloadDocxReport(Map<String, Object> params, HttpServletRequest req, HttpServletResponse resp) {
|
||||
File templateFile = null;
|
||||
File exportFile = null;
|
||||
InputStream fin = null;
|
||||
ServletOutputStream out = null;
|
||||
@@ -5463,7 +5462,27 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
|
||||
dataMap.put("REGULATION_ENG", StringUtils.isNotEmpty(regulationOwnerName) ? regulationOwnerName : "");
|
||||
log.debug("导出word报告,查询数据结束 =============================================================================");
|
||||
log.debug("导出word报告,获取模板开始 =============================================================================");
|
||||
templateFile = new File(exportPdfTempPath + "temp/ComplianceReportTemplate.docx");
|
||||
File templateFile = new File(exportPdfTempPath + "temp/ComplianceReportTemplate.docx");
|
||||
InputStream inputStream = ProjectLawsInventoryEOServiceImpl.class.getClassLoader().getResourceAsStream("exportPdfTemp/ComplianceReportTemplate.docx");
|
||||
try {
|
||||
FileUtils.copyInputStreamToFile(inputStream, templateFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//
|
||||
// try {
|
||||
// OutputStream os = new FileOutputStream(templateFile);
|
||||
// int bytesRead = 0;
|
||||
// byte[] buffer = new byte[8192];
|
||||
// while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) {
|
||||
// os.write(buffer, 0, bytesRead);
|
||||
// }
|
||||
// os.close();
|
||||
// inputStream.close();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
log.debug("导出word报告,获取模板结束 =============================================================================");
|
||||
if(templateFile != null){
|
||||
try {
|
||||
@@ -5479,6 +5498,7 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
|
||||
exportFile = new File(outFile);
|
||||
FileOutputStream os = new FileOutputStream(outFile);
|
||||
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new FileInputStream(templateFile));
|
||||
// WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(inputStream);
|
||||
|
||||
//验证符合性流程实例id
|
||||
String verifyPId = projectTaskInventoryEO.getVerifyPId();
|
||||
|
||||
BIN
Binary file not shown.
@@ -355,6 +355,9 @@
|
||||
<nonFilteredFileExtension>eot</nonFilteredFileExtension>
|
||||
<nonFilteredFileExtension>ttf</nonFilteredFileExtension>
|
||||
<nonFilteredFileExtension>svg</nonFilteredFileExtension>
|
||||
<nonFilteredFileExtension>svg</nonFilteredFileExtension>
|
||||
<nonFilteredFileExtension>doc</nonFilteredFileExtension>
|
||||
<nonFilteredFileExtension>docx</nonFilteredFileExtension>
|
||||
</nonFilteredFileExtensions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
Reference in New Issue
Block a user