add 公式转换图片url
This commit is contained in:
+28
-24
@@ -1,5 +1,8 @@
|
|||||||
package com.jero.modules.split.service.impl;
|
package com.jero.modules.split.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.http.Header;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.jero.common.exception.JeroBootException;
|
import com.jero.common.exception.JeroBootException;
|
||||||
import com.jero.common.system.vo.LoginUser;
|
import com.jero.common.system.vo.LoginUser;
|
||||||
@@ -18,10 +21,7 @@ import com.jero.modules.split.enums.SplitFileTypeTypeEnum;
|
|||||||
import com.jero.modules.split.mapper.SarFileSplitMenuEOMapper;
|
import com.jero.modules.split.mapper.SarFileSplitMenuEOMapper;
|
||||||
import com.jero.modules.split.service.IFileSplitItemsEOService;
|
import com.jero.modules.split.service.IFileSplitItemsEOService;
|
||||||
import com.jero.modules.split.service.ISarFileSplitItemsValEOService;
|
import com.jero.modules.split.service.ISarFileSplitItemsValEOService;
|
||||||
import com.jero.modules.split.util.AsposeUtil;
|
import com.jero.modules.split.util.*;
|
||||||
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;
|
import com.jero.modules.split.vo.TitleNumberVO;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
@@ -94,6 +94,8 @@ public class FileSpiltService {
|
|||||||
private String filePathCos;
|
private String filePathCos;
|
||||||
@Value("${jero.splitUrl}")
|
@Value("${jero.splitUrl}")
|
||||||
private String splitUrl;
|
private String splitUrl;
|
||||||
|
@Value("${jero.mathToImgUrl}")
|
||||||
|
private String mathToImgUrl;
|
||||||
/**
|
/**
|
||||||
* 判断附录正则
|
* 判断附录正则
|
||||||
*/
|
*/
|
||||||
@@ -178,16 +180,6 @@ public class FileSpiltService {
|
|||||||
XWPFDocument doc = new XWPFDocument(is);
|
XWPFDocument doc = new XWPFDocument(is);
|
||||||
// 获取文档中的图片
|
// 获取文档中的图片
|
||||||
List<XWPFPictureData> allPictures = doc.getAllPictures();
|
List<XWPFPictureData> allPictures = doc.getAllPictures();
|
||||||
// 遍历图片并处理数学公式
|
|
||||||
for (XWPFPictureData pictureData : allPictures) {
|
|
||||||
String contentType = pictureData.getPackagePart().getContentType();
|
|
||||||
System.out.println(contentType);
|
|
||||||
// 判断图片类型是否为数学公式
|
|
||||||
if (contentType.equals(PictureType.EMF.getExtension())) {
|
|
||||||
// 处理数学公式,你可以在这里添加自己的逻辑
|
|
||||||
System.out.println("Found a math equation!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//获得序号标题和无标题序号
|
//获得序号标题和无标题序号
|
||||||
TitleNumberVO titleNumberVO = AsposeUtil.getNumber(is1);
|
TitleNumberVO titleNumberVO = AsposeUtil.getNumber(is1);
|
||||||
//TitleNumberVO titleNumberVO = new TitleNumberVO();
|
//TitleNumberVO titleNumberVO = new TitleNumberVO();
|
||||||
@@ -221,18 +213,30 @@ public class FileSpiltService {
|
|||||||
//} else
|
//} else
|
||||||
if (child instanceof CTOMath) {
|
if (child instanceof CTOMath) {
|
||||||
CTOMath ctoMath = (CTOMath) child;
|
CTOMath ctoMath = (CTOMath) child;
|
||||||
//stringBuilder.append(ctoMath.xmlText());
|
String xmlText = ctoMath.xmlText().replaceAll("xml-fragment","m:oMath");
|
||||||
// 处理word中存在的公式成mathML格式
|
Map<String, Object> map = new HashMap<>();
|
||||||
//String imageName = OmmlUtils.convertOmathToPng(ctoMath.xmlText());
|
map.put("encode", xmlText);
|
||||||
//if (messageList.size() > 0) {
|
String post = HttpRequest.post(mathToImgUrl)
|
||||||
// addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, imageName);
|
.header(Header.CONTENT_TYPE, "application/json")
|
||||||
//}
|
.body(xmlText)
|
||||||
|
.execute().body();
|
||||||
|
//String post = HttpUtil.post(mathToImgUrl, map);
|
||||||
|
if (messageList.size() > 0) {
|
||||||
|
addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, post);
|
||||||
|
}
|
||||||
} else if (child instanceof CTOMathPara) {
|
} else if (child instanceof CTOMathPara) {
|
||||||
CTOMathPara ctoMathPara = (CTOMathPara) child;
|
CTOMathPara ctoMathPara = (CTOMathPara) child;
|
||||||
//String imageName = OmmlUtils.convertOmathToPng(ctoMathPara.xmlText());
|
String xmlText = ctoMathPara.xmlText().replaceAll("xml-fragment","m:oMath");;
|
||||||
//if (messageList.size() > 0) {
|
Map<String,Object> map = new HashMap<>();
|
||||||
// addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, imageName);
|
map.put("encode",xmlText);
|
||||||
//}
|
String post = HttpRequest.post(mathToImgUrl)
|
||||||
|
.header(Header.CONTENT_TYPE, "application/json")
|
||||||
|
.body(xmlText)
|
||||||
|
.execute().body();
|
||||||
|
//String post = HttpUtil.post(mathToImgUrl, map);
|
||||||
|
if (messageList.size() > 0) {
|
||||||
|
addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, post);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -235,6 +235,8 @@ jero:
|
|||||||
backUrlPhone: http://localhost:3000
|
backUrlPhone: http://localhost:3000
|
||||||
#拆分图片展示地址
|
#拆分图片展示地址
|
||||||
splitUrl: http://localhost:8184/laws-sinotruk/sys/split/file/getImage?fileName=
|
splitUrl: http://localhost:8184/laws-sinotruk/sys/split/file/getImage?fileName=
|
||||||
|
#公式转换图片url
|
||||||
|
mathToImgUrl: http://localhost:9998/mathToImg
|
||||||
path:
|
path:
|
||||||
#文件上传根目录 设置
|
#文件上传根目录 设置
|
||||||
upload: D://opt//upFiles
|
upload: D://opt//upFiles
|
||||||
|
|||||||
@@ -206,6 +206,8 @@ jero:
|
|||||||
backUrlPhone: http://localhost:3000
|
backUrlPhone: http://localhost:3000
|
||||||
#拆分图片展示地址
|
#拆分图片展示地址
|
||||||
splitUrl: http://srms.sinotruk.com/laws-sinotruk/sys/split/file/getImage?fileName=
|
splitUrl: http://srms.sinotruk.com/laws-sinotruk/sys/split/file/getImage?fileName=
|
||||||
|
#公式转换图片url
|
||||||
|
mathToImgUrl: http://mathtoimg-gk8cg.yf-grp:8080/mathToImg
|
||||||
path:
|
path:
|
||||||
#文件上传根目录 设置
|
#文件上传根目录 设置
|
||||||
upload: /app/opt/upFiles
|
upload: /app/opt/upFiles
|
||||||
|
|||||||
@@ -206,6 +206,8 @@ jero:
|
|||||||
backUrlPhone: http://localhost:3000
|
backUrlPhone: http://localhost:3000
|
||||||
#拆分图片展示地址
|
#拆分图片展示地址
|
||||||
splitUrl: http://srms-test.sinotruk.com/laws-sinotruk/sys/split/file/getImage?fileName=
|
splitUrl: http://srms-test.sinotruk.com/laws-sinotruk/sys/split/file/getImage?fileName=
|
||||||
|
#公式转换图片url
|
||||||
|
mathToImgUrl: http://mathtoimg-gk8cg.yf-grp:8080/mathToImg
|
||||||
path:
|
path:
|
||||||
#文件上传根目录 设置
|
#文件上传根目录 设置
|
||||||
upload: /app/opt/upFiles
|
upload: /app/opt/upFiles
|
||||||
|
|||||||
Reference in New Issue
Block a user