mirror of
https://gitee.com/republicline/rax-remote-v2.git
synced 2025-08-24 07:34:57 +08:00
生命体征模块迁移
This commit is contained in:
parent
158129e56e
commit
815b3d4403
|
@ -106,11 +106,6 @@
|
||||||
<groupId>com.rax</groupId>
|
<groupId>com.rax</groupId>
|
||||||
<artifactId>quartz</artifactId>
|
<artifactId>quartz</artifactId>
|
||||||
<version>${common.version}</version>
|
<version>${common.version}</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.rax</groupId>
|
|
||||||
<artifactId>vital-signs</artifactId>
|
|
||||||
<version>${common.version}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rax</groupId>
|
<groupId>com.rax</groupId>
|
||||||
|
|
1
pom.xml
1
pom.xml
|
@ -99,7 +99,6 @@
|
||||||
<!-- 通用模块 -->
|
<!-- 通用模块 -->
|
||||||
<module>common</module>
|
<module>common</module>
|
||||||
|
|
||||||
<module>vital-signs</module>
|
|
||||||
<module>daily-plan</module>
|
<module>daily-plan</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
|
@ -49,10 +49,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rax</groupId>
|
<groupId>com.rax</groupId>
|
||||||
<artifactId>common-log</artifactId>
|
<artifactId>common-log</artifactId>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.rax</groupId>
|
|
||||||
<artifactId>vital-signs</artifactId>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rax</groupId>
|
<groupId>com.rax</groupId>
|
||||||
|
@ -96,6 +92,19 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.security</groupId>
|
||||||
|
<artifactId>spring-security-messaging</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
|
<version>1.2.21</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -4,7 +4,6 @@ import com.mongodb.ConnectionString;
|
||||||
import com.mongodb.MongoClientSettings;
|
import com.mongodb.MongoClientSettings;
|
||||||
import com.mongodb.client.MongoClient;
|
import com.mongodb.client.MongoClient;
|
||||||
import com.mongodb.client.MongoClients;
|
import com.mongodb.client.MongoClients;
|
||||||
import lombok.Getter;
|
|
||||||
import org.springframework.data.mongodb.SpringDataMongoDB;
|
import org.springframework.data.mongodb.SpringDataMongoDB;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
|
import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
|
|
@ -1,7 +1,6 @@
|
||||||
package com.rax.vital.handler;
|
package com.rax.vital.handler;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.rax.vital.timer.VitalSignTimer;
|
|
||||||
import com.rax.vital.timer.VitalSignTimerWS;
|
import com.rax.vital.timer.VitalSignTimerWS;
|
||||||
import com.rax.vital.util.DatabaseNameUtil;
|
import com.rax.vital.util.DatabaseNameUtil;
|
||||||
import com.rax.vital.util.GetHttpParamUtil;
|
import com.rax.vital.util.GetHttpParamUtil;
|
|
@ -2,7 +2,6 @@ package com.rax.vital.handler.mysql;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.rax.vital.timer.VitalSignTimerWS;
|
import com.rax.vital.timer.VitalSignTimerWS;
|
||||||
import com.rax.vital.util.DatabaseNameUtil;
|
|
||||||
import com.rax.vital.util.GetHttpParamUtil;
|
import com.rax.vital.util.GetHttpParamUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.security.oauth2.server.authorization.OAuth2Authorization;
|
import org.springframework.security.oauth2.server.authorization.OAuth2Authorization;
|
||||||
|
@ -48,8 +47,18 @@ public class AddMedicineHandler implements WebSocketHandler {
|
||||||
OAuth2Authorization authorization = authorizationService.findByToken(token, OAuth2TokenType.ACCESS_TOKEN);
|
OAuth2Authorization authorization = authorizationService.findByToken(token, OAuth2TokenType.ACCESS_TOKEN);
|
||||||
String username = authorization.getPrincipalName();
|
String username = authorization.getPrincipalName();
|
||||||
|
|
||||||
if (message.getPayload() instanceof String) {
|
String payload = (String) message.getPayload();
|
||||||
JSONObject jsonObject = JSONObject.parseObject((String) message.getPayload());
|
JSONObject jsonObject = JSONObject.parseObject(payload);
|
||||||
|
synchronized (payload) {
|
||||||
|
if ("heartbeat".equals(jsonObject.getString("msgType"))) {
|
||||||
|
jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("msgType", "heartbeat");
|
||||||
|
session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
|
if (pingTime > 0) {
|
||||||
|
pingTime--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pingTime = 0;
|
||||||
// 病人名
|
// 病人名
|
||||||
String patientName = jsonObject.getString("patientName");
|
String patientName = jsonObject.getString("patientName");
|
||||||
// 病人身份证
|
// 病人身份证
|
||||||
|
@ -59,14 +68,12 @@ public class AddMedicineHandler implements WebSocketHandler {
|
||||||
String databaseName = patientName + idNum;
|
String databaseName = patientName + idNum;
|
||||||
vitalSignTimerWS.changeWSAIFlag(databaseName, username, session, jsonObject.getString("flag"),
|
vitalSignTimerWS.changeWSAIFlag(databaseName, username, session, jsonObject.getString("flag"),
|
||||||
jsonObject.getString("medicine"), jsonObject.getString("value"));
|
jsonObject.getString("medicine"), jsonObject.getString("value"));
|
||||||
} else {
|
}
|
||||||
session.sendMessage(new PongMessage());
|
|
||||||
pingTime--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
|
public void handleTransportError(WebSocketSession session, Throwable exception) {
|
||||||
if (heartbeatTask != null) {
|
if (heartbeatTask != null) {
|
||||||
heartbeatTask.cancel(true);
|
heartbeatTask.cancel(true);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +84,7 @@ public class AddMedicineHandler implements WebSocketHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
|
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) {
|
||||||
vitalSignTimerWS.removeWSAIFlagSession(session);
|
vitalSignTimerWS.removeWSAIFlagSession(session);
|
||||||
System.out.println(this.getClass().getName() + " Connection closed:" + closeStatus.getReason());
|
System.out.println(this.getClass().getName() + " Connection closed:" + closeStatus.getReason());
|
||||||
if (heartbeatTask != null) {
|
if (heartbeatTask != null) {
|
||||||
|
@ -105,7 +112,9 @@ public class AddMedicineHandler implements WebSocketHandler {
|
||||||
}
|
}
|
||||||
vitalSignTimerWS.removeWSAIFlagSession(session);
|
vitalSignTimerWS.removeWSAIFlagSession(session);
|
||||||
} else {
|
} else {
|
||||||
session.sendMessage(new PingMessage());
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("msgType", "heartbeat");
|
||||||
|
session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
pingTime++;
|
pingTime++;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
|
@ -9,13 +9,11 @@ import org.springframework.security.oauth2.server.authorization.OAuth2Authorizat
|
||||||
import org.springframework.security.oauth2.server.authorization.OAuth2TokenType;
|
import org.springframework.security.oauth2.server.authorization.OAuth2TokenType;
|
||||||
import org.springframework.web.socket.*;
|
import org.springframework.web.socket.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.Timer;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.TimerTask;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class ChatHandler implements WebSocketHandler {
|
public class ChatHandler implements WebSocketHandler {
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -24,15 +22,11 @@ public class ChatHandler implements WebSocketHandler {
|
||||||
@Resource
|
@Resource
|
||||||
private ChatService chatService;
|
private ChatService chatService;
|
||||||
|
|
||||||
private static final long HEARTBEAT_INTERVAL = 30; // 心跳间隔秒数
|
private Map<String, TimerTask> timerTaskMap = new ConcurrentHashMap();
|
||||||
private ScheduledExecutorService scheduler;
|
|
||||||
private ScheduledFuture<?> heartbeatTask;
|
|
||||||
private int pingTime = 0;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
||||||
scheduler = Executors.newScheduledThreadPool(1);
|
startHeartbeat(session);
|
||||||
heartbeatTask = scheduler.scheduleAtFixedRate(() -> sendPing(session), 0, HEARTBEAT_INTERVAL, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -44,41 +38,31 @@ public class ChatHandler implements WebSocketHandler {
|
||||||
if (authorization != null) {
|
if (authorization != null) {
|
||||||
String username = authorization.getPrincipalName();
|
String username = authorization.getPrincipalName();
|
||||||
|
|
||||||
if (message.getPayload() instanceof String) {
|
|
||||||
String payload = (String) message.getPayload();
|
String payload = (String) message.getPayload();
|
||||||
JSONObject jsonObject = JSONObject.parseObject(payload);
|
JSONObject jsonObject = JSONObject.parseObject(payload);
|
||||||
|
|
||||||
|
if ("heartbeat".equals(jsonObject.getString("msgType"))) {
|
||||||
|
// session.sendMessage(new TextMessage(""));
|
||||||
|
} else {
|
||||||
String patientName = jsonObject.getString("patientName");
|
String patientName = jsonObject.getString("patientName");
|
||||||
String idNum = jsonObject.getString("idNum");
|
String idNum = jsonObject.getString("idNum");
|
||||||
String date = jsonObject.getString("date");
|
String date = jsonObject.getString("date");
|
||||||
// 消息内容
|
// 消息内容
|
||||||
String msg = jsonObject.getString("msg");
|
String msg = jsonObject.getString("msg");
|
||||||
chatService.sendMessageMysql(username, patientName, idNum, date, session, msg);
|
chatService.sendMessageMysql(username, patientName, idNum, date, session, msg);
|
||||||
} else {
|
|
||||||
session.sendMessage(new PongMessage());
|
|
||||||
pingTime--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
|
public void handleTransportError(WebSocketSession session, Throwable exception) {
|
||||||
if (heartbeatTask != null) {
|
System.out.println("Error: " + exception.getMessage());
|
||||||
heartbeatTask.cancel(true);
|
|
||||||
}
|
|
||||||
if (scheduler != null) {
|
|
||||||
scheduler.shutdown();
|
|
||||||
}
|
|
||||||
chatService.stopTask(session.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
|
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) {
|
||||||
if (heartbeatTask != null) {
|
System.out.println("CloseStatus: " + closeStatus.getReason() + closeStatus.getCode());
|
||||||
heartbeatTask.cancel(true);
|
stopHeartbeat(session);
|
||||||
}
|
|
||||||
if (scheduler != null) {
|
|
||||||
scheduler.shutdown();
|
|
||||||
}
|
|
||||||
chatService.stopTask(session.getId());
|
chatService.stopTask(session.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,24 +71,36 @@ public class ChatHandler implements WebSocketHandler {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendPing(WebSocketSession session) {
|
private void startHeartbeat(WebSocketSession session) {
|
||||||
|
if (!timerTaskMap.containsKey(session.getId())) {
|
||||||
|
TimerTask timerTask = new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
try {
|
try {
|
||||||
if (pingTime > 3) {
|
if (session.isOpen()) {
|
||||||
session.close();
|
JSONObject jsonObject = new JSONObject();
|
||||||
if (heartbeatTask != null) {
|
jsonObject.put("msgType", "heartbeat");
|
||||||
heartbeatTask.cancel(true);
|
session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
}
|
|
||||||
if (scheduler != null) {
|
|
||||||
scheduler.shutdown();
|
|
||||||
}
|
|
||||||
chatService.stopTask(session.getId());
|
|
||||||
} else {
|
} else {
|
||||||
session.sendMessage(new PingMessage());
|
stopHeartbeat(session);
|
||||||
pingTime++;
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
chatService.stopTask(session.getId());
|
chatService.stopTask(session.getId());
|
||||||
|
session.close();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
stopHeartbeat(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
// 定时任务,设置1秒
|
||||||
|
Timer timer = new Timer();
|
||||||
|
timer.schedule(timerTask, 0, 1000);
|
||||||
|
timerTaskMap.put(session.getId(), timerTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopHeartbeat(WebSocketSession session) {
|
||||||
|
TimerTask timerTask = timerTaskMap.get(session.getId());
|
||||||
|
timerTask.cancel();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,6 @@ package com.rax.vital.handler.mysql;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.rax.vital.timer.VitalSignTimerWS;
|
import com.rax.vital.timer.VitalSignTimerWS;
|
||||||
import com.rax.vital.util.DatabaseNameUtil;
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
|
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
|
||||||
import org.springframework.web.socket.*;
|
import org.springframework.web.socket.*;
|
||||||
|
@ -37,8 +36,18 @@ public class MachineFeedbackHandler implements WebSocketHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
|
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
|
||||||
if (message.getPayload() instanceof String) {
|
String payload = (String) message.getPayload();
|
||||||
JSONObject jsonObject = JSONObject.parseObject((String) message.getPayload());
|
JSONObject jsonObject = JSONObject.parseObject(payload);
|
||||||
|
synchronized (payload) {
|
||||||
|
if ("heartbeat".equals(jsonObject.getString("msgType"))) {
|
||||||
|
jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("msgType", "heartbeat");
|
||||||
|
session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
|
if (pingTime > 0) {
|
||||||
|
pingTime--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pingTime = 0;
|
||||||
// 病人名
|
// 病人名
|
||||||
String patientName = jsonObject.getString("patientName");
|
String patientName = jsonObject.getString("patientName");
|
||||||
// 病人身份证住院号
|
// 病人身份证住院号
|
||||||
|
@ -49,9 +58,7 @@ public class MachineFeedbackHandler implements WebSocketHandler {
|
||||||
String code = jsonObject.getString("code");
|
String code = jsonObject.getString("code");
|
||||||
|
|
||||||
vitalSignTimerWS.sendMachineFlag(databaseName, code, session);
|
vitalSignTimerWS.sendMachineFlag(databaseName, code, session);
|
||||||
} else {
|
}
|
||||||
session.sendMessage(new PongMessage());
|
|
||||||
pingTime--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +102,9 @@ public class MachineFeedbackHandler implements WebSocketHandler {
|
||||||
}
|
}
|
||||||
vitalSignTimerWS.removeMachineSessionMap(session);
|
vitalSignTimerWS.removeMachineSessionMap(session);
|
||||||
} else {
|
} else {
|
||||||
session.sendMessage(new PingMessage());
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("msgType", "heartbeat");
|
||||||
|
session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
pingTime++;
|
pingTime++;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
|
@ -2,7 +2,6 @@ package com.rax.vital.handler.mysql;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.rax.vital.timer.VitalSignTimerWS;
|
import com.rax.vital.timer.VitalSignTimerWS;
|
||||||
import com.rax.vital.util.DatabaseNameUtil;
|
|
||||||
import com.rax.vital.util.GetHttpParamUtil;
|
import com.rax.vital.util.GetHttpParamUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.security.oauth2.server.authorization.OAuth2Authorization;
|
import org.springframework.security.oauth2.server.authorization.OAuth2Authorization;
|
||||||
|
@ -13,10 +12,9 @@ import org.springframework.web.socket.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.Timer;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.TimerTask;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class MedicineHandler implements WebSocketHandler {
|
public class MedicineHandler implements WebSocketHandler {
|
||||||
|
|
||||||
|
@ -26,15 +24,11 @@ public class MedicineHandler implements WebSocketHandler {
|
||||||
@Resource
|
@Resource
|
||||||
private OAuth2AuthorizationService authorizationService;
|
private OAuth2AuthorizationService authorizationService;
|
||||||
|
|
||||||
private static final long HEARTBEAT_INTERVAL = 30; // 心跳间隔秒数
|
private Map<String, TimerTask> timerTaskMap = new ConcurrentHashMap();
|
||||||
private ScheduledExecutorService scheduler;
|
|
||||||
private ScheduledFuture<?> heartbeatTask;
|
|
||||||
private int pingTime = 0;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
public void afterConnectionEstablished(WebSocketSession session) {
|
||||||
scheduler = Executors.newScheduledThreadPool(1);
|
startHeartbeat(session);
|
||||||
heartbeatTask = scheduler.scheduleAtFixedRate(() -> sendPing(session), 0, HEARTBEAT_INTERVAL, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,40 +39,28 @@ public class MedicineHandler implements WebSocketHandler {
|
||||||
OAuth2Authorization authorization = authorizationService.findByToken(token, OAuth2TokenType.ACCESS_TOKEN);
|
OAuth2Authorization authorization = authorizationService.findByToken(token, OAuth2TokenType.ACCESS_TOKEN);
|
||||||
String username = authorization.getPrincipalName();
|
String username = authorization.getPrincipalName();
|
||||||
|
|
||||||
if (message.getPayload() instanceof String) {
|
|
||||||
String payload = (String) message.getPayload();
|
String payload = (String) message.getPayload();
|
||||||
JSONObject jsonObject = JSONObject.parseObject(payload);
|
JSONObject jsonObject = JSONObject.parseObject(payload);
|
||||||
|
|
||||||
|
if ("heartbeat".equals(jsonObject.getString("msgType"))) {
|
||||||
|
// session.sendMessage(new TextMessage(""));
|
||||||
|
} else {
|
||||||
String patientName = jsonObject.getString("patientName");
|
String patientName = jsonObject.getString("patientName");
|
||||||
String idNum = jsonObject.getString("idNum");
|
String idNum = jsonObject.getString("idNum");
|
||||||
String databaseName = patientName + idNum;
|
String databaseName = patientName + idNum;
|
||||||
vitalSignTimerWS.createAndSendMessageMySQL(databaseName, username, session);
|
vitalSignTimerWS.createAndSendMessageMySQL(databaseName, username, session);
|
||||||
} else {
|
|
||||||
session.sendMessage(new PongMessage());
|
|
||||||
pingTime--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
|
public void handleTransportError(WebSocketSession session, Throwable exception) {
|
||||||
System.out.println("Error: " + exception.getMessage());
|
System.out.println("Error: " + exception.getMessage());
|
||||||
if (heartbeatTask != null) {
|
|
||||||
heartbeatTask.cancel(true);
|
|
||||||
}
|
|
||||||
if (scheduler != null) {
|
|
||||||
scheduler.shutdown();
|
|
||||||
}
|
|
||||||
vitalSignTimerWS.stopTimerTask(session.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
|
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) {
|
||||||
System.out.println("MedicineHandler Connection closed:" + closeStatus.getReason());
|
System.out.println("MedicineHandler Connection closed:" + closeStatus.getReason());
|
||||||
if (heartbeatTask != null) {
|
stopHeartbeat(session);
|
||||||
heartbeatTask.cancel(true);
|
|
||||||
}
|
|
||||||
if (scheduler != null) {
|
|
||||||
scheduler.shutdown();
|
|
||||||
}
|
|
||||||
vitalSignTimerWS.stopTimerTask(session.getId());
|
vitalSignTimerWS.stopTimerTask(session.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,24 +69,36 @@ public class MedicineHandler implements WebSocketHandler {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendPing(WebSocketSession session) {
|
private void startHeartbeat(WebSocketSession session) {
|
||||||
|
if (!timerTaskMap.containsKey(session.getId())) {
|
||||||
|
TimerTask timerTask = new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
try {
|
try {
|
||||||
if (pingTime > 3) {
|
if (session.isOpen()) {
|
||||||
session.close();
|
JSONObject jsonObject = new JSONObject();
|
||||||
if (heartbeatTask != null) {
|
jsonObject.put("msgType", "heartbeat");
|
||||||
heartbeatTask.cancel(true);
|
session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
}
|
|
||||||
if (scheduler != null) {
|
|
||||||
scheduler.shutdown();
|
|
||||||
}
|
|
||||||
vitalSignTimerWS.stopTimerTask(session.getId());
|
|
||||||
} else {
|
} else {
|
||||||
session.sendMessage(new PingMessage());
|
session.close();
|
||||||
pingTime++;
|
stopHeartbeat(session);
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
vitalSignTimerWS.stopTimerTask(session.getId());
|
vitalSignTimerWS.stopTimerTask(session.getId());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
stopHeartbeat(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
// 定时任务,设置1秒
|
||||||
|
Timer timer = new Timer();
|
||||||
|
timer.schedule(timerTask, 0, 1000);
|
||||||
|
timerTaskMap.put(session.getId(), timerTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopHeartbeat(WebSocketSession session) {
|
||||||
|
TimerTask timerTask = timerTaskMap.get(session.getId());
|
||||||
|
timerTask.cancel();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,6 @@ package com.rax.vital.medicine.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.rax.vital.medicine.service.ChatService;
|
import com.rax.vital.medicine.service.ChatService;
|
||||||
import com.rax.vital.util.DatabaseNameUtil;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.messaging.MessageHeaders;
|
import org.springframework.messaging.MessageHeaders;
|
||||||
import org.springframework.messaging.handler.annotation.MessageMapping;
|
import org.springframework.messaging.handler.annotation.MessageMapping;
|
||||||
|
@ -14,7 +13,6 @@ import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.util.LinkedMultiValueMap;
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class ChatController {
|
public class ChatController {
|
|
@ -1,6 +1,5 @@
|
||||||
package com.rax.vital.medicine.service;
|
package com.rax.vital.medicine.service;
|
||||||
|
|
||||||
import com.rax.common.core.util.R;
|
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
|
@ -1,7 +1,5 @@
|
||||||
package com.rax.vital.medicine.service;
|
package com.rax.vital.medicine.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.rax.vital.medicine.entity.DoctorMedicine;
|
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
|
@ -3,7 +3,6 @@ package com.rax.vital.medicine.service;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface FlagService {
|
public interface FlagService {
|
|
@ -2,7 +2,6 @@ package com.rax.vital.medicine.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.rax.common.core.util.R;
|
import com.rax.common.core.util.R;
|
||||||
import com.rax.vital.datasource.MongoDBSource;
|
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
|
@ -55,7 +55,7 @@ public class AIMedicineServiceImpl implements AIMedicineService {
|
||||||
List<Map> medicineList = new ArrayList<>();
|
List<Map> medicineList = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
ResultSet resultSet = statement.executeQuery("SELECT id, phase, `丙泊酚`, `舒芬太尼`, `瑞芬太尼`, `顺阿曲库胺`, `尼卡地平`, `艾司洛尔`, `麻黄素`, `阿托品`, time FROM `aimedicinetable` ORDER BY time DESC LIMIT 1;");
|
/*ResultSet resultSet = statement.executeQuery("SELECT id, phase, `丙泊酚`, `舒芬太尼`, `瑞芬太尼`, `顺阿曲库胺`, `尼卡地平`, `艾司洛尔`, `麻黄素`, `阿托品`, time FROM `aimedicinetable` ORDER BY time DESC LIMIT 1;");
|
||||||
Map medicine = new HashMap();
|
Map medicine = new HashMap();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
medicine.put("id", resultSet.getString("id"));
|
medicine.put("id", resultSet.getString("id"));
|
||||||
|
@ -84,8 +84,33 @@ public class AIMedicineServiceImpl implements AIMedicineService {
|
||||||
medicine.put("艾司洛尔sum", sumSet.getString("艾司洛尔sum"));
|
medicine.put("艾司洛尔sum", sumSet.getString("艾司洛尔sum"));
|
||||||
medicine.put("麻黄素sum", sumSet.getString("麻黄素sum"));
|
medicine.put("麻黄素sum", sumSet.getString("麻黄素sum"));
|
||||||
medicine.put("阿托品sum", sumSet.getString("阿托品sum"));
|
medicine.put("阿托品sum", sumSet.getString("阿托品sum"));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
String sql = " SELECT " +
|
||||||
|
"rate_1, cumu_1, rate_2, cumu_2,rate_3, cumu_3,rate_4, cumu_4, rate_5, cumu_5,rate_6, cumu_6,rate_7, cumu_7,rate_8, cumu_8, time " +
|
||||||
|
" FROM fktable " +
|
||||||
|
" ORDER BY time DESC LIMIT 1; ";
|
||||||
|
ResultSet resultSet = statement.executeQuery(sql);
|
||||||
|
Map medicine = new HashMap();
|
||||||
|
while (resultSet.next()) {
|
||||||
|
medicine.put("丙泊酚", resultSet.getString("rate_1"));
|
||||||
|
medicine.put("丙泊酚sum", resultSet.getString("cumu_1"));
|
||||||
|
medicine.put("舒芬太尼", resultSet.getString("rate_2"));
|
||||||
|
medicine.put("舒芬太尼sum", resultSet.getString("cumu_2"));
|
||||||
|
medicine.put("瑞芬太尼", resultSet.getString("rate_3"));
|
||||||
|
medicine.put("瑞芬太尼sum", resultSet.getString("cumu_3"));
|
||||||
|
medicine.put("顺阿曲库胺", resultSet.getString("rate_4"));
|
||||||
|
medicine.put("顺阿曲库胺sum", resultSet.getString("cumu_4"));
|
||||||
|
medicine.put("尼卡地平", resultSet.getString("rate_5"));
|
||||||
|
medicine.put("尼卡地平sum", resultSet.getString("cumu_5"));
|
||||||
|
medicine.put("艾司洛尔", resultSet.getString("rate_6"));
|
||||||
|
medicine.put("艾司洛尔sum", resultSet.getString("cumu_6"));
|
||||||
|
medicine.put("麻黄素", resultSet.getString("rate_7"));
|
||||||
|
medicine.put("麻黄素sum", resultSet.getString("cumu_7"));
|
||||||
|
medicine.put("阿托品", resultSet.getString("rate_8"));
|
||||||
|
medicine.put("阿托品sum", resultSet.getString("cumu_8"));
|
||||||
|
medicine.put("Time", resultSet.getString("time"));
|
||||||
|
}
|
||||||
medicineList.add(medicine);
|
medicineList.add(medicine);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
|
@ -2,11 +2,9 @@ package com.rax.vital.medicine.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.rax.admin.api.dto.UserDTO;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.rax.admin.api.dto.UserInfo;
|
import com.rax.admin.api.entity.SysUser;
|
||||||
import com.rax.admin.api.feign.RemoteUserService;
|
import com.rax.admin.service.SysUserService;
|
||||||
import com.rax.common.core.constant.SecurityConstants;
|
|
||||||
import com.rax.common.core.util.R;
|
|
||||||
import com.rax.vital.datasource.CustomDataSource;
|
import com.rax.vital.datasource.CustomDataSource;
|
||||||
import com.rax.vital.datasource.MongoDBSource;
|
import com.rax.vital.datasource.MongoDBSource;
|
||||||
import com.rax.vital.datasource.MySQLSource;
|
import com.rax.vital.datasource.MySQLSource;
|
||||||
|
@ -24,9 +22,14 @@ import org.springframework.web.socket.TextMessage;
|
||||||
import org.springframework.web.socket.WebSocketSession;
|
import org.springframework.web.socket.WebSocketSession;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.*;
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@RefreshScope
|
@RefreshScope
|
||||||
@Service
|
@Service
|
||||||
|
@ -36,13 +39,13 @@ public class ChatServiceImpl implements ChatService {
|
||||||
private SimpMessagingTemplate simpMessagingTemplate;
|
private SimpMessagingTemplate simpMessagingTemplate;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RemoteUserService remoteUserService;
|
private SysUserService SysUserService;
|
||||||
|
|
||||||
private static final Map<String, CustomDataSource> datasourceMap = new HashMap<>();
|
private static final Map<String, CustomDataSource> datasourceMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private static final Map<String, Map<String, WebSocketSession>> databaseSessionMap = new HashMap<>();
|
private static final Map<String, Map<String, WebSocketSession>> databaseSessionMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private static final Map<String, String> sessionDatabaseMap = new HashMap<>();
|
private static final Map<String, String> sessionDatabaseMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
// MongoDB的地址
|
// MongoDB的地址
|
||||||
@Value("${vital-sign.mongodb.host}")
|
@Value("${vital-sign.mongodb.host}")
|
||||||
|
@ -78,10 +81,8 @@ public class ChatServiceImpl implements ChatService {
|
||||||
mongoDBSource.open();
|
mongoDBSource.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
UserDTO userDTO = new UserDTO();
|
|
||||||
userDTO.setUsername(username);
|
SysUser sysUser = SysUserService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, username));
|
||||||
R<UserInfo> info = remoteUserService.info(userDTO, SecurityConstants.FROM_IN);
|
|
||||||
UserInfo userInfo = info.getData();
|
|
||||||
|
|
||||||
Map param = new HashMap();
|
Map param = new HashMap();
|
||||||
|
|
||||||
|
@ -93,7 +94,7 @@ public class ChatServiceImpl implements ChatService {
|
||||||
document.put("create_time", now);
|
document.put("create_time", now);
|
||||||
param.put("createTime", now);
|
param.put("createTime", now);
|
||||||
document.put("create_user", username);
|
document.put("create_user", username);
|
||||||
String name = userInfo.getSysUser().getName();
|
String name = sysUser.getName();
|
||||||
document.put("create_name", name);
|
document.put("create_name", name);
|
||||||
param.put("createName", name);
|
param.put("createName", name);
|
||||||
document.put("deleted", 0);
|
document.put("deleted", 0);
|
||||||
|
@ -127,10 +128,7 @@ public class ChatServiceImpl implements ChatService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UserDTO userDTO = new UserDTO();
|
SysUser sysUser = SysUserService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, username));
|
||||||
userDTO.setUsername(username);
|
|
||||||
R<UserInfo> info = remoteUserService.info(userDTO, SecurityConstants.FROM_IN);
|
|
||||||
UserInfo userInfo = info.getData();
|
|
||||||
|
|
||||||
if (StringUtils.hasText(msg)) {
|
if (StringUtils.hasText(msg)) {
|
||||||
JSONObject param = new JSONObject();
|
JSONObject param = new JSONObject();
|
||||||
|
@ -142,12 +140,13 @@ public class ChatServiceImpl implements ChatService {
|
||||||
document.put("create_time", now);
|
document.put("create_time", now);
|
||||||
param.put("createTime", now);
|
param.put("createTime", now);
|
||||||
document.put("create_user", username);
|
document.put("create_user", username);
|
||||||
String name = userInfo.getSysUser().getName();
|
String name = sysUser.getName();
|
||||||
document.put("create_name", name);
|
document.put("create_name", name);
|
||||||
param.put("createName", name);
|
param.put("createName", name);
|
||||||
document.put("deleted", 0);
|
document.put("deleted", 0);
|
||||||
document.put("revoked", 0);
|
document.put("revoked", 0);
|
||||||
template.insert(document, "t_chat");
|
template.insert(document, "t_chat");
|
||||||
|
param.put("msgType", "msg");
|
||||||
|
|
||||||
Map<String, WebSocketSession> sessionMap = databaseSessionMap.get(databaseName);
|
Map<String, WebSocketSession> sessionMap = databaseSessionMap.get(databaseName);
|
||||||
for (Map.Entry<String, WebSocketSession> entry : sessionMap.entrySet()) {
|
for (Map.Entry<String, WebSocketSession> entry : sessionMap.entrySet()) {
|
||||||
|
@ -161,7 +160,8 @@ public class ChatServiceImpl implements ChatService {
|
||||||
public void sendMessageMysql(String username, String patientName, String idNum, String date, WebSocketSession session, String msg) {
|
public void sendMessageMysql(String username, String patientName, String idNum, String date, WebSocketSession session, String msg) {
|
||||||
CustomDataSource dataSource = datasourceMap.get(session.getId());
|
CustomDataSource dataSource = datasourceMap.get(session.getId());
|
||||||
String databaseName = patientName + idNum;
|
String databaseName = patientName + idNum;
|
||||||
synchronized (username) {
|
ArrayList<Map> history = new ArrayList<>();
|
||||||
|
|
||||||
if (dataSource == null) {
|
if (dataSource == null) {
|
||||||
dataSource = new MySQLSource(mysqlHost, mysqlPassword, mysqlUsername, databaseName);
|
dataSource = new MySQLSource(mysqlHost, mysqlPassword, mysqlUsername, databaseName);
|
||||||
boolean status = dataSource.open();
|
boolean status = dataSource.open();
|
||||||
|
@ -182,21 +182,18 @@ public class ChatServiceImpl implements ChatService {
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("status", 1);
|
jsonObject.put("status", 1);
|
||||||
jsonObject.put("msg", "数据库未创建, 请重新连接。");
|
jsonObject.put("msg", "数据库未创建, 请重新连接。");
|
||||||
|
jsonObject.put("msgType", "msg");
|
||||||
try {
|
try {
|
||||||
session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
session.close();
|
session.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
UserDTO userDTO = new UserDTO();
|
SysUser sysUser = SysUserService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, username));
|
||||||
userDTO.setUsername(username);
|
|
||||||
R<UserInfo> info = remoteUserService.info(userDTO, SecurityConstants.FROM_IN);
|
|
||||||
UserInfo userInfo = info.getData();
|
|
||||||
|
|
||||||
if (StringUtils.hasText(msg)) {
|
if (StringUtils.hasText(msg)) {
|
||||||
JSONObject param = new JSONObject();
|
JSONObject param = new JSONObject();
|
||||||
|
@ -229,15 +226,16 @@ public class ChatServiceImpl implements ChatService {
|
||||||
param.put("createTime", now);
|
param.put("createTime", now);
|
||||||
preparedStatement.setString(3, username);
|
preparedStatement.setString(3, username);
|
||||||
param.put("createUser", username);
|
param.put("createUser", username);
|
||||||
String name = userInfo.getSysUser().getName();
|
String name = sysUser.getName();
|
||||||
preparedStatement.setString(4, name);
|
preparedStatement.setString(4, name);
|
||||||
param.put("createName", name);
|
param.put("createName", name);
|
||||||
preparedStatement.setInt(5, 0);
|
preparedStatement.setInt(5, 0);
|
||||||
preparedStatement.setInt(6, 0);
|
preparedStatement.setInt(6, 0);
|
||||||
|
param.put("msgType", "msg");
|
||||||
|
|
||||||
preparedStatement.execute();
|
preparedStatement.execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, WebSocketSession> sessionMap = databaseSessionMap.get(databaseName);
|
Map<String, WebSocketSession> sessionMap = databaseSessionMap.get(databaseName);
|
||||||
|
@ -246,7 +244,7 @@ public class ChatServiceImpl implements ChatService {
|
||||||
try {
|
try {
|
||||||
value.sendMessage(new TextMessage(param.toJSONString().getBytes()));
|
value.sendMessage(new TextMessage(param.toJSONString().getBytes()));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,5 @@
|
||||||
package com.rax.vital.medicine.service.impl;
|
package com.rax.vital.medicine.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.rax.vital.medicine.entity.DoctorMedicine;
|
|
||||||
import com.rax.vital.medicine.mapper.DoctorMedicineMapper;
|
|
||||||
import com.rax.vital.medicine.service.DoctorMedicineService;
|
import com.rax.vital.medicine.service.DoctorMedicineService;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
|
@ -10,7 +10,6 @@ import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.socket.WebSocketSession;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.util.*;
|
import java.util.*;
|
|
@ -121,6 +121,7 @@ public class VitalSignTimerWS {
|
||||||
jsonObject.put("revulsionList", revulsionList);
|
jsonObject.put("revulsionList", revulsionList);
|
||||||
Map flags = flagService.getFlags(template);
|
Map flags = flagService.getFlags(template);
|
||||||
jsonObject.put("flags", flags);
|
jsonObject.put("flags", flags);
|
||||||
|
jsonObject.put("msgType", "msg");
|
||||||
|
|
||||||
WebSocketMessage message = new TextMessage(jsonObject.toJSONString().getBytes());
|
WebSocketMessage message = new TextMessage(jsonObject.toJSONString().getBytes());
|
||||||
try {
|
try {
|
||||||
|
@ -156,10 +157,11 @@ public class VitalSignTimerWS {
|
||||||
dataSource = new MySQLSource(mysqlHost, mysqlPassword, mysqlUsername, database);
|
dataSource = new MySQLSource(mysqlHost, mysqlPassword, mysqlUsername, database);
|
||||||
boolean status = dataSource.open();
|
boolean status = dataSource.open();
|
||||||
if (status) {
|
if (status) {
|
||||||
dataSourceMap.put(database, dataSource);
|
dataSourceMap.put(sessionId, dataSource);
|
||||||
} else {
|
} else {
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("status", 1);
|
jsonObject.put("status", 1);
|
||||||
|
jsonObject.put("msgType", "msg");
|
||||||
jsonObject.put("msg", "数据库未创建, 请重新连接。");
|
jsonObject.put("msg", "数据库未创建, 请重新连接。");
|
||||||
WebSocketMessage message = new TextMessage(jsonObject.toJSONString().getBytes());
|
WebSocketMessage message = new TextMessage(jsonObject.toJSONString().getBytes());
|
||||||
try {
|
try {
|
||||||
|
@ -182,12 +184,13 @@ public class VitalSignTimerWS {
|
||||||
jsonObject.put("vitalSignsList", vitalSignsList);
|
jsonObject.put("vitalSignsList", vitalSignsList);
|
||||||
List<Map> aiMedicineList = aiMedicineService.getAIMedicine(connection);
|
List<Map> aiMedicineList = aiMedicineService.getAIMedicine(connection);
|
||||||
jsonObject.put("aiMedicineList", aiMedicineList);
|
jsonObject.put("aiMedicineList", aiMedicineList);
|
||||||
List<Map> docMedicineList = doctorMedicineService.getDocMedicine(connection);
|
// List<Map> docMedicineList = doctorMedicineService.getDocMedicine(connection);
|
||||||
jsonObject.put("docMedicineList", docMedicineList);
|
// jsonObject.put("docMedicineList", docMedicineList);
|
||||||
List revulsionList = revulsionService.getRevulsionServiceList(connection);
|
List revulsionList = revulsionService.getRevulsionServiceList(connection);
|
||||||
jsonObject.put("revulsionList", revulsionList);
|
jsonObject.put("revulsionList", revulsionList);
|
||||||
Map flags = flagService.getFlag(connection);
|
Map flags = flagService.getFlag(connection);
|
||||||
jsonObject.put("flags", flags);
|
jsonObject.put("flags", flags);
|
||||||
|
jsonObject.put("msgType", "msg");
|
||||||
|
|
||||||
WebSocketMessage message = new TextMessage(jsonObject.toJSONString().getBytes());
|
WebSocketMessage message = new TextMessage(jsonObject.toJSONString().getBytes());
|
||||||
try {
|
try {
|
||||||
|
@ -232,11 +235,13 @@ public class VitalSignTimerWS {
|
||||||
if (machineSession != null) {
|
if (machineSession != null) {
|
||||||
result.put(medicine, value);
|
result.put(medicine, value);
|
||||||
result.put("flag", flag);
|
result.put("flag", flag);
|
||||||
|
result.put("msgType", "msg");
|
||||||
machineSession.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
machineSession.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||||
} else {
|
} else {
|
||||||
result.put("flag", flag);
|
result.put("flag", flag);
|
||||||
result.put("msg", "设备端未连接");
|
result.put("msg", "设备端未连接");
|
||||||
result.put("status", 1);
|
result.put("status", 1);
|
||||||
|
result.put("msgType", "msg");
|
||||||
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -244,6 +249,7 @@ public class VitalSignTimerWS {
|
||||||
result.put("medicine", medicine);
|
result.put("medicine", medicine);
|
||||||
result.put("msg", "设备端未连接");
|
result.put("msg", "设备端未连接");
|
||||||
result.put("status", 1);
|
result.put("status", 1);
|
||||||
|
result.put("msgType", "msg");
|
||||||
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -251,6 +257,7 @@ public class VitalSignTimerWS {
|
||||||
result.put("medicine", medicine);
|
result.put("medicine", medicine);
|
||||||
result.put("status", 1);
|
result.put("status", 1);
|
||||||
result.put("msg", "不是主控人员");
|
result.put("msg", "不是主控人员");
|
||||||
|
result.put("msgType", "msg");
|
||||||
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,6 +286,7 @@ public class VitalSignTimerWS {
|
||||||
JSONObject msg = new JSONObject();
|
JSONObject msg = new JSONObject();
|
||||||
msg.put("status", 1);
|
msg.put("status", 1);
|
||||||
msg.put("msg", "手术已有设备远程中");
|
msg.put("msg", "手术已有设备远程中");
|
||||||
|
msg.put("msgType", "msg");
|
||||||
session.sendMessage(new TextMessage(msg.toJSONString().getBytes()));
|
session.sendMessage(new TextMessage(msg.toJSONString().getBytes()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -294,10 +302,12 @@ public class VitalSignTimerWS {
|
||||||
WebSocketSession webSocketSession = userSessionMap.get(userSessionId);
|
WebSocketSession webSocketSession = userSessionMap.get(userSessionId);
|
||||||
result.put("status", code);
|
result.put("status", code);
|
||||||
result.put("msg", "");
|
result.put("msg", "");
|
||||||
|
result.put("msgType", "msg");
|
||||||
webSocketSession.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
webSocketSession.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||||
} else {
|
} else {
|
||||||
result.put("status", 1);
|
result.put("status", 1);
|
||||||
result.put("msg", "网站未进行远程");
|
result.put("msg", "网站未进行远程");
|
||||||
|
result.put("msgType", "msg");
|
||||||
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package com.rax.vital.util;
|
package com.rax.vital.util;
|
||||||
|
|
||||||
import java.util.Base64;
|
|
||||||
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
public class DatabaseNameUtil {
|
public class DatabaseNameUtil {
|
||||||
private static final String key = "ruianxing112232323";
|
private static final String key = "ruianxing112232323";
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.rax</groupId>
|
|
||||||
<artifactId>rax</artifactId>
|
|
||||||
<version>3.7.3</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>vital-signs</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<description>病人生命特征和用药模块</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!--接口文档-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.rax</groupId>
|
|
||||||
<artifactId>common-swagger</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.rax</groupId>
|
|
||||||
<artifactId>common-mybatis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.rax</groupId>
|
|
||||||
<artifactId>common-security</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- 引入quartz依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.rax</groupId>
|
|
||||||
<artifactId>quartz</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!--日志处理-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.rax</groupId>
|
|
||||||
<artifactId>common-log</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!--websocket, stompJs-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.security</groupId>
|
|
||||||
<artifactId>spring-security-messaging</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>druid-spring-boot-starter</artifactId>
|
|
||||||
<version>1.2.21</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
Loading…
Reference in New Issue
Block a user