代码提交
This commit is contained in:
parent
b2e07ce5c6
commit
1bd6a6637b
@ -18,6 +18,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -117,6 +118,21 @@ public class TsNodesController {
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 根据ID确认是否可以实验任务项目
|
||||
* 参数说明 id 试验数据管理节点ID
|
||||
* 返回值说明: com.yfd.platform.config.ResponseResult 返回删除成功或者失败
|
||||
***********************************/
|
||||
@Log(module = "确认是否可以删除节点", value = "根据ID确认是否可以实验任务节点")
|
||||
@PostMapping("/confirmDeleteNodes")
|
||||
@ApiOperation("根据ID确认是否可以实验任务节点")
|
||||
public ResponseResult confirmDeleteNodes(@RequestParam String id) {
|
||||
if (StrUtil.isBlank(id)) {
|
||||
return ResponseResult.error("参数为空");
|
||||
}
|
||||
return ResponseResult.successData(tsNodesService.confirmDeleteNodes(id));
|
||||
}
|
||||
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 试验数据扫描接口
|
||||
|
@ -56,9 +56,9 @@ public class TsTaskController {
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("分页查询试验数据管理试验任务管理")
|
||||
@PreAuthorize("@el.check('select:tsTask')")
|
||||
public ResponseResult getTsTaskPage(String taskName, String startDate, String endDate,String taskPlace, String taskPerson, String taskCode, String taskType,String carrierName,String deviceCode,String testDescribe,String sensorDescribe, Page<TsTask> page) {
|
||||
public ResponseResult getTsTaskPage(String taskName, String startDate, String endDate, String taskPlace, String taskPerson, String taskCode, String taskType, String carrierName, String deviceCode, String testDescribe, String sensorDescribe, Page<TsTask> page) {
|
||||
//分页查询
|
||||
Page<TsTask> sdProjectPage = tsTaskService.getTsTaskPage(taskName, startDate, endDate,taskPlace,taskPerson,taskCode,taskType,carrierName,deviceCode,testDescribe,sensorDescribe, page);
|
||||
Page<TsTask> sdProjectPage = tsTaskService.getTsTaskPage(taskName, startDate, endDate, taskPlace, taskPerson, taskCode, taskType, carrierName, deviceCode, testDescribe, sensorDescribe, page);
|
||||
return ResponseResult.successData(sdProjectPage);
|
||||
}
|
||||
|
||||
@ -156,6 +156,24 @@ public class TsTaskController {
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 根据ID确认是否可以实验任务项目
|
||||
* 参数说明 id 试验数据管理ID
|
||||
* 返回值说明: com.yfd.platform.config.ResponseResult 返回删除成功或者失败
|
||||
***********************************/
|
||||
@Log(module = "确认是否可以删除", value = "根据ID确认是否可以实验任务")
|
||||
@PostMapping("/confirmDeleteTask")
|
||||
@ApiOperation("根据ID确认是否可以实验任务")
|
||||
public ResponseResult confirmDeleteTask(@RequestParam String ids) {
|
||||
if (StrUtil.isBlank(ids)) {
|
||||
return ResponseResult.error("参数为空");
|
||||
}
|
||||
String[] splitIds = ids.split(",");
|
||||
// 数组转集合
|
||||
List<String> dataset = Arrays.asList(splitIds);
|
||||
return ResponseResult.successData(tsTaskService.confirmDeleteTask(dataset));
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* 用途说明: 查询所有试验数据管理-试验任务管理
|
||||
* 参数说明
|
||||
|
@ -57,4 +57,11 @@ public interface ITsNodesService extends IService<TsNodes> {
|
||||
* 返回值说明: com.yfd.platform.config.ResponseResult 返回成功或者失败
|
||||
***********************************/
|
||||
void testDataScanByIdAsync(String id) throws Exception;
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 根据ID确认是否可以实验任务项目
|
||||
* 参数说明 id 试验数据管理节点ID
|
||||
* 返回值说明: com.yfd.platform.config.ResponseResult 返回删除成功或者失败
|
||||
***********************************/
|
||||
Object confirmDeleteNodes(String id);
|
||||
}
|
||||
|
@ -58,4 +58,10 @@ public interface ITsTaskService extends IService<TsTask> {
|
||||
* 返回值说明: com.yfd.platform.config.ResponseResult 返回批量删除成功或失败
|
||||
***********************************/
|
||||
boolean deleteTstaskByIds(List<String> dataset);
|
||||
/**********************************
|
||||
* 用途说明: 根据ID确认是否可以实验任务项目
|
||||
* 参数说明 id 试验数据管理ID
|
||||
* 返回值说明: com.yfd.platform.config.ResponseResult 返回删除成功或者失败
|
||||
***********************************/
|
||||
Object confirmDeleteTask(List<String> dataset);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.yfd.platform.modules.experimentalData.service.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
@ -611,9 +612,6 @@ public class TsNodesServiceImpl extends ServiceImpl<TsNodesMapper, TsNodes> impl
|
||||
for (TsNodes tsNodes : tsNodesList) {
|
||||
//删除文件表
|
||||
Boolean deleteTsFiles = tsFilesService.deleteTsFilesByNodeId(tsNodes.getNodeId(), tsNodes.getTaskId());
|
||||
|
||||
|
||||
//删除当前节点的文件夹 todo 这个地方改动
|
||||
// 删除 sdlocal 中的文件夹
|
||||
List<BatchDeleteRequest.DeleteItem> deleteItemList = new ArrayList<>();
|
||||
BatchDeleteRequest.DeleteItem deleteItemData = new BatchDeleteRequest.DeleteItem();
|
||||
@ -686,6 +684,41 @@ public class TsNodesServiceImpl extends ServiceImpl<TsNodesMapper, TsNodes> impl
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 根据ID确认是否可以实验任务项目
|
||||
* 参数说明 id 试验数据管理节点ID
|
||||
* 返回值说明: com.yfd.platform.config.ResponseResult 返回删除成功或者失败
|
||||
***********************************/
|
||||
@Override
|
||||
public Object confirmDeleteNodes(String id) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
TsNodes tsNodes = tsNodesMapper.selectById(id);
|
||||
if (tsNodes == null) {
|
||||
jsonObject.putOpt("status", "1");
|
||||
return ResponseResult.successData(jsonObject);
|
||||
}
|
||||
//递归查询所有的子节点
|
||||
List<TsNodes> tsNodesList = selectChildrentsNodes(tsNodes.getNodeId(), tsNodes.getTaskId());
|
||||
// 提取所有节点的 ID
|
||||
List<String> nodeIds = tsNodesList.stream()
|
||||
.map(TsNodes::getNodeId) // 获取每个节点的 ID
|
||||
.collect(Collectors.toList());
|
||||
|
||||
LambdaQueryWrapper<TsFiles> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(TsFiles::getTaskId, tsNodes.getTaskId())
|
||||
.in(TsFiles::getNodeId, nodeIds)
|
||||
.and(wrapper -> wrapper.isNotNull(TsFiles::getBackupPath)
|
||||
.or().ne(TsFiles::getBackupPath, ""));
|
||||
int count = tsFilesService.count(queryWrapper);
|
||||
//如果大于0不让删
|
||||
if (count > 0) {
|
||||
jsonObject.putOpt("status", "0");
|
||||
} else {
|
||||
jsonObject.putOpt("status", "1");
|
||||
}
|
||||
return ResponseResult.successData(jsonObject);
|
||||
}
|
||||
|
||||
private String testDataScanById(String id) throws Exception {
|
||||
|
||||
//查询试验任务信息
|
||||
|
@ -3,9 +3,12 @@ package com.yfd.platform.modules.experimentalData.service.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yfd.platform.config.ResponseResult;
|
||||
import com.yfd.platform.modules.experimentalData.domain.TsFiles;
|
||||
import com.yfd.platform.modules.experimentalData.domain.TsTask;
|
||||
import com.yfd.platform.modules.experimentalData.mapper.TsTaskMapper;
|
||||
import com.yfd.platform.modules.experimentalData.service.ITsFilesService;
|
||||
@ -54,6 +57,9 @@ public class TsTaskServiceImpl extends ServiceImpl<TsTaskMapper, TsTask> impleme
|
||||
@Resource
|
||||
private ITsNodesService tsNodesService;
|
||||
|
||||
@Resource
|
||||
private ITsFilesService tsFilesService;
|
||||
|
||||
@Resource
|
||||
private StorageSourceContext storageSourceContext;
|
||||
|
||||
@ -155,6 +161,14 @@ public class TsTaskServiceImpl extends ServiceImpl<TsTaskMapper, TsTask> impleme
|
||||
String taskName = buildTaskName(tsTask);
|
||||
tsTask.setTaskName(taskName);
|
||||
|
||||
|
||||
LambdaQueryWrapper<TsTask> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(TsTask::getTaskName,tsTask.getTaskName());
|
||||
TsTask tsTask1 = tsTaskMapper.selectOne(queryWrapper);
|
||||
if (tsTask1 != null){
|
||||
throw new RuntimeException("试验任务管理项目已存在!");
|
||||
}
|
||||
|
||||
// 设置当前时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
// 转换为 Timestamp
|
||||
@ -311,6 +325,29 @@ public class TsTaskServiceImpl extends ServiceImpl<TsTaskMapper, TsTask> impleme
|
||||
return value;
|
||||
}
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 根据ID确认是否可以实验任务项目
|
||||
* 参数说明 id 试验数据管理ID
|
||||
* 返回值说明: com.yfd.platform.config.ResponseResult 返回删除成功或者失败
|
||||
***********************************/
|
||||
@Override
|
||||
public Object confirmDeleteTask(List<String> dataset) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
// 删除 getBackupPath 和 getWorkPath 都为空的记录
|
||||
LambdaQueryWrapper<TsFiles> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(TsFiles::getTaskId, dataset)
|
||||
.and(wrapper -> wrapper.isNotNull(TsFiles::getBackupPath)
|
||||
.or().ne(TsFiles::getBackupPath, ""));
|
||||
int count = tsFilesService.count(queryWrapper);
|
||||
//如果大于0不让删
|
||||
if (count > 0) {
|
||||
jsonObject.putOpt("status", "0");
|
||||
} else {
|
||||
jsonObject.putOpt("status", "1");
|
||||
}
|
||||
return ResponseResult.successData(jsonObject);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public synchronized String generateNextTsTaskCode() {
|
||||
// 1. 使用悲观锁查询最大编号
|
||||
|
Loading…
Reference in New Issue
Block a user