refactor(项目管理): 优化任务中心查询sql
This commit is contained in:
parent
a26a4dd1ad
commit
fec6cfce98
|
@ -25,16 +25,16 @@
|
||||||
|
|
||||||
<select id="list" resultType="io.metersphere.api.domain.ApiReport">
|
<select id="list" resultType="io.metersphere.api.domain.ApiReport">
|
||||||
select
|
select
|
||||||
api_report.*
|
ar.*
|
||||||
from api_report where api_report.deleted = false
|
from api_report ar where ar.deleted = false
|
||||||
and api_report.test_plan_id = 'NONE'
|
and ar.test_plan_id = 'NONE'
|
||||||
<if test="request.keyword != null and request.keyword != ''">
|
<if test="request.keyword != null and request.keyword != ''">
|
||||||
and (
|
and (
|
||||||
api_report.name like concat('%', #{request.keyword},'%')
|
ar.name like concat('%', #{request.keyword},'%')
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
<if test="request.projectId != null and request.projectId != ''">
|
<if test="request.projectId != null and request.projectId != ''">
|
||||||
and api_report.project_id = #{request.projectId}
|
and ar.project_id = #{request.projectId}
|
||||||
</if>
|
</if>
|
||||||
<include refid="filters">
|
<include refid="filters">
|
||||||
<property name="filter" value="request.filter"/>
|
<property name="filter" value="request.filter"/>
|
||||||
|
@ -42,16 +42,16 @@
|
||||||
</select>
|
</select>
|
||||||
<select id="getIds" resultType="java.lang.String">
|
<select id="getIds" resultType="java.lang.String">
|
||||||
select
|
select
|
||||||
api_report.id
|
ar.id
|
||||||
from api_report where api_report.deleted = false
|
from api_report ar where ar.deleted = false
|
||||||
and api_report.test_plan_id = 'NONE'
|
and ar.test_plan_id = 'NONE'
|
||||||
<if test="request.condition.keyword != null">
|
<if test="request.condition.keyword != null">
|
||||||
and (
|
and (
|
||||||
api_report.name like concat('%', #{request.condition.keyword},'%')
|
ar.name like concat('%', #{request.condition.keyword},'%')
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
<if test="request.projectId != null and request.projectId != ''">
|
<if test="request.projectId != null and request.projectId != ''">
|
||||||
and api_report.project_id = #{request.projectId}
|
and ar.project_id = #{request.projectId}
|
||||||
</if>
|
</if>
|
||||||
<include refid="filters">
|
<include refid="filters">
|
||||||
<property name="filter" value="request.condition.filter"/>
|
<property name="filter" value="request.condition.filter"/>
|
||||||
|
@ -117,7 +117,7 @@
|
||||||
<if test="values != null and values.size() > 0">
|
<if test="values != null and values.size() > 0">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="key=='integrated'">
|
<when test="key=='integrated'">
|
||||||
and api_report.integrated in
|
and ar.integrated in
|
||||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="value == 'true'">1</when>
|
<when test="value == 'true'">1</when>
|
||||||
|
@ -127,29 +127,29 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='status'">
|
<when test="key=='status'">
|
||||||
and api_report.status in
|
and ar.status in
|
||||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='triggerMode'">
|
<when test="key=='triggerMode'">
|
||||||
and api_report.trigger_mode in
|
and ar.trigger_mode in
|
||||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='createUser'">
|
<when test="key=='createUser'">
|
||||||
and api_report.create_user in
|
and ar.create_user in
|
||||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='updateUser'">
|
<when test="key=='updateUser'">
|
||||||
and api_report.update_user in
|
and ar.update_user in
|
||||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='projectIds'">
|
<when test="key=='projectIds'">
|
||||||
and api_report.project_id in
|
and ar.project_id in
|
||||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
#{value}
|
#{value}
|
||||||
</foreach>
|
</foreach>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='organizationIds'">
|
<when test="key=='organizationIds'">
|
||||||
and api_report.organization_id in
|
and project.organization_id in
|
||||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
#{value}
|
#{value}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="taskCenterlist" resultType="io.metersphere.system.dto.taskcenter.TaskCenterDTO">
|
<select id="taskCenterlist" resultType="io.metersphere.system.dto.taskcenter.TaskCenterDTO">
|
||||||
SELECT api_report.* from (
|
|
||||||
select
|
select
|
||||||
distinct ar.id,
|
distinct ar.id,
|
||||||
ar.project_id,
|
ar.project_id,
|
||||||
|
@ -173,20 +173,9 @@
|
||||||
ar.start_time,
|
ar.start_time,
|
||||||
project.organization_id,
|
project.organization_id,
|
||||||
|
|
||||||
CASE
|
if(ar.integrated, ar.id, c.num) AS resourceNum,
|
||||||
WHEN ar.integrated = 0 THEN
|
if(ar.integrated, ar.name,c.name) AS resourceName,
|
||||||
c.num ELSE ar.id
|
if (ar.integrated,ar.id,c.id ) AS resourceId,
|
||||||
END AS resourceNum,
|
|
||||||
|
|
||||||
CASE
|
|
||||||
WHEN ar.integrated = 0 THEN
|
|
||||||
c.id ELSE ar.id
|
|
||||||
END AS resourceId,
|
|
||||||
|
|
||||||
CASE
|
|
||||||
WHEN ar.integrated = 0 THEN
|
|
||||||
c.NAME ELSE ar.NAME
|
|
||||||
END AS resourceName,
|
|
||||||
|
|
||||||
t.NAME AS poolName
|
t.NAME AS poolName
|
||||||
FROM
|
FROM
|
||||||
|
@ -198,16 +187,16 @@
|
||||||
where
|
where
|
||||||
ar.test_plan_id = 'NONE'
|
ar.test_plan_id = 'NONE'
|
||||||
and ar.start_time BETWEEN #{startTime} AND #{endTime}
|
and ar.start_time BETWEEN #{startTime} AND #{endTime}
|
||||||
) as api_report
|
|
||||||
where
|
and
|
||||||
api_report.project_id IN
|
ar.project_id IN
|
||||||
<foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
|
<foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
|
||||||
#{projectId}
|
#{projectId}
|
||||||
</foreach>
|
</foreach>
|
||||||
<if test="request.keyword != null and request.keyword != ''">
|
<if test="request.keyword != null and request.keyword != ''">
|
||||||
and ( api_report.resourceName like concat('%', #{request.keyword},'%')
|
and ( if(ar.integrated, ar.id, c.num) like concat('%', #{request.keyword},'%')
|
||||||
|
|
||||||
or api_report.resourceNum like concat('%', #{request.keyword},'%')
|
or if(ar.integrated, ar.name,c.name) like concat('%', #{request.keyword},'%')
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
<include refid="filters">
|
<include refid="filters">
|
||||||
|
@ -215,29 +204,34 @@
|
||||||
</include>
|
</include>
|
||||||
</select>
|
</select>
|
||||||
<select id="getReports" resultType="io.metersphere.api.dto.report.ReportDTO">
|
<select id="getReports" resultType="io.metersphere.api.dto.report.ReportDTO">
|
||||||
select id, pool_id from (select ar.* , project.organization_id from api_report ar
|
select distinct ar.* , project.organization_id from api_report ar
|
||||||
left join project on ar.project_id = project.id ) as api_report
|
LEFT JOIN api_test_case_record a ON ar.id = a.api_report_id
|
||||||
|
LEFT JOIN api_test_case c ON a.api_test_case_id = c.id
|
||||||
|
left join project on ar.project_id = project.id
|
||||||
where
|
where
|
||||||
api_report.deleted = false
|
ar.deleted = false
|
||||||
and api_report.test_plan_id = 'NONE'
|
and ar.test_plan_id = 'NONE'
|
||||||
and api_report.start_time BETWEEN #{startTime} AND #{endTime}
|
and ar.start_time BETWEEN #{startTime} AND #{endTime}
|
||||||
and api_report.status in ('PENDING', 'RUNNING', 'RERUNNING')
|
and ar.status in ('PENDING', 'RUNNING', 'RERUNNING')
|
||||||
<if test="ids != null and ids.size() > 0">
|
<if test="ids != null and ids.size() > 0">
|
||||||
and api_report.id in
|
and ar.id in
|
||||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="projectIds != null and projectIds.size() > 0">
|
<if test="projectIds != null and projectIds.size() > 0">
|
||||||
and api_report.project_id in
|
and ar.project_id in
|
||||||
<foreach collection="projectIds" item="projectId" open="(" separator="," close=")">
|
<foreach collection="projectIds" item="projectId" open="(" separator="," close=")">
|
||||||
#{projectId}
|
#{projectId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="request.condition.keyword != null">
|
<if test="request.condition.keyword != null">
|
||||||
and (
|
and (
|
||||||
api_report.name like concat('%', #{request.condition.keyword},'%')
|
|
||||||
|
if(ar.integrated, ar.id, c.num) like concat('%', #{request.condition.keyword},'%')
|
||||||
|
|
||||||
|
or if(ar.integrated, ar.name,c.name) like concat('%', #{request.condition.keyword},'%')
|
||||||
|
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
|
|
|
@ -24,16 +24,16 @@
|
||||||
|
|
||||||
<select id="list" resultType="io.metersphere.api.domain.ApiScenarioReport">
|
<select id="list" resultType="io.metersphere.api.domain.ApiScenarioReport">
|
||||||
select
|
select
|
||||||
api_scenario_report.*
|
asr.*
|
||||||
from api_scenario_report where api_scenario_report.deleted = false
|
from api_scenario_report asr where asr.deleted = false
|
||||||
and api_scenario_report.test_plan_id = 'NONE'
|
and asr.test_plan_id = 'NONE'
|
||||||
<if test="request.keyword != null and request.keyword != ''">
|
<if test="request.keyword != null and request.keyword != ''">
|
||||||
and (
|
and (
|
||||||
api_scenario_report.name like concat('%', #{request.keyword},'%')
|
asr.name like concat('%', #{request.keyword},'%')
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
<if test="request.projectId != null and request.projectId != ''">
|
<if test="request.projectId != null and request.projectId != ''">
|
||||||
and api_scenario_report.project_id = #{request.projectId}
|
and asr.project_id = #{request.projectId}
|
||||||
</if>
|
</if>
|
||||||
<include refid="filters">
|
<include refid="filters">
|
||||||
<property name="filter" value="request.filter"/>
|
<property name="filter" value="request.filter"/>
|
||||||
|
@ -41,16 +41,16 @@
|
||||||
</select>
|
</select>
|
||||||
<select id="getIds" resultType="java.lang.String">
|
<select id="getIds" resultType="java.lang.String">
|
||||||
select
|
select
|
||||||
api_scenario_report.id
|
asr.id
|
||||||
from api_scenario_report where api_scenario_report.deleted = false
|
from api_scenario_report asr where asr.deleted = false
|
||||||
and api_scenario_report.test_plan_id = 'NONE'
|
and asr.test_plan_id = 'NONE'
|
||||||
<if test="request.condition.keyword != null">
|
<if test="request.condition.keyword != null">
|
||||||
and (
|
and (
|
||||||
api_scenario_report.name like concat('%', #{request.condition.keyword},'%')
|
asr.name like concat('%', #{request.condition.keyword},'%')
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
<if test="request.projectId != null and request.projectId != ''">
|
<if test="request.projectId != null and request.projectId != ''">
|
||||||
and api_scenario_report.project_id = #{request.projectId}
|
and asr.project_id = #{request.projectId}
|
||||||
</if>
|
</if>
|
||||||
<include refid="filters">
|
<include refid="filters">
|
||||||
<property name="filter" value="request.condition.filter"/>
|
<property name="filter" value="request.condition.filter"/>
|
||||||
|
@ -111,29 +111,33 @@
|
||||||
and api_scenario_report.project_id = #{projectId} limit 500
|
and api_scenario_report.project_id = #{projectId} limit 500
|
||||||
</select>
|
</select>
|
||||||
<select id="getReports" resultType="io.metersphere.api.dto.report.ReportDTO">
|
<select id="getReports" resultType="io.metersphere.api.dto.report.ReportDTO">
|
||||||
select id, pool_id from (
|
|
||||||
select asr.*, p.organization_id from api_scenario_report asr
|
select distinct asr.*, project.organization_id from api_scenario_report asr
|
||||||
left join project p on asr.project_id = p.id ) as api_scenario_report
|
left join api_scenario_record a on asr.id = a.api_scenario_report_id
|
||||||
|
left JOIN api_scenario s on a.api_scenario_id = s.id
|
||||||
|
left join project on asr.project_id = project.id
|
||||||
where
|
where
|
||||||
api_scenario_report.deleted = false
|
asr.deleted = false
|
||||||
and api_scenario_report.test_plan_id = 'NONE'
|
and asr.test_plan_id = 'NONE'
|
||||||
and api_scenario_report.start_time BETWEEN #{startTime} AND #{endTime}
|
and asr.start_time BETWEEN #{startTime} AND #{endTime}
|
||||||
and api_scenario_report.status in ('PENDING', 'RUNNING', 'RERUNNING')
|
and asr.status in ('PENDING', 'RUNNING', 'RERUNNING')
|
||||||
<if test="ids != null and ids.size() > 0">
|
<if test="ids != null and ids.size() > 0">
|
||||||
and api_scenario_report.id in
|
and asr.id in
|
||||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="projectIds != null and projectIds.size() > 0">
|
<if test="projectIds != null and projectIds.size() > 0">
|
||||||
and api_scenario_report.project_id in
|
and asr.project_id in
|
||||||
<foreach collection="projectIds" item="projectId" open="(" separator="," close=")">
|
<foreach collection="projectIds" item="projectId" open="(" separator="," close=")">
|
||||||
#{projectId}
|
#{projectId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="request.condition.keyword != null">
|
<if test="request.condition.keyword != null">
|
||||||
and (
|
and (
|
||||||
api_scenario_report.name like concat('%', #{request.condition.keyword},'%')
|
if(asr.integrated, asr.id, s.num) like concat('%', #{request.condition.keyword},'%')
|
||||||
|
or if(asr.integrated, asr.name,s.name) like concat('%', #{request.condition.keyword},'%')
|
||||||
|
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
<include refid="filters">
|
<include refid="filters">
|
||||||
|
@ -143,7 +147,6 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="taskCenterlist" resultType="io.metersphere.system.dto.taskcenter.TaskCenterDTO">
|
<select id="taskCenterlist" resultType="io.metersphere.system.dto.taskcenter.TaskCenterDTO">
|
||||||
select * from (
|
|
||||||
select
|
select
|
||||||
distinct asr.id,
|
distinct asr.id,
|
||||||
asr.project_id,
|
asr.project_id,
|
||||||
|
@ -156,20 +159,9 @@
|
||||||
asr.start_time,
|
asr.start_time,
|
||||||
project.organization_id,
|
project.organization_id,
|
||||||
|
|
||||||
CASE
|
if(asr.integrated, asr.id, s.num) AS resourceNum,
|
||||||
WHEN asr.integrated = 0 THEN
|
if(asr.integrated, asr.name,s.name) AS resourceName,
|
||||||
s.num ELSE asr.id
|
if (asr.integrated,asr.id,s.id ) AS resourceId,
|
||||||
END AS resourceNum,
|
|
||||||
|
|
||||||
CASE
|
|
||||||
WHEN asr.integrated = 0 THEN
|
|
||||||
s.NAME ELSE asr.NAME
|
|
||||||
END AS resourceName,
|
|
||||||
|
|
||||||
CASE
|
|
||||||
WHEN asr.integrated = 0 THEN
|
|
||||||
s.id ELSE asr.id
|
|
||||||
END AS resourceId,
|
|
||||||
|
|
||||||
t.name as poolName
|
t.name as poolName
|
||||||
from api_scenario_report asr
|
from api_scenario_report asr
|
||||||
|
@ -178,16 +170,16 @@
|
||||||
left JOIN test_resource_pool t on asr.pool_id = t.id
|
left JOIN test_resource_pool t on asr.pool_id = t.id
|
||||||
left join project on asr.project_id = project.id
|
left join project on asr.project_id = project.id
|
||||||
where asr.test_plan_id = 'NONE'
|
where asr.test_plan_id = 'NONE'
|
||||||
and asr.start_time BETWEEN #{startTime} AND #{endTime} ) api_scenario_report
|
and asr.start_time BETWEEN #{startTime} AND #{endTime}
|
||||||
where
|
and
|
||||||
api_scenario_report.project_id IN
|
asr.project_id IN
|
||||||
<foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
|
<foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
|
||||||
#{projectId}
|
#{projectId}
|
||||||
</foreach>
|
</foreach>
|
||||||
<if test="request.keyword != null and request.keyword != ''">
|
<if test="request.keyword != null and request.keyword != ''">
|
||||||
and (
|
and (
|
||||||
api_scenario_report.resourceName like concat('%', #{request.keyword},'%')
|
if(asr.integrated, asr.id, s.num) like concat('%', #{request.keyword},'%')
|
||||||
or api_scenario_report.resourceNum like concat('%', #{request.keyword},'%')
|
or if(asr.integrated, asr.name,s.name) like concat('%', #{request.keyword},'%')
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
<include refid="filters">
|
<include refid="filters">
|
||||||
|
@ -265,7 +257,7 @@
|
||||||
<if test="values != null and values.size() > 0">
|
<if test="values != null and values.size() > 0">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="key=='integrated'">
|
<when test="key=='integrated'">
|
||||||
and api_scenario_report.integrated in
|
and asr.integrated in
|
||||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="value == 'true'">1</when>
|
<when test="value == 'true'">1</when>
|
||||||
|
@ -275,29 +267,29 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='status'">
|
<when test="key=='status'">
|
||||||
and api_scenario_report.status in
|
and asr.status in
|
||||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='triggerMode'">
|
<when test="key=='triggerMode'">
|
||||||
and api_scenario_report.trigger_mode in
|
and asr.trigger_mode in
|
||||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='createUser'">
|
<when test="key=='createUser'">
|
||||||
and api_scenario_report.create_user in
|
and asr.create_user in
|
||||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='updateUser'">
|
<when test="key=='updateUser'">
|
||||||
and api_scenario_report.update_user in
|
and asr.update_user in
|
||||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='projectIds'">
|
<when test="key=='projectIds'">
|
||||||
and api_scenario_report.project_id in
|
and asr.project_id in
|
||||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
#{value}
|
#{value}
|
||||||
</foreach>
|
</foreach>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='organizationIds'">
|
<when test="key=='organizationIds'">
|
||||||
and api_scenario_report.organization_id in
|
and project.organization_id in
|
||||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||||
#{value}
|
#{value}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
Loading…
Reference in New Issue