修改拆分表格包公式
This commit is contained in:
+117
-80
@@ -44,10 +44,7 @@ import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTAnchor
|
|||||||
import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline;
|
import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline;
|
||||||
import org.openxmlformats.schemas.officeDocument.x2006.math.CTOMath;
|
import org.openxmlformats.schemas.officeDocument.x2006.math.CTOMath;
|
||||||
import org.openxmlformats.schemas.officeDocument.x2006.math.CTOMathPara;
|
import org.openxmlformats.schemas.officeDocument.x2006.math.CTOMathPara;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDrawing;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLevelText;
|
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
|
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
@@ -151,17 +148,10 @@ public class FileSpiltService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String partName = "";
|
String partName = "";
|
||||||
// LawsDomesticStandard lawsDomesticStandard = lawsDomesticStandardService.getById(sarFileSplitInfoEO.getStandardId());
|
|
||||||
// LawsEnterpriseStandard lawsEnterpriseStandard = lawsEnterpriseStandardService.getById(sarFileSplitInfoEO.getStandardId());
|
|
||||||
// if (!Objects.isNull(lawsDomesticStandard)){
|
|
||||||
// partName = lawsDomesticStandard.getPartName();
|
|
||||||
// }else {
|
|
||||||
// partName = lawsEnterpriseStandard.getPartName();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 拆分文件条款表中最终插入数据
|
// 拆分文件条款表中最终插入数据
|
||||||
List<SarFileSplitItemsEO> messageList = new ArrayList<>();
|
List<SarFileSplitItemsEO> messageList = new ArrayList<>();
|
||||||
// List<SarFileSplitItemsValEO> messageList = new ArrayList<>();
|
|
||||||
int messageNumber = 0;
|
int messageNumber = 0;
|
||||||
// 拆分文件目录表中最终插入数据
|
// 拆分文件目录表中最终插入数据
|
||||||
List<SarFileSplitMenuEO> treeList = new ArrayList<>();
|
List<SarFileSplitMenuEO> treeList = new ArrayList<>();
|
||||||
@@ -171,7 +161,6 @@ public class FileSpiltService {
|
|||||||
|
|
||||||
String generalCatalogueId = UUIDUtils.randomUUID20();
|
String generalCatalogueId = UUIDUtils.randomUUID20();
|
||||||
SarFileSplitMenuEO documentTreeEO = new SarFileSplitMenuEO();
|
SarFileSplitMenuEO documentTreeEO = new SarFileSplitMenuEO();
|
||||||
// SarFileSplitMenuEO documentTreeEO = new SarFileSplitMenuEO(generalCatalogueId,"总目录","",sarFileSplitInfoEO.getId(),treeListDisplay++,"");
|
|
||||||
documentTreeEO.setId(generalCatalogueId);
|
documentTreeEO.setId(generalCatalogueId);
|
||||||
documentTreeEO.setName("总目录");
|
documentTreeEO.setName("总目录");
|
||||||
documentTreeEO.setInfoId(sarFileSplitInfoEO.getId());
|
documentTreeEO.setInfoId(sarFileSplitInfoEO.getId());
|
||||||
@@ -183,15 +172,11 @@ public class FileSpiltService {
|
|||||||
treeList.add(documentTreeEO);
|
treeList.add(documentTreeEO);
|
||||||
|
|
||||||
List<String> nowStart = new ArrayList<>();
|
List<String> nowStart = new ArrayList<>();
|
||||||
// if (sarFileSplitInfoEO.getStartNumber()<4){
|
|
||||||
//从第二个开始拆解
|
//从第二个开始拆解
|
||||||
nowStart.add("2");
|
nowStart.add("2");
|
||||||
// } else {
|
|
||||||
// nowStart.add(String.valueOf(sarFileSplitInfoEO.getStartNumber()));
|
|
||||||
// }
|
|
||||||
//获取文件地址
|
//获取文件地址
|
||||||
|
|
||||||
InputStream splitFileIs = null;
|
InputStream splitFileIs = null;
|
||||||
|
InputStream splitFileIs1 = null;
|
||||||
if (StringUtils.equals(splitSource, CommonConstant.SPLIT_SOURCE_1)) {
|
if (StringUtils.equals(splitSource, CommonConstant.SPLIT_SOURCE_1)) {
|
||||||
String fileId = sarFileSplitInfoEO.getFileId();
|
String fileId = sarFileSplitInfoEO.getFileId();
|
||||||
|
|
||||||
@@ -209,9 +194,11 @@ public class FileSpiltService {
|
|||||||
throw new JeroBootException("当前文件未找到,请重新选择!");
|
throw new JeroBootException("当前文件未找到,请重新选择!");
|
||||||
}
|
}
|
||||||
splitFileIs = MinioUtil.download(readFilePath);
|
splitFileIs = MinioUtil.download(readFilePath);
|
||||||
|
splitFileIs1 = MinioUtil.download(readFilePath);
|
||||||
} else if (CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){
|
} else if (CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){
|
||||||
try {
|
try {
|
||||||
splitFileIs = new FileInputStream(readFilePath);
|
splitFileIs = new FileInputStream(readFilePath);
|
||||||
|
splitFileIs1 = new FileInputStream(readFilePath);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new JeroBootException("当前文件未找到,请重新选择!");
|
throw new JeroBootException("当前文件未找到,请重新选择!");
|
||||||
@@ -236,14 +223,13 @@ public class FileSpiltService {
|
|||||||
HttpEntity<Map<String, String>> requestEntity = new HttpEntity<>(params, headers);
|
HttpEntity<Map<String, String>> requestEntity = new HttpEntity<>(params, headers);
|
||||||
|
|
||||||
// 发送POST请求并获取响应
|
// 发送POST请求并获取响应
|
||||||
// ResponseEntity<byte[]> responseEntity = restTemplate.postForEntity(bydDownLoadFileUrl, requestEntity, byte[].class);
|
|
||||||
|
|
||||||
Long fileIdLong = Long.valueOf(sarFileSplitInfoEO.getId());
|
Long fileIdLong = Long.valueOf(sarFileSplitInfoEO.getId());
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(bydDownLoadFileUrl).queryParam("fileId", fileIdLong);
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(bydDownLoadFileUrl).queryParam("fileId", fileIdLong);
|
||||||
// 发送POST请求并获取响应
|
// 发送POST请求并获取响应
|
||||||
ResponseEntity<byte[]> responseEntity = restTemplate.postForEntity(builder.toUriString(), requestEntity, byte[].class);
|
ResponseEntity<byte[]> responseEntity = restTemplate.postForEntity(builder.toUriString(), requestEntity, byte[].class);
|
||||||
// 获取文件流
|
// 获取文件流
|
||||||
splitFileIs = new ByteArrayInputStream(responseEntity.getBody());
|
splitFileIs = new ByteArrayInputStream(responseEntity.getBody());
|
||||||
|
splitFileIs1 = new ByteArrayInputStream(responseEntity.getBody());
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
log.error("调用比亚迪下载文档接口失败:" + ex.getMessage());
|
log.error("调用比亚迪下载文档接口失败:" + ex.getMessage());
|
||||||
@@ -252,9 +238,7 @@ public class FileSpiltService {
|
|||||||
log.info("下载文档结束=========================================================");
|
log.info("下载文档结束=========================================================");
|
||||||
}
|
}
|
||||||
|
|
||||||
try (InputStream is = splitFileIs;InputStream is1 = splitFileIs) {
|
try (InputStream is = splitFileIs;InputStream is1 = splitFileIs1) {
|
||||||
//String readFilePath = "E:\\Data\\Downloads\\wordtest\\GB7258标准修订test - 表格测试 - 副本.docx";
|
|
||||||
//try (InputStream is = new FileInputStream(readFilePath); InputStream is1 = new FileInputStream(readFilePath)) {//需要将文件路更改为word文档所在路径。
|
|
||||||
ZipSecureFile.setMinInflateRatio(-1.0d);
|
ZipSecureFile.setMinInflateRatio(-1.0d);
|
||||||
XWPFDocument doc = new XWPFDocument(is);
|
XWPFDocument doc = new XWPFDocument(is);
|
||||||
// 获取文档中的图片
|
// 获取文档中的图片
|
||||||
@@ -271,20 +255,16 @@ public class FileSpiltService {
|
|||||||
}
|
}
|
||||||
//获得序号标题和无标题序号
|
//获得序号标题和无标题序号
|
||||||
TitleNumberVO titleNumberVO = AsposeUtil.getNumber(is1);
|
TitleNumberVO titleNumberVO = AsposeUtil.getNumber(is1);
|
||||||
//TitleNumberVO titleNumberVO = new TitleNumberVO();
|
|
||||||
Map<String, String> titleNumberMap = titleNumberVO.getTitleNumberMap();
|
Map<String, String> titleNumberMap = titleNumberVO.getTitleNumberMap();
|
||||||
List<String> emptyTitleList = titleNumberVO.getEmptyTitleList();
|
List<String> emptyTitleList = titleNumberVO.getEmptyTitleList();
|
||||||
// 记录拆分后的每一段文字
|
// 记录拆分后的每一段文字
|
||||||
List<IBodyElement> elements = doc.getBodyElements();
|
List<IBodyElement> elements = doc.getBodyElements();
|
||||||
// 记录word自动生成的编号数据
|
|
||||||
Map numberMap = new HashMap<String, Integer>();
|
|
||||||
boolean menuCanAdd = false; // 判断当前目录下是否可以正常填写数据
|
boolean menuCanAdd = false; // 判断当前目录下是否可以正常填写数据
|
||||||
boolean firstFlag = true;
|
boolean firstFlag = true;
|
||||||
List<String> startDigitList = getStartDigit(elements, enumByValue);
|
List<String> startDigitList = getStartDigit(elements, enumByValue);
|
||||||
String regex = "^[0-9]*$";
|
String regex = "^[0-9]*$";
|
||||||
String preName = "";
|
String preName = "";
|
||||||
int preNameNum = 0;
|
int preNameNum = 0;
|
||||||
// for (IBodyElement element : elements) {
|
|
||||||
for (int g=0; g< elements.size(); g++) {
|
for (int g=0; g< elements.size(); g++) {
|
||||||
IBodyElement element = elements.get(g);
|
IBodyElement element = elements.get(g);
|
||||||
// 段落
|
// 段落
|
||||||
@@ -296,29 +276,14 @@ public class FileSpiltService {
|
|||||||
List<Object> childList = runOrMaths.getChildList();
|
List<Object> childList = runOrMaths.getChildList();
|
||||||
|
|
||||||
for (Object child : childList) {
|
for (Object child : childList) {
|
||||||
//if (child instanceof XWPFRun) {
|
|
||||||
// //处理段落中的文本以及图片
|
|
||||||
// handleParagraphRun(content, (XWPFRun) child, imageParser);
|
|
||||||
//} else
|
|
||||||
if (child instanceof CTOMath) {
|
if (child instanceof CTOMath) {
|
||||||
CTOMath ctoMath = (CTOMath) child;
|
CTOMath ctoMath = (CTOMath) child;
|
||||||
//stringBuilder.append(ctoMath.xmlText());
|
|
||||||
// 处理word中存在的公式成mathML格式
|
|
||||||
//String imageName = OmmlUtils.convertOmathToPng(ctoMath.xmlText());
|
|
||||||
//if (messageList.size() > 0) {
|
|
||||||
// addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, imageName);
|
|
||||||
//}
|
|
||||||
File mathToImgFile = this.getMathToImgUrl(ctoMath.xmlText());
|
File mathToImgFile = this.getMathToImgUrl(ctoMath.xmlText());
|
||||||
if (null != mathToImgFile && messageList.size() > 0) {
|
if (null != mathToImgFile && messageList.size() > 0) {
|
||||||
addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, mathToImgFile);
|
addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, mathToImgFile);
|
||||||
}
|
}
|
||||||
} else if (child instanceof CTOMathPara) {
|
} else if (child instanceof CTOMathPara) {
|
||||||
CTOMathPara ctoMathPara = (CTOMathPara) child;
|
CTOMathPara ctoMathPara = (CTOMathPara) child;
|
||||||
//String imageName = OmmlUtils.convertOmathToPng(ctoMathPara.xmlText());
|
|
||||||
//if (messageList.size() > 0) {
|
|
||||||
// addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, imageName);
|
|
||||||
//}
|
|
||||||
|
|
||||||
File mathToImgFile = this.getMathToImgUrl(ctoMathPara.xmlText());
|
File mathToImgFile = this.getMathToImgUrl(ctoMathPara.xmlText());
|
||||||
if (null != mathToImgFile && messageList.size() > 0) {
|
if (null != mathToImgFile && messageList.size() > 0) {
|
||||||
addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, mathToImgFile);
|
addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, mathToImgFile);
|
||||||
@@ -329,6 +294,9 @@ public class FileSpiltService {
|
|||||||
for (XWPFRun xwrun : p.getRuns()) {
|
for (XWPFRun xwrun : p.getRuns()) {
|
||||||
VerticalAlign subscript = xwrun.getSubscript();
|
VerticalAlign subscript = xwrun.getSubscript();
|
||||||
String smalltext = xwrun.getText(0);
|
String smalltext = xwrun.getText(0);
|
||||||
|
if (StringUtils.isNotBlank(smalltext)){
|
||||||
|
smalltext = smalltext.replace("<", "<").replace(">", ">");
|
||||||
|
}
|
||||||
if (smalltext==null){
|
if (smalltext==null){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -346,6 +314,7 @@ public class FileSpiltService {
|
|||||||
stringBuilder.append(smalltext);
|
stringBuilder.append(smalltext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ParagraphAlignment alignment = p.getAlignment();
|
||||||
// 处理段落生成编号不识别问题
|
// 处理段落生成编号不识别问题
|
||||||
String paragraphString = stringBuilder.toString();
|
String paragraphString = stringBuilder.toString();
|
||||||
if (StringUtils.isNotBlank(paragraphString)) {
|
if (StringUtils.isNotBlank(paragraphString)) {
|
||||||
@@ -397,7 +366,6 @@ public class FileSpiltService {
|
|||||||
List<String> clauseContent = new ArrayList<>();
|
List<String> clauseContent = new ArrayList<>();
|
||||||
SarFileSplitItemsEO message = getSarFileSplitItemsEO(sarFileSplitInfoEO.getId(), "1", "范围", clauseContent);
|
SarFileSplitItemsEO message = getSarFileSplitItemsEO(sarFileSplitInfoEO.getId(), "1", "范围", clauseContent);
|
||||||
SarFileSplitMenuEO documentTreeEO1 = new SarFileSplitMenuEO();
|
SarFileSplitMenuEO documentTreeEO1 = new SarFileSplitMenuEO();
|
||||||
// SarFileSplitMenuEO documentTreeEO1 = new SarFileSplitMenuEO(UUIDUtils.randomUUID20(),message.getItemsNum(),generalCatalogueId,sarFileSplitInfoEO.getId(),treeListDisplay++,"范围");
|
|
||||||
documentTreeEO1.setId(UUIDUtils.randomUUID20());
|
documentTreeEO1.setId(UUIDUtils.randomUUID20());
|
||||||
documentTreeEO1.setItemName("范围");
|
documentTreeEO1.setItemName("范围");
|
||||||
documentTreeEO1.setPId(generalCatalogueId);
|
documentTreeEO1.setPId(generalCatalogueId);
|
||||||
@@ -405,7 +373,6 @@ public class FileSpiltService {
|
|||||||
documentTreeEO1.setDisplaySeq(treeListDisplay++);
|
documentTreeEO1.setDisplaySeq(treeListDisplay++);
|
||||||
documentTreeEO1.setName(message.getItemNum());
|
documentTreeEO1.setName(message.getItemNum());
|
||||||
documentTreeEO1.setValidFlag(0);
|
documentTreeEO1.setValidFlag(0);
|
||||||
// treeList.add(documentTreeEO1);
|
|
||||||
|
|
||||||
message.setMenuId(documentTreeEO1.getId());
|
message.setMenuId(documentTreeEO1.getId());
|
||||||
if (sarFileSplitInfoEO.getStartNumber() <= 1 && sarFileSplitInfoEO.getStopNumber() >= 1) {
|
if (sarFileSplitInfoEO.getStartNumber() <= 1 && sarFileSplitInfoEO.getStopNumber() >= 1) {
|
||||||
@@ -443,7 +410,6 @@ public class FileSpiltService {
|
|||||||
startDigit = getOneStartDigit(paragraphString, enumByValue);
|
startDigit = getOneStartDigit(paragraphString, enumByValue);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < nowStart.size(); i++) {
|
for (int i = 0; i < nowStart.size(); i++) {
|
||||||
// if (paragraphString.startsWith(nowStart.get(i))) {
|
|
||||||
if (startDigit.equals(nowStart.get(i))) {
|
if (startDigit.equals(nowStart.get(i))) {
|
||||||
// 判断真的是标题还是干扰项 TODO
|
// 判断真的是标题还是干扰项 TODO
|
||||||
if (nowStart.get(i).matches(regex)) {
|
if (nowStart.get(i).matches(regex)) {
|
||||||
@@ -474,7 +440,7 @@ public class FileSpiltService {
|
|||||||
preNameNum = g;
|
preNameNum = g;
|
||||||
message.setMenuId(sarFileSplitMenuEO.getId());
|
message.setMenuId(sarFileSplitMenuEO.getId());
|
||||||
if(!StringUtils.isEmpty(itemName) && !paragraphString.endsWith(itemName)){
|
if(!StringUtils.isEmpty(itemName) && !paragraphString.endsWith(itemName)){
|
||||||
addItermsConditionsText(message, itemValList, paragraphString.substring(nowStart.get(i).length()));
|
addItermsConditionsText(message, itemValList, paragraphString.substring(nowStart.get(i).length()), alignment);
|
||||||
}
|
}
|
||||||
message.setApplicableComponents(partName);
|
message.setApplicableComponents(partName);
|
||||||
messageList.add(message);
|
messageList.add(message);
|
||||||
@@ -489,27 +455,21 @@ public class FileSpiltService {
|
|||||||
// 判断是否是附录
|
// 判断是否是附录
|
||||||
boolean find = APPENDIX_PATTERN.matcher(paragraphString).find();
|
boolean find = APPENDIX_PATTERN.matcher(paragraphString).find();
|
||||||
// 获取当前最后一项num
|
// 获取当前最后一项num
|
||||||
String appendixNum = messageList.get(messageList.size() - 1).getItemNum().split("\\.")[0];
|
|
||||||
if (find && !messageList.get(messageList.size() - 1).getItemNum().equals("附录")) {
|
if (find && !messageList.get(messageList.size() - 1).getItemNum().equals("附录")) {
|
||||||
if (Integer.valueOf(appendixNum) + 1 <= sarFileSplitInfoEO.getStopNumber()) {
|
String itemName = paragraphString;
|
||||||
String itemName = "附录";
|
|
||||||
List<String> clauseContent = new ArrayList<>();
|
List<String> clauseContent = new ArrayList<>();
|
||||||
clauseContent.add(paragraphString);
|
clauseContent.add(paragraphString);
|
||||||
SarFileSplitItemsEO message = getSarFileSplitItemsEO(sarFileSplitInfoEO.getId(), "附录", itemName, clauseContent);
|
SarFileSplitItemsEO message = getSarFileSplitItemsEO(sarFileSplitInfoEO.getId(), itemName, "", clauseContent);
|
||||||
// 增加一条数据,需要在数结构中加一条数据
|
// 增加一条数据,需要在数结构中加一条数据
|
||||||
SarFileSplitMenuEO sarFileSplitMenuEO = getTreeList("附录", treeList, generalCatalogueId, sarFileSplitInfoEO, treeListDisplay++, "", enumByValue);
|
SarFileSplitMenuEO sarFileSplitMenuEO = getTreeList(itemName, treeList, generalCatalogueId, sarFileSplitInfoEO, treeListDisplay++, "", enumByValue);
|
||||||
addItermsConditionsText(message, itemValList, paragraphString);
|
|
||||||
treeList.add(sarFileSplitMenuEO);
|
treeList.add(sarFileSplitMenuEO);
|
||||||
message.setMenuId(sarFileSplitMenuEO.getId());
|
message.setMenuId(sarFileSplitMenuEO.getId());
|
||||||
message.setApplicableComponents(partName);
|
message.setApplicableComponents(partName);
|
||||||
messageList.add(message);
|
messageList.add(message);
|
||||||
nowStart = new ArrayList<>();
|
nowStart = new ArrayList<>();
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!paragraphString.equals("")) {
|
if (!paragraphString.equals("")) {
|
||||||
addItermsConditionsText(messageList.get(messageList.size() - 1), itemValList, paragraphString);
|
addItermsConditionsText(messageList.get(messageList.size() - 1), itemValList, paragraphString, alignment);
|
||||||
}
|
}
|
||||||
List<String> imageBundleList = readImageInParagraph((XWPFParagraph) p);
|
List<String> imageBundleList = readImageInParagraph((XWPFParagraph) p);
|
||||||
if (CollectionUtils.isNotEmpty(imageBundleList)) {
|
if (CollectionUtils.isNotEmpty(imageBundleList)) {
|
||||||
@@ -531,11 +491,9 @@ public class FileSpiltService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.info("拆分出现异常了:",e);
|
|
||||||
log.error(e.getMessage(),e);
|
log.error(e.getMessage(),e);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
log.info("treeList长度:" + treeList.size());
|
|
||||||
if (treeList.size() > 0 && messageList.size() > 0) {
|
if (treeList.size() > 0 && messageList.size() > 0) {
|
||||||
sarFileSplitMenuEOMapper.insertForeach(treeList);
|
sarFileSplitMenuEOMapper.insertForeach(treeList);
|
||||||
for (int i = 0; i < messageList.size(); i++) {
|
for (int i = 0; i < messageList.size(); i++) {
|
||||||
@@ -549,7 +507,6 @@ public class FileSpiltService {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return treeList.size();
|
return treeList.size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNextParagraphString(int g, List<IBodyElement> elements, SplitFileTypeTypeEnum enumByValue) {
|
private String getNextParagraphString(int g, List<IBodyElement> elements, SplitFileTypeTypeEnum enumByValue) {
|
||||||
@@ -586,7 +543,6 @@ public class FileSpiltService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<String> getNewNowStart(String nowStart) {
|
public List<String> getNewNowStart(String nowStart) {
|
||||||
// List<String> nowStartList = new ArrayList<>();
|
|
||||||
List<String> nowResultStartList = new ArrayList<>();
|
List<String> nowResultStartList = new ArrayList<>();
|
||||||
String[] numberStr = nowStart.split("\\.");
|
String[] numberStr = nowStart.split("\\.");
|
||||||
String startnumber = "";
|
String startnumber = "";
|
||||||
@@ -647,18 +603,7 @@ public class FileSpiltService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
// case EU:
|
|
||||||
// if (name.indexOf(".") >= 0) {
|
|
||||||
// if (name.substring(0, name.lastIndexOf(".") - 1).equals(forDocumentTree.getName())) {
|
|
||||||
// documentTreeEO.setPId(forDocumentTree.getId());
|
|
||||||
//// pIdList.add(forDocumentTree.getId());
|
|
||||||
// break a;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// documentTreeEO.setPId(generalCatalogueId);
|
|
||||||
//// pIdList.add(generalCatalogueId);
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
case JPN_ATTACHMENT:
|
case JPN_ATTACHMENT:
|
||||||
if (name.contains(".")) {
|
if (name.contains(".")) {
|
||||||
if (name.indexOf(".") >= 0) {
|
if (name.indexOf(".") >= 0) {
|
||||||
@@ -1123,9 +1068,13 @@ public class FileSpiltService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 像每个条款中依次插入每一段的内容
|
// 像每个条款中依次插入每一段的内容
|
||||||
public static void addItermsConditionsText(SarFileSplitItemsEO message, List<SarFileSplitItemsValEO> itemsValList, String p) {
|
public static void addItermsConditionsText(SarFileSplitItemsEO message, List<SarFileSplitItemsValEO> itemsValList, String p, ParagraphAlignment alignment) {
|
||||||
message.getItemsCondi().add(p);
|
message.getItemsCondi().add(p);
|
||||||
|
if (ParagraphAlignment.CENTER.equals(alignment)){
|
||||||
|
message.setItemContent(message.getItemContent() + "<p style=\"text-align: center;\">" + p + "</p>");
|
||||||
|
}else {
|
||||||
message.setItemContent(message.getItemContent() + "<p>" + p + "</p>");
|
message.setItemContent(message.getItemContent() + "<p>" + p + "</p>");
|
||||||
|
}
|
||||||
itemsValList.add(getSplitItemsValObject(message.getId(), SplitFilePragraTypeEnum.TEXT.getValue(), p, message.getItemsCondi().size(), null));
|
itemsValList.add(getSplitItemsValObject(message.getId(), SplitFilePragraTypeEnum.TEXT.getValue(), p, message.getItemsCondi().size(), null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1154,12 +1103,6 @@ public class FileSpiltService {
|
|||||||
StringBuilder tableToHtmlStr = new StringBuilder("<table style=\"border-collapse: collapse;\">");
|
StringBuilder tableToHtmlStr = new StringBuilder("<table style=\"border-collapse: collapse;\">");
|
||||||
|
|
||||||
for (int i = 0; i < tableRowsSize; i++) {
|
for (int i = 0; i < tableRowsSize; i++) {
|
||||||
//最后一行的都增加下边框
|
|
||||||
//if (i == tableRowsSize-1){
|
|
||||||
// tableToHtmlStr.append("<tr style=\"border-bottom: 1px solid;\">");
|
|
||||||
//}else {
|
|
||||||
// tableToHtmlStr.append("<tr>");
|
|
||||||
//}
|
|
||||||
tableToHtmlStr.append("<tr>");
|
tableToHtmlStr.append("<tr>");
|
||||||
|
|
||||||
int tableCellsSize = table.getRow(i).getTableCells().size();
|
int tableCellsSize = table.getRow(i).getTableCells().size();
|
||||||
@@ -1196,6 +1139,100 @@ public class FileSpiltService {
|
|||||||
List<XWPFParagraph> paragraphs = tableCell.getParagraphs();
|
List<XWPFParagraph> paragraphs = tableCell.getParagraphs();
|
||||||
for (XWPFParagraph paragraph : paragraphs) {
|
for (XWPFParagraph paragraph : paragraphs) {
|
||||||
List<String> imageBundleList = readImageInParagraph(paragraph);
|
List<String> imageBundleList = readImageInParagraph(paragraph);
|
||||||
|
ParagraphChildOrderManager runOrMaths = new ParagraphChildOrderManager(paragraph);
|
||||||
|
List<Object> childList = runOrMaths.getChildList();
|
||||||
|
for (Object child : childList) {
|
||||||
|
if (child instanceof CTOMath) {
|
||||||
|
CTOMath ctoMath = (CTOMath) child;
|
||||||
|
File mathToImgFile = this.getMathToImgUrl(ctoMath.xmlText());
|
||||||
|
if (null != mathToImgFile) {
|
||||||
|
String imageName = UUIDUtils.randomUUID10() + mathToImgFile.getName();
|
||||||
|
String path = splitUrl + imageName;
|
||||||
|
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){
|
||||||
|
File splitImgFolder = new File(splitImgPath);
|
||||||
|
if (!splitImgFolder.exists()) {
|
||||||
|
splitImgFolder.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
String newFilePath = splitImgPath + imageName;
|
||||||
|
try {
|
||||||
|
File newFile = new File(newFilePath);
|
||||||
|
FileUtils.copyFile(mathToImgFile, newFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
//上传成功 进行数据库存储
|
||||||
|
OSSFile ossFile = new OSSFile();
|
||||||
|
// 文件名
|
||||||
|
String fileName = mathToImgFile.getName();
|
||||||
|
fileName = CommonUtils.getFileName(fileName);
|
||||||
|
ossFile.setFileName(fileName);
|
||||||
|
ossFile.setUrl(newFilePath);
|
||||||
|
ossFile.setId(imageName);
|
||||||
|
iossFileService.save(ossFile);
|
||||||
|
} else if (CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){
|
||||||
|
byte[] bytev = null;
|
||||||
|
try (FileInputStream fis = new FileInputStream(mathToImgFile)){
|
||||||
|
bytev = new byte[(int) mathToImgFile.length()];
|
||||||
|
fis.read(bytev);
|
||||||
|
}catch (IOException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
String filepathandname = filePathCos + "/" + imageName;
|
||||||
|
MinioUtil.uploadByte(bytev, filepathandname);
|
||||||
|
}
|
||||||
|
|
||||||
|
String imgConVal = "<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\"" + path + "\">";
|
||||||
|
stringBuilder.append(imgConVal);
|
||||||
|
}
|
||||||
|
} else if (child instanceof CTOMathPara) {
|
||||||
|
CTOMathPara ctoMathPara = (CTOMathPara) child;
|
||||||
|
File mathToImgFile = this.getMathToImgUrl(ctoMathPara.xmlText());
|
||||||
|
if (null != mathToImgFile) {
|
||||||
|
String imageName = UUIDUtils.randomUUID10() + mathToImgFile.getName();
|
||||||
|
String path = splitUrl + imageName;
|
||||||
|
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){
|
||||||
|
File splitImgFolder = new File(splitImgPath);
|
||||||
|
if (!splitImgFolder.exists()) {
|
||||||
|
splitImgFolder.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
String newFilePath = splitImgPath + imageName;
|
||||||
|
try {
|
||||||
|
File newFile = new File(newFilePath);
|
||||||
|
FileUtils.copyFile(mathToImgFile, newFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
//上传成功 进行数据库存储
|
||||||
|
OSSFile ossFile = new OSSFile();
|
||||||
|
// 文件名
|
||||||
|
String fileName = mathToImgFile.getName();
|
||||||
|
fileName = CommonUtils.getFileName(fileName);
|
||||||
|
ossFile.setFileName(fileName);
|
||||||
|
ossFile.setUrl(newFilePath);
|
||||||
|
ossFile.setId(imageName);
|
||||||
|
iossFileService.save(ossFile);
|
||||||
|
} else if (CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){
|
||||||
|
byte[] bytev = null;
|
||||||
|
try (FileInputStream fis = new FileInputStream(mathToImgFile)){
|
||||||
|
bytev = new byte[(int) mathToImgFile.length()];
|
||||||
|
fis.read(bytev);
|
||||||
|
}catch (IOException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
String filepathandname = filePathCos + "/" + imageName;
|
||||||
|
MinioUtil.uploadByte(bytev, filepathandname);
|
||||||
|
}
|
||||||
|
|
||||||
|
String imgConVal = "<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\"" + path + "\">";
|
||||||
|
stringBuilder.append(imgConVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(imageBundleList)) {
|
if (CollectionUtils.isNotEmpty(imageBundleList)) {
|
||||||
String s = addTableImage(paragraph, imageBundleList);
|
String s = addTableImage(paragraph, imageBundleList);
|
||||||
stringBuilder.append(s);
|
stringBuilder.append(s);
|
||||||
@@ -1487,7 +1524,7 @@ public class FileSpiltService {
|
|||||||
// 此处相当于在Authorization里头添加Bear token参数信息
|
// 此处相当于在Authorization里头添加Bear token参数信息
|
||||||
HttpResponse res = client.execute(post);
|
HttpResponse res = client.execute(post);
|
||||||
String results = EntityUtils.toString(res.getEntity());
|
String results = EntityUtils.toString(res.getEntity());
|
||||||
|
System.out.println("getMathToImgUrl results:"+results);
|
||||||
if (StringUtils.isNotEmpty(results)) {
|
if (StringUtils.isNotEmpty(results)) {
|
||||||
boolean errorFlag = (StringUtils.equals(results,"非法请求!") || StringUtils.equals(results,"非法参数!") || StringUtils.equals(results,"转换失败!"));
|
boolean errorFlag = (StringUtils.equals(results,"非法请求!") || StringUtils.equals(results,"非法参数!") || StringUtils.equals(results,"转换失败!"));
|
||||||
if (!errorFlag) {
|
if (!errorFlag) {
|
||||||
|
|||||||
Reference in New Issue
Block a user