代码提交
This commit is contained in:
parent
84fc2ff0a4
commit
cfebecb806
@ -65,11 +65,13 @@ public class TsFilesController {
|
||||
public ResponseResult getTsFilesPage(String id, String fileName, String startDate, String endDate, String keywords, String nodeId, String taskId, String childNode, Page<TsFiles> page) throws Exception {
|
||||
//分页查询
|
||||
int currentPage = (int) page.getCurrent();
|
||||
// 先尝试从缓存获取
|
||||
if(!StrUtil.isEmpty(id)){
|
||||
IPage<TsFiles> cachedPage = tsFilesService.getCachedTsFilesPage(taskId, nodeId, currentPage,id);
|
||||
if (cachedPage != null) {
|
||||
return ResponseResult.successData(cachedPage);
|
||||
// 先尝试从缓存获取 如果搜索条件为空 从Redis获取
|
||||
if(StrUtil.isBlank(fileName)&&StrUtil.isBlank(keywords) &&StrUtil.isBlank(startDate) &&StrUtil.isBlank(endDate)) {
|
||||
if (!StrUtil.isEmpty(id)) {
|
||||
IPage<TsFiles> cachedPage = tsFilesService.getCachedTsFilesPage(taskId, nodeId, currentPage, id);
|
||||
if (cachedPage != null) {
|
||||
return ResponseResult.successData(cachedPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
Page<TsFiles> tsfilesPage = tsFilesService.getTsFilesPage(id, fileName, startDate, endDate, keywords, nodeId, taskId, fileName, childNode, page);
|
||||
@ -238,8 +240,6 @@ public class TsFilesController {
|
||||
if (StrUtil.isBlank(id)) {
|
||||
return ResponseResult.error("参数为空");
|
||||
}
|
||||
|
||||
|
||||
return ResponseResult.success(tsFilesService.decompressionFolder(id, decompressionPath, parentId, path));
|
||||
} catch (Exception e) {
|
||||
System.out.print("解压缩异常原因" + e);
|
||||
|
@ -267,11 +267,13 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
|
||||
tsFilesPage.setRecords(records); // 同步到 tsFilesPage
|
||||
int currentPage = (int) page.getCurrent();
|
||||
// 如果是前五页,将结果存入Redis(有效期建议30分钟)
|
||||
if (!StrUtil.isEmpty(id)) {
|
||||
if (currentPage >= 1 && currentPage <= 5) {
|
||||
String redisKey = "tsfiles_" + taskId + "_" + nodeId + "_parentId" + id + "_page_" + currentPage + "";
|
||||
redisTemplate.opsForValue().set(redisKey, tsFilesPage, 2, TimeUnit.HOURS);
|
||||
// 如果是前五页,将结果存入Redis(有效期建议30分钟)如果搜索条件为空 从Redis获取
|
||||
if (StrUtil.isBlank(fileName) && StrUtil.isBlank(keywords) && StrUtil.isBlank(startDate) && StrUtil.isBlank(endDate)) {
|
||||
if (!StrUtil.isEmpty(id)) {
|
||||
if (currentPage >= 1 && currentPage <= 5) {
|
||||
String redisKey = "tsfiles_" + taskId + "_" + nodeId + "_parentId" + id + "_page_" + currentPage + "";
|
||||
redisTemplate.opsForValue().set(redisKey, tsFilesPage, 2, TimeUnit.HOURS);
|
||||
}
|
||||
}
|
||||
}
|
||||
return tsFilesPage;
|
||||
@ -1260,6 +1262,15 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
try {
|
||||
String finalParentId = ensureFullPathExists(compressedPath, filesList.get(0).getNodeId(), filesList.get(0).getTaskId(), path);
|
||||
parentId = finalParentId;
|
||||
LOGGER.info("压缩的时候删除Redis");
|
||||
//todo 压缩的时候删除Redis
|
||||
if (!parentId.equals("00")) {
|
||||
for (int page = 1; page <= 5; page++) {
|
||||
String redisKey = "tsfiles_" + filesList.get(0).getTaskId() + "_" + filesList.get(0).getNodeId() + "_parentId" + parentId + "_page_" + page;
|
||||
redisTemplate.delete(redisKey);
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.info("路径已全部存在,最终目录ID: {}", finalParentId);
|
||||
} catch (RuntimeException e) {
|
||||
LOGGER.error("路径创建失败: {}", e.getMessage());
|
||||
@ -1867,6 +1878,16 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
try {
|
||||
String finalParentId = ensureFullPathExists(decompressionPath, zipFileRecord.getNodeId(), zipFileRecord.getTaskId(), path);
|
||||
parentId = finalParentId;
|
||||
|
||||
LOGGER.info("解压缩的时候删除Redis");
|
||||
//todo 解压缩的时候删除Redis
|
||||
if (!parentId.equals("00")) {
|
||||
for (int page = 1; page <= 5; page++) {
|
||||
String redisKey = "tsfiles_" + zipFileRecord.getTaskId() + "_" + zipFileRecord.getNodeId() + "_parentId" + parentId + "_page_" + page;
|
||||
redisTemplate.delete(redisKey);
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.info("路径已全部存在,最终目录ID: {}", finalParentId);
|
||||
} catch (RuntimeException e) {
|
||||
LOGGER.error("路径创建失败: {}", e.getMessage());
|
||||
@ -1937,7 +1958,7 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
TsFiles fileRecord = createFileRecord(
|
||||
file.getName(),
|
||||
parentId,
|
||||
buildFolderPath(decompressionPath),
|
||||
buildFolderPath(extractPath),
|
||||
zipFileRecord.getTaskId(),
|
||||
zipFileRecord.getNodeId(),
|
||||
zipFileRecord.getUploader(),
|
||||
@ -3402,13 +3423,13 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
String asyncKey = taskStatusHolder.generateKey(taskId, nodeId);
|
||||
// 无论成功失败都标记完成
|
||||
taskStatusHolder.finishTask(asyncKey);
|
||||
WebSocketServer.sendMessageTo("文件自动备份完成", "taskId_"+taskId+"_"+"nodeId_"+nodeId);
|
||||
WebSocketServer.sendMessageTo("文件自动备份完成", "taskId_" + taskId + "_" + "nodeId_" + nodeId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async("asyncExecutor")
|
||||
public void automaticFileBackupAsyncByIds(List<String> dataset,String taskId,String nodeId) throws IOException {
|
||||
public void automaticFileBackupAsyncByIds(List<String> dataset, String taskId, String nodeId) throws IOException {
|
||||
try {
|
||||
// 执行实际备份逻辑
|
||||
this.automaticFileBackupByIds(dataset);
|
||||
@ -3417,7 +3438,7 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
String asyncKey = taskStatusHolder.generateKey(taskId, nodeId);
|
||||
// 无论成功失败都标记完成
|
||||
taskStatusHolder.finishTask(asyncKey);
|
||||
WebSocketServer.sendMessageTo("文件自动备份完成", "taskId_"+taskId+"_"+"nodeId_"+nodeId);
|
||||
WebSocketServer.sendMessageTo("文件自动备份完成", "taskId_" + taskId + "_" + "nodeId_" + nodeId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3918,6 +3939,16 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
*/
|
||||
private void updateDatabase(String parentId, String oldpaths, String fileName,
|
||||
String newPath, String targetFileName, String type) {
|
||||
TsFiles tsFilesData = tsFilesMapper.selectById(parentId);
|
||||
LOGGER.info("移动的时候删除Redis");
|
||||
//todo 移动的时候成功以后 删除redis
|
||||
if (!parentId.equals("00")) {
|
||||
for (int page = 1; page <= 5; page++) {
|
||||
String redisKey = "tsfiles_" + tsFilesData.getTaskId() + "_" + tsFilesData.getNodeId() + "_parentId" + parentId + "_page_" + page;
|
||||
redisTemplate.delete(redisKey);
|
||||
}
|
||||
LOGGER.info("已清理缓存:taskid={}, node={}, pages=1-5", tsFilesData.getTaskId(), tsFilesData.getNodeId());
|
||||
}
|
||||
// 1. 构建完整路径
|
||||
String oldWorkPath = oldpaths.endsWith("/") ? oldpaths : oldpaths + "/";
|
||||
String newWorkPath = newPath.endsWith("/") ? newPath : newPath + "/";
|
||||
@ -4154,6 +4185,17 @@ public class TsFilesServiceImpl extends ServiceImpl<TsFilesMapper, TsFiles> impl
|
||||
*/
|
||||
private void insertDatabaseRecord(String parentId, String oldpaths, String fileName,
|
||||
String newPath, String targetFileName, String type) {
|
||||
|
||||
TsFiles tsFilesData = tsFilesMapper.selectById(parentId);
|
||||
LOGGER.info("复制的时候删除Redis");
|
||||
//todo 复制的时候成功以后 删除redis
|
||||
if (!parentId.equals("00")) {
|
||||
for (int page = 1; page <= 5; page++) {
|
||||
String redisKey = "tsfiles_" + tsFilesData.getTaskId() + "_" + tsFilesData.getNodeId() + "_parentId" + parentId + "_page_" + page;
|
||||
redisTemplate.delete(redisKey);
|
||||
}
|
||||
LOGGER.info("已清理缓存:taskid={}, node={}, pages=1-5", tsFilesData.getTaskId(), tsFilesData.getNodeId());
|
||||
}
|
||||
// 获取用户信息
|
||||
// 获取当前用户和时间
|
||||
UsernamePasswordAuthenticationToken authentication =
|
||||
|
@ -477,11 +477,23 @@ public class TsNodesServiceImpl extends ServiceImpl<TsNodesMapper, TsNodes> impl
|
||||
|
||||
//批量修改
|
||||
LambdaUpdateWrapper<TsFiles> updateWrapper1 = new LambdaUpdateWrapper<>();
|
||||
updateWrapper1.in(TsFiles::getId, dataset).isNotNull(TsFiles::getBackupPath).ne(TsFiles::getBackupPath, "").set(TsFiles::getWorkPath, "");
|
||||
updateWrapper1.in(TsFiles::getId, dataset).set(TsFiles::getWorkPath, "");
|
||||
tsFilesMapper.update(null, updateWrapper1);
|
||||
//批量删除
|
||||
// LambdaQueryWrapper<TsFiles> deleteWrapper = new LambdaQueryWrapper<>();
|
||||
// deleteWrapper.in(TsFiles::getId, dataset).isNull(TsFiles::getBackupPath).eq(TsFiles::getBackupPath, "").isNull(TsFiles::getWorkPath).eq(TsFiles::getWorkPath, "");
|
||||
// tsFilesMapper.delete(deleteWrapper);
|
||||
//
|
||||
// LambdaQueryWrapper<TsFiles> deleteWrapper = new LambdaQueryWrapper<>();
|
||||
// deleteWrapper.in(TsFiles::getId, dataset)
|
||||
// .and(wrapper -> wrapper.isNull(TsFiles::getBackupPath).or().eq(TsFiles::getBackupPath, ""))
|
||||
// .and(wrapper -> wrapper.isNull(TsFiles::getWorkPath).or().eq(TsFiles::getWorkPath, ""));
|
||||
// tsFilesMapper.delete(deleteWrapper);
|
||||
|
||||
LambdaQueryWrapper<TsFiles> deleteWrapper = new LambdaQueryWrapper<>();
|
||||
deleteWrapper.in(TsFiles::getId, dataset).isNull(TsFiles::getBackupPath).eq(TsFiles::getBackupPath, "").isNull(TsFiles::getWorkPath).eq(TsFiles::getWorkPath, "");
|
||||
deleteWrapper.in(TsFiles::getId, dataset)
|
||||
.and(wrapper -> wrapper.isNull(TsFiles::getBackupPath).or().eq(TsFiles::getBackupPath, ""))
|
||||
.and(wrapper -> wrapper.isNull(TsFiles::getWorkPath).or().eq(TsFiles::getWorkPath, ""));
|
||||
tsFilesMapper.delete(deleteWrapper);
|
||||
|
||||
// //批量修改TsFiles表结构
|
||||
|
@ -56,11 +56,13 @@ public class FilesController {
|
||||
public ResponseResult getFilesPage(String fileName, String startDate, String endDate, String keywords, String nodeId,String projectId, Page<Files> page) throws Exception {
|
||||
//分页查询
|
||||
int currentPage = (int) page.getCurrent();
|
||||
// 先尝试从缓存获取
|
||||
IPage<Files> cachedFilesPage = filesService.getCachedFilesPage(projectId, nodeId,currentPage );
|
||||
if (cachedFilesPage != null){
|
||||
return ResponseResult.successData(cachedFilesPage);
|
||||
}
|
||||
// 先尝试从缓存获取 如果搜索条件为空 从Redis获取
|
||||
if(StrUtil.isBlank(fileName)&&StrUtil.isBlank(keywords) &&StrUtil.isBlank(startDate) &&StrUtil.isBlank(endDate)){
|
||||
IPage<Files> cachedFilesPage = filesService.getCachedFilesPage(projectId, nodeId,currentPage);
|
||||
if (cachedFilesPage != null){
|
||||
return ResponseResult.successData(cachedFilesPage);
|
||||
}
|
||||
}
|
||||
|
||||
Page<Files> filesPage = filesService.getFilesPage(fileName, startDate, endDate, keywords, nodeId, projectId, fileName, page);
|
||||
return ResponseResult.successData(filesPage);
|
||||
|
@ -3,6 +3,7 @@ package com.yfd.platform.modules.specialDocument.service.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@ -208,9 +209,11 @@ public class FilesServiceImpl extends ServiceImpl<FilesMapper, Files> implements
|
||||
filesPage.setRecords(records);
|
||||
int currentPage = (int) page.getCurrent();
|
||||
// 如果是前五页,将结果存入Redis(有效期建议30分钟)
|
||||
if (currentPage >= 1 && currentPage <= 5) {
|
||||
String redisKey = "sdfiles_" + projectId + "_" + nodeId + "_page_" + currentPage;
|
||||
redisTemplate.opsForValue().set(redisKey, filesPage, 2, TimeUnit.HOURS);
|
||||
if (StrUtil.isBlank(fileName) && StrUtil.isBlank(keywords) && StrUtil.isBlank(startDate) && StrUtil.isBlank(endDate)) {
|
||||
if (currentPage >= 1 && currentPage <= 5) {
|
||||
String redisKey = "sdfiles_" + projectId + "_" + nodeId + "_page_" + currentPage;
|
||||
redisTemplate.opsForValue().set(redisKey, filesPage, 2, TimeUnit.HOURS);
|
||||
}
|
||||
}
|
||||
return filesPage;
|
||||
}
|
||||
@ -317,6 +320,9 @@ public class FilesServiceImpl extends ServiceImpl<FilesMapper, Files> implements
|
||||
value = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
value = true;
|
||||
LOGGER.info("文件名相同覆盖 {}", files.getFileName());
|
||||
}
|
||||
File target = new File(storageSourceConfig.getValue() + String.valueOf(sourceFilePath));
|
||||
//删除临时文件
|
||||
|
@ -19,6 +19,7 @@ import com.yfd.platform.modules.storage.service.base.AbstractBaseFileService;
|
||||
import com.yfd.platform.system.mapper.SysDictionaryItemsMapper;
|
||||
import com.yfd.platform.utils.StringUtils;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import net.bytebuddy.implementation.bytecode.Throw;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -124,6 +125,15 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||
// 转换为 Timestamp
|
||||
Timestamp currentTime = Timestamp.valueOf(now);
|
||||
project.setCreateTime(currentTime);
|
||||
|
||||
LambdaQueryWrapper<Project> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(Project::getProjectName,project.getProjectName());
|
||||
Project project1 = projectMapper.selectOne(queryWrapper);
|
||||
if (project1 != null){
|
||||
throw new RuntimeException("专项文档管理项目已存在!");
|
||||
}
|
||||
|
||||
|
||||
int valueAdded = projectMapper.insert(project);
|
||||
if (valueAdded == 1) {
|
||||
|
||||
@ -226,7 +236,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||
if (project.getProjectTime() == null || project.getProjectTime().equals("")) {
|
||||
project.setProjectTime(null);
|
||||
}
|
||||
|
||||
int valueUpdate = projectMapper.updateById(project);
|
||||
if (valueUpdate == 1) {
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user