fix(测试跟踪): 测试计划跨项目关联用例执行人为空

--bug=1016158 --user=陈建星 【测试跟踪】测试计划关联功能用例,关联完执行人是空 https://www.tapd.cn/55049933/s/1231757
This commit is contained in:
AnAngle 2022-08-23 19:27:15 +08:00 committed by jianxing
parent 89c64b8c02
commit 8f2384119c

View File

@ -545,6 +545,8 @@ public class TestPlanService {
public void testPlanRelevance(PlanCaseRelevanceRequest request) {
LinkedHashMap<String, String> userMap;
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId());
boolean isSelectAll = request.getRequest() != null && request.getRequest().isSelectAll();
if (isSelectAll) {
List<TestCase> maintainerMap = extTestCaseMapper.getMaintainerMap(request.getRequest());
@ -558,6 +560,11 @@ public class TestPlanService {
.collect(LinkedHashMap::new, (m, v) -> m.put(v.getId(), v.getMaintainer()), LinkedHashMap::putAll);
}
Set<String> projectMemberSet = userService.getProjectMemberOption(testPlan.getProjectId())
.stream()
.map(User::getId)
.collect(Collectors.toSet());
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
TestPlanTestCaseMapper batchMapper = sqlSession.getMapper(TestPlanTestCaseMapper.class);
@ -580,7 +587,10 @@ public class TestPlanService {
TestPlanTestCaseWithBLOBs testPlanTestCase = new TestPlanTestCaseWithBLOBs();
testPlanTestCase.setId(UUID.randomUUID().toString());
testPlanTestCase.setCreateUser(SessionUtils.getUserId());
String maintainer = Optional.ofNullable(userMap.get(caseId)).orElse(SessionUtils.getUserId());
String maintainer = userMap.get(caseId);
if (StringUtils.isBlank(maintainer) || !projectMemberSet.contains(maintainer)) {
maintainer = SessionUtils.getUserId();
}
testPlanTestCase.setExecutor(maintainer);
testPlanTestCase.setCaseId(caseId);
testPlanTestCase.setCreateTime(System.currentTimeMillis());
@ -597,7 +607,6 @@ public class TestPlanService {
caseTestRelevance(request, testCaseIds);
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId());
if (StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Prepare.name())
|| StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Completed.name())) {
testPlan.setStatus(TestPlanStatus.Underway.name());