feat(测试计划): 计划执行通知
This commit is contained in:
parent
9e22faaf36
commit
14cd8371e7
|
@ -572,7 +572,7 @@ public class TestPlanExecuteService {
|
||||||
// 执行生成报告, 执行状态为已完成, 执行及结束时间为当前时间
|
// 执行生成报告, 执行状态为已完成, 执行及结束时间为当前时间
|
||||||
postParam.setEndTime(System.currentTimeMillis());
|
postParam.setEndTime(System.currentTimeMillis());
|
||||||
postParam.setExecStatus(ExecStatus.COMPLETED.name());
|
postParam.setExecStatus(ExecStatus.COMPLETED.name());
|
||||||
testPlanReportService.postHandleReport(postParam);
|
testPlanReportService.postHandleReport(postParam, false);
|
||||||
|
|
||||||
if (!isGroupReport) {
|
if (!isGroupReport) {
|
||||||
TestPlanReport testPlanReport = testPlanReportService.selectById(reportId);
|
TestPlanReport testPlanReport = testPlanReportService.selectById(reportId);
|
||||||
|
|
|
@ -92,6 +92,8 @@ public class TestPlanReportService {
|
||||||
private TestPlanReportAttachmentMapper testPlanReportAttachmentMapper;
|
private TestPlanReportAttachmentMapper testPlanReportAttachmentMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private BaseUserMapper baseUserMapper;
|
private BaseUserMapper baseUserMapper;
|
||||||
|
@Resource
|
||||||
|
private TestPlanSendNoticeService testPlanSendNoticeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询报告列表
|
* 分页查询报告列表
|
||||||
|
@ -270,7 +272,7 @@ public class TestPlanReportService {
|
||||||
postParam.setExecuteTime(System.currentTimeMillis());
|
postParam.setExecuteTime(System.currentTimeMillis());
|
||||||
postParam.setEndTime(System.currentTimeMillis());
|
postParam.setEndTime(System.currentTimeMillis());
|
||||||
postParam.setExecStatus(ExecStatus.COMPLETED.name());
|
postParam.setExecStatus(ExecStatus.COMPLETED.name());
|
||||||
postHandleReport(postParam);
|
postHandleReport(postParam, true);
|
||||||
}
|
}
|
||||||
preReportMap.put(plan.getId(), preReport.getId());
|
preReportMap.put(plan.getId(), preReport.getId());
|
||||||
});
|
});
|
||||||
|
@ -458,7 +460,7 @@ public class TestPlanReportService {
|
||||||
*
|
*
|
||||||
* @param postParam 后置处理参数
|
* @param postParam 后置处理参数
|
||||||
*/
|
*/
|
||||||
public void postHandleReport(TestPlanReportPostParam postParam) {
|
public void postHandleReport(TestPlanReportPostParam postParam, boolean useManual) {
|
||||||
/*
|
/*
|
||||||
* 处理报告(执行状态, 结束时间)
|
* 处理报告(执行状态, 结束时间)
|
||||||
*/
|
*/
|
||||||
|
@ -486,6 +488,11 @@ public class TestPlanReportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
testPlanReportMapper.updateByPrimaryKeySelective(planReport);
|
testPlanReportMapper.updateByPrimaryKeySelective(planReport);
|
||||||
|
|
||||||
|
// 发送计划执行通知
|
||||||
|
if (!useManual) {
|
||||||
|
testPlanSendNoticeService.sendExecuteNotice(planReport.getCreateUser(), planReport.getTestPlanId(), planReport.getProjectId(), planReport.getResultStatus());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,6 +10,7 @@ import io.metersphere.plan.dto.request.TestPlanCreateRequest;
|
||||||
import io.metersphere.plan.dto.request.TestPlanUpdateRequest;
|
import io.metersphere.plan.dto.request.TestPlanUpdateRequest;
|
||||||
import io.metersphere.plan.mapper.TestPlanConfigMapper;
|
import io.metersphere.plan.mapper.TestPlanConfigMapper;
|
||||||
import io.metersphere.plan.mapper.TestPlanMapper;
|
import io.metersphere.plan.mapper.TestPlanMapper;
|
||||||
|
import io.metersphere.sdk.constants.ReportStatus;
|
||||||
import io.metersphere.sdk.constants.TestPlanConstants;
|
import io.metersphere.sdk.constants.TestPlanConstants;
|
||||||
import io.metersphere.sdk.util.BeanUtils;
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
|
@ -25,6 +26,7 @@ import org.apache.commons.beanutils.BeanMap;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -161,4 +163,35 @@ public class TestPlanSendNoticeService {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报告汇总-计划执行结束通知
|
||||||
|
* @param currentUser 当前用户
|
||||||
|
* @param planId 计划ID
|
||||||
|
* @param projectId 项目ID
|
||||||
|
* @param executeResult 执行结果
|
||||||
|
*/
|
||||||
|
@Async
|
||||||
|
public void sendExecuteNotice(String currentUser, String planId, String projectId, String executeResult) {
|
||||||
|
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId);
|
||||||
|
if (testPlan != null) {
|
||||||
|
User user = userMapper.selectByPrimaryKey(currentUser);
|
||||||
|
setLanguage(user.getLanguage());
|
||||||
|
Map<String, String> defaultTemplateMap = MessageTemplateUtils.getDefaultTemplateMap();
|
||||||
|
String template = defaultTemplateMap.get(StringUtils.equals(executeResult, ReportStatus.SUCCESS.name()) ?
|
||||||
|
NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_SUCCESSFUL : NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_FAILED);
|
||||||
|
Map<String, String> defaultSubjectMap = MessageTemplateUtils.getDefaultTemplateSubjectMap();
|
||||||
|
String subject = defaultSubjectMap.get(StringUtils.equals(executeResult, ReportStatus.SUCCESS.name()) ?
|
||||||
|
NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_SUCCESSFUL : NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_FAILED);
|
||||||
|
Map<String, Object> paramMap = new HashMap<>(4);
|
||||||
|
paramMap.put(NoticeConstants.RelatedUser.OPERATOR, user.getName());
|
||||||
|
paramMap.put("name", testPlan.getName());
|
||||||
|
paramMap.put("projectId", projectId);
|
||||||
|
paramMap.put("Language", user.getLanguage());
|
||||||
|
NoticeModel noticeModel = NoticeModel.builder().operator(currentUser).excludeSelf(false)
|
||||||
|
.context(template).subject(subject).paramMap(paramMap).event(StringUtils.equals(executeResult, ReportStatus.SUCCESS.name()) ?
|
||||||
|
NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_SUCCESSFUL : NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_FAILED).build();
|
||||||
|
noticeSendService.send(NoticeConstants.TaskType.TEST_PLAN_TASK, noticeModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue