fix(测试跟踪): 修复测试计划场景使用环境组时执行测试计划所选环境不对的问题
--bug=1015251 --user=宋天阳 【测试跟踪】多次切换环境后,在测试计划详情里和报告列表查看测试报告,显示的环境不一样 https://www.tapd.cn/55049933/s/1209606
This commit is contained in:
parent
ff61886ea9
commit
50d33f9521
|
@ -3,327 +3,359 @@
|
||||||
<mapper namespace="io.metersphere.base.mapper.ext.ExtTestPlanScenarioCaseMapper">
|
<mapper namespace="io.metersphere.base.mapper.ext.ExtTestPlanScenarioCaseMapper">
|
||||||
|
|
||||||
|
|
||||||
<insert id="insertIfNotExists" parameterType="io.metersphere.base.domain.TestPlanApiScenario">
|
<insert id="insertIfNotExists" parameterType="io.metersphere.base.domain.TestPlanApiScenario">
|
||||||
-- 查询没有数据再插入
|
-- 查询没有数据再插入
|
||||||
INSERT INTO test_plan_api_scenario(id, test_plan_id, api_scenario_id, create_time, update_time, environment, `order`, environment_group_id, environment_type)
|
INSERT INTO test_plan_api_scenario(id, test_plan_id, api_scenario_id, create_time, update_time, environment,
|
||||||
SELECT #{request.id}, #{request.testPlanId}, #{request.apiScenarioId}, #{request.createTime}, #{request.updateTime}, #{request.environment}, #{request.order}, #{request.environmentGroupId}, #{request.environmentType}
|
`order`, environment_group_id, environment_type)
|
||||||
FROM DUAL
|
SELECT #{request.id},
|
||||||
WHERE NOT EXISTS(
|
#{request.testPlanId},
|
||||||
SELECT id FROM
|
#{request.apiScenarioId},
|
||||||
test_plan_api_scenario
|
#{request.createTime},
|
||||||
WHERE test_plan_id = #{request.testPlanId} and api_scenario_id = #{request.apiScenarioId}
|
#{request.updateTime},
|
||||||
)
|
#{request.environment},
|
||||||
</insert>
|
#{request.order},
|
||||||
|
#{request.environmentGroupId},
|
||||||
|
#{request.environmentType}
|
||||||
|
FROM DUAL
|
||||||
|
WHERE NOT EXISTS(
|
||||||
|
SELECT id
|
||||||
|
FROM test_plan_api_scenario
|
||||||
|
WHERE test_plan_id = #{request.testPlanId}
|
||||||
|
and api_scenario_id = #{request.apiScenarioId}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
<select id="selectLegalDataByTestPlanId" resultType="io.metersphere.track.dto.testplan.TestPlanApiScenarioInfoDTO">
|
<select id="selectLegalDataByTestPlanId" resultType="io.metersphere.track.dto.testplan.TestPlanApiScenarioInfoDTO">
|
||||||
SELECT tpas.id, tpas.api_scenario_id,tpas.environment,apis.project_id FROM
|
SELECT tpas.id,
|
||||||
test_plan_api_scenario tpas INNER JOIN api_scenario apis ON tpas.api_scenario_id = apis.id
|
tpas.api_scenario_id,
|
||||||
WHERE (apis.`status` IS NULL OR apis.`status` != 'Trash')
|
tpas.environment,
|
||||||
AND tpas.test_plan_id = #{0}
|
tpas.environment_type,
|
||||||
ORDER BY tpas.`order` DESC;
|
tpas.environment_group_id,
|
||||||
</select>
|
apis.project_id
|
||||||
|
FROM test_plan_api_scenario tpas
|
||||||
|
INNER JOIN api_scenario apis ON tpas.api_scenario_id = apis.id
|
||||||
|
WHERE (apis.`status` IS NULL OR apis.`status` != 'Trash')
|
||||||
|
AND tpas.test_plan_id = #{0}
|
||||||
|
ORDER BY tpas.`order` DESC;
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="list" resultType="io.metersphere.api.dto.automation.ApiScenarioDTO">
|
<select id="list" resultType="io.metersphere.api.dto.automation.ApiScenarioDTO">
|
||||||
SELECT
|
SELECT
|
||||||
t.id,
|
t.id,
|
||||||
t.environment,
|
t.environment,
|
||||||
t.create_time,
|
t.create_time,
|
||||||
t.update_time,
|
t.update_time,
|
||||||
t.last_result,
|
t.last_result,
|
||||||
t.pass_rate,
|
t.pass_rate,
|
||||||
t.report_id,
|
t.report_id,
|
||||||
c.scenario_definition,
|
c.scenario_definition,
|
||||||
c.id AS case_id,
|
c.id AS case_id,
|
||||||
c.user_id,
|
c.user_id,
|
||||||
c.api_scenario_module_id,
|
c.api_scenario_module_id,
|
||||||
c.module_path,
|
c.module_path,
|
||||||
c. NAME,
|
c. NAME,
|
||||||
c. LEVEL,
|
c. LEVEL,
|
||||||
c. STATUS,
|
c. STATUS,
|
||||||
c.principal,
|
c.principal,
|
||||||
c.step_total,
|
c.step_total,
|
||||||
c. SCHEDULE,
|
c. SCHEDULE,
|
||||||
c.description,
|
c.description,
|
||||||
c.tags,
|
c.tags,
|
||||||
c.create_user,
|
c.create_user,
|
||||||
c.project_id,
|
c.project_id,
|
||||||
c.num,
|
c.num,
|
||||||
c.custom_num,
|
c.custom_num,
|
||||||
t.environment_group_id,
|
t.environment_group_id,
|
||||||
t.environment_type,
|
t.environment_type,
|
||||||
project_version. NAME versionName,
|
project_version. NAME versionName,
|
||||||
project_version.id versionId
|
project_version.id versionId
|
||||||
FROM
|
FROM
|
||||||
test_plan_api_scenario t
|
test_plan_api_scenario t
|
||||||
INNER JOIN api_scenario c ON t.api_scenario_id = c.id
|
INNER JOIN api_scenario c ON t.api_scenario_id = c.id
|
||||||
INNER JOIN project_version ON c.project_id = project_version.project_id
|
INNER JOIN project_version ON c.project_id = project_version.project_id
|
||||||
AND c.version_id = project_version.id
|
AND c.version_id = project_version.id
|
||||||
AND c. STATUS != 'Trash'
|
AND c. STATUS != 'Trash'
|
||||||
<if test="request.planId != null and request.planId!=''">
|
<if test="request.planId != null and request.planId!=''">
|
||||||
and t.test_plan_id = #{request.planId}
|
and t.test_plan_id = #{request.planId}
|
||||||
</if>
|
</if>
|
||||||
WHERE 1
|
WHERE 1
|
||||||
<include refid="queryVersionCondition">
|
<include refid="queryVersionCondition">
|
||||||
<property name="versionTable" value="c"/>
|
<property name="versionTable" value="c"/>
|
||||||
</include>
|
</include>
|
||||||
|
|
||||||
<if test="request.scenarioIds != null and request.scenarioIds.size() > 0">
|
<if test="request.scenarioIds != null and request.scenarioIds.size() > 0">
|
||||||
and c.id in
|
and c.id in
|
||||||
<foreach collection="request.scenarioIds" item="caseId" separator="," open="(" close=")">
|
<foreach collection="request.scenarioIds" item="caseId" separator="," open="(" close=")">
|
||||||
#{caseId}
|
#{caseId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="request.ids != null and request.ids.size() > 0">
|
<if test="request.ids != null and request.ids.size() > 0">
|
||||||
<if test="request.projectId != null and request.projectId!=''">
|
<if test="request.projectId != null and request.projectId!=''">
|
||||||
and c.project_id = #{request.projectId}
|
and c.project_id = #{request.projectId}
|
||||||
</if>
|
</if>
|
||||||
and t.id in
|
and t.id in
|
||||||
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
|
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
|
||||||
#{caseId}
|
#{caseId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="request.name != null and request.name!=''">
|
<if test="request.name != null and request.name!=''">
|
||||||
and (c.name like CONCAT('%', #{request.name},'%')
|
and (c.name like CONCAT('%', #{request.name},'%')
|
||||||
or c.num like CONCAT('%', #{request.name},'%')
|
or c.num like CONCAT('%', #{request.name},'%')
|
||||||
or c.custom_num like CONCAT('%', #{request.name},'%')
|
or c.custom_num like CONCAT('%', #{request.name},'%')
|
||||||
or c.tags like CONCAT('%', #{request.name},'%'))
|
or c.tags like CONCAT('%', #{request.name},'%'))
|
||||||
</if>
|
|
||||||
<if test="request.status != null and request.status!=''">
|
|
||||||
and t.last_result like CONCAT('%', #{request.status},'%')
|
|
||||||
</if>
|
|
||||||
|
|
||||||
|
|
||||||
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
|
|
||||||
and c.api_scenario_module_id in
|
|
||||||
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
|
|
||||||
#{nodeId}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
|
|
||||||
<include refid="filters"/>
|
|
||||||
<if test="request.orders != null and request.orders.size() > 0">
|
|
||||||
order by
|
|
||||||
<foreach collection="request.orders" separator="," item="order">
|
|
||||||
<choose>
|
|
||||||
<when test="order.name == 'update_time' or order.name == 'order'">
|
|
||||||
t.${order.name} ${order.type}
|
|
||||||
</when>
|
|
||||||
<otherwise>
|
|
||||||
${order.name} ${order.type}
|
|
||||||
</otherwise>
|
|
||||||
</choose>
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectByIds" resultType="io.metersphere.base.domain.TestPlanApiScenario">
|
|
||||||
select t.* from test_plan_api_scenario t where t.id in (${ids}) ORDER BY FIND_IN_SET(t.id,${oderId})
|
|
||||||
</select>
|
|
||||||
<select id="selectIds" resultType="java.lang.String">
|
|
||||||
select
|
|
||||||
t.id
|
|
||||||
from
|
|
||||||
test_plan_api_scenario t
|
|
||||||
inner join
|
|
||||||
api_scenario c
|
|
||||||
on t.api_scenario_id = c.id and c.status != 'Trash'
|
|
||||||
<if test="request.planId != null and request.planId!=''">
|
|
||||||
and t.test_plan_id = #{request.planId}
|
|
||||||
</if>
|
|
||||||
left join project p
|
|
||||||
on c.project_id = p.id
|
|
||||||
left join user u
|
|
||||||
on c.user_id = u.id
|
|
||||||
where 1
|
|
||||||
<if test="request.ids != null and request.ids.size() > 0">
|
|
||||||
<if test="request.projectId != null and request.projectId!=''">
|
|
||||||
and
|
|
||||||
</if>
|
|
||||||
t.id in
|
|
||||||
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
|
|
||||||
#{caseId}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="request.name != null and request.name!=''">
|
|
||||||
and (c.name like CONCAT('%', #{request.name},'%')
|
|
||||||
or c.num like CONCAT('%', #{request.name},'%')
|
|
||||||
or c.tags like CONCAT('%', #{request.name},'%'))
|
|
||||||
</if>
|
|
||||||
<if test="request.status != null and request.status!=''">
|
|
||||||
and t.last_result like CONCAT('%', #{request.status},'%')
|
|
||||||
</if>
|
|
||||||
|
|
||||||
|
|
||||||
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
|
|
||||||
and c.api_scenario_module_id in
|
|
||||||
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
|
|
||||||
#{nodeId}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<include refid="filters"/>
|
|
||||||
<if test="request.orders != null and request.orders.size() > 0">
|
|
||||||
order by
|
|
||||||
<foreach collection="request.orders" separator="," item="order">
|
|
||||||
<choose>
|
|
||||||
<when test="order.name == 'update_time' or order.name == 'order'">
|
|
||||||
t.${order.name} ${order.type}
|
|
||||||
</when>
|
|
||||||
<otherwise>
|
|
||||||
${order.name} ${order.type}
|
|
||||||
</otherwise>
|
|
||||||
</choose>
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<sql id="filters">
|
|
||||||
<if test="request.filters != null and request.filters.size() > 0">
|
|
||||||
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
|
||||||
<if test="values != null and values.size() > 0">
|
|
||||||
<choose>
|
|
||||||
<when test="key == 'level'">
|
|
||||||
and c.level in
|
|
||||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
|
||||||
#{value}
|
|
||||||
</foreach>
|
|
||||||
</when>
|
|
||||||
<when test="key == 'last_result'">
|
|
||||||
and c.last_result in
|
|
||||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
|
||||||
#{value}
|
|
||||||
</foreach>
|
|
||||||
</when>
|
|
||||||
<when test="key == 'version_id'">
|
|
||||||
and c.version_id in
|
|
||||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
|
||||||
#{value}
|
|
||||||
</foreach>
|
|
||||||
</when>
|
|
||||||
</choose>
|
|
||||||
</if>
|
</if>
|
||||||
</foreach>
|
<if test="request.status != null and request.status!=''">
|
||||||
</if>
|
and t.last_result like CONCAT('%', #{request.status},'%')
|
||||||
</sql>
|
</if>
|
||||||
|
|
||||||
|
|
||||||
|
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
|
||||||
|
and c.api_scenario_module_id in
|
||||||
|
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
|
||||||
|
#{nodeId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<include refid="filters"/>
|
||||||
|
<if test="request.orders != null and request.orders.size() > 0">
|
||||||
|
order by
|
||||||
|
<foreach collection="request.orders" separator="," item="order">
|
||||||
|
<choose>
|
||||||
|
<when test="order.name == 'update_time' or order.name == 'order'">
|
||||||
|
t.${order.name} ${order.type}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
${order.name} ${order.type}
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByIds" resultType="io.metersphere.base.domain.TestPlanApiScenario">
|
||||||
|
select t.*
|
||||||
|
from test_plan_api_scenario t
|
||||||
|
where t.id in (${ids})
|
||||||
|
ORDER BY FIND_IN_SET(t.id, ${oderId})
|
||||||
|
</select>
|
||||||
|
<select id="selectIds" resultType="java.lang.String">
|
||||||
|
select
|
||||||
|
t.id
|
||||||
|
from
|
||||||
|
test_plan_api_scenario t
|
||||||
|
inner join
|
||||||
|
api_scenario c
|
||||||
|
on t.api_scenario_id = c.id and c.status != 'Trash'
|
||||||
|
<if test="request.planId != null and request.planId!=''">
|
||||||
|
and t.test_plan_id = #{request.planId}
|
||||||
|
</if>
|
||||||
|
left join project p
|
||||||
|
on c.project_id = p.id
|
||||||
|
left join user u
|
||||||
|
on c.user_id = u.id
|
||||||
|
where 1
|
||||||
|
<if test="request.ids != null and request.ids.size() > 0">
|
||||||
|
<if test="request.projectId != null and request.projectId!=''">
|
||||||
|
and
|
||||||
|
</if>
|
||||||
|
t.id in
|
||||||
|
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
|
||||||
|
#{caseId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="request.name != null and request.name!=''">
|
||||||
|
and (c.name like CONCAT('%', #{request.name},'%')
|
||||||
|
or c.num like CONCAT('%', #{request.name},'%')
|
||||||
|
or c.tags like CONCAT('%', #{request.name},'%'))
|
||||||
|
</if>
|
||||||
|
<if test="request.status != null and request.status!=''">
|
||||||
|
and t.last_result like CONCAT('%', #{request.status},'%')
|
||||||
|
</if>
|
||||||
|
|
||||||
|
|
||||||
|
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
|
||||||
|
and c.api_scenario_module_id in
|
||||||
|
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
|
||||||
|
#{nodeId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<include refid="filters"/>
|
||||||
|
<if test="request.orders != null and request.orders.size() > 0">
|
||||||
|
order by
|
||||||
|
<foreach collection="request.orders" separator="," item="order">
|
||||||
|
<choose>
|
||||||
|
<when test="order.name == 'update_time' or order.name == 'order'">
|
||||||
|
t.${order.name} ${order.type}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
${order.name} ${order.type}
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<sql id="filters">
|
||||||
|
<if test="request.filters != null and request.filters.size() > 0">
|
||||||
|
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
||||||
|
<if test="values != null and values.size() > 0">
|
||||||
|
<choose>
|
||||||
|
<when test="key == 'level'">
|
||||||
|
and c.level in
|
||||||
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
|
#{value}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
<when test="key == 'last_result'">
|
||||||
|
and c.last_result in
|
||||||
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
|
#{value}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
<when test="key == 'version_id'">
|
||||||
|
and c.version_id in
|
||||||
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
|
#{value}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
</choose>
|
||||||
|
</if>
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
|
|
||||||
<select id="getExecResultByPlanId" resultType="java.lang.String">
|
<select id="getExecResultByPlanId" resultType="java.lang.String">
|
||||||
select last_result
|
select last_result
|
||||||
from
|
from test_plan_api_scenario
|
||||||
test_plan_api_scenario
|
where test_plan_id = #{planId}
|
||||||
where test_plan_id = #{planId}
|
AND api_scenario_id in (SELECT id FROM api_scenario WHERE (`status` is null or `status` != 'Trash'))
|
||||||
AND api_scenario_id in (SELECT id FROM api_scenario WHERE (`status` is null or `status` != 'Trash'))
|
|
||||||
</select>
|
</select>
|
||||||
<select id="getIdsByPlanId" resultType="java.lang.String">
|
<select id="getIdsByPlanId" resultType="java.lang.String">
|
||||||
select id
|
select id
|
||||||
from test_plan_api_scenario
|
from test_plan_api_scenario
|
||||||
where test_plan_id = #{planId}
|
where test_plan_id = #{planId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getNotRelevanceCaseIds" resultType="java.lang.String">
|
<select id="getNotRelevanceCaseIds" resultType="java.lang.String">
|
||||||
select t.id
|
select t.id
|
||||||
from test_plan_api_scenario t
|
from test_plan_api_scenario t
|
||||||
inner join api_scenario c
|
inner join api_scenario c
|
||||||
on c.id = t.api_scenario_id
|
on c.id = t.api_scenario_id
|
||||||
<if test="relevanceProjectIds != null and relevanceProjectIds.size() > 0">
|
<if test="relevanceProjectIds != null and relevanceProjectIds.size() > 0">
|
||||||
and c.project_id not in
|
and c.project_id not in
|
||||||
<foreach collection="relevanceProjectIds" item="projectId" separator="," open="(" close=")">
|
<foreach collection="relevanceProjectIds" item="projectId" separator="," open="(" close=")">
|
||||||
#{projectId}
|
#{projectId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
where t.test_plan_id = #{planId}
|
where t.test_plan_id = #{planId}
|
||||||
</select>
|
</select>
|
||||||
<select id="selectForPlanReport" resultType="io.metersphere.track.dto.PlanReportCaseDTO">
|
<select id="selectForPlanReport" resultType="io.metersphere.track.dto.PlanReportCaseDTO">
|
||||||
select id,last_result as status, report_id, api_scenario_id as caseId from test_plan_api_scenario where test_plan_id = #{planId}
|
select id, last_result as status, report_id, api_scenario_id as caseId
|
||||||
and api_scenario_id IN (
|
from test_plan_api_scenario
|
||||||
SELECT id FROM api_scenario where status is null or status != 'Trash'
|
where test_plan_id = #{planId}
|
||||||
)
|
and api_scenario_id IN (
|
||||||
|
SELECT id
|
||||||
|
FROM api_scenario
|
||||||
|
where status is null
|
||||||
|
or status
|
||||||
|
!= 'Trash'
|
||||||
|
)
|
||||||
</select>
|
</select>
|
||||||
<select id="getFailureList" resultType="io.metersphere.api.dto.automation.TestPlanFailureScenarioDTO">
|
<select id="getFailureList" resultType="io.metersphere.api.dto.automation.TestPlanFailureScenarioDTO">
|
||||||
select
|
select
|
||||||
t.id, t.last_result, t.report_id, c.user_id, c.module_path, c.name, c.level,c.create_user,c.principal,
|
t.id, t.last_result, t.report_id, c.user_id, c.module_path, c.name, c.level,c.create_user,c.principal,
|
||||||
c.status,c.step_total, c.step_total, c.project_id,
|
c.status,c.step_total, c.step_total, c.project_id,
|
||||||
c.num, c.custom_num
|
c.num, c.custom_num
|
||||||
from
|
from
|
||||||
test_plan_api_scenario t
|
test_plan_api_scenario t
|
||||||
inner join
|
inner join
|
||||||
api_scenario c
|
api_scenario c
|
||||||
on t.api_scenario_id = c.id and (c.status != 'Trash' or c.status is null)
|
on t.api_scenario_id = c.id and (c.status != 'Trash' or c.status is null)
|
||||||
and t.test_plan_id = #{planId}
|
and t.test_plan_id = #{planId}
|
||||||
<if test="status != null and status != 'Fail' and status != 'unExecute'">
|
<if test="status != null and status != 'Fail' and status != 'unExecute'">
|
||||||
and t.last_result = #{status}
|
and t.last_result = #{status}
|
||||||
</if>
|
</if>
|
||||||
<if test="status == 'unExecute'">
|
<if test="status == 'unExecute'">
|
||||||
and (t.last_result in ('Stop','unExecute') or t.last_result IS NULL)
|
and (t.last_result in ('Stop','unExecute') or t.last_result IS NULL)
|
||||||
</if>
|
</if>
|
||||||
<if test="status == 'Fail'">
|
<if test="status == 'Fail'">
|
||||||
and t.last_result in ('Fail','Error')
|
and t.last_result in ('Fail','Error')
|
||||||
</if>
|
</if>
|
||||||
where t.test_plan_id = #{planId}
|
where t.test_plan_id = #{planId}
|
||||||
ORDER BY t.order DESC
|
ORDER BY t.order DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getFailureListByIds" resultType="io.metersphere.api.dto.automation.TestPlanFailureScenarioDTO">
|
<select id="getFailureListByIds" resultType="io.metersphere.api.dto.automation.TestPlanFailureScenarioDTO">
|
||||||
select
|
select
|
||||||
t.id, t.last_result, t.report_id, c.user_id, c.module_path, c.name, c.level,c.create_user,c.principal,
|
t.id, t.last_result, t.report_id, c.user_id, c.module_path, c.name, c.level,c.create_user,c.principal,
|
||||||
c.status,c.step_total, c.step_total, c.project_id,
|
c.status,c.step_total, c.step_total, c.project_id,
|
||||||
c.num, c.custom_num
|
c.num, c.custom_num
|
||||||
from
|
from
|
||||||
test_plan_api_scenario t
|
test_plan_api_scenario t
|
||||||
inner join
|
inner join
|
||||||
api_scenario c
|
api_scenario c
|
||||||
on t.api_scenario_id = c.id and c.status != 'Trash'
|
on t.api_scenario_id = c.id and c.status != 'Trash'
|
||||||
<if test="status != null">
|
<if test="status != null">
|
||||||
and t.last_result = 'Fail'
|
and t.last_result = 'Fail'
|
||||||
</if>
|
</if>
|
||||||
where t.id IN
|
where t.id IN
|
||||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
ORDER BY t.order DESC
|
ORDER BY t.order DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getUnderwaySteps" resultType="java.lang.Integer">
|
<select id="getUnderwaySteps" resultType="java.lang.Integer">
|
||||||
select step_total from api_scenario c
|
select step_total from api_scenario c
|
||||||
where c.id in
|
where c.id in
|
||||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getProjectIdById" resultType="java.lang.String">
|
<select id="getProjectIdById" resultType="java.lang.String">
|
||||||
SELECT project_id FROM test_plan WHERE id in (
|
SELECT project_id
|
||||||
SELECT test_plan_id FROM test_plan_api_scenario WHERE id = #{0}
|
FROM test_plan
|
||||||
)
|
WHERE id in (
|
||||||
</select>
|
SELECT test_plan_id
|
||||||
|
FROM test_plan_api_scenario
|
||||||
|
WHERE id = #{0}
|
||||||
|
)
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectPlanIds" resultType="java.lang.String">
|
<select id="selectPlanIds" resultType="java.lang.String">
|
||||||
select DISTINCT test_plan_id from test_plan_api_scenario;
|
select DISTINCT test_plan_id
|
||||||
</select>
|
from test_plan_api_scenario;
|
||||||
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
|
</select>
|
||||||
select id from test_plan_api_scenario where test_plan_id = #{planId} order by update_time ASC;
|
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
|
||||||
</select>
|
select id
|
||||||
|
from test_plan_api_scenario
|
||||||
|
where test_plan_id = #{planId}
|
||||||
|
order by update_time ASC;
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="getLastOrder" resultType="java.lang.Long">
|
<select id="getLastOrder" resultType="java.lang.Long">
|
||||||
select `order` from test_plan_api_scenario where test_plan_id = #{planId}
|
select `order` from test_plan_api_scenario where test_plan_id = #{planId}
|
||||||
<if test="baseOrder != null">
|
<if test="baseOrder != null">
|
||||||
and `order` > #{baseOrder}
|
and `order` > #{baseOrder}
|
||||||
</if>
|
</if>
|
||||||
order by `order` desc limit 1;
|
order by `order` desc limit 1;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getPreOrder" resultType="java.lang.Long">
|
<select id="getPreOrder" resultType="java.lang.Long">
|
||||||
select `order` from test_plan_api_scenario where test_plan_id = #{planId}
|
select `order` from test_plan_api_scenario where test_plan_id = #{planId}
|
||||||
<if test="baseOrder != null">
|
<if test="baseOrder != null">
|
||||||
and `order` < #{baseOrder}
|
and `order` < #{baseOrder}
|
||||||
</if>
|
</if>
|
||||||
order by `order` desc limit 1;
|
order by `order` desc limit 1;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<sql id="queryVersionCondition">
|
<sql id="queryVersionCondition">
|
||||||
<if test="request.versionId != null">
|
<if test="request.versionId != null">
|
||||||
and ${versionTable}.version_id = #{request.versionId}
|
and ${versionTable}.version_id = #{request.versionId}
|
||||||
</if>
|
</if>
|
||||||
<if test="request.refId != null">
|
<if test="request.refId != null">
|
||||||
and ${versionTable}.ref_id = #{request.refId}
|
and ${versionTable}.ref_id = #{request.refId}
|
||||||
</if>
|
</if>
|
||||||
</sql>
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -10,4 +10,6 @@ public class TestPlanApiScenarioInfoDTO {
|
||||||
private String apiScenarioId;
|
private String apiScenarioId;
|
||||||
private String environment;
|
private String environment;
|
||||||
private String projectId;
|
private String projectId;
|
||||||
|
private String environmentType;
|
||||||
|
private String environmentGroupId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,19 +299,25 @@ public class TestPlanReportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TestPlanApiScenarioInfoDTO model : testPlanApiScenarioList) {
|
for (TestPlanApiScenarioInfoDTO model : testPlanApiScenarioList) {
|
||||||
if (MapUtils.isNotEmpty(selectEnvMap) && selectEnvMap.containsKey(model.getProjectId())) {
|
Map<String, String> envMap = null;
|
||||||
runInfoDTO.putScenarioRunInfo(model.getId(), model.getProjectId(), selectEnvMap.get(model.getProjectId()));
|
if (StringUtils.equalsIgnoreCase("group", model.getEnvironmentType()) && StringUtils.isNotEmpty(model.getEnvironmentGroupId())) {
|
||||||
} else if (StringUtils.isNotEmpty(model.getEnvironment())) {
|
envMap = environmentGroupProjectService.getEnvMap(model.getEnvironmentGroupId());
|
||||||
try {
|
} else {
|
||||||
Map<String, String> envMap = JSONObject.parseObject(model.getEnvironment(), Map.class);
|
if (MapUtils.isNotEmpty(selectEnvMap) && selectEnvMap.containsKey(model.getProjectId())) {
|
||||||
if (MapUtils.isNotEmpty(envMap)) {
|
runInfoDTO.putScenarioRunInfo(model.getId(), model.getProjectId(), selectEnvMap.get(model.getProjectId()));
|
||||||
for (Map.Entry<String, String> entry : envMap.entrySet()) {
|
} else if (StringUtils.isNotEmpty(model.getEnvironment())) {
|
||||||
String projectId = entry.getKey();
|
try {
|
||||||
String envIdStr = entry.getValue();
|
envMap = JSONObject.parseObject(model.getEnvironment(), Map.class);
|
||||||
runInfoDTO.putScenarioRunInfo(model.getId(), projectId, envIdStr);
|
} catch (Exception e) {
|
||||||
}
|
LogUtil.error("解析场景环境失败!", e);
|
||||||
}
|
}
|
||||||
} catch (Exception ignore) {
|
}
|
||||||
|
}
|
||||||
|
if (MapUtils.isNotEmpty(envMap)) {
|
||||||
|
for (Map.Entry<String, String> entry : envMap.entrySet()) {
|
||||||
|
String projectId = entry.getKey();
|
||||||
|
String envIdStr = entry.getValue();
|
||||||
|
runInfoDTO.putScenarioRunInfo(model.getId(), projectId, envIdStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue