Browse Source

电子病历踢人

xiaochan 2 years ago
parent
commit
262c088143

+ 8 - 6
src/main/java/thyyxxk/webserver/config/auth/AuthenticationInterceptor.java

@@ -12,8 +12,10 @@ import org.springframework.web.servlet.HandlerInterceptor;
 import thyyxxk.webserver.config.exception.BizException;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.controller.ShutDownController;
+import thyyxxk.webserver.dao.his.LoginDao;
 import thyyxxk.webserver.entity.login.UserInfo;
 import thyyxxk.webserver.service.redislike.RedisLikeService;
+import thyyxxk.webserver.utils.StringUtil;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -25,12 +27,12 @@ import java.lang.reflect.Method;
 @Slf4j
 @Component
 public class AuthenticationInterceptor implements HandlerInterceptor {
-    private final RedisLikeService redisLikeService;
+    private final LoginDao dao;
 
     private static final String EXPIRED = "The Token has expired";
 
-    public AuthenticationInterceptor(RedisLikeService redisLikeService) {
-        this.redisLikeService = redisLikeService;
+    public AuthenticationInterceptor(LoginDao dao) {
+        this.dao = dao;
     }
 
     @Override
@@ -76,12 +78,12 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
             log.info("请求参数: {}", request.getQueryString());
             throw new BizException(ExceptionEnum.TOKEN_ERROR);
         }
-        UserInfo userInfo = redisLikeService.getUserInfoByCode(code);
-        if (userInfo == null) {
+        String password = dao.getPasswordByCode(code);
+        if (StringUtil.isBlank(password)) {
             throw new BizException(ExceptionEnum.USER_NOT_EXIST);
         }
         // 验证 token
-        JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(userInfo.getPassword())).build();
+        JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(password)).build();
 
         try {
             jwtVerifier.verify(token);

+ 5 - 4
src/main/java/thyyxxk/webserver/config/auth/InterceptorConfig.java

@@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import thyyxxk.webserver.dao.his.LoginDao;
 import thyyxxk.webserver.service.redislike.RedisLikeService;
 
 /**
@@ -11,16 +12,16 @@ import thyyxxk.webserver.service.redislike.RedisLikeService;
  */
 @Configuration
 public class InterceptorConfig implements WebMvcConfigurer {
-    private final RedisLikeService redisLikeService;
+    private final LoginDao dao;
 
     @Autowired
-    public InterceptorConfig(RedisLikeService redisLikeService) {
-        this.redisLikeService = redisLikeService;
+    public InterceptorConfig(LoginDao dao) {
+        this.dao = dao;
     }
 
     @Override
     public void addInterceptors(InterceptorRegistry registry) {
-        registry.addInterceptor(new AuthenticationInterceptor(redisLikeService))
+        registry.addInterceptor(new AuthenticationInterceptor(dao))
                 .addPathPatterns("/**");
     }
 }

+ 31 - 3
src/main/java/thyyxxk/webserver/controller/zhuyuanyizheng/emr/EmrWebSocketController.java

@@ -1,12 +1,19 @@
 package thyyxxk.webserver.controller.zhuyuanyizheng.emr;
 
+import com.alibaba.fastjson.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import thyyxxk.webserver.config.auth.PassToken;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.login.UserInfo;
 import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrSocketMessage;
+import thyyxxk.webserver.service.externalhttp.WebSocketService;
+import thyyxxk.webserver.service.redislike.RedisLikeService;
 import thyyxxk.webserver.service.zhuyuanyisheng.emr.EmrWebSocketServer;
 import thyyxxk.webserver.service.zhuyuanyisheng.emr.EmrWebSocketServiceV2;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.StringUtil;
 
 import java.util.List;
 import java.util.Map;
@@ -17,11 +24,15 @@ public class EmrWebSocketController {
 
     private final EmrWebSocketServer server;
     private final EmrWebSocketServiceV2 emrWebSocketServerV2;
+    private final WebSocketService webSocketService;
+    private final RedisLikeService redisLikeService;
 
     @Autowired
-    public EmrWebSocketController(EmrWebSocketServer server, EmrWebSocketServiceV2 emrWebSocketServerV2) {
+    public EmrWebSocketController(EmrWebSocketServer server, EmrWebSocketServiceV2 emrWebSocketServerV2, WebSocketService webSocketService, RedisLikeService redisLikeService) {
         this.server = server;
         this.emrWebSocketServerV2 = emrWebSocketServerV2;
+        this.webSocketService = webSocketService;
+        this.redisLikeService = redisLikeService;
     }
 
     @GetMapping("/getRoomPeople")
@@ -52,9 +63,26 @@ public class EmrWebSocketController {
     }
 
     @GetMapping("/forcedKickingOutOfPersonnelByDocumentId")
-    public void forcedKickingOutOfPersonnelByDocumentId(@RequestParam("documentId") String documentId) {
-        emrWebSocketServerV2.forcedKickingOutOfPersonnelByDocumentId(documentId);
+    public ResultVo<String> forcedKickingOutOfPersonnelByDocumentId(@RequestParam("documentId") String documentId) {
+        return emrWebSocketServerV2.forcedKickingOutOfPersonnelByDocumentId(documentId);
     }
 
+    @PostMapping("/sendEmrSocketMessage")
+    @PassToken
+    public ResultVo<String> sendEmrSocketMessage(@RequestBody JSONObject js) {
+        webSocketService.sendEmrSocketMessage(js);
+        return ResultVoUtil.success();
+    }
+
+    @GetMapping("/getCurrentDocumentUserCode")
+    @PassToken
+    public ResultVo<UserInfo> getCurrentDocumentUserCode(@RequestParam("documentId") String documentId) {
+        ResultVo<String> res = webSocketService.getCurrentDocumentUserCode(documentId);
+        String userCode = res.getData();
+        if (StringUtil.isBlank(userCode)) {
+            return ResultVoUtil.success(ExceptionEnum.SUCCESS, null, null);
+        }
+        return ResultVoUtil.success(redisLikeService.getUserInfoByCode(userCode));
+    }
 
 }

+ 8 - 0
src/main/java/thyyxxk/webserver/dao/his/LoginDao.java

@@ -83,4 +83,12 @@ public interface LoginDao {
             "</foreach> order by sort" +
             "</script>")
     List<String> selectVueMenusPathByRoles(@Param("roles") List<Integer> roles);
+
+    @Select("select password " +
+            "from dj_user_base a, " +
+            "     a_employee_mi b " +
+            "where a.code = b.code " +
+            "  and isnull(nullif(b.del_flag, ''), 0) = 0 " +
+            "  and b.code = #{code}")
+    String getPasswordByCode(String code);
 }

+ 3 - 0
src/main/java/thyyxxk/webserver/service/PublicServer.java

@@ -223,6 +223,7 @@ public class PublicServer {
     /**
      * @return 返回申请号
      */
+    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     public Integer getReqPageNo() {
         Integer oldId = dao.getReqNo();
         Integer newId = oldId + 1;
@@ -238,6 +239,7 @@ public class PublicServer {
      *
      * @return 药品单号
      */
+    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     public Integer getTheDrugListNo() {
         Integer oldId = dao.caoYaoDanHao();
         Integer newId = oldId + 1;
@@ -253,6 +255,7 @@ public class PublicServer {
      *
      * @return 序号
      */
+    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     public Integer getCrbNo() {
         Integer oldId = dao.oldCrbNo();
         Integer newId = oldId + 1;

+ 10 - 1
src/main/java/thyyxxk/webserver/service/externalhttp/WebSocketService.java

@@ -1,5 +1,6 @@
 package thyyxxk.webserver.service.externalhttp;
 
+import com.alibaba.fastjson.JSONObject;
 import com.dtflys.forest.annotation.*;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.socketmessage.ApiMessageBody;
@@ -62,4 +63,12 @@ public interface WebSocketService {
 
     @Get("/getThmzToken")
     String getThmzToken();
-}
+
+    @Post("/sendEmrSocketMessage")
+    void sendEmrSocketMessage(@JSONBody JSONObject obj);
+
+    @Get("/getCurrentDocumentUserCode?documentId={documentId}")
+    ResultVo<String> getCurrentDocumentUserCode(@Var("documentId") String documentId);
+
+    @Post("/forcedKickingOutOfPersonnelByDocumentId")
+    ResultVo<String> forcedKickingOutOfPersonnelByDocumentId(@JSONBody JSONObject js);}

+ 0 - 2
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/emr/EmrServer.java

@@ -244,7 +244,6 @@ public class EmrServer {
     public ResultVo<Map<String, Object>> insertEmrData(EmrPatientData param) {
         JSONObject saveJson = new JSONObject();
         saveJson.put("document", param.getDocumentData());
-
         try {
             emr.saveDocument(saveJson);
         } catch (Exception e) {
@@ -888,5 +887,4 @@ public class EmrServer {
     }
 
 
-
 }

+ 16 - 7
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/emr/EmrWebSocketServiceV2.java

@@ -1,5 +1,6 @@
 package thyyxxk.webserver.service.zhuyuanyisheng.emr;
 
+import com.alibaba.fastjson.JSONObject;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -8,9 +9,11 @@ import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.login.UserInfo;
 import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrSocketParam;
+import thyyxxk.webserver.service.TokenService;
 import thyyxxk.webserver.service.externalhttp.WebSocketService;
 import thyyxxk.webserver.service.redislike.RedisLikeService;
 import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.TokenUtil;
 
 import javax.websocket.Session;
 import java.util.concurrent.ConcurrentHashMap;
@@ -18,13 +21,13 @@ import java.util.concurrent.ConcurrentHashMap;
 @Slf4j
 @Service
 public class EmrWebSocketServiceV2 {
-    private final WebSocketService socketService;
     @Data
     public static class Edit {
         private Session session;
         private String userCode;
     }
 
+    private final WebSocketService socketService;
     private final RedisLikeService redisLikeService;
     private static final ConcurrentHashMap<String, Edit> EDITOR_USER = new ConcurrentHashMap<>();
 
@@ -65,14 +68,20 @@ public class EmrWebSocketServiceV2 {
         return param;
     }
 
-    public void forcedKickingOutOfPersonnelByDocumentId(String documentId) {
-        Edit edit = EDITOR_USER.get(documentId);
-        if (edit == null) return;
+    public ResultVo<String> forcedKickingOutOfPersonnelByDocumentId(String documentId) {
         try {
-            edit.getSession().getBasicRemote().sendText("{\"forceRefresh\":\"true\"}");
-        } catch (Exception ignored) {
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("documentId", documentId);
+            jsonObject.put("userInfo", redisLikeService.getUserInfoByToken());
+            ResultVo<String> res = socketService
+                    .forcedKickingOutOfPersonnelByDocumentId(jsonObject);
+            if (ExceptionEnum.SUCCESS.getCode() == res.getCode()) {
+                return ResultVoUtil.success();
+            }
+        } catch (Exception e) {
+            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "强制踢出失败,请重试。");
         }
-        EDITOR_USER.remove(documentId);
+        return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "强制踢出失败,请重试。");
     }
 
 }