增加报警数据websocket 消息推送
This commit is contained in:
@@ -13,8 +13,8 @@ import org.dromara.property.api.RemoteAttendanceService;
|
||||
import org.dromara.property.api.RemoteFloorService;
|
||||
import org.dromara.property.api.domain.vo.RemoteAttendanceUserGroupVo;
|
||||
import org.dromara.property.api.domain.vo.RemoteFloorVo;
|
||||
import org.dromara.sis.domain.entity.SisAlarmEvents;
|
||||
import org.dromara.sis.domain.bo.alarm.AlarmAssignmentBo;
|
||||
import org.dromara.sis.domain.entity.SisAlarmEvents;
|
||||
import org.dromara.sis.domain.enums.ControlTypeEnum;
|
||||
import org.dromara.sis.domain.enums.EventSmallTypeEnum;
|
||||
import org.dromara.sis.domain.enums.RosterTypeEnum;
|
||||
|
@@ -23,14 +23,16 @@ import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.property.api.RemoteAttendanceService;
|
||||
import org.dromara.property.api.domain.vo.RemoteAttendanceUserGroupVo;
|
||||
import org.dromara.resource.api.RemoteFileService;
|
||||
import org.dromara.resource.api.RemoteWebSocketMessageService;
|
||||
import org.dromara.resource.api.domain.RemoteFile;
|
||||
import org.dromara.resource.api.domain.WebSocketMsgType;
|
||||
import org.dromara.sis.domain.bo.SisAlarmEventsBo;
|
||||
import org.dromara.sis.domain.bo.alarm.AlarmAssignmentBo;
|
||||
import org.dromara.sis.domain.bo.alarm.AlarmCompleteBo;
|
||||
import org.dromara.sis.domain.entity.SisAlarmEventAttachments;
|
||||
import org.dromara.sis.domain.entity.SisAlarmEventProcess;
|
||||
import org.dromara.sis.domain.entity.SisAlarmEvents;
|
||||
import org.dromara.sis.domain.entity.SisDeviceManage;
|
||||
import org.dromara.sis.domain.bo.SisAlarmEventsBo;
|
||||
import org.dromara.sis.domain.bo.alarm.AlarmAssignmentBo;
|
||||
import org.dromara.sis.domain.bo.alarm.AlarmCompleteBo;
|
||||
import org.dromara.sis.domain.enums.AlarmStatus;
|
||||
import org.dromara.sis.domain.enums.EventBigTypeEnum;
|
||||
import org.dromara.sis.domain.enums.EventSmallTypeEnum;
|
||||
@@ -44,6 +46,9 @@ import org.dromara.sis.service.ISisDeviceManageService;
|
||||
import org.dromara.system.api.RemoteDictService;
|
||||
import org.dromara.system.api.domain.vo.RemoteDictDataVo;
|
||||
import org.dromara.system.api.model.LoginUser;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -58,7 +63,7 @@ import java.util.*;
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
||||
public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService, ApplicationContextAware {
|
||||
|
||||
private final SisAlarmEventsMapper baseMapper;
|
||||
private final ISisDeviceManageService deviceManageService;
|
||||
@@ -71,6 +76,9 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
||||
private RemoteAttendanceService remoteAttendanceService;
|
||||
@DubboReference
|
||||
private RemoteDictService remoteDictService;
|
||||
@DubboReference
|
||||
private RemoteWebSocketMessageService webSocketMessageService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询告警
|
||||
@@ -303,8 +311,16 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
||||
process.setTenantId(sisAlarmEvents.getTenantId());
|
||||
Boolean insert = alarmEventProcessService.insert(process);
|
||||
log.info("事件处理信息写入完成,result= {}", insert);
|
||||
//TODO 推送到执行客户端
|
||||
// 进行消息推送
|
||||
webSocketMessageService.publishMessage(List.of(bo.getSolveId()), WebSocketMsgType.ALARM_MSG, sisAlarmEvents);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -0,0 +1,63 @@
|
||||
package org.dromara.resource.dubbo;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.dromara.common.websocket.dto.WebSocketMessageDto;
|
||||
import org.dromara.common.websocket.utils.WebSocketUtils;
|
||||
import org.dromara.resource.api.RemoteWebSocketMessageService;
|
||||
import org.dromara.resource.api.domain.WebSocketMsgType;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* websocket 消息推送实现类
|
||||
*
|
||||
* @author lxj
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@DubboService
|
||||
public class RemoteWebSocketMessageServiceImpl implements RemoteWebSocketMessageService {
|
||||
|
||||
@Override
|
||||
public void publishMessage(List<Long> sessionKey, WebSocketMsgType webSocketMsgType, Object data) {
|
||||
WebSocketMessageDto dto = new WebSocketMessageDto();
|
||||
dto.setSessionKeys(sessionKey);
|
||||
dto.setMessage(createMsg(webSocketMsgType, data));
|
||||
try {
|
||||
WebSocketUtils.publishMessage(dto);
|
||||
} catch (Exception e) {
|
||||
log.error("发送分布式消息失败,error:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishAll(WebSocketMsgType webSocketMsgType, Object data) {
|
||||
try {
|
||||
WebSocketUtils.publishAll(createMsg(webSocketMsgType, data));
|
||||
} catch (Exception e) {
|
||||
log.error("群发消息失败,error:{}", e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(Long userId, WebSocketMsgType webSocketMsgType, Object data) {
|
||||
try {
|
||||
WebSocketUtils.sendMessage(userId, createMsg(webSocketMsgType, data));
|
||||
} catch (Exception e) {
|
||||
log.error("发送指定消息失败,error:{}", e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String createMsg(WebSocketMsgType webSocketMsgType, Object data) {
|
||||
JSONObject msg = new JSONObject();
|
||||
msg.put("code", webSocketMsgType.getCode());
|
||||
msg.put("data", data);
|
||||
return msg.toJSONString();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user