调通了数据库导入的部分功能
This commit is contained in:
parent
4d145eaaea
commit
ea62e1ecb7
|
|
@ -474,7 +474,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
ZipUtil.unzip(zipDirPath, tmpDir);
|
ZipUtil.unzip(zipDirPath, tmpDir);
|
||||||
update2Database(tmpDir, dataOwnCode);
|
update2Database(tmpDir, dataOwnCode);
|
||||||
fileSystemService.deleteFile(zipDirPath, destColibPath);
|
fileSystemService.deleteFile(zipDirPath, destColibPath);
|
||||||
UserThreadLocal.setSuccessInfo("", "", "导入数据库成功");
|
UserThreadLocal.setSuccessInfo("", "", "导入数据库成功,文件名称为 " + mainName);
|
||||||
return ElectromagneticResultUtil.success(true);
|
return ElectromagneticResultUtil.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -494,13 +494,13 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFileRelationInfo(String prjDirPath) {
|
private void updateFileRelationInfo(String prjDirPath) {
|
||||||
String path = prjDirPath + File.separator + ED_TAG_RELATIONS + ".json";
|
String path = prjDirPath + File.separator + ED_FILE_RELATION + ".json";
|
||||||
List<EdFileRelation> relations = JSONUtil.toList(FileUtil.readString(path, Charset.defaultCharset()), EdFileRelation.class);
|
List<EdFileRelation> relations = JSONUtil.toList(FileUtil.readString(path, Charset.defaultCharset()), EdFileRelation.class);
|
||||||
edFileRelationService.saveOrUpdateBatch(relations);
|
edFileRelationService.saveOrUpdateBatch(relations);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFileTageInfo(String prjDirPath) {
|
private void updateFileTageInfo(String prjDirPath) {
|
||||||
String path = prjDirPath + File.separator + USER_ACCESS_LOG + ".json";
|
String path = prjDirPath + File.separator + ED_TAG_RELATIONS + ".json";
|
||||||
List<FileTagRelation> relations = JSONUtil.toList(FileUtil.readString(path, Charset.defaultCharset()), FileTagRelation.class);
|
List<FileTagRelation> relations = JSONUtil.toList(FileUtil.readString(path, Charset.defaultCharset()), FileTagRelation.class);
|
||||||
fileTagRelationService.saveOrUpdateBatch(relations);
|
fileTagRelationService.saveOrUpdateBatch(relations);
|
||||||
}
|
}
|
||||||
|
|
@ -692,7 +692,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
|
|
||||||
private void update2FileSystem(Set<EdFileInfo> needMove2FileSystemFiles, String prjDirPath, int dataOwnCode) {
|
private void update2FileSystem(Set<EdFileInfo> needMove2FileSystemFiles, String prjDirPath, int dataOwnCode) {
|
||||||
List<EdFileInfo> files = needMove2FileSystemFiles.stream().filter(e -> e.getDataType().equals(EleDataTypeEnum.FILE.code)).toList();
|
List<EdFileInfo> files = needMove2FileSystemFiles.stream().filter(e -> e.getDataType().equals(EleDataTypeEnum.FILE.code)).toList();
|
||||||
List<File> files1 = FileUtil.loopFiles(new File(prjDirPath), file -> file.isDirectory() && file.getName().startsWith(EXPORT_PRJ_NAME));
|
List<File> files1 = Arrays.stream(Objects.requireNonNull(new File(prjDirPath).listFiles())).filter(e -> e.isDirectory() && e.getName().startsWith(EXPORT_PRJ_NAME)).toList();
|
||||||
String prjFilePath = files1.get(0).getAbsolutePath();
|
String prjFilePath = files1.get(0).getAbsolutePath();
|
||||||
for (EdFileInfo edFileInfo : files) {
|
for (EdFileInfo edFileInfo : files) {
|
||||||
String id = edFileInfo.getId();
|
String id = edFileInfo.getId();
|
||||||
|
|
@ -748,7 +748,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
// 导出标签相关信息
|
// 导出标签相关信息
|
||||||
exportFileTagInfo(nowTimeStr, exportFileIds, userDownloadDataDir);
|
exportFileTagInfo(nowTimeStr, exportFileIds, userDownloadDataDir);
|
||||||
// 导出操作记录相关
|
// 导出操作记录相关
|
||||||
exportLogInfo(nowTimeStr, exportFileIds, userDownloadDataDir);
|
exportLogInfo(nowTimeStr, userDownloadDataDir);
|
||||||
|
|
||||||
String prjDirPath = userDownloadDataDir + File.separator + EXPORT_PRJ_NAME + "_" + nowTimeStr;
|
String prjDirPath = userDownloadDataDir + File.separator + EXPORT_PRJ_NAME + "_" + nowTimeStr;
|
||||||
String exportZipFile = userDownloadDataDir + File.separator + EXPORT_PRJ_NAME + "_" + nowTimeStr + ".zip";
|
String exportZipFile = userDownloadDataDir + File.separator + EXPORT_PRJ_NAME + "_" + nowTimeStr + ".zip";
|
||||||
|
|
@ -772,11 +772,12 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
FileSystemResource fileSystemResource = new FileSystemResource(file);
|
FileSystemResource fileSystemResource = new FileSystemResource(file);
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
|
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||||
String fileName = Base64.encode(fileSystemResource.getFilename() + "_" + nowTimeStr);
|
String tmpFileName = fileSystemResource.getFilename() + "_" + nowTimeStr;
|
||||||
|
String fileName = Base64.encode(tmpFileName);
|
||||||
headers.add("Pragma", "no-cache");
|
headers.add("Pragma", "no-cache");
|
||||||
headers.add("Expires", "0");
|
headers.add("Expires", "0");
|
||||||
response.setHeader("content-disposition", "attachment;filename=" + fileName);
|
response.setHeader("content-disposition", "attachment;filename=" + fileName);
|
||||||
UserThreadLocal.setSuccessInfo("", "", "导出数据库成功");
|
UserThreadLocal.setSuccessInfo("", "", "导出数据库成功,文件名称为" + tmpFileName);
|
||||||
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
.ok()
|
.ok()
|
||||||
|
|
@ -786,7 +787,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
.body(new InputStreamResource(fileSystemResource.getInputStream()));
|
.body(new InputStreamResource(fileSystemResource.getInputStream()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exportLogInfo(String nowTimeStr, List<String> exportFileIds, String userDownloadDataDir) {
|
private void exportLogInfo(String nowTimeStr, String userDownloadDataDir) {
|
||||||
List<UserAccessLog> userAccessLogs = userAccessLogService.getBaseMapper().selectList(null);
|
List<UserAccessLog> userAccessLogs = userAccessLogService.getBaseMapper().selectList(null);
|
||||||
String json = JSONUtil.toJsonStr(userAccessLogs);
|
String json = JSONUtil.toJsonStr(userAccessLogs);
|
||||||
String path = userDownloadDataDir + File.separator + EXPORT_PRJ_NAME + "_" + nowTimeStr + File.separator + USER_ACCESS_LOG + ".json";
|
String path = userDownloadDataDir + File.separator + EXPORT_PRJ_NAME + "_" + nowTimeStr + File.separator + USER_ACCESS_LOG + ".json";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue