From de4f48507c88901d391cfac17f1f959deafd8984 Mon Sep 17 00:00:00 2001 From: chenxudong Date: Fri, 3 Jan 2025 10:30:24 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=B0=83=E9=80=9A=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/EdFileInfoServiceImpl.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java index ca4c227..42e8dc6 100644 --- a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java +++ b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java @@ -560,23 +560,28 @@ public class EdFileInfoServiceImpl extends ServiceImpl prjFolders = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class).eq(EdFileInfo::getPrjDir, true).eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)); + String prjId = resFiles.get(0).getFilePath().split(MYSQL_FILE_PATH_SPLIT)[0]; + List prjFolders = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class) + .likeRight(EdFileInfo::getFilePath, prjId + MYSQL_FILE_PATH_SPLIT) + .eq(EdFileInfo::getPrjDir, true) + .eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)); + EdFileInfo prjFileInfo = this.baseMapper.selectById(prjId); Map prjFoldersMap = prjFolders.stream().collect(Collectors.toMap(EdFileInfo::getId, e -> e)); Map tmps = resFiles.stream().collect(Collectors.toMap(EdFileInfo::getId, e -> e)); + tmps.putAll(prjFoldersMap); resFiles.clear(); resFiles.addAll(tmps.values()); - resFiles.addAll(prjFoldersMap.values()); + resFiles.add(prjFileInfo); String prjName = commonService.getPrjNameByDbPath(resFiles.get(0).getFilePath()); List folders = resFiles.stream().filter(e -> e.getDataType().equals(EleDataTypeEnum.FOLDER.code)).collect(Collectors.toList()); List files = resFiles.stream().filter(e -> e.getDataType().equals(EleDataTypeEnum.FILE.code)).collect(Collectors.toList()); for (EdFileInfo edFileInfo : folders) { - String destFolderPath = downloadDataDir + File.separator + prjName + File.separator + commonService.getFileSysPath(edFileInfo.getFileId()); // file + String destFolderPath = downloadDataDir + File.separator + prjName + File.separator + commonService.getDbPath(edFileInfo.getFilePath()); // file fileSystemService.createDirectory(destFolderPath); } for (EdFileInfo edFileInfo : files) { - String filePath = commonService.getFileSysPath(edFileInfo.getFileId()); // file - String destPath = downloadDataDir + File.separator + prjName + File.separator + commonService.getDbPath(edFileInfo.getFileId()); + String filePath = commonService.getFileSysPath(edFileInfo.getFilePath()); // file + String destPath = downloadDataDir + File.separator + prjName + File.separator + commonService.getDbPath(edFileInfo.getFilePath()); fileSystemService.copyFile(filePath, destPath); } String mysqlInfo = JSONUtil.toJsonStr(resFiles); @@ -596,6 +601,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl upload(String parentId, MultipartFile file, Integer strategy) { Assert.isTrue(EleCommonUtil.isFileNameValid(file.getOriginalFilename()), NAME_VALID_MSG); - EdFileInfo fileInfo = this.baseMapper.selectById(parentId); - Assert.isTrue(fileInfo.getDataType().equals(EleDataTypeEnum.FOLDER.code) && !fileInfo.getPrjDir(), "层级目录不允许上传文件"); +// EdFileInfo fileInfo = this.baseMapper.selectById(parentId); +// Assert.isTrue(fileInfo.getDataType().equals(EleDataTypeEnum.FOLDER.code) && !fileInfo.getPrjDir(), "层级目录不允许上传文件"); String fileName = file.getOriginalFilename(); String mainName = FileUtil.mainName(fileName); String suffix = FileUtil.getSuffix(fileName); From 52a51c8e1b49702bd13d3e2b499b577c8e6538e9 Mon Sep 17 00:00:00 2001 From: chenxudong Date: Fri, 3 Jan 2025 14:18:40 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/serviceimpl/CommonService.java | 14 ++++++++------ .../serviceimpl/EdFileInfoServiceImpl.java | 8 ++++++++ .../service/serviceimpl/EdPrjServiceImpl.java | 18 ++++++++++++------ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/CommonService.java b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/CommonService.java index dbc356c..39b7b25 100644 --- a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/CommonService.java +++ b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/CommonService.java @@ -210,7 +210,7 @@ public class CommonService { } } - public List queryAllPrjInfo(boolean isAdminQuery) { + public List queryAllPrjInfo(boolean isAdminQuery) { try { LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class) @@ -222,7 +222,7 @@ public class CommonService { } List ids = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList()); - List projectVOS = new ArrayList<>(); + List projectVOS = new ArrayList<>(); for (String id : ids) { List edFileInfos = selectAllAdminFolder(id); @@ -246,8 +246,9 @@ public class CommonService { treeNode.putExtra(ProjectVO.Fields.dataStatus, obj.getDataStatus()); })); String jsonStr = JSONUtil.toJsonStr(trees); - ProjectVO projectVO = JSONUtil.toList(jsonStr, ProjectVO.class).get(0); - projectVOS.add(projectVO); + projectVOS.add(jsonStr); +// ProjectVO projectVO = JSONUtil.toList(jsonStr, ProjectVO.class).get(0); +// projectVOS.add(projectVO); } else { TreeNodeConfig config = new TreeNodeConfig(); config.setIdKey(FileProjectVO.Fields.categoryId); @@ -261,8 +262,9 @@ public class CommonService { treeNode.putExtra(FileProjectVO.Fields.dataStatus, obj.getDataStatus()); })); String jsonStr = JSONUtil.toJsonStr(trees); - FileProjectVO fileProjectVO = JSONUtil.toList(jsonStr, FileProjectVO.class).get(0); - projectVOS.add(fileProjectVO); + projectVOS.add(jsonStr); +// FileProjectVO fileProjectVO = JSONUtil.toList(jsonStr, FileProjectVO.class).get(0); +// projectVOS.add(fileProjectVO); } } return projectVOS; diff --git a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java index 42e8dc6..c4d91d1 100644 --- a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java +++ b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java @@ -28,6 +28,7 @@ import com.electromagnetic.industry.software.manage.pojo.other.FileInfoVO; import com.electromagnetic.industry.software.manage.pojo.other.UploadRecordDTO; import com.electromagnetic.industry.software.manage.pojo.req.*; import com.electromagnetic.industry.software.manage.pojo.resp.FileInfoQueryPageVO; +import com.electromagnetic.industry.software.manage.pojo.resp.FileProjectVO; import com.electromagnetic.industry.software.manage.pojo.resp.FileVersionViewVO; import com.electromagnetic.industry.software.manage.pojo.resp.UploadRecordVO; import com.electromagnetic.industry.software.manage.service.EdFileInfoService; @@ -165,6 +166,13 @@ public class EdFileInfoServiceImpl extends ServiceImpl tree() { + List strings = commonService.queryAllPrjInfo(false); + List res = new ArrayList<>(); + strings.forEach(e -> { + FileProjectVO fileProjectVO = JSONUtil.toList(e, FileProjectVO.class).get(0); + res.add(fileProjectVO); + }); + res.sort(Comparator.comparing(FileProjectVO::getSort)); return ElectromagneticResultUtil.success(commonService.queryAllPrjInfo(false)); } diff --git a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdPrjServiceImpl.java b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdPrjServiceImpl.java index 9ebe8ee..a7f83e5 100644 --- a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdPrjServiceImpl.java +++ b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdPrjServiceImpl.java @@ -3,6 +3,7 @@ package com.electromagnetic.industry.software.manage.service.serviceimpl; import cn.hutool.core.lang.Assert; import cn.hutool.core.text.StrFormatter; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -20,6 +21,7 @@ import com.electromagnetic.industry.software.common.util.UserThreadLocal; import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper; import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo; import com.electromagnetic.industry.software.manage.pojo.req.FolderResortDTO; +import com.electromagnetic.industry.software.manage.pojo.resp.ProjectVO; import com.electromagnetic.industry.software.manage.service.EdPrjService; import com.electromagnetic.industry.software.manage.service.FileSystemService; import org.springframework.beans.factory.annotation.Value; @@ -28,10 +30,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.File; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; import static com.electromagnetic.industry.software.common.cons.ElectromagneticConstants.*; @@ -215,7 +214,14 @@ public class EdPrjServiceImpl extends ServiceImpl */ @Override public ElectromagneticResult queryAllPrjInfo() { - return ElectromagneticResultUtil.success(commonService.queryAllPrjInfo(true)); + List res = commonService.queryAllPrjInfo(true); + List projectVOS = new ArrayList<>(); + res.forEach(e -> { + ProjectVO projectVO = JSONUtil.toList(e, ProjectVO.class).get(0); + projectVOS.add(projectVO); + }); + projectVOS.sort(Comparator.comparing(ProjectVO::getSort)); + return ElectromagneticResultUtil.success(projectVOS); } /** @@ -349,7 +355,7 @@ public class EdPrjServiceImpl extends ServiceImpl .setFileTime(nowTimeStr) .setDataType(EleDataTypeEnum.FOLDER.code) .setDataStatus(EleDataStatusEnum.NOT_PUBLISHED.code) - .setEffectFlag(EffectFlagEnum.NOT_EFFECTIVE.code) + .setEffectFlag(EffectFlagEnum.EFFECT.code) .setFileCode(fileCode) .setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code) .setFilePath(targetParentFile.getFilePath() + MYSQL_FILE_PATH_SPLIT + newFolderId) From 80a187ed12d5270d69f555260fd2c37e086bc3cf Mon Sep 17 00:00:00 2001 From: chenxudong Date: Fri, 3 Jan 2025 14:40:54 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=B0=83=E9=80=9A=E4=BA=86=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E5=AF=BC=E5=87=BA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/service/serviceimpl/EdFileInfoServiceImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java index c4d91d1..f07bf1b 100644 --- a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java +++ b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java @@ -596,7 +596,10 @@ public class EdFileInfoServiceImpl extends ServiceImpl