fix(文档拆分): MinioUtil -> ObsBootUtil
This commit is contained in:
+5
-4
@@ -1,7 +1,7 @@
|
|||||||
package com.jero.modules.oss.controller;
|
package com.jero.modules.oss.controller;
|
||||||
|
|
||||||
import com.jero.common.exception.JeroBootException;
|
import com.jero.common.exception.JeroBootException;
|
||||||
import com.jero.common.util.MinioUtil;
|
import com.jero.common.util.obs.ObsBootUtil;
|
||||||
import com.jero.modules.oss.service.IOSSFileService;
|
import com.jero.modules.oss.service.IOSSFileService;
|
||||||
import com.jero.modules.oss.util.SplitFileUtils;
|
import com.jero.modules.oss.util.SplitFileUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -36,9 +36,10 @@ public class SplitFileController {
|
|||||||
response.setHeader("Content-Disposition",
|
response.setHeader("Content-Disposition",
|
||||||
"attachment; filename=\"" + SplitFileUtils.encodeFileName(fileName, request) + "\"");
|
"attachment; filename=\"" + SplitFileUtils.encodeFileName(fileName, request) + "\"");
|
||||||
response.setContentType("application/force-download");
|
response.setContentType("application/force-download");
|
||||||
if (MinioUtil.doesObjectExist(fileUrl)) {
|
// if (MinioUtil.doesObjectExist(fileUrl)) {
|
||||||
try (OutputStream os = response.getOutputStream();
|
try (OutputStream os = response.getOutputStream();
|
||||||
InputStream fis = MinioUtil.download(fileUrl)) {
|
// InputStream fis = MinioUtil.download(fileUrl)) {
|
||||||
|
InputStream fis = ObsBootUtil.getOssFile(fileUrl)) {
|
||||||
int len = 0;
|
int len = 0;
|
||||||
while ((len = fis.read()) != -1) {
|
while ((len = fis.read()) != -1) {
|
||||||
os.write(len);
|
os.write(len);
|
||||||
@@ -49,7 +50,7 @@ public class SplitFileController {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new JeroBootException("文件不存在");
|
throw new JeroBootException("文件不存在");
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+44
-36
@@ -2,12 +2,14 @@ package com.jero.modules.split.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.lang.RegexPool;
|
import cn.hutool.core.lang.RegexPool;
|
||||||
import cn.hutool.core.util.ReUtil;
|
import cn.hutool.core.util.ReUtil;
|
||||||
|
import cn.hutool.http.Header;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
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;
|
||||||
import com.jero.common.util.IntekeyUtils;
|
import com.jero.common.util.IntekeyUtils;
|
||||||
import com.jero.common.util.MinioUtil;
|
|
||||||
import com.jero.common.util.UUIDUtils;
|
import com.jero.common.util.UUIDUtils;
|
||||||
|
import com.jero.common.util.obs.ObsBootUtil;
|
||||||
import com.jero.modules.laws.documenttool.mapper.DocumentSplitMapper;
|
import com.jero.modules.laws.documenttool.mapper.DocumentSplitMapper;
|
||||||
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
|
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
|
||||||
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
|
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
|
||||||
@@ -40,6 +42,8 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObject;
|
|||||||
import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
|
import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
|
||||||
import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTAnchor;
|
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.CTOMathPara;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDrawing;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDrawing;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLevelText;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLevelText;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
|
||||||
@@ -55,6 +59,7 @@ import org.w3c.dom.NamedNodeMap;
|
|||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -173,10 +178,11 @@ public class FileSpiltService {
|
|||||||
}
|
}
|
||||||
OSSFile ossFile = ossFileList.get(0);
|
OSSFile ossFile = ossFileList.get(0);
|
||||||
String readFilePath = ossFile.getUrl();
|
String readFilePath = ossFile.getUrl();
|
||||||
if (StringUtils.isEmpty(readFilePath) || !MinioUtil.doesObjectExist(readFilePath)) {
|
if (StringUtils.isEmpty(readFilePath)) {
|
||||||
throw new JeroBootException("当前文件未找到,请重新选择!");
|
throw new JeroBootException("当前文件未找到,请重新选择!");
|
||||||
}
|
}
|
||||||
try (InputStream is = MinioUtil.download(readFilePath);InputStream is1 = MinioUtil.download(readFilePath)) {
|
// try (InputStream is = MinioUtil.download(readFilePath);InputStream is1 = MinioUtil.download(readFilePath)) {
|
||||||
|
try (InputStream is = ObsBootUtil.getOssFile(readFilePath);InputStream is1 = ObsBootUtil.getOssFile(readFilePath)) {
|
||||||
String fileName = readFilePath.substring((readFilePath.lastIndexOf("/") + 1));
|
String fileName = readFilePath.substring((readFilePath.lastIndexOf("/") + 1));
|
||||||
MultipartFile mFile = new MockMultipartFile(fileName, fileName, ContentType.APPLICATION_OCTET_STREAM.toString(), is);
|
MultipartFile mFile = new MockMultipartFile(fileName, fileName, ContentType.APPLICATION_OCTET_STREAM.toString(), is);
|
||||||
MultipartFile mFile1 = new MockMultipartFile(fileName, fileName, ContentType.APPLICATION_OCTET_STREAM.toString(), is1);
|
MultipartFile mFile1 = new MockMultipartFile(fileName, fileName, ContentType.APPLICATION_OCTET_STREAM.toString(), is1);
|
||||||
@@ -217,34 +223,34 @@ public class FileSpiltService {
|
|||||||
// //处理段落中的文本以及图片
|
// //处理段落中的文本以及图片
|
||||||
// handleParagraphRun(content, (XWPFRun) child, imageParser);
|
// handleParagraphRun(content, (XWPFRun) child, imageParser);
|
||||||
//} else
|
//} else
|
||||||
// if (child instanceof CTOMath) {
|
if (child instanceof CTOMath) {
|
||||||
// CTOMath ctoMath = (CTOMath) child;
|
CTOMath ctoMath = (CTOMath) child;
|
||||||
// String xmlText = ctoMath.xmlText().replaceAll("xml-fragment","m:oMath");
|
String xmlText = ctoMath.xmlText().replaceAll("xml-fragment","m:oMath");
|
||||||
// Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
// map.put("encode", xmlText);
|
map.put("encode", xmlText);
|
||||||
// String post = HttpRequest.post(mathToImgUrl)
|
String post = HttpRequest.post(mathToImgUrl)
|
||||||
// .header(Header.CONTENT_TYPE, "application/json")
|
.header(Header.CONTENT_TYPE, "application/json")
|
||||||
// .body(xmlText)
|
.body(xmlText)
|
||||||
// .execute().body();
|
.execute().body();
|
||||||
// //String post = HttpUtil.post(mathToImgUrl, map);
|
//String post = HttpUtil.post(mathToImgUrl, map);
|
||||||
// if (messageList.size() > 0) {
|
if (messageList.size() > 0) {
|
||||||
// addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, post);
|
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 xmlText = ctoMathPara.xmlText().replaceAll("xml-fragment","m:oMath");;
|
String xmlText = ctoMathPara.xmlText().replaceAll("xml-fragment","m:oMath");;
|
||||||
// Map<String,Object> map = new HashMap<>();
|
Map<String,Object> map = new HashMap<>();
|
||||||
// map.put("encode",xmlText);
|
map.put("encode",xmlText);
|
||||||
// String post = HttpRequest.post(mathToImgUrl)
|
String post = HttpRequest.post(mathToImgUrl)
|
||||||
// .header(Header.CONTENT_TYPE, "application/json")
|
.header(Header.CONTENT_TYPE, "application/json")
|
||||||
// .body(xmlText)
|
.body(xmlText)
|
||||||
// .execute().body();
|
.execute().body();
|
||||||
// //String post = HttpUtil.post(mathToImgUrl, map);
|
//String post = HttpUtil.post(mathToImgUrl, map);
|
||||||
// if (messageList.size() > 0) {
|
if (messageList.size() > 0) {
|
||||||
// addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, post);
|
addItermsMathImage(messageList.get(messageList.size() - 1), itemValList, post);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (XWPFRun xwrun : p.getRuns()) {
|
for (XWPFRun xwrun : p.getRuns()) {
|
||||||
@@ -940,7 +946,8 @@ public class FileSpiltService {
|
|||||||
String filepathandname = filePathCos + "/" + imageName;
|
String filepathandname = filePathCos + "/" + imageName;
|
||||||
try {
|
try {
|
||||||
String path = splitUrl+imageName;
|
String path = splitUrl+imageName;
|
||||||
MinioUtil.uploadByte(bytev, filepathandname);
|
// MinioUtil.uploadByte(bytev, filepathandname);
|
||||||
|
ObsBootUtil.upload(new ByteArrayInputStream(bytev), filepathandname);
|
||||||
String imgCon = path;
|
String imgCon = path;
|
||||||
String imgConVal = "<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\"" + path + "\">";
|
String imgConVal = "<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\"" + path + "\">";
|
||||||
message.getItemsCondi().add(imgConVal);
|
message.getItemsCondi().add(imgConVal);
|
||||||
@@ -961,7 +968,8 @@ public class FileSpiltService {
|
|||||||
String filepathandname = filePathCos + "/" + imageName;
|
String filepathandname = filePathCos + "/" + imageName;
|
||||||
try {
|
try {
|
||||||
String path = splitUrl+imageName;
|
String path = splitUrl+imageName;
|
||||||
MinioUtil.uploadByte(bytev, filepathandname);
|
// MinioUtil.uploadByte(bytev, filepathandname);
|
||||||
|
ObsBootUtil.upload(new ByteArrayInputStream(bytev), filepathandname);
|
||||||
String imgCon = path;
|
String imgCon = path;
|
||||||
String imgConVal = "<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\"" + path + "\">";
|
String imgConVal = "<img class=\"wordImg\" style=\"width:100%;height:100%\" src=\"" + path + "\">";
|
||||||
stringBuilder.append(imgConVal);
|
stringBuilder.append(imgConVal);
|
||||||
@@ -1118,11 +1126,11 @@ public class FileSpiltService {
|
|||||||
}
|
}
|
||||||
OSSFile ossFile = ossFileList.get(0);
|
OSSFile ossFile = ossFileList.get(0);
|
||||||
String readFilePath = ossFile.getUrl();
|
String readFilePath = ossFile.getUrl();
|
||||||
if (org.apache.commons.lang.StringUtils.isEmpty(readFilePath) || !MinioUtil.doesObjectExist(readFilePath)) {
|
if (org.apache.commons.lang.StringUtils.isEmpty(readFilePath)) {
|
||||||
throw new JeroBootException("当前文件未找到,请重新选择!");
|
throw new JeroBootException("当前文件未找到,请重新选择!");
|
||||||
}
|
}
|
||||||
try (InputStream is = MinioUtil.download(readFilePath)) {
|
// try (InputStream is = MinioUtil.download(readFilePath)) {
|
||||||
|
try (InputStream is = ObsBootUtil.getOssFile(readFilePath)) {
|
||||||
// InputStream is = new FileInputStream(readFilePath); //需要将文件路更改为word文档所在路径。
|
// InputStream is = new FileInputStream(readFilePath); //需要将文件路更改为word文档所在路径。
|
||||||
XWPFDocument doc = new XWPFDocument(is);
|
XWPFDocument doc = new XWPFDocument(is);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user