perf(消息通知): 优化发送通知的性能

--bug=1010865 --user=刘瑞斌 【测试跟踪】批量移动功能用例耗时较长 https://www.tapd.cn/55049933/s/1114701
This commit is contained in:
CaptainB 2022-03-09 12:20:33 +08:00 committed by 刘瑞斌
parent 0bb27faa76
commit 0219728c98
2 changed files with 4 additions and 4 deletions

View File

@ -3,7 +3,6 @@ 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;
@ -27,7 +26,7 @@ public class AfterReturningNoticeSendService {
private NoticeSendService noticeSendService;
@Async
public void sendNotice(SendNotice sendNotice, Object retValue, SessionUser sessionUser) {
public void sendNotice(SendNotice sendNotice, Object retValue, SessionUser sessionUser, String currentProjectId) {
//
List<Map> resources = new ArrayList<>();
String source = sendNotice.source();
@ -51,7 +50,7 @@ public class AfterReturningNoticeSendService {
paramMap.put("url", baseSystemConfigDTO.getUrl());
paramMap.put("operator", sessionUser.getName());
paramMap.putAll(resource);
paramMap.putIfAbsent("projectId", SessionUtils.getCurrentProjectId());
paramMap.putIfAbsent("projectId", currentProjectId);
// 占位符
handleDefaultValues(paramMap);

View File

@ -123,7 +123,8 @@ public class SendNoticeAspect {
context.setVariable(params[len], args[len]);
}
SessionUser sessionUser = SessionUtils.getUser();
afterReturningNoticeSendService.sendNotice(sendNotice, retValue, sessionUser);
String currentProjectId = SessionUtils.getCurrentProjectId();
afterReturningNoticeSendService.sendNotice(sendNotice, retValue, sessionUser, currentProjectId);
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
}