diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.java b/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.java index 0f55e57a55..bb02f5767e 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.java @@ -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); } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.xml index 24a7fbfa34..a2b277876a 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/TestPlanReportMapper.xml @@ -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> diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanReportMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanReportMapper.java index 8ad038f8b7..99f1370873 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanReportMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanReportMapper.java @@ -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); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanReportMapper.xml index 790179635b..d6d57c1e59 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanReportMapper.xml @@ -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> diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index 355842e63e..0462a797ff 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -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()));