Merge pull request #3559 from dataease/pr@dev@fix_msg_channel_block

fix(消息管理): 单一渠道异常阻塞全部消息渠道
This commit is contained in:
王嘉豪 2022-10-31 18:21:21 +08:00 committed by GitHub
commit 25950fc4e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
package io.dataease.service.message; package io.dataease.service.message;
import io.dataease.commons.utils.LogUtil;
import io.dataease.ext.ExtSysMsgMapper; import io.dataease.ext.ExtSysMsgMapper;
import io.dataease.commons.constants.SysMsgConstants; import io.dataease.commons.constants.SysMsgConstants;
import io.dataease.commons.utils.AuthUtils; import io.dataease.commons.utils.AuthUtils;
@ -25,6 +26,7 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -65,7 +67,7 @@ public class SysMsgService {
orderClause = String.join(", ", orders); orderClause = String.join(", ", orders);
} }
if (CollectionUtils.isNotEmpty(typeIds)){ if (CollectionUtils.isNotEmpty(typeIds)) {
criteria.andTypeIdIn(typeIds); criteria.andTypeIdIn(typeIds);
} }
@ -120,7 +122,7 @@ public class SysMsgService {
return sysMsgTypeMapper.selectByExample(example); return sysMsgTypeMapper.selectByExample(example);
} }
private List<SettingTreeNode> buildTree(List<SysMsgType> lists){ private List<SettingTreeNode> buildTree(List<SysMsgType> lists) {
List<SettingTreeNode> rootNodes = new ArrayList<>(); List<SettingTreeNode> rootNodes = new ArrayList<>();
lists.forEach(node -> { lists.forEach(node -> {
SettingTreeNode settingTreeNode = convert(node); SettingTreeNode settingTreeNode = convert(node);
@ -183,6 +185,7 @@ public class SysMsgService {
/** /**
* 修改了订阅信息 需要清除缓存 * 修改了订阅信息 需要清除缓存
*
* @param request * @param request
* @param userId * @param userId
*/ */
@ -241,22 +244,29 @@ public class SysMsgService {
List<SubscribeNode> subscribes = subscribes(userId); List<SubscribeNode> subscribes = subscribes(userId);
if (CollectionUtils.isNotEmpty(subscribes)) { if (CollectionUtils.isNotEmpty(subscribes)) {
subscribes.stream().filter(item -> item.getTypeId().equals(typeId)).forEach(sub -> { for (int i = 0; i < subscribes.size(); i++) {
SendService sendService = serviceByChannel(sub.getChannelId()); SubscribeNode item = subscribes.get(i);
if (item.getTypeId().equals(typeId)) {
try {
SendService sendService = serviceByChannel(item.getChannelId());
sendService.sendMsg(userId, typeId, content, param); sendService.sendMsg(userId, typeId, content, param);
}); } catch (Exception e) {
LogUtil.error(e.getMessage(), e);
}
}
}
} }
} }
private SendService serviceByChannel(Long channelId){ private SendService serviceByChannel(Long channelId) {
String beanName = sysMsgChannelMapper.selectByPrimaryKey(channelId).getServiceName(); String beanName = sysMsgChannelMapper.selectByPrimaryKey(channelId).getServiceName();
return (SendService)CommonBeanFactory.getBean(beanName); return (SendService) CommonBeanFactory.getBean(beanName);
} }
/** /**
* 查询用户订阅的消息 并缓存 * 查询用户订阅的消息 并缓存
*
* @param userId * @param userId
* @return * @return
*/ */
@ -280,7 +290,7 @@ public class SysMsgService {
List<SysMsgSetting> defaultSettings = defaultSettings(); List<SysMsgSetting> defaultSettings = defaultSettings();
defaultSettings.forEach(setting -> { defaultSettings.forEach(setting -> {
if (!sourceLists.stream().anyMatch(item -> item.match(setting))){ if (!sourceLists.stream().anyMatch(item -> item.match(setting))) {
sourceLists.add(setting); sourceLists.add(setting);
} }
}); });
@ -297,7 +307,7 @@ public class SysMsgService {
public Long overTime() { public Long overTime() {
String msgTimeOut = systemParameterService.basicInfo().getMsgTimeOut(); String msgTimeOut = systemParameterService.basicInfo().getMsgTimeOut();
if(StringUtils.isNotBlank(msgTimeOut)) { if (StringUtils.isNotBlank(msgTimeOut)) {
overDays = Integer.parseInt(msgTimeOut); overDays = Integer.parseInt(msgTimeOut);
} }
Long currentTime = System.currentTimeMillis(); Long currentTime = System.currentTimeMillis();
@ -311,5 +321,4 @@ public class SysMsgService {
} }
} }