refactor: 测试计划发送通知
This commit is contained in:
parent
da7b8d0e76
commit
093bf40a51
|
@ -790,6 +790,7 @@ public class ApiDefinitionService {
|
||||||
Map<String, Object> paramMap = new HashMap<>();
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
paramMap.put("url", request.getSwaggerUrl());
|
paramMap.put("url", request.getSwaggerUrl());
|
||||||
NoticeModel noticeModel = NoticeModel.builder()
|
NoticeModel noticeModel = NoticeModel.builder()
|
||||||
|
.operator(SessionUtils.getUserId())
|
||||||
.context(context)
|
.context(context)
|
||||||
.testId(scheduleId)
|
.testId(scheduleId)
|
||||||
.subject(Translator.get("swagger_url_scheduled_import_notification"))
|
.subject(Translator.get("swagger_url_scheduled_import_notification"))
|
||||||
|
@ -814,6 +815,7 @@ public class ApiDefinitionService {
|
||||||
Map<String, Object> paramMap = new HashMap<>();
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
paramMap.put("url", request.getSwaggerUrl());
|
paramMap.put("url", request.getSwaggerUrl());
|
||||||
NoticeModel noticeModel = NoticeModel.builder()
|
NoticeModel noticeModel = NoticeModel.builder()
|
||||||
|
.operator(SessionUtils.getUserId())
|
||||||
.context(context)
|
.context(context)
|
||||||
.testId(scheduleId)
|
.testId(scheduleId)
|
||||||
.subject(Translator.get("swagger_url_scheduled_import_notification"))
|
.subject(Translator.get("swagger_url_scheduled_import_notification"))
|
||||||
|
|
|
@ -8,6 +8,7 @@ import io.metersphere.commons.constants.*;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
import io.metersphere.commons.utils.DateUtils;
|
import io.metersphere.commons.utils.DateUtils;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
import io.metersphere.notice.sender.NoticeModel;
|
import io.metersphere.notice.sender.NoticeModel;
|
||||||
|
@ -242,6 +243,7 @@ public class TestResultService {
|
||||||
paramMap.put("executionEnvironment", report.getExecutionEnvironment());
|
paramMap.put("executionEnvironment", report.getExecutionEnvironment());
|
||||||
paramMap.put("principal", report.getPrincipal());
|
paramMap.put("principal", report.getPrincipal());
|
||||||
NoticeModel noticeModel = NoticeModel.builder()
|
NoticeModel noticeModel = NoticeModel.builder()
|
||||||
|
.operator(SessionUtils.getUserId())
|
||||||
.successContext(successContext)
|
.successContext(successContext)
|
||||||
.successMailTemplate("ApiSuccessfulNotification")
|
.successMailTemplate("ApiSuccessfulNotification")
|
||||||
.failedContext(failedContext)
|
.failedContext(failedContext)
|
||||||
|
|
|
@ -38,6 +38,7 @@ public interface NoticeConstants {
|
||||||
String CREATE = "CREATE";
|
String CREATE = "CREATE";
|
||||||
String UPDATE = "UPDATE";
|
String UPDATE = "UPDATE";
|
||||||
String DELETE = "DELETE";
|
String DELETE = "DELETE";
|
||||||
|
String COMPLETE = "COMPLETE";
|
||||||
|
|
||||||
String CASE_CREATE = "CASE_CREATE";
|
String CASE_CREATE = "CASE_CREATE";
|
||||||
String CASE_UPDATE = "CASE_UPDATE";
|
String CASE_UPDATE = "CASE_UPDATE";
|
||||||
|
|
|
@ -141,6 +141,7 @@ public class SendNoticeAspect {
|
||||||
.mailTemplate(sendNotice.mailTemplate())
|
.mailTemplate(sendNotice.mailTemplate())
|
||||||
.paramMap(paramMap)
|
.paramMap(paramMap)
|
||||||
.event(sendNotice.event())
|
.event(sendNotice.event())
|
||||||
|
.status((String) paramMap.get("status"))
|
||||||
.build();
|
.build();
|
||||||
noticeSendService.send(sendNotice.taskType(), noticeModel);
|
noticeSendService.send(sendNotice.taskType(), noticeModel);
|
||||||
}
|
}
|
||||||
|
@ -170,6 +171,9 @@ public class SendNoticeAspect {
|
||||||
case NoticeConstants.Event.COMMENT:
|
case NoticeConstants.Event.COMMENT:
|
||||||
operation = "评论了";
|
operation = "评论了";
|
||||||
break;
|
break;
|
||||||
|
case NoticeConstants.Event.COMPLETE:
|
||||||
|
operation = "完成了";
|
||||||
|
break;
|
||||||
case NoticeConstants.Event.CLOSE_SCHEDULE:
|
case NoticeConstants.Event.CLOSE_SCHEDULE:
|
||||||
operation = "关闭了定时任务";
|
operation = "关闭了定时任务";
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class InSiteNoticeSender extends AbstractNoticeSender {
|
public class InSiteNoticeSender extends AbstractNoticeSender {
|
||||||
|
@ -28,20 +29,22 @@ public class InSiteNoticeSender extends AbstractNoticeSender {
|
||||||
|
|
||||||
receivers.forEach(receiver -> {
|
receivers.forEach(receiver -> {
|
||||||
LogUtil.debug("发送站内通知: {}, 内容: {}", receiver, context);
|
LogUtil.debug("发送站内通知: {}, 内容: {}", receiver, context);
|
||||||
|
|
||||||
|
Map<String, Object> paramMap = noticeModel.getParamMap();
|
||||||
Notification notification = new Notification();
|
Notification notification = new Notification();
|
||||||
notification.setTitle(noticeModel.getSubject());
|
notification.setTitle(noticeModel.getSubject());
|
||||||
notification.setContent(context);
|
notification.setContent(context);
|
||||||
notification.setOperator(noticeModel.getOperator());
|
notification.setOperator(noticeModel.getOperator());
|
||||||
notification.setOperation(noticeModel.getEvent());
|
notification.setOperation(noticeModel.getEvent());
|
||||||
notification.setResourceId((String) noticeModel.getParamMap().get("id"));
|
notification.setResourceId((String) paramMap.get("id"));
|
||||||
notification.setResourceType(messageDetail.getTaskType());
|
notification.setResourceType(messageDetail.getTaskType());
|
||||||
//
|
//
|
||||||
if (noticeModel.getParamMap().get("name") != null) {
|
if (paramMap.get("name") != null) {
|
||||||
notification.setResourceName((String) noticeModel.getParamMap().get("name"));
|
notification.setResourceName((String) paramMap.get("name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noticeModel.getParamMap().get("title") != null) {
|
if (paramMap.get("title") != null) {
|
||||||
notification.setResourceName((String) noticeModel.getParamMap().get("title"));
|
notification.setResourceName((String) paramMap.get("title"));
|
||||||
}
|
}
|
||||||
|
|
||||||
notification.setType(receiver.getType());
|
notification.setType(receiver.getType());
|
||||||
|
|
|
@ -6,6 +6,7 @@ import io.metersphere.commons.constants.PerformanceTestStatus;
|
||||||
import io.metersphere.commons.constants.ReportTriggerMode;
|
import io.metersphere.commons.constants.ReportTriggerMode;
|
||||||
import io.metersphere.commons.consumer.LoadTestFinishEvent;
|
import io.metersphere.commons.consumer.LoadTestFinishEvent;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
import io.metersphere.notice.sender.NoticeModel;
|
import io.metersphere.notice.sender.NoticeModel;
|
||||||
|
@ -57,6 +58,7 @@ public class PerformanceNoticeEvent implements LoadTestFinishEvent {
|
||||||
paramMap.put("status", loadTestReport.getStatus());
|
paramMap.put("status", loadTestReport.getStatus());
|
||||||
paramMap.put("url", baseSystemConfigDTO.getUrl());
|
paramMap.put("url", baseSystemConfigDTO.getUrl());
|
||||||
NoticeModel noticeModel = NoticeModel.builder()
|
NoticeModel noticeModel = NoticeModel.builder()
|
||||||
|
.operator(SessionUtils.getUserId())
|
||||||
.successContext(successContext)
|
.successContext(successContext)
|
||||||
.successMailTemplate("PerformanceApiSuccessNotification")
|
.successMailTemplate("PerformanceApiSuccessNotification")
|
||||||
.failedContext(failedContext)
|
.failedContext(failedContext)
|
||||||
|
|
|
@ -123,7 +123,6 @@ public class TestCaseReviewController {
|
||||||
|
|
||||||
@PostMapping("/edit/status/{reviewId}")
|
@PostMapping("/edit/status/{reviewId}")
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_EDIT)
|
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ_EDIT)
|
||||||
@SendNotice(taskType = NoticeConstants.TaskType.REVIEW_TASK, event = NoticeConstants.Event.UPDATE, mailTemplate = "track/ReviewEnd", subject = "测试评审通知")
|
|
||||||
public void editTestPlanStatus(@PathVariable String reviewId) {
|
public void editTestPlanStatus(@PathVariable String reviewId) {
|
||||||
checkPermissionService.checkTestReviewOwner(reviewId);
|
checkPermissionService.checkTestReviewOwner(reviewId);
|
||||||
testCaseReviewService.editTestReviewStatus(reviewId);
|
testCaseReviewService.editTestReviewStatus(reviewId);
|
||||||
|
|
|
@ -122,7 +122,8 @@ public class TestPlanController {
|
||||||
@PostMapping("/delete/{testPlanId}")
|
@PostMapping("/delete/{testPlanId}")
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_DELETE)
|
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_DELETE)
|
||||||
@MsAuditLog(module = "track_test_plan", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#testPlanId)", msClass = TestPlanService.class)
|
@MsAuditLog(module = "track_test_plan", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#testPlanId)", msClass = TestPlanService.class)
|
||||||
@SendNotice(taskType = NoticeConstants.TaskType.TEST_PLAN_TASK, event = NoticeConstants.Event.DELETE, mailTemplate = "track/TestPlanDelete", subject = "测试计划通知")
|
@SendNotice(taskType = NoticeConstants.TaskType.TEST_PLAN_TASK, target = "#targetClass.getTestPlan(#testPlanId)", targetClass = TestPlanService.class,
|
||||||
|
event = NoticeConstants.Event.DELETE, mailTemplate = "track/TestPlanDelete", subject = "测试计划通知")
|
||||||
public int deleteTestPlan(@PathVariable String testPlanId) {
|
public int deleteTestPlan(@PathVariable String testPlanId) {
|
||||||
checkPermissionService.checkTestPlanOwner(testPlanId);
|
checkPermissionService.checkTestPlanOwner(testPlanId);
|
||||||
return testPlanService.deleteTestPlan(testPlanId);
|
return testPlanService.deleteTestPlan(testPlanId);
|
||||||
|
|
|
@ -18,7 +18,6 @@ import io.metersphere.commons.utils.ServiceUtils;
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.controller.request.member.QueryMemberRequest;
|
import io.metersphere.controller.request.member.QueryMemberRequest;
|
||||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||||
import io.metersphere.i18n.Translator;
|
|
||||||
import io.metersphere.log.utils.ReflexObjectUtil;
|
import io.metersphere.log.utils.ReflexObjectUtil;
|
||||||
import io.metersphere.log.vo.DetailColumn;
|
import io.metersphere.log.vo.DetailColumn;
|
||||||
import io.metersphere.log.vo.OperatingLogDetails;
|
import io.metersphere.log.vo.OperatingLogDetails;
|
||||||
|
@ -79,19 +78,6 @@ public class TestCaseReviewService {
|
||||||
private NoticeSendService noticeSendService;
|
private NoticeSendService noticeSendService;
|
||||||
@Resource
|
@Resource
|
||||||
private SystemParameterService systemParameterService;
|
private SystemParameterService systemParameterService;
|
||||||
@Resource
|
|
||||||
private TestCaseReviewLoadMapper testCaseReviewLoadMapper;
|
|
||||||
@Resource
|
|
||||||
private TestCaseReviewApiCaseMapper testCaseReviewApiCaseMapper;
|
|
||||||
@Resource
|
|
||||||
private TestCaseReviewScenarioMapper testCaseReviewScenarioMapper;
|
|
||||||
@Resource
|
|
||||||
private ApiTestCaseMapper apiTestCaseMapper;
|
|
||||||
@Resource
|
|
||||||
private ApiScenarioMapper apiScenarioMapper;
|
|
||||||
@Resource
|
|
||||||
private ApiDefinitionMapper apiDefinitionMapper;
|
|
||||||
|
|
||||||
|
|
||||||
public TestCaseReview saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) {
|
public TestCaseReview saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) {
|
||||||
checkCaseReviewExist(reviewRequest);
|
checkCaseReviewExist(reviewRequest);
|
||||||
|
@ -137,9 +123,8 @@ public class TestCaseReviewService {
|
||||||
Map<String, String> paramMap = new HashMap<>();
|
Map<String, String> paramMap = new HashMap<>();
|
||||||
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
||||||
paramMap.put("url", baseSystemConfigDTO.getUrl());
|
paramMap.put("url", baseSystemConfigDTO.getUrl());
|
||||||
User user = userMapper.selectByPrimaryKey(reviewRequest.getCreator());
|
paramMap.put("creator", reviewRequest.getCreator());
|
||||||
paramMap.put("creator", user.getName());
|
paramMap.put("name", reviewRequest.getName());
|
||||||
paramMap.put("reviewName", reviewRequest.getName());
|
|
||||||
paramMap.put("start", start);
|
paramMap.put("start", start);
|
||||||
paramMap.put("end", end);
|
paramMap.put("end", end);
|
||||||
paramMap.put("id", reviewRequest.getId());
|
paramMap.put("id", reviewRequest.getId());
|
||||||
|
@ -421,6 +406,28 @@ public class TestCaseReviewService {
|
||||||
}
|
}
|
||||||
testCaseReview.setStatus(TestCaseReviewStatus.Completed.name());
|
testCaseReview.setStatus(TestCaseReviewStatus.Completed.name());
|
||||||
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
|
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
|
||||||
|
SaveTestCaseReviewRequest testCaseReviewRequest = new SaveTestCaseReviewRequest();
|
||||||
|
TestCaseReview _testCaseReview = testCaseReviewMapper.selectByPrimaryKey(reviewId);
|
||||||
|
|
||||||
|
if (StringUtils.equals(TestCaseReviewStatus.Completed.name(), _testCaseReview.getStatus())) {
|
||||||
|
try {
|
||||||
|
BeanUtils.copyProperties(testCaseReviewRequest, _testCaseReview);
|
||||||
|
String context = getReviewContext(testCaseReviewRequest, NoticeConstants.Event.UPDATE);
|
||||||
|
Map<String, Object> paramMap = new HashMap<>(getReviewParamMap(testCaseReviewRequest));
|
||||||
|
NoticeModel noticeModel = NoticeModel.builder()
|
||||||
|
.operator(SessionUtils.getUserId())
|
||||||
|
.context(context)
|
||||||
|
.subject("测试评审通知")
|
||||||
|
.mailTemplate("track/ReviewEnd")
|
||||||
|
.paramMap(paramMap)
|
||||||
|
.event(NoticeConstants.Event.COMPLETE)
|
||||||
|
.status(TestCaseReviewStatus.Completed.name())
|
||||||
|
.build();
|
||||||
|
noticeSendService.send(NoticeConstants.TaskType.REVIEW_TASK, noticeModel);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TestReviewDTOWithMetric> listRelateAll(ReviewRelateRequest relateRequest) {
|
public List<TestReviewDTOWithMetric> listRelateAll(ReviewRelateRequest relateRequest) {
|
||||||
|
|
|
@ -982,6 +982,7 @@ public class TestPlanReportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
NoticeModel noticeModel = NoticeModel.builder()
|
NoticeModel noticeModel = NoticeModel.builder()
|
||||||
|
.operator(SessionUtils.getUserId())
|
||||||
.successContext(successContext)
|
.successContext(successContext)
|
||||||
.successMailTemplate(successfulMailTemplate)
|
.successMailTemplate(successfulMailTemplate)
|
||||||
.failedContext(failedContext)
|
.failedContext(failedContext)
|
||||||
|
|
|
@ -14,14 +14,20 @@ import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
|
||||||
import io.metersphere.api.dto.definition.request.*;
|
import io.metersphere.api.dto.definition.request.*;
|
||||||
import io.metersphere.api.dto.definition.request.variable.ScenarioVariable;
|
import io.metersphere.api.dto.definition.request.variable.ScenarioVariable;
|
||||||
import io.metersphere.api.jmeter.JMeterService;
|
import io.metersphere.api.jmeter.JMeterService;
|
||||||
import io.metersphere.api.service.*;
|
import io.metersphere.api.service.ApiAutomationService;
|
||||||
|
import io.metersphere.api.service.ApiDefinitionService;
|
||||||
|
import io.metersphere.api.service.ApiScenarioReportService;
|
||||||
|
import io.metersphere.api.service.ApiTestCaseService;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.*;
|
import io.metersphere.base.mapper.*;
|
||||||
import io.metersphere.base.mapper.ext.*;
|
import io.metersphere.base.mapper.ext.*;
|
||||||
import io.metersphere.commons.constants.*;
|
import io.metersphere.commons.constants.*;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.user.SessionUser;
|
import io.metersphere.commons.user.SessionUser;
|
||||||
import io.metersphere.commons.utils.*;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
|
import io.metersphere.commons.utils.MathUtils;
|
||||||
|
import io.metersphere.commons.utils.ServiceUtils;
|
||||||
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||||
import io.metersphere.dto.IssueTemplateDao;
|
import io.metersphere.dto.IssueTemplateDao;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
|
@ -190,7 +196,7 @@ public class TestPlanService {
|
||||||
return Optional.ofNullable(testPlanMapper.selectByPrimaryKey(testPlanId)).orElse(new TestPlanWithBLOBs());
|
return Optional.ofNullable(testPlanMapper.selectByPrimaryKey(testPlanId)).orElse(new TestPlanWithBLOBs());
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestPlan editTestPlan(TestPlanDTO testPlan) {
|
public TestPlan editTestPlan(TestPlanWithBLOBs testPlan) {
|
||||||
checkTestPlanExist(testPlan);
|
checkTestPlanExist(testPlan);
|
||||||
TestPlan res = testPlanMapper.selectByPrimaryKey(testPlan.getId()); // 先查一次库
|
TestPlan res = testPlanMapper.selectByPrimaryKey(testPlan.getId()); // 先查一次库
|
||||||
testPlan.setUpdateTime(System.currentTimeMillis());
|
testPlan.setUpdateTime(System.currentTimeMillis());
|
||||||
|
@ -226,7 +232,7 @@ public class TestPlanService {
|
||||||
i = testPlanMapper.updateByPrimaryKeyWithBLOBs(testPlan); // 更新
|
i = testPlanMapper.updateByPrimaryKeyWithBLOBs(testPlan); // 更新
|
||||||
}
|
}
|
||||||
|
|
||||||
return testPlan;
|
return testPlanMapper.selectByPrimaryKey(testPlan.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
//计划内容
|
//计划内容
|
||||||
|
@ -248,7 +254,7 @@ public class TestPlanService {
|
||||||
Map<String, Object> context = new HashMap<>();
|
Map<String, Object> context = new HashMap<>();
|
||||||
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
||||||
context.put("url", baseSystemConfigDTO.getUrl());
|
context.put("url", baseSystemConfigDTO.getUrl());
|
||||||
context.put("testPlanName", testPlan.getName());
|
context.put("name", testPlan.getName());
|
||||||
context.put("start", start);
|
context.put("start", start);
|
||||||
context.put("end", end);
|
context.put("end", end);
|
||||||
context.put("id", testPlan.getId());
|
context.put("id", testPlan.getId());
|
||||||
|
@ -374,11 +380,11 @@ public class TestPlanService {
|
||||||
statusList.addAll(testPlanApiCaseService.getExecResultByPlanId(testPlanId));
|
statusList.addAll(testPlanApiCaseService.getExecResultByPlanId(testPlanId));
|
||||||
statusList.addAll(testPlanScenarioCaseService.getExecResultByPlanId(testPlanId));
|
statusList.addAll(testPlanScenarioCaseService.getExecResultByPlanId(testPlanId));
|
||||||
statusList.addAll(testPlanLoadCaseService.getStatus(testPlanId));
|
statusList.addAll(testPlanLoadCaseService.getStatus(testPlanId));
|
||||||
TestPlanDTO testPlanDTO = new TestPlanDTO();
|
TestPlanWithBLOBs testPlanWithBLOBs = testPlanMapper.selectByPrimaryKey(testPlanId);
|
||||||
testPlanDTO.setId(testPlanId);
|
testPlanWithBLOBs.setId(testPlanId);
|
||||||
if (statusList.size() == 0) { // 原先status不是prepare, 但删除所有关联用例的情况
|
if (statusList.size() == 0) { // 原先status不是prepare, 但删除所有关联用例的情况
|
||||||
testPlanDTO.setStatus(TestPlanStatus.Prepare.name());
|
testPlanWithBLOBs.setStatus(TestPlanStatus.Prepare.name());
|
||||||
editTestPlan(testPlanDTO);
|
editTestPlan(testPlanWithBLOBs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int passNum = 0, prepareNum = 0, failNum = 0;
|
int passNum = 0, prepareNum = 0, failNum = 0;
|
||||||
|
@ -394,14 +400,16 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (passNum == statusList.size()) { // 全部通过
|
if (passNum == statusList.size()) { // 全部通过
|
||||||
testPlanDTO.setStatus(TestPlanStatus.Completed.name());
|
testPlanWithBLOBs.setStatus(TestPlanStatus.Completed.name());
|
||||||
this.editTestPlan(testPlanDTO);
|
this.editTestPlan(testPlanWithBLOBs);
|
||||||
|
// 发送成功通知
|
||||||
|
sendCompletedNotice(testPlanWithBLOBs);
|
||||||
} else if (prepareNum == 0 && passNum + failNum == statusList.size()) { // 已结束
|
} else if (prepareNum == 0 && passNum + failNum == statusList.size()) { // 已结束
|
||||||
testPlanDTO.setStatus(TestPlanStatus.Finished.name());
|
testPlanWithBLOBs.setStatus(TestPlanStatus.Finished.name());
|
||||||
editTestPlan(testPlanDTO);
|
editTestPlan(testPlanWithBLOBs);
|
||||||
} else if (prepareNum != 0) { // 进行中
|
} else if (prepareNum != 0) { // 进行中
|
||||||
testPlanDTO.setStatus(TestPlanStatus.Underway.name());
|
testPlanWithBLOBs.setStatus(TestPlanStatus.Underway.name());
|
||||||
editTestPlan(testPlanDTO);
|
editTestPlan(testPlanWithBLOBs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,30 +614,28 @@ public class TestPlanService {
|
||||||
testPlan.setStatus(status);
|
testPlan.setStatus(status);
|
||||||
testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
testPlanMapper.updateByPrimaryKeySelective(testPlan);
|
||||||
TestPlan testPlans = getTestPlan(planId);
|
TestPlan testPlans = getTestPlan(planId);
|
||||||
List<String> userIds = new ArrayList<>();
|
|
||||||
userIds.add(testPlans.getCreator());
|
sendCompletedNotice(testPlans);
|
||||||
AddTestPlanRequest _testPlans = new AddTestPlanRequest();
|
}
|
||||||
if (StringUtils.equals(TestPlanStatus.Completed.name(), testPlans.getStatus())) {
|
|
||||||
|
private void sendCompletedNotice(TestPlan testPlan) {
|
||||||
|
if (StringUtils.equals(TestPlanStatus.Completed.name(), testPlan.getStatus())) {
|
||||||
try {
|
try {
|
||||||
BeanUtils.copyBean(_testPlans, testPlans);
|
String context = getTestPlanContext(testPlan, NoticeConstants.Event.UPDATE);
|
||||||
String context = getTestPlanContext(_testPlans, NoticeConstants.Event.UPDATE);
|
Map<String, Object> paramMap = getTestPlanParamMap(testPlan);
|
||||||
User user = userMapper.selectByPrimaryKey(_testPlans.getCreator());
|
|
||||||
Map<String, Object> paramMap = getTestPlanParamMap(_testPlans);
|
|
||||||
paramMap.put("operator", user.getName());
|
|
||||||
NoticeModel noticeModel = NoticeModel.builder()
|
NoticeModel noticeModel = NoticeModel.builder()
|
||||||
|
.operator(SessionUtils.getUserId())
|
||||||
.context(context)
|
.context(context)
|
||||||
.relatedUsers(userIds)
|
|
||||||
.subject(Translator.get("test_plan_notification"))
|
.subject(Translator.get("test_plan_notification"))
|
||||||
.mailTemplate("track/TestPlanEnd")
|
.mailTemplate("track/TestPlanEnd")
|
||||||
.paramMap(paramMap)
|
.paramMap(paramMap)
|
||||||
.event(NoticeConstants.Event.UPDATE)
|
.event(NoticeConstants.Event.COMPLETE)
|
||||||
.build();
|
.build();
|
||||||
noticeSendService.send(NoticeConstants.TaskType.TEST_PLAN_TASK, noticeModel);
|
noticeSendService.send(NoticeConstants.TaskType.TEST_PLAN_TASK, noticeModel);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e.getMessage(), e);
|
LogUtil.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -691,7 +697,7 @@ public class TestPlanService {
|
||||||
return projectName;
|
return projectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTestPlanContext(AddTestPlanRequest testPlan, String type) {
|
private String getTestPlanContext(TestPlan testPlan, String type) {
|
||||||
User user = userMapper.selectByPrimaryKey(testPlan.getCreator());
|
User user = userMapper.selectByPrimaryKey(testPlan.getCreator());
|
||||||
Long startTime = testPlan.getPlannedStartTime();
|
Long startTime = testPlan.getPlannedStartTime();
|
||||||
Long endTime = testPlan.getPlannedEndTime();
|
Long endTime = testPlan.getPlannedEndTime();
|
||||||
|
@ -984,7 +990,7 @@ public class TestPlanService {
|
||||||
|
|
||||||
String planReportId = testPlanReport.getId();
|
String planReportId = testPlanReport.getId();
|
||||||
|
|
||||||
testPlanLog.info("ReportId[" + planReportId + "] created. TestPlanID:[" + testPlanID + "]. "+"API Run Config:【"+apiRunConfig+"】");
|
testPlanLog.info("ReportId[" + planReportId + "] created. TestPlanID:[" + testPlanID + "]. " + "API Run Config:【" + apiRunConfig + "】");
|
||||||
|
|
||||||
//不同任务的执行ID
|
//不同任务的执行ID
|
||||||
Map<String, String> executePerformanceIdMap = new HashMap<>();
|
Map<String, String> executePerformanceIdMap = new HashMap<>();
|
||||||
|
@ -992,7 +998,7 @@ public class TestPlanService {
|
||||||
Map<String, String> executeScenarioCaseIdMap = new HashMap<>();
|
Map<String, String> executeScenarioCaseIdMap = new HashMap<>();
|
||||||
|
|
||||||
//执行性能测试任务
|
//执行性能测试任务
|
||||||
Map<String,String> performaneReportIDMap = new LinkedHashMap<>();
|
Map<String, String> performaneReportIDMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
for (Map.Entry<String, String> entry : performanceIdMap.entrySet()) {
|
for (Map.Entry<String, String> entry : performanceIdMap.entrySet()) {
|
||||||
String id = entry.getKey();
|
String id = entry.getKey();
|
||||||
|
@ -1011,7 +1017,7 @@ public class TestPlanService {
|
||||||
try {
|
try {
|
||||||
reportId = performanceTestService.run(performanceRequest);
|
reportId = performanceTestService.run(performanceRequest);
|
||||||
if (reportId != null) {
|
if (reportId != null) {
|
||||||
performaneReportIDMap.put(reportId,caseID);
|
performaneReportIDMap.put(reportId, caseID);
|
||||||
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();
|
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();
|
||||||
testPlanLoadCase.setId(performanceRequest.getTestPlanLoadId());
|
testPlanLoadCase.setId(performanceRequest.getTestPlanLoadId());
|
||||||
testPlanLoadCase.setLoadReportId(reportId);
|
testPlanLoadCase.setLoadReportId(reportId);
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
<table tableName="test_plan"/>
|
<table tableName="test_plan"/>
|
||||||
<table tableName="test_case_test"/>-->
|
<table tableName="test_case_test"/>-->
|
||||||
<!-- <table tableName="api_test_environment"></table>-->
|
<!-- <table tableName="api_test_environment"></table>-->
|
||||||
<table tableName="api_test_case"/>
|
<table tableName="notification"/>
|
||||||
<!-- <table tableName="custom_field"></table>-->
|
<!-- <table tableName="custom_field"></table>-->
|
||||||
<!-- <table tableName="test_case"></table>-->
|
<!-- <table tableName="test_case"></table>-->
|
||||||
<!-- <table tableName="test_case"></table>-->
|
<!-- <table tableName="test_case"></table>-->
|
||||||
|
|
|
@ -12,6 +12,9 @@ export function getOperation(operation) {
|
||||||
case "COMMENT":
|
case "COMMENT":
|
||||||
operation = "评论了";
|
operation = "评论了";
|
||||||
break;
|
break;
|
||||||
|
case "COMPLETE":
|
||||||
|
operation = "完成了";
|
||||||
|
break;
|
||||||
case "CLOSE_SCHEDULE":
|
case "CLOSE_SCHEDULE":
|
||||||
operation = "关闭了定时任务";
|
operation = "关闭了定时任务";
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue