fix(测试跟踪): 测试报告查询语句放到ext文件

--user=郭雨琦
This commit is contained in:
guoyuqi 2022-05-16 14:48:55 +08:00 committed by 刘瑞斌
parent 4aca52bfb1
commit d2ac70b4c4
5 changed files with 23 additions and 19 deletions

View File

@ -32,7 +32,4 @@ public interface TestPlanReportMapper {
int updateByPrimaryKeySelective(TestPlanReport record);
int updateByPrimaryKey(TestPlanReport record);
@MapKey("id")
Map<String, ParamsDTO> reportCount(@Param("planIds") Set<String> planIds);
}

View File

@ -235,18 +235,7 @@
<include refid="Example_Where_Clause" />
</if>
</select>
<select id="reportCount" resultType="io.metersphere.api.dto.definition.ParamsDTO">
select t.test_plan_id as id , count(*) from test_plan_report t
<where>
<if test="planIds != null and planIds.size() > 0">
and t.test_plan_id IN
<foreach collection="planIds" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</if>
</where>
GROUP BY t.test_plan_id
</select>
<update id="updateByExampleSelective" parameterType="map">
update test_plan_report
<set>

View File

@ -1,12 +1,14 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.TestPlanReport;
import io.metersphere.api.dto.definition.ParamsDTO;
import io.metersphere.track.dto.TestPlanReportDTO;
import io.metersphere.track.request.report.QueryTestPlanReportRequest;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.MapKey;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author song.tianyang
@ -15,4 +17,7 @@ import java.util.List;
*/
public interface ExtTestPlanReportMapper {
List<TestPlanReportDTO> list(@Param("request")QueryTestPlanReportRequest request);
@MapKey("id")
Map<String, ParamsDTO> reportCount(@Param("planIds") Set<String> planIds);
}

View File

@ -140,4 +140,17 @@
</foreach>
</if>
</select>
<select id="reportCount" resultType="io.metersphere.api.dto.definition.ParamsDTO">
select t.test_plan_id as id , count(*) from test_plan_report t
<where>
<if test="planIds != null and planIds.size() > 0">
and t.test_plan_id IN
<foreach collection="planIds" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</if>
</where>
GROUP BY t.test_plan_id
</select>
</mapper>

View File

@ -147,7 +147,7 @@ public class TestPlanService {
@Resource
private TestCaseTestMapper testCaseTestMapper;
@Resource
private TestPlanReportMapper testPlanReportMapper;
private ExtTestPlanReportMapper extTestPlanReportMapper;
@Resource
private TestPlanReportService testPlanReportService;
@Lazy
@ -438,7 +438,7 @@ public class TestPlanService {
ArrayList<String> idList = new ArrayList<>(ids);
List<Schedule> scheduleByResourceIds = scheduleService.getScheduleByResourceIds(idList, ScheduleGroup.TEST_PLAN_TEST.name());
Map<String, Schedule> scheduleMap = scheduleByResourceIds.stream().collect(Collectors.toMap(Schedule::getResourceId, Schedule -> Schedule));
Map<String, ParamsDTO> stringParamsDTOMap = testPlanReportMapper.reportCount(ids);
Map<String, ParamsDTO> stringParamsDTOMap = extTestPlanReportMapper.reportCount(ids);
testPlans.forEach(item -> {
item.setExecutionTimes(stringParamsDTOMap.get(item.getId()) == null ? 0 : Integer.parseInt(stringParamsDTOMap.get(item.getId()).getValue() == null ? "0" : stringParamsDTOMap.get(item.getId()).getValue()));