From 1acaec87a739ae35ffffe57ba5a5ed24174df767 Mon Sep 17 00:00:00 2001 From: chenxudong Date: Tue, 7 Jan 2025 09:36:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/controller/CategoryController.java | 27 - .../manage/controller/EDDataController.java | 106 --- .../manage/service/CategoryService.java | 9 - .../manage/service/EDDataService.java | 109 --- .../serviceimpl/CategoryServiceImpl.java | 85 -- .../serviceimpl/EDDataServiceImpl.java | 899 ------------------ 6 files changed, 1235 deletions(-) delete mode 100644 electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/controller/CategoryController.java delete mode 100644 electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/controller/EDDataController.java delete mode 100644 electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/CategoryService.java delete mode 100644 electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/EDDataService.java delete mode 100644 electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/CategoryServiceImpl.java delete mode 100644 electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EDDataServiceImpl.java diff --git a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/controller/CategoryController.java b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/controller/CategoryController.java deleted file mode 100644 index 1177ab6..0000000 --- a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/controller/CategoryController.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.electromagnetic.industry.software.manage.controller; - -import com.electromagnetic.industry.software.common.resp.ElectromagneticResult; -import com.electromagnetic.industry.software.manage.service.CategoryService; -import io.swagger.annotations.ApiOperation; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -@RequestMapping("/data/ed/category") -@RestController -public class CategoryController { - - @Resource - private CategoryService categoryService; - - /** - * 目录树查询 - */ - @ApiOperation(value = "目录树查询", notes = "") - @RequestMapping(value = "/tree", method = RequestMethod.GET) - public ElectromagneticResult categoryTree() { - return categoryService.getAllCategories(); - } -} diff --git a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/controller/EDDataController.java b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/controller/EDDataController.java deleted file mode 100644 index 96c1a9a..0000000 --- a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/controller/EDDataController.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.electromagnetic.industry.software.manage.controller; - -import com.electromagnetic.industry.software.common.resp.ElectromagneticResult; -import com.electromagnetic.industry.software.manage.pojo.req.EDDataRequest; -import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO; -import com.electromagnetic.industry.software.manage.service.EDDataService; -import io.swagger.annotations.ApiOperation; -import org.springframework.core.io.InputStreamResource; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Date; - -@RequestMapping("/data1/ed/file") -@RestController -public class EDDataController { - - - @Resource - private EDDataService edDataService; - - @ApiOperation(value = "新建文件夹", notes = "") - @RequestMapping(value = "/createFolder", method = RequestMethod.POST) - public ElectromagneticResult createFolder(@RequestBody EDDataRequest request) { - return edDataService.createFolder(request); - } - - - @ApiOperation(value = "获取文件信息列表", notes = "") - @RequestMapping(value = "/getFileInfoList", method = RequestMethod.POST) - public ElectromagneticResult getFileInfoList(@RequestBody EDDataRequest request) { - return edDataService.getDataInfoList(request); - } - - - @ApiOperation(value = "更新文件信息", notes = "") - @RequestMapping(value = "/updateFileInfo", method = RequestMethod.POST) - public ElectromagneticResult updateFileInfo(@RequestBody EDDataRequest request) { - return edDataService.updateFileInfo(request); - } - - - @ApiOperation(value = "获取子文件数量", notes = "") - @RequestMapping(value = "/getChildFileCount", method = RequestMethod.POST) - public ElectromagneticResult getChildFileCount(@RequestBody EDDataRequest request) { - return edDataService.getChildFileCount(request); - } - - - @ApiOperation(value = "上传", notes = "") - @RequestMapping(value = "/upload", consumes = "multipart/form-data", method = RequestMethod.POST) - public ElectromagneticResult upload(@RequestParam("parentId") String parentId, - @RequestParam("file") MultipartFile file, - @RequestParam("gmtBatchUpload") Long gmtBatchUpload) { - EDDataRequest request = new EDDataRequest(); - request.setParentId(parentId); - request.setFileData(file); - request.setGmtBatchUpload(new Date(gmtBatchUpload)); - return edDataService.uploadFile(request); - } - - - @ApiOperation(value = "下载", notes = "") - @RequestMapping(value = "/download", method = RequestMethod.GET) - public ResponseEntity download(@RequestParam String dataId, HttpServletResponse response) throws IOException { - return edDataService.download(dataId, response); - } - - - @ApiOperation(value = "数据导出", notes = "") - @RequestMapping(value = "/batchExport", method = RequestMethod.GET) - public ResponseEntity batchExport(@RequestParam String dataIdArr, HttpServletResponse response) throws IOException { - return edDataService.batchExport(dataIdArr, response); - } - - @ApiOperation(value = "获取已经上传的分片", notes = "") - @RequestMapping(value = "/getUploadedChunkNums", method = RequestMethod.GET) - public ElectromagneticResult getUploadedChunkNums(@RequestParam String identifier) { - return edDataService.getUploadedChunkNums(identifier); - } - - @ApiOperation(value = "合并分片", notes = "") - @RequestMapping(value = "/mergeChunks", method = RequestMethod.GET) - public ElectromagneticResult mergeChunks(@RequestParam String identifier, - @RequestParam String fileName, - @RequestParam Integer totalChunks) { - return edDataService.mergeChunks(identifier, fileName, totalChunks); - } - - @ApiOperation(value = "分片上传", notes = "") - @RequestMapping(value = "/batchImport", method = RequestMethod.POST) - public ElectromagneticResult batchImport(FileChunkDTO fileChunkDTO) { - return edDataService.batchImport(fileChunkDTO); - } - - @ApiOperation(value = "检查分片是否存在", notes = "") - @RequestMapping(value = "/batchImport", method = RequestMethod.GET) - public ElectromagneticResult checkChunkExist(FileChunkDTO fileChunkDTO) { - return edDataService.checkChunkExist(fileChunkDTO); - } - -} diff --git a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/CategoryService.java b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/CategoryService.java deleted file mode 100644 index 6c4ffa0..0000000 --- a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/CategoryService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.electromagnetic.industry.software.manage.service; - -import com.electromagnetic.industry.software.common.resp.ElectromagneticResult; - -public interface CategoryService { - - ElectromagneticResult getAllCategories(); - -} diff --git a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/EDDataService.java b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/EDDataService.java deleted file mode 100644 index ec9f52f..0000000 --- a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/EDDataService.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.electromagnetic.industry.software.manage.service; - -import com.electromagnetic.industry.software.common.resp.ElectromagneticResult; -import com.electromagnetic.industry.software.manage.pojo.req.EDDataRequest; -import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO; -import com.electromagnetic.industry.software.manage.pojo.req.FileChunkResultDTO; -import com.electromagnetic.industry.software.manage.pojo.resp.EDDataPageResponse; -import org.springframework.core.io.InputStreamResource; -import org.springframework.http.ResponseEntity; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.List; -import java.util.Map; - -public interface EDDataService { - /** - * 创建文件夹 - * - * @param request - * @return - */ - ElectromagneticResult createFolder(EDDataRequest request); - - - /** - * 获取文件信息列表 - * - * @param request - * @return - */ - ElectromagneticResult getDataInfoList(EDDataRequest request); - - /** - * 更新文件信息 - * - * @param request - * @return - */ - ElectromagneticResult updateFileInfo(EDDataRequest request); - - /** - * 获取子文件数量 - * - * @param request - * @return - */ - ElectromagneticResult> getChildFileCount(EDDataRequest request); - - /** - * 上传 - * - * @param request - * @return - */ - ElectromagneticResult uploadFile(EDDataRequest request); - - /** - * 下载 - * - * @param dataId - * @return - */ - ResponseEntity download(String dataId, HttpServletResponse response) throws IOException; - - /** - * 导出数据 - * - * @param dataIdArr - * @return - */ - ResponseEntity batchExport(String dataIdArr, HttpServletResponse response) throws IOException; - - /** - * 导入数据 - * - * @param fileChunkDTO - * @return - */ - ElectromagneticResult batchImport(FileChunkDTO fileChunkDTO); - - /** - * 获取已经上传的分片 - * - * @param identifier - * @return - */ - ElectromagneticResult> getUploadedChunkNums(String identifier); - - - /** - * 合并分片 - * - * @param identifier - * @param fileName - * @param totalChunks - * @return - */ - ElectromagneticResult mergeChunks(String identifier, String fileName, Integer totalChunks); - - - /** - * 检查分片是否存在 - * - * @param fileChunkDTO - * @return - */ - ElectromagneticResult checkChunkExist(FileChunkDTO fileChunkDTO); -} diff --git a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/CategoryServiceImpl.java b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/CategoryServiceImpl.java deleted file mode 100644 index a4ff55a..0000000 --- a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/CategoryServiceImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.electromagnetic.industry.software.manage.service.serviceimpl; - -import com.electromagnetic.industry.software.common.resp.ElectromagneticResult; -import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil; -import com.electromagnetic.industry.software.manage.mapper.CategoryMapper; -import com.electromagnetic.industry.software.manage.pojo.models.Category; -import com.electromagnetic.industry.software.manage.service.CategoryService; -import org.springframework.stereotype.Service; -import org.springframework.util.StringUtils; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.stream.Collectors; - -@Service -public class CategoryServiceImpl implements CategoryService { - - @Resource - private CategoryMapper categoryMapper; - - @Override - public ElectromagneticResult getAllCategories() { - List categories = categoryMapper.selectAllCategories(); - List returnList = new ArrayList<>(); - List tempList = categories.stream().map(Category::getCategoryId).collect(Collectors.toList()); - for (Category category : categories) { - if (!tempList.contains(category.getParentId())) { - recursionFn(categories, category); - returnList.add(category); - } - } - if (returnList.isEmpty()) { - returnList = categories; - } - return ElectromagneticResultUtil.success(returnList); - } - - /** - * 递归列表 - * - * @param list - * @param category - */ - private void recursionFn(List list, Category category) { - List childList = getChildList(list, category); - category.setChildren(childList); - for (Category child : childList) { - if (hasChild(list, child)) { - recursionFn(list, child); - } - } - } - - /** - * 得到子节点列表 - * - * @param list - * @param category - * @return - */ - private List getChildList(List list, Category category) { - List childList = new ArrayList<>(); - Iterator it = list.iterator(); - while (it.hasNext()) { - Category child = it.next(); - if (!StringUtils.isEmpty(child.getParentId()) && child.getParentId().equals(category.getCategoryId())) { - childList.add(child); - } - } - return childList; - } - - /** - * 判断是否有子节点 - * - * @param list - * @param category - * @return - */ - private boolean hasChild(List list, Category category) { - return !getChildList(list, category).isEmpty(); - } -} diff --git a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EDDataServiceImpl.java b/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EDDataServiceImpl.java deleted file mode 100644 index a44b361..0000000 --- a/electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EDDataServiceImpl.java +++ /dev/null @@ -1,899 +0,0 @@ -package com.electromagnetic.industry.software.manage.service.serviceimpl; - -import cn.hutool.core.codec.Base64; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.util.StrUtil; -import cn.hutool.core.util.ZipUtil; -import cn.hutool.crypto.SecureUtil; -import cn.hutool.crypto.symmetric.AES; -import cn.hutool.json.JSONArray; -import cn.hutool.json.JSONUtil; -import com.electromagnetic.industry.software.common.cons.ElectromagneticConstants; -import com.electromagnetic.industry.software.common.resp.ElectromagneticResult; -import com.electromagnetic.industry.software.common.util.EleCommonUtil; -import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil; -import com.electromagnetic.industry.software.common.util.IdWorker; -import com.electromagnetic.industry.software.common.util.UserThreadLocal; -import com.electromagnetic.industry.software.manage.mapper.CategoryMapper; -import com.electromagnetic.industry.software.manage.mapper.EDDataMapper; -import com.electromagnetic.industry.software.manage.mapper.EDDataMappers; -import com.electromagnetic.industry.software.manage.pojo.models.Category; -import com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo; -import com.electromagnetic.industry.software.manage.pojo.other.EDDataPage; -import com.electromagnetic.industry.software.manage.pojo.other.EDDataParams; -import com.electromagnetic.industry.software.manage.pojo.req.EDDataRequest; -import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO; -import com.electromagnetic.industry.software.manage.pojo.req.FileChunkResultDTO; -import com.electromagnetic.industry.software.manage.pojo.resp.EDDataPageResponse; -import com.electromagnetic.industry.software.manage.service.EDDataService; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; -import lombok.extern.slf4j.Slf4j; -import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.InputStreamResource; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.stream.Collectors; - -@Service -@Slf4j -public class EDDataServiceImpl implements EDDataService { - - private static final String UPLOAD_FILE_CHUNK_SUFFIX = ".part"; - // 文件夹名称分隔符 - private static final String FOLDER_NAME_SEPARATOR = "_"; - @Resource - private EDDataMapper edDataMapper; - @Resource - private CategoryMapper categoryMapper; - // @Value("${data.windows.path}") - private String uploadFilePath; - // @Value("${data.file.storage.dir}") - private String fileStorageDir; - // @Value("${data.import.cache.dir}") - private String importCacheDir; - // @Value("${file.encode.passwd}") - private String encodePasswd; - // @Value("${data.type.folder}") - private String dataTypeFolder; - // @Value("${data.windows.path}") - private String windowsDir; - // @Value("${data.file.cache.dir}") - private String fileCacheDir; - // @Value("${data.upload.cache.dir}") - private String uploadCacheDir; - // @Value("${data.export.cache.dir}") - private String exportCacheDir; - // @Value("${data.type.file}") - private String dataTypeFile; - - @Override - public ElectromagneticResult createFolder(EDDataRequest request) { - - EDDataInfo edDataInfo = EDDataMappers.INSTANCE.getEDDataInfo(request); - - edDataInfo.setCreator(UserThreadLocal.getUserId()); - edDataInfo.setCreatorName(UserThreadLocal.getUsername()); - edDataInfo.setModifier(UserThreadLocal.getUserId()); - edDataInfo.setModifierName(UserThreadLocal.getUsername()); - edDataInfo.setCategoryId(request.getParentId()); - edDataInfo.setDataName(request.getName()); - edDataInfo.setNote(request.getNote()); - edDataInfo.setGmtBatchUpload(new Date()); - - edDataInfo.setDataId(IdWorker.getSnowFlakeIdString()); - edDataInfo.setDataNo(edDataInfo.getDataId()); - edDataInfo.setDataType(dataTypeFolder); - edDataInfo.setVersion("1.0.0"); - edDataInfo.setDataStatus("publish"); - edDataInfo.setSaveStatus("success"); - - try { - return ElectromagneticResultUtil.success(createDataInfo(edDataInfo)); - } catch (Exception e) { - log.error("创建文件夹失败。。。", e); - return ElectromagneticResultUtil.fail("500", e.getMessage()); - } - - } - - public Boolean createDataInfo(EDDataInfo edDataInfo) throws Exception { - // 获取上级目录的名称 - String fileName = edDataInfo.getDataName(); - Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), ElectromagneticConstants.NAME_VALID_MSG); - - Category categoryParent = new Category(); - categoryParent.setCategoryId(edDataInfo.getCategoryId()); - List categoryParentList = categoryMapper.selectCategories(categoryParent); - - if (categoryParentList.size() < 1) { - throw new Exception("上级文件夹不存在"); - } else { - // 获取新文件夹路径信息 - categoryParent = categoryParentList.get(0); - - String dataStoragePath = getDataStoragePath(); - String folderParent = categoryParent.getCategoryId() + FOLDER_NAME_SEPARATOR + categoryParent.getCategoryName(); - String folderNew = dataStoragePath + File.separator + folderParent + File.separator + edDataInfo.getDataName(); - - // 判断文件夹名称是否存在 - EDDataParams folderParames = new EDDataParams(); - folderParames.setParentId(edDataInfo.getCategoryId()); - List childFileInfoList = edDataMapper.getDataInfoList(folderParames); - for (EDDataInfo fileInfo : childFileInfoList) { - if (fileInfo.getDataName().equals(edDataInfo.getDataName())) { - throw new Exception("文件夹已存在"); - } - } - - // 将文件夹数据写到数据库中 - if (edDataMapper.createDataInfo(edDataInfo)) { - if (!FileUtil.exist(folderNew)) { - FileUtil.mkdir(folderNew); - } - } - } - - return Boolean.TRUE; - } - - /** - * 获取数据存储目录 - * - * @return - */ - public String getDataStoragePath() { - String osName = System.getProperty("os.name").toLowerCase(); - return osName.startsWith("win") ? windowsDir + fileStorageDir : fileStorageDir; - } - - @Override - public ElectromagneticResult getDataInfoList(EDDataRequest request) { - EDDataParams parames = EDDataMappers.INSTANCE.getEDDataParames(request); - //获取中支指标配置列表 - PageHelper.startPage(parames.getPageIndex(), parames.getPageSize()); - List edDataInfoList = edDataMapper.getDataInfoList(parames); - PageInfo pageInfo = new PageInfo<>(edDataInfoList); - EDDataPage edDataPage = new EDDataPage(); - edDataPage.setEdDataInfo(pageInfo); - //模型转换 - EDDataPageResponse edDataPageResponse = EDDataMappers.INSTANCE.getEDDataInfoToModel(edDataPage); - return ElectromagneticResultUtil.success(edDataPageResponse); - } - - @Override - public ElectromagneticResult updateFileInfo(EDDataRequest request) { - - try { - EDDataParams parames = EDDataMappers.INSTANCE.getEDDataParames(request); - parames.setUserId(UserThreadLocal.getUserId()); - parames.setUserName(UserThreadLocal.getUsername()); - return ElectromagneticResultUtil.success(updateFileInfo(parames)); - } catch (Exception e) { - log.error("文件信息更新失败。。。", e); - return ElectromagneticResultUtil.fail("500", e.getMessage()); - } - } - - public Boolean updateFileInfo(EDDataParams parames) throws Exception { - - String dataStoragePath = getDataStoragePath(); - if (!FileUtil.exist(dataStoragePath)) { - throw new Exception("数据存储文件夹不存在"); - } - - EDDataParams paramesFind = new EDDataParams(); - paramesFind.setDataId(parames.getDataId()); - List edDataInfoList = edDataMapper.getDataInfoList(paramesFind); - if (edDataInfoList.size() < 1) { - throw new Exception("文件信息不存在"); - } - - EDDataInfo edDataInfo = edDataInfoList.get(0); - String filePathOfFolder = getFilePathOfFolder(edDataInfo.getCategoryId()); - String fileType = StrUtil.isEmpty(edDataInfo.getFileType()) ? "" : "." + edDataInfo.getFileType(); - String fileStorageFullPath = dataStoragePath + filePathOfFolder + File.separator + edDataInfo.getDataName() + fileType; - - if (!FileUtil.exist(fileStorageFullPath)) { - throw new Exception("文件不存在"); - } - - String fileNameNew = parames.getName() + fileType; - if (fileNameNew != null && fileNameNew != "" && !fileNameNew.equals(edDataInfo.getDataName())) { - FileUtil.rename(Paths.get(fileStorageFullPath), fileNameNew, true); - } - - // 修改文件夹 - edDataMapper.updateFileInfo(parames); - // 修改文件夹中的文件 - if (edDataInfo.getDataType().equals(dataTypeFolder) && parames.getEffectFlag() != null) { - EDDataParams paramesChild = new EDDataParams(); - paramesChild.setParentId(edDataInfo.getDataId()); - paramesChild.setEffectFlag(parames.getEffectFlag()); - edDataMapper.updateFileInfo(paramesChild); - } - - return Boolean.TRUE; - } - - public String getFilePathOfFolder(String categoryId) { - String filePathOfFolder = ""; //文件存放在文件夹的路径 - - String categoryIdHighest = categoryId; //最高级的目录编码 - EDDataParams folderParames = new EDDataParams(); - folderParames.setDataId(categoryId); - List edDataInfoList = edDataMapper.getDataInfoList(folderParames); - EDDataInfo edDataInfoParent = null; - if (CollUtil.isNotEmpty(edDataInfoList)) { - categoryIdHighest = edDataInfoList.get(0).getCategoryId(); - edDataInfoParent = edDataInfoList.get(0); - } - Category categoryParent = new Category(); - categoryParent.setCategoryId(categoryIdHighest); - List categoryParentList = categoryMapper.selectCategories(categoryParent); - if (categoryParentList.size() > 0) { - categoryParent = categoryParentList.get(0); - filePathOfFolder = categoryParent.getCategoryId() + FOLDER_NAME_SEPARATOR + categoryParent.getCategoryName(); - if (edDataInfoParent != null) { - String fileType = StrUtil.isEmpty(edDataInfoParent.getFileType()) ? "" : "." + edDataInfoParent.getFileType(); - filePathOfFolder = filePathOfFolder + File.separator + edDataInfoParent.getDataName() + fileType; - } - } - - return filePathOfFolder; - } - - @Override - public ElectromagneticResult> getChildFileCount(EDDataRequest request) { - EDDataParams parames = EDDataMappers.INSTANCE.getEDDataParames(request); - Integer fileCount = getChildFileCount(parames); - Map result = new HashMap<>(); - result.put("fileCount", fileCount); - return ElectromagneticResultUtil.success(result); - } - - public Integer getChildFileCount(EDDataParams parames) { - Integer childFileCount = 0; - - List edDataInfoList = edDataMapper.getDataInfoList(parames); - parames.setDataId(null); - for (EDDataInfo edDataInfo : edDataInfoList) { - if (edDataInfo.getDataType().equals(dataTypeFolder)) { - parames.setParentId(edDataInfo.getDataId()); - childFileCount += getChildFileCount(parames); - } else if (edDataInfo.getDataType().equals(dataTypeFile) && edDataInfo.getEffectFlag().equals(1)) { - ++childFileCount; - } - } - - return childFileCount; - } - - @Override - public ElectromagneticResult uploadFile(EDDataRequest request) { - try { - EDDataParams parames = EDDataMappers.INSTANCE.getEDDataParames(request); - parames.setUserId(UserThreadLocal.getUserId()); - parames.setUserName(UserThreadLocal.getUsername()); - return ElectromagneticResultUtil.success(upload(parames)); - } catch (Exception e) { - log.error("上传文件失败。。。", e); - return ElectromagneticResultUtil.fail("500", e.getMessage()); - } - } - - private Boolean upload(EDDataParams parames) throws Exception { - // 获取目录编码ID - String categoryId = parames.getParentId(); - - // 获取要上传的文件 - MultipartFile fileInput = parames.getFileData(); - - // 检查文件是否为空 - if (fileInput == null || fileInput.isEmpty()) { - throw new Exception("上传的文件为空"); - } - - // 获取文件名 - String fileFullName = fileInput.getOriginalFilename(); - // 获取文件类型 - String fileType = EleCommonUtil.getFileType(fileFullName); - // 获取文件名称 - String fileName = EleCommonUtil.getFileName(fileFullName); - Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), ElectromagneticConstants.NAME_VALID_MSG); - // 判断文件名称是否存在 - EDDataParams folderParames = new EDDataParams(); - folderParames.setParentId(categoryId); - List childFileInfoList = edDataMapper.getDataInfoList(folderParames); - for (EDDataInfo fileInfo : childFileInfoList) { - if (fileInfo.getDataName().equals(fileFullName)) { - throw new Exception("上传的文件已存在"); - } - } - - String dataStoragePath = getDataStoragePath(); - if (!FileUtil.exist(dataStoragePath)) { - FileUtil.mkdir(dataStoragePath); - } - - //获取文件存放在文件夹的路径 - String filePathOfFolder = getFilePathOfFolder(categoryId); - - // 将文件数据信息写到数据库 - EDDataInfo edDataInfo = new EDDataInfo(); - - - // 创建新文件数据 - edDataInfo.setCreator(parames.getUserId()); - edDataInfo.setCreatorName(parames.getUserName()); - edDataInfo.setModifier(parames.getUserId()); - edDataInfo.setModifierName(parames.getUserName()); - edDataInfo.setCategoryId(parames.getParentId()); - edDataInfo.setDataName(fileName); - edDataInfo.setNote(parames.getNote()); - edDataInfo.setFileType(fileType); - edDataInfo.setGmtBatchUpload(parames.getGmtBatchUpload()); - - edDataInfo.setDataId(IdWorker.getSnowFlakeIdString()); - edDataInfo.setDataNo(edDataInfo.getDataId()); - edDataInfo.setDataType(dataTypeFile); - edDataInfo.setVersion("1.0.0"); - edDataInfo.setDataStatus("publish"); - edDataInfo.setSaveStatus("saving"); - - boolean isSuccess = edDataMapper.createDataInfo(edDataInfo); - log.info("文件开始保存."); - - // 保存文件数据 到 文件存储目录 - - - // 文件保存目录路径 - String fileSavePath = dataStoragePath + File.separator + filePathOfFolder; - String newFileName = edDataInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileFullName; - if (!FileUtil.exist(fileSavePath)) { - FileUtil.mkdir(fileSavePath); - } - - String dataCachePath = getDataCachePath(); - String uploadFileCachePath = dataCachePath + uploadCacheDir + FOLDER_NAME_SEPARATOR + getTimeStampString(); - if (!FileUtil.exist(uploadFileCachePath)) { - FileUtil.mkdir(uploadFileCachePath); - } - - String fileCacheFullPath = uploadFileCachePath + File.separator + newFileName; - String fileSaveFullPath = fileSavePath + File.separator + fileFullName; - log.info("文件缓存路径为: " + fileCacheFullPath); - - - // 这里可以添加将文件保存到本地磁盘或其他存储介质的逻辑 - File saveFile = new File(fileCacheFullPath); - - // 将文件保存到硬盘 - EDDataParams fileParames = new EDDataParams(); - try { - fileInput.transferTo(saveFile); - - - fileParames.setDataId(edDataInfo.getDataId()); - if (fileInput.getSize() == saveFile.length()) { - Path source = Paths.get(fileCacheFullPath); - Path target = Paths.get(fileSaveFullPath); - Files.move(source, target); - fileParames.setSaveStatus("success"); - } else { - saveFile.delete(); - fileParames.setSaveStatus("failure"); - } - - isSuccess = edDataMapper.updateFileInfo(fileParames); - - FileUtil.del(uploadFileCachePath);//删除临时目录 - - log.info("文件保存成功: " + fileSaveFullPath); - - return Boolean.TRUE; - - } catch (IOException e) { - fileParames.setSaveStatus("failure"); - edDataMapper.updateFileInfo(fileParames); - log.info("文件保存失败: " + fileSaveFullPath); - throw new Exception(e.getMessage()); - } - } - - /** - * 获取时间戳字符串 - * - * @return - */ - public String getTimeStampString() { - long timestamp = System.currentTimeMillis(); - return String.valueOf(timestamp); - } - - /** - * 获取数据缓存目录 - * - * @return - */ - public String getDataCachePath() { - String osName = System.getProperty("os.name").toLowerCase(); - return osName.startsWith("win") ? windowsDir + fileCacheDir : fileCacheDir; - } - - @Override - public ResponseEntity download(String dataId, HttpServletResponse response) throws IOException { - // 获取文件存储的文件夹路径 - String osName = System.getProperty("os.name").toLowerCase(); - String storageFilePath = osName.startsWith("win") ? uploadFilePath + fileStorageDir : fileStorageDir; - EDDataParams parames = new EDDataParams(); - parames.setDataId(dataId); - List edDataInfos = edDataMapper.getDataInfoList(parames); - Assert.isTrue(CollUtil.isNotEmpty(edDataInfos), "没有找到该下载文件"); - EDDataInfo edDataInfo = edDataInfos.get(0); - String filePathOfFolder = getFilePathOfFolder1(edDataInfo.getCategoryId()); - String fileType = StrUtil.isEmpty(edDataInfo.getFileType()) ? "" : "." + edDataInfo.getFileType(); - String filePath = storageFilePath + "/" + filePathOfFolder + "/" + edDataInfo.getDataName() + fileType; - - Assert.isTrue(FileUtil.exist(filePath), "下载文件不存在。"); - FileSystemResource fileSystemResource = new FileSystemResource(filePath); - HttpHeaders headers = new HttpHeaders(); - headers.add("Cache-Control", "no-cache, no-store, must-revalidate"); - headers.add("Pragma", "no-cache"); - headers.add("Expires", "0"); - String fileName = Base64.encode(fileSystemResource.getFilename()); - response.setHeader("content-disposition", "attachment;filename=" + fileName); - // 构建响应实体(可以返回 edDataInfoList = edDataMapper.getDataInfoList(folderParames); - EDDataInfo edDataInfoParent = null; - if (CollUtil.isNotEmpty(edDataInfoList)) { - categoryIdHighest = edDataInfoList.get(0).getCategoryId(); - edDataInfoParent = edDataInfoList.get(0); - } - Category categoryParent = new Category(); - categoryParent.setCategoryId(categoryIdHighest); - List categoryParentList = categoryMapper.selectCategories(categoryParent); - if (categoryParentList.size() > 0) { - categoryParent = categoryParentList.get(0); - filePathOfFolder = categoryParent.getCategoryId() + FOLDER_NAME_SEPARATOR + categoryParent.getCategoryName(); - if (edDataInfoParent != null) { - String fileType = StrUtil.isEmpty(edDataInfoParent.getFileType()) ? "" : "." + edDataInfoParent.getFileType(); - filePathOfFolder = filePathOfFolder + File.separator + edDataInfoParent.getDataName() + fileType; - } - } - return filePathOfFolder; - } - - @Override - public ResponseEntity batchExport(String dataIdArr, HttpServletResponse response) throws IOException { - //1、根据用户选择层级树编码查出所有文件和文件夹list - //2、循环list将每个文件复制到新建目录并进行重命名,命名规则:目录树编码+,+文件夹编码(有则填写无则为空)+,+文件编码 - //3、打包新建为zip,并根据生产下载地址(域名+文件路径+文件) - //4、返回前端下载的地址 - - // **********在导出的过程中可能会出现有用户上传文件的情况 - - Map result = new HashMap<>(); - List dataIdList = Arrays.asList(dataIdArr.split(",")); - if (!dataIdList.isEmpty()) { - String filePath = exportData(dataIdList); - - Assert.isTrue(FileUtil.exist(filePath), "下载文件不存在。"); - File file = new File(filePath); - FileSystemResource fileSystemResource = new FileSystemResource(file); - - HttpHeaders headers = new HttpHeaders(); - headers.add("Cache-Control", "no-cache, no-store, must-revalidate"); - String fileName = Base64.encode(fileSystemResource.getFilename()); - headers.add("Pragma", "no-cache"); - headers.add("Expires", "0"); - response.setHeader("content-disposition", "attachment;filename=" + fileName); - - // 构建响应实体(可以返回 dataIdList) { - String zipPathFileName = ""; - String exportDataCachePath = ""; - String enCodeZipPathFileName = ""; - - try { - // 获取文件夹编码ID数组 - List categoryIdInputList = dataIdList; - - String dataCachePath = getDataCachePath(); - - // 导出数据时的临时存放目录 - exportDataCachePath = dataCachePath + exportCacheDir + FOLDER_NAME_SEPARATOR + getTimeStampString(); - if (!FileUtil.exist(exportDataCachePath)) { - FileUtil.mkdir(exportDataCachePath); - } - - List categoryAllList = categoryMapper.selectAllCategories(); - Map categoryAllMap = new HashMap(); //所有目录数组map - for (Category category : categoryAllList) { - categoryAllMap.put(category.getCategoryId(), category); - } - - EDDataParams folderParames = new EDDataParams(); - List fileAllList = edDataMapper.getDataInfoList(folderParames); //获取所有文件信息数据 - Map fileAllMap = new HashMap(); //所有文件数组map - for (EDDataInfo fileFinfo : fileAllList) { - fileAllMap.put(fileFinfo.getDataId(), fileFinfo); - } - - List categoryInputList = new ArrayList(); //客户端输入的目录数组 - Map categoryInputMap = new HashMap(); //客户端输入的目录数组map - for (String categoryId : categoryIdInputList) { - Category category = categoryAllMap.get(categoryId); - if (category != null) { - categoryInputList.add(category); - categoryInputMap.put(categoryId, category); - } - } - - - // 将List转换为JSON字符串 - String jsonStringCategory = JSONUtil.toJsonStr(categoryInputList); - String categoryListFileFullPath = exportDataCachePath + "/categoryList.json"; - FileUtil.writeString(jsonStringCategory, categoryListFileFullPath, "utf-8"); - log.info("目录树数据已成功导出为JSON文件。" + categoryListFileFullPath); - - - // 导出文件信息数据和文件数据 - - List fileExportList = new ArrayList(); //需要导出的文件信息数据数组 - Map fileExportMap = new HashMap(); //需要导出的文件信息数据数组map - for (EDDataInfo fileFinfo : fileAllList) { - if (categoryInputMap.get(fileFinfo.getCategoryId()) != null) { - fileExportList.add(fileFinfo); - fileExportMap.put(fileFinfo.getDataId(), fileFinfo); - } - } - // 找出子文件夹下的文件 - for (EDDataInfo fileFinfo : fileAllList) { - if (fileExportMap.get(fileFinfo.getCategoryId()) != null) { - fileExportList.add(fileFinfo); - } - } - - // 将文件信息数据导出为json文件 - String jsonStringFile = JSONUtil.toJsonStr(fileExportList); - String fileListFileFullPath = exportDataCachePath + "/fileInfoList.json"; - FileUtil.writeString(jsonStringFile, fileListFileFullPath, "utf-8"); - log.info("文件数据已成功导出为JSON文件。" + fileListFileFullPath); - - - // 将文件 复制到 数据导出的缓存目录中 - String dataStoragePath = getDataStoragePath(); - String needExportfolder = ""; - for (Category category : categoryInputList) { - needExportfolder = dataStoragePath + category.getCategoryId() + FOLDER_NAME_SEPARATOR + category.getCategoryName(); - if (FileUtil.exist(needExportfolder)) { - Path source = Paths.get(needExportfolder); - Path target = Paths.get(exportDataCachePath); - FileUtil.copy(source, target); // StandardCopyOption.REPLACE_EXISTING - } - } - - log.info("文件数据已成功复制到目标目录。"); - - // 将目录树数据 和 文件夹及文件夹内数据 进行压缩打包 - Date date = new Date(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HHmmss"); - String dateString = sdf.format(date); - - zipPathFileName = dataCachePath + "/exportData_" + dateString; - enCodeZipPathFileName = dataCachePath + "/exportData_" + dateString + ElectromagneticConstants.EXPORT_FILE_SUFFIX; - - ZipUtil.zip(exportDataCachePath, zipPathFileName); - - AES aes = SecureUtil.aes(encodePasswd.getBytes()); // aesKey是加密密钥 - try ( - InputStream inputStream = new FileInputStream(zipPathFileName); - OutputStream outputStream = new FileOutputStream(enCodeZipPathFileName); - ) { - aes.encrypt(inputStream, outputStream, true); - } catch (Exception e) { - log.error("文件加密错误..", e); - } - - log.info("目录树数据+文件数据已成功复制到目标目录。" + enCodeZipPathFileName); - } catch (Exception e) { - log.error("导出数据异常..", e); - } finally { - // 删除 导出数据的 缓存目录 - FileUtil.del(exportDataCachePath); - } - - return enCodeZipPathFileName; - } - - - @Override - public ElectromagneticResult batchImport(FileChunkDTO fileChunkDTO) { - String identifier = fileChunkDTO.getIdentifier(); - String fileName = fileChunkDTO.getFileName(); - - String dataCachePath = getDataCachePath(); - String importDataCachePath = dataCachePath + importCacheDir; - - // 首先检查文件是否存在,如果存在则不允许重复上传。 - String destZipPath = importDataCachePath + identifier + File.separator + fileName; - boolean existFile = FileUtil.exist(new File(destZipPath)); - if (existFile) { - return ElectromagneticResultUtil.fail("-1", "文件已经存在,请勿重复上传。"); - } - - // 检查该分片有没被上传过 - String destChunkPath = importDataCachePath + identifier + File.separator + fileChunkDTO.getChunkNumber() + UPLOAD_FILE_CHUNK_SUFFIX; - boolean existChunk = FileUtil.exist(new File(destChunkPath)); - if (existChunk) { - return ElectromagneticResultUtil.success(true); - } - - File dir = new File(importDataCachePath + identifier + File.separator); - if (!dir.exists()) { - dir.mkdir(); - } - - try ( - InputStream inputStream = fileChunkDTO.getFile().getInputStream(); - FileOutputStream fileOutputStream = new FileOutputStream(destChunkPath); - ) { - IoUtil.copy(inputStream, fileOutputStream); - } catch (IOException ioException) { - log.error("上传文件错误...", ioException); - } - return ElectromagneticResultUtil.success(fileChunkDTO.getIdentifier()); - } - - @Override - public ElectromagneticResult> getUploadedChunkNums(String identifier) { - return ElectromagneticResultUtil.success(getUploadedChunks(identifier)); - } - - private List getUploadedChunks(String identifier) { - String dataCachePath = getDataCachePath(); - String importDataCachePath = dataCachePath + importCacheDir; - String destPath = importDataCachePath + identifier; - if (!FileUtil.exist(new File(destPath))) { - return new ArrayList<>(); - } - - return FileUtil.listFileNames(destPath) - .stream() - .filter(e -> !e.endsWith(ElectromagneticConstants.EXPORT_FILE_SUFFIX)) - .map(e -> e.replace(UPLOAD_FILE_CHUNK_SUFFIX, "")) - .map(Integer::parseInt) - .collect(Collectors.toList()); - } - - @Override - public ElectromagneticResult mergeChunks(String identifier, String fileName, Integer totalChunks) { - String dataCachePath = getDataCachePath(); - String importDataCachePath = dataCachePath + importCacheDir; - - // 检查所有分片是否已经上传完成,分片编号从1开始 - for (int i = 1; i <= totalChunks; i++) { - String tmpPath = importDataCachePath + identifier + File.separator + i + UPLOAD_FILE_CHUNK_SUFFIX; - if (!FileUtil.exist(new File(tmpPath))) { - log.error("第{}个分片没有上传完成,请上传完成后再合并。", i); - ElectromagneticResultUtil.fail("-1", "文件尚未上传完成。"); - } - } - - // 合并分片 - String destZipPath = importDataCachePath + identifier + File.separator + fileName; - File mergedFile = new File(destZipPath); - try { - RandomAccessFile targetFile = new RandomAccessFile(mergedFile, "rw"); - byte[] buffer = new byte[1024]; - for (int i = 1; i <= totalChunks; i++) { - String tmpPath = importDataCachePath + identifier + File.separator + i + UPLOAD_FILE_CHUNK_SUFFIX; - RandomAccessFile tmp = new RandomAccessFile(new File(tmpPath), "r"); - int len; - while ((len = tmp.read(buffer)) != -1) { - targetFile.write(buffer, 0, len); - } - tmp.close(); - } - targetFile.close(); - } catch (IOException ioException) { - ElectromagneticResultUtil.fail("-1", "文件合并失败"); - } - - // 删除分片 - for (int i = 1; i <= totalChunks; i++) { - String tmpPath = importDataCachePath + identifier + File.separator + i + UPLOAD_FILE_CHUNK_SUFFIX; - FileUtil.del(tmpPath); - } - - // 检验文件的MD5值 - - // 解密文件 - String decryptFilePath = destZipPath + "_decrypted"; - AES aes = SecureUtil.aes(encodePasswd.getBytes()); // aesKey是加密密钥 - try ( - InputStream inputStream = new FileInputStream(destZipPath); - OutputStream outputStream = new FileOutputStream(decryptFilePath); - ) { - aes.decrypt(inputStream, outputStream, true); - } catch (Exception e) { - log.error("文件加密错误..", e); - } - - // 解压文件 - String unzipFileOutputPath = importDataCachePath + identifier + File.separator; - ZipUtil.unzip(decryptFilePath, unzipFileOutputPath); - - // 文件信息存入数据库 - Map> result = importData(importDataCachePath + identifier); - - // 删除 解压数据的 缓存目录 - FileUtil.del(unzipFileOutputPath); - - return ElectromagneticResultUtil.success(result); - } - - public Map> importData(String folderPath) { - // 获取所有目录树节点数据 - List categoryAllList = categoryMapper.selectAllCategories(); - Map categoryAllMap = new HashMap(); //所有目录数组map - for (Category category : categoryAllList) { - categoryAllMap.put(category.getCategoryId(), category); - } - - // 获取所有文件信息数据 - EDDataParams parames = new EDDataParams(); - List fileInfoAllList = edDataMapper.getDataInfoList(parames); - Map fileInfoAllMap = new HashMap(); //所有文件数组map - for (EDDataInfo fileInfo : fileInfoAllList) { - fileInfoAllMap.put(fileInfo.getDataId(), fileInfo); - } - - - // 读取并反序列化目录树的JSON文件数据为List;然后写入到数据库中。 - String jsonStringCategory = FileUtil.readString(folderPath + "/categoryList.json", StandardCharsets.UTF_8); - JSONArray jsonArrayCategory = JSONUtil.parseArray(jsonStringCategory); - List categoryImportList = JSONUtil.toList(jsonArrayCategory, Category.class); - if (categoryImportList == null) { - log.error("读取并反序列化JSON文件数据为List失败!"); - return null; - } - // 将目录树数据写入到数据库中 - for (Category category : categoryImportList) { - if (categoryAllMap.get(category.getCategoryId()) == null) { - categoryMapper.createCategory(category); - } - } - - // 读取并反序列化文件信息的JSON文件数据为List;然后写入到数据库中。 - String jsonStringFile = FileUtil.readString(folderPath + "/fileInfoList.json", StandardCharsets.UTF_8); - JSONArray jsonArrayFile = JSONUtil.parseArray(jsonStringFile); - List fileInfoImportList = JSONUtil.toList(jsonArrayFile, EDDataInfo.class); - if (fileInfoImportList == null) { - log.error("读取并反序列化JSON文件数据为List失败!"); - return null; - } - // 将文件信息数据写入到数据库中 - for (EDDataInfo fileInfo : fileInfoImportList) { - if (fileInfoAllMap.get(fileInfo.getDataId()) == null) { - edDataMapper.createDataInfo(fileInfo); - } - } - - // 将解压后的文件夹和文件 移动到 上传文件的存储目录中 - List importFileSuccess = new ArrayList(); - List importFileFail = new ArrayList(); - - String dataStoragePath = getDataStoragePath(); - if (!FileUtil.exist(dataStoragePath)) { - FileUtil.mkdir(dataStoragePath); - } - - String importDataCachePath = folderPath; //导入数据时 数据文件解压后的目录 - String importFileCachePath = ""; //需要导入的文件的缓存路径 - String importFileCacheFullPath = ""; //需要导入的文件的全路径 - String fileStorageFolder = ""; //文件存储的文件夹 - String fileStoragePath = ""; //文件存储的文件夹路径 - String fileStorageFullPath = ""; //文件存储的文件全路径 - - for (EDDataInfo fileInfo : fileInfoImportList) { - fileStorageFolder = getFilePathOfFolder(fileInfo.getCategoryId()); - importFileCachePath = importDataCachePath + File.separator + fileStorageFolder; - importFileCacheFullPath = importFileCachePath + File.separator + fileInfo.getDataName(); - fileStoragePath = dataStoragePath + File.separator + fileStorageFolder; - fileStorageFullPath = fileStoragePath + File.separator + fileInfo.getDataName(); - - if (fileInfoAllMap.get(fileInfo.getDataId()) == null - && !fileStorageFolder.isEmpty() - && FileUtil.exist(importFileCachePath) - && FileUtil.exist(importFileCacheFullPath) - && !FileUtil.exist(fileStorageFullPath) - ) { - if (fileInfo.getDataType().equals(dataTypeFolder)) { - if (!FileUtil.exist(fileStorageFullPath)) { - FileUtil.mkdir(fileStorageFullPath); - } - } else if (fileInfo.getDataType().equals(dataTypeFile)) { - Path source = Paths.get(importFileCacheFullPath); - Path target = Paths.get(fileStorageFullPath); - FileUtil.move(source, target, true); - } - - importFileSuccess.add(fileInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileInfo.getDataName()); - } else { - importFileFail.add(fileInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileInfo.getDataName()); - } - } - - - Map> result = new HashMap<>(); - result.put("success", importFileSuccess); - result.put("fail", importFileFail); - - return result; - } - - - @Override - public ElectromagneticResult checkChunkExist(FileChunkDTO fileChunkDTO) { - String dataCachePath = getDataCachePath(); - String importDataCachePath = dataCachePath + importCacheDir; - // 首先判断zip文件是否存在,如果不存在则表示还没有上传完成。 - String identifier = fileChunkDTO.getIdentifier(); - String fileName = fileChunkDTO.getFileName(); - String destZipPath = importDataCachePath + identifier + File.separator + fileName; - boolean existFile = FileUtil.exist(new File(destZipPath)); - - if (existFile) { - return ElectromagneticResultUtil.success(new FileChunkResultDTO(true, new HashSet<>())); - } - - List uploadedChunks = getUploadedChunks(identifier); - return ElectromagneticResultUtil.success(new FileChunkResultDTO(false, new HashSet<>(uploadedChunks))); - } -}