From 7aa5a6fc5c5968db9e4c0f00917edf5b879c6281 Mon Sep 17 00:00:00 2001 From: Coooder-X <55648333+Coooder-X@users.noreply.github.com> Date: Mon, 1 Feb 2021 14:26:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92)?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=20=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92-?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=8A=B6=E6=80=81=E5=90=8E=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=9C=89=E8=AF=AF=20(#1291)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/service/TestPlanService.java | 33 ++++++++++++++----- .../track/plan/components/TestPlanList.vue | 12 ++++++- 2 files changed, 35 insertions(+), 10 deletions(-) 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 c6651c55f2..7917a3f2b9 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -168,20 +168,35 @@ public class TestPlanService { public int editTestPlan(TestPlanDTO testPlan) { editTestPlanProject(testPlan); - testPlan.setUpdateTime(System.currentTimeMillis()); checkTestPlanExist(testPlan); - //进行中状态,写入实际开始时间 - if (TestPlanStatus.Underway.name().equals(testPlan.getStatus())) { - testPlan.setActualStartTime(System.currentTimeMillis()); - } else if (TestPlanStatus.Completed.name().equals(testPlan.getStatus())) { - //已完成,写入实际完成时间 - testPlan.setActualEndTime(System.currentTimeMillis()); - + TestPlan res = testPlanMapper.selectByPrimaryKey(testPlan.getId()); // 先查一次库 + if (!res.getStatus().equals(testPlan.getStatus())) { // 若有改变才更新时间 + res.setUpdateTime(System.currentTimeMillis()); + if (TestPlanStatus.Underway.name().equals(testPlan.getStatus())) { + if (res.getStatus().equals(TestPlanStatus.Prepare.name())) { + res.setActualStartTime(System.currentTimeMillis()); + } // 未开始->进行中,写入实际开始时间 + else if (res.getStatus().equals(TestPlanStatus.Completed.name())) { + res.setActualEndTime(null); + } // 已完成->进行中,结束时间置空 + } + else if (!res.getStatus().equals(TestPlanStatus.Prepare.name()) && + testPlan.getStatus().equals(TestPlanStatus.Prepare.name())) { + res.setActualStartTime(null); + res.setActualEndTime(null); + } // 非未开始->未开始,时间都置空 + else if (TestPlanStatus.Completed.name().equals(testPlan.getStatus()) && + !TestPlanStatus.Completed.name().equals(res.getStatus())) { + //已完成,写入实际完成时间 + res.setActualEndTime(System.currentTimeMillis()); + } + res.setStatus(testPlan.getStatus()); } + List userIds = new ArrayList<>(); userIds.add(testPlan.getPrincipal()); AddTestPlanRequest testPlans = new AddTestPlanRequest(); - int i = testPlanMapper.updateByPrimaryKeySelective(testPlan); + int i = testPlanMapper.updateByPrimaryKey(res); // 更新 if (!StringUtils.isBlank(testPlan.getStatus())) { BeanUtils.copyBean(testPlans, getTestPlan(testPlan.getId())); String context = getTestPlanContext(testPlans, NoticeConstants.Event.UPDATE); diff --git a/frontend/src/business/components/track/plan/components/TestPlanList.vue b/frontend/src/business/components/track/plan/components/TestPlanList.vue index b6f68ba8c7..80fa8678ba 100644 --- a/frontend/src/business/components/track/plan/components/TestPlanList.vue +++ b/frontend/src/business/components/track/plan/components/TestPlanList.vue @@ -257,7 +257,17 @@ export default { statusChange(param) { this.$post('/test/plan/edit', param, () => { for (let i = 0; i < this.tableData.length; i++) { - if (this.tableData[i].id == param.id) { + if (this.tableData[i].id == param.id) { // 手动修改当前状态后,前端结束时间先用当前时间,等刷新后变成后台数据(相等) + if (this.tableData[i].status !== "Completed" && param.status === "Completed") { + this.tableData[i].actualEndTime = new Date(); + } // 非完成->已完成,结束时间=null + else if (this.tableData[i].status !== "Underway" && param.status === "Underway") { + this.tableData[i].actualStartTime = new Date(); + this.tableData[i].actualEndTime = ""; + } // 非进行中->进行中,结束时间=null + else if (this.tableData[i].status !== "Prepare" && param.status === "Prepare") { + this.tableData[i].actualStartTime = this.tableData[i].actualEndTime = ""; + } // 非未开始->未开始,结束时间=null this.tableData[i].status = param.status; break; }