From b749f6277b4856f3844e32e7812f56cc5bbee94d Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 2 Nov 2020 15:21:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20=E6=B7=BB=E5=8A=A0=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/issue/AbstractIssuePlatform.java | 2 +- .../track/issue/IssuesPlatform.java | 11 +++--- .../track/service/TestCaseNodeService.java | 34 +++++++++++++++++-- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java index a5e8dd6bf1..4a5ba53f7a 100644 --- a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java @@ -62,7 +62,7 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { /** * 获取平台与项目相关的属性 - * @return + * @return 其他平台和本地项目绑定的属性值 */ abstract String getProjectId(); diff --git a/backend/src/main/java/io/metersphere/track/issue/IssuesPlatform.java b/backend/src/main/java/io/metersphere/track/issue/IssuesPlatform.java index a80d225733..458e885408 100644 --- a/backend/src/main/java/io/metersphere/track/issue/IssuesPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/IssuesPlatform.java @@ -9,31 +9,30 @@ public interface IssuesPlatform { /** * 获取平台相关联的缺陷 - * @return + * @return platform issues list */ List getIssue(); /** * 添加缺陷到缺陷平台 - * @param issuesRequest + * @param issuesRequest issueRequest */ void addIssue(IssuesRequest issuesRequest); /** * 删除缺陷平台缺陷 - * @param id + * @param id issue id */ void deleteIssue(String id); /** - * 测试缺陷平台连通性 - * @param + * 测试平台联通性 */ void testAuth(); /** * 获取缺陷平台项目下的相关人员 - * @return + * @return platform user list */ List getPlatformUser(); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java index 22d612a948..bda8df1325 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java @@ -586,9 +586,14 @@ public class TestCaseNodeService { } - // 测试用例同级模块排序 + /** + * 测试用例同级模块排序 + * @param ids 被拖拽模块相邻的前一个模块 id, + * 被拖拽的模块 id, + * 被拖拽模块相邻的后一个模块 id + */ public void sort(List ids) { - // 获取相邻节点 + // 获取相邻节点 id String before = ids.get(0); String id = ids.get(1); String after = ids.get(2); @@ -598,6 +603,7 @@ public class TestCaseNodeService { TestCaseNode caseNode = getCaseNode(id); + // 获取相邻节点 if (StringUtils.isNotBlank(before)) { beforeCase = getCaseNode(before); beforeCase = beforeCase.getLevel().equals(caseNode.getLevel()) ? beforeCase : null; @@ -625,6 +631,14 @@ public class TestCaseNodeService { } } + /** + * 按照指定排序方式获取同级模块的列表 + * @param projectId 所属项目 id + * @param level node level + * @param parentId node parent id + * @param order pos 排序方式 + * @return 按照指定排序方式排序的同级模块列表 + */ private List getPos(String projectId, int level, String parentId, String order) { TestCaseNodeExample example = new TestCaseNodeExample(); TestCaseNodeExample.Criteria criteria = example.createCriteria(); @@ -636,6 +650,12 @@ public class TestCaseNodeService { return testCaseNodeMapper.selectByExample(example); } + /** + * 刷新同级模块的 pos 值 + * @param projectId project id + * @param level node level + * @param parentId node parent id + */ private void refreshPos(String projectId, int level, String parentId) { List nodes = getPos(projectId, level, parentId, "pos asc"); if (!CollectionUtils.isEmpty(nodes)) { @@ -650,7 +670,15 @@ public class TestCaseNodeService { } } - public double getNextLevelPos(String projectId, int level, String parentId) { + + /** + * 获得同级模块下一个 pos 值 + * @param projectId project id + * @param level node level + * @param parentId node parent id + * @return 同级模块下一个 pos 值 + */ + private double getNextLevelPos(String projectId, int level, String parentId) { List list = getPos(projectId, level, parentId, "pos desc"); if (!CollectionUtils.isEmpty(list)) { return list.get(0).getPos() + 65536; From 352d464ca68d1c3207381b5884000a38269ded93 Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Mon, 2 Nov 2020 16:51:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=AE=A1=E5=88=92=EF=BC=8C=E9=92=89=E9=92=89=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E8=AF=AD=E4=B8=BA=E7=A9=BA=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notice/service/DingTaskService.java | 3 +- .../notice/service/WxChatTaskService.java | 3 +- .../track/service/TestCaseReviewService.java | 44 ++++++++++--------- .../track/service/TestPlanService.java | 12 ++--- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/backend/src/main/java/io/metersphere/notice/service/DingTaskService.java b/backend/src/main/java/io/metersphere/notice/service/DingTaskService.java index fef93eb126..dd30c10ff3 100644 --- a/backend/src/main/java/io/metersphere/notice/service/DingTaskService.java +++ b/backend/src/main/java/io/metersphere/notice/service/DingTaskService.java @@ -6,6 +6,7 @@ import com.dingtalk.api.request.OapiRobotSendRequest; import com.dingtalk.api.response.OapiRobotSendResponse; import com.taobao.api.ApiException; import io.metersphere.commons.constants.NoticeConstants; +import io.metersphere.commons.utils.LogUtil; import io.metersphere.notice.domain.MessageDetail; import io.metersphere.notice.domain.UserDetail; import io.metersphere.service.UserService; @@ -62,7 +63,7 @@ public class DingTaskService { try { response = client.execute(request); } catch (ApiException e) { - e.printStackTrace(); + LogUtil.error(e); } System.out.println(response.getErrcode()); } diff --git a/backend/src/main/java/io/metersphere/notice/service/WxChatTaskService.java b/backend/src/main/java/io/metersphere/notice/service/WxChatTaskService.java index a4bc03e904..10be211dc5 100644 --- a/backend/src/main/java/io/metersphere/notice/service/WxChatTaskService.java +++ b/backend/src/main/java/io/metersphere/notice/service/WxChatTaskService.java @@ -1,6 +1,7 @@ package io.metersphere.notice.service; import io.metersphere.commons.constants.NoticeConstants; +import io.metersphere.commons.utils.LogUtil; import io.metersphere.notice.domain.MessageDetail; import io.metersphere.notice.domain.UserDetail; import io.metersphere.notice.message.TextMessage; @@ -55,7 +56,7 @@ public class WxChatTaskService { SendResult result = WxChatbotClient.send(Webhook, message); System.out.println(result); } catch (IOException e) { - e.printStackTrace(); + LogUtil.error(e); } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java index a3e0bee76a..69575d5f69 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java @@ -8,6 +8,7 @@ import io.metersphere.base.mapper.ext.ExtTestCaseReviewMapper; import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper; import io.metersphere.commons.constants.NoticeConstants; import io.metersphere.commons.constants.TestCaseReviewStatus; +import io.metersphere.commons.constants.TestPlanStatus; import io.metersphere.commons.constants.TestReviewCaseStatus; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.user.SessionUser; @@ -184,28 +185,31 @@ public class TestCaseReviewService { testCaseReview.setUpdateTime(System.currentTimeMillis()); checkCaseReviewExist(testCaseReview); testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview); - List userIds=new ArrayList<>(); + List userIds = new ArrayList<>(); userIds.addAll(testCaseReview.getUserIds()); - try { - String context = getReviewContext(testCaseReview, NoticeConstants.CREATE); - MessageSettingDetail messageSettingDetail = noticeService.searchMessage(); - List taskList = messageSettingDetail.getReviewTask(); - taskList.forEach(r -> { - switch (r.getType()) { - case NoticeConstants.NAIL_ROBOT: - dingTaskService.sendNailRobot(r, userIds, context, NoticeConstants.CREATE); - break; - case NoticeConstants.WECHAT_ROBOT: - wxChatTaskService.sendWechatRobot(r, userIds, context, NoticeConstants.CREATE); - break; - case NoticeConstants.EMAIL: - mailService.sendReviewerNotice(r, userIds, testCaseReview, NoticeConstants.CREATE); - break; - } - }); - } catch (Exception e) { - LogUtil.error(e); + if (StringUtils.equals(TestPlanStatus.Completed.name(), testCaseReview.getStatus())) { + try { + String context = getReviewContext(testCaseReview, NoticeConstants.UPDATE); + MessageSettingDetail messageSettingDetail = noticeService.searchMessage(); + List taskList = messageSettingDetail.getReviewTask(); + taskList.forEach(r -> { + switch (r.getType()) { + case NoticeConstants.NAIL_ROBOT: + dingTaskService.sendNailRobot(r, userIds, context, NoticeConstants.UPDATE); + break; + case NoticeConstants.WECHAT_ROBOT: + wxChatTaskService.sendWechatRobot(r, userIds, context, NoticeConstants.UPDATE); + break; + case NoticeConstants.EMAIL: + mailService.sendReviewerNotice(r, userIds, testCaseReview, NoticeConstants.UPDATE); + break; + } + }); + } catch (Exception e) { + LogUtil.error(e); + } } + } private void editCaseReviewer(SaveTestCaseReviewRequest testCaseReview) { 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 7ae31d1ea3..14e16fb576 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -165,20 +165,20 @@ public class TestPlanService { //已完成,写入实际完成时间 testPlan.setActualEndTime(System.currentTimeMillis()); try { - BeanUtils.copyBean(testPlans, testPlan); - String context = getTestPlanContext(testPlans, NoticeConstants.CREATE); + BeanUtils.copyBean(testPlans, getTestPlan(testPlan.getId())); + String context = getTestPlanContext(testPlans, NoticeConstants.UPDATE); MessageSettingDetail messageSettingDetail = noticeService.searchMessage(); - List taskList = messageSettingDetail.getReviewTask(); + List taskList = messageSettingDetail.getTestCasePlanTask(); taskList.forEach(r -> { switch (r.getType()) { case NoticeConstants.NAIL_ROBOT: - dingTaskService.sendNailRobot(r, userIds, context, NoticeConstants.CREATE); + dingTaskService.sendNailRobot(r, userIds, context, NoticeConstants.UPDATE); break; case NoticeConstants.WECHAT_ROBOT: - wxChatTaskService.sendWechatRobot(r, userIds, context, NoticeConstants.CREATE); + wxChatTaskService.sendWechatRobot(r, userIds, context, NoticeConstants.UPDATE); break; case NoticeConstants.EMAIL: - mailService.sendTestPlanStartNotice(r, userIds, testPlans, NoticeConstants.CREATE); + mailService.sendTestPlanStartNotice(r, userIds, testPlans, NoticeConstants.UPDATE); break; } });