| 
					
				 | 
			
			
				@@ -1,5 +1,6 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package thyyxxk.webserver.service.zhuyuanyisheng.emr; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import lombok.Data; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -9,14 +10,22 @@ import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrSocketParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.service.redislike.RedisLikeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.utils.ResultVoUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import javax.websocket.Session; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.concurrent.ConcurrentHashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Slf4j 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class EmrWebSocketServiceV2 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Data 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static class Edit { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private Session session; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private String userCode; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private final RedisLikeService redisLikeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private static final ConcurrentHashMap<String, String> EDITOR_USER = new ConcurrentHashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private static final ConcurrentHashMap<String, Edit> EDITOR_USER = new ConcurrentHashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public EmrWebSocketServiceV2(RedisLikeService redisLikeService) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -25,19 +34,22 @@ public class EmrWebSocketServiceV2 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public ResultVo<UserInfo> isBeingEditing(String documentId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (EDITOR_USER.containsKey(documentId)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            String code = EDITOR_USER.get(documentId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Edit code = EDITOR_USER.get(documentId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (code == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 return ResultVoUtil.success(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            UserInfo us = redisLikeService.getUserInfoByCode(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            UserInfo us = redisLikeService.getUserInfoByCode(code.getUserCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return ResultVoUtil.success(us); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return ResultVoUtil.success(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public static void open(String sid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static void open(String sid, Session session) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         EmrSocketParam param = parameterParsing(sid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        EDITOR_USER.put(param.getId(), param.getUserCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Edit edit = new Edit(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        edit.setSession(session); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        edit.setUserCode(param.getUserCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        EDITOR_USER.put(param.getId(), edit); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public static void close(String sid) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -53,4 +65,16 @@ public class EmrWebSocketServiceV2 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 .setUserCode(sids[2]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return param; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void forcedKickingOutOfPersonnelByDocumentId(String documentId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Edit edit = EDITOR_USER.get(documentId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (edit == null) return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            edit.getSession().getBasicRemote().sendText("{\"forceRefresh\":\"true\"}"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.error("封禁用户失败", e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        EDITOR_USER.remove(documentId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |