解决导出的问题
This commit is contained in:
parent
68724883a7
commit
b911212ef2
|
|
@ -7,6 +7,7 @@ import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
|||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.CreateFolderDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.FileInfoQueryDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.UpdateFileInfoDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.EdFileFavoriteService;
|
||||
|
|
@ -18,6 +19,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/user/file")
|
||||
|
|
@ -66,6 +68,32 @@ public class UserEdFileInfoController {
|
|||
return edFileInfoService.download(id, response, DataOwnEnum.USER_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "导出数据库", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping("batchExport")
|
||||
public ResponseEntity<InputStreamResource> batchExport(@RequestParam String fileIds, HttpServletResponse response) throws IOException {
|
||||
return edFileInfoService.batchExport(fileIds, response, DataOwnEnum.USER_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "批量上传数据库", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping(value = "/mergeChunks", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> mergeChunks(@RequestParam String identifier,
|
||||
@RequestParam String fileName,
|
||||
@RequestParam Integer totalChunks) {
|
||||
return edFileInfoService.mergeChunks(identifier, fileName, totalChunks, DataOwnEnum.USER_FILE.code);
|
||||
}
|
||||
|
||||
@UserOperation(value = "批量上传数据库", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping(value = "/batchImport", method = RequestMethod.POST)
|
||||
public ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO) {
|
||||
return edFileInfoService.batchImport(fileChunkDTO);
|
||||
}
|
||||
|
||||
@UserOperation(value = "批量上传数据库")
|
||||
@RequestMapping(value = "/batchImport", method = RequestMethod.GET)
|
||||
public ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO) {
|
||||
return edFileInfoService.checkChunkExist(fileChunkDTO);
|
||||
}
|
||||
|
||||
@UserOperation(value = "更新文件信息", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping("updateFileInfo")
|
||||
public ElectromagneticResult<?> updateFileInfo(@RequestBody UpdateFileInfoDTO updateFileInfoDTO) {
|
||||
|
|
|
|||
|
|
@ -638,8 +638,10 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
public ResponseEntity<InputStreamResource> batchExport(String dataIdArr, HttpServletResponse response, int dataOwnCode) throws IOException {
|
||||
String userDownloadDataDir = elePropertyConfig.getDownloadDataDir() + File.separator + UserThreadLocal.getUserId();
|
||||
String[] ids = dataIdArr.split(",");
|
||||
if (dataOwnCode == DataOwnEnum.COMMON.code) {
|
||||
Map<String, Boolean> map = permissionService.filterExportIds(ids);
|
||||
Assert.isTrue(!map.containsValue(Boolean.FALSE), "有未授权的层级目录,禁止导出");
|
||||
}
|
||||
Map<String, EdFileInfo> maps = new HashMap<>();
|
||||
for (String id : ids) {
|
||||
Map<String, EdFileInfo> edFileInfos = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
|
|
@ -651,7 +653,8 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
String prjId = resFiles.get(0).getFilePath().split(MYSQL_FILE_PATH_SPLIT)[0];
|
||||
List<EdFileInfo> prjFolders = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.likeRight(EdFileInfo::getFilePath, prjId + MYSQL_FILE_PATH_SPLIT)
|
||||
.eq(EdFileInfo::getDataOwn, dataOwnCode)
|
||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
||||
.eq(EdFileInfo::getDataOwn, dataOwnCode == DataOwnEnum.COMMON.code ? DataOwnEnum.SYS_PRJ.code : DataOwnEnum.USER_PRJ.code)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||
EdFileInfo prjFileInfo = this.baseMapper.selectById(prjId);
|
||||
Map<String, EdFileInfo> prjFoldersMap = prjFolders.stream().collect(Collectors.toMap(EdFileInfo::getId, e -> e));
|
||||
|
|
@ -668,7 +671,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
fileSystemService.createDirectory(destFolderPath);
|
||||
}
|
||||
for (EdFileInfo edFileInfo : files) {
|
||||
String filePath = commonService.getFileSysPath(edFileInfo.getFilePath(), dataOwnCode); // file
|
||||
String filePath = commonService.getFileSysPath(edFileInfo.getFilePath(), dataOwnCode == DataOwnEnum.COMMON.code ? DataOwnEnum.SYS_PRJ.code : DataOwnEnum.USER_PRJ.code); // file
|
||||
String destPath = userDownloadDataDir + File.separator + prjName + File.separator + commonService.getDbPath(edFileInfo.getFilePath());
|
||||
fileSystemService.copyFile(filePath, destPath);
|
||||
}
|
||||
|
|
@ -783,7 +786,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
||||
.setDataOwn(dataOwnCode);
|
||||
this.saveOrUpdate(newEdFileInfo);
|
||||
String fileDestPath = commonService.getFileSysPath(newEdFileInfo.getFilePath(), dataOwnCode);
|
||||
String fileDestPath = commonService.getFileSysPath(newEdFileInfo.getFilePath(), dataOwnCode == DataOwnEnum.COMMON.code ? DataOwnEnum.SYS_PRJ.code : DataOwnEnum.USER_PRJ.code);
|
||||
FileUtil.writeFromStream(file.getInputStream(), fileDestPath);
|
||||
EleCommonUtil.encryptFile(fileDestPath, SecureUtil.aes(FILE_SEC_PASSWD.getBytes()));
|
||||
finalEdFileInfo = newEdFileInfo;
|
||||
|
|
|
|||
Loading…
Reference in New Issue