refactor(iot-access): 重构设备离线通知和事件推送逻辑
- 移除过时的定时任务相关代码和依赖 - 集成新的DeviceMessageFeignClient服务接口 - 更新设备离线通知逻辑,增加推送客户端检查 - 修改事件用户获取方式,使用远程服务调用 - 优化推送用户筛选流程,统一使用DeviceMessageParam参数 - 清理冗余的导入包和废弃的方法 - 调整事件推送类型的参数传递方式
This commit is contained in:
@@ -4,19 +4,16 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.njcn.access.pojo.dto.NoticeUserDto;
|
||||
import com.njcn.access.utils.SendMessageUtil;
|
||||
import com.njcn.csdevice.api.CsDeviceUserFeignClient;
|
||||
import com.njcn.csdevice.api.CsLedgerFeignClient;
|
||||
import com.njcn.csdevice.api.DeviceMessageFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.api.EventLogsFeignClient;
|
||||
import com.njcn.csdevice.param.DeviceMessageParam;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsEventSendMsg;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.user.api.AppInfoSetFeignClient;
|
||||
import com.njcn.user.api.AppUserFeignClient;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.user.pojo.po.app.AppInfoSet;
|
||||
import com.njcn.zlevent.service.ICsEventUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -40,14 +37,6 @@ import java.util.stream.Collectors;
|
||||
@Component
|
||||
public class SendEventUtils {
|
||||
|
||||
@Resource
|
||||
private UserFeignClient userFeignClient;
|
||||
@Resource
|
||||
private AppUserFeignClient appUserFeignClient;
|
||||
@Resource
|
||||
private CsDeviceUserFeignClient csDeviceUserFeignClient;
|
||||
@Resource
|
||||
private AppInfoSetFeignClient appInfoSetFeignClient;
|
||||
@Resource
|
||||
private EventLogsFeignClient eventLogsFeignClient;
|
||||
@Resource
|
||||
@@ -60,6 +49,8 @@ public class SendEventUtils {
|
||||
private SendMessageUtil sendMessageUtil;
|
||||
@Resource
|
||||
private EquipmentFeignClient equipmentFeignClient;
|
||||
@Resource
|
||||
private DeviceMessageFeignClient deviceMessageFeignClient;
|
||||
|
||||
/**
|
||||
* 事件推送给相关用户
|
||||
@@ -92,7 +83,7 @@ public class SendEventUtils {
|
||||
case "1":
|
||||
code = 3;
|
||||
//设备自身事件 不推送给用户,推送给业务管理
|
||||
eventUser = getEventUser(devId,false);
|
||||
eventUser = deviceMessageFeignClient.getEventUserByDeviceId(devId,false).getData();
|
||||
if (CollectionUtil.isNotEmpty(eventUser)) {
|
||||
eventUser.forEach(item->{
|
||||
CsEventUserPO csEventUser = new CsEventUserPO();
|
||||
@@ -102,7 +93,10 @@ public class SendEventUtils {
|
||||
result.add(csEventUser);
|
||||
});
|
||||
|
||||
users = getSendUser(eventUser,2);
|
||||
DeviceMessageParam param1 = new DeviceMessageParam();
|
||||
param1.setUserList(eventUser);
|
||||
param1.setEventType(2);
|
||||
users = deviceMessageFeignClient.getSendUserByType(param1).getData();
|
||||
if (CollectionUtil.isNotEmpty(users)){
|
||||
for (User user : users){
|
||||
userList.add(user.getDevCode());
|
||||
@@ -115,7 +109,7 @@ public class SendEventUtils {
|
||||
case "2":
|
||||
code = 0;
|
||||
//暂态事件
|
||||
eventUser = getEventUser(devId,true);
|
||||
eventUser = deviceMessageFeignClient.getEventUserByDeviceId(devId,true).getData();
|
||||
if (CollectionUtil.isNotEmpty(eventUser)) {
|
||||
eventUser.forEach(item->{
|
||||
CsEventUserPO csEventUser = new CsEventUserPO();
|
||||
@@ -124,7 +118,10 @@ public class SendEventUtils {
|
||||
csEventUser.setEventId(id);
|
||||
result.add(csEventUser);
|
||||
});
|
||||
users = getSendUser(eventUser,0);
|
||||
DeviceMessageParam param1 = new DeviceMessageParam();
|
||||
param1.setUserList(eventUser);
|
||||
param1.setEventType(0);
|
||||
users = deviceMessageFeignClient.getSendUserByType(param1).getData();
|
||||
if (CollectionUtil.isNotEmpty(users)){
|
||||
devCodeList = users.stream().map(User::getDevCode).distinct().collect(Collectors.toList());
|
||||
noticeUserDto.setPushClientId(devCodeList);
|
||||
@@ -249,60 +246,4 @@ public class SendEventUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有需要推送的用户id
|
||||
*/
|
||||
public List<String> getEventUser(String devId,boolean isAdmin) {
|
||||
List<User> adminUser = appUserFeignClient.getAdminInfo().getData();
|
||||
List<String> adminList = adminUser.stream().map(User::getId).collect(Collectors.toList());
|
||||
if (isAdmin) {
|
||||
List<String> list = csDeviceUserFeignClient.findUserById(devId).getData();
|
||||
adminList.addAll(list);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(adminList)) {
|
||||
adminList = adminList.stream().distinct().collect(Collectors.toList());
|
||||
}
|
||||
return adminList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有打开推送的用户信息
|
||||
*/
|
||||
public List<User> getSendUser(List<String> userList,Integer type) {
|
||||
List<User> users = new ArrayList<>();
|
||||
List<String> result = new ArrayList<>();
|
||||
List<AppInfoSet> appInfoSet = appInfoSetFeignClient.getListById(userList).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 2:
|
||||
result = appInfoSet.stream()
|
||||
.filter(person -> person.getRunInfo() == 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(result)){
|
||||
users = userFeignClient.appuserByIdList(result).getData();
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user