fix: 修复账号不一致,更新不发送,时间问题

This commit is contained in:
wenyann 2020-11-25 10:13:05 +08:00
parent 8e4ada8e18
commit 18c810178a
6 changed files with 74 additions and 44 deletions

View File

@ -2,10 +2,7 @@ package io.metersphere.notice.service;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.UserMapper; import io.metersphere.base.mapper.UserMapper;
import io.metersphere.commons.constants.APITestStatus; import io.metersphere.commons.constants.*;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.ParamConstants;
import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.EncryptUtils; import io.metersphere.commons.utils.EncryptUtils;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
@ -321,6 +318,15 @@ public class MailService {
context.put("start", start); context.put("start", start);
context.put("end", end); context.put("end", end);
context.put("id", reviewRequest.getId()); context.put("id", reviewRequest.getId());
String status = "";
if (StringUtils.equals(TestPlanStatus.Underway.name(), reviewRequest.getStatus())) {
status = "进行中";
} else if (StringUtils.equals(TestPlanStatus.Prepare.name(), reviewRequest.getStatus())) {
status = "未开始";
} else if (StringUtils.equals(TestPlanStatus.Completed.name(), reviewRequest.getStatus())) {
status = "已完成";
}
context.put("status", status);
return context; return context;
} }
@ -347,14 +353,21 @@ public class MailService {
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());
String status = "";
if (StringUtils.equals(TestPlanStatus.Underway.name(), testPlan.getStatus())) {
status = "进行中";
} else if (StringUtils.equals(TestPlanStatus.Prepare.name(), testPlan.getStatus())) {
status = "未开始";
} else if (StringUtils.equals(TestPlanStatus.Completed.name(), testPlan.getStatus())) {
status = "已完成";
}
context.put("status", status);
User user = userMapper.selectByPrimaryKey(testPlan.getCreator()); User user = userMapper.selectByPrimaryKey(testPlan.getCreator());
context.put("creator", user.getName()); context.put("creator", user.getName());
return context; return context;
} }
private JavaMailSenderImpl getMailSender() { private JavaMailSenderImpl getMailSender() {
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl(); JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
List<SystemParameter> paramList = systemParameterService.getParamList(ParamConstants.Classify.MAIL.getValue()); List<SystemParameter> paramList = systemParameterService.getParamList(ParamConstants.Classify.MAIL.getValue());
@ -396,6 +409,7 @@ public class MailService {
} else { } else {
template = RegExUtils.replaceAll(template, "\\$\\{" + k + "}", "未设置"); template = RegExUtils.replaceAll(template, "\\$\\{" + k + "}", "未设置");
} }
} }
} }
return template; return template;
@ -405,7 +419,7 @@ public class MailService {
List<String> addresseeIdList = new ArrayList<>(); List<String> addresseeIdList = new ArrayList<>();
if (StringUtils.equals(eventType, messageDetail.getEvent())) { if (StringUtils.equals(eventType, messageDetail.getEvent())) {
messageDetail.getUserIds().forEach(u -> { messageDetail.getUserIds().forEach(u -> {
if (!StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.MAINTAINER, u)) { if (!StringUtils.equals(NoticeConstants.EXECUTOR, u) && !StringUtils.equals(NoticeConstants.FOUNDER, u) && !StringUtils.equals(NoticeConstants.MAINTAINER, u)) {
addresseeIdList.add(u); addresseeIdList.add(u);
} }
if (StringUtils.equals(NoticeConstants.CREATE, eventType) && StringUtils.equals(NoticeConstants.EXECUTOR, u)) { if (StringUtils.equals(NoticeConstants.CREATE, eventType) && StringUtils.equals(NoticeConstants.EXECUTOR, u)) {

View File

@ -187,27 +187,25 @@ public class TestCaseReviewService {
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview); testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
List<String> userIds = new ArrayList<>(); List<String> userIds = new ArrayList<>();
userIds.addAll(testCaseReview.getUserIds()); userIds.addAll(testCaseReview.getUserIds());
if (StringUtils.equals(TestPlanStatus.Completed.name(), testCaseReview.getStatus())) { try {
try { String context = getReviewContext(testCaseReview, NoticeConstants.UPDATE);
String context = getReviewContext(testCaseReview, NoticeConstants.UPDATE); MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
MessageSettingDetail messageSettingDetail = noticeService.searchMessage(); List<MessageDetail> taskList = messageSettingDetail.getReviewTask();
List<MessageDetail> taskList = messageSettingDetail.getReviewTask(); taskList.forEach(r -> {
taskList.forEach(r -> { switch (r.getType()) {
switch (r.getType()) { case NoticeConstants.NAIL_ROBOT:
case NoticeConstants.NAIL_ROBOT: dingTaskService.sendNailRobot(r, userIds, context, NoticeConstants.UPDATE);
dingTaskService.sendNailRobot(r, userIds, context, NoticeConstants.UPDATE); break;
break; case NoticeConstants.WECHAT_ROBOT:
case NoticeConstants.WECHAT_ROBOT: wxChatTaskService.sendWechatRobot(r, userIds, context, NoticeConstants.UPDATE);
wxChatTaskService.sendWechatRobot(r, userIds, context, NoticeConstants.UPDATE); break;
break; case NoticeConstants.EMAIL:
case NoticeConstants.EMAIL: mailService.sendEndNotice(r, userIds, testCaseReview, NoticeConstants.UPDATE);
mailService.sendReviewerNotice(r, userIds, testCaseReview, NoticeConstants.UPDATE); break;
break; }
} });
}); } catch (Exception e) {
} catch (Exception e) { LogUtil.error(e);
LogUtil.error(e);
}
} }
} }
@ -585,7 +583,15 @@ public class TestCaseReviewService {
if (StringUtils.equals(NoticeConstants.CREATE, type)) { if (StringUtils.equals(NoticeConstants.CREATE, type)) {
context = "测试评审任务通知:" + user.getName() + "发起的" + "'" + reviewRequest.getName() + "'" + "待开始,计划开始时间是" + start + "计划结束时间为" + end + "请跟进"; context = "测试评审任务通知:" + user.getName() + "发起的" + "'" + reviewRequest.getName() + "'" + "待开始,计划开始时间是" + start + "计划结束时间为" + end + "请跟进";
} else if (StringUtils.equals(NoticeConstants.UPDATE, type)) { } else if (StringUtils.equals(NoticeConstants.UPDATE, type)) {
context = "测试评审任务通知:" + user.getName() + "发起的" + "'" + reviewRequest.getName() + "'" + "已完成,计划开始时间是" + start + "计划结束时间为" + end + "已完成"; String status = "";
if (StringUtils.equals(TestPlanStatus.Underway.name(), reviewRequest.getStatus())) {
status = "进行中";
} else if (StringUtils.equals(TestPlanStatus.Prepare.name(), reviewRequest.getStatus())) {
status = "未开始";
} else if (StringUtils.equals(TestPlanStatus.Completed.name(), reviewRequest.getStatus())) {
status = "已完成";
}
context = "测试评审任务通知:" + user.getName() + "发起的" + "'" + reviewRequest.getName() + "'" + "计划开始时间是" + start + "计划结束时间为" + end + status;
} else if (StringUtils.equals(NoticeConstants.DELETE, type)) { } else if (StringUtils.equals(NoticeConstants.DELETE, type)) {
context = "测试评审任务通知:" + user.getName() + "发起的" + "'" + reviewRequest.getName() + "'" + "计划开始时间是" + start + "计划结束时间为" + end + "已删除"; context = "测试评审任务通知:" + user.getName() + "发起的" + "'" + reviewRequest.getName() + "'" + "计划开始时间是" + start + "计划结束时间为" + end + "已删除";
} }

View File

@ -159,13 +159,16 @@ public class TestPlanService {
//进行中状态写入实际开始时间 //进行中状态写入实际开始时间
if (TestPlanStatus.Underway.name().equals(testPlan.getStatus())) { if (TestPlanStatus.Underway.name().equals(testPlan.getStatus())) {
testPlan.setActualStartTime(System.currentTimeMillis()); testPlan.setActualStartTime(System.currentTimeMillis());
} else if (TestPlanStatus.Completed.name().equals(testPlan.getStatus())) { } else if (TestPlanStatus.Completed.name().equals(testPlan.getStatus())) {
List<String> userIds = new ArrayList<>();
userIds.add(testPlan.getPrincipal());
AddTestPlanRequest testPlans = new AddTestPlanRequest();
//已完成写入实际完成时间 //已完成写入实际完成时间
testPlan.setActualEndTime(System.currentTimeMillis()); testPlan.setActualEndTime(System.currentTimeMillis());
}
List<String> userIds = new ArrayList<>();
userIds.add(testPlan.getPrincipal());
AddTestPlanRequest testPlans = new AddTestPlanRequest();
int i = testPlanMapper.updateByPrimaryKeySelective(testPlan);
if (!StringUtils.isBlank(testPlan.getStatus())) {
try { try {
BeanUtils.copyBean(testPlans, getTestPlan(testPlan.getId())); BeanUtils.copyBean(testPlans, getTestPlan(testPlan.getId()));
String context = getTestPlanContext(testPlans, NoticeConstants.UPDATE); String context = getTestPlanContext(testPlans, NoticeConstants.UPDATE);
@ -180,7 +183,7 @@ public class TestPlanService {
wxChatTaskService.sendWechatRobot(r, userIds, context, NoticeConstants.UPDATE); wxChatTaskService.sendWechatRobot(r, userIds, context, NoticeConstants.UPDATE);
break; break;
case NoticeConstants.EMAIL: case NoticeConstants.EMAIL:
mailService.sendTestPlanStartNotice(r, userIds, testPlans, NoticeConstants.UPDATE); mailService.sendTestPlanEndNotice(r, userIds, testPlans, NoticeConstants.UPDATE);
break; break;
} }
}); });
@ -188,8 +191,7 @@ public class TestPlanService {
LogUtil.error(e); LogUtil.error(e);
} }
} }
return i;
return testPlanMapper.updateByPrimaryKeySelective(testPlan);
} }
private void editTestPlanProject(TestPlanDTO testPlan) { private void editTestPlanProject(TestPlanDTO testPlan) {
@ -557,11 +559,19 @@ public class TestPlanService {
} }
String context = ""; String context = "";
if (StringUtils.equals(NoticeConstants.CREATE, type)) { if (StringUtils.equals(NoticeConstants.CREATE, type)) {
context = "测试计划任务通知:" + user.getName() + "创建的" + "'" + testPlan.getName() + "'" + "待开始,计划开始时间是" + start + "计划结束时间为" + end + "请跟进"; context = "测试计划任务通知:" + user.getName() + "创建的" + "'" + testPlan.getName() + "'" + "待开始,计划开始时间是:" + "'" + start + "'" + ";" + "计划结束时间是:" + "'" + end + "'" + " " + "请跟进";
} else if (StringUtils.equals(NoticeConstants.UPDATE, type)) { } else if (StringUtils.equals(NoticeConstants.UPDATE, type)) {
context = "测试计划任务通知:" + user.getName() + "创建的" + "'" + testPlan.getName() + "'" + "已完成,计划开始时间是" + start + "计划结束时间为" + end + "已完成"; String status = "";
if (StringUtils.equals(TestPlanStatus.Underway.name(), testPlan.getStatus())) {
status = "进行中";
} else if (StringUtils.equals(TestPlanStatus.Prepare.name(), testPlan.getStatus())) {
status = "未开始";
} else if (StringUtils.equals(TestPlanStatus.Completed.name(), testPlan.getStatus())) {
status = "已完成";
}
context = "测试计划任务通知:" + user.getName() + "创建的" + "'" + testPlan.getName() + "'" + "计划开始时间是:" + "'" + start + "'" + ";" + "计划结束时间是:" + "'" + end + "'" + " " + status;
} else if (StringUtils.equals(NoticeConstants.DELETE, type)) { } else if (StringUtils.equals(NoticeConstants.DELETE, type)) {
context = "测试计划任务通知:" + user.getName() + "创建的" + "'" + testPlan.getName() + "'" + "计划开始时间是" + start + "计划结束时间为" + end + "已删除"; context = "测试计划任务通知:" + user.getName() + "创建的" + "'" + testPlan.getName() + "'" + "计划开始时间是:" + "'" + start + "'" + ";" + "计划结束时间是:" + "'" + end + "'" + " " + "已删除";
} }
return context; return context;
} }

View File

@ -6,7 +6,7 @@
</head> </head>
<body> <body>
<div> <div>
<p style="text-align: left"> ${maintainer} 维护的<br/> <p style="text-align: left"> ${maintainer} <br/>
${testCaseName}<br/> ${testCaseName}<br/>
添加评论:${description}<br/> 添加评论:${description}<br/>
点击下面链接进入用例评审页面</p> 点击下面链接进入用例评审页面</p>

View File

@ -7,10 +7,10 @@
<body> <body>
<div> <div>
<p style="text-align: left">${creator} 发起的:<br> <p style="text-align: left">${creator} 发起的:<br>
${reviewName}已完成<br> ${reviewName}<br>
计划开始时间是:${start}<br> 计划开始时间是:${start}<br>
计划结束时间为:${end}<br> 计划结束时间为:${end}<br>
已完成<br> ${status}<br>
点击下面链接进入用例评审页面</p> 点击下面链接进入用例评审页面</p>
<a href="${url}/#/track/review/view">${url}/#/track/review/view</a> <a href="${url}/#/track/review/view">${url}/#/track/review/view</a>
</div> </div>

View File

@ -7,10 +7,10 @@
<body> <body>
<div> <div>
<p style="text-align: left">${creator} 创建的:<br> <p style="text-align: left">${creator} 创建的:<br>
${testPlanName}已完成<br> ${testPlanName}<br>
计划开始时间是:${start}<br> 计划开始时间是:${start}<br>
计划结束时间为:${end}<br> 计划结束时间为:${end}<br>
已完成<br> ${status}<br>
点击下面链接进入测试计划页面</p> 点击下面链接进入测试计划页面</p>
<a href="${url}/#/track/plan/view/${id}">${url}/#/track/plan/view</a> <a href="${url}/#/track/plan/view/${id}">${url}/#/track/plan/view</a>
</div> </div>