fix(测试计划): 修复测试计划列表高级搜索问题

--bug=1048906 --user=王旭 【测试计划】-筛选-使用计划名称与其他条件组合筛选,筛选结果错误 https://www.tapd.cn/55049933/s/1611266
This commit is contained in:
WangXu10 2024-11-18 15:12:03 +08:00 committed by Craftsman
parent 9bedceefe2
commit eeda5334ce
3 changed files with 99 additions and 77 deletions

View File

@ -29,6 +29,7 @@ public class TestPlanTableRequest extends BasePageRequest {
@Schema(description = "通过其他条件查询出来的必须要包含的测试计划ID") @Schema(description = "通过其他条件查询出来的必须要包含的测试计划ID")
private List<String> innerIds; private List<String> innerIds;
private List<String> combineInnerIds; private List<String> combineInnerIds;
private String combineOperator;
@Schema(description = "是否我的待办, 默认查询全部") @Schema(description = "是否我的待办, 默认查询全部")
private boolean myTodo = false; private boolean myTodo = false;

View File

@ -137,7 +137,13 @@
</when> </when>
</choose>--> </choose>-->
<if test="request.combineInnerIds != null and request.combineInnerIds.size() > 0"> <if test="request.combineInnerIds != null and request.combineInnerIds.size() > 0">
and t.id in and t.id
<if test="request.combineOperator != 'NOT_IN'">
in
</if>
<if test="request.combineOperator == 'NOT_IN'">
not in
</if>
<foreach collection="request.combineInnerIds" item="id" open="(" separator="," close=")"> <foreach collection="request.combineInnerIds" item="id" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
@ -214,44 +220,50 @@
</include> </include>
</if> </if>
<if test="condition.name == 'name'"> <if test="condition.name == 'name'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition"> <trim prefix="(" suffix=")">
<property name="condition" value="condition"/>
<property name="column" value="t.name"/>
</include>
<if test="condition.operator == 'CONTAINS' or condition.operator == 'EQUALS'">
or t.id in
(
SELECT group_id
FROM test_plan
WHERE project_id = #{request.projectId}
AND
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="test_plan.name"/>
</include>
)
</if>
</if>
<if test="condition.name == 'num'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="t.num"/>
</include>
<if test="request.type != 'TEST_PLAN'" >
<if test="condition.operator == 'CONTAINS' or condition.operator == 'EQUALS'">
or t.id in
(
SELECT group_id
FROM test_plan
WHERE project_id = #{request.projectId}
AND
<include refid="io.metersphere.system.mapper.BaseMapper.condition"> <include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/> <property name="condition" value="condition"/>
<property name="column" value="test_plan.num"/> <property name="column" value="t.name"/>
</include> </include>
) <if test="request.type != 'TEST_PLAN'" >
<if test="condition.operator == 'CONTAINS' or condition.operator == 'EQUALS'">
or t.id in
(
SELECT group_id
FROM test_plan
WHERE project_id = #{request.projectId}
AND
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="test_plan.name"/>
</include>
)
</if>
</if> </if>
</if> </trim>
</if>
<if test="condition.name == 'num'">
<trim prefix="(" suffix=")">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="t.num"/>
</include>
<if test="request.type != 'TEST_PLAN'" >
<if test="condition.operator == 'CONTAINS' or condition.operator == 'EQUALS'">
or t.id in
(
SELECT group_id
FROM test_plan
WHERE project_id = #{request.projectId}
AND
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
<property name="column" value="test_plan.num"/>
</include>
)
</if>
</if>
</trim>
</if> </if>
<if test="condition.name == 'createUser'"> <if test="condition.name == 'createUser'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition"> <include refid="io.metersphere.system.mapper.BaseMapper.condition">
@ -278,31 +290,35 @@
</include> </include>
</if> </if>
<if test="condition.name == 'tags'"> <if test="condition.name == 'tags'">
<include refid="io.metersphere.system.mapper.BaseMapper.arrayValueCondition"> <trim prefix="(" suffix=")">
<property name="condition" value="condition"/>
<property name="column" value="t.tags"/>
</include>
<if test="condition.operator == 'CONTAINS'">
or t.id in
(
SELECT group_id
FROM test_plan
WHERE project_id = #{request.projectId}
AND
<include refid="io.metersphere.system.mapper.BaseMapper.arrayValueCondition"> <include refid="io.metersphere.system.mapper.BaseMapper.arrayValueCondition">
<property name="condition" value="condition"/> <property name="condition" value="condition"/>
<property name="column" value="test_plan.tags"/> <property name="column" value="t.tags"/>
</include> </include>
) <if test="request.type != 'TEST_PLAN'" >
</if> <if test="condition.operator == 'CONTAINS'">
or t.id in
(
SELECT group_id
FROM test_plan
WHERE project_id = #{request.projectId}
AND
<include refid="io.metersphere.system.mapper.BaseMapper.arrayValueCondition">
<property name="condition" value="condition"/>
<property name="column" value="test_plan.tags"/>
</include>
)
</if>
</if>
</trim>
</if> </if>
<!-- 状态 --> <!-- 状态 -->
<if test="condition.name == 'status'"> <if test="condition.name == 'status'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition"> status in
<property name="condition" value="condition"/> <foreach collection="condition.value" item="v" separator="," open="(" close=")">
<property name="column" value="t.status"/> #{v}
</include> </foreach>
</if> </if>
<include refid="io.metersphere.system.mapper.BaseMapper.queryType"> <include refid="io.metersphere.system.mapper.BaseMapper.queryType">
<property name="searchMode" value="${combineSearch}.searchMode"/> <property name="searchMode" value="${combineSearch}.searchMode"/>
@ -976,18 +992,20 @@
<property name="condition" value="condition"/> <property name="condition" value="condition"/>
<property name="column" value="t.name"/> <property name="column" value="t.name"/>
</include> </include>
<if test="condition.operator == 'CONTAINS' or condition.operator == 'EQUALS'"> <if test="request.type != 'TEST_PLAN'" >
or t.id in <if test="condition.operator == 'CONTAINS' or condition.operator == 'EQUALS'">
( or t.id in
SELECT group_id (
FROM test_plan SELECT group_id
WHERE project_id = #{request.projectId} FROM test_plan
AND WHERE project_id = #{request.projectId}
<include refid="io.metersphere.system.mapper.BaseMapper.condition"> AND
<property name="condition" value="condition"/> <include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="column" value="test_plan.name"/> <property name="condition" value="condition"/>
</include> <property name="column" value="test_plan.name"/>
) </include>
)
</if>
</if> </if>
</if> </if>
<if test="condition.name == 'num'"> <if test="condition.name == 'num'">
@ -1040,18 +1058,20 @@
<property name="condition" value="condition"/> <property name="condition" value="condition"/>
<property name="column" value="t.tags"/> <property name="column" value="t.tags"/>
</include> </include>
<if test="condition.operator == 'CONTAINS'"> <if test="request.type != 'TEST_PLAN'" >
or t.id in <if test="condition.operator == 'CONTAINS'">
( or t.id in
SELECT group_id (
FROM test_plan SELECT group_id
WHERE project_id = #{request.projectId} FROM test_plan
AND WHERE project_id = #{request.projectId}
<include refid="io.metersphere.system.mapper.BaseMapper.arrayValueCondition"> AND
<property name="condition" value="condition"/> <include refid="io.metersphere.system.mapper.BaseMapper.arrayValueCondition">
<property name="column" value="test_plan.tags"/> <property name="condition" value="condition"/>
</include> <property name="column" value="test_plan.tags"/>
) </include>
)
</if>
</if> </if>
</if> </if>
<!-- 状态 --> <!-- 状态 -->

View File

@ -202,6 +202,7 @@ public class TestPlanManagementService {
//目前未归档的测试计划只有3中类型所以这里判断如果是3个的话等于直接查询未归档 //目前未归档的测试计划只有3中类型所以这里判断如果是3个的话等于直接查询未归档
if (statusList.size() < 3) { if (statusList.size() < 3) {
request.setCombineInnerIds(this.selectTestPlanIdByProjectIdAndStatus(request.getProjectId(), statusList)); request.setCombineInnerIds(this.selectTestPlanIdByProjectIdAndStatus(request.getProjectId(), statusList));
request.setCombineOperator(item.getOperator());
} }
} }
}); });