fix(测试计划): 脑图批量关联&新增缺陷时未规划模块问题

This commit is contained in:
WangXu10 2024-09-04 15:14:04 +08:00 committed by Craftsman
parent d74d6bf190
commit c113036641
3 changed files with 30 additions and 11 deletions

View File

@ -82,4 +82,6 @@ public interface ExtTestPlanFunctionalCaseMapper {
List<FunctionalCaseModule> selectProjectByModuleIds(@Param("moduleIds") List<String> moduleIds);
Collection<String> selectIdsByModuleIds(@Param("request") TestPlanCaseMinderRequest request, @Param("minderModuleIds") List<String> minderModuleIds);
Collection<String> selectIdsByRootIds(@Param("rootIds") List<String> rootIds, @Param("testPlanId") String testPlanId);
}

View File

@ -688,14 +688,7 @@
FROM functional_case_module
WHERE id IN
<foreach collection="moduleIds" item="moduleId" separator="," open="(" close=")">
<choose>
<when test="moduleId.contains('_root')">
'root'
</when>
<otherwise>
#{moduleId}
</otherwise>
</choose>
#{moduleId}
</foreach>
</select>
@ -715,4 +708,20 @@
</foreach>
</select>
<select id="selectIdsByRootIds" resultType="java.lang.String">
SELECT
test_plan_functional_case.id
FROM
test_plan_functional_case
LEFT JOIN functional_case ON test_plan_functional_case.functional_case_id = functional_case.id
WHERE
functional_case.deleted = false
and test_plan_functional_case.test_plan_id = #{testPlanId}
and functional_case.project_id in
<foreach collection="rootIds" item="rootId" open="(" separator="," close=")">
#{rootId}
</foreach>
and functional_case.module_id = 'root'
</select>
</mapper>

View File

@ -9,6 +9,7 @@ import io.metersphere.plan.mapper.ExtTestPlanFunctionalCaseMapper;
import io.metersphere.system.dto.sdk.BaseTreeNode;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -61,6 +62,11 @@ public class TestPlanFunctionalCaseMinderService {
}
//模块
if (CollectionUtils.isNotEmpty(request.getMinderModuleIds())) {
//处理未规划用例
List<String> rootIds = ids.stream().filter(id -> StringUtils.endsWith(id, "_root")).map(id -> id.replace("_root", "")).toList();
if (CollectionUtils.isNotEmpty(rootIds)) {
ids.addAll(extTestPlanFunctionalCaseMapper.selectIdsByRootIds(rootIds, request.getTestPlanId()));
}
//获取模块及子模块
List<FunctionalCaseModule> modules = extTestPlanFunctionalCaseMapper.selectProjectByModuleIds(request.getMinderModuleIds());
Map<String, List<FunctionalCaseModule>> moduleMaps = modules.stream().collect(Collectors.groupingBy(FunctionalCaseModule::getProjectId));
@ -68,14 +74,16 @@ public class TestPlanFunctionalCaseMinderService {
moduleMaps.forEach((k, v) -> {
buildIdsByModule(k, v, minderModuleIds);
});
ids.addAll(extTestPlanFunctionalCaseMapper.selectIdsByModuleIds(request, minderModuleIds));
if (CollectionUtils.isNotEmpty(minderModuleIds)) {
ids.addAll(extTestPlanFunctionalCaseMapper.selectIdsByModuleIds(request, minderModuleIds));
}
}
//用例
if (CollectionUtils.isNotEmpty(request.getMinderCaseIds())) {
ids.addAll(request.getMinderCaseIds());
}
return ids;
//去重
return ids.stream().distinct().toList();
}
}