提交 01c3554d 作者: ZhangJingKun

解决onlyoffice编辑后端问题无法解析问题

上级 0c25f2e7
......@@ -18,6 +18,7 @@ import com.zzsn.knowbase.util.file.Md5Utils;
import com.zzsn.knowbase.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.hashids.Hashids;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
......@@ -302,6 +303,7 @@ public class LocalFileServiceImpl implements ILocalFileService {
@Override
public Result<?> editKnowledge(Knowledge knowledge) {
log.info("保存文档:" + knowledge);
Result result = Result.OK();
String id = knowledge.getId();
if(id == null || "".equals(id))
......@@ -338,11 +340,32 @@ public class LocalFileServiceImpl implements ILocalFileService {
e.printStackTrace();
}
try {
log.info("文件转换");
File file = new File(filesStorage+filePath);
XWPFDocument document = new XWPFDocument(new FileInputStream(file));
document.write(new FileOutputStream(filesStorage+filePath+".tmp"));
document.close();
//log.info("文件转换成功:{}", filePath+".tmp");
Path path = Paths.get(filesStorage+filePath);
Files.delete(path);
//log.info("文件删除成功:{}", filesStorage+filePath);
Path path1 = Paths.get(filesStorage+filePath+".tmp");
Files.move(path1, path);
//log.info("文件重命名成功");
log.info("文件转换成功:{}", filePath);
} catch (IOException e) {
e.printStackTrace();
}
String fileType = fileUtility.getFileType(knowFile.getFileName());
knowFile.setFileType(fileType);
File file = new File(filesStorage + knowFile.getFilePath());
Long size = file.length();
knowFile.setFileSize(size);
log.info("knowFile:" + knowFile);
knowledgeService.addKnowledge(knowFile,knowledge,userInfo);
}else {
knowledgeService.addKnowledge(null,knowledge,userInfo);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论