Merge branch 'test' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into test
This commit is contained in:
commit
7a55a351cb
|
|
@ -325,29 +325,35 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
// 把source工程的层级结构copy到目标工程
|
// 把source工程的层级结构copy到目标工程
|
||||||
// 查找source的全部目录
|
// 查找source的全部目录
|
||||||
List<EdFileInfo> sourceEdFileInfos = commonService.selectAllAdminFolder(sourceId, true, null);
|
List<EdFileInfo> sourceEdFileInfos = commonService.selectAllAdminFolder(sourceId, true, null);
|
||||||
List<EdFileInfo> targetEdFileInfos = commonService.selectAllAdminFolder(targetId, true, null);
|
|
||||||
List<String> needSavePaths = new ArrayList<>();
|
List<String> needSavePaths = new ArrayList<>();
|
||||||
// 确定层级最大为prjFolderMaxLength层,现在逐层来处理。
|
// 确定层级最大为prjFolderMaxLength层,现在逐层来处理。
|
||||||
for (int i = 1; i <= prjFolderMaxLength; ++i) {
|
for (int i = 1; i <= prjFolderMaxLength; ++i) {
|
||||||
|
List<EdFileInfo> targetEdFileInfos = commonService.selectAllAdminFolder(targetId, true, null);
|
||||||
// 先查找source第i层下有那些子集
|
// 先查找source第i层下有那些子集
|
||||||
final int count = i;
|
final int count = i;
|
||||||
EdFileInfo targetParentFile = targetEdFileInfos.stream()
|
// 取source当前层
|
||||||
.filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == count - 1)
|
|
||||||
.collect(Collectors.toList()).stream().findFirst().orElse(null);
|
|
||||||
if (targetParentFile == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
List<EdFileInfo> sourceTmpEdFiles = sourceEdFileInfos.stream()
|
List<EdFileInfo> sourceTmpEdFiles = sourceEdFileInfos.stream()
|
||||||
.filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == count)
|
.filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == count)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
// 取target父层
|
||||||
List<EdFileInfo> targetTmpEdFiles = targetEdFileInfos.stream()
|
List<EdFileInfo> targetTmpEdFiles = targetEdFileInfos.stream()
|
||||||
.filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == count)
|
.filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == count - 1)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 获取source名称的map
|
||||||
|
Map<String, EdFileInfo> sourceFileNameMap = sourceTmpEdFiles.stream()
|
||||||
|
.collect(Collectors.toMap(EdFileInfo::getFileName, e -> e));
|
||||||
|
// 获取target当前层级的子集名称
|
||||||
|
List<String> targetFileNames = targetEdFileInfos.stream()
|
||||||
|
.filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == count)
|
||||||
|
.map(EdFileInfo::getFileName)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
Map<String, EdFileInfo> sourceFileNameMap = sourceTmpEdFiles.stream().collect(Collectors.toMap(EdFileInfo::getFileName, e -> e));
|
|
||||||
List<String> targetFileNames = targetTmpEdFiles.stream().map(EdFileInfo::getFileName).collect(Collectors.toList());
|
|
||||||
int sort = targetTmpEdFiles.size();
|
int sort = targetTmpEdFiles.size();
|
||||||
for (EdFileInfo edFileInfo : sourceTmpEdFiles) {
|
for (EdFileInfo edFileInfo : sourceTmpEdFiles) {
|
||||||
String sourceFileName = edFileInfo.getFileName();
|
String sourceFileName = edFileInfo.getFileName();
|
||||||
|
|
||||||
|
String sourceFileParentName = sourceEdFileInfos.stream().filter(e -> e.getId().equals(edFileInfo.getParentId())).findFirst().get().getFileName();
|
||||||
|
EdFileInfo targetParentFile = i == 1 ? targetTmpEdFiles.stream().filter(e -> e.getId().equals(targetId)).findFirst().get() : targetTmpEdFiles.stream().filter(e -> e.getFileName().equals(sourceFileParentName)).findFirst().get();
|
||||||
|
|
||||||
if (!targetFileNames.contains(sourceFileName)) {
|
if (!targetFileNames.contains(sourceFileName)) {
|
||||||
EdFileInfo sourceFile = sourceFileNameMap.get(sourceFileName);
|
EdFileInfo sourceFile = sourceFileNameMap.get(sourceFileName);
|
||||||
EdFileInfo targetFile = new EdFileInfo();
|
EdFileInfo targetFile = new EdFileInfo();
|
||||||
|
|
@ -368,6 +374,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
.setDataStatus(EleDataStatusEnum.NOT_PUBLISHED.code)
|
.setDataStatus(EleDataStatusEnum.NOT_PUBLISHED.code)
|
||||||
.setEffectFlag(EffectFlagEnum.EFFECT.code)
|
.setEffectFlag(EffectFlagEnum.EFFECT.code)
|
||||||
.setFileCode(fileCode)
|
.setFileCode(fileCode)
|
||||||
|
.setFileType("文件夹")
|
||||||
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
||||||
.setFilePath(targetParentFile.getFilePath() + MYSQL_FILE_PATH_SPLIT + newFolderId)
|
.setFilePath(targetParentFile.getFilePath() + MYSQL_FILE_PATH_SPLIT + newFolderId)
|
||||||
.setSort(++sort)
|
.setSort(++sort)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ pagehelper.helperDialect=mysql
|
||||||
pagehelper.reasonable=false
|
pagehelper.reasonable=false
|
||||||
server.port=12395
|
server.port=12395
|
||||||
file.security.passwd=adknfhkj87654knd
|
file.security.passwd=adknfhkj87654knd
|
||||||
#windowsæÂÂä»¶åÂÂå¨ç®å½Âï¼Âç¨äºÂæµÂè¯Â
|
|
||||||
data.windows.path=D:/tmp/eleData/project/
|
data.windows.path=D:/tmp/eleData/project/
|
||||||
data.linux.path=/szsd/data/eleData/project/
|
data.linux.path=/szsd/data/eleData/project/
|
||||||
data.upload.windows.tmp.path=D:/tmp/eleData/upload/
|
data.upload.windows.tmp.path=D:/tmp/eleData/upload/
|
||||||
|
|
|
||||||
|
|
@ -1,74 +1,21 @@
|
||||||
//import cn.hutool.core.io.FileUtil;
|
|
||||||
//import cn.hutool.core.util.IdUtil;
|
|
||||||
//import cn.hutool.core.util.ZipUtil;
|
|
||||||
//import cn.hutool.crypto.SecureUtil;
|
|
||||||
//import cn.hutool.crypto.symmetric.AES;
|
|
||||||
//import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
|
||||||
//import com.electromagnetic.industry.software.manage.Application;
|
//import com.electromagnetic.industry.software.manage.Application;
|
||||||
//import com.electromagnetic.industry.software.manage.service.FileSystemService;
|
//import com.electromagnetic.industry.software.manage.service.serviceimpl.EdPrjServiceImpl;
|
||||||
//import com.electromagnetic.industry.software.manage.service.serviceimpl.EdFileInfoServiceImpl;
|
|
||||||
//import org.junit.jupiter.api.Test;
|
//import org.junit.jupiter.api.Test;
|
||||||
//import org.springframework.beans.factory.annotation.Value;
|
|
||||||
//import org.springframework.boot.test.context.SpringBootTest;
|
//import org.springframework.boot.test.context.SpringBootTest;
|
||||||
//import org.springframework.core.env.Environment;
|
|
||||||
//
|
//
|
||||||
//import javax.annotation.PostConstruct;
|
|
||||||
//import javax.annotation.Resource;
|
//import javax.annotation.Resource;
|
||||||
//import java.io.File;
|
|
||||||
//import java.io.InputStream;
|
|
||||||
//import java.io.OutputStream;
|
|
||||||
//import java.nio.file.Files;
|
|
||||||
//import java.nio.file.Paths;
|
|
||||||
//
|
//
|
||||||
//@SpringBootTest(classes = Application.class)
|
//@SpringBootTest(classes = Application.class)
|
||||||
//public class Test1 {
|
//public class Test1 {
|
||||||
//
|
//
|
||||||
// @Resource
|
// @Resource
|
||||||
// private EdFileInfoServiceImpl edFileInfoServiceImpl;
|
// private EdPrjServiceImpl edPrjService;
|
||||||
// @Resource
|
|
||||||
// private FileSystemService fileSystemService;
|
|
||||||
//
|
|
||||||
// @Value("${file.security.passwd}")
|
|
||||||
// private String password;
|
|
||||||
//
|
|
||||||
// private String downloadDataDir = "";
|
|
||||||
// private String uploadDataDir = "";
|
|
||||||
//
|
|
||||||
// @Resource
|
|
||||||
// private Environment environment;
|
|
||||||
//
|
|
||||||
// @PostConstruct
|
|
||||||
// public void init() {
|
|
||||||
// String osName = System.getProperty("os.name").toLowerCase();
|
|
||||||
// uploadDataDir = osName.startsWith("win") ? environment.getProperty("data.upload.windows.tmp.path") : environment.getProperty("data.upload.linux.tmp.path");
|
|
||||||
// downloadDataDir = osName.startsWith("win") ? environment.getProperty("data.download.windows.tmp.path") : environment.getProperty("data.download.linux.tmp.path");
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
// @Test
|
// @Test
|
||||||
// public void testImport() {
|
// public void testFollow() {
|
||||||
// String currentUserId = UserThreadLocal.getUserId();
|
// String sourceId = "100101";
|
||||||
// String destColibPath = "E:/tmp/测试沿用.colib";
|
// String targetId = "100323";
|
||||||
// String mainName = FileUtil.mainName(destColibPath);
|
// edPrjService.follow(sourceId, targetId);
|
||||||
// String parentDir = FileUtil.getParent(destColibPath, 1);
|
|
||||||
// String zipDirPath = parentDir + File.separator + mainName + ".zip";
|
|
||||||
// AES aes = SecureUtil.aes(password.getBytes());
|
|
||||||
// try (
|
|
||||||
// InputStream inputStream = Files.newInputStream(Paths.get(destColibPath));
|
|
||||||
// OutputStream outputStream = Files.newOutputStream(Paths.get(zipDirPath));
|
|
||||||
// ) {
|
|
||||||
// aes.decrypt(inputStream, outputStream, true);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// String info = "文件上传错误";
|
|
||||||
// System.out.println("info = " + info);
|
|
||||||
// }
|
|
||||||
// String uuid = IdUtil.fastSimpleUUID();
|
|
||||||
// String tmpDir = uploadDataDir + currentUserId + File.separator + uuid + File.separator;
|
|
||||||
// ZipUtil.unzip(zipDirPath, tmpDir);
|
|
||||||
//
|
|
||||||
// edFileInfoServiceImpl.update2Database(tmpDir);
|
|
||||||
// fileSystemService.deleteFile(zipDirPath, destColibPath);
|
|
||||||
//
|
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue