Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
package com.jero.modules.document.utils;
|
||||
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.MinioUtil;
|
||||
import com.jero.common.util.obs.ObsBootUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
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;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -20,9 +19,9 @@ import java.util.Objects;
|
||||
public class ReadPdfUtil {
|
||||
|
||||
public static String readPdf(String path) {
|
||||
if(MinioUtil.doesObjectExist(path)){
|
||||
try (InputStream in = MinioUtil.download(path)) {
|
||||
if(Objects.isNull(in) || in.available() == 0){
|
||||
if(StringUtils.isNotBlank(path)){
|
||||
try (InputStream in = ObsBootUtil.getOssFile(path)) {
|
||||
if(Objects.isNull(in)){
|
||||
return null;
|
||||
}
|
||||
try (PDDocument document = PDDocument.load(in)) {
|
||||
|
||||
+56
-17
@@ -24,7 +24,6 @@ import com.jero.modules.split.mapper.SarFileSplitMenuEOMapper;
|
||||
import com.jero.modules.split.service.IFileSplitItemsEOService;
|
||||
import com.jero.modules.split.service.ISarFileSplitItemsValEOService;
|
||||
import com.jero.modules.split.util.AsposeUtil;
|
||||
import com.jero.modules.split.util.FileSplitUtils;
|
||||
import com.jero.modules.split.util.ParagraphChildOrderManager;
|
||||
import com.jero.modules.split.util.ReadWordTable;
|
||||
import com.jero.modules.split.vo.TitleNumberVO;
|
||||
@@ -1045,7 +1044,11 @@ public class FileSpiltService {
|
||||
return startDigitList;
|
||||
}
|
||||
|
||||
public String getOneStartDigit(String arr, SplitFileTypeTypeEnum enumByValue) {
|
||||
public static void main(String[] args) {
|
||||
getOneStartDigit("Scope", SplitFileTypeTypeEnum.UN);
|
||||
}
|
||||
|
||||
public static String getOneStartDigit(String arr, SplitFileTypeTypeEnum enumByValue) {
|
||||
//\p{Punct} 标点符号:!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
|
||||
//\p{Space} 空白字符:[ \t\n\x0B\f\r]
|
||||
//\p{Digit} 十进制数字:[0-9]
|
||||
@@ -1130,13 +1133,19 @@ public class FileSpiltService {
|
||||
throw new JeroBootException("当前文件未找到,请重新选择!");
|
||||
}
|
||||
// try (InputStream is = MinioUtil.download(readFilePath)) {
|
||||
try (InputStream is = ObsBootUtil.getOssFile(readFilePath)) {
|
||||
try (InputStream is = ObsBootUtil.getOssFile(readFilePath);
|
||||
InputStream is2 = ObsBootUtil.getOssFile(readFilePath)) {
|
||||
// InputStream is = new FileInputStream(readFilePath); //需要将文件路更改为word文档所在路径。
|
||||
XWPFDocument doc = new XWPFDocument(is);
|
||||
|
||||
Pattern ptest = Pattern.compile("^[\\d.]*$");
|
||||
// Matcher matcher;
|
||||
|
||||
//获得序号标题和无标题序号
|
||||
TitleNumberVO titleNumberVO = AsposeUtil.getNumber(is2);
|
||||
//TitleNumberVO titleNumberVO = new TitleNumberVO();
|
||||
Map<String, List<String>> titleNumberMap = titleNumberVO.getTitleNumberMap();
|
||||
|
||||
// 记录拆分后的每一段文字
|
||||
List<IBodyElement> elements = doc.getBodyElements();
|
||||
// 记录word自动生成的编号数据
|
||||
@@ -1160,7 +1169,6 @@ public class FileSpiltService {
|
||||
// 段落
|
||||
if (element instanceof XWPFParagraph) {
|
||||
XWPFParagraph p = (XWPFParagraph) element;
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (XWPFRun xwrun : p.getRuns()) {
|
||||
VerticalAlign subscript = xwrun.getSubscript();
|
||||
@@ -1204,7 +1212,7 @@ public class FileSpiltService {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (paragraphString.toLowerCase().contains("scope")) {
|
||||
if (paragraphString.contains("SCOPE")) {
|
||||
String pp = paragraphString.replaceAll("\t", "")
|
||||
.replaceAll("\b", "").replaceAll(" ", "");
|
||||
if (!pp.substring(pp.length()-1).matches(regex)) {
|
||||
@@ -1234,7 +1242,20 @@ public class FileSpiltService {
|
||||
ptest = Pattern.compile("^[\\d.]*$");
|
||||
//定义查看是否有编号,没有编号则按照上一个编号放置数据
|
||||
boolean hasGoIf = false;
|
||||
String startDigit = getOneStartDigit(paragraphString, enumByValue);
|
||||
String startDigit = "";
|
||||
String replace = paragraphString.replace("\"", "");
|
||||
List<String> stringList = titleNumberMap.get(replace);
|
||||
if (CollectionUtils.isNotEmpty(stringList)){
|
||||
startDigit = stringList.get(0);
|
||||
if (messageList.size() == 0){
|
||||
startDigit = startDigit.replace(".", "");
|
||||
}
|
||||
|
||||
paragraphString = startDigit + paragraphString;
|
||||
}else {
|
||||
startDigit = getOneStartDigit(paragraphString, enumByValue);
|
||||
}
|
||||
|
||||
for (int i = 0; i < nowStart.size(); i++) {
|
||||
// if (paragraphString.startsWith(nowStart.get(i))) {
|
||||
if (startDigit.equals(nowStart.get(i)) || startDigit.equals(nowStart.get(i)+ ".") || startDigit.equals(nowStart.get(i)+ "-") ) {
|
||||
@@ -1259,7 +1280,13 @@ public class FileSpiltService {
|
||||
}
|
||||
// 判断名称,如果大于10位,取十位,
|
||||
// String itemName = paragraphString.substring(nowStart.get(i).length()).length()>10?paragraphString.substring(nowStart.get(i).length(),nowStart.get(i).length()+10):paragraphString.substring(nowStart.get(i).length());
|
||||
String itemName = FileSplitUtils.getItemName(paragraphString, startDigit);
|
||||
// String itemName = FileSplitUtils.getItemName(paragraphString, startDigit);
|
||||
String itemName;
|
||||
if (paragraphString.indexOf(nowStart.get(i)) == 0){
|
||||
itemName = paragraphString.substring(nowStart.get(i).length()).trim().length() > 10 ? paragraphString.substring(nowStart.get(i).length()).trim().substring(0,10) :paragraphString.substring(nowStart.get(i).length()).trim();
|
||||
}else {
|
||||
itemName = paragraphString.substring(nowStart.get(i).length()).length() > 10 ? paragraphString.substring(nowStart.get(i).length(), nowStart.get(i).length() + 10) : paragraphString.substring(nowStart.get(i).length());
|
||||
}
|
||||
List<String> clauseContent = new ArrayList<>();
|
||||
clauseContent.add(paragraphString);
|
||||
SarFileSplitItemsEO message = getSarFileSplitItemsEO(sarFileSplitInfoEO.getId(), startDigit, itemName, clauseContent);
|
||||
@@ -1291,20 +1318,32 @@ public class FileSpiltService {
|
||||
|
||||
}
|
||||
if (!hasGoIf && menuCanAdd) {
|
||||
if (("annex1".equals(paragraphString.toLowerCase().replaceAll("\t", "")
|
||||
.replaceAll("\b", "").replaceAll(" ", ""))
|
||||
|| "annex1a".equals(paragraphString.toLowerCase().replaceAll("\t", "")
|
||||
.replaceAll("\b", "").replaceAll(" ", "")))
|
||||
&& !messageList.get(messageList.size() - 1).getItemNum().equals("annex")) {
|
||||
if (paragraphString.toLowerCase().replaceAll("\t", "").startsWith("annex 1")
|
||||
|| paragraphString.toLowerCase().replaceAll("\t", "").startsWith("annex 1a")
|
||||
&& !messageList.get(messageList.size() - 1).getItemNum().equals("annex")){
|
||||
|
||||
String appendixNum = messageList.get(messageList.size() - 1).getItemNum().split("\\.")[0];
|
||||
if (Integer.valueOf(appendixNum) + 1 <= sarFileSplitInfoEO.getStopNumber()) {
|
||||
String itemName = "annex";
|
||||
// }
|
||||
// if (("annex 1".equals(paragraphString.toLowerCase().replaceAll("\t", "")
|
||||
// .replaceAll("\b", "").replaceAll(" ", ""))
|
||||
// || "annex 1a".equals(paragraphString.toLowerCase().replaceAll("\t", "")
|
||||
// .replaceAll("\b", "").replaceAll(" ", "")))
|
||||
// && !messageList.get(messageList.size() - 1).getItemNum().equals("annex")) {
|
||||
|
||||
// String appendixNum = messageList.get(messageList.size() - 1).getItemNum().split("\\.")[0];
|
||||
// if (Integer.valueOf(appendixNum) + 1 <= sarFileSplitInfoEO.getStopNumber()) {
|
||||
if (!messageList.get(messageList.size() - 1).getItemNum().equals("annex")) {
|
||||
// String itemName = "annex";
|
||||
String itemName = paragraphString;
|
||||
List<String> clauseContent = new ArrayList<>();
|
||||
clauseContent.add(paragraphString);
|
||||
SarFileSplitItemsEO message = getSarFileSplitItemsEO(sarFileSplitInfoEO.getId(), "annex", itemName, clauseContent);
|
||||
// 如果itemName长度大于10截取前10位
|
||||
if (itemName.length() > 10) {
|
||||
itemName = itemName.substring(0, 10);
|
||||
}
|
||||
// SarFileSplitItemsEO message = getSarFileSplitItemsEO(sarFileSplitInfoEO.getId(), "annex", itemName, clauseContent);
|
||||
SarFileSplitItemsEO message = getSarFileSplitItemsEO(sarFileSplitInfoEO.getId(), itemName, "", clauseContent);
|
||||
// 增加一条数据,需要在数结构中加一条数据
|
||||
SarFileSplitMenuEO sarFileSplitMenuEO = getTreeList("annex", treeList, generalCatalogueId, sarFileSplitInfoEO, treeListDisplay++, "", enumByValue);
|
||||
SarFileSplitMenuEO sarFileSplitMenuEO = getTreeList(itemName, treeList, generalCatalogueId, sarFileSplitInfoEO, treeListDisplay++, "", enumByValue);
|
||||
addItermsConditionsText(message, itemValList, paragraphString, p.getAlignment());
|
||||
treeList.add(sarFileSplitMenuEO);
|
||||
message.setMenuId(sarFileSplitMenuEO.getId());
|
||||
|
||||
+9
-8
@@ -18,6 +18,7 @@ import com.jero.common.constant.enums.YesOrNoEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.*;
|
||||
import com.jero.common.util.obs.ObsBootUtil;
|
||||
import com.jero.generater.modules.online.cgform.entity.OnlCgformField;
|
||||
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
|
||||
import com.jero.modules.document.enums.FieldTypeEnum;
|
||||
@@ -1782,15 +1783,15 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
// 导入文件
|
||||
OSSFile ossFile = ossFileService.getById(splitFileId);
|
||||
String url = ossFile.getUrl();
|
||||
if (!MinioUtil.doesObjectExist(url)) {
|
||||
if (MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())) {
|
||||
throw new JeroBootException("导入的压缩包不存在!");
|
||||
} else {
|
||||
throw new JeroBootException("Importing a compressed package that does not exist!");
|
||||
}
|
||||
}
|
||||
MultipartFile mFile = null;
|
||||
try (InputStream inputStream = MinioUtil.download(url);) {
|
||||
try (InputStream inputStream = ObsBootUtil.getOssFile(url)) {
|
||||
if (Objects.isNull(inputStream)) {
|
||||
if (MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())) {
|
||||
throw new JeroBootException("导入的压缩包不存在!");
|
||||
} else {
|
||||
throw new JeroBootException("Importing a compressed package that does not exist!");
|
||||
}
|
||||
}
|
||||
String fileName = url.substring((url.lastIndexOf("/") + 1));
|
||||
mFile = new MockMultipartFile(fileName, fileName, ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream);
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -4,8 +4,6 @@ import com.aspose.words.*;
|
||||
import com.jero.modules.split.vo.TitleNumberVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.poi.xwpf.usermodel.VerticalAlign;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
@@ -83,4 +81,9 @@ public class AsposeUtil {
|
||||
titleNumberVO.setEmptyTitleList(emptyTitleList);
|
||||
return titleNumberVO;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String str = "Annex 1";
|
||||
System.out.println(str.substring(0, str.length()-1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class FileSplitUtils {
|
||||
public static void main(String[] args) {
|
||||
String paragraphString ="1.1 weere wewwe";
|
||||
// String paragraphString ="1.1 weere wewwe";
|
||||
String paragraphString ="1.1 APPLICATION FOR APPROVAL";
|
||||
String s ="1.1";
|
||||
|
||||
System.out.println(getItemName(paragraphString,s));
|
||||
|
||||
Reference in New Issue
Block a user