perf(消息通知): 优化发送通知的性能
--bug=1010865 --user=刘瑞斌 【测试跟踪】批量移动功能用例耗时较长 https://www.tapd.cn/55049933/s/1114701
This commit is contained in:
parent
260cefe5f9
commit
f7d6842656
|
@ -1136,6 +1136,7 @@ public class ApiDefinitionService {
|
|||
String context = request.getSwaggerUrl() + "导入失败";
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("url", request.getSwaggerUrl());
|
||||
paramMap.put("projectId", request.getProjectId());
|
||||
NoticeModel noticeModel = NoticeModel.builder()
|
||||
.operator(SessionUtils.getUserId())
|
||||
.context(context)
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.notice.controller;
|
|||
|
||||
import io.metersphere.commons.constants.OperLogConstants;
|
||||
import io.metersphere.commons.constants.OperLogModule;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.log.annotation.MsAuditLog;
|
||||
import io.metersphere.notice.domain.MessageDetail;
|
||||
import io.metersphere.notice.service.NoticeService;
|
||||
|
@ -24,7 +25,8 @@ public class NoticeController {
|
|||
|
||||
@GetMapping("/search/message/type/{type}")
|
||||
public List<MessageDetail> searchMessage(@PathVariable String type) {
|
||||
return noticeService.searchMessageByType(type);
|
||||
String projectId = SessionUtils.getCurrentProjectId();
|
||||
return noticeService.searchMessageByTypeAndProjectId(type, projectId);
|
||||
}
|
||||
|
||||
@GetMapping("/search/message/{testId}")
|
||||
|
|
|
@ -3,6 +3,7 @@ package io.metersphere.notice.sender;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import io.metersphere.commons.constants.NoticeConstants;
|
||||
import io.metersphere.commons.user.SessionUser;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||
import io.metersphere.notice.annotation.SendNotice;
|
||||
import io.metersphere.notice.service.NoticeSendService;
|
||||
|
@ -50,6 +51,7 @@ public class AfterReturningNoticeSendService {
|
|||
paramMap.put("url", baseSystemConfigDTO.getUrl());
|
||||
paramMap.put("operator", sessionUser.getName());
|
||||
paramMap.putAll(resource);
|
||||
paramMap.putIfAbsent("projectId", SessionUtils.getCurrentProjectId());
|
||||
// 占位符
|
||||
handleDefaultValues(paramMap);
|
||||
|
||||
|
|
|
@ -61,7 +61,8 @@ public class NoticeSendService {
|
|||
*/
|
||||
public void send(String taskType, NoticeModel noticeModel) {
|
||||
try {
|
||||
List<MessageDetail> messageDetails = noticeService.searchMessageByType(taskType);
|
||||
String projectId = (String) noticeModel.getParamMap().get("projectId");
|
||||
List<MessageDetail> messageDetails = noticeService.searchMessageByTypeAndProjectId(taskType, projectId);
|
||||
|
||||
// 异步发送通知
|
||||
messageDetails.stream()
|
||||
|
@ -132,7 +133,7 @@ public class NoticeSendService {
|
|||
// default:
|
||||
// break;
|
||||
// }
|
||||
messageDetails = noticeService.searchMessageByTypeAndWorkspaceId(taskType, project.getWorkspaceId());
|
||||
messageDetails = noticeService.searchMessageByTypeAndProjectId(taskType, project.getId());
|
||||
|
||||
// 异步发送通知
|
||||
messageDetails.stream()
|
||||
|
|
|
@ -111,20 +111,9 @@ public class NoticeService {
|
|||
return scheduleMessageTask;
|
||||
}
|
||||
|
||||
public List<MessageDetail> searchMessageByType(String type) {
|
||||
public List<MessageDetail> searchMessageByTypeAndProjectId(String type, String projectId) {
|
||||
try {
|
||||
String workspaceId = SessionUtils.getCurrentWorkspaceId();
|
||||
return getMessageDetails(type, workspaceId);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<MessageDetail> searchMessageByTypeAndWorkspaceId(String type, String workspaceId) {
|
||||
try {
|
||||
return getMessageDetails(type, workspaceId);
|
||||
return getMessageDetails(type, projectId);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
return new ArrayList<>();
|
||||
|
|
Loading…
Reference in New Issue