From d97ed8e0aea0b8db87f4f27c7f3e09c45699e8aa Mon Sep 17 00:00:00 2001 From: "nathan.liu" Date: Wed, 24 Aug 2022 15:35:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=AE=8C=E6=88=90=E6=89=A7=E8=A1=8C=E5=90=8E=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E7=8A=B6=E6=80=81=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1015942 --user=刘瑶 【测试跟踪】github#16977,在测试计划列表列表中点击【执行】,完成执行后。该计划当前状态不对:测试进度非100%,但是当前状态为“完成”。 https://www.tapd.cn/55049933/s/1232711 --- .../track/service/TestPlanMessageService.java | 26 ++++++++++++++----- backend/src/main/java/io/metersphere/xpack | 2 +- frontend/src/business/components/xpack | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanMessageService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanMessageService.java index 3bb60cf398..daa74d6e41 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanMessageService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanMessageService.java @@ -27,10 +27,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; +import java.util.*; @Service @Transactional @@ -50,6 +47,8 @@ public class TestPlanMessageService { @Resource private TestPlanReportService testPlanReportService; + public static final Integer FULL_MARKS = 100; + @Async public void checkTestPlanStatusAndSendMessage(TestPlanReport report, TestPlanReportContentWithBLOBs testPlanReportContent, boolean sendMessage) { @@ -93,15 +92,28 @@ public class TestPlanMessageService { //通过率 Double passRate = Optional.ofNullable(testPlanDTOWithMetric.getPassRate()).orElse(0.0); - //只有通过率 与 测试进度 都为100% 才为已完成状态 - if (testRate >= 100 && passRate >= 100) { + // 已完成:测试进度=100% 且 通过率=100% + if (testRate >= FULL_MARKS && passRate >= FULL_MARKS) { return TestPlanStatus.Completed.name(); } + + // 已结束:超过了计划结束时间(如有) 或 测试进度=100% 且 通过率非100% + Long plannedEndTime = testPlan.getPlannedEndTime(); + long currentTime = System.currentTimeMillis(); + if(Objects.nonNull(plannedEndTime) && currentTime >= plannedEndTime){ + return TestPlanStatus.Finished.name(); + } + + if(testRate >= FULL_MARKS && passRate < FULL_MARKS){ + return TestPlanStatus.Finished.name(); + } + } catch (Exception e) { LogUtil.error("计算通过率失败!", e); } - return TestPlanStatus.Finished.name(); + // 进行中:0 < 测试进度 < 100% + return TestPlanStatus.Underway.name(); } @Async diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index 2280ac8d66..7cdda1b8f4 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit 2280ac8d6679c9d5121264e166d79ae3e5af867c +Subproject commit 7cdda1b8f4554cb4185997d6a6beb2bc72809eed diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index c5c6bd584e..dc732de117 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit c5c6bd584e86f114705883e1b2986be19289c533 +Subproject commit dc732de11799623169ffa05a230fc33540704a65