消息推送调整
This commit is contained in:
@@ -22,6 +22,7 @@ import com.njcn.zlevent.service.ICsEventUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.BufferedReader;
|
||||
@@ -86,7 +87,7 @@ public class SendEventUtils {
|
||||
public void sendUser(Integer eventType,String type,String devId, String eventName, LocalDateTime eventTime, String id) {
|
||||
int code;
|
||||
List<User> users = new ArrayList<>();
|
||||
List<String> devCodeList = new ArrayList<>();
|
||||
List<String> devCodeList;
|
||||
List<CsEventSendMsg> csEventSendMsgList = new ArrayList<>();
|
||||
NoticeUserDto noticeUserDto = new NoticeUserDto();
|
||||
NoticeUserDto.Payload payload = new NoticeUserDto.Payload();
|
||||
@@ -99,7 +100,8 @@ public class SendEventUtils {
|
||||
case "1":
|
||||
code = 2;
|
||||
//设备自身事件 不推送给用户,推送给业务管理
|
||||
users = appUserFeignClient.getAdminInfo().getData();
|
||||
users = getAdminUser();
|
||||
if (CollectionUtil.isNotEmpty(users)){
|
||||
noticeUserDto.setPushClientId(Collections.singletonList(users.get(0).getDevCode()));
|
||||
noticeUserDto.setTitle("设备事件");
|
||||
//记录需要通知的用户和事件关系
|
||||
@@ -108,11 +110,12 @@ public class SendEventUtils {
|
||||
csEventUser.setStatus(0);
|
||||
csEventUser.setEventId(id);
|
||||
result.add(csEventUser);
|
||||
}
|
||||
break;
|
||||
case "2":
|
||||
code = 0;
|
||||
//暂态事件
|
||||
users = getEventUser(devId);
|
||||
users = getEventUser(devId,0);
|
||||
devCodeList = users.stream().map(User::getDevCode).collect(Collectors.toList());
|
||||
noticeUserDto.setPushClientId(devCodeList);
|
||||
noticeUserDto.setTitle("暂态事件");
|
||||
@@ -129,7 +132,7 @@ public class SendEventUtils {
|
||||
case "3":
|
||||
code = 1;
|
||||
//稳态事件
|
||||
users = getEventUser(devId);
|
||||
users = getEventUser(devId,1);
|
||||
devCodeList = users.stream().map(User::getDevCode).collect(Collectors.toList());
|
||||
noticeUserDto.setPushClientId(devCodeList);
|
||||
noticeUserDto.setTitle("稳态事件");
|
||||
@@ -159,9 +162,10 @@ public class SendEventUtils {
|
||||
else if (eventType == 2){
|
||||
switch (type) {
|
||||
case "1":
|
||||
eventName = epdFeignClient.findByName(eventName).getData().getShowName();
|
||||
//Ⅰ级告警 不推送给用户,推送给业务管理
|
||||
users = appUserFeignClient.getAdminInfo().getData();
|
||||
users = getAdminUser();
|
||||
if (CollectionUtil.isNotEmpty(users)){
|
||||
eventName = epdFeignClient.findByName(eventName).getData().getShowName();
|
||||
noticeUserDto.setPushClientId(Collections.singletonList(users.get(0).getDevCode()));
|
||||
//记录需要通知的用户和事件关系
|
||||
users.forEach(item->{
|
||||
@@ -171,12 +175,13 @@ public class SendEventUtils {
|
||||
csEventUser.setEventId(id);
|
||||
result.add(csEventUser);
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "2":
|
||||
eventName = epdFeignClient.findByName(eventName).getData().getShowName();
|
||||
case "3":
|
||||
//Ⅱ、Ⅲ级告警推送相关用户及业务管理员
|
||||
users = getEventUser(devId);
|
||||
users = getEventUser(devId,3);
|
||||
devCodeList = users.stream().map(User::getDevCode).collect(Collectors.toList());
|
||||
noticeUserDto.setPushClientId(devCodeList);
|
||||
//记录需要通知的用户和事件关系
|
||||
@@ -265,25 +270,58 @@ public class SendEventUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取需要通知暂态事件的用户
|
||||
* 获取需要通知事件的用户
|
||||
*/
|
||||
public List<User> getEventUser(String devId) {
|
||||
public List<User> getEventUser(String devId,Integer type) {
|
||||
List<User> users = new ArrayList<>();
|
||||
List<String> result = new ArrayList<>();
|
||||
//获取设备下主用户和子用户集合
|
||||
List<String> list = csDeviceUserFeignClient.findUserById(devId).getData();
|
||||
List<User> adminUser = appUserFeignClient.getAdminInfo().getData();
|
||||
List<String> adminList = adminUser.stream().map(User::getId).collect(Collectors.toList());
|
||||
list.addAll(adminList);
|
||||
//查询哪些用户打开了事件提示
|
||||
if (CollectionUtil.isNotEmpty(list)){
|
||||
List<AppInfoSet> appInfoSet = appInfoSetFeignClient.getListById(list).getData();
|
||||
switch (type) {
|
||||
case 0:
|
||||
result = appInfoSet.stream()
|
||||
.filter(person -> person.getEventInfo() == 1)
|
||||
.map(AppInfoSet::getUserId).collect(Collectors.toList());
|
||||
break;
|
||||
case 1:
|
||||
result = appInfoSet.stream()
|
||||
.filter(person -> person.getHarmonicInfo() == 1)
|
||||
.map(AppInfoSet::getUserId).collect(Collectors.toList());
|
||||
break;
|
||||
case 3:
|
||||
result = appInfoSet.stream()
|
||||
.filter(person -> person.getAlarmInfo() == 1)
|
||||
.map(AppInfoSet::getUserId).collect(Collectors.toList());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(list)){
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(result)){
|
||||
users = userFeignClient.getUserByIdList(result).getData();
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
public List<User> getAdminUser() {
|
||||
List<User> users = appUserFeignClient.getAdminInfo().getData();
|
||||
List<String> result = new ArrayList<>();
|
||||
List<String> adminList = users.stream().map(User::getId).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(adminList)){
|
||||
List<AppInfoSet> appInfoSet = appInfoSetFeignClient.getListById(adminList).getData();
|
||||
result = appInfoSet.stream()
|
||||
.filter(person -> person.getRunInfo() == 1)
|
||||
.map(AppInfoSet::getUserId).collect(Collectors.toList());
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(result)){
|
||||
users = userFeignClient.getUserByIdList(result).getData();
|
||||
}
|
||||
List<User> adminUser = appUserFeignClient.getAdminInfo().getData();
|
||||
users.addAll(adminUser);
|
||||
return users;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user