|
@@ -2,6 +2,7 @@ package com.css.simulation.resource.scheduler.manager;
|
|
|
|
|
|
import api.common.pojo.constants.DictConstants;
|
|
import api.common.pojo.constants.DictConstants;
|
|
import api.common.util.*;
|
|
import api.common.util.*;
|
|
|
|
+import com.css.simulation.resource.scheduler.mapper.AutoSubProjectMapper;
|
|
import com.css.simulation.resource.scheduler.mapper.IndexMapper;
|
|
import com.css.simulation.resource.scheduler.mapper.IndexMapper;
|
|
import com.css.simulation.resource.scheduler.mapper.ManualProjectMapper;
|
|
import com.css.simulation.resource.scheduler.mapper.ManualProjectMapper;
|
|
import com.css.simulation.resource.scheduler.mapper.TaskMapper;
|
|
import com.css.simulation.resource.scheduler.mapper.TaskMapper;
|
|
@@ -64,6 +65,8 @@ public class TaskManager {
|
|
@Resource
|
|
@Resource
|
|
ManualProjectMapper manualProjectMapper;
|
|
ManualProjectMapper manualProjectMapper;
|
|
@Resource
|
|
@Resource
|
|
|
|
+ AutoSubProjectMapper autoSubProjectMapper;
|
|
|
|
+ @Resource
|
|
KafkaTemplate<String, String> kafkaTemplate;
|
|
KafkaTemplate<String, String> kafkaTemplate;
|
|
@Resource
|
|
@Resource
|
|
TaskIndexManager taskIndexManager;
|
|
TaskIndexManager taskIndexManager;
|
|
@@ -155,8 +158,8 @@ public class TaskManager {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
String taskJson = stringRedisTemplate.opsForValue().get(taskMessageKey);
|
|
String taskJson = stringRedisTemplate.opsForValue().get(taskMessageKey);
|
|
|
|
+ log.info("TaskManager--retry 重试项目 " + projectId + " 的任务 " + taskId + ",重试次数为:" + retry + ",重新发送的消息为:" + taskJson);
|
|
retry++;
|
|
retry++;
|
|
- log.info("TaskService--retry 重试项目 " + projectId + " 的任务 " + taskId + ",重试次数为:" + retry + ",重新发送的消息为:" + taskJson);
|
|
|
|
stringRedisTemplate.opsForValue().set(taskRetryKey, retry + "");
|
|
stringRedisTemplate.opsForValue().set(taskRetryKey, retry + "");
|
|
kafkaTemplate.send(projectId, taskJson);
|
|
kafkaTemplate.send(projectId, taskJson);
|
|
return true;
|
|
return true;
|
|
@@ -172,10 +175,15 @@ public class TaskManager {
|
|
}
|
|
}
|
|
|
|
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
- public void score(PrefixTO redisPrefix, String userId, String projectId, ClientSession session) {
|
|
|
|
|
|
+ public void score(PrefixTO redisPrefix, String userId, String projectId, String projectType, ClientSession session) {
|
|
// -------------------------------- 打分 --------------------------------
|
|
// -------------------------------- 打分 --------------------------------
|
|
- ProjectPO projectPO = manualProjectMapper.selectById(projectId);
|
|
|
|
- String packageId = projectPO.getScenePackageId(); // 场景测试包 id,指标根 id
|
|
|
|
|
|
+ ProjectPO projectPO = null;
|
|
|
|
+ if (DictConstants.PROJECT_TYPE_MANUAL.equals(projectType)) {
|
|
|
|
+ projectPO = manualProjectMapper.selectById(projectId);
|
|
|
|
+ } else if (DictConstants.PROJECT_TYPE_AUTO_SUB.equals(projectType)) {
|
|
|
|
+ projectPO = autoSubProjectMapper.selectById(projectId);
|
|
|
|
+ }
|
|
|
|
+ String packageId = projectPO.getScenePackageId(); // 场景测试包 id,指标的rootId
|
|
List<TaskPO> taskList = taskMapper.selectTaskListByProjectId(projectId); // 所有任务信息
|
|
List<TaskPO> taskList = taskMapper.selectTaskListByProjectId(projectId); // 所有任务信息
|
|
if (CollectionUtil.isEmpty(taskList)) {
|
|
if (CollectionUtil.isEmpty(taskList)) {
|
|
log.error("TaskManager--score 项目 " + projectId + " 下没有查询到任务!");
|
|
log.error("TaskManager--score 项目 " + projectId + " 下没有查询到任务!");
|
|
@@ -212,7 +220,7 @@ public class TaskManager {
|
|
List<TaskPO> taskListOfLeafIndex = taskList.stream()
|
|
List<TaskPO> taskListOfLeafIndex = taskList.stream()
|
|
.filter(task -> indexId.equals(task.getLastTargetId()))
|
|
.filter(task -> indexId.equals(task.getLastTargetId()))
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
- log.info("TaskService--state 叶子节点 " + indexId + " 包括 " + taskListOfLeafIndex.size() + " 个成功运行结束任务!");
|
|
|
|
|
|
+ log.info("TaskService--state 叶子节点 " + indexId + " 包括 " + taskListOfLeafIndex.size() + " 个任务!");
|
|
// 计算叶子指标的得分
|
|
// 计算叶子指标的得分
|
|
taskListOfLeafIndex.forEach(taskOfLeaf -> {
|
|
taskListOfLeafIndex.forEach(taskOfLeaf -> {
|
|
String task2Id = taskOfLeaf.getId();
|
|
String task2Id = taskOfLeaf.getId();
|