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">
|
||||
|
||||
|
||||
<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)
|
||||
SELECT #{request.id}, #{request.testPlanId}, #{request.apiScenarioId}, #{request.createTime}, #{request.updateTime}, #{request.environment}, #{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>
|
||||
<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)
|
||||
SELECT #{request.id},
|
||||
#{request.testPlanId},
|
||||
#{request.apiScenarioId},
|
||||
#{request.createTime},
|
||||
#{request.updateTime},
|
||||
#{request.environment},
|
||||
#{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 tpas.id, tpas.api_scenario_id,tpas.environment,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="selectLegalDataByTestPlanId" resultType="io.metersphere.track.dto.testplan.TestPlanApiScenarioInfoDTO">
|
||||
SELECT tpas.id,
|
||||
tpas.api_scenario_id,
|
||||
tpas.environment,
|
||||
tpas.environment_type,
|
||||
tpas.environment_group_id,
|
||||
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
|
||||
t.id,
|
||||
t.environment,
|
||||
t.create_time,
|
||||
t.update_time,
|
||||
t.last_result,
|
||||
t.pass_rate,
|
||||
t.report_id,
|
||||
c.scenario_definition,
|
||||
c.id AS case_id,
|
||||
c.user_id,
|
||||
c.api_scenario_module_id,
|
||||
c.module_path,
|
||||
c. NAME,
|
||||
c. LEVEL,
|
||||
c. STATUS,
|
||||
c.principal,
|
||||
c.step_total,
|
||||
c. SCHEDULE,
|
||||
c.description,
|
||||
c.tags,
|
||||
c.create_user,
|
||||
c.project_id,
|
||||
c.num,
|
||||
c.custom_num,
|
||||
t.environment_group_id,
|
||||
t.environment_type,
|
||||
project_version. NAME versionName,
|
||||
project_version.id versionId
|
||||
FROM
|
||||
test_plan_api_scenario t
|
||||
INNER JOIN api_scenario c ON t.api_scenario_id = c.id
|
||||
INNER JOIN project_version ON c.project_id = project_version.project_id
|
||||
AND c.version_id = project_version.id
|
||||
AND c. STATUS != 'Trash'
|
||||
<if test="request.planId != null and request.planId!=''">
|
||||
and t.test_plan_id = #{request.planId}
|
||||
</if>
|
||||
WHERE 1
|
||||
<include refid="queryVersionCondition">
|
||||
<property name="versionTable" value="c"/>
|
||||
</include>
|
||||
<select id="list" resultType="io.metersphere.api.dto.automation.ApiScenarioDTO">
|
||||
SELECT
|
||||
t.id,
|
||||
t.environment,
|
||||
t.create_time,
|
||||
t.update_time,
|
||||
t.last_result,
|
||||
t.pass_rate,
|
||||
t.report_id,
|
||||
c.scenario_definition,
|
||||
c.id AS case_id,
|
||||
c.user_id,
|
||||
c.api_scenario_module_id,
|
||||
c.module_path,
|
||||
c. NAME,
|
||||
c. LEVEL,
|
||||
c. STATUS,
|
||||
c.principal,
|
||||
c.step_total,
|
||||
c. SCHEDULE,
|
||||
c.description,
|
||||
c.tags,
|
||||
c.create_user,
|
||||
c.project_id,
|
||||
c.num,
|
||||
c.custom_num,
|
||||
t.environment_group_id,
|
||||
t.environment_type,
|
||||
project_version. NAME versionName,
|
||||
project_version.id versionId
|
||||
FROM
|
||||
test_plan_api_scenario t
|
||||
INNER JOIN api_scenario c ON t.api_scenario_id = c.id
|
||||
INNER JOIN project_version ON c.project_id = project_version.project_id
|
||||
AND c.version_id = project_version.id
|
||||
AND c. STATUS != 'Trash'
|
||||
<if test="request.planId != null and request.planId!=''">
|
||||
and t.test_plan_id = #{request.planId}
|
||||
</if>
|
||||
WHERE 1
|
||||
<include refid="queryVersionCondition">
|
||||
<property name="versionTable" value="c"/>
|
||||
</include>
|
||||
|
||||
<if test="request.scenarioIds != null and request.scenarioIds.size() > 0">
|
||||
and c.id in
|
||||
<foreach collection="request.scenarioIds" item="caseId" separator="," open="(" close=")">
|
||||
#{caseId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.ids != null and request.ids.size() > 0">
|
||||
<if test="request.projectId != null and request.projectId!=''">
|
||||
and c.project_id = #{request.projectId}
|
||||
</if>
|
||||
and 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},'%')
|
||||
<if test="request.scenarioIds != null and request.scenarioIds.size() > 0">
|
||||
and c.id in
|
||||
<foreach collection="request.scenarioIds" item="caseId" separator="," open="(" close=")">
|
||||
#{caseId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.ids != null and request.ids.size() > 0">
|
||||
<if test="request.projectId != null and request.projectId!=''">
|
||||
and c.project_id = #{request.projectId}
|
||||
</if>
|
||||
and 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.custom_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>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getExecResultByPlanId" resultType="java.lang.String">
|
||||
select last_result
|
||||
from
|
||||
test_plan_api_scenario
|
||||
where test_plan_id = #{planId}
|
||||
AND api_scenario_id in (SELECT id FROM api_scenario WHERE (`status` is null or `status` != 'Trash'))
|
||||
select last_result
|
||||
from test_plan_api_scenario
|
||||
where test_plan_id = #{planId}
|
||||
AND api_scenario_id in (SELECT id FROM api_scenario WHERE (`status` is null or `status` != 'Trash'))
|
||||
</select>
|
||||
<select id="getIdsByPlanId" resultType="java.lang.String">
|
||||
select id
|
||||
from test_plan_api_scenario
|
||||
where test_plan_id = #{planId}
|
||||
select id
|
||||
from test_plan_api_scenario
|
||||
where test_plan_id = #{planId}
|
||||
</select>
|
||||
|
||||
<select id="getNotRelevanceCaseIds" resultType="java.lang.String">
|
||||
select t.id
|
||||
from test_plan_api_scenario t
|
||||
inner join api_scenario c
|
||||
on c.id = t.api_scenario_id
|
||||
<if test="relevanceProjectIds != null and relevanceProjectIds.size() > 0">
|
||||
and c.project_id not in
|
||||
<foreach collection="relevanceProjectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</if>
|
||||
where t.test_plan_id = #{planId}
|
||||
select t.id
|
||||
from test_plan_api_scenario t
|
||||
inner join api_scenario c
|
||||
on c.id = t.api_scenario_id
|
||||
<if test="relevanceProjectIds != null and relevanceProjectIds.size() > 0">
|
||||
and c.project_id not in
|
||||
<foreach collection="relevanceProjectIds" item="projectId" separator="," open="(" close=")">
|
||||
#{projectId}
|
||||
</foreach>
|
||||
</if>
|
||||
where t.test_plan_id = #{planId}
|
||||
</select>
|
||||
<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}
|
||||
and api_scenario_id IN (
|
||||
SELECT id FROM api_scenario where status is null or status != 'Trash'
|
||||
)
|
||||
select id, last_result as status, report_id, api_scenario_id as caseId
|
||||
from test_plan_api_scenario
|
||||
where test_plan_id = #{planId}
|
||||
and api_scenario_id IN (
|
||||
SELECT id
|
||||
FROM api_scenario
|
||||
where status is null
|
||||
or status
|
||||
!= 'Trash'
|
||||
)
|
||||
</select>
|
||||
<select id="getFailureList" resultType="io.metersphere.api.dto.automation.TestPlanFailureScenarioDTO">
|
||||
select
|
||||
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.num, c.custom_num
|
||||
from
|
||||
test_plan_api_scenario t
|
||||
inner join
|
||||
api_scenario c
|
||||
on t.api_scenario_id = c.id and (c.status != 'Trash' or c.status is null)
|
||||
and t.test_plan_id = #{planId}
|
||||
<if test="status != null and status != 'Fail' and status != 'unExecute'">
|
||||
and t.last_result = #{status}
|
||||
</if>
|
||||
<if test="status == 'unExecute'">
|
||||
and (t.last_result in ('Stop','unExecute') or t.last_result IS NULL)
|
||||
</if>
|
||||
<if test="status == 'Fail'">
|
||||
and t.last_result in ('Fail','Error')
|
||||
</if>
|
||||
where t.test_plan_id = #{planId}
|
||||
select
|
||||
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.num, c.custom_num
|
||||
from
|
||||
test_plan_api_scenario t
|
||||
inner join
|
||||
api_scenario c
|
||||
on t.api_scenario_id = c.id and (c.status != 'Trash' or c.status is null)
|
||||
and t.test_plan_id = #{planId}
|
||||
<if test="status != null and status != 'Fail' and status != 'unExecute'">
|
||||
and t.last_result = #{status}
|
||||
</if>
|
||||
<if test="status == 'unExecute'">
|
||||
and (t.last_result in ('Stop','unExecute') or t.last_result IS NULL)
|
||||
</if>
|
||||
<if test="status == 'Fail'">
|
||||
and t.last_result in ('Fail','Error')
|
||||
</if>
|
||||
where t.test_plan_id = #{planId}
|
||||
ORDER BY t.order DESC
|
||||
</select>
|
||||
|
||||
<select id="getFailureListByIds" resultType="io.metersphere.api.dto.automation.TestPlanFailureScenarioDTO">
|
||||
select
|
||||
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.num, c.custom_num
|
||||
from
|
||||
test_plan_api_scenario t
|
||||
inner join
|
||||
api_scenario c
|
||||
on t.api_scenario_id = c.id and c.status != 'Trash'
|
||||
<if test="status != null">
|
||||
and t.last_result = 'Fail'
|
||||
</if>
|
||||
where t.id IN
|
||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
select
|
||||
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.num, c.custom_num
|
||||
from
|
||||
test_plan_api_scenario t
|
||||
inner join
|
||||
api_scenario c
|
||||
on t.api_scenario_id = c.id and c.status != 'Trash'
|
||||
<if test="status != null">
|
||||
and t.last_result = 'Fail'
|
||||
</if>
|
||||
where t.id IN
|
||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
ORDER BY t.order DESC
|
||||
</select>
|
||||
|
||||
<select id="getUnderwaySteps" resultType="java.lang.Integer">
|
||||
select step_total from api_scenario c
|
||||
where c.id in
|
||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getUnderwaySteps" resultType="java.lang.Integer">
|
||||
select step_total from api_scenario c
|
||||
where c.id in
|
||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getProjectIdById" resultType="java.lang.String">
|
||||
SELECT project_id FROM test_plan WHERE id in (
|
||||
SELECT test_plan_id FROM test_plan_api_scenario WHERE id = #{0}
|
||||
)
|
||||
</select>
|
||||
<select id="getProjectIdById" resultType="java.lang.String">
|
||||
SELECT project_id
|
||||
FROM test_plan
|
||||
WHERE id in (
|
||||
SELECT test_plan_id
|
||||
FROM test_plan_api_scenario
|
||||
WHERE id = #{0}
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="selectPlanIds" resultType="java.lang.String">
|
||||
select DISTINCT test_plan_id from test_plan_api_scenario;
|
||||
</select>
|
||||
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
|
||||
select id from test_plan_api_scenario where test_plan_id = #{planId} order by update_time ASC;
|
||||
</select>
|
||||
<select id="selectPlanIds" resultType="java.lang.String">
|
||||
select DISTINCT test_plan_id
|
||||
from test_plan_api_scenario;
|
||||
</select>
|
||||
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
|
||||
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 `order` from test_plan_api_scenario where test_plan_id = #{planId}
|
||||
<if test="baseOrder != null">
|
||||
and `order` > #{baseOrder}
|
||||
</if>
|
||||
order by `order` desc limit 1;
|
||||
</select>
|
||||
<select id="getLastOrder" resultType="java.lang.Long">
|
||||
select `order` from test_plan_api_scenario where test_plan_id = #{planId}
|
||||
<if test="baseOrder != null">
|
||||
and `order` > #{baseOrder}
|
||||
</if>
|
||||
order by `order` desc limit 1;
|
||||
</select>
|
||||
|
||||
<select id="getPreOrder" resultType="java.lang.Long">
|
||||
select `order` from test_plan_api_scenario where test_plan_id = #{planId}
|
||||
<if test="baseOrder != null">
|
||||
and `order` < #{baseOrder}
|
||||
</if>
|
||||
order by `order` desc limit 1;
|
||||
</select>
|
||||
<select id="getPreOrder" resultType="java.lang.Long">
|
||||
select `order` from test_plan_api_scenario where test_plan_id = #{planId}
|
||||
<if test="baseOrder != null">
|
||||
and `order` < #{baseOrder}
|
||||
</if>
|
||||
order by `order` desc limit 1;
|
||||
</select>
|
||||
|
||||
<sql id="queryVersionCondition">
|
||||
<if test="request.versionId != null">
|
||||
and ${versionTable}.version_id = #{request.versionId}
|
||||
</if>
|
||||
<if test="request.refId != null">
|
||||
and ${versionTable}.ref_id = #{request.refId}
|
||||
</if>
|
||||
</sql>
|
||||
<sql id="queryVersionCondition">
|
||||
<if test="request.versionId != null">
|
||||
and ${versionTable}.version_id = #{request.versionId}
|
||||
</if>
|
||||
<if test="request.refId != null">
|
||||
and ${versionTable}.ref_id = #{request.refId}
|
||||
</if>
|
||||
</sql>
|
||||
</mapper>
|
||||
|
|
|
@ -10,4 +10,6 @@ public class TestPlanApiScenarioInfoDTO {
|
|||
private String apiScenarioId;
|
||||
private String environment;
|
||||
private String projectId;
|
||||
private String environmentType;
|
||||
private String environmentGroupId;
|
||||
}
|
||||
|
|
|
@ -299,19 +299,25 @@ public class TestPlanReportService {
|
|||
}
|
||||
|
||||
for (TestPlanApiScenarioInfoDTO model : testPlanApiScenarioList) {
|
||||
if (MapUtils.isNotEmpty(selectEnvMap) && selectEnvMap.containsKey(model.getProjectId())) {
|
||||
runInfoDTO.putScenarioRunInfo(model.getId(), model.getProjectId(), selectEnvMap.get(model.getProjectId()));
|
||||
} else if (StringUtils.isNotEmpty(model.getEnvironment())) {
|
||||
try {
|
||||
Map<String, String> envMap = JSONObject.parseObject(model.getEnvironment(), Map.class);
|
||||
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);
|
||||
}
|
||||
Map<String, String> envMap = null;
|
||||
if (StringUtils.equalsIgnoreCase("group", model.getEnvironmentType()) && StringUtils.isNotEmpty(model.getEnvironmentGroupId())) {
|
||||
envMap = environmentGroupProjectService.getEnvMap(model.getEnvironmentGroupId());
|
||||
} else {
|
||||
if (MapUtils.isNotEmpty(selectEnvMap) && selectEnvMap.containsKey(model.getProjectId())) {
|
||||
runInfoDTO.putScenarioRunInfo(model.getId(), model.getProjectId(), selectEnvMap.get(model.getProjectId()));
|
||||
} else if (StringUtils.isNotEmpty(model.getEnvironment())) {
|
||||
try {
|
||||
envMap = JSONObject.parseObject(model.getEnvironment(), Map.class);
|
||||
} 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