From 03af9393e509898af90e11910ccb848c71704fa0 Mon Sep 17 00:00:00 2001
From: 18756 <1875631620@qq.com>
Date: 星期一, 26 八月 2024 15:36:30 +0800
Subject: [PATCH] 文档功能优化8.26
---
src/main/java/com/product/file/service/OnlineDocumentEditService.java | 36 ++++++++++++++++++++++++++++++++++--
1 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/product/file/service/OnlineDocumentEditService.java b/src/main/java/com/product/file/service/OnlineDocumentEditService.java
index 817138c..8f39bf7 100644
--- a/src/main/java/com/product/file/service/OnlineDocumentEditService.java
+++ b/src/main/java/com/product/file/service/OnlineDocumentEditService.java
@@ -59,9 +59,31 @@
try {
String document_template = ff.getString("document_template");
String document_template_tail = ff.getString("document_template_tail");
+ String fileUuid = ff.getString("file_uuid");
+ FieldSetEntity fieldSetEntity = getBaseDao().getFieldSetEntity(CmnConst.PRODUCT_SYS_ATTACHMENTS, fileUuid, false);
+ //鑾峰彇鏂囦欢绫诲瀷
+ String fileName = fieldSetEntity.getString(CmnConst.FILE_NAME);
+ //鍒ゆ柇鏄惁涓篸oc鏂囦欢
+ String fileType = fileName.substring(fileName.lastIndexOf(".") + 1);
+ if ("doc".equals(fileType)) {
+ //灏哾oc鏂囦欢杞崲涓篸ocx鏂囦欢
+ File f = file;
+ file = com.product.file.util.FileUtil.toDocx(file);
+ if (f != null) {
+ f.delete();
+ }
+ }
List<File> fileList = new ArrayList<>(3);
if (!StringUtils.isEmpty(document_template)) {
- fileList.add(fileManagerService.getFile(document_template));
+ File file1 = fileManagerService.getFile(document_template);
+ //鍒ゆ柇file1鐨勬枃浠剁被鍨�
+ if (file1.getName().substring(file1.getName().lastIndexOf(".") + 1).equals("doc")) {
+ //杞崲涓篸ocx
+ File docx = com.product.file.util.FileUtil.toDocx(file1);
+ FileUtil.del(file1);
+ file1 = docx;
+ }
+ fileList.add(file1);
fileList.add(file);
} else {
fileList.add(file);
@@ -72,15 +94,25 @@
File mergeFile = MergeDoc.mergeDoc(fileList, Global.getSystemConfig("upload.file.temp.path", "./attachment/temp") +
File.separator + "nest_red_document_" + IdUtil.randomUUID() + "_" + ff.getString("file_uuid"));
if (mergeFile != null && mergeFile.isFile()) {
+ if ("doc".equals(fileType)) {
+ //灏哾ocx鏂囦欢杞崲涓篸oc鏂囦欢
+ File f = mergeFile;
+ mergeFile = com.product.file.util.FileUtil.toDoc(f);
+ if (f != null) {
+ f.delete();
+ }
+ }
HashMap<String, File> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("mergeFile", mergeFile);
uploadFile(ff.getString("file_uuid"), objectObjectHashMap);
} else {
throw new BaseException(FileCode.NEST_RED_DOCUMENT_FAIL);
}
+ fileList.forEach(FileUtil::del);
} catch (BaseException e) {
throw e;
} catch (Exception e) {
+ e.printStackTrace();
throw new BaseException(FileCode.NEST_RED_DOCUMENT_FAIL);
}
}
@@ -288,7 +320,7 @@
//姝e湪琚紪杈�
String existsKey = keys.toArray(new String[]{})[0];
//杩欓噷浼氭姏鍑烘鍦ㄧ紪杈戠殑寮傚父
- throwBeingEditDocument(existsKey.substring(existsKey.lastIndexOf("-")+1));
+ throwBeingEditDocument(existsKey.substring(existsKey.lastIndexOf("-") + 1));
} else if (remove) {
RedisUtil.setOutTime(key, getExpirationTime());
return;
--
Gitblit v1.9.2