This commit is contained in:
parent
e73d6abf62
commit
9dbccf93a8
@ -35,6 +35,7 @@ public class PlusWebSocketHandler extends AbstractWebSocketHandler {
|
||||
}
|
||||
WebSocketSessionHolder.addSession(loginUser.getUserId(), session);
|
||||
log.info("[connect] sessionId: {},userId:{},userType:{}", session.getId(), loginUser.getUserId(), loginUser.getUserType());
|
||||
System.out.println(WebSocketSessionHolder.getSessions(loginUser.getUserId()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,8 +26,10 @@ public class WebSocketSessionHolder {
|
||||
* @param session 要添加的WebSocket会话
|
||||
*/
|
||||
public static void addSession(Long sessionKey, WebSocketSession session) {
|
||||
System.out.println(USER_SESSION_MAP);
|
||||
removeSession(sessionKey);
|
||||
USER_SESSION_MAP.put(sessionKey, session);
|
||||
System.out.println(USER_SESSION_MAP);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -36,6 +38,7 @@ public class WebSocketSessionHolder {
|
||||
* @param sessionKey 要移除的会话键
|
||||
*/
|
||||
public static void removeSession(Long sessionKey) {
|
||||
System.out.println(USER_SESSION_MAP);
|
||||
WebSocketSession session = USER_SESSION_MAP.remove(sessionKey);
|
||||
try {
|
||||
session.close(CloseStatus.BAD_DATA);
|
||||
@ -50,6 +53,7 @@ public class WebSocketSessionHolder {
|
||||
* @return 与给定会话键对应的WebSocket会话,如果不存在则返回null
|
||||
*/
|
||||
public static WebSocketSession getSessions(Long sessionKey) {
|
||||
System.out.println(USER_SESSION_MAP);
|
||||
return USER_SESSION_MAP.get(sessionKey);
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ public class WebSocketUtils {
|
||||
*/
|
||||
public static void sendMessage(Long sessionKey, String message) {
|
||||
WebSocketSession session = WebSocketSessionHolder.getSessions(sessionKey);
|
||||
|
||||
sendMessage(session, message);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import java.util.UUID;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
@ -14,6 +15,9 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.common.core.constant.GlobalConstants;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.common.websocket.dto.WebSocketMessageDto;
|
||||
import org.dromara.common.websocket.holder.WebSocketSessionHolder;
|
||||
import org.dromara.common.websocket.utils.WebSocketUtils;
|
||||
import org.dromara.property.domain.bo.QrCodeInfo;
|
||||
import org.dromara.resource.api.RemoteMessageService;
|
||||
import org.dromara.system.api.RemoteConfigService;
|
||||
@ -51,8 +55,6 @@ public class TbVisitorManagementController extends BaseController {
|
||||
@DubboReference
|
||||
private final RemoteConfigService remoteConfigService;
|
||||
|
||||
@DubboReference(stub = "true")
|
||||
private final RemoteMessageService remoteMessageService;
|
||||
|
||||
|
||||
|
||||
@ -97,7 +99,13 @@ public class TbVisitorManagementController extends BaseController {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("type","qrcode");
|
||||
jsonObject.put("date",qrcode);
|
||||
remoteMessageService.publishMessage(List.of(qrCodeInfo.getUserid()),jsonObject.toString());
|
||||
System.out.println(WebSocketSessionHolder.getSessions(1L));
|
||||
System.out.println(WebSocketSessionHolder.getSessionsAll());
|
||||
WebSocketMessageDto webSocketMessage = new WebSocketMessageDto();
|
||||
webSocketMessage.setMessage(jsonObject.toString());
|
||||
webSocketMessage.setSessionKeys(List.of(qrCodeInfo.getUserid()));
|
||||
WebSocketUtils.publishMessage(webSocketMessage);
|
||||
// WebSocketUtils.sendMessage(qrCodeInfo.getUserid(),jsonObject.toString());
|
||||
return R.ok("二维码可用");
|
||||
|
||||
}
|
||||
|
@ -105,6 +105,7 @@ public class TbVisitorManagementServiceImpl implements ITbVisitorManagementServi
|
||||
@Override
|
||||
public Boolean insertByBo(TbVisitorManagementBo bo) {
|
||||
QrCodeInfo info = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY +"Qrcode" + bo.getQrCodeId());
|
||||
RedisUtils.deleteKeys(GlobalConstants.CAPTCHA_CODE_KEY +"Qrcode" + bo.getQrCodeId());
|
||||
TbVisitorManagement add = MapstructUtils.convert(bo, TbVisitorManagement.class);
|
||||
validEntityBeforeSave(add);
|
||||
add.setCreateById(info.getUserid());
|
||||
|
@ -2,12 +2,15 @@ package org.dromara.sis.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.sis.sdk.unview.model.UvModel;
|
||||
import org.dromara.sis.sdk.unview.service.VideoAlarmService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 宇视告警书记上报
|
||||
*
|
||||
@ -32,8 +35,9 @@ public class VideoAlarmController {
|
||||
}
|
||||
|
||||
@PostMapping("/huawei/callback")
|
||||
public void huaweiAlarm(@RequestBody Object data) {
|
||||
log.info("华为上报消息,msg={}", data);
|
||||
public void huaweiAlarm(HttpServletRequest request) throws IOException {
|
||||
int read = request.getInputStream().read();
|
||||
log.info("华为上报消息,msg={}", read);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user