fix:Jenkins通知性能测试报告
This commit is contained in:
parent
19372d2c7a
commit
27b545d8d8
|
@ -50,11 +50,12 @@ public class NoticeSendService {
|
|||
}
|
||||
|
||||
public void send(String taskType, NoticeModel noticeModel) {
|
||||
String loadReportId = (String) noticeModel.getParamMap().get("id");
|
||||
try {
|
||||
List<MessageDetail> messageDetails;
|
||||
switch (taskType) {
|
||||
case NoticeConstants.Mode.API:
|
||||
messageDetails = noticeService.searchMessageByType(NoticeConstants.TaskType.JENKINS_TASK);
|
||||
messageDetails = noticeService.searchMessageByTypeBySend(NoticeConstants.TaskType.JENKINS_TASK, loadReportId);
|
||||
break;
|
||||
case NoticeConstants.Mode.SCHEDULE:
|
||||
messageDetails = noticeService.searchMessageByTestId(noticeModel.getTestId());
|
||||
|
|
|
@ -2,7 +2,9 @@ package io.metersphere.notice.service;
|
|||
|
||||
import io.metersphere.base.domain.MessageTask;
|
||||
import io.metersphere.base.domain.MessageTaskExample;
|
||||
import io.metersphere.base.mapper.LoadTestReportMapper;
|
||||
import io.metersphere.base.mapper.MessageTaskMapper;
|
||||
import io.metersphere.base.mapper.UserMapper;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.user.SessionUser;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
|
@ -23,6 +25,10 @@ import java.util.stream.Collectors;
|
|||
public class NoticeService {
|
||||
@Resource
|
||||
private MessageTaskMapper messageTaskMapper;
|
||||
@Resource
|
||||
private LoadTestReportMapper loadTestReportMapper;
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
|
||||
public void saveMessageTask(MessageDetail messageDetail) {
|
||||
MessageTaskExample example = new MessageTaskExample();
|
||||
|
@ -133,6 +139,42 @@ public class NoticeService {
|
|||
}
|
||||
}
|
||||
|
||||
public List<MessageDetail> searchMessageByTypeBySend(String type, String id) {
|
||||
try {
|
||||
String orgId = "";
|
||||
if (null == SessionUtils.getUser()) {
|
||||
String userId = loadTestReportMapper.selectByPrimaryKey(id).getUserId();
|
||||
orgId = userMapper.selectByPrimaryKey(userId).getLastOrganizationId();
|
||||
} else {
|
||||
SessionUser user = SessionUtils.getUser();
|
||||
orgId = user.getLastOrganizationId();
|
||||
}
|
||||
List<MessageDetail> messageDetails = new ArrayList<>();
|
||||
MessageTaskExample example = new MessageTaskExample();
|
||||
example.createCriteria()
|
||||
.andTaskTypeEqualTo(type)
|
||||
.andOrganizationIdEqualTo(orgId);
|
||||
List<MessageTask> messageTaskLists = messageTaskMapper.selectByExampleWithBLOBs(example);
|
||||
|
||||
Map<String, List<MessageTask>> messageTaskMap = messageTaskLists.stream()
|
||||
.collect(Collectors.groupingBy(NoticeService::fetchGroupKey));
|
||||
messageTaskMap.forEach((k, v) -> {
|
||||
MessageDetail messageDetail = getMessageDetail(v);
|
||||
messageDetails.add(messageDetail);
|
||||
});
|
||||
|
||||
return messageDetails.stream()
|
||||
.sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed())
|
||||
.collect(Collectors.toList())
|
||||
.stream()
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
private MessageDetail getMessageDetail(List<MessageTask> messageTasks) {
|
||||
Set<String> userIds = new HashSet<>();
|
||||
|
||||
|
|
Loading…
Reference in New Issue