1.优化查重功能新添停止查重不删除文件功能
This commit is contained in:
parent
890c4642ca
commit
462af65bd3
|
@ -6,6 +6,7 @@ import com.platform.check.domain.vo.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -24,6 +25,8 @@ public interface CheckDocTaskService extends IService<CheckDocTask>{
|
||||||
|
|
||||||
List<CheckReportVo> findAllReport(String taskId);
|
List<CheckReportVo> findAllReport(String taskId);
|
||||||
|
|
||||||
|
void handleTaskData(String taskId);
|
||||||
|
|
||||||
void deleteTask(String taskId);
|
void deleteTask(String taskId);
|
||||||
|
|
||||||
String updateSubmitState(String taskId,Integer submitState,String description,String analysis);
|
String updateSubmitState(String taskId,Integer submitState,String description,String analysis);
|
||||||
|
|
|
@ -329,26 +329,82 @@ public class CheckDocTaskServiceImpl extends ServiceImpl<CheckDocTaskMapper,Chec
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理停止查重任务时相关表数据
|
||||||
|
* @param taskId
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void handleTaskData(String taskId){
|
||||||
|
try {
|
||||||
|
//延迟3秒再处理数据,否则任务文件可能还在占用导致任务文件删除不掉
|
||||||
|
TimeUnit.SECONDS.sleep(4);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
//修改项目查重标识
|
||||||
|
CheckDocTask task = this.getById(taskId);
|
||||||
|
if(Objects.isNull(task)){
|
||||||
|
throw new BusinessException("查重任务不存在!");
|
||||||
|
}
|
||||||
|
//删除文档查重任务对应的报告信息
|
||||||
|
checkReportService.deleteReport(taskId);
|
||||||
|
//删除关联表
|
||||||
|
checkFileUnitService.deleteByTaskId(taskId);
|
||||||
|
//删除历史表
|
||||||
|
checkPaperLibraryService.deleteByTaskId(taskId);
|
||||||
|
//删除当前查重任务对应的提交/退回记录
|
||||||
|
descriptionService.deleteByTaskId(taskId);
|
||||||
|
//删除任务文档索引数据
|
||||||
|
Splitter splitter = Splitter.on(",").omitEmptyStrings().trimResults();
|
||||||
|
List<String> fileIds = splitter.splitToList(task.getFileIdList());
|
||||||
|
elasticsearchService.batchDeleteIndex(fileIds);
|
||||||
|
//删除redis缓存数据
|
||||||
|
this.deleteRedisParsingCache(task);
|
||||||
|
//删除文档查重任务对应的文件信息
|
||||||
|
String taskFilePath = properties.getTaskFilePath()+File.separator+taskId;
|
||||||
|
File taskFile = new File(taskFilePath);
|
||||||
|
if(taskFile.exists()){
|
||||||
|
FileUtils.deleteDirectory(taskFile);
|
||||||
|
}
|
||||||
|
//删除任务报告对应文件信息
|
||||||
|
String taskReportPath = properties.getTaskReportFilePath()+File.separator+taskId;
|
||||||
|
File taskReportFile = new File(taskReportPath);
|
||||||
|
if(taskReportFile.exists()){
|
||||||
|
FileUtils.deleteDirectory(taskReportPath);
|
||||||
|
}
|
||||||
|
//设置查重任务状态为未开始
|
||||||
|
task.setTaskStatus(CheckStatus.NOT_STARTED.getCode());
|
||||||
|
//删除文档查重任务
|
||||||
|
this.baseMapper.updateById(task);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除文件查重任务信息
|
* 删除文件查重任务信息
|
||||||
* @param taskId
|
* @param taskId
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void deleteTask(String taskId) {
|
public void deleteTask(String taskId){
|
||||||
//修改项目查重标识
|
//修改项目查重标识
|
||||||
CheckDocTask task = this.getById(taskId);
|
CheckDocTask task = this.getById(taskId);
|
||||||
if(Objects.isNull(task)){
|
if(Objects.isNull(task)){
|
||||||
throw new BusinessException("查重任务不存在!");
|
throw new BusinessException("查重任务不存在!");
|
||||||
}
|
}
|
||||||
//删除过滤词文件
|
//删除过滤词文件
|
||||||
// if (StringUtils.isNotBlank(task.getFilterWordFilePath())){
|
if (StringUtils.isNotBlank(task.getFilterWordFilePath())){
|
||||||
// String filterWordFilePath = task.getFilterWordFilePath();
|
String filterWordFilePath = task.getFilterWordFilePath();
|
||||||
// File filterWordFile = new File(filterWordFilePath);
|
File filterWordFile = new File(filterWordFilePath);
|
||||||
// if(filterWordFile.exists()){
|
if(filterWordFile.exists()){
|
||||||
// FileUtils.deleteDirectory(filterWordFilePath);
|
FileUtils.deleteDirectory(filterWordFilePath);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
//删除任务报告对应文件信息
|
||||||
|
String taskReportPath = properties.getTaskReportFilePath()+File.separator+taskId;
|
||||||
|
File taskReportFile = new File(taskReportPath);
|
||||||
|
if(taskReportFile.exists()){
|
||||||
|
FileUtils.deleteDirectory(taskReportFile);
|
||||||
|
}
|
||||||
//删除文档查重任务对应的报告信息
|
//删除文档查重任务对应的报告信息
|
||||||
checkReportService.deleteReport(taskId);
|
checkReportService.deleteReport(taskId);
|
||||||
//删除关联表
|
//删除关联表
|
||||||
|
@ -358,16 +414,10 @@ public class CheckDocTaskServiceImpl extends ServiceImpl<CheckDocTaskMapper,Chec
|
||||||
//删除当前查重任务对应的提交/退回记录
|
//删除当前查重任务对应的提交/退回记录
|
||||||
descriptionService.deleteByTaskId(taskId);
|
descriptionService.deleteByTaskId(taskId);
|
||||||
//删除文档查重任务对应的文件信息
|
//删除文档查重任务对应的文件信息
|
||||||
// String taskFilePath = properties.getTaskFilePath()+File.separator+taskId;
|
String taskFilePath = properties.getTaskFilePath()+File.separator+taskId;
|
||||||
// File taskFile = new File(taskFilePath);
|
File taskFile = new File(taskFilePath);
|
||||||
// if(taskFile.exists()){
|
if(taskFile.exists()){
|
||||||
// FileUtils.deleteDirectory(taskFilePath);
|
FileUtils.deleteDirectory(taskFilePath);
|
||||||
// }
|
|
||||||
//删除任务报告对应文件信息
|
|
||||||
String taskReportPath = properties.getTaskReportFilePath()+File.separator+taskId;
|
|
||||||
File taskReportFile = new File(taskReportPath);
|
|
||||||
if(taskReportFile.exists()){
|
|
||||||
FileUtils.deleteDirectory(taskReportPath);
|
|
||||||
}
|
}
|
||||||
//删除任务文档索引数据
|
//删除任务文档索引数据
|
||||||
Splitter splitter = Splitter.on(",").omitEmptyStrings().trimResults();
|
Splitter splitter = Splitter.on(",").omitEmptyStrings().trimResults();
|
||||||
|
@ -599,10 +649,8 @@ public class CheckDocTaskServiceImpl extends ServiceImpl<CheckDocTaskMapper,Chec
|
||||||
log.error("{}查重任务停止失败,原因{}",project.getProcurementContent(),e.getMessage());
|
log.error("{}查重任务停止失败,原因{}",project.getProcurementContent(),e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}finally {
|
}finally {
|
||||||
//删除任务信息
|
//处理本次任务相关数据
|
||||||
this.deleteTask(project.getCurrentTaskId());
|
this.handleTaskData(project.getCurrentTaskId());
|
||||||
//修改项目当前任务id为空
|
|
||||||
project.setCurrentTaskId(StringUtils.EMPTY);
|
|
||||||
project.setCheckFlag(CheckStatus.NOT_STARTED.getCode());
|
project.setCheckFlag(CheckStatus.NOT_STARTED.getCode());
|
||||||
this.projectEntityMapper.updateById(project);
|
this.projectEntityMapper.updateById(project);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.io.*;
|
||||||
* 文件操作工具类
|
* 文件操作工具类
|
||||||
* 实现文件的创建、删除、复制、压缩、解压以及目录的创建、删除、复制、压缩解压等功能
|
* 实现文件的创建、删除、复制、压缩、解压以及目录的创建、删除、复制、压缩解压等功能
|
||||||
*/
|
*/
|
||||||
public class FileUtils extends org.apache.commons.io.FileUtils {
|
public class FileUtils {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(FileUtils.class);
|
private static Logger log = LoggerFactory.getLogger(FileUtils.class);
|
||||||
|
|
||||||
|
@ -115,6 +115,19 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除目录
|
||||||
|
* @param dirName
|
||||||
|
*/
|
||||||
|
public static void deleteDirectory(File dirName){
|
||||||
|
try {
|
||||||
|
org.apache.commons.io.FileUtils.deleteDirectory(dirName);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.debug("删除目录 " + dirName + " 失败!");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建单个文件
|
* 创建单个文件
|
||||||
* @param descFileName 文件名,包含路径
|
* @param descFileName 文件名,包含路径
|
||||||
|
|
Loading…
Reference in New Issue
Block a user