提交代码删除任务的时候删除下面的所有节点 以及自动备份异步
This commit is contained in:
parent
03ceb1d226
commit
6a88a1a252
@ -21,7 +21,7 @@ public class TaskStatusHolder {
|
||||
|
||||
// 标记任务结束
|
||||
public void finishTask(String key) {
|
||||
taskStatusMap.put(key, "COMPLETED");
|
||||
taskStatusMap.remove(key);
|
||||
}
|
||||
|
||||
// 获取任务状态
|
||||
|
@ -307,7 +307,7 @@ public class TsFilesController {
|
||||
@Log(module = "实验数据管理", value = "对比本地和minio的文件差异!")
|
||||
@PostMapping("/compareMd5")
|
||||
@ApiOperation("对比本地和minio的文件差异")
|
||||
public ResponseResult compareMd5(String id, String nodeId, String taskId,Page<TsFiles> page) {
|
||||
public ResponseResult compareMd5(String id, String nodeId, String taskId, Page<TsFiles> page) {
|
||||
try {
|
||||
List<String> dataset = new ArrayList<>();
|
||||
if (StrUtil.isNotEmpty(id)) {
|
||||
@ -334,7 +334,7 @@ public class TsFilesController {
|
||||
@Log(module = "实验数据管理", value = "对比本地有minio没有的文件差异!")
|
||||
@PostMapping("/compareLocal")
|
||||
@ApiOperation("对比本地有minio没有的文件差异")
|
||||
public ResponseResult compareLocal(String id, String nodeId, String taskId,Page<TsFiles> page) {
|
||||
public ResponseResult compareLocal(String id, String nodeId, String taskId, Page<TsFiles> page) {
|
||||
try {
|
||||
List<String> dataset = new ArrayList<>();
|
||||
if (StrUtil.isNotEmpty(id)) {
|
||||
@ -345,7 +345,7 @@ public class TsFilesController {
|
||||
|
||||
Page<TsFiles> tsfilesPage = tsFilesService.compareLocal(dataset, nodeId, taskId, page);
|
||||
|
||||
// List<TsFilesDTO> dtos = tsFilesService.compareLocal(dataset, nodeId, taskId);
|
||||
// List<TsFilesDTO> dtos = tsFilesService.compareLocal(dataset, nodeId, taskId);
|
||||
// DualTreeResponse response = tsFilesService.compareLocal(dataset, nodeId, taskId);
|
||||
return ResponseResult.successData(tsfilesPage);
|
||||
} catch (Exception e) {
|
||||
@ -363,7 +363,7 @@ public class TsFilesController {
|
||||
@Log(module = "实验数据管理", value = "对比本地没有minio有的文件差异!")
|
||||
@PostMapping("/compareMinio")
|
||||
@ApiOperation("对比本地没有minio有的文件差异")
|
||||
public ResponseResult compareMinio(String id, String nodeId, String taskId,Page<TsFiles> page) {
|
||||
public ResponseResult compareMinio(String id, String nodeId, String taskId, Page<TsFiles> page) {
|
||||
try {
|
||||
List<String> dataset = new ArrayList<>();
|
||||
if (StrUtil.isNotEmpty(id)) {
|
||||
@ -492,12 +492,6 @@ public class TsFilesController {
|
||||
} else {
|
||||
return ResponseResult.success("任务已由其他请求启动");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// return ResponseResult.success(tsFilesService.automaticFileBackup(taskId, nodeId));
|
||||
}
|
||||
|
||||
@ -529,6 +523,19 @@ public class TsFilesController {
|
||||
|
||||
}
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 停止获取轨迹数据
|
||||
* 参数说明 token SSE连接的token
|
||||
* 返回值说明: com.yfd.platform.config.ResponseResult
|
||||
***********************************/
|
||||
@Log(module = "实验数据管理", value = "停止获取轨迹数据!")
|
||||
@PostMapping("/stopSimpleNavi")
|
||||
@ApiOperation("停止获取轨迹数据")
|
||||
public ResponseResult stopSimpleNavi(String token) {
|
||||
tsFilesService.stopSimpleNavi(token);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 查询文件内容接口
|
||||
* 参数说明 id 文件的ID
|
||||
|
@ -204,7 +204,6 @@ public interface ITsFilesService extends IService<TsFiles> {
|
||||
* 参数说明 id 文件id
|
||||
* 返回值说明: com.yfd.platform.config.ResponseResult 返回成功或者失败
|
||||
***********************************/
|
||||
// DualTreeResponse compareLocal(List<String> dataset, String nodeId, String taskId);
|
||||
Page<TsFiles> compareLocal(List<String> dataset, String nodeId, String taskId, Page<TsFiles> page);
|
||||
|
||||
/**********************************
|
||||
@ -214,7 +213,6 @@ public interface ITsFilesService extends IService<TsFiles> {
|
||||
* 参数说明 id 文件id
|
||||
* 返回值说明: com.yfd.platform.config.ResponseResult 返回成功或者失败
|
||||
***********************************/
|
||||
// DualTreeResponse compareMinio(List<String> dataset, String nodeId, String taskId);
|
||||
Page<TsFiles> compareMinio(List<String> dataset, String nodeId, String taskId, Page<TsFiles> page);
|
||||
|
||||
|
||||
@ -226,11 +224,17 @@ public interface ITsFilesService extends IService<TsFiles> {
|
||||
* 参数说明 id 文件id
|
||||
* 返回值说明: com.yfd.platform.config.ResponseResult 返回成功或者失败
|
||||
***********************************/
|
||||
// Page<TsFiles> compareMd5(List<String> dataset, String nodeId, String taskId) throws IOException, NoSuchAlgorithmException;
|
||||
Page<TsFiles> compareMd5(List<String> dataset, String nodeId, String taskId, Page<TsFiles> page);
|
||||
|
||||
|
||||
void automaticFileBackupAsync(String taskId, String nodeId) throws IOException;
|
||||
|
||||
Boolean deleteTsFilesByNodeId(String nodeId, String taskId);
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 停止获取轨迹数据
|
||||
* 参数说明 token SSE连接的token
|
||||
* 返回值说明: com.yfd.platform.config.ResponseResult
|
||||
***********************************/
|
||||
void stopSimpleNavi(String token);
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package com.yfd.platform.modules.experimentalData.service.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
|
||||
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ClosedByInterruptException;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
@ -145,17 +148,29 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
|
||||
QueryWrapper<TsFiles> queryWrapper = new QueryWrapper<>();
|
||||
// 固定条件过滤
|
||||
if (StringUtils.isNotBlank(nodeId)) queryWrapper.eq("node_id", nodeId);
|
||||
if (StringUtils.isNotBlank(taskId)) queryWrapper.eq("task_id", taskId);
|
||||
if (StringUtils.isNotBlank(nodeId)) {
|
||||
queryWrapper.eq("node_id", nodeId);
|
||||
}
|
||||
if (StringUtils.isNotBlank(taskId)) {
|
||||
queryWrapper.eq("task_id", taskId);
|
||||
}
|
||||
|
||||
|
||||
// 模糊搜索
|
||||
if (StringUtils.isNotBlank(fileName)) queryWrapper.like("file_name", fileName);
|
||||
if (StringUtils.isNotBlank(keywords)) queryWrapper.like("keywords", keywords);
|
||||
if (StringUtils.isNotBlank(fileName)) {
|
||||
queryWrapper.like("file_name", fileName);
|
||||
}
|
||||
if (StringUtils.isNotBlank(keywords)) {
|
||||
queryWrapper.like("keywords", keywords);
|
||||
}
|
||||
|
||||
// 时间范围过滤
|
||||
if (StringUtils.isNotBlank(startDate)) queryWrapper.ge("upload_time", startDate);
|
||||
if (StringUtils.isNotBlank(endDate)) queryWrapper.le("upload_time", endDate);
|
||||
if (StringUtils.isNotBlank(startDate)) {
|
||||
queryWrapper.ge("upload_time", startDate);
|
||||
}
|
||||
if (StringUtils.isNotBlank(endDate)) {
|
||||
queryWrapper.le("upload_time", endDate);
|
||||
}
|
||||
boolean hasSearchCondition = StringUtils.isNotBlank(fileName) || StringUtils.isNotBlank(keywords) || StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate);
|
||||
|
||||
// 处理层级关系条件
|
||||
@ -2186,7 +2201,9 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
|
||||
// 路径规范化
|
||||
String normalizedPath = normalizePathtargz(entry.getName(), sourcePath.getFileName().toString());
|
||||
if (normalizedPath.isEmpty()) continue;
|
||||
if (normalizedPath.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Path targetPath = destRoot.resolve(normalizedPath).normalize();
|
||||
validatePath(targetPath, destRoot);
|
||||
@ -2311,7 +2328,9 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
* @return 规范化后的路径(如 "222/3.txt")
|
||||
*/
|
||||
private String normalizePathtargz(String entryPath, String archiveName) {
|
||||
if (entryPath == null || entryPath.trim().isEmpty()) return "";
|
||||
if (entryPath == null || entryPath.trim().isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// 统一路径分隔符并清理特殊字符
|
||||
String path = entryPath.replace("\\", "/")
|
||||
@ -2931,7 +2950,9 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
|
||||
// 查询当前文件记录
|
||||
TsFiles currentFile = getFileRecord(name, path);
|
||||
if (currentFile == null) return false;
|
||||
if (currentFile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 递归创建父文件夹
|
||||
boolean parentsCreated = createParentFolders(currentFile.getParentId());
|
||||
@ -2967,8 +2988,12 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
|
||||
// 规范化路径格式
|
||||
private String normalizePath(String path) {
|
||||
if (!path.startsWith("/")) path = "/" + path;
|
||||
if (!path.endsWith("/")) path += "/";
|
||||
if (!path.startsWith("/")) {
|
||||
path = "/" + path;
|
||||
}
|
||||
if (!path.endsWith("/")) {
|
||||
path += "/";
|
||||
}
|
||||
return path.replace("//", "/");
|
||||
}
|
||||
|
||||
@ -2989,7 +3014,9 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
|
||||
// 先递归处理上级
|
||||
boolean ancestorsCreated = createParentFolders(parentFolder.getParentId());
|
||||
if (!ancestorsCreated) return false;
|
||||
if (!ancestorsCreated) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查当前文件夹是否已创建
|
||||
if (StringUtils.isEmpty(parentFolder.getBackupPath())) {
|
||||
@ -3702,7 +3729,9 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
if ("0".equals(type)) { // 覆盖模式
|
||||
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
|
||||
} else { // 重命名模式
|
||||
if (Files.exists(target)) throw new IOException("目标文件已存在: " + target);
|
||||
if (Files.exists(target)) {
|
||||
throw new IOException("目标文件已存在: " + target);
|
||||
}
|
||||
Files.copy(source, target);
|
||||
}
|
||||
}
|
||||
@ -4198,10 +4227,14 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
// 读取指定行
|
||||
for (int i = 0; i < step; i++) {
|
||||
line = reader.readLine();
|
||||
if (line == null) break; // 文件结束
|
||||
if (line == null) {
|
||||
break; // 文件结束
|
||||
}
|
||||
}
|
||||
|
||||
if (line == null) break; // 文件结束
|
||||
if (line == null) {
|
||||
break; // 文件结束
|
||||
}
|
||||
|
||||
line = line.trim();
|
||||
String[] values = line.split("\t");
|
||||
@ -4240,7 +4273,7 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
// 封装发送数据的逻辑
|
||||
private void sendData(String token, String[] values, int lineCount) {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
return; // 如果线程已被中断,则直接返回
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
@ -4330,6 +4363,7 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
* @throws SecurityException 路径非法时抛出
|
||||
* @throws IOException 文件写入失败时抛出
|
||||
*/
|
||||
@Override
|
||||
public void saveFileContent(String id, String content) throws SecurityException, IOException {
|
||||
StorageSourceConfig config = storageSourceConfigMapper.selectOne(new QueryWrapper<StorageSourceConfig>().eq("name", "filePath"));
|
||||
TsFiles tsFiles = tsFilesMapper.selectById(id);
|
||||
@ -4558,6 +4592,19 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
|
||||
}
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 停止获取轨迹数据
|
||||
* 参数说明 token SSE连接的token
|
||||
* 返回值说明: com.yfd.platform.config.ResponseResult
|
||||
***********************************/
|
||||
@Override
|
||||
public void stopSimpleNavi(String token) {
|
||||
if (currentTaskFuture != null && !currentTaskFuture.isDone()) {
|
||||
currentTaskFuture.cancel(true); // 中断之前的任务
|
||||
}
|
||||
ServerSendEventServer.removeUser(token);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -279,7 +279,6 @@ public class TsNodesServiceImpl extends ServiceImpl<TsNodesMapper, TsNodes> impl
|
||||
tsnodes.setNodeOrder(orderno);
|
||||
|
||||
|
||||
|
||||
int valueAdded = tsNodesMapper.insert(tsnodes);
|
||||
if (valueAdded == 1) {
|
||||
LOGGER.info("tsnodes表结构增加成功");
|
||||
@ -287,11 +286,11 @@ public class TsNodesServiceImpl extends ServiceImpl<TsNodesMapper, TsNodes> impl
|
||||
AbstractBaseFileService<?> fileService = storageSourceContext.getByStorageKey("local");
|
||||
boolean flag = fileService.isFolderCreated(File.separator + tsnodes.getNodeId());
|
||||
//如果是false 说明没有创建 那就新建一个文件夹
|
||||
if(!flag){
|
||||
if (!flag) {
|
||||
//本地创建文件夹
|
||||
AbstractBaseFileService<?> fileServiceData = storageSourceContext.getByStorageKey("local");
|
||||
boolean flagData = fileServiceData.newFolder(File.separator, tsnodes.getNodeId());
|
||||
if(!flagData){
|
||||
if (!flagData) {
|
||||
LOGGER.error("创建节点文件夹失败!");
|
||||
return ResponseResult.error("新增节点失败!");
|
||||
}
|
||||
@ -450,27 +449,27 @@ public class TsNodesServiceImpl extends ServiceImpl<TsNodesMapper, TsNodes> impl
|
||||
Boolean value = false;
|
||||
//根据任务ID 查询所有的集合 不管层级结构全部都删除
|
||||
QueryWrapper<TsNodes> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("task_id",taskId);
|
||||
queryWrapper.eq("task_id", taskId);
|
||||
List<TsNodes> tsNodesList = tsNodesMapper.selectList(queryWrapper);
|
||||
if(tsNodesList == null && tsNodesList.isEmpty()){
|
||||
return true;
|
||||
if (tsNodesList == null && tsNodesList.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for(TsNodes tsNodes : tsNodesList){
|
||||
//删除文件表
|
||||
Boolean deleteTsFiles = tsFilesService.deleteTsFilesByNodeId(tsNodes.getNodeId(),tsNodes.getTaskId());
|
||||
//如果删除成功 接着删除节点表数据
|
||||
if(deleteTsFiles){
|
||||
// 删除当前节点
|
||||
int deleteCount = tsNodesMapper.deleteById(tsNodes.getNodeId());
|
||||
if (deleteCount == 1) {
|
||||
LOGGER.info("tsnodes表结删除改成功");
|
||||
value = true;
|
||||
} else {
|
||||
LOGGER.error("tsnodes表结构删除失败");
|
||||
value = false;
|
||||
}
|
||||
}
|
||||
for (TsNodes tsNodes : tsNodesList) {
|
||||
//删除文件表
|
||||
Boolean deleteTsFiles = tsFilesService.deleteTsFilesByNodeId(tsNodes.getNodeId(), tsNodes.getTaskId());
|
||||
//如果删除成功 接着删除节点表数据
|
||||
if (deleteTsFiles) {
|
||||
// 删除当前节点
|
||||
int deleteCount = tsNodesMapper.deleteById(tsNodes.getNodeId());
|
||||
if (deleteCount == 1) {
|
||||
LOGGER.info("tsnodes表结删除改成功");
|
||||
value = true;
|
||||
} else {
|
||||
LOGGER.error("tsnodes表结构删除失败");
|
||||
value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@ -178,21 +178,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||
queryWrapper.eq("parent_id", "00");
|
||||
List<Nodes> nodesList = nodesService.list(queryWrapper);
|
||||
//如果为空 跳过当前项目 接着下一个项目
|
||||
if (nodesList == null || nodesList.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
for (Nodes nodes : nodesList) {
|
||||
//调用删除节点 根据任务ID
|
||||
Boolean deleteTsnodes = nodesService.deleteNodesById(nodes.getParentId());
|
||||
//如果删除成功 接着删除节点表数据
|
||||
if (deleteTsnodes) {
|
||||
LOGGER.info("nodes表结删除改成功");
|
||||
value = true;
|
||||
} else {
|
||||
LOGGER.error("nodes表结构删除失败");
|
||||
value = false;
|
||||
if (nodesList != null || !nodesList.isEmpty()) {
|
||||
for (Nodes nodes : nodesList) {
|
||||
//调用删除节点 根据任务ID
|
||||
Boolean deleteTsnodes = nodesService.deleteNodesById(nodes.getId());
|
||||
//如果删除成功 接着删除节点表数据
|
||||
if (deleteTsnodes) {
|
||||
LOGGER.info("nodes表结删除改成功");
|
||||
value = true;
|
||||
} else {
|
||||
LOGGER.error("nodes表结构删除失败");
|
||||
value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 删除当前项目
|
||||
int deleteCount = projectMapper.deleteById(id);
|
||||
if (deleteCount == 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user