支持任务名称修改
This commit is contained in:
parent
0e28431435
commit
2ea468c04c
@ -167,7 +167,7 @@ public class TsNodesController {
|
||||
if ("IN_PROGRESS".equals(existingStatus)) {
|
||||
return ResponseResult.success("试验数据扫描任务正在处理中!");
|
||||
} else if ("COMPLETED".equals(existingStatus)) {
|
||||
return ResponseResult.success("验数据扫描任务已完成!");
|
||||
return ResponseResult.success("试验数据扫描任务已完成!");
|
||||
}
|
||||
UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||
LoginUser loginuser = (LoginUser) authentication.getPrincipal();
|
||||
|
||||
@ -6395,47 +6395,52 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
@Override
|
||||
public Map<String, TsFiles> splitFile(String id,String taskId,File jsonFile) throws Exception {
|
||||
//1:动态表名 以及通过ID查询tsfiles 然后根据id path taskId nodeid 等等条件查询所欲的集合
|
||||
TsTask tsTask = tsTaskMapper.selectById(taskId);
|
||||
TableNameContextHolder.setTaskCode(tsTask.getTaskCode());
|
||||
StorageSource storageSource = getStorageConfig(tsTask.getLocalStorageId());
|
||||
TsFiles tsFile = tsFilesMapper.selectById(id);
|
||||
if (tsFile == null) {
|
||||
throw new RuntimeException("文件不存在: " + id);
|
||||
}
|
||||
StorageSourceConfig config = getStorageSourceConfig("filePath", "local", tsTask.getLocalStorageId());
|
||||
|
||||
|
||||
// 2. 构建源文件路径
|
||||
Path sourcePath = Paths.get(config.getValue(), tsFile.getWorkPath(), tsFile.getFileName()).normalize();
|
||||
File sourceFile = sourcePath.toFile();
|
||||
if (!sourceFile.exists()) {
|
||||
throw new FileNotFoundException("文件不存在: " + sourcePath);
|
||||
}
|
||||
|
||||
// 3. 根据规则拆分文件
|
||||
Map<String, String> outputPaths = insFileConvertNewService.convert(sourceFile,jsonFile);
|
||||
|
||||
// 3. 生成TsFiles对象集合
|
||||
Map<String, TsFiles> resultMap = new HashMap<>();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
try {
|
||||
TsTask tsTask = tsTaskMapper.selectById(taskId);
|
||||
TableNameContextHolder.setTaskCode(tsTask.getTaskCode());
|
||||
StorageSource storageSource = getStorageConfig(tsTask.getLocalStorageId());
|
||||
TsFiles tsFile = tsFilesMapper.selectById(id);
|
||||
if (tsFile == null) {
|
||||
throw new RuntimeException("文件不存在: " + id);
|
||||
}
|
||||
StorageSourceConfig config = getStorageSourceConfig("filePath", "local", tsTask.getLocalStorageId());
|
||||
|
||||
// 遍历所有输出文件
|
||||
for (Map.Entry<String, String> entry : outputPaths.entrySet()) {
|
||||
String outputName = entry.getKey(); // 如 vins、fvns
|
||||
String path = entry.getValue();
|
||||
File outFile = new File(path);
|
||||
|
||||
TsFiles ts = new TsFiles();
|
||||
ts.setNodeId(tsFile.getNodeId());
|
||||
ts.setTaskId(tsFile.getTaskId());
|
||||
ts.setIsFile("FILE");
|
||||
ts.setParentId(tsFile.getParentId());
|
||||
ts.setFileName(outFile.getName());
|
||||
ts.setFileSize(String.valueOf(outFile.length() / (1024.0 * 1024.0))); // 转 M
|
||||
ts.setWorkPath(tsFile.getWorkPath());
|
||||
this.addTsFiles(ts);
|
||||
// 2. 构建源文件路径
|
||||
Path sourcePath = Paths.get(config.getValue(), tsFile.getWorkPath(), tsFile.getFileName()).normalize();
|
||||
File sourceFile = sourcePath.toFile();
|
||||
if (!sourceFile.exists()) {
|
||||
throw new FileNotFoundException("文件不存在: " + sourcePath);
|
||||
}
|
||||
|
||||
resultMap.put(outputName, ts);
|
||||
// 3. 根据规则拆分文件
|
||||
Map<String, String> outputPaths = insFileConvertNewService.convert(sourceFile, jsonFile);
|
||||
|
||||
// 3. 生成TsFiles对象集合
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
// 遍历所有输出文件
|
||||
for (Map.Entry<String, String> entry : outputPaths.entrySet()) {
|
||||
String outputName = entry.getKey(); // 如 vins、fvns
|
||||
String path = entry.getValue();
|
||||
File outFile = new File(path);
|
||||
|
||||
TsFiles ts = new TsFiles();
|
||||
ts.setNodeId(tsFile.getNodeId());
|
||||
ts.setTaskId(tsFile.getTaskId());
|
||||
ts.setIsFile("FILE");
|
||||
ts.setParentId(tsFile.getParentId());
|
||||
ts.setFileName(outFile.getName());
|
||||
ts.setFileSize(String.valueOf(outFile.length() / (1024.0 * 1024.0))); // 转 M
|
||||
ts.setWorkPath(tsFile.getWorkPath());
|
||||
this.addTsFiles(ts);
|
||||
|
||||
resultMap.put(outputName, ts);
|
||||
}
|
||||
} finally {
|
||||
TableNameContextHolder.clear(); // 确保清理资源
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
|
||||
@ -494,7 +494,9 @@ public class TsTaskServiceImpl extends ServiceImpl<TsTaskMapper, TsTask> impleme
|
||||
@Override
|
||||
public boolean updatetsTask(TsTask tsTask) throws IOException {
|
||||
Boolean value = false;
|
||||
|
||||
//生成任务名称 任务开始时间_结束时间_地点_载机名称_设备代号_编号
|
||||
String taskName = buildTaskName(tsTask);
|
||||
tsTask.setTaskName(taskName);
|
||||
//处理属性
|
||||
String frontEndJson = tsTask.getTaskProps();
|
||||
List<TsTask> tsTasksList = tsTaskMapper.selectList(new LambdaQueryWrapper<>());
|
||||
@ -506,10 +508,30 @@ public class TsTaskServiceImpl extends ServiceImpl<TsTaskMapper, TsTask> impleme
|
||||
tsTaskMapper.updateById(tsTaskData);
|
||||
}
|
||||
}
|
||||
|
||||
//修改的时候判断本地存储空间是不是发生了变化 如果是的话 需要重新创建本地文件
|
||||
TsTask TsTaskOld = tsTaskMapper.selectById(tsTask.getId());
|
||||
StorageSource storageSource = getStorageConfig(tsTask.getLocalStorageId());
|
||||
if(!TsTaskOld.getTaskName().equals(tsTask.getTaskName())){
|
||||
String path = "/";
|
||||
//新增节点的时候 创建文件夹
|
||||
NewFolderRequest newFolderRequest = new NewFolderRequest();
|
||||
newFolderRequest.setName(tsTask.getTaskName());//新建的文件夹名称,示例值(/a/b/c)
|
||||
newFolderRequest.setPassword("");//文件夹密码, 如果文件夹需要密码才能访问,则支持请求密码,示例值(123456)
|
||||
newFolderRequest.setPath(path);//请求路径,示例值(/)
|
||||
newFolderRequest.setStorageKey(storageSource.getKey());//存储源 key,示例值(local minio)
|
||||
AbstractBaseFileService<?> fileService = storageSourceContext.getByStorageKey(newFolderRequest.getStorageKey());
|
||||
boolean flag = fileService.newFolder(newFolderRequest.getPath(), newFolderRequest.getName());
|
||||
|
||||
//删除旧文件夹
|
||||
NewFolderRequest oldFolderRequest = new NewFolderRequest();
|
||||
oldFolderRequest.setName(TsTaskOld.getTaskName());//新建的文件夹名称,示例值(/a/b/c)
|
||||
oldFolderRequest.setPassword("");//文件夹密码, 如果文件夹需要密码才能访问,则支持请求密码,示例值(123456)
|
||||
oldFolderRequest.setPath(path);//请求路径,示例值(/)
|
||||
oldFolderRequest.setStorageKey(storageSource.getKey());//存储源 key,示例值(local minio)
|
||||
AbstractBaseFileService<?> fileServiceOld = storageSourceContext.getByStorageKey(oldFolderRequest.getStorageKey());
|
||||
boolean flagOld = fileServiceOld.deleteFolder(oldFolderRequest.getPath(), oldFolderRequest.getName());
|
||||
}
|
||||
//如果存储空间和名称都没有该表的情况下
|
||||
if (!TsTaskOld.getLocalStorageId().equals(tsTask.getLocalStorageId())) {
|
||||
String path = "/";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user