From 96a893bcc673085f7d6fe3bc5ca7dc34e7ca1db2 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期三, 12 二月 2025 17:44:25 +0800
Subject: [PATCH] flowable模块中的FlowTaskService及controller移动到business模块,完成任务和驳回任务添加日志
---
common/src/main/java/com/ycl/common/utils/file/FileUploadUtils.java | 41 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 40 insertions(+), 1 deletions(-)
diff --git a/common/src/main/java/com/ycl/common/utils/file/FileUploadUtils.java b/common/src/main/java/com/ycl/common/utils/file/FileUploadUtils.java
index bab638f..586f5b5 100644
--- a/common/src/main/java/com/ycl/common/utils/file/FileUploadUtils.java
+++ b/common/src/main/java/com/ycl/common/utils/file/FileUploadUtils.java
@@ -2,7 +2,9 @@
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
import java.util.Objects;
import org.apache.commons.io.FilenameUtils;
import org.springframework.web.multipart.MultipartFile;
@@ -85,7 +87,44 @@
throw new IOException(e.getMessage(), e);
}
}
-
+ /**
+ * 鏂囦欢涓婁紶
+ *
+ * @param baseDir 鐩稿搴旂敤鐨勫熀鐩綍
+ * @param file 涓婁紶鐨勬枃浠�
+ * @return 杩斿洖涓婁紶鎴愬姛鐨勬枃浠跺悕
+ * @throws FileSizeLimitExceededException 濡傛灉瓒呭嚭鏈�澶уぇ灏�
+ * @throws FileNameLengthLimitExceededException 鏂囦欢鍚嶅お闀�
+ * @throws IOException 姣斿璇诲啓鏂囦欢鍑洪敊鏃�
+ * @throws InvalidExtensionException 鏂囦欢鏍¢獙寮傚父
+ */
+ public static final String uploadIOFile(String baseDir, java.io.File file)
+ throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException
+ {
+ int fileNamelength = Objects.requireNonNull(file.getName()).length();
+ if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
+ {
+ throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
+ }
+ //涓婁紶IOFile鏂囦欢閫昏緫
+ String fileName = file.getName();
+ //甯︽棩鏈熷墠缂�鐨勬枃浠跺悕
+ String formatName = StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
+ FilenameUtils.getBaseName(fileName), Seq.getId(Seq.uploadSeqType), fileName.substring(fileName.lastIndexOf(".") + 1));
+ // /home/projectManagement/uploadPath/upload/2024/11/11/xxxx
+ String url = baseDir + File.separator + formatName;
+ File newFile = new File(url);
+ if (!newFile.exists())
+ {
+ if (!newFile.getParentFile().exists())
+ {
+ newFile.getParentFile().mkdirs();
+ }
+ }
+ //澶嶅埗鏂囦欢鍒颁笂浼犺矾寰�
+ Files.copy(file.toPath(), newFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ return getPathFileName(baseDir, formatName);
+ }
/**
* 鏂囦欢涓婁紶
*
--
Gitblit v1.8.0