diff --git a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java index 11851c3db1..321072bdcf 100644 --- a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java +++ b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java @@ -47,7 +47,7 @@ public interface ExtIssuesMapper { Long getThisWeekIssueCount(@Param("ids") List ids, @Param("projectId") String projectId); - List getTestPlanThisWeekIssue(String projectId); + List getTestPlanThisWeekIssue(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp); List getTestPlanIssue(String projectId); } diff --git a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml index bd8ea22b42..a1e637fa69 100644 --- a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml +++ b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml @@ -173,7 +173,7 @@ from test_plan_test_case tptc join test_plan tp on tp.id = tptc.plan_id join test_case_issues tci on tptc.id = tci.resource_id - where tptc.is_del != 1 and date_sub(curdate(), interval 7 day) <= from_unixtime(round(tci.relate_time / 1000, 0)) + where tptc.is_del != 1 and tci.relate_time between #{firstDayTimestamp} and #{lastDayTimestamp} and tp.project_id = #{projectId} diff --git a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java index f81eb7a4d4..48e62e38aa 100644 --- a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java +++ b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java @@ -92,7 +92,7 @@ public interface ExtTestCaseMapper { List getTestPlanBug(@Param("planId") String planId); - Long getTestPlanThisWeekBugCount(@Param("projectId") String projectId, @Param("ids") List ids); + Long getTestPlanThisWeekBugCount(@Param("projectId") String projectId, @Param("ids") List ids, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp); int getTestPlanCase(@Param("planId") String planId); diff --git a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml index 0a287c81dc..17410dc060 100644 --- a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml +++ b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml @@ -968,7 +968,7 @@ from test_plan_test_case tptc join test_plan tp on tp.id = tptc.plan_id join test_case_issues tci on tptc.id = tci.resource_id - where tp.project_id = #{projectId} and tptc.is_del != 1 and date_sub(curdate(), interval 7 day) <= from_unixtime(round(tci.relate_time / 1000, 0)) + where tp.project_id = #{projectId} and tptc.is_del != 1 and tci.relate_time between #{firstDayTimestamp} and #{lastDayTimestamp} and tci.issues_id in #{id} diff --git a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java index f91432fc77..e8459f8a3b 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java @@ -1888,7 +1888,10 @@ public class IssuesService { public void setFilterIds(IssuesRequest request) { List issueIds; if (request.getThisWeekUnClosedTestPlanIssue()) { - issueIds = extIssuesMapper.getTestPlanThisWeekIssue(request.getProjectId()); + Map weedFirstTimeAndLastTime = io.metersphere.commons.utils.DateUtils.getWeedFirstTimeAndLastTime(new Date()); + Date firstDay = weedFirstTimeAndLastTime.get("firstTime"); + Date lastDay = weedFirstTimeAndLastTime.get("lastTime"); + issueIds = extIssuesMapper.getTestPlanThisWeekIssue(request.getProjectId(), firstDay.getTime(), lastDay.getTime()); } else if (request.getAllTestPlanIssue() || request.getUnClosedTestPlanIssue()) { issueIds = extIssuesMapper.getTestPlanIssue(request.getProjectId()); } else { diff --git a/test-track/backend/src/main/java/io/metersphere/service/TrackService.java b/test-track/backend/src/main/java/io/metersphere/service/TrackService.java index 9c1e0251b9..51cb6527df 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TrackService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TrackService.java @@ -182,7 +182,10 @@ public class TrackService { int thisWeekCount = 0; if (CollectionUtils.isNotEmpty(issueIds)) { - thisWeekCount = extTestCaseMapper.getTestPlanThisWeekBugCount(projectId, issueIds).intValue(); + Map weedFirstTimeAndLastTime = DateUtils.getWeedFirstTimeAndLastTime(new Date()); + Date firstDay = weedFirstTimeAndLastTime.get("firstTime"); + Date lastDay = weedFirstTimeAndLastTime.get("lastTime"); + thisWeekCount = extTestCaseMapper.getTestPlanThisWeekBugCount(projectId, issueIds, firstDay.getTime(), lastDay.getTime()).intValue(); } bugSizeMap.put("thisWeekCount", thisWeekCount); return bugSizeMap;