|
@@ -1,19 +1,21 @@
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
-import java.io.ByteArrayInputStream;
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.io.StringReader;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
-import java.util.Base64;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
+import java.nio.file.StandardCopyOption;
|
|
|
import java.util.List;
|
|
|
|
|
|
import com.ruoyi.common.config.RuoYiConfig;
|
|
|
+import com.ruoyi.common.constant.Constants;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
import com.ruoyi.common.utils.file.FileUtils;
|
|
|
import com.ruoyi.system.entity.BpmProcess;
|
|
@@ -108,7 +110,7 @@ public class BpmProcessServiceImpl implements IBpmProcessService {
|
|
|
String filePath = ""; // 新的文件存放路径
|
|
|
if (!fileXML.isEmpty()) {
|
|
|
// 修改流程删除流程文件后重新生成
|
|
|
- System.err.println(FileUtils.deleteFile(bpmProcess.getProcessXmlPath()));
|
|
|
+ FileUtils.deleteFile(RuoYiConfig.getProfile() + StringUtils.substringAfter(bpmProcess.getProcessXmlPath(), Constants.RESOURCE_PREFIX));
|
|
|
try {
|
|
|
// 解析得到当前文件中的内容
|
|
|
byte[] bytes = fileXML.getBytes();
|
|
@@ -163,6 +165,16 @@ public class BpmProcessServiceImpl implements IBpmProcessService {
|
|
|
bpmProcess.setCreateTime(DateUtils.getNowDate());
|
|
|
bpmProcess.setCreateBy(SecurityUtils.getUsername());
|
|
|
bpmProcess.setProcessVersion(1L); // 设置为历史版本,备份状态
|
|
|
+ String filePath = RuoYiConfig.getProfile() + StringUtils.substringAfter(bpmProcess.getProcessXmlPath(), Constants.RESOURCE_PREFIX);
|
|
|
+ // 复制流程文件
|
|
|
+ Path fileInfo = Paths.get(filePath);
|
|
|
+ // 定义目标文件路径,注意这里我们只是改变了文件的名字,路径还是原来的路径
|
|
|
+ Path destinationFile = Paths.get(filePath).resolveSibling("备份:" + fileInfo.getFileName().toString());
|
|
|
+ try {
|
|
|
+ Files.copy(fileInfo, destinationFile, StandardCopyOption.REPLACE_EXISTING);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
return bpmProcessMapper.insertBpmProcess(bpmProcess);
|
|
|
}
|
|
|
|