增加移动端推送title content
This commit is contained in:
@@ -21,6 +21,17 @@ public interface RemoteWebSocketMessageService {
|
|||||||
*/
|
*/
|
||||||
void publishMessage(List<Long> sessionKey, WebSocketMsgType webSocketMsgType, String data);
|
void publishMessage(List<Long> sessionKey, WebSocketMsgType webSocketMsgType, String data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送移动端消息
|
||||||
|
*
|
||||||
|
* @param sessionKey session主键 一般为用户id
|
||||||
|
* @param webSocketMsgType webSocket消息类型
|
||||||
|
* @param title 推送title
|
||||||
|
* @param content 推送内容
|
||||||
|
* @param data 推送数据
|
||||||
|
*/
|
||||||
|
void pushMobileMessage(List<Long> sessionKey, WebSocketMsgType webSocketMsgType, String title, String content, String data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发布订阅的消息(群发)
|
* 发布订阅的消息(群发)
|
||||||
*
|
*
|
||||||
|
@@ -310,7 +310,9 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
|||||||
Boolean insert = alarmEventProcessService.insert(process);
|
Boolean insert = alarmEventProcessService.insert(process);
|
||||||
log.info("事件处理信息写入完成,result= {}", insert);
|
log.info("事件处理信息写入完成,result= {}", insert);
|
||||||
// 进行消息推送
|
// 进行消息推送
|
||||||
webSocketMessageService.publishMessage(List.of(bo.getSolveId()), WebSocketMsgType.ALARM_MSG, JSONObject.toJSONString(sisAlarmEvents));
|
String title = "视频预警";
|
||||||
|
String content = "您有一条" + sisAlarmEvents.getSolveName() + "预警数据";
|
||||||
|
webSocketMessageService.pushMobileMessage(List.of(bo.getSolveId()), WebSocketMsgType.ALARM_MSG, title, content, JSONObject.toJSONString(sisAlarmEvents));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,6 +33,18 @@ public class RemoteWebSocketMessageServiceImpl implements RemoteWebSocketMessage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pushMobileMessage(List<Long> sessionKey, WebSocketMsgType webSocketMsgType, String title, String content, String data) {
|
||||||
|
WebSocketMessageDto dto = new WebSocketMessageDto();
|
||||||
|
dto.setSessionKeys(sessionKey);
|
||||||
|
dto.setMessage(createMsg(webSocketMsgType, title, content, data));
|
||||||
|
try {
|
||||||
|
WebSocketUtils.publishMessage(dto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("发送分布式消息失败,error:{}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void publishAll(WebSocketMsgType webSocketMsgType, String data) {
|
public void publishAll(WebSocketMsgType webSocketMsgType, String data) {
|
||||||
try {
|
try {
|
||||||
@@ -60,4 +72,13 @@ public class RemoteWebSocketMessageServiceImpl implements RemoteWebSocketMessage
|
|||||||
return msg.toJSONString();
|
return msg.toJSONString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String createMsg(WebSocketMsgType webSocketMsgType, String title, String content, Object data) {
|
||||||
|
JSONObject msg = new JSONObject();
|
||||||
|
msg.put("type", webSocketMsgType.getCode());
|
||||||
|
msg.put("title", title);
|
||||||
|
msg.put("content", content);
|
||||||
|
msg.put("data", data);
|
||||||
|
return msg.toJSONString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user