From 0967768affcb970ecf149b68a4363735fe171858 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Mon, 24 Apr 2023 15:01:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E9=81=97?= =?UTF-8?q?=E7=95=99=E7=BC=BA=E9=99=B7=E7=BB=9F=E8=AE=A1=E6=9C=AC=E5=91=A8?= =?UTF-8?q?=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1025744 --user=宋昌昌 【测试跟踪】首页-测试计划遗留缺陷统计-本周新增-统计时间不是从周一开始 https://www.tapd.cn/55049933/s/1366006 --- .../java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java | 2 +- .../java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml | 2 +- .../io/metersphere/base/mapper/ext/ExtTestCaseMapper.java | 2 +- .../io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml | 2 +- .../src/main/java/io/metersphere/service/IssuesService.java | 5 ++++- .../src/main/java/io/metersphere/service/TrackService.java | 5 ++++- 6 files changed, 12 insertions(+), 6 deletions(-) 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;