fix(测试计划): 批量串行执行顺序有误

This commit is contained in:
AgAngle 2024-06-16 15:21:11 +08:00 committed by jianxing
parent 8419fe6aa6
commit dd1e5619e3
2 changed files with 26 additions and 2 deletions

View File

@ -62,6 +62,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service
@ -488,7 +489,18 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
} else {
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
example.createCriteria().andIdIn(request.getSelectIds());
return testPlanApiCaseMapper.selectByExample(example);
Map<String, TestPlanApiCase> testPlanApiCaseMap = testPlanApiCaseMapper.selectByExample(example)
.stream()
.collect(Collectors.toMap(TestPlanApiCase::getId, Function.identity()));
List<TestPlanApiCase> testPlanApiCases = new ArrayList<>(request.getSelectIds().size());
// 按ID的顺序排序
for (String id : request.getSelectIds()) {
TestPlanApiCase testPlanApiCase = testPlanApiCaseMap.get(id);
if (testPlanApiCase != null) {
testPlanApiCases.add(testPlanApiCase);
}
}
return testPlanApiCases;
}
}

View File

@ -63,6 +63,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service
@ -654,7 +655,18 @@ public class TestPlanApiScenarioService extends TestPlanResourceService {
} else {
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
example.createCriteria().andIdIn(request.getSelectIds());
return testPlanApiScenarioMapper.selectByExample(example);
Map<String, TestPlanApiScenario> testPlanApiScenarioMap = testPlanApiScenarioMapper.selectByExample(example)
.stream()
.collect(Collectors.toMap(TestPlanApiScenario::getId, Function.identity()));
List<TestPlanApiScenario> testPlanApiScenarios = new ArrayList<>(request.getSelectIds().size());
// 按ID的顺序排序
for (String id : request.getSelectIds()) {
TestPlanApiScenario testPlanApiScenario = testPlanApiScenarioMap.get(id);
if (testPlanApiScenario != null) {
testPlanApiScenarios.add(testPlanApiScenario);
}
}
return testPlanApiScenarios;
}
}
}