commit: 配置local的配置文件
This commit is contained in:
parent
9cc5fed164
commit
9193e945df
|
@ -17,7 +17,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
@EnableScheduling // 开启定时任务 -> 清除日志相关内容
|
@EnableScheduling // 开启定时任务 -> 清除日志相关内容
|
||||||
// 一期下面解注, 二期注释掉
|
// 一期下面解注, 二期注释掉
|
||||||
@SpringBootApplication(exclude = MongoAutoConfiguration.class)
|
@SpringBootApplication(exclude = MongoAutoConfiguration.class)
|
||||||
//@SpringBootApplication
|
|
||||||
@ComponentScan(
|
@ComponentScan(
|
||||||
basePackages = {"com.rax"},
|
basePackages = {"com.rax"},
|
||||||
excludeFilters = {
|
excludeFilters = {
|
||||||
|
|
|
@ -1,47 +1,47 @@
|
||||||
package com.rax.vital.v2.config;
|
//package com.rax.vital.v2.config;
|
||||||
|
//
|
||||||
import com.mongodb.ConnectionString;
|
//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 org.springframework.context.annotation.Bean;
|
//import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
//import org.springframework.context.annotation.Configuration;
|
||||||
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;
|
||||||
|
//
|
||||||
import java.util.concurrent.TimeUnit;
|
//import java.util.concurrent.TimeUnit;
|
||||||
|
//
|
||||||
@Configuration
|
//@Configuration
|
||||||
public class MongoConfig {
|
//public class MongoConfig {
|
||||||
|
//
|
||||||
@Bean
|
// @Bean
|
||||||
public MongoClient mongoClient() {
|
// public MongoClient mongoClient() {
|
||||||
MongoClientSettings.Builder mongoBuilder = MongoClientSettings.builder();
|
// MongoClientSettings.Builder mongoBuilder = MongoClientSettings.builder();
|
||||||
String connectionUrl = "mongodb://useradmin:Xg137839mg@110.41.142.124:27017/information?authSource=admin";
|
// String connectionUrl = "mongodb://useradmin:Xg137839mg@110.41.142.124:27017/information?authSource=admin";
|
||||||
mongoBuilder.applyConnectionString(new ConnectionString(connectionUrl));
|
// mongoBuilder.applyConnectionString(new ConnectionString(connectionUrl));
|
||||||
mongoBuilder.applyToConnectionPoolSettings(builder -> {
|
// mongoBuilder.applyToConnectionPoolSettings(builder -> {
|
||||||
// 允许的最大连接数。
|
// // 允许的最大连接数。
|
||||||
builder.maxSize(120);
|
// builder.maxSize(120);
|
||||||
// 最小连接数。
|
// // 最小连接数。
|
||||||
builder.minSize(1);
|
// builder.minSize(1);
|
||||||
// 池连接可以存活的最长时间。零值表示寿命没有限制。超过其生命周期的池连接将被关闭并在必要时由新连接替换
|
// // 池连接可以存活的最长时间。零值表示寿命没有限制。超过其生命周期的池连接将被关闭并在必要时由新连接替换
|
||||||
builder.maxConnectionLifeTime(0, TimeUnit.SECONDS);
|
// builder.maxConnectionLifeTime(0, TimeUnit.SECONDS);
|
||||||
// 池连接的最大空闲时间。零值表示对空闲时间没有限制。超过其空闲时间的池连接将被关闭并在必要时由新连接替换
|
// // 池连接的最大空闲时间。零值表示对空闲时间没有限制。超过其空闲时间的池连接将被关闭并在必要时由新连接替换
|
||||||
builder.maxConnectionIdleTime(60, TimeUnit.MINUTES);
|
// builder.maxConnectionIdleTime(60, TimeUnit.MINUTES);
|
||||||
// 默认最大连接时间6min;
|
// // 默认最大连接时间6min;
|
||||||
builder.maxWaitTime(6, TimeUnit.MINUTES);
|
// builder.maxWaitTime(6, TimeUnit.MINUTES);
|
||||||
});
|
// });
|
||||||
return MongoClients.create(mongoBuilder.build());
|
// return MongoClients.create(mongoBuilder.build());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Bean
|
// @Bean
|
||||||
public SimpleMongoClientDatabaseFactory mongoDbFactory(MongoClient mongoClient) {
|
// public SimpleMongoClientDatabaseFactory mongoDbFactory(MongoClient mongoClient) {
|
||||||
return new SimpleMongoClientDatabaseFactory(mongoClient, "information");
|
// return new SimpleMongoClientDatabaseFactory(mongoClient, "information");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Bean
|
// @Bean
|
||||||
public MongoTemplate mongoTemplate(SimpleMongoClientDatabaseFactory mongoDbFactory) {
|
// public MongoTemplate mongoTemplate(SimpleMongoClientDatabaseFactory mongoDbFactory) {
|
||||||
return new MongoTemplate(mongoDbFactory);
|
// return new MongoTemplate(mongoDbFactory);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,50 +1,50 @@
|
||||||
package com.rax.vital.v2.config;
|
//package com.rax.vital.v2.config;
|
||||||
|
//
|
||||||
import com.rax.vital.v2.handler.AddMedicineHandler;
|
//import com.rax.vital.v2.handler.AddMedicineHandler;
|
||||||
import com.rax.vital.v2.handler.ChatHandler;
|
//import com.rax.vital.v2.handler.ChatHandler;
|
||||||
import com.rax.vital.v2.handler.MachineFeedbackHandler;
|
//import com.rax.vital.v2.handler.MachineFeedbackHandler;
|
||||||
import com.rax.vital.v2.handler.MedicineHandler;
|
//import com.rax.vital.v2.handler.MedicineHandler;
|
||||||
import com.rax.vital.v2.interceptor.WebSocketInterceptors;
|
//import com.rax.vital.v2.interceptor.WebSocketInterceptors;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Configuration;
|
//import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
//import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
||||||
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
|
//import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
|
||||||
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
|
//import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
|
||||||
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor;
|
//import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* socket配置类
|
// * socket配置类
|
||||||
* 这里使用spring托管每个socketHandler 单例
|
// * 这里使用spring托管每个socketHandler 单例
|
||||||
*/
|
// */
|
||||||
@EnableWebSocket
|
//@EnableWebSocket
|
||||||
@Configuration
|
//@Configuration
|
||||||
public class WebSocketConfig implements WebSocketConfigurer {
|
//public class WebSocketConfig implements WebSocketConfigurer {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private WebSocketInterceptors webSocketInterceptors;
|
// private WebSocketInterceptors webSocketInterceptors;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private AddMedicineHandler addMedicineHandler;
|
// private AddMedicineHandler addMedicineHandler;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private ChatHandler chatHandler;
|
// private ChatHandler chatHandler;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private MachineFeedbackHandler machineFeedbackHandler;
|
// private MachineFeedbackHandler machineFeedbackHandler;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private MedicineHandler medicineHandler;
|
// private MedicineHandler medicineHandler;
|
||||||
|
//
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
|
// public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
|
||||||
registry.addHandler(medicineHandler, "/rax/vitalSignsMedicine")
|
// registry.addHandler(medicineHandler, "/rax/vitalSignsMedicine")
|
||||||
.addHandler(chatHandler,"/rax/chatRoom")
|
// .addHandler(chatHandler,"/rax/chatRoom")
|
||||||
.addHandler(addMedicineHandler, "/rax/addMedicine")
|
// .addHandler(addMedicineHandler, "/rax/addMedicine")
|
||||||
.addHandler(machineFeedbackHandler,"/rax/getMedicine")
|
// .addHandler(machineFeedbackHandler,"/rax/getMedicine")
|
||||||
.addInterceptors(new HttpSessionHandshakeInterceptor())
|
// .addInterceptors(new HttpSessionHandshakeInterceptor())
|
||||||
.addInterceptors(webSocketInterceptors)
|
// .addInterceptors(webSocketInterceptors)
|
||||||
.setAllowedOrigins("*");
|
// .setAllowedOrigins("*");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,192 +1,192 @@
|
||||||
package com.rax.vital.v2.handler;
|
//package com.rax.vital.v2.handler;
|
||||||
|
//
|
||||||
import com.alibaba.fastjson.JSONObject;
|
//import com.alibaba.fastjson.JSONObject;
|
||||||
import com.rax.admin.api.entity.SysLog;
|
//import com.rax.admin.api.entity.SysLog;
|
||||||
import com.rax.admin.service.SysLogService;
|
//import com.rax.admin.service.SysLogService;
|
||||||
import com.rax.vital.common.util.DatabaseNameUtil;
|
//import com.rax.vital.common.util.DatabaseNameUtil;
|
||||||
import com.rax.vital.common.util.GetHttpParamUtil;
|
//import com.rax.vital.common.util.GetHttpParamUtil;
|
||||||
import com.rax.vital.common.util.SysLoggerBuilder;
|
//import com.rax.vital.common.util.SysLoggerBuilder;
|
||||||
import com.rax.vital.common.util.TokenUtil;
|
//import com.rax.vital.common.util.TokenUtil;
|
||||||
import com.rax.vital.v2.timer.AIMedicineTimer;
|
//import com.rax.vital.v2.timer.AIMedicineTimer;
|
||||||
import com.rax.vital.v2.timer.VitalSignTimerV2;
|
//import com.rax.vital.v2.timer.VitalSignTimerV2;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.socket.*;
|
//import org.springframework.web.socket.*;
|
||||||
|
//
|
||||||
import java.util.Date;
|
//import java.util.Date;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
import java.util.concurrent.*;
|
//import java.util.concurrent.*;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 网站发送给仪器给药信息
|
// * 网站发送给仪器给药信息
|
||||||
*/
|
// */
|
||||||
@Slf4j
|
//@Slf4j
|
||||||
@Component
|
//@Component
|
||||||
public class AddMedicineHandler implements WebSocketHandler {
|
//public class AddMedicineHandler implements WebSocketHandler {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private VitalSignTimerV2 vitalSignTimerV2;
|
// private VitalSignTimerV2 vitalSignTimerV2;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private SysLoggerBuilder sysLoggerBuilder;
|
// private SysLoggerBuilder sysLoggerBuilder;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private SysLogService sysLogService;
|
// private SysLogService sysLogService;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private TokenUtil tokenUtil;
|
// private TokenUtil tokenUtil;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private AIMedicineTimer aiMedicineTimer;
|
// private AIMedicineTimer aiMedicineTimer;
|
||||||
|
//
|
||||||
// 发送心跳任务的定时任务容器
|
// // 发送心跳任务的定时任务容器
|
||||||
private Map<String, ScheduledExecutorService> timerTaskMap = new ConcurrentHashMap<>();
|
// private Map<String, ScheduledExecutorService> timerTaskMap = new ConcurrentHashMap<>();
|
||||||
|
//
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void afterConnectionEstablished(WebSocketSession session) {
|
// public void afterConnectionEstablished(WebSocketSession session) {
|
||||||
startHeartbeat(session);
|
// startHeartbeat(session);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
|
// public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
|
||||||
|
//
|
||||||
JSONObject jsonObject = JSONObject.parseObject((String) message.getPayload());
|
// JSONObject jsonObject = JSONObject.parseObject((String) message.getPayload());
|
||||||
String msgType = jsonObject.getString("msgType");
|
// String msgType = jsonObject.getString("msgType");
|
||||||
if (!"heartbeat".equals(msgType)) {
|
// if (!"heartbeat".equals(msgType)) {
|
||||||
// 病人名
|
// // 病人名
|
||||||
String patientName = jsonObject.getString("patientName");
|
// String patientName = jsonObject.getString("patientName");
|
||||||
// 病人身份证
|
// // 病人身份证
|
||||||
String idNum = jsonObject.getString("idNum");
|
// String idNum = jsonObject.getString("idNum");
|
||||||
// yyyyMMdd
|
// // yyyyMMdd
|
||||||
String date = jsonObject.getString("date");
|
// String date = jsonObject.getString("date");
|
||||||
String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
// String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||||
|
//
|
||||||
// 将网站端的dbName作为key session作为Value存入Map 以便后续判断状态
|
// // 将网站端的dbName作为key session作为Value存入Map 以便后续判断状态
|
||||||
if ("init".equals(msgType)) {
|
// if ("init".equals(msgType)) {
|
||||||
aiMedicineTimer.initWeb(databaseName, session);
|
// aiMedicineTimer.initWeb(databaseName, session);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 处理网页端接收到消息后的相应内容
|
// // 处理网页端接收到消息后的相应内容
|
||||||
if ("webResponseConnection".equals(msgType)) {
|
// if ("webResponseConnection".equals(msgType)) {
|
||||||
String webConnectionFlag = jsonObject.getString("webConnectionFlag");
|
// String webConnectionFlag = jsonObject.getString("webConnectionFlag");
|
||||||
// 给unity端发送网页端拒绝连接
|
// // 给unity端发送网页端拒绝连接
|
||||||
aiMedicineTimer.sendConnectionResponseToUnity(patientName, idNum, date, databaseName, webConnectionFlag);
|
// aiMedicineTimer.sendConnectionResponseToUnity(patientName, idNum, date, databaseName, webConnectionFlag);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 处理web端请求或断开连接
|
// // 处理web端请求或断开连接
|
||||||
if ("webRequestConnection".equals(msgType)) {
|
// if ("webRequestConnection".equals(msgType)) {
|
||||||
String webRequestFlag = jsonObject.getString("webConnectionFlag");
|
// String webRequestFlag = jsonObject.getString("webConnectionFlag");
|
||||||
aiMedicineTimer.sendWebRequestConnectionMsg(patientName, idNum, date, databaseName, webRequestFlag);
|
// aiMedicineTimer.sendWebRequestConnectionMsg(patientName, idNum, date, databaseName, webRequestFlag);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
// 处理发送给药相关
|
// // 处理发送给药相关
|
||||||
if ("addMedicine".equals(msgType) && aiMedicineTimer.getWebSession(databaseName) != null && aiMedicineTimer.getUnitySession(databaseName) != null
|
// if ("addMedicine".equals(msgType) && aiMedicineTimer.getWebSession(databaseName) != null && aiMedicineTimer.getUnitySession(databaseName) != null
|
||||||
&& aiMedicineTimer.isReady(databaseName)) {
|
// && aiMedicineTimer.isReady(databaseName)) {
|
||||||
// 解析获取username
|
// // 解析获取username
|
||||||
String query = session.getUri().getQuery();
|
// String query = session.getUri().getQuery();
|
||||||
String token = GetHttpParamUtil.getParam(query, "token");
|
// String token = GetHttpParamUtil.getParam(query, "token");
|
||||||
Map<String, Object> map = tokenUtil.parseToken(token);
|
// Map<String, Object> map = tokenUtil.parseToken(token);
|
||||||
String username = (String) map.get("username");
|
// String username = (String) map.get("username");
|
||||||
|
//
|
||||||
// flag 0 代表人工给药, 1代表AI给药
|
// // flag 0 代表人工给药, 1代表AI给药
|
||||||
vitalSignTimerV2.sendMedicalMessageToUnity(databaseName, username, session, jsonObject.getString("flag"),
|
// vitalSignTimerV2.sendMedicalMessageToUnity(databaseName, username, session, jsonObject.getString("flag"),
|
||||||
jsonObject.getString("medicine"), jsonObject.getString("value"));
|
// jsonObject.getString("medicine"), jsonObject.getString("value"));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 展示网页端延迟信息
|
// // 展示网页端延迟信息
|
||||||
if ("ping".equals(msgType)) {
|
// if ("ping".equals(msgType)) {
|
||||||
Long timeStamp = jsonObject.getLong("msg");
|
// Long timeStamp = jsonObject.getLong("msg");
|
||||||
JSONObject result = new JSONObject();
|
// JSONObject result = new JSONObject();
|
||||||
result.put("msgType", "pong");
|
// result.put("msgType", "pong");
|
||||||
if (aiMedicineTimer.getWebSession(databaseName) != null) {
|
// if (aiMedicineTimer.getWebSession(databaseName) != null) {
|
||||||
result.put("webMsg", "网页端已登陆");
|
// result.put("webMsg", "网页端已登陆");
|
||||||
} else {
|
// } else {
|
||||||
result.put("webMsg", "网页端未登陆");
|
// result.put("webMsg", "网页端未登陆");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (aiMedicineTimer.getUnitySession(databaseName) != null) {
|
// if (aiMedicineTimer.getUnitySession(databaseName) != null) {
|
||||||
result.put("unityMsg", "unity端已登录");
|
// result.put("unityMsg", "unity端已登录");
|
||||||
} else {
|
// } else {
|
||||||
result.put("unityMsg", "unity端未登录");
|
// result.put("unityMsg", "unity端未登录");
|
||||||
}
|
// }
|
||||||
// 当前时间戳
|
// // 当前时间戳
|
||||||
Long diff = new Date().getTime() - timeStamp;
|
// Long diff = new Date().getTime() - timeStamp;
|
||||||
result.put("msg", diff);
|
// result.put("msg", diff);
|
||||||
sendMsgAsync(session,result);
|
// sendMsgAsync(session,result);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void handleTransportError(WebSocketSession session, Throwable exception) {
|
// public void handleTransportError(WebSocketSession session, Throwable exception) {
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
aiMedicineTimer.closeConnection(session);
|
// aiMedicineTimer.closeConnection(session);
|
||||||
SysLog sysLog = sysLoggerBuilder.buildSysLog("给药接口异常中断:"+exception.getMessage(), "4", session);
|
// SysLog sysLog = sysLoggerBuilder.buildSysLog("给药接口异常中断:"+exception.getMessage(), "4", session);
|
||||||
sysLogService.saveLog(sysLog);
|
// sysLogService.saveLog(sysLog);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) {
|
// public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) {
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
aiMedicineTimer.closeConnection(session);
|
// aiMedicineTimer.closeConnection(session);
|
||||||
SysLog sysLog = sysLoggerBuilder.buildSysLog("给药接口客户端,断开连接", "0", session);
|
// SysLog sysLog = sysLoggerBuilder.buildSysLog("给药接口客户端,断开连接", "0", session);
|
||||||
sysLogService.saveLog(sysLog);
|
// sysLogService.saveLog(sysLog);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public boolean supportsPartialMessages() {
|
// public boolean supportsPartialMessages() {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void startHeartbeat(WebSocketSession session) {
|
// private void startHeartbeat(WebSocketSession session) {
|
||||||
if (!timerTaskMap.containsKey(session.getId())) {
|
// if (!timerTaskMap.containsKey(session.getId())) {
|
||||||
ScheduledExecutorService heartbeatExecutor = Executors.newScheduledThreadPool(1);
|
// ScheduledExecutorService heartbeatExecutor = Executors.newScheduledThreadPool(1);
|
||||||
heartbeatExecutor.scheduleAtFixedRate(() -> {
|
// heartbeatExecutor.scheduleAtFixedRate(() -> {
|
||||||
try {
|
// try {
|
||||||
if (session.isOpen()) {
|
// if (session.isOpen()) {
|
||||||
JSONObject jsonObject = new JSONObject();
|
// JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("msgType", "heartbeat");
|
// jsonObject.put("msgType", "heartbeat");
|
||||||
session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
// session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
} else {
|
// } else {
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
aiMedicineTimer.closeConnection(session);
|
// aiMedicineTimer.closeConnection(session);
|
||||||
session.close();
|
// session.close();
|
||||||
}
|
// }
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
}
|
// }
|
||||||
}, 0, 30, TimeUnit.SECONDS);
|
// }, 0, 30, TimeUnit.SECONDS);
|
||||||
timerTaskMap.put(session.getId(), heartbeatExecutor);
|
// timerTaskMap.put(session.getId(), heartbeatExecutor);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void stopHeartbeat(WebSocketSession session) {
|
// private void stopHeartbeat(WebSocketSession session) {
|
||||||
ScheduledExecutorService heartbeatExecutor = timerTaskMap.get(session.getId());
|
// ScheduledExecutorService heartbeatExecutor = timerTaskMap.get(session.getId());
|
||||||
heartbeatExecutor.shutdownNow();
|
// heartbeatExecutor.shutdownNow();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 异步发送消息
|
// // 异步发送消息
|
||||||
private void sendMsgAsync(WebSocketSession session, JSONObject jsonObject) {
|
// private void sendMsgAsync(WebSocketSession session, JSONObject jsonObject) {
|
||||||
CompletableFuture.runAsync(() -> {
|
// CompletableFuture.runAsync(() -> {
|
||||||
try {
|
// try {
|
||||||
if (session.isOpen()) {
|
// if (session.isOpen()) {
|
||||||
session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
// session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
}else {
|
// }else {
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
aiMedicineTimer.closeConnection(session);
|
// aiMedicineTimer.closeConnection(session);
|
||||||
session.close();
|
// session.close();
|
||||||
}
|
// }
|
||||||
}catch (Exception e) {
|
// }catch (Exception e) {
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
aiMedicineTimer.closeConnection(session);
|
// aiMedicineTimer.closeConnection(session);
|
||||||
log.error("addMedicineHandler-sendMsgAsync error: {}", e.getMessage());
|
// log.error("addMedicineHandler-sendMsgAsync error: {}", e.getMessage());
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,115 +1,115 @@
|
||||||
package com.rax.vital.v2.handler;
|
//package com.rax.vital.v2.handler;
|
||||||
|
//
|
||||||
import com.alibaba.fastjson.JSONObject;
|
//import com.alibaba.fastjson.JSONObject;
|
||||||
import com.rax.admin.api.entity.SysLog;
|
//import com.rax.admin.api.entity.SysLog;
|
||||||
import com.rax.admin.service.SysLogService;
|
//import com.rax.admin.service.SysLogService;
|
||||||
import com.rax.vital.common.util.DatabaseNameUtil;
|
//import com.rax.vital.common.util.DatabaseNameUtil;
|
||||||
import com.rax.vital.common.util.GetHttpParamUtil;
|
//import com.rax.vital.common.util.GetHttpParamUtil;
|
||||||
import com.rax.vital.common.util.SysLoggerBuilder;
|
//import com.rax.vital.common.util.SysLoggerBuilder;
|
||||||
import com.rax.vital.common.util.TokenUtil;
|
//import com.rax.vital.common.util.TokenUtil;
|
||||||
import com.rax.vital.v2.medicine.service.ChatService;
|
//import com.rax.vital.v2.medicine.service.ChatService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.socket.*;
|
//import org.springframework.web.socket.*;
|
||||||
|
//
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
import java.util.Objects;
|
//import java.util.Objects;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
//import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.Executors;
|
//import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
//import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
//import java.util.concurrent.TimeUnit;
|
||||||
|
//
|
||||||
@Component
|
//@Component
|
||||||
public class ChatHandler implements WebSocketHandler {
|
//public class ChatHandler implements WebSocketHandler {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private ChatService chatService;
|
// private ChatService chatService;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private SysLoggerBuilder sysLoggerBuilder;
|
// private SysLoggerBuilder sysLoggerBuilder;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private SysLogService sysLogService;
|
// private SysLogService sysLogService;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private TokenUtil tokenUtil;
|
// private TokenUtil tokenUtil;
|
||||||
|
//
|
||||||
private Map<String, ScheduledExecutorService> timerTaskMap = new ConcurrentHashMap();
|
// private Map<String, ScheduledExecutorService> timerTaskMap = new ConcurrentHashMap();
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void afterConnectionEstablished(WebSocketSession session) {
|
// public void afterConnectionEstablished(WebSocketSession session) {
|
||||||
startHeartbeat(session);
|
// startHeartbeat(session);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
|
// public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
|
||||||
|
//
|
||||||
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"))) {
|
// if (!"heartbeat".equals(jsonObject.getString("msgType"))) {
|
||||||
|
//
|
||||||
String query = Objects.requireNonNull(session.getUri()).getQuery();
|
// String query = Objects.requireNonNull(session.getUri()).getQuery();
|
||||||
String token = GetHttpParamUtil.getParam(query, "token");
|
// String token = GetHttpParamUtil.getParam(query, "token");
|
||||||
Map<String, Object> map = tokenUtil.parseToken(token);
|
// Map<String, Object> map = tokenUtil.parseToken(token);
|
||||||
String username = (String) map.get("username");
|
// String username = (String) map.get("username");
|
||||||
|
//
|
||||||
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");
|
||||||
String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
// String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||||
chatService.sendMessage(databaseName, username, session, msg);
|
// chatService.sendMessage(databaseName, username, session, msg);
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void handleTransportError(WebSocketSession session, Throwable exception) {
|
// public void handleTransportError(WebSocketSession session, Throwable exception) {
|
||||||
SysLog sysLog = sysLoggerBuilder.buildSysLog("聊天室接口异常中断:"+exception.getMessage(), "4", session);
|
// SysLog sysLog = sysLoggerBuilder.buildSysLog("聊天室接口异常中断:"+exception.getMessage(), "4", session);
|
||||||
sysLogService.saveLog(sysLog);
|
// sysLogService.saveLog(sysLog);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) {
|
// public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) {
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
chatService.stopTask(session.getId());
|
// chatService.stopTask(session.getId());
|
||||||
SysLog sysLog = sysLoggerBuilder.buildSysLog("聊天室接口关闭", "0", session);
|
// SysLog sysLog = sysLoggerBuilder.buildSysLog("聊天室接口关闭", "0", session);
|
||||||
sysLogService.saveLog(sysLog);
|
// sysLogService.saveLog(sysLog);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public boolean supportsPartialMessages() {
|
// public boolean supportsPartialMessages() {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void startHeartbeat(WebSocketSession session) {
|
// private void startHeartbeat(WebSocketSession session) {
|
||||||
if (!timerTaskMap.containsKey(session.getId())) {
|
// if (!timerTaskMap.containsKey(session.getId())) {
|
||||||
ScheduledExecutorService heartbeatExecutor = Executors.newScheduledThreadPool(1);
|
// ScheduledExecutorService heartbeatExecutor = Executors.newScheduledThreadPool(1);
|
||||||
heartbeatExecutor.scheduleAtFixedRate(() -> {
|
// heartbeatExecutor.scheduleAtFixedRate(() -> {
|
||||||
try {
|
// try {
|
||||||
if (session.isOpen()) {
|
// if (session.isOpen()) {
|
||||||
JSONObject jsonObject = new JSONObject();
|
// JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("msgType", "heartbeat");
|
// jsonObject.put("msgType", "heartbeat");
|
||||||
session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
// session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
} else {
|
// } else {
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
chatService.stopTask(session.getId());
|
// chatService.stopTask(session.getId());
|
||||||
session.close();
|
// session.close();
|
||||||
}
|
// }
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
}
|
// }
|
||||||
}, 0, 10, TimeUnit.SECONDS);
|
// }, 0, 10, TimeUnit.SECONDS);
|
||||||
timerTaskMap.put(session.getId(), heartbeatExecutor);
|
// timerTaskMap.put(session.getId(), heartbeatExecutor);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void stopHeartbeat(WebSocketSession session) {
|
// private void stopHeartbeat(WebSocketSession session) {
|
||||||
ScheduledExecutorService heartbeatExecutor = timerTaskMap.get(session.getId());
|
// ScheduledExecutorService heartbeatExecutor = timerTaskMap.get(session.getId());
|
||||||
heartbeatExecutor.shutdownNow();
|
// heartbeatExecutor.shutdownNow();
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,209 +1,209 @@
|
||||||
package com.rax.vital.v2.handler;
|
//package com.rax.vital.v2.handler;
|
||||||
|
//
|
||||||
import com.alibaba.fastjson.JSONObject;
|
//import com.alibaba.fastjson.JSONObject;
|
||||||
import com.rax.admin.api.entity.SysLog;
|
//import com.rax.admin.api.entity.SysLog;
|
||||||
import com.rax.admin.service.SysLogService;
|
//import com.rax.admin.service.SysLogService;
|
||||||
import com.rax.vital.common.util.DatabaseNameUtil;
|
//import com.rax.vital.common.util.DatabaseNameUtil;
|
||||||
import com.rax.vital.common.util.SysLoggerBuilder;
|
//import com.rax.vital.common.util.SysLoggerBuilder;
|
||||||
import com.rax.vital.v2.timer.AIMedicineTimer;
|
//import com.rax.vital.v2.timer.AIMedicineTimer;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.socket.*;
|
//import org.springframework.web.socket.*;
|
||||||
|
//
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.util.Date;
|
//import java.util.Date;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
import java.util.concurrent.*;
|
//import java.util.concurrent.*;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 仪器获取网站给药信息
|
// * 仪器获取网站给药信息
|
||||||
*/
|
// */
|
||||||
@Slf4j
|
//@Slf4j
|
||||||
@Component
|
//@Component
|
||||||
public class MachineFeedbackHandler implements WebSocketHandler {
|
//public class MachineFeedbackHandler implements WebSocketHandler {
|
||||||
|
//
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private SysLoggerBuilder sysLoggerBuilder;
|
// private SysLoggerBuilder sysLoggerBuilder;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private SysLogService sysLogService;
|
// private SysLogService sysLogService;
|
||||||
|
//
|
||||||
private Map<String, ScheduledExecutorService> timerTaskMap = new ConcurrentHashMap();
|
// private Map<String, ScheduledExecutorService> timerTaskMap = new ConcurrentHashMap();
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private AIMedicineTimer aiMedicineTimer;
|
// private AIMedicineTimer aiMedicineTimer;
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void afterConnectionEstablished(WebSocketSession session) throws IOException {
|
// public void afterConnectionEstablished(WebSocketSession session) throws IOException {
|
||||||
JSONObject msg = new JSONObject();
|
// JSONObject msg = new JSONObject();
|
||||||
msg.put("msgType", "msg");
|
// msg.put("msgType", "msg");
|
||||||
msg.put("msg", "已成功连接服务器!");
|
// msg.put("msg", "已成功连接服务器!");
|
||||||
session.sendMessage(new TextMessage(msg.toJSONString().getBytes()));
|
// session.sendMessage(new TextMessage(msg.toJSONString().getBytes()));
|
||||||
startHeartbeat(session);
|
// startHeartbeat(session);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
|
// public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
|
||||||
|
//
|
||||||
JSONObject jsonObject = JSONObject.parseObject((String) message.getPayload());
|
// JSONObject jsonObject = JSONObject.parseObject((String) message.getPayload());
|
||||||
|
//
|
||||||
String msgType = jsonObject.getString("msgType");
|
// String msgType = jsonObject.getString("msgType");
|
||||||
if (!"heartbeat".equals(msgType)) {
|
// if (!"heartbeat".equals(msgType)) {
|
||||||
// 病人名
|
// // 病人名
|
||||||
String patientName = jsonObject.getString("patientName");
|
// String patientName = jsonObject.getString("patientName");
|
||||||
// 病人身份证住院号
|
// // 病人身份证住院号
|
||||||
String idNum = jsonObject.getString("idNum");
|
// String idNum = jsonObject.getString("idNum");
|
||||||
// yyyyMMdd
|
// // yyyyMMdd
|
||||||
String date = jsonObject.getString("date");
|
// String date = jsonObject.getString("date");
|
||||||
String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
// String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||||
String code = jsonObject.getString("code");
|
// String code = jsonObject.getString("code");
|
||||||
|
//
|
||||||
if ("init".equals(msgType)) {
|
// if ("init".equals(msgType)) {
|
||||||
aiMedicineTimer.initUnity(databaseName, session);
|
// aiMedicineTimer.initUnity(databaseName, session);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// Unity获取到给药信息后回复
|
// // Unity获取到给药信息后回复
|
||||||
if ("getMedicine".equals(msgType)) {
|
// if ("getMedicine".equals(msgType)) {
|
||||||
JSONObject msg = new JSONObject();
|
// JSONObject msg = new JSONObject();
|
||||||
msg.put("msgType", msgType);
|
// msg.put("msgType", msgType);
|
||||||
msg.put("patientName", patientName);
|
// msg.put("patientName", patientName);
|
||||||
msg.put("idNum", idNum);
|
// msg.put("idNum", idNum);
|
||||||
msg.put("date", date);
|
// msg.put("date", date);
|
||||||
WebSocketSession webSession = aiMedicineTimer.getWebSession(databaseName);
|
// WebSocketSession webSession = aiMedicineTimer.getWebSession(databaseName);
|
||||||
webSession.sendMessage(new TextMessage(msg.toJSONString().getBytes()));
|
// webSession.sendMessage(new TextMessage(msg.toJSONString().getBytes()));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
// u3d发送表示请求与网页端的连接
|
// // u3d发送表示请求与网页端的连接
|
||||||
if ("unityRequestConnection".equals(msgType)) {
|
// if ("unityRequestConnection".equals(msgType)) {
|
||||||
String unityConnectionFlag = jsonObject.getString("unityConnectionFlag");
|
// String unityConnectionFlag = jsonObject.getString("unityConnectionFlag");
|
||||||
// u3d端请求网页端连接或断开
|
// // u3d端请求网页端连接或断开
|
||||||
aiMedicineTimer.sendUnityRequestConnectionMsg(patientName, idNum, date, databaseName, unityConnectionFlag);
|
// aiMedicineTimer.sendUnityRequestConnectionMsg(patientName, idNum, date, databaseName, unityConnectionFlag);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// u3d相应网页端的请求
|
// // u3d相应网页端的请求
|
||||||
if ("unityResponseConnection".equals(msgType)) {
|
// if ("unityResponseConnection".equals(msgType)) {
|
||||||
String unityConnectionFlag = jsonObject.getString("unityConnectionFlag");
|
// String unityConnectionFlag = jsonObject.getString("unityConnectionFlag");
|
||||||
aiMedicineTimer.sendConnectionResponseToWeb(patientName, idNum, date, databaseName, unityConnectionFlag);
|
// aiMedicineTimer.sendConnectionResponseToWeb(patientName, idNum, date, databaseName, unityConnectionFlag);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (aiMedicineTimer.getUnitySession(databaseName) != null
|
// if (aiMedicineTimer.getUnitySession(databaseName) != null
|
||||||
&& aiMedicineTimer.getWebSession(databaseName) != null
|
// && aiMedicineTimer.getWebSession(databaseName) != null
|
||||||
&& aiMedicineTimer.isReady(databaseName)) {
|
// && aiMedicineTimer.isReady(databaseName)) {
|
||||||
// vitalSignTimerWS.sendMachineFlag(databaseName, code, session);
|
// // vitalSignTimerWS.sendMachineFlag(databaseName, code, session);
|
||||||
JSONObject msg = new JSONObject();
|
// JSONObject msg = new JSONObject();
|
||||||
msg.put("status", code);
|
// msg.put("status", code);
|
||||||
msg.put("msg", "网站已进行远程连接");
|
// msg.put("msg", "网站已进行远程连接");
|
||||||
msg.put("msgType", "msg");
|
// msg.put("msgType", "msg");
|
||||||
WebSocketSession unitySession = aiMedicineTimer.getUnitySession(databaseName);
|
// WebSocketSession unitySession = aiMedicineTimer.getUnitySession(databaseName);
|
||||||
unitySession.sendMessage(new TextMessage(msg.toJSONString().getBytes()));
|
// unitySession.sendMessage(new TextMessage(msg.toJSONString().getBytes()));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 展示unity端延迟信息
|
// // 展示unity端延迟信息
|
||||||
if ("ping".equals(msgType)) {
|
// if ("ping".equals(msgType)) {
|
||||||
Long timeStamp = jsonObject.getLong("msg");
|
// Long timeStamp = jsonObject.getLong("msg");
|
||||||
JSONObject result = new JSONObject();
|
// JSONObject result = new JSONObject();
|
||||||
result.put("msgType", "pong");
|
// result.put("msgType", "pong");
|
||||||
if (aiMedicineTimer.getWebSession(databaseName) != null) {
|
// if (aiMedicineTimer.getWebSession(databaseName) != null) {
|
||||||
result.put("webMsg", "网页端已登陆");
|
// result.put("webMsg", "网页端已登陆");
|
||||||
} else {
|
// } else {
|
||||||
result.put("webMsg", "网页端未登陆");
|
// result.put("webMsg", "网页端未登陆");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (aiMedicineTimer.getUnitySession(databaseName) != null) {
|
// if (aiMedicineTimer.getUnitySession(databaseName) != null) {
|
||||||
result.put("unityMsg", "unity端已登录");
|
// result.put("unityMsg", "unity端已登录");
|
||||||
} else {
|
// } else {
|
||||||
result.put("unityMsg", "unity端未登录");
|
// result.put("unityMsg", "unity端未登录");
|
||||||
}
|
// }
|
||||||
// 当前时间戳
|
// // 当前时间戳
|
||||||
Long diff = new Date().getTime() - timeStamp;
|
// Long diff = new Date().getTime() - timeStamp;
|
||||||
result.put("msg", diff);
|
// result.put("msg", diff);
|
||||||
sendMsgAsync(session, result);
|
// sendMsgAsync(session, result);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// unity收到给药信息后回复把此消息推送给web
|
// // unity收到给药信息后回复把此消息推送给web
|
||||||
if ("getMedicine".equals(msgType)) {
|
// if ("getMedicine".equals(msgType)) {
|
||||||
JSONObject getMedicineMsg = new JSONObject();
|
// JSONObject getMedicineMsg = new JSONObject();
|
||||||
getMedicineMsg.put("msgType", "getMedicine");
|
// getMedicineMsg.put("msgType", "getMedicine");
|
||||||
getMedicineMsg.put("patientName", patientName);
|
// getMedicineMsg.put("patientName", patientName);
|
||||||
getMedicineMsg.put("idNum", idNum);
|
// getMedicineMsg.put("idNum", idNum);
|
||||||
getMedicineMsg.put("date", date);
|
// getMedicineMsg.put("date", date);
|
||||||
getMedicineMsg.put(jsonObject.getString("medicine"), jsonObject.getString("value"));
|
// getMedicineMsg.put(jsonObject.getString("medicine"), jsonObject.getString("value"));
|
||||||
WebSocketSession webSession = aiMedicineTimer.getWebSession(databaseName);
|
// WebSocketSession webSession = aiMedicineTimer.getWebSession(databaseName);
|
||||||
webSession.sendMessage(new TextMessage(getMedicineMsg.toJSONString().getBytes()));
|
// webSession.sendMessage(new TextMessage(getMedicineMsg.toJSONString().getBytes()));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void handleTransportError(WebSocketSession session, Throwable exception) {
|
// public void handleTransportError(WebSocketSession session, Throwable exception) {
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
aiMedicineTimer.closeConnection(session);
|
// aiMedicineTimer.closeConnection(session);
|
||||||
SysLog sysLog = sysLoggerBuilder.buildSysLog("仪器端获取收药口异常中断", "4", session);
|
// SysLog sysLog = sysLoggerBuilder.buildSysLog("仪器端获取收药口异常中断", "4", session);
|
||||||
sysLogService.saveLog(sysLog);
|
// sysLogService.saveLog(sysLog);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) {
|
// public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) {
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
aiMedicineTimer.closeConnection(session);
|
// aiMedicineTimer.closeConnection(session);
|
||||||
SysLog sysLog = sysLoggerBuilder.buildSysLog("仪器端收药接口关闭", "0", session);
|
// SysLog sysLog = sysLoggerBuilder.buildSysLog("仪器端收药接口关闭", "0", session);
|
||||||
sysLogService.saveLog(sysLog);
|
// sysLogService.saveLog(sysLog);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public boolean supportsPartialMessages() {
|
// public boolean supportsPartialMessages() {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void startHeartbeat(WebSocketSession session) {
|
// private void startHeartbeat(WebSocketSession session) {
|
||||||
if (!timerTaskMap.containsKey(session.getId())) {
|
// if (!timerTaskMap.containsKey(session.getId())) {
|
||||||
ScheduledExecutorService heartbeatExecutor = Executors.newScheduledThreadPool(1);
|
// ScheduledExecutorService heartbeatExecutor = Executors.newScheduledThreadPool(1);
|
||||||
heartbeatExecutor.scheduleAtFixedRate(() -> {
|
// heartbeatExecutor.scheduleAtFixedRate(() -> {
|
||||||
try {
|
// try {
|
||||||
if (session.isOpen()) {
|
// if (session.isOpen()) {
|
||||||
JSONObject jsonObject = new JSONObject();
|
// JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("msgType", "heartbeat");
|
// jsonObject.put("msgType", "heartbeat");
|
||||||
session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
// session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
} else {
|
// } else {
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
aiMedicineTimer.closeConnection(session);
|
// aiMedicineTimer.closeConnection(session);
|
||||||
session.close();
|
// session.close();
|
||||||
}
|
// }
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
}
|
// }
|
||||||
}, 0, 30, TimeUnit.SECONDS);
|
// }, 0, 30, TimeUnit.SECONDS);
|
||||||
timerTaskMap.put(session.getId(), heartbeatExecutor);
|
// timerTaskMap.put(session.getId(), heartbeatExecutor);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void stopHeartbeat(WebSocketSession session) {
|
// private void stopHeartbeat(WebSocketSession session) {
|
||||||
ScheduledExecutorService heartbeatExecutor = timerTaskMap.get(session.getId());
|
// ScheduledExecutorService heartbeatExecutor = timerTaskMap.get(session.getId());
|
||||||
heartbeatExecutor.shutdownNow();
|
// heartbeatExecutor.shutdownNow();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 异步发送消息
|
// // 异步发送消息
|
||||||
private void sendMsgAsync(WebSocketSession session, JSONObject jsonObject) {
|
// private void sendMsgAsync(WebSocketSession session, JSONObject jsonObject) {
|
||||||
CompletableFuture.runAsync(() -> {
|
// CompletableFuture.runAsync(() -> {
|
||||||
try {
|
// try {
|
||||||
if (session.isOpen()) {
|
// if (session.isOpen()) {
|
||||||
session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
// session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
} else {
|
// } else {
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
aiMedicineTimer.closeConnection(session);
|
// aiMedicineTimer.closeConnection(session);
|
||||||
session.close();
|
// session.close();
|
||||||
}
|
// }
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
aiMedicineTimer.closeConnection(session);
|
// aiMedicineTimer.closeConnection(session);
|
||||||
log.error("addMedicineHandler-sendMsgAsync error: {}", e.getMessage());
|
// log.error("addMedicineHandler-sendMsgAsync error: {}", e.getMessage());
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,119 +1,119 @@
|
||||||
package com.rax.vital.v2.handler;
|
//package com.rax.vital.v2.handler;
|
||||||
|
//
|
||||||
import com.alibaba.fastjson.JSONObject;
|
//import com.alibaba.fastjson.JSONObject;
|
||||||
import com.rax.admin.api.entity.SysLog;
|
//import com.rax.admin.api.entity.SysLog;
|
||||||
import com.rax.admin.service.SysLogService;
|
//import com.rax.admin.service.SysLogService;
|
||||||
import com.rax.vital.common.util.DatabaseNameUtil;
|
//import com.rax.vital.common.util.DatabaseNameUtil;
|
||||||
import com.rax.vital.common.util.GetHttpParamUtil;
|
//import com.rax.vital.common.util.GetHttpParamUtil;
|
||||||
import com.rax.vital.common.util.SysLoggerBuilder;
|
//import com.rax.vital.common.util.SysLoggerBuilder;
|
||||||
import com.rax.vital.common.util.TokenUtil;
|
//import com.rax.vital.common.util.TokenUtil;
|
||||||
import com.rax.vital.v2.timer.VitalSignTimerV2;
|
//import com.rax.vital.v2.timer.VitalSignTimerV2;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.socket.*;
|
//import org.springframework.web.socket.*;
|
||||||
|
//
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
//import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.Executors;
|
//import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
//import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
//import java.util.concurrent.TimeUnit;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 生命体征和标志位信息
|
// * 生命体征和标志位信息
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
@Slf4j
|
//@Slf4j
|
||||||
@Component
|
//@Component
|
||||||
public class MedicineHandler implements WebSocketHandler {
|
//public class MedicineHandler implements WebSocketHandler {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private VitalSignTimerV2 vitalSignTimerV2;
|
// private VitalSignTimerV2 vitalSignTimerV2;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private SysLoggerBuilder sysLoggerBuilder;
|
// private SysLoggerBuilder sysLoggerBuilder;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private SysLogService sysLogService;
|
// private SysLogService sysLogService;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private TokenUtil tokenUtil;
|
// private TokenUtil tokenUtil;
|
||||||
|
//
|
||||||
private Map<String, ScheduledExecutorService> timerTaskMap = new ConcurrentHashMap<>();
|
// private Map<String, ScheduledExecutorService> timerTaskMap = new ConcurrentHashMap<>();
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void afterConnectionEstablished(WebSocketSession session) {
|
// public void afterConnectionEstablished(WebSocketSession session) {
|
||||||
startHeartbeat(session);
|
// startHeartbeat(session);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) {
|
// public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) {
|
||||||
|
//
|
||||||
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"))) {
|
// if (!"heartbeat".equals(jsonObject.getString("msgType"))) {
|
||||||
|
//
|
||||||
String query = session.getUri().getQuery();
|
// String query = session.getUri().getQuery();
|
||||||
String token = GetHttpParamUtil.getParam(query, "token");
|
// String token = GetHttpParamUtil.getParam(query, "token");
|
||||||
Map<String, Object> map = tokenUtil.parseToken(token);
|
// Map<String, Object> map = tokenUtil.parseToken(token);
|
||||||
String username = (String) map.get("username");
|
// String username = (String) map.get("username");
|
||||||
|
//
|
||||||
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 databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
// String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||||
vitalSignTimerV2.sendMedicalMessage(databaseName, username, session);
|
// vitalSignTimerV2.sendMedicalMessage(databaseName, username, session);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
|
// public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
vitalSignTimerV2.stopTimerTask(session.getId());
|
// vitalSignTimerV2.stopTimerTask(session.getId());
|
||||||
SysLog sysLog = sysLoggerBuilder.buildSysLog("生命体征接口异常中断", "4", session);
|
// SysLog sysLog = sysLoggerBuilder.buildSysLog("生命体征接口异常中断", "4", session);
|
||||||
sysLogService.saveLog(sysLog);
|
// sysLogService.saveLog(sysLog);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
|
// public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
vitalSignTimerV2.stopTimerTask(session.getId());
|
// vitalSignTimerV2.stopTimerTask(session.getId());
|
||||||
SysLog sysLog = sysLoggerBuilder.buildSysLog("生命体征接口连接关闭", "0", session);
|
// SysLog sysLog = sysLoggerBuilder.buildSysLog("生命体征接口连接关闭", "0", session);
|
||||||
sysLogService.saveLog(sysLog);
|
// sysLogService.saveLog(sysLog);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public boolean supportsPartialMessages() {
|
// public boolean supportsPartialMessages() {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void startHeartbeat(WebSocketSession session) {
|
// private void startHeartbeat(WebSocketSession session) {
|
||||||
if (!timerTaskMap.containsKey(session.getId())) {
|
// if (!timerTaskMap.containsKey(session.getId())) {
|
||||||
ScheduledExecutorService heartbeatExecutor = Executors.newScheduledThreadPool(1);
|
// ScheduledExecutorService heartbeatExecutor = Executors.newScheduledThreadPool(1);
|
||||||
heartbeatExecutor.scheduleAtFixedRate(() -> {
|
// heartbeatExecutor.scheduleAtFixedRate(() -> {
|
||||||
try {
|
// try {
|
||||||
if (session.isOpen()) {
|
// if (session.isOpen()) {
|
||||||
JSONObject jsonObject = new JSONObject();
|
// JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("msgType", "heartbeat");
|
// jsonObject.put("msgType", "heartbeat");
|
||||||
session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
// session.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
} else {
|
// } else {
|
||||||
session.close();
|
// session.close();
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
vitalSignTimerV2.stopTimerTask(session.getId());
|
// vitalSignTimerV2.stopTimerTask(session.getId());
|
||||||
}
|
// }
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
stopHeartbeat(session);
|
// stopHeartbeat(session);
|
||||||
}
|
// }
|
||||||
}, 0, 10, TimeUnit.SECONDS);
|
// }, 0, 10, TimeUnit.SECONDS);
|
||||||
timerTaskMap.put(session.getId(), heartbeatExecutor);
|
// timerTaskMap.put(session.getId(), heartbeatExecutor);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void stopHeartbeat(WebSocketSession session) {
|
// private void stopHeartbeat(WebSocketSession session) {
|
||||||
ScheduledExecutorService heartbeatExecutor = timerTaskMap.get(session.getId());
|
// ScheduledExecutorService heartbeatExecutor = timerTaskMap.get(session.getId());
|
||||||
heartbeatExecutor.shutdownNow();
|
// heartbeatExecutor.shutdownNow();
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,55 +1,55 @@
|
||||||
package com.rax.vital.v2.interceptor;
|
//package com.rax.vital.v2.interceptor;
|
||||||
|
//
|
||||||
import lombok.extern.slf4j.Slf4j;
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.messaging.Message;
|
//import org.springframework.messaging.Message;
|
||||||
import org.springframework.messaging.MessageChannel;
|
//import org.springframework.messaging.MessageChannel;
|
||||||
import org.springframework.messaging.simp.stomp.StompCommand;
|
//import org.springframework.messaging.simp.stomp.StompCommand;
|
||||||
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
|
//import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
|
||||||
import org.springframework.messaging.support.ChannelInterceptor;
|
//import org.springframework.messaging.support.ChannelInterceptor;
|
||||||
import org.springframework.messaging.support.MessageHeaderAccessor;
|
//import org.springframework.messaging.support.MessageHeaderAccessor;
|
||||||
import org.springframework.security.access.AccessDeniedException;
|
//import org.springframework.security.access.AccessDeniedException;
|
||||||
import org.springframework.security.oauth2.server.authorization.OAuth2Authorization;
|
//import org.springframework.security.oauth2.server.authorization.OAuth2Authorization;
|
||||||
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
|
//import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
|
||||||
import org.springframework.security.oauth2.server.authorization.OAuth2TokenType;
|
//import org.springframework.security.oauth2.server.authorization.OAuth2TokenType;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
|
//
|
||||||
@Slf4j
|
//@Slf4j
|
||||||
@Component
|
//@Component
|
||||||
public class WSChannelInterceptor implements ChannelInterceptor {
|
//public class WSChannelInterceptor implements ChannelInterceptor {
|
||||||
@Autowired
|
// @Autowired
|
||||||
private OAuth2AuthorizationService authorizationService;
|
// private OAuth2AuthorizationService authorizationService;
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Message<?> preSend(Message<?> message, MessageChannel channel) {
|
// public Message<?> preSend(Message<?> message, MessageChannel channel) {
|
||||||
|
//
|
||||||
StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
|
// StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
|
||||||
|
//
|
||||||
if (accessor != null) {
|
// if (accessor != null) {
|
||||||
|
//
|
||||||
List<String> accessToken = accessor.getNativeHeader("token");
|
// List<String> accessToken = accessor.getNativeHeader("token");
|
||||||
|
//
|
||||||
if (accessToken != null && !accessToken.isEmpty()) {
|
// if (accessToken != null && !accessToken.isEmpty()) {
|
||||||
|
//
|
||||||
String token = accessToken.get(0);
|
// String token = accessToken.get(0);
|
||||||
OAuth2Authorization authorization = authorizationService.findByToken(token, OAuth2TokenType.ACCESS_TOKEN);
|
// OAuth2Authorization authorization = authorizationService.findByToken(token, OAuth2TokenType.ACCESS_TOKEN);
|
||||||
|
//
|
||||||
if (StompCommand.CONNECT.equals(accessor.getCommand()) || StompCommand.SEND.equals(accessor.getCommand())) {
|
// if (StompCommand.CONNECT.equals(accessor.getCommand()) || StompCommand.SEND.equals(accessor.getCommand())) {
|
||||||
if (authorization == null) {
|
// if (authorization == null) {
|
||||||
throw new AccessDeniedException("Access is denied");
|
// throw new AccessDeniedException("Access is denied");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (StompCommand.DISCONNECT.equals(accessor.getCommand())
|
// if (StompCommand.DISCONNECT.equals(accessor.getCommand())
|
||||||
|| StompCommand.UNSUBSCRIBE.equals(accessor.getCommand()) || StompCommand.ABORT.equals(accessor.getCommand())) {
|
// || StompCommand.UNSUBSCRIBE.equals(accessor.getCommand()) || StompCommand.ABORT.equals(accessor.getCommand())) {
|
||||||
// String simpSessionId = (String) accessor.getHeader("simpSessionId");
|
//// String simpSessionId = (String) accessor.getHeader("simpSessionId");
|
||||||
// vitalSignTimer.stopTimerTaskMongo(simpSessionId);
|
//// vitalSignTimer.stopTimerTaskMongo(simpSessionId);
|
||||||
// chatService.stopTimerTask(simpSessionId);
|
//// chatService.stopTimerTask(simpSessionId);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return message;
|
// return message;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,69 +1,69 @@
|
||||||
package com.rax.vital.v2.interceptor;
|
//package com.rax.vital.v2.interceptor;
|
||||||
|
//
|
||||||
import com.rax.admin.api.entity.SysLog;
|
//import com.rax.admin.api.entity.SysLog;
|
||||||
import com.rax.admin.service.SysLogService;
|
//import com.rax.admin.service.SysLogService;
|
||||||
import com.rax.vital.common.util.GetHttpParamUtil;
|
//import com.rax.vital.common.util.GetHttpParamUtil;
|
||||||
import com.rax.vital.common.util.SysLoggerBuilder;
|
//import com.rax.vital.common.util.SysLoggerBuilder;
|
||||||
import jakarta.annotation.Resource;
|
//import jakarta.annotation.Resource;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.server.ServerHttpRequest;
|
//import org.springframework.http.server.ServerHttpRequest;
|
||||||
import org.springframework.http.server.ServerHttpResponse;
|
//import org.springframework.http.server.ServerHttpResponse;
|
||||||
import org.springframework.security.oauth2.server.authorization.OAuth2Authorization;
|
//import org.springframework.security.oauth2.server.authorization.OAuth2Authorization;
|
||||||
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
|
//import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
|
||||||
import org.springframework.security.oauth2.server.authorization.OAuth2TokenType;
|
//import org.springframework.security.oauth2.server.authorization.OAuth2TokenType;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.socket.WebSocketHandler;
|
//import org.springframework.web.socket.WebSocketHandler;
|
||||||
import org.springframework.web.socket.server.HandshakeInterceptor;
|
//import org.springframework.web.socket.server.HandshakeInterceptor;
|
||||||
|
//
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
|
//
|
||||||
|
//
|
||||||
@Component
|
//@Component
|
||||||
public class WebSocketInterceptors implements HandshakeInterceptor {
|
//public class WebSocketInterceptors implements HandshakeInterceptor {
|
||||||
|
//
|
||||||
@Resource
|
// @Resource
|
||||||
private OAuth2AuthorizationService authorizationService;
|
// private OAuth2AuthorizationService authorizationService;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private SysLoggerBuilder sysLoggerBuilder;
|
// private SysLoggerBuilder sysLoggerBuilder;
|
||||||
|
//
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private SysLogService sysLogService;
|
// private SysLogService sysLogService;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 在这里做一个全局的日志插入根据路径匹配不同的操作title
|
// * 在这里做一个全局的日志插入根据路径匹配不同的操作title
|
||||||
*
|
// *
|
||||||
* @param request
|
// * @param request
|
||||||
* @param response
|
// * @param response
|
||||||
* @param wsHandler
|
// * @param wsHandler
|
||||||
* @param attributes
|
// * @param attributes
|
||||||
* @return
|
// * @return
|
||||||
* @throws Exception
|
// * @throws Exception
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {
|
// public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {
|
||||||
String query = request.getURI().getQuery();
|
// String query = request.getURI().getQuery();
|
||||||
if (query == null) {
|
// if (query == null) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
Map<String, String> params = GetHttpParamUtil.getParams(query);
|
// Map<String, String> params = GetHttpParamUtil.getParams(query);
|
||||||
if (!params.containsKey("token")) {
|
// if (!params.containsKey("token")) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
String token = GetHttpParamUtil.getParam(query, "token");
|
// String token = GetHttpParamUtil.getParam(query, "token");
|
||||||
OAuth2Authorization authorization = authorizationService.findByToken(token, OAuth2TokenType.ACCESS_TOKEN);
|
// OAuth2Authorization authorization = authorizationService.findByToken(token, OAuth2TokenType.ACCESS_TOKEN);
|
||||||
if (authorization == null) {
|
// if (authorization == null) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
// 适配一下,根据req中不同的路径做不同的操作title
|
// // 适配一下,根据req中不同的路径做不同的操作title
|
||||||
SysLog sysLog = sysLoggerBuilder.buildLongWithLogType(request);
|
// SysLog sysLog = sysLoggerBuilder.buildLongWithLogType(request);
|
||||||
sysLogService.saveLog(sysLog);
|
// sysLogService.saveLog(sysLog);
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception exception) {
|
// public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception exception) {
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,94 +1,94 @@
|
||||||
package com.rax.vital.v2.medicine.controller;
|
//package com.rax.vital.v2.medicine.controller;
|
||||||
|
//
|
||||||
import com.rax.common.core.util.R;
|
//import com.rax.common.core.util.R;
|
||||||
import com.rax.vital.common.util.DatabaseNameUtil;
|
//import com.rax.vital.common.util.DatabaseNameUtil;
|
||||||
import com.rax.vital.v2.medicine.service.IMedicineService;
|
//import com.rax.vital.v2.medicine.service.IMedicineService;
|
||||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
//import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
//import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpHeaders;
|
//import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
//import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
//import org.springframework.web.bind.annotation.RestController;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 用药
|
// * 用药
|
||||||
*
|
// *
|
||||||
* @date 2024.2.19
|
// * @date 2024.2.19
|
||||||
*/
|
// */
|
||||||
@RestController
|
//@RestController
|
||||||
@Tag(description = "medicine", name = "人工和AI用药管理")
|
//@Tag(description = "medicine", name = "人工和AI用药管理")
|
||||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
//@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||||
@RequestMapping("/medicine")
|
//@RequestMapping("/medicine")
|
||||||
public class MedicineController {
|
//public class MedicineController {
|
||||||
|
//
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private IMedicineService medicineService;
|
// private IMedicineService medicineService;
|
||||||
|
//
|
||||||
|
//
|
||||||
@PostMapping("/getPatientInfo")
|
// @PostMapping("/getPatientInfo")
|
||||||
public R getPatientInfo(String patientName, String idNum, String date) {
|
// public R getPatientInfo(String patientName, String idNum, String date) {
|
||||||
// todo : 存疑
|
// // todo : 存疑
|
||||||
String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
// String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||||
return medicineService.getPatientInfo(databaseName);
|
// return medicineService.getPatientInfo(databaseName);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
@PostMapping("/getPatientPage")
|
// @PostMapping("/getPatientPage")
|
||||||
public R getPatientPage(String name, String dept, long offset, int limit) {
|
// public R getPatientPage(String name, String dept, long offset, int limit) {
|
||||||
return R.ok(medicineService.getPatientPage(name, dept, offset, limit));
|
// return R.ok(medicineService.getPatientPage(name, dept, offset, limit));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 某月手术每天台数
|
// * 某月手术每天台数
|
||||||
*/
|
// */
|
||||||
@PostMapping("/getSurgeryCount")
|
// @PostMapping("/getSurgeryCount")
|
||||||
public R getSurgeryCount(String start, String end) {
|
// public R getSurgeryCount(String start, String end) {
|
||||||
return R.ok(medicineService.getSurgeryCount(start, end));
|
// return R.ok(medicineService.getSurgeryCount(start, end));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 某月手术每天时长
|
// * 某月手术每天时长
|
||||||
*/
|
// */
|
||||||
@PostMapping("/getSurgeryDuration")
|
// @PostMapping("/getSurgeryDuration")
|
||||||
public R getSurgeryDuration(String start, String end) {
|
// public R getSurgeryDuration(String start, String end) {
|
||||||
return R.ok(medicineService.getSurgeryDuration(start, end));
|
// return R.ok(medicineService.getSurgeryDuration(start, end));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 某月手术类型数量
|
// * 某月手术类型数量
|
||||||
*/
|
// */
|
||||||
@PostMapping("/getSurgeryTypeProportion")
|
// @PostMapping("/getSurgeryTypeProportion")
|
||||||
public R getSurgeryTypeProportion(String start, String end) {
|
// public R getSurgeryTypeProportion(String start, String end) {
|
||||||
return R.ok(medicineService.getSurgeryTypeProportion(start, end));
|
// return R.ok(medicineService.getSurgeryTypeProportion(start, end));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 某周的麻醉和人工给药时长
|
// * 某周的麻醉和人工给药时长
|
||||||
*/
|
// */
|
||||||
@PostMapping("/getSurgeryOtherDuration")
|
// @PostMapping("/getSurgeryOtherDuration")
|
||||||
public R getSurgeryOtherDuration(String start, String end) {
|
// public R getSurgeryOtherDuration(String start, String end) {
|
||||||
return R.ok(medicineService.getSurgeryOtherDuration(start, end));
|
// return R.ok(medicineService.getSurgeryOtherDuration(start, end));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 获取用户的手术列表
|
// * 获取用户的手术列表
|
||||||
*/
|
// */
|
||||||
@PostMapping("/getPatientSurgeryList")
|
// @PostMapping("/getPatientSurgeryList")
|
||||||
public R getPatientSurgeryList(String name, String code, String surgery, String type) {
|
// public R getPatientSurgeryList(String name, String code, String surgery, String type) {
|
||||||
return R.ok(medicineService.getPatientSurgeryList(name, code, surgery, type));
|
// return R.ok(medicineService.getPatientSurgeryList(name, code, surgery, type));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 根据手术表名来获取所有数据
|
// * 根据手术表名来获取所有数据
|
||||||
*/
|
// */
|
||||||
@PostMapping("/getSurgeryTableData")
|
// @PostMapping("/getSurgeryTableData")
|
||||||
public R getSurgeryTableData(String name, String code, String date, String table) {
|
// public R getSurgeryTableData(String name, String code, String date, String table) {
|
||||||
return R.ok(medicineService.getSurgeryTableData(name, code, date, table));
|
// return R.ok(medicineService.getSurgeryTableData(name, code, date, table));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package com.rax.vital.v2.medicine.dto;
|
//package com.rax.vital.v2.medicine.dto;
|
||||||
|
//
|
||||||
|
//
|
||||||
import lombok.AllArgsConstructor;
|
//import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
//import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
//import lombok.NoArgsConstructor;
|
||||||
|
//
|
||||||
@Data
|
//@Data
|
||||||
@NoArgsConstructor
|
//@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
//@AllArgsConstructor
|
||||||
public class MedicineDTO {
|
//public class MedicineDTO {
|
||||||
private String linkNum;
|
// private String linkNum;
|
||||||
private String medicineName;
|
// private String medicineName;
|
||||||
private String medicineRate;
|
// private String medicineRate;
|
||||||
private String countMedicine;
|
// private String countMedicine;
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,207 +1,207 @@
|
||||||
package com.rax.vital.v2.medicine.service.impl;
|
//package com.rax.vital.v2.medicine.service.impl;
|
||||||
|
//
|
||||||
import com.mongodb.BasicDBObject;
|
//import com.mongodb.BasicDBObject;
|
||||||
import com.rax.vital.v2.medicine.service.AIMedicineService;
|
//import com.rax.vital.v2.medicine.service.AIMedicineService;
|
||||||
import lombok.AllArgsConstructor;
|
//import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.domain.Sort;
|
//import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
//import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
//import org.springframework.data.mongodb.core.query.Query;
|
||||||
import org.springframework.stereotype.Service;
|
//import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
//import org.springframework.util.StringUtils;
|
||||||
|
//
|
||||||
import java.sql.Connection;
|
//import java.sql.Connection;
|
||||||
import java.sql.ResultSet;
|
//import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
//import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
//import java.sql.Statement;
|
||||||
import java.time.LocalDateTime;
|
//import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
//import java.util.HashMap;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* AI给药
|
// * AI给药
|
||||||
*/
|
// */
|
||||||
@Slf4j
|
//@Slf4j
|
||||||
@Service
|
//@Service
|
||||||
@AllArgsConstructor
|
//@AllArgsConstructor
|
||||||
public class AIMedicineServiceImpl implements AIMedicineService {
|
//public class AIMedicineServiceImpl implements AIMedicineService {
|
||||||
|
//
|
||||||
private static final Map<String, String> doctorMedicineKeyMap = new HashMap() {
|
// private static final Map<String, String> doctorMedicineKeyMap = new HashMap() {
|
||||||
{
|
// {
|
||||||
put("丙泊酚", "丙泊酚");
|
// put("丙泊酚", "丙泊酚");
|
||||||
put("舒芬太尼", "舒芬太尼");
|
// put("舒芬太尼", "舒芬太尼");
|
||||||
put("瑞芬太尼", "瑞芬太尼");
|
// put("瑞芬太尼", "瑞芬太尼");
|
||||||
put("顺阿曲库胺", "顺阿曲库胺");
|
// put("顺阿曲库胺", "顺阿曲库胺");
|
||||||
put("尼卡地平", "尼卡地平");
|
// put("尼卡地平", "尼卡地平");
|
||||||
put("艾司洛尔", "艾司洛尔");
|
// put("艾司洛尔", "艾司洛尔");
|
||||||
put("麻黄素", "麻黄素");
|
// put("麻黄素", "麻黄素");
|
||||||
put("阿托品", "阿托品");
|
// put("阿托品", "阿托品");
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public List<Map> getAIMedicine(MongoTemplate template) {
|
// public List<Map> getAIMedicine(MongoTemplate template) {
|
||||||
Query query = new Query();
|
// Query query = new Query();
|
||||||
query.limit(1);
|
// query.limit(1);
|
||||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
// query.with(Sort.by(Sort.Order.desc("Time")));
|
||||||
List<Map> aiMedicines = template.find(query, Map.class, "fktable");
|
// List<Map> aiMedicines = template.find(query, Map.class, "fktable");
|
||||||
if (!aiMedicines.isEmpty()) {
|
// if (!aiMedicines.isEmpty()) {
|
||||||
Map medicine = new HashMap();
|
// Map medicine = new HashMap();
|
||||||
for (Map map : aiMedicines) {
|
// for (Map map : aiMedicines) {
|
||||||
medicine.put("丙泊酚", map.get("rate_1"));
|
// medicine.put("丙泊酚", map.get("rate_1"));
|
||||||
medicine.put("丙泊酚sum", map.get("cumu_1"));
|
// medicine.put("丙泊酚sum", map.get("cumu_1"));
|
||||||
medicine.put("舒芬太尼", map.get("rate_2"));
|
// medicine.put("舒芬太尼", map.get("rate_2"));
|
||||||
medicine.put("舒芬太尼sum", map.get("cumu_2"));
|
// medicine.put("舒芬太尼sum", map.get("cumu_2"));
|
||||||
medicine.put("瑞芬太尼", map.get("rate_3"));
|
// medicine.put("瑞芬太尼", map.get("rate_3"));
|
||||||
medicine.put("瑞芬太尼sum", map.get("cumu_3"));
|
// medicine.put("瑞芬太尼sum", map.get("cumu_3"));
|
||||||
medicine.put("顺阿曲库胺", map.get("rate_4"));
|
// medicine.put("顺阿曲库胺", map.get("rate_4"));
|
||||||
medicine.put("顺阿曲库胺sum", map.get("cumu_4"));
|
// medicine.put("顺阿曲库胺sum", map.get("cumu_4"));
|
||||||
medicine.put("尼卡地平", map.get("rate_5"));
|
// medicine.put("尼卡地平", map.get("rate_5"));
|
||||||
medicine.put("尼卡地平sum", map.get("cumu_5"));
|
// medicine.put("尼卡地平sum", map.get("cumu_5"));
|
||||||
medicine.put("艾司洛尔", map.get("rate_6"));
|
// medicine.put("艾司洛尔", map.get("rate_6"));
|
||||||
medicine.put("艾司洛尔sum", map.get("cumu_6"));
|
// medicine.put("艾司洛尔sum", map.get("cumu_6"));
|
||||||
medicine.put("麻黄素", map.get("rate_7"));
|
// medicine.put("麻黄素", map.get("rate_7"));
|
||||||
medicine.put("麻黄素sum", map.get("cumu_7"));
|
// medicine.put("麻黄素sum", map.get("cumu_7"));
|
||||||
medicine.put("阿托品", map.get("rate_8"));
|
// medicine.put("阿托品", map.get("rate_8"));
|
||||||
medicine.put("阿托品sum", map.get("cumu_8"));
|
// medicine.put("阿托品sum", map.get("cumu_8"));
|
||||||
medicine.put("Time", map.get("Time"));
|
// medicine.put("Time", map.get("Time"));
|
||||||
}
|
// }
|
||||||
aiMedicines.remove(0);
|
// aiMedicines.remove(0);
|
||||||
aiMedicines.add(medicine);
|
// aiMedicines.add(medicine);
|
||||||
}
|
// }
|
||||||
return aiMedicines;
|
// return aiMedicines;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public List<Map> getAIMedicine(Connection connection) {
|
// public List<Map> getAIMedicine(Connection connection) {
|
||||||
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"));
|
||||||
medicine.put("phase", resultSet.getString("phase"));
|
// medicine.put("phase", resultSet.getString("phase"));
|
||||||
medicine.put("丙泊酚", resultSet.getString("丙泊酚"));
|
// medicine.put("丙泊酚", resultSet.getString("丙泊酚"));
|
||||||
medicine.put("舒芬太尼", resultSet.getString("舒芬太尼"));
|
// medicine.put("舒芬太尼", resultSet.getString("舒芬太尼"));
|
||||||
medicine.put("瑞芬太尼", resultSet.getString("瑞芬太尼"));
|
// medicine.put("瑞芬太尼", resultSet.getString("瑞芬太尼"));
|
||||||
medicine.put("顺阿曲库胺", resultSet.getString("顺阿曲库胺"));
|
// medicine.put("顺阿曲库胺", resultSet.getString("顺阿曲库胺"));
|
||||||
medicine.put("尼卡地平", resultSet.getString("尼卡地平"));
|
// medicine.put("尼卡地平", resultSet.getString("尼卡地平"));
|
||||||
medicine.put("艾司洛尔", resultSet.getString("艾司洛尔"));
|
// medicine.put("艾司洛尔", resultSet.getString("艾司洛尔"));
|
||||||
medicine.put("麻黄素", resultSet.getString("麻黄素"));
|
// medicine.put("麻黄素", resultSet.getString("麻黄素"));
|
||||||
medicine.put("阿托品", resultSet.getString("阿托品"));
|
// medicine.put("阿托品", resultSet.getString("阿托品"));
|
||||||
medicine.put("Time", resultSet.getString("time"));
|
// medicine.put("Time", resultSet.getString("time"));
|
||||||
}
|
// }
|
||||||
String sql = "SELECT sum(`丙泊酚`) \"丙泊酚sum\", sum(`舒芬太尼`) \"舒芬太尼sum\", " +
|
// String sql = "SELECT sum(`丙泊酚`) \"丙泊酚sum\", sum(`舒芬太尼`) \"舒芬太尼sum\", " +
|
||||||
"sum(`瑞芬太尼`) \"瑞芬太尼sum\", sum(`顺阿曲库胺`) \"顺阿曲库胺sum\", " +
|
// "sum(`瑞芬太尼`) \"瑞芬太尼sum\", sum(`顺阿曲库胺`) \"顺阿曲库胺sum\", " +
|
||||||
"sum(`尼卡地平`) \"尼卡地平sum\", sum(`艾司洛尔`) \"艾司洛尔sum\", " +
|
// "sum(`尼卡地平`) \"尼卡地平sum\", sum(`艾司洛尔`) \"艾司洛尔sum\", " +
|
||||||
"sum(`麻黄素`) \"麻黄素sum\", sum(`阿托品`) \"阿托品sum\" FROM `aimedicinetable`";
|
// "sum(`麻黄素`) \"麻黄素sum\", sum(`阿托品`) \"阿托品sum\" FROM `aimedicinetable`";
|
||||||
ResultSet sumSet = statement.executeQuery(sql);
|
// ResultSet sumSet = statement.executeQuery(sql);
|
||||||
while (sumSet.next()) {
|
// while (sumSet.next()) {
|
||||||
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"));
|
||||||
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"));
|
||||||
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 " +
|
// 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 " +
|
// "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 " +
|
// " FROM fktable " +
|
||||||
" ORDER BY time DESC LIMIT 1; ";
|
// " ORDER BY time DESC LIMIT 1; ";
|
||||||
ResultSet resultSet = statement.executeQuery(sql);
|
// ResultSet resultSet = statement.executeQuery(sql);
|
||||||
Map medicine = new HashMap();
|
// Map medicine = new HashMap();
|
||||||
while (resultSet.next()) {
|
// while (resultSet.next()) {
|
||||||
medicine.put("丙泊酚", resultSet.getString("rate_1"));
|
// medicine.put("丙泊酚", resultSet.getString("rate_1"));
|
||||||
medicine.put("丙泊酚sum", resultSet.getString("cumu_1"));
|
// medicine.put("丙泊酚sum", resultSet.getString("cumu_1"));
|
||||||
medicine.put("舒芬太尼", resultSet.getString("rate_2"));
|
// medicine.put("舒芬太尼", resultSet.getString("rate_2"));
|
||||||
medicine.put("舒芬太尼sum", resultSet.getString("cumu_2"));
|
// medicine.put("舒芬太尼sum", resultSet.getString("cumu_2"));
|
||||||
medicine.put("瑞芬太尼", resultSet.getString("rate_3"));
|
// medicine.put("瑞芬太尼", resultSet.getString("rate_3"));
|
||||||
medicine.put("瑞芬太尼sum", resultSet.getString("cumu_3"));
|
// medicine.put("瑞芬太尼sum", resultSet.getString("cumu_3"));
|
||||||
medicine.put("顺阿曲库胺", resultSet.getString("rate_4"));
|
// medicine.put("顺阿曲库胺", resultSet.getString("rate_4"));
|
||||||
medicine.put("顺阿曲库胺sum", resultSet.getString("cumu_4"));
|
// medicine.put("顺阿曲库胺sum", resultSet.getString("cumu_4"));
|
||||||
medicine.put("尼卡地平", resultSet.getString("rate_5"));
|
// medicine.put("尼卡地平", resultSet.getString("rate_5"));
|
||||||
medicine.put("尼卡地平sum", resultSet.getString("cumu_5"));
|
// medicine.put("尼卡地平sum", resultSet.getString("cumu_5"));
|
||||||
medicine.put("艾司洛尔", resultSet.getString("rate_6"));
|
// medicine.put("艾司洛尔", resultSet.getString("rate_6"));
|
||||||
medicine.put("艾司洛尔sum", resultSet.getString("cumu_6"));
|
// medicine.put("艾司洛尔sum", resultSet.getString("cumu_6"));
|
||||||
medicine.put("麻黄素", resultSet.getString("rate_7"));
|
// medicine.put("麻黄素", resultSet.getString("rate_7"));
|
||||||
medicine.put("麻黄素sum", resultSet.getString("cumu_7"));
|
// medicine.put("麻黄素sum", resultSet.getString("cumu_7"));
|
||||||
medicine.put("阿托品", resultSet.getString("rate_8"));
|
// medicine.put("阿托品", resultSet.getString("rate_8"));
|
||||||
medicine.put("阿托品sum", resultSet.getString("cumu_8"));
|
// medicine.put("阿托品sum", resultSet.getString("cumu_8"));
|
||||||
medicine.put("Time", resultSet.getString("time"));
|
// 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);
|
||||||
}
|
// }
|
||||||
return medicineList;
|
// return medicineList;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void changeAIFlagMedicine(MongoTemplate template, String flag, String medicine, String value) {
|
// public void changeAIFlagMedicine(MongoTemplate template, String flag, String medicine, String value) {
|
||||||
BasicDBObject obj = new BasicDBObject();
|
// BasicDBObject obj = new BasicDBObject();
|
||||||
obj.put("Flag", flag);
|
// obj.put("Flag", flag);
|
||||||
obj.put("Time", LocalDateTime.now());
|
// obj.put("Time", LocalDateTime.now());
|
||||||
obj.put("ConvertFlag", "2".equals(flag) ? 1 : 0);
|
// obj.put("ConvertFlag", "2".equals(flag) ? 1 : 0);
|
||||||
template.insert(obj, "aiflagtable");
|
// template.insert(obj, "aiflagtable");
|
||||||
|
//
|
||||||
if (StringUtils.hasText(value) && StringUtils.hasText(medicine)) {
|
// if (StringUtils.hasText(value) && StringUtils.hasText(medicine)) {
|
||||||
BasicDBObject medicineObj = new BasicDBObject();
|
// BasicDBObject medicineObj = new BasicDBObject();
|
||||||
for (String key : doctorMedicineKeyMap.keySet()) {
|
// for (String key : doctorMedicineKeyMap.keySet()) {
|
||||||
if (key.equals(medicine)) {
|
// if (key.equals(medicine)) {
|
||||||
medicineObj.put(medicine, value);
|
// medicineObj.put(medicine, value);
|
||||||
} else {
|
// } else {
|
||||||
medicineObj.put(key, 0);
|
// medicineObj.put(key, 0);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
medicineObj.put("phase", "");
|
// medicineObj.put("phase", "");
|
||||||
medicineObj.put("Time", LocalDateTime.now());
|
// medicineObj.put("Time", LocalDateTime.now());
|
||||||
template.insert(medicineObj, "doctormedicinetable");
|
// template.insert(medicineObj, "doctormedicinetable");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Map getCountMedicine(MongoTemplate template) {
|
// public Map getCountMedicine(MongoTemplate template) {
|
||||||
Query query = new Query();
|
// Query query = new Query();
|
||||||
query.limit(1);
|
// query.limit(1);
|
||||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
// query.with(Sort.by(Sort.Order.desc("Time")));
|
||||||
List<Map> aiMedicines = template.find(query, Map.class, "fktable");
|
// List<Map> aiMedicines = template.find(query, Map.class, "fktable");
|
||||||
if (!aiMedicines.isEmpty()) {
|
// if (!aiMedicines.isEmpty()) {
|
||||||
Map medicine = new HashMap();
|
// Map medicine = new HashMap();
|
||||||
for (Map map : aiMedicines) {
|
// for (Map map : aiMedicines) {
|
||||||
medicine.put("丙泊酚sum", map.get("cumu_1"));
|
// medicine.put("丙泊酚sum", map.get("cumu_1"));
|
||||||
medicine.put("舒芬太尼sum", map.get("cumu_2"));
|
// medicine.put("舒芬太尼sum", map.get("cumu_2"));
|
||||||
medicine.put("瑞芬太尼sum", map.get("cumu_3"));
|
// medicine.put("瑞芬太尼sum", map.get("cumu_3"));
|
||||||
medicine.put("顺阿曲库胺sum", map.get("cumu_4"));
|
// medicine.put("顺阿曲库胺sum", map.get("cumu_4"));
|
||||||
medicine.put("尼卡地平sum", map.get("cumu_5"));
|
// medicine.put("尼卡地平sum", map.get("cumu_5"));
|
||||||
medicine.put("艾司洛尔sum", map.get("cumu_6"));
|
// medicine.put("艾司洛尔sum", map.get("cumu_6"));
|
||||||
medicine.put("麻黄素sum", map.get("cumu_7"));
|
// medicine.put("麻黄素sum", map.get("cumu_7"));
|
||||||
medicine.put("阿托品sum", map.get("cumu_8"));
|
// medicine.put("阿托品sum", map.get("cumu_8"));
|
||||||
medicine.put("Time", map.get("Time"));
|
// medicine.put("Time", map.get("Time"));
|
||||||
}
|
// }
|
||||||
aiMedicines.remove(0);
|
// aiMedicines.remove(0);
|
||||||
aiMedicines.add(medicine);
|
// aiMedicines.add(medicine);
|
||||||
return aiMedicines.get(0);
|
// return aiMedicines.get(0);
|
||||||
}else {
|
// }else {
|
||||||
return Map.of();
|
// return Map.of();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Map getAiMedicine(MongoTemplate template) {
|
// public Map getAiMedicine(MongoTemplate template) {
|
||||||
Query query = new Query();
|
// Query query = new Query();
|
||||||
query.limit(1);
|
// query.limit(1);
|
||||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
// query.with(Sort.by(Sort.Order.desc("Time")));
|
||||||
List<Map> aimedicinetable = template.find(query, Map.class, "aimedicinetable");
|
// List<Map> aimedicinetable = template.find(query, Map.class, "aimedicinetable");
|
||||||
if (aimedicinetable.isEmpty()) {
|
// if (aimedicinetable.isEmpty()) {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
return aimedicinetable.get(0);
|
// return aimedicinetable.get(0);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,141 +1,141 @@
|
||||||
package com.rax.vital.v2.medicine.service.impl;
|
//package com.rax.vital.v2.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.baomidou.mybatisplus.core.toolkit.Wrappers;
|
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.rax.admin.api.entity.SysUser;
|
//import com.rax.admin.api.entity.SysUser;
|
||||||
import com.rax.admin.service.SysUserService;
|
//import com.rax.admin.service.SysUserService;
|
||||||
import com.rax.vital.common.datasource.CustomDataSource;
|
//import com.rax.vital.common.datasource.CustomDataSource;
|
||||||
import com.rax.vital.common.datasource.MongoDBSource;
|
//import com.rax.vital.common.datasource.MongoDBSource;
|
||||||
import com.rax.vital.v2.medicine.service.ChatService;
|
//import com.rax.vital.v2.medicine.service.ChatService;
|
||||||
import org.bson.Document;
|
//import org.bson.Document;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
//import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
//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.stereotype.Service;
|
//import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
//import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.socket.TextMessage;
|
//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.util.HashMap;
|
//import java.util.HashMap;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
//import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
//
|
||||||
@RefreshScope
|
//@RefreshScope
|
||||||
@Service
|
//@Service
|
||||||
public class ChatServiceImpl implements ChatService {
|
//public class ChatServiceImpl implements ChatService {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private SysUserService SysUserService;
|
// private SysUserService SysUserService;
|
||||||
|
//
|
||||||
private static final Map<String, CustomDataSource> datasourceMap = new ConcurrentHashMap<>();
|
// private static final Map<String, CustomDataSource> datasourceMap = new ConcurrentHashMap<>();
|
||||||
|
//
|
||||||
// key: databaseName, value: Map<simpSessionId, WebSocketSession>
|
// // key: databaseName, value: Map<simpSessionId, WebSocketSession>
|
||||||
private static final Map<String, Map<String, WebSocketSession>> databaseSessionMap = new ConcurrentHashMap<>();
|
// private static final Map<String, Map<String, WebSocketSession>> databaseSessionMap = new ConcurrentHashMap<>();
|
||||||
|
//
|
||||||
private static final Map<String, String> sessionDatabaseMap = new ConcurrentHashMap<>();
|
// private static final Map<String, String> sessionDatabaseMap = new ConcurrentHashMap<>();
|
||||||
|
//
|
||||||
// MongoDB的地址
|
// // MongoDB的地址
|
||||||
@Value("${vital-sign.mongodb.host}")
|
// @Value("${vital-sign.mongodb.host}")
|
||||||
private String mongoDBHost;
|
// private String mongoDBHost;
|
||||||
|
//
|
||||||
// MongoDB的用户名
|
// // MongoDB的用户名
|
||||||
@Value("${vital-sign.mongodb.username}")
|
// @Value("${vital-sign.mongodb.username}")
|
||||||
private String mongoUsername;
|
// private String mongoUsername;
|
||||||
|
//
|
||||||
// MongoDB的用户的密码
|
// // MongoDB的用户的密码
|
||||||
@Value("${vital-sign.mongodb.password}")
|
// @Value("${vital-sign.mongodb.password}")
|
||||||
private String mongoPassword;
|
// private String mongoPassword;
|
||||||
|
//
|
||||||
// mysql地址
|
// // mysql地址
|
||||||
@Value("${vital-sign.mysql.host}")
|
// @Value("${vital-sign.mysql.host}")
|
||||||
private String mysqlHost;
|
// private String mysqlHost;
|
||||||
|
//
|
||||||
// mysql用户名
|
// // mysql用户名
|
||||||
@Value("${vital-sign.mysql.username}")
|
// @Value("${vital-sign.mysql.username}")
|
||||||
private String mysqlUsername;
|
// private String mysqlUsername;
|
||||||
|
//
|
||||||
// mysql用户密码
|
// // mysql用户密码
|
||||||
@Value("${vital-sign.mysql.password}")
|
// @Value("${vital-sign.mysql.password}")
|
||||||
private String mysqlPassword;
|
// private String mysqlPassword;
|
||||||
|
//
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void sendMessage(String databaseName, String username, WebSocketSession session, String msg) throws IOException {
|
// public void sendMessage(String databaseName, String username, WebSocketSession session, String msg) throws IOException {
|
||||||
CustomDataSource mongoDBSource = datasourceMap.get(session.getId());
|
// CustomDataSource mongoDBSource = datasourceMap.get(session.getId());
|
||||||
if (mongoDBSource == null) {
|
// if (mongoDBSource == null) {
|
||||||
mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, databaseName);
|
// mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, databaseName);
|
||||||
mongoDBSource.open();
|
// mongoDBSource.open();
|
||||||
datasourceMap.put(session.getId(), mongoDBSource);
|
// datasourceMap.put(session.getId(), mongoDBSource);
|
||||||
sessionDatabaseMap.put(session.getId(), databaseName);
|
// sessionDatabaseMap.put(session.getId(), databaseName);
|
||||||
Map<String, WebSocketSession> sessionMap = databaseSessionMap.get(databaseName);
|
// Map<String, WebSocketSession> sessionMap = databaseSessionMap.get(databaseName);
|
||||||
if (sessionMap == null) {
|
// if (sessionMap == null) {
|
||||||
sessionMap = new HashMap();
|
// sessionMap = new HashMap();
|
||||||
sessionMap.put(session.getId(), session);
|
// sessionMap.put(session.getId(), session);
|
||||||
databaseSessionMap.put(databaseName, sessionMap);
|
// databaseSessionMap.put(databaseName, sessionMap);
|
||||||
} else {
|
// } else {
|
||||||
if (!sessionMap.containsKey(session.getId())) {
|
// if (!sessionMap.containsKey(session.getId())) {
|
||||||
sessionMap.put(session.getId(), session);
|
// sessionMap.put(session.getId(), session);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
SysUser sysUser = SysUserService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, username));
|
// SysUser sysUser = SysUserService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, username));
|
||||||
|
//
|
||||||
// 将聊天消息保存在mongo中
|
// // 将聊天消息保存在mongo中
|
||||||
if (StringUtils.hasText(msg)) {
|
// if (StringUtils.hasText(msg)) {
|
||||||
JSONObject param = new JSONObject();
|
// JSONObject param = new JSONObject();
|
||||||
MongoTemplate template = mongoDBSource.getConnection();
|
// MongoTemplate template = mongoDBSource.getConnection();
|
||||||
Document document = new Document();
|
// Document document = new Document();
|
||||||
document.put("content", msg);
|
// document.put("content", msg);
|
||||||
param.put("content", msg);
|
// param.put("content", msg);
|
||||||
String now = DateUtil.now();
|
// String now = DateUtil.now();
|
||||||
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 = sysUser.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");
|
// 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()) {
|
||||||
WebSocketSession value = entry.getValue();
|
// WebSocketSession value = entry.getValue();
|
||||||
value.sendMessage(new TextMessage(param.toJSONString().getBytes()));
|
// value.sendMessage(new TextMessage(param.toJSONString().getBytes()));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public synchronized void stopTimerTask(String simpSessionId) {
|
// public synchronized void stopTimerTask(String simpSessionId) {
|
||||||
CustomDataSource mongoDBSource = datasourceMap.get(simpSessionId);
|
// CustomDataSource mongoDBSource = datasourceMap.get(simpSessionId);
|
||||||
if (mongoDBSource != null) {
|
// if (mongoDBSource != null) {
|
||||||
mongoDBSource.close();
|
// mongoDBSource.close();
|
||||||
datasourceMap.remove(simpSessionId);
|
// datasourceMap.remove(simpSessionId);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public synchronized void stopTask(String simpSessionId) {
|
// public synchronized void stopTask(String simpSessionId) {
|
||||||
CustomDataSource mongoDBSource = datasourceMap.get(simpSessionId);
|
// CustomDataSource mongoDBSource = datasourceMap.get(simpSessionId);
|
||||||
if (mongoDBSource != null) {
|
// if (mongoDBSource != null) {
|
||||||
mongoDBSource.close();
|
// mongoDBSource.close();
|
||||||
datasourceMap.remove(simpSessionId);
|
// datasourceMap.remove(simpSessionId);
|
||||||
}
|
// }
|
||||||
String databaseName = sessionDatabaseMap.get(simpSessionId);
|
// String databaseName = sessionDatabaseMap.get(simpSessionId);
|
||||||
if (databaseName != null) {
|
// if (databaseName != null) {
|
||||||
sessionDatabaseMap.remove(simpSessionId);
|
// sessionDatabaseMap.remove(simpSessionId);
|
||||||
Map<String, WebSocketSession> stringWebSocketSessionMap = databaseSessionMap.get(databaseName);
|
// Map<String, WebSocketSession> stringWebSocketSessionMap = databaseSessionMap.get(databaseName);
|
||||||
stringWebSocketSessionMap.remove(simpSessionId);
|
// stringWebSocketSessionMap.remove(simpSessionId);
|
||||||
if (stringWebSocketSessionMap.isEmpty()) {
|
// if (stringWebSocketSessionMap.isEmpty()) {
|
||||||
databaseSessionMap.remove(databaseName);
|
// databaseSessionMap.remove(databaseName);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,83 +1,83 @@
|
||||||
package com.rax.vital.v2.medicine.service.impl;
|
//package com.rax.vital.v2.medicine.service.impl;
|
||||||
|
//
|
||||||
import com.rax.vital.v2.medicine.service.DoctorMedicineService;
|
//import com.rax.vital.v2.medicine.service.DoctorMedicineService;
|
||||||
import lombok.AllArgsConstructor;
|
//import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.domain.Sort;
|
//import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
//import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
//import org.springframework.data.mongodb.core.query.Query;
|
||||||
import org.springframework.stereotype.Service;
|
//import org.springframework.stereotype.Service;
|
||||||
|
//
|
||||||
import java.sql.Connection;
|
//import java.sql.Connection;
|
||||||
import java.sql.ResultSet;
|
//import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
//import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
//import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
//import java.util.HashMap;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 医生给药
|
// * 医生给药
|
||||||
*/
|
// */
|
||||||
@Slf4j
|
//@Slf4j
|
||||||
@Service
|
//@Service
|
||||||
@AllArgsConstructor
|
//@AllArgsConstructor
|
||||||
public class DoctorMedicineServiceImpl implements DoctorMedicineService {
|
//public class DoctorMedicineServiceImpl implements DoctorMedicineService {
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Map getDocMedicine(MongoTemplate template) {
|
// public Map getDocMedicine(MongoTemplate template) {
|
||||||
Query query = new Query();
|
// Query query = new Query();
|
||||||
query.limit(1);
|
// query.limit(1);
|
||||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
// query.with(Sort.by(Sort.Order.desc("Time")));
|
||||||
List<Map> doctorMedicineTable = template.find(query, Map.class, "doctormedicinetable");
|
// List<Map> doctorMedicineTable = template.find(query, Map.class, "doctormedicinetable");
|
||||||
if (doctorMedicineTable.isEmpty()){
|
// if (doctorMedicineTable.isEmpty()){
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
return doctorMedicineTable.get(0);
|
// return doctorMedicineTable.get(0);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public List<Map> getDocMedicine(Connection connection) {
|
// public List<Map> getDocMedicine(Connection connection) {
|
||||||
List<Map> medicineList = new ArrayList<>();
|
// List<Map> medicineList = new ArrayList<>();
|
||||||
try {
|
// try {
|
||||||
Map medicine = new HashMap();
|
// Map medicine = new HashMap();
|
||||||
Statement statement = connection.createStatement();
|
// Statement statement = connection.createStatement();
|
||||||
ResultSet resultSet = statement.executeQuery("SELECT id, phase, `丙泊酚`, `舒芬太尼`, `瑞芬太尼`, `顺阿曲库胺`, `尼卡地平`, `艾司洛尔`, `麻黄素`, `阿托品`, time FROM `doctormedicinetable` ORDER BY time DESC LIMIT 1;");
|
// ResultSet resultSet = statement.executeQuery("SELECT id, phase, `丙泊酚`, `舒芬太尼`, `瑞芬太尼`, `顺阿曲库胺`, `尼卡地平`, `艾司洛尔`, `麻黄素`, `阿托品`, time FROM `doctormedicinetable` ORDER BY time DESC LIMIT 1;");
|
||||||
while (resultSet.next()) {
|
// while (resultSet.next()) {
|
||||||
medicine.put("id", resultSet.getString("id"));
|
// medicine.put("id", resultSet.getString("id"));
|
||||||
medicine.put("phase", resultSet.getString("phase"));
|
// medicine.put("phase", resultSet.getString("phase"));
|
||||||
medicine.put("丙泊酚", resultSet.getString("丙泊酚"));
|
// medicine.put("丙泊酚", resultSet.getString("丙泊酚"));
|
||||||
medicine.put("舒芬太尼", resultSet.getString("舒芬太尼"));
|
// medicine.put("舒芬太尼", resultSet.getString("舒芬太尼"));
|
||||||
medicine.put("瑞芬太尼", resultSet.getString("瑞芬太尼"));
|
// medicine.put("瑞芬太尼", resultSet.getString("瑞芬太尼"));
|
||||||
medicine.put("顺阿曲库胺", resultSet.getString("顺阿曲库胺"));
|
// medicine.put("顺阿曲库胺", resultSet.getString("顺阿曲库胺"));
|
||||||
medicine.put("尼卡地平", resultSet.getString("尼卡地平"));
|
// medicine.put("尼卡地平", resultSet.getString("尼卡地平"));
|
||||||
medicine.put("艾司洛尔", resultSet.getString("艾司洛尔"));
|
// medicine.put("艾司洛尔", resultSet.getString("艾司洛尔"));
|
||||||
medicine.put("麻黄素", resultSet.getString("麻黄素"));
|
// medicine.put("麻黄素", resultSet.getString("麻黄素"));
|
||||||
medicine.put("阿托品", resultSet.getString("阿托品"));
|
// medicine.put("阿托品", resultSet.getString("阿托品"));
|
||||||
medicine.put("Time", resultSet.getString("time"));
|
// medicine.put("Time", resultSet.getString("time"));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
String sql = "SELECT sum(`丙泊酚`) \"丙泊酚sum\", sum(`舒芬太尼`) \"舒芬太尼sum\", " +
|
// String sql = "SELECT sum(`丙泊酚`) \"丙泊酚sum\", sum(`舒芬太尼`) \"舒芬太尼sum\", " +
|
||||||
"sum(`瑞芬太尼`) \"瑞芬太尼sum\", sum(`顺阿曲库胺`) \"顺阿曲库胺sum\", " +
|
// "sum(`瑞芬太尼`) \"瑞芬太尼sum\", sum(`顺阿曲库胺`) \"顺阿曲库胺sum\", " +
|
||||||
"sum(`尼卡地平`) \"尼卡地平sum\", sum(`艾司洛尔`) \"艾司洛尔sum\", " +
|
// "sum(`尼卡地平`) \"尼卡地平sum\", sum(`艾司洛尔`) \"艾司洛尔sum\", " +
|
||||||
"sum(`麻黄素`) \"麻黄素sum\", sum(`阿托品`) \"阿托品sum\" FROM `doctormedicinetable`";
|
// "sum(`麻黄素`) \"麻黄素sum\", sum(`阿托品`) \"阿托品sum\" FROM `doctormedicinetable`";
|
||||||
ResultSet sumSet = statement.executeQuery(sql);
|
// ResultSet sumSet = statement.executeQuery(sql);
|
||||||
while (sumSet.next()) {
|
// while (sumSet.next()) {
|
||||||
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"));
|
||||||
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"));
|
||||||
medicine.put("麻黄素sum", sumSet.getString("麻黄素sum"));
|
// medicine.put("麻黄素sum", sumSet.getString("麻黄素sum"));
|
||||||
medicine.put("阿托品sum", sumSet.getString("阿托品sum"));
|
// medicine.put("阿托品sum", sumSet.getString("阿托品sum"));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
medicineList.add(medicine);
|
// medicineList.add(medicine);
|
||||||
} catch (SQLException e) {
|
// } catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
// throw new RuntimeException(e);
|
||||||
}
|
// }
|
||||||
return medicineList;
|
// return medicineList;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,171 +1,171 @@
|
||||||
package com.rax.vital.v2.medicine.service.impl;
|
//package com.rax.vital.v2.medicine.service.impl;
|
||||||
|
//
|
||||||
import com.rax.vital.v2.medicine.service.FlagService;
|
//import com.rax.vital.v2.medicine.service.FlagService;
|
||||||
import lombok.AllArgsConstructor;
|
//import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.domain.Sort;
|
//import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
//import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
//import org.springframework.data.mongodb.core.query.Query;
|
||||||
import org.springframework.stereotype.Service;
|
//import org.springframework.stereotype.Service;
|
||||||
|
//
|
||||||
import java.sql.Connection;
|
//import java.sql.Connection;
|
||||||
import java.sql.ResultSet;
|
//import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
//import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
//import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
//import java.util.HashMap;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 标志位
|
// * 标志位
|
||||||
*/
|
// */
|
||||||
@Slf4j
|
//@Slf4j
|
||||||
@Service
|
//@Service
|
||||||
@AllArgsConstructor
|
//@AllArgsConstructor
|
||||||
public class FlagServiceImpl implements FlagService {
|
//public class FlagServiceImpl implements FlagService {
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 新标志位接口MongoDB
|
// * 新标志位接口MongoDB
|
||||||
* flag 0:诱导期给药 1:维持期AI给药 2:维持期人工给药
|
// * flag 0:诱导期给药 1:维持期AI给药 2:维持期人工给药
|
||||||
*
|
// *
|
||||||
* @param template
|
// * @param template
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public Map getFlags(MongoTemplate template) {
|
// public Map getFlags(MongoTemplate template) {
|
||||||
Map flagMap = new HashMap();
|
// Map flagMap = new HashMap();
|
||||||
Query query = new Query();
|
// Query query = new Query();
|
||||||
query.limit(1);
|
// query.limit(1);
|
||||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
// query.with(Sort.by(Sort.Order.desc("Time")));
|
||||||
List<Map> linkTable = template.find(query, Map.class, "linktable");
|
// List<Map> linkTable = template.find(query, Map.class, "linktable");
|
||||||
List<Map> aiFlagTable = template.find(query, Map.class, "aiflagtable");
|
// List<Map> aiFlagTable = template.find(query, Map.class, "aiflagtable");
|
||||||
List<Map> endFlagTable = template.find(query, Map.class, "endflagtable");
|
// List<Map> endFlagTable = template.find(query, Map.class, "endflagtable");
|
||||||
|
//
|
||||||
if (!linkTable.isEmpty()){
|
// if (!linkTable.isEmpty()){
|
||||||
flagMap.put("linkFlag", linkTable.get(0).get("Flag"));
|
// flagMap.put("linkFlag", linkTable.get(0).get("Flag"));
|
||||||
}else {
|
// }else {
|
||||||
flagMap.put("linkFlag", "");
|
// flagMap.put("linkFlag", "");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (!aiFlagTable.isEmpty()){
|
// if (!aiFlagTable.isEmpty()){
|
||||||
flagMap.put("aiFlag", aiFlagTable.get(0).get("Flag"));
|
// flagMap.put("aiFlag", aiFlagTable.get(0).get("Flag"));
|
||||||
}else {
|
// }else {
|
||||||
flagMap.put("aiFlag", "");
|
// flagMap.put("aiFlag", "");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (!endFlagTable.isEmpty()){
|
// if (!endFlagTable.isEmpty()){
|
||||||
flagMap.put("endFlag", endFlagTable.get(0).get("Flag"));
|
// flagMap.put("endFlag", endFlagTable.get(0).get("Flag"));
|
||||||
}else {
|
// }else {
|
||||||
flagMap.put("endFlag", "");
|
// flagMap.put("endFlag", "");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return flagMap;
|
// return flagMap;
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 标志位接口MongoDB
|
// * 标志位接口MongoDB
|
||||||
*
|
// *
|
||||||
* @param template
|
// * @param template
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
@Deprecated
|
// @Deprecated
|
||||||
@Override
|
// @Override
|
||||||
public Map getFlag(MongoTemplate template) {
|
// public Map getFlag(MongoTemplate template) {
|
||||||
Map allFlag = new HashMap();
|
// Map allFlag = new HashMap();
|
||||||
Query query1 = new Query();
|
// Query query1 = new Query();
|
||||||
query1.limit(1);
|
// query1.limit(1);
|
||||||
query1.with(Sort.by(Sort.Order.desc("_id")));
|
// query1.with(Sort.by(Sort.Order.desc("_id")));
|
||||||
List<Map> endFlagTable = template.find(query1, Map.class, "EndFlagTable");
|
// List<Map> endFlagTable = template.find(query1, Map.class, "EndFlagTable");
|
||||||
if (!endFlagTable.isEmpty()) {
|
// if (!endFlagTable.isEmpty()) {
|
||||||
allFlag.put("endFlag", endFlagTable.get(1));
|
// allFlag.put("endFlag", endFlagTable.get(1));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Query query2 = new Query();
|
// Query query2 = new Query();
|
||||||
query2.limit(1);
|
// query2.limit(1);
|
||||||
query2.with(Sort.by(Sort.Order.desc("_id")));
|
// query2.with(Sort.by(Sort.Order.desc("_id")));
|
||||||
List<Map> aiFlagTable = template.find(query2, Map.class, "AIFlagTable");
|
// List<Map> aiFlagTable = template.find(query2, Map.class, "AIFlagTable");
|
||||||
if (!aiFlagTable.isEmpty()) {
|
// if (!aiFlagTable.isEmpty()) {
|
||||||
allFlag.put("aiFlag", aiFlagTable);
|
// allFlag.put("aiFlag", aiFlagTable);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Query query3 = new Query();
|
// Query query3 = new Query();
|
||||||
query3.limit(1);
|
// query3.limit(1);
|
||||||
query3.with(Sort.by(Sort.Order.desc("_id")));
|
// query3.with(Sort.by(Sort.Order.desc("_id")));
|
||||||
List<Map> reFlagTable = template.find(query3, Map.class, "ReFlagTable");
|
// List<Map> reFlagTable = template.find(query3, Map.class, "ReFlagTable");
|
||||||
if (!reFlagTable.isEmpty()) {
|
// if (!reFlagTable.isEmpty()) {
|
||||||
allFlag.put("reFlagTable", reFlagTable);
|
// allFlag.put("reFlagTable", reFlagTable);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return allFlag;
|
// return allFlag;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 标志位接口MySQL
|
// * 标志位接口MySQL
|
||||||
*
|
// *
|
||||||
* @param connection
|
// * @param connection
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
@Deprecated
|
// @Deprecated
|
||||||
public Map getFlag(Connection connection) {
|
// public Map getFlag(Connection connection) {
|
||||||
Map allFlag = new HashMap();
|
// Map allFlag = new HashMap();
|
||||||
try {
|
// try {
|
||||||
Statement statement = connection.createStatement();
|
// Statement statement = connection.createStatement();
|
||||||
// 0代表手术未开始或已结束、1代表手术进行中
|
// // 0代表手术未开始或已结束、1代表手术进行中
|
||||||
ResultSet resultSet = statement.executeQuery("SELECT * FROM `endflagtable` ORDER BY time DESC LIMIT 1;");
|
// ResultSet resultSet = statement.executeQuery("SELECT * FROM `endflagtable` ORDER BY time DESC LIMIT 1;");
|
||||||
List<Map> endFlagList = new ArrayList<>();
|
// List<Map> endFlagList = new ArrayList<>();
|
||||||
while (resultSet.next()) {
|
// while (resultSet.next()) {
|
||||||
Map flag = new HashMap();
|
// Map flag = new HashMap();
|
||||||
flag.put("id", resultSet.getString(1));
|
// flag.put("id", resultSet.getString(1));
|
||||||
flag.put("Flag", resultSet.getString(2));
|
// flag.put("Flag", resultSet.getString(2));
|
||||||
flag.put("Time", resultSet.getString(3));
|
// flag.put("Time", resultSet.getString(3));
|
||||||
endFlagList.add(flag);
|
// endFlagList.add(flag);
|
||||||
}
|
// }
|
||||||
allFlag.put("endflagtable", endFlagList);
|
// allFlag.put("endflagtable", endFlagList);
|
||||||
|
//
|
||||||
// Flag默认为1:0代表诱导期给药、1代表维持期AI给药、2代表维持期医生给药
|
// // Flag默认为1:0代表诱导期给药、1代表维持期AI给药、2代表维持期医生给药
|
||||||
// ConvertFlag默认为0:0代表无需切换、1代表由AI给药转为医生给药
|
// // ConvertFlag默认为0:0代表无需切换、1代表由AI给药转为医生给药
|
||||||
ResultSet aiRe = statement.executeQuery("SELECT * FROM `aiflagtable` ORDER BY time DESC LIMIT 1;");
|
// ResultSet aiRe = statement.executeQuery("SELECT * FROM `aiflagtable` ORDER BY time DESC LIMIT 1;");
|
||||||
List<Map> aiFlagList = new ArrayList<>();
|
// List<Map> aiFlagList = new ArrayList<>();
|
||||||
while (aiRe.next()) {
|
// while (aiRe.next()) {
|
||||||
Map flag = new HashMap();
|
// Map flag = new HashMap();
|
||||||
flag.put("id", aiRe.getString(1));
|
// flag.put("id", aiRe.getString(1));
|
||||||
flag.put("Flag", aiRe.getString(2));
|
// flag.put("Flag", aiRe.getString(2));
|
||||||
flag.put("ConvertFlag", aiRe.getString(3));
|
// flag.put("ConvertFlag", aiRe.getString(3));
|
||||||
flag.put("Time", aiRe.getString(4));
|
// flag.put("Time", aiRe.getString(4));
|
||||||
aiFlagList.add(flag);
|
// aiFlagList.add(flag);
|
||||||
}
|
// }
|
||||||
allFlag.put("aiflagtable", aiFlagList);
|
// allFlag.put("aiflagtable", aiFlagList);
|
||||||
|
//
|
||||||
// 诱导期标志符 0是诱导期 1是维持期
|
// // 诱导期标志符 0是诱导期 1是维持期
|
||||||
ResultSet reRe = statement.executeQuery("SELECT * FROM `reflagtable` ORDER BY time DESC LIMIT 1;");
|
// ResultSet reRe = statement.executeQuery("SELECT * FROM `reflagtable` ORDER BY time DESC LIMIT 1;");
|
||||||
List<Map> reFlagList = new ArrayList<>();
|
// List<Map> reFlagList = new ArrayList<>();
|
||||||
while (reRe.next()) {
|
// while (reRe.next()) {
|
||||||
Map flag = new HashMap();
|
// Map flag = new HashMap();
|
||||||
flag.put("id", reRe.getString(1));
|
// flag.put("id", reRe.getString(1));
|
||||||
flag.put("Flag", reRe.getString(2));
|
// flag.put("Flag", reRe.getString(2));
|
||||||
flag.put("Time", reRe.getString(3));
|
// flag.put("Time", reRe.getString(3));
|
||||||
reFlagList.add(flag);
|
// reFlagList.add(flag);
|
||||||
}
|
// }
|
||||||
allFlag.put("reflagtable", reFlagList);
|
// allFlag.put("reflagtable", reFlagList);
|
||||||
|
//
|
||||||
// Flag默认为1: 0代表泵站通讯正常、1代表泵站通讯异常
|
// // Flag默认为1: 0代表泵站通讯正常、1代表泵站通讯异常
|
||||||
ResultSet link = statement.executeQuery("SELECT * FROM `linktable` ORDER BY time DESC LIMIT 1;");
|
// ResultSet link = statement.executeQuery("SELECT * FROM `linktable` ORDER BY time DESC LIMIT 1;");
|
||||||
List<Map> linkFlagList = new ArrayList<>();
|
// List<Map> linkFlagList = new ArrayList<>();
|
||||||
while (link.next()) {
|
// while (link.next()) {
|
||||||
Map flag = new HashMap();
|
// Map flag = new HashMap();
|
||||||
flag.put("id", link.getString(1));
|
// flag.put("id", link.getString(1));
|
||||||
flag.put("Flag", link.getString(2));
|
// flag.put("Flag", link.getString(2));
|
||||||
flag.put("Time", link.getString(3));
|
// flag.put("Time", link.getString(3));
|
||||||
linkFlagList.add(flag);
|
// linkFlagList.add(flag);
|
||||||
}
|
// }
|
||||||
allFlag.put("linktable", linkFlagList);
|
// allFlag.put("linktable", linkFlagList);
|
||||||
|
//
|
||||||
} catch (SQLException e) {
|
// } catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
// throw new RuntimeException(e);
|
||||||
}
|
// }
|
||||||
return allFlag;
|
// return allFlag;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,306 +1,306 @@
|
||||||
package com.rax.vital.v2.medicine.service.impl;
|
//package com.rax.vital.v2.medicine.service.impl;
|
||||||
|
//
|
||||||
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.common.datasource.MongoDBSource;
|
//import com.rax.vital.common.datasource.MongoDBSource;
|
||||||
import com.rax.vital.common.util.DatabaseNameUtil;
|
//import com.rax.vital.common.util.DatabaseNameUtil;
|
||||||
import com.rax.vital.v2.medicine.service.IMedicineService;
|
//import com.rax.vital.v2.medicine.service.IMedicineService;
|
||||||
import org.bson.BsonRegularExpression;
|
//import org.bson.BsonRegularExpression;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
//import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.data.domain.Sort;
|
//import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
//import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
import org.springframework.data.mongodb.core.aggregation.*;
|
//import org.springframework.data.mongodb.core.aggregation.*;
|
||||||
import org.springframework.data.mongodb.core.query.Criteria;
|
//import org.springframework.data.mongodb.core.query.Criteria;
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
//import org.springframework.data.mongodb.core.query.Query;
|
||||||
import org.springframework.stereotype.Service;
|
//import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
//import org.springframework.util.StringUtils;
|
||||||
|
//
|
||||||
import java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* @project_name: rax-remote-v2
|
// * @project_name: rax-remote-v2
|
||||||
* @time: 2024/9/10 17:01
|
// * @time: 2024/9/10 17:01
|
||||||
* @author: republicline
|
// * @author: republicline
|
||||||
* @description: 针对于固定数据源的读取配置操作.
|
// * @description: 针对于固定数据源的读取配置操作.
|
||||||
*/
|
// */
|
||||||
@Service
|
//@Service
|
||||||
public class MedicineService implements IMedicineService {
|
//public class MedicineService implements IMedicineService {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private MongoTemplate mongoTemplate;
|
// private MongoTemplate mongoTemplate;
|
||||||
|
//
|
||||||
@Value("${vital-sign.mongodb.host}")
|
// @Value("${vital-sign.mongodb.host}")
|
||||||
private String mongoDBHost;
|
// private String mongoDBHost;
|
||||||
|
//
|
||||||
// MongoDB的用户名
|
// // MongoDB的用户名
|
||||||
@Value("${vital-sign.mongodb.username}")
|
// @Value("${vital-sign.mongodb.username}")
|
||||||
private String mongoUsername;
|
// private String mongoUsername;
|
||||||
|
//
|
||||||
// MongoDB的用户的密码
|
// // MongoDB的用户的密码
|
||||||
@Value("${vital-sign.mongodb.password}")
|
// @Value("${vital-sign.mongodb.password}")
|
||||||
private String mongoPassword;
|
// private String mongoPassword;
|
||||||
|
//
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public R getPatientInfo(String databaseName) {
|
// public R getPatientInfo(String databaseName) {
|
||||||
// MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, databaseName);
|
//// MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, databaseName);
|
||||||
// mongoDBSource.open();
|
//// mongoDBSource.open();
|
||||||
// MongoTemplate template = mongoDBSource.getConnection();
|
//// MongoTemplate template = mongoDBSource.getConnection();
|
||||||
|
//// Query query = new Query();
|
||||||
|
//// query.limit(1);
|
||||||
|
//// query.with(Sort.by(Sort.Order.desc("Time")));
|
||||||
|
//// List<Map> vitalList = template.find(query, Map.class, "patienttable");
|
||||||
|
//// mongoDBSource.close();
|
||||||
|
//// return R.ok(vitalList);
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public Page getPatientPage(String name, String dept, long offset, int limit) {
|
||||||
// Query query = new Query();
|
// Query query = new Query();
|
||||||
// query.limit(1);
|
//
|
||||||
// query.with(Sort.by(Sort.Order.desc("Time")));
|
// if (StringUtils.hasText(name)) {
|
||||||
// List<Map> vitalList = template.find(query, Map.class, "patienttable");
|
// Criteria criteria = new Criteria("姓名");
|
||||||
// mongoDBSource.close();
|
// criteria.regex(new BsonRegularExpression(".*" + name + ".*"));
|
||||||
// return R.ok(vitalList);
|
// query.addCriteria(criteria);
|
||||||
return null;
|
// }
|
||||||
}
|
//
|
||||||
|
// if (StringUtils.hasText(dept)) {
|
||||||
@Override
|
// Criteria criteria = new Criteria("科室");
|
||||||
public Page getPatientPage(String name, String dept, long offset, int limit) {
|
// criteria.regex(new BsonRegularExpression(dept));
|
||||||
Query query = new Query();
|
// query.addCriteria(criteria);
|
||||||
|
// }
|
||||||
if (StringUtils.hasText(name)) {
|
//
|
||||||
Criteria criteria = new Criteria("姓名");
|
// query.with(Sort.by(Sort.Order.desc("住院时间")));
|
||||||
criteria.regex(new BsonRegularExpression(".*" + name + ".*"));
|
// query.skip(offset).limit(limit);
|
||||||
query.addCriteria(criteria);
|
// List<Map> list = mongoTemplate.find(query, Map.class, "patient_info");
|
||||||
}
|
// long count = mongoTemplate.count(query, "patient_info");
|
||||||
|
// Page page = new Page();
|
||||||
if (StringUtils.hasText(dept)) {
|
// page.setRecords(list);
|
||||||
Criteria criteria = new Criteria("科室");
|
// page.setTotal(count);
|
||||||
criteria.regex(new BsonRegularExpression(dept));
|
// return page;
|
||||||
query.addCriteria(criteria);
|
// }
|
||||||
}
|
//
|
||||||
|
// @Override
|
||||||
query.with(Sort.by(Sort.Order.desc("住院时间")));
|
// public List getSurgeryCount(String start, String end) {
|
||||||
query.skip(offset).limit(limit);
|
// // 按医院查询
|
||||||
List<Map> list = mongoTemplate.find(query, Map.class, "patient_info");
|
//// RaxUser user = SecurityUtils.getUser();
|
||||||
long count = mongoTemplate.count(query, "patient_info");
|
//// Long currentHospital = AuthUtils.getCurrentHospital(user);
|
||||||
Page page = new Page();
|
//
|
||||||
page.setRecords(list);
|
//
|
||||||
page.setTotal(count);
|
//// Criteria hosCriteria = Criteria.where("hospitalId")
|
||||||
return page;
|
//// .is(hospitalId);
|
||||||
}
|
//
|
||||||
|
// Criteria criteria = Criteria.where("Time")
|
||||||
@Override
|
// .gte(start)
|
||||||
public List getSurgeryCount(String start, String end) {
|
// .lte(end);
|
||||||
// 按医院查询
|
// Aggregation aggregation = Aggregation.newAggregation(
|
||||||
// RaxUser user = SecurityUtils.getUser();
|
//// Aggregation.match(hosCriteria),
|
||||||
// Long currentHospital = AuthUtils.getCurrentHospital(user);
|
// Aggregation.match(criteria),
|
||||||
|
// Aggregation.project("Time")
|
||||||
|
// .and(DateOperators.DateFromString.fromStringOf("Time").withFormat("%Y-%m-%d %H:%M:%S")).as("timeDate"),
|
||||||
// Criteria hosCriteria = Criteria.where("hospitalId")
|
// Aggregation.project("timeDate")
|
||||||
// .is(hospitalId);
|
// .and(DateOperators.DateToString.dateOf("timeDate").toString("%Y-%m-%d")).as("time"),
|
||||||
|
// Aggregation.group("time").count().as("count"),
|
||||||
Criteria criteria = Criteria.where("Time")
|
// Aggregation.project("_id","count"),
|
||||||
.gte(start)
|
// Aggregation.sort(Sort.by(Sort.Direction.ASC, "_id"))
|
||||||
.lte(end);
|
// );
|
||||||
Aggregation aggregation = Aggregation.newAggregation(
|
// AggregationResults<Map> results = mongoTemplate.aggregate(aggregation, "surgery_info", Map.class);
|
||||||
// Aggregation.match(hosCriteria),
|
// List<Map> mappedResults = results.getMappedResults();
|
||||||
Aggregation.match(criteria),
|
// return mappedResults;
|
||||||
Aggregation.project("Time")
|
// }
|
||||||
.and(DateOperators.DateFromString.fromStringOf("Time").withFormat("%Y-%m-%d %H:%M:%S")).as("timeDate"),
|
//
|
||||||
Aggregation.project("timeDate")
|
// @Override
|
||||||
.and(DateOperators.DateToString.dateOf("timeDate").toString("%Y-%m-%d")).as("time"),
|
// public List getSurgeryDuration(String start, String end) {
|
||||||
Aggregation.group("time").count().as("count"),
|
//
|
||||||
Aggregation.project("_id","count"),
|
// List<AggregationOperation> operations = new ArrayList<>();
|
||||||
Aggregation.sort(Sort.by(Sort.Direction.ASC, "_id"))
|
//
|
||||||
);
|
// Criteria criteria = new Criteria("Time");
|
||||||
AggregationResults<Map> results = mongoTemplate.aggregate(aggregation, "surgery_info", Map.class);
|
// criteria.gte(start);
|
||||||
List<Map> mappedResults = results.getMappedResults();
|
// criteria.lte(end);
|
||||||
return mappedResults;
|
// operations.add(Aggregation.match(criteria));
|
||||||
}
|
//
|
||||||
|
//
|
||||||
@Override
|
// ProjectionOperation timeToDateOperation = Aggregation.project()
|
||||||
public List getSurgeryDuration(String start, String end) {
|
// .andExpression("{$toLong: '$Surgery_duration(min)'}").as("Surgery_duration(min)")
|
||||||
|
// .andExpression("{$toDate: '$Time'}").as("day");
|
||||||
List<AggregationOperation> operations = new ArrayList<>();
|
// operations.add(timeToDateOperation);
|
||||||
|
//
|
||||||
Criteria criteria = new Criteria("Time");
|
// ProjectionOperation timeFormatOperation = Aggregation.project()
|
||||||
criteria.gte(start);
|
// .andInclude("Surgery_duration(min)")
|
||||||
criteria.lte(end);
|
// .andExpression("{ $dateToString: { format: '%Y-%m-%d', date: '$day' } }").as("time");
|
||||||
operations.add(Aggregation.match(criteria));
|
// operations.add(timeFormatOperation);
|
||||||
|
//
|
||||||
|
// operations.add(Aggregation.group("$time").sum("Surgery_duration(min)").as("count"));
|
||||||
ProjectionOperation timeToDateOperation = Aggregation.project()
|
//
|
||||||
.andExpression("{$toLong: '$Surgery_duration(min)'}").as("Surgery_duration(min)")
|
// operations.add(Aggregation.project()
|
||||||
.andExpression("{$toDate: '$Time'}").as("day");
|
// .andInclude("_id")
|
||||||
operations.add(timeToDateOperation);
|
// .andExpression("count").divide(60).as("count"));
|
||||||
|
//
|
||||||
ProjectionOperation timeFormatOperation = Aggregation.project()
|
// operations.add(Aggregation.project()
|
||||||
.andInclude("Surgery_duration(min)")
|
// .andInclude("_id")
|
||||||
.andExpression("{ $dateToString: { format: '%Y-%m-%d', date: '$day' } }").as("time");
|
// .andExpression("{$round: {'$count', 1}}").as("duration"));
|
||||||
operations.add(timeFormatOperation);
|
//
|
||||||
|
// operations.add(Aggregation.project()
|
||||||
operations.add(Aggregation.group("$time").sum("Surgery_duration(min)").as("count"));
|
// .andInclude("duration")
|
||||||
|
// .andExpression("{$toDate: '$_id'}").as("time"));
|
||||||
operations.add(Aggregation.project()
|
//
|
||||||
.andInclude("_id")
|
// operations.add(Aggregation.project()
|
||||||
.andExpression("count").divide(60).as("count"));
|
// .andInclude("duration")
|
||||||
|
// .andExpression("{ $dateToString: { format: '%d', date: '$time' } }").as("_id"));
|
||||||
operations.add(Aggregation.project()
|
//
|
||||||
.andInclude("_id")
|
// operations.add(Aggregation.sort(Sort.Direction.ASC, "_id"));
|
||||||
.andExpression("{$round: {'$count', 1}}").as("duration"));
|
//
|
||||||
|
// TypedAggregation typedAggregation = new TypedAggregation(Map.class, operations);
|
||||||
operations.add(Aggregation.project()
|
// AggregationResults<Map> aggregate = mongoTemplate.aggregate(typedAggregation, "surgery_info", Map.class);
|
||||||
.andInclude("duration")
|
// List<Map> mappedResults = aggregate.getMappedResults();
|
||||||
.andExpression("{$toDate: '$_id'}").as("time"));
|
// return mappedResults;
|
||||||
|
// }
|
||||||
operations.add(Aggregation.project()
|
//
|
||||||
.andInclude("duration")
|
// @Override
|
||||||
.andExpression("{ $dateToString: { format: '%d', date: '$time' } }").as("_id"));
|
// public List getSurgeryTypeProportion(String start, String end) {
|
||||||
|
//
|
||||||
operations.add(Aggregation.sort(Sort.Direction.ASC, "_id"));
|
//// RaxUser user = SecurityUtils.getUser();
|
||||||
|
//// Long currentHospital = AuthUtils.getCurrentHospital(user);
|
||||||
TypedAggregation typedAggregation = new TypedAggregation(Map.class, operations);
|
//
|
||||||
AggregationResults<Map> aggregate = mongoTemplate.aggregate(typedAggregation, "surgery_info", Map.class);
|
//
|
||||||
List<Map> mappedResults = aggregate.getMappedResults();
|
//
|
||||||
return mappedResults;
|
// Aggregation aggregation = Aggregation.newAggregation(
|
||||||
}
|
// Aggregation.match(Criteria.where("Time")
|
||||||
|
// .gte(start)
|
||||||
@Override
|
// .lte(end)),
|
||||||
public List getSurgeryTypeProportion(String start, String end) {
|
//// Aggregation.match(Criteria.where("hospitalId")
|
||||||
|
//// .is(currentHospital)),
|
||||||
// RaxUser user = SecurityUtils.getUser();
|
// Aggregation.group("Surgery_type").count().as("count")
|
||||||
// Long currentHospital = AuthUtils.getCurrentHospital(user);
|
// );
|
||||||
|
// List<Map> mappedResults = mongoTemplate.aggregate(aggregation, "surgery_info", Map.class).getMappedResults();
|
||||||
|
//
|
||||||
|
// return mappedResults;
|
||||||
Aggregation aggregation = Aggregation.newAggregation(
|
// }
|
||||||
Aggregation.match(Criteria.where("Time")
|
//
|
||||||
.gte(start)
|
// @Override
|
||||||
.lte(end)),
|
// public List getSurgeryOtherDuration(String start, String end) {
|
||||||
// Aggregation.match(Criteria.where("hospitalId")
|
//// MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, informationDatabase);
|
||||||
// .is(currentHospital)),
|
//// mongoDBSource.open();
|
||||||
Aggregation.group("Surgery_type").count().as("count")
|
//// MongoTemplate template = mongoDBSource.getConnection();
|
||||||
);
|
// List<AggregationOperation> operations = new ArrayList<>();
|
||||||
List<Map> mappedResults = mongoTemplate.aggregate(aggregation, "surgery_info", Map.class).getMappedResults();
|
//
|
||||||
|
// Criteria criteria = new Criteria("Time");
|
||||||
return mappedResults;
|
// criteria.gte(start);
|
||||||
}
|
// criteria.lte(end);
|
||||||
|
// operations.add(Aggregation.match(criteria));
|
||||||
@Override
|
//
|
||||||
public List getSurgeryOtherDuration(String start, String end) {
|
// ProjectionOperation timeToDateOperation = Aggregation.project()
|
||||||
// MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, informationDatabase);
|
// .andExpression("{$toLong: '$Aianaesthesia_duration(min)'}").as("Aianaesthesia_duration(min)")
|
||||||
// mongoDBSource.open();
|
// .andExpression("{$toLong: '$Doctoranaesthesia_duration(min)'}").as("Doctoranaesthesia_duration(min)")
|
||||||
// MongoTemplate template = mongoDBSource.getConnection();
|
// .andExpression("{$toDate: '$Time'}").as("time");
|
||||||
List<AggregationOperation> operations = new ArrayList<>();
|
// operations.add(timeToDateOperation);
|
||||||
|
//
|
||||||
Criteria criteria = new Criteria("Time");
|
// ProjectionOperation timeFormatOperation = Aggregation.project()
|
||||||
criteria.gte(start);
|
// .andInclude("Aianaesthesia_duration(min)")
|
||||||
criteria.lte(end);
|
// .andInclude("Doctoranaesthesia_duration(min)")
|
||||||
operations.add(Aggregation.match(criteria));
|
// .andExpression("{ $dateToString: { format: '%Y-%m-%d', date: '$time' } }").as("time");
|
||||||
|
// operations.add(timeFormatOperation);
|
||||||
ProjectionOperation timeToDateOperation = Aggregation.project()
|
//
|
||||||
.andExpression("{$toLong: '$Aianaesthesia_duration(min)'}").as("Aianaesthesia_duration(min)")
|
// operations.add(Aggregation.group("$time")
|
||||||
.andExpression("{$toLong: '$Doctoranaesthesia_duration(min)'}").as("Doctoranaesthesia_duration(min)")
|
// .sum("Aianaesthesia_duration(min)").as("aicount")
|
||||||
.andExpression("{$toDate: '$Time'}").as("time");
|
// .sum("Doctoranaesthesia_duration(min)").as("doccount"));
|
||||||
operations.add(timeToDateOperation);
|
//
|
||||||
|
// operations.add(Aggregation.project()
|
||||||
ProjectionOperation timeFormatOperation = Aggregation.project()
|
// .andInclude("_id")
|
||||||
.andInclude("Aianaesthesia_duration(min)")
|
// .andExpression("aicount").divide(60).as("aicount")
|
||||||
.andInclude("Doctoranaesthesia_duration(min)")
|
// .andExpression("doccount").divide(60).as("doccount"));
|
||||||
.andExpression("{ $dateToString: { format: '%Y-%m-%d', date: '$time' } }").as("time");
|
//
|
||||||
operations.add(timeFormatOperation);
|
// operations.add(Aggregation.project()
|
||||||
|
// .andInclude("_id")
|
||||||
operations.add(Aggregation.group("$time")
|
// .andExpression("{$round: {'$aicount', 1}}").as("aicount")
|
||||||
.sum("Aianaesthesia_duration(min)").as("aicount")
|
// .andExpression("{$round: {'$doccount', 1}}").as("doccount"));
|
||||||
.sum("Doctoranaesthesia_duration(min)").as("doccount"));
|
//
|
||||||
|
// operations.add(Aggregation.sort(Sort.Direction.ASC, "_id"));
|
||||||
operations.add(Aggregation.project()
|
//
|
||||||
.andInclude("_id")
|
// TypedAggregation typedAggregation = new TypedAggregation(Map.class, operations);
|
||||||
.andExpression("aicount").divide(60).as("aicount")
|
// AggregationResults<Map> aggregate = mongoTemplate.aggregate(typedAggregation, "surgery_info", Map.class);
|
||||||
.andExpression("doccount").divide(60).as("doccount"));
|
// List<Map> mappedResults = aggregate.getMappedResults();
|
||||||
|
// return mappedResults;
|
||||||
operations.add(Aggregation.project()
|
// }
|
||||||
.andInclude("_id")
|
//
|
||||||
.andExpression("{$round: {'$aicount', 1}}").as("aicount")
|
// @Override
|
||||||
.andExpression("{$round: {'$doccount', 1}}").as("doccount"));
|
// public List getPatientSurgeryList(String name, String code, String surgery, String type) {
|
||||||
|
// if (StringUtils.hasText(code)) {
|
||||||
operations.add(Aggregation.sort(Sort.Direction.ASC, "_id"));
|
//
|
||||||
|
// if (!StringUtils.hasText(name)) {
|
||||||
TypedAggregation typedAggregation = new TypedAggregation(Map.class, operations);
|
|
||||||
AggregationResults<Map> aggregate = mongoTemplate.aggregate(typedAggregation, "surgery_info", Map.class);
|
|
||||||
List<Map> mappedResults = aggregate.getMappedResults();
|
|
||||||
return mappedResults;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List getPatientSurgeryList(String name, String code, String surgery, String type) {
|
|
||||||
if (StringUtils.hasText(code)) {
|
|
||||||
|
|
||||||
if (!StringUtils.hasText(name)) {
|
|
||||||
Query query = new Query();
|
|
||||||
Criteria criteria = new Criteria("住院号");
|
|
||||||
criteria.regex(new BsonRegularExpression(code));
|
|
||||||
query.addCriteria(criteria);
|
|
||||||
List<Map> list = mongoTemplate.find(query, Map.class, "patient_info");
|
|
||||||
if (!list.isEmpty()) {
|
|
||||||
Map patient = list.get(0);
|
|
||||||
name = (String) patient.get("姓名");
|
|
||||||
} else {
|
|
||||||
return List.of();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Query query = new Query();
|
|
||||||
String databasePrefix = DatabaseNameUtil.encrypt(name) + "_" + DatabaseNameUtil.encrypt(code) + "_";
|
|
||||||
Criteria criteria = new Criteria("Databasename");
|
|
||||||
criteria.regex(new BsonRegularExpression("^" + databasePrefix));
|
|
||||||
query.addCriteria(criteria);
|
|
||||||
|
|
||||||
if (StringUtils.hasText(surgery)) {
|
|
||||||
Criteria surgeryCriteria = new Criteria("Surgery_name");
|
|
||||||
surgeryCriteria.regex(new BsonRegularExpression(surgery));
|
|
||||||
query.addCriteria(surgeryCriteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtils.hasText(type)) {
|
|
||||||
Criteria anesthesiaCriteria = new Criteria("Anesthesia_way");
|
|
||||||
anesthesiaCriteria.regex(new BsonRegularExpression(type));
|
|
||||||
query.addCriteria(anesthesiaCriteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
|
||||||
List<Map> surgeryInfoList = mongoTemplate.find(query, Map.class, "surgery_info");
|
|
||||||
return surgeryInfoList;
|
|
||||||
} else {
|
|
||||||
return List.of();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List getSurgeryTableData(String name, String code, String date, String table) {
|
|
||||||
if (StringUtils.hasText(code)) {
|
|
||||||
if (!StringUtils.hasText(name)) {
|
|
||||||
// Query query = new Query();
|
// Query query = new Query();
|
||||||
// Criteria criteria = new Criteria("住院号");
|
// Criteria criteria = new Criteria("住院号");
|
||||||
// criteria.regex(new BsonRegularExpression(code));
|
// criteria.regex(new BsonRegularExpression(code));
|
||||||
// query.addCriteria(criteria);
|
// query.addCriteria(criteria);
|
||||||
Query query = new Query(
|
// List<Map> list = mongoTemplate.find(query, Map.class, "patient_info");
|
||||||
Criteria.where("住院号").is(code)
|
// if (!list.isEmpty()) {
|
||||||
);
|
// Map patient = list.get(0);
|
||||||
List<Map> list = mongoTemplate.find(query, Map.class, "patient_info");
|
// name = (String) patient.get("姓名");
|
||||||
if (!list.isEmpty()) {
|
// } else {
|
||||||
Map patient = list.get(0);
|
// return List.of();
|
||||||
name = (String) patient.get("姓名");
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//
|
||||||
String database = DatabaseNameUtil.encrypt(name) + "_" + DatabaseNameUtil.encrypt(code) + "_" + date;
|
// Query query = new Query();
|
||||||
MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, database);
|
// String databasePrefix = DatabaseNameUtil.encrypt(name) + "_" + DatabaseNameUtil.encrypt(code) + "_";
|
||||||
mongoDBSource.open();
|
// Criteria criteria = new Criteria("Databasename");
|
||||||
MongoTemplate template = mongoDBSource.getConnection();
|
// criteria.regex(new BsonRegularExpression("^" + databasePrefix));
|
||||||
Query query = new Query();
|
// query.addCriteria(criteria);
|
||||||
query.with(Sort.by(Sort.Order.asc("_id")));
|
//
|
||||||
List<Map> list = template.find(query, Map.class, table);
|
// if (StringUtils.hasText(surgery)) {
|
||||||
System.out.println("list = " + list);
|
// Criteria surgeryCriteria = new Criteria("Surgery_name");
|
||||||
mongoDBSource.close();
|
// surgeryCriteria.regex(new BsonRegularExpression(surgery));
|
||||||
return list;
|
// query.addCriteria(surgeryCriteria);
|
||||||
} else {
|
// }
|
||||||
return new ArrayList<>();
|
//
|
||||||
}
|
// if (StringUtils.hasText(type)) {
|
||||||
}
|
// Criteria anesthesiaCriteria = new Criteria("Anesthesia_way");
|
||||||
}
|
// anesthesiaCriteria.regex(new BsonRegularExpression(type));
|
||||||
|
// query.addCriteria(anesthesiaCriteria);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// query.with(Sort.by(Sort.Order.desc("Time")));
|
||||||
|
// List<Map> surgeryInfoList = mongoTemplate.find(query, Map.class, "surgery_info");
|
||||||
|
// return surgeryInfoList;
|
||||||
|
// } else {
|
||||||
|
// return List.of();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public List getSurgeryTableData(String name, String code, String date, String table) {
|
||||||
|
// if (StringUtils.hasText(code)) {
|
||||||
|
// if (!StringUtils.hasText(name)) {
|
||||||
|
//// Query query = new Query();
|
||||||
|
//// Criteria criteria = new Criteria("住院号");
|
||||||
|
//// criteria.regex(new BsonRegularExpression(code));
|
||||||
|
//// query.addCriteria(criteria);
|
||||||
|
// Query query = new Query(
|
||||||
|
// Criteria.where("住院号").is(code)
|
||||||
|
// );
|
||||||
|
// List<Map> list = mongoTemplate.find(query, Map.class, "patient_info");
|
||||||
|
// if (!list.isEmpty()) {
|
||||||
|
// Map patient = list.get(0);
|
||||||
|
// name = (String) patient.get("姓名");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// String database = DatabaseNameUtil.encrypt(name) + "_" + DatabaseNameUtil.encrypt(code) + "_" + date;
|
||||||
|
// MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, database);
|
||||||
|
// mongoDBSource.open();
|
||||||
|
// MongoTemplate template = mongoDBSource.getConnection();
|
||||||
|
// Query query = new Query();
|
||||||
|
// query.with(Sort.by(Sort.Order.asc("_id")));
|
||||||
|
// List<Map> list = template.find(query, Map.class, table);
|
||||||
|
// System.out.println("list = " + list);
|
||||||
|
// mongoDBSource.close();
|
||||||
|
// return list;
|
||||||
|
// } else {
|
||||||
|
// return new ArrayList<>();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
|
@ -1,65 +1,65 @@
|
||||||
package com.rax.vital.v2.medicine.service.impl;
|
//package com.rax.vital.v2.medicine.service.impl;
|
||||||
|
//
|
||||||
import com.rax.vital.v2.medicine.service.RevulsionService;
|
//import com.rax.vital.v2.medicine.service.RevulsionService;
|
||||||
import lombok.AllArgsConstructor;
|
//import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.domain.Sort;
|
//import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
//import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
//import org.springframework.data.mongodb.core.query.Query;
|
||||||
import org.springframework.stereotype.Service;
|
//import org.springframework.stereotype.Service;
|
||||||
|
//
|
||||||
import java.sql.Connection;
|
//import java.sql.Connection;
|
||||||
import java.sql.ResultSet;
|
//import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
//import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
//import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
//import java.util.HashMap;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 诱导期给药数据
|
// * 诱导期给药数据
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
@Slf4j
|
//@Slf4j
|
||||||
@Service
|
//@Service
|
||||||
@AllArgsConstructor
|
//@AllArgsConstructor
|
||||||
public class RevulsionServiceImpl implements RevulsionService {
|
//public class RevulsionServiceImpl implements RevulsionService {
|
||||||
|
//
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public List<Map> getRevulsionServiceList(MongoTemplate template) {
|
// public List<Map> getRevulsionServiceList(MongoTemplate template) {
|
||||||
Query query = new Query();
|
// Query query = new Query();
|
||||||
query.limit(1);
|
// query.limit(1);
|
||||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
// query.with(Sort.by(Sort.Order.desc("Time")));
|
||||||
List<Map> revulsionTable = template.find(query, Map.class, "revulsiontable");
|
// List<Map> revulsionTable = template.find(query, Map.class, "revulsiontable");
|
||||||
return revulsionTable;
|
// return revulsionTable;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public List<Map> getRevulsionServiceList(Connection connection) {
|
// public List<Map> getRevulsionServiceList(Connection connection) {
|
||||||
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 `revulsiontable` ORDER BY time DESC LIMIT 1;");
|
// ResultSet resultSet = statement.executeQuery("SELECT id, phase, `丙泊酚`, `舒芬太尼`, `瑞芬太尼`, `顺阿曲库胺`, `尼卡地平`, `艾司洛尔`, `麻黄素`, `阿托品`, time FROM `revulsiontable` ORDER BY time DESC LIMIT 1;");
|
||||||
while (resultSet.next()) {
|
// while (resultSet.next()) {
|
||||||
Map medicine = new HashMap();
|
// Map medicine = new HashMap();
|
||||||
medicine.put("id", resultSet.getString("id"));
|
// medicine.put("id", resultSet.getString("id"));
|
||||||
medicine.put("phase", resultSet.getString("phase"));
|
// medicine.put("phase", resultSet.getString("phase"));
|
||||||
medicine.put("丙泊酚", resultSet.getString("丙泊酚"));
|
// medicine.put("丙泊酚", resultSet.getString("丙泊酚"));
|
||||||
medicine.put("舒芬太尼", resultSet.getString("舒芬太尼"));
|
// medicine.put("舒芬太尼", resultSet.getString("舒芬太尼"));
|
||||||
medicine.put("瑞芬太尼", resultSet.getString("瑞芬太尼"));
|
// medicine.put("瑞芬太尼", resultSet.getString("瑞芬太尼"));
|
||||||
medicine.put("顺阿曲库胺", resultSet.getString("顺阿曲库胺"));
|
// medicine.put("顺阿曲库胺", resultSet.getString("顺阿曲库胺"));
|
||||||
medicine.put("尼卡地平", resultSet.getString("尼卡地平"));
|
// medicine.put("尼卡地平", resultSet.getString("尼卡地平"));
|
||||||
medicine.put("艾司洛尔", resultSet.getString("艾司洛尔"));
|
// medicine.put("艾司洛尔", resultSet.getString("艾司洛尔"));
|
||||||
medicine.put("麻黄素", resultSet.getString("麻黄素"));
|
// medicine.put("麻黄素", resultSet.getString("麻黄素"));
|
||||||
medicine.put("阿托品", resultSet.getString("阿托品"));
|
// medicine.put("阿托品", resultSet.getString("阿托品"));
|
||||||
medicine.put("Time", resultSet.getString("time"));
|
// 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);
|
||||||
}
|
// }
|
||||||
return medicineList;
|
// return medicineList;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,48 +1,48 @@
|
||||||
package com.rax.vital.v2.medicine.service.impl;
|
//package com.rax.vital.v2.medicine.service.impl;
|
||||||
|
//
|
||||||
import com.rax.vital.v2.medicine.service.SurgeryServiceV2;
|
//import com.rax.vital.v2.medicine.service.SurgeryServiceV2;
|
||||||
import org.springframework.data.domain.Sort;
|
//import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
//import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
//import org.springframework.data.mongodb.core.query.Query;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* project_name:remote-control-backend
|
// * project_name:remote-control-backend
|
||||||
* time:2024/8/23 16:23
|
// * time:2024/8/23 16:23
|
||||||
* author:republicline
|
// * author:republicline
|
||||||
* 术中信息服务实现 V2, 针对mongoDB数据库
|
// * 术中信息服务实现 V2, 针对mongoDB数据库
|
||||||
*/
|
// */
|
||||||
@Component
|
//@Component
|
||||||
public class SurgeryServiceV2Impl implements SurgeryServiceV2 {
|
//public class SurgeryServiceV2Impl implements SurgeryServiceV2 {
|
||||||
|
//
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public List<Map> getVitalSignsList(MongoTemplate template) {
|
// public List<Map> getVitalSignsList(MongoTemplate template) {
|
||||||
Query query = new Query();
|
// Query query = new Query();
|
||||||
query.limit(1);
|
// query.limit(1);
|
||||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
// query.with(Sort.by(Sort.Order.desc("Time")));
|
||||||
List<Map> vitalList = template.find(query, Map.class, "featuretable");
|
// List<Map> vitalList = template.find(query, Map.class, "featuretable");
|
||||||
|
//
|
||||||
if (vitalList != null && vitalList.size() > 0) {
|
// if (vitalList != null && vitalList.size() > 0) {
|
||||||
Map map = vitalList.get(0);
|
// Map map = vitalList.get(0);
|
||||||
Double bis = Double.valueOf((String) map.get("BIS"));
|
// Double bis = Double.valueOf((String) map.get("BIS"));
|
||||||
map.put("BIS_except", bis <= 40 || bis >= 60);
|
// map.put("BIS_except", bis <= 40 || bis >= 60);
|
||||||
Double hr = Double.valueOf((String) map.get("HR"));
|
// Double hr = Double.valueOf((String) map.get("HR"));
|
||||||
map.put("HR_except", hr <= 50 || hr >= 80);
|
// map.put("HR_except", hr <= 50 || hr >= 80);
|
||||||
Double sbp = Double.valueOf((String) map.get("SBP"));
|
// Double sbp = Double.valueOf((String) map.get("SBP"));
|
||||||
map.put("SBP_except", sbp <= 90 || sbp >= 120);
|
// map.put("SBP_except", sbp <= 90 || sbp >= 120);
|
||||||
Double dbp = Double.valueOf((String) map.get("DBP"));
|
// Double dbp = Double.valueOf((String) map.get("DBP"));
|
||||||
map.put("DBP_except", dbp <= 60 || dbp >= 90);
|
// map.put("DBP_except", dbp <= 60 || dbp >= 90);
|
||||||
Double st = Double.valueOf((String) map.get("ST"));
|
// Double st = Double.valueOf((String) map.get("ST"));
|
||||||
map.put("ST_except", st <= -0.2 || st >= 0.2);
|
// map.put("ST_except", st <= -0.2 || st >= 0.2);
|
||||||
Double etCO2 = Double.valueOf((String) map.get("EtCO2"));
|
// Double etCO2 = Double.valueOf((String) map.get("EtCO2"));
|
||||||
map.put("EtCO2_except", etCO2 <= 30 || etCO2 >= 45);
|
// map.put("EtCO2_except", etCO2 <= 30 || etCO2 >= 45);
|
||||||
}
|
// }
|
||||||
return vitalList;
|
// return vitalList;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,225 +1,225 @@
|
||||||
package com.rax.vital.v2.timer;
|
//package com.rax.vital.v2.timer;
|
||||||
|
//
|
||||||
|
//
|
||||||
import com.alibaba.fastjson.JSONObject;
|
//import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.RequiredArgsConstructor;
|
//import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
//import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.socket.TextMessage;
|
//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.util.Map;
|
//import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
//import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* project_name:remote-control-backend
|
// * project_name:remote-control-backend
|
||||||
* time:2024/8/14 15:09
|
// * time:2024/8/14 15:09
|
||||||
* author:republicline
|
// * author:republicline
|
||||||
* 联调给药2.0 网页端和unity端互相确认连接状态
|
// * 联调给药2.0 网页端和unity端互相确认连接状态
|
||||||
*/
|
// */
|
||||||
@RefreshScope
|
//@RefreshScope
|
||||||
@Component
|
//@Component
|
||||||
@RequiredArgsConstructor
|
//@RequiredArgsConstructor
|
||||||
public class AIMedicineTimer {
|
//public class AIMedicineTimer {
|
||||||
|
//
|
||||||
// 存放sessionId与dbName的映射关系
|
// // 存放sessionId与dbName的映射关系
|
||||||
private static final Map<String, WebSocketSession> webDbSessionMap = new ConcurrentHashMap<>();
|
// private static final Map<String, WebSocketSession> webDbSessionMap = new ConcurrentHashMap<>();
|
||||||
|
//
|
||||||
// 存放sessionId的状态
|
// // 存放sessionId的状态
|
||||||
private static final Map<WebSocketSession, Boolean> webStatusMap = new ConcurrentHashMap<>();
|
// private static final Map<WebSocketSession, Boolean> webStatusMap = new ConcurrentHashMap<>();
|
||||||
|
//
|
||||||
// unity 端的dbname 和 sessionId 映射
|
// // unity 端的dbname 和 sessionId 映射
|
||||||
private static final Map<String, WebSocketSession> u3DDbSessionMap = new ConcurrentHashMap<>();
|
// private static final Map<String, WebSocketSession> u3DDbSessionMap = new ConcurrentHashMap<>();
|
||||||
|
//
|
||||||
// unity端的session状态映射
|
// // unity端的session状态映射
|
||||||
private static final Map<WebSocketSession, Boolean> u3DStatusMap = new ConcurrentHashMap<>();
|
// private static final Map<WebSocketSession, Boolean> u3DStatusMap = new ConcurrentHashMap<>();
|
||||||
|
//
|
||||||
// unity响应web端的信息
|
// // unity响应web端的信息
|
||||||
public void sendConnectionResponseToWeb(String patientName,String idNum,String date,String databaseName, String flag) throws IOException {
|
// public void sendConnectionResponseToWeb(String patientName,String idNum,String date,String databaseName, String flag) throws IOException {
|
||||||
WebSocketSession webSession = getWebSession(databaseName);
|
// WebSocketSession webSession = getWebSession(databaseName);
|
||||||
if (webSession != null) {
|
// if (webSession != null) {
|
||||||
JSONObject unityMsg = new JSONObject();
|
// JSONObject unityMsg = new JSONObject();
|
||||||
if ("1".equals(flag)) {
|
// if ("1".equals(flag)) {
|
||||||
// unity同意连接
|
// // unity同意连接
|
||||||
setU3DStatus(databaseName, true);
|
// setU3DStatus(databaseName, true);
|
||||||
unityMsg.put("msgType", "unityResponseConnection");
|
// unityMsg.put("msgType", "unityResponseConnection");
|
||||||
unityMsg.put("unityConnectionFlag", "1");
|
// unityMsg.put("unityConnectionFlag", "1");
|
||||||
unityMsg.put("patientName", patientName);
|
// unityMsg.put("patientName", patientName);
|
||||||
unityMsg.put("idNum", idNum);
|
// unityMsg.put("idNum", idNum);
|
||||||
unityMsg.put("date", date);
|
// unityMsg.put("date", date);
|
||||||
webSession.sendMessage(new TextMessage(unityMsg.toJSONString().getBytes()));
|
// webSession.sendMessage(new TextMessage(unityMsg.toJSONString().getBytes()));
|
||||||
}
|
// }
|
||||||
if ("0".equals(flag)) {
|
// if ("0".equals(flag)) {
|
||||||
// unity拒绝连接
|
// // unity拒绝连接
|
||||||
setU3DStatus(databaseName, false);
|
// setU3DStatus(databaseName, false);
|
||||||
setWebStatus(databaseName, false);
|
// setWebStatus(databaseName, false);
|
||||||
unityMsg = new JSONObject();
|
// unityMsg = new JSONObject();
|
||||||
unityMsg.put("msgType", "unityResponseConnection");
|
// unityMsg.put("msgType", "unityResponseConnection");
|
||||||
unityMsg.put("unityConnectionFlag", "0");
|
// unityMsg.put("unityConnectionFlag", "0");
|
||||||
unityMsg.put("patientName", patientName);
|
// unityMsg.put("patientName", patientName);
|
||||||
unityMsg.put("idNum", idNum);
|
// unityMsg.put("idNum", idNum);
|
||||||
unityMsg.put("date", date);
|
// unityMsg.put("date", date);
|
||||||
webSession.sendMessage(new TextMessage(unityMsg.toJSONString().getBytes()));
|
// webSession.sendMessage(new TextMessage(unityMsg.toJSONString().getBytes()));
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
// 告知u3d网页端
|
// // 告知u3d网页端
|
||||||
System.out.println("U3d尚未初始化,无法发送连接响应消息");
|
// System.out.println("U3d尚未初始化,无法发送连接响应消息");
|
||||||
WebSocketSession webSocketSession = u3DDbSessionMap.get(databaseName);
|
// WebSocketSession webSocketSession = u3DDbSessionMap.get(databaseName);
|
||||||
webSocketSession.sendMessage(new TextMessage("网页端尚未初始化,无法发送连接响应消息".getBytes()));
|
// webSocketSession.sendMessage(new TextMessage("网页端尚未初始化,无法发送连接响应消息".getBytes()));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// unity端请求网页端连接或断开连接
|
// // unity端请求网页端连接或断开连接
|
||||||
public void sendUnityRequestConnectionMsg(String patientName,String idNum,String date,String databaseName, String flag) throws IOException {
|
// public void sendUnityRequestConnectionMsg(String patientName,String idNum,String date,String databaseName, String flag) throws IOException {
|
||||||
WebSocketSession webSession = getWebSession(databaseName);
|
// WebSocketSession webSession = getWebSession(databaseName);
|
||||||
JSONObject jsonObject = new JSONObject();
|
// JSONObject jsonObject = new JSONObject();
|
||||||
if (webSession != null) {
|
// if (webSession != null) {
|
||||||
if ("1".equals(flag)) {
|
// if ("1".equals(flag)) {
|
||||||
jsonObject.put("patientName",patientName);
|
// jsonObject.put("patientName",patientName);
|
||||||
jsonObject.put("idNum",idNum);
|
// jsonObject.put("idNum",idNum);
|
||||||
jsonObject.put("date",date);
|
// jsonObject.put("date",date);
|
||||||
jsonObject.put("msgType", "unityRequestConnection");
|
// jsonObject.put("msgType", "unityRequestConnection");
|
||||||
jsonObject.put("unityConnectionFlag", "1");
|
// jsonObject.put("unityConnectionFlag", "1");
|
||||||
webSession.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
// webSession.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
setU3DStatus(databaseName, true);
|
// setU3DStatus(databaseName, true);
|
||||||
}
|
// }
|
||||||
if ("0".equals(flag)) {
|
// if ("0".equals(flag)) {
|
||||||
jsonObject.put("patientName",patientName);
|
// jsonObject.put("patientName",patientName);
|
||||||
jsonObject.put("idNum",idNum);
|
// jsonObject.put("idNum",idNum);
|
||||||
jsonObject.put("date",date);
|
// jsonObject.put("date",date);
|
||||||
jsonObject.put("msgType", "unityRequestConnection");
|
// jsonObject.put("msgType", "unityRequestConnection");
|
||||||
jsonObject.put("unityConnectionFlag", "0");
|
// jsonObject.put("unityConnectionFlag", "0");
|
||||||
webSession.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
// webSession.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
setU3DStatus(databaseName, false);
|
// setU3DStatus(databaseName, false);
|
||||||
// 把网页端的sessionStatus置为false
|
// // 把网页端的sessionStatus置为false
|
||||||
setWebStatus(databaseName, false);
|
// setWebStatus(databaseName, false);
|
||||||
}
|
// }
|
||||||
}else {
|
// }else {
|
||||||
// 告知u3d,网页端尚未初始化
|
// // 告知u3d,网页端尚未初始化
|
||||||
WebSocketSession u3dSession = u3DDbSessionMap.get(databaseName);
|
// WebSocketSession u3dSession = u3DDbSessionMap.get(databaseName);
|
||||||
JSONObject msg = new JSONObject();
|
// JSONObject msg = new JSONObject();
|
||||||
msg.put("msgType","connectionMsg");
|
// msg.put("msgType","connectionMsg");
|
||||||
msg.put("msg","网页端尚未初始化,无法发送连接请求消息");
|
// msg.put("msg","网页端尚未初始化,无法发送连接请求消息");
|
||||||
u3dSession.sendMessage(new TextMessage(msg.toJSONString().getBytes()));
|
// u3dSession.sendMessage(new TextMessage(msg.toJSONString().getBytes()));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public WebSocketSession getUnitySession(String databaseName) {
|
// public WebSocketSession getUnitySession(String databaseName) {
|
||||||
return u3DDbSessionMap.getOrDefault(databaseName, null);
|
// return u3DDbSessionMap.getOrDefault(databaseName, null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setU3DStatus(String dbName, boolean status) {
|
// public void setU3DStatus(String dbName, boolean status) {
|
||||||
WebSocketSession webSocketSession = u3DDbSessionMap.get(dbName);
|
// WebSocketSession webSocketSession = u3DDbSessionMap.get(dbName);
|
||||||
u3DStatusMap.put(webSocketSession, status);
|
// u3DStatusMap.put(webSocketSession, status);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public boolean getUnityConnectionStatus(String dbName) {
|
// public boolean getUnityConnectionStatus(String dbName) {
|
||||||
return u3DStatusMap.getOrDefault(u3DDbSessionMap.get(dbName),false);
|
// return u3DStatusMap.getOrDefault(u3DDbSessionMap.get(dbName),false);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// web端请求unity端连接或断开连接
|
// // web端请求unity端连接或断开连接
|
||||||
public void sendWebRequestConnectionMsg(String patientName,String idNum, String date,String databaseName, String flag) throws IOException {
|
// public void sendWebRequestConnectionMsg(String patientName,String idNum, String date,String databaseName, String flag) throws IOException {
|
||||||
WebSocketSession unitySession = getUnitySession(databaseName);
|
// WebSocketSession unitySession = getUnitySession(databaseName);
|
||||||
JSONObject jsonObject = new JSONObject();
|
// JSONObject jsonObject = new JSONObject();
|
||||||
if (unitySession != null) {
|
// if (unitySession != null) {
|
||||||
if ("1".equals(flag)) {
|
// if ("1".equals(flag)) {
|
||||||
jsonObject.put("patientName",patientName);
|
// jsonObject.put("patientName",patientName);
|
||||||
jsonObject.put("idNum",idNum);
|
// jsonObject.put("idNum",idNum);
|
||||||
jsonObject.put("date",date);
|
// jsonObject.put("date",date);
|
||||||
jsonObject.put("msgType", "webRequestConnection");
|
// jsonObject.put("msgType", "webRequestConnection");
|
||||||
jsonObject.put("webConnectionFlag", "1");
|
// jsonObject.put("webConnectionFlag", "1");
|
||||||
unitySession.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
// unitySession.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
setWebStatus(databaseName,true);
|
// setWebStatus(databaseName,true);
|
||||||
}
|
// }
|
||||||
if ("0".equals(flag)) {
|
// if ("0".equals(flag)) {
|
||||||
jsonObject.put("patientName",patientName);
|
// jsonObject.put("patientName",patientName);
|
||||||
jsonObject.put("idNum",idNum);
|
// jsonObject.put("idNum",idNum);
|
||||||
jsonObject.put("date",date);
|
// jsonObject.put("date",date);
|
||||||
jsonObject.put("msgType", "webRequestConnection");
|
// jsonObject.put("msgType", "webRequestConnection");
|
||||||
jsonObject.put("webConnectionFlag", "0");
|
// jsonObject.put("webConnectionFlag", "0");
|
||||||
unitySession.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
// unitySession.sendMessage(new TextMessage(jsonObject.toJSONString().getBytes()));
|
||||||
setU3DStatus(databaseName, false);
|
// setU3DStatus(databaseName, false);
|
||||||
setWebStatus(databaseName, false);
|
// setWebStatus(databaseName, false);
|
||||||
}
|
// }
|
||||||
}else {
|
// }else {
|
||||||
// 告知网页端U3d尚未初始化
|
// // 告知网页端U3d尚未初始化
|
||||||
WebSocketSession webSocketSession = webDbSessionMap.get(databaseName);
|
// WebSocketSession webSocketSession = webDbSessionMap.get(databaseName);
|
||||||
JSONObject msg = new JSONObject();
|
// JSONObject msg = new JSONObject();
|
||||||
msg.put("msgType","connectionMsg");
|
// msg.put("msgType","connectionMsg");
|
||||||
msg.put("msg","客户端尚未初始化,无法发送连接请求消息");
|
// msg.put("msg","客户端尚未初始化,无法发送连接请求消息");
|
||||||
webSocketSession.sendMessage(new TextMessage(msg.toJSONString().getBytes()));
|
// webSocketSession.sendMessage(new TextMessage(msg.toJSONString().getBytes()));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void sendConnectionResponseToUnity(String patientName,String idNum,String date,String databaseName, String flag) throws IOException {
|
// public void sendConnectionResponseToUnity(String patientName,String idNum,String date,String databaseName, String flag) throws IOException {
|
||||||
WebSocketSession unitySession = getUnitySession(databaseName);
|
// WebSocketSession unitySession = getUnitySession(databaseName);
|
||||||
if (unitySession != null) {
|
// if (unitySession != null) {
|
||||||
JSONObject unityMsg = new JSONObject();
|
// JSONObject unityMsg = new JSONObject();
|
||||||
if ("1".equals(flag)) {
|
// if ("1".equals(flag)) {
|
||||||
unityMsg.put("msgType", "webResponseConnection");
|
// unityMsg.put("msgType", "webResponseConnection");
|
||||||
unityMsg.put("webConnectionFlag", "1");
|
// unityMsg.put("webConnectionFlag", "1");
|
||||||
unityMsg.put("patientName", patientName);
|
// unityMsg.put("patientName", patientName);
|
||||||
unityMsg.put("idNum", idNum);
|
// unityMsg.put("idNum", idNum);
|
||||||
unityMsg.put("date", date);
|
// unityMsg.put("date", date);
|
||||||
unitySession.sendMessage(new TextMessage(unityMsg.toJSONString().getBytes()));
|
// unitySession.sendMessage(new TextMessage(unityMsg.toJSONString().getBytes()));
|
||||||
// 网页端同意连接
|
// // 网页端同意连接
|
||||||
setWebStatus(databaseName, true);
|
// setWebStatus(databaseName, true);
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
if ("0".equals(flag)) {
|
// if ("0".equals(flag)) {
|
||||||
// 网页端拒绝连接
|
// // 网页端拒绝连接
|
||||||
setWebStatus(databaseName, false);
|
// setWebStatus(databaseName, false);
|
||||||
unityMsg = new JSONObject();
|
// unityMsg = new JSONObject();
|
||||||
unityMsg.put("msgType", "webResponseConnection");
|
// unityMsg.put("msgType", "webResponseConnection");
|
||||||
unityMsg.put("webConnectionFlag", "0");
|
// unityMsg.put("webConnectionFlag", "0");
|
||||||
unityMsg.put("patientName", patientName);
|
// unityMsg.put("patientName", patientName);
|
||||||
unityMsg.put("idNum", idNum);
|
// unityMsg.put("idNum", idNum);
|
||||||
unityMsg.put("date", date);
|
// unityMsg.put("date", date);
|
||||||
unitySession.sendMessage(new TextMessage(unityMsg.toJSONString().getBytes()));
|
// unitySession.sendMessage(new TextMessage(unityMsg.toJSONString().getBytes()));
|
||||||
// 把unity的sessionStatus置为false
|
// // 把unity的sessionStatus置为false
|
||||||
setU3DStatus(databaseName, false);
|
// setU3DStatus(databaseName, false);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
// 告知网页端U3d尚未初始化
|
// // 告知网页端U3d尚未初始化
|
||||||
WebSocketSession webSocketSession = webDbSessionMap.get(databaseName);
|
// WebSocketSession webSocketSession = webDbSessionMap.get(databaseName);
|
||||||
webSocketSession.sendMessage(new TextMessage("U3d尚未初始化,无法发送连接响应消息".getBytes()));
|
// webSocketSession.sendMessage(new TextMessage("U3d尚未初始化,无法发送连接响应消息".getBytes()));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setWebStatus(String dbName, Boolean status) {
|
// public void setWebStatus(String dbName, Boolean status) {
|
||||||
WebSocketSession webSocketSession = webDbSessionMap.get(dbName);
|
// WebSocketSession webSocketSession = webDbSessionMap.get(dbName);
|
||||||
webStatusMap.put(webSocketSession, status);
|
// webStatusMap.put(webSocketSession, status);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public boolean getWebConnectionStatus(String dbName) {
|
// public boolean getWebConnectionStatus(String dbName) {
|
||||||
return webStatusMap.getOrDefault(webDbSessionMap.get(dbName),false);
|
// return webStatusMap.getOrDefault(webDbSessionMap.get(dbName),false);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public WebSocketSession getWebSession(String databaseName) {
|
// public WebSocketSession getWebSession(String databaseName) {
|
||||||
return webDbSessionMap.getOrDefault(databaseName, null);
|
// return webDbSessionMap.getOrDefault(databaseName, null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void initWeb(String databaseName, WebSocketSession session) {
|
// public void initWeb(String databaseName, WebSocketSession session) {
|
||||||
webDbSessionMap.put(databaseName, session);
|
// webDbSessionMap.put(databaseName, session);
|
||||||
webStatusMap.put(session, false);
|
// webStatusMap.put(session, false);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void initUnity(String databaseName, WebSocketSession session) {
|
// public void initUnity(String databaseName, WebSocketSession session) {
|
||||||
u3DDbSessionMap.put(databaseName, session);
|
// u3DDbSessionMap.put(databaseName, session);
|
||||||
u3DStatusMap.put(session, false);
|
// u3DStatusMap.put(session, false);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public boolean isReady(String databaseName) {
|
// public boolean isReady(String databaseName) {
|
||||||
return getUnityConnectionStatus(databaseName) && getWebConnectionStatus(databaseName);
|
// return getUnityConnectionStatus(databaseName) && getWebConnectionStatus(databaseName);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void closeConnection(WebSocketSession session) {
|
// public void closeConnection(WebSocketSession session) {
|
||||||
webDbSessionMap.values().remove(session);
|
// webDbSessionMap.values().remove(session);
|
||||||
webStatusMap.remove(session);
|
// webStatusMap.remove(session);
|
||||||
u3DDbSessionMap.values().remove(session);
|
// u3DDbSessionMap.values().remove(session);
|
||||||
u3DStatusMap.remove(session);
|
// u3DStatusMap.remove(session);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,202 +1,202 @@
|
||||||
package com.rax.vital.v2.timer;
|
//package com.rax.vital.v2.timer;
|
||||||
|
//
|
||||||
import com.alibaba.fastjson.JSONObject;
|
//import com.alibaba.fastjson.JSONObject;
|
||||||
import com.rax.vital.common.datasource.CustomDataSource;
|
//import com.rax.vital.common.datasource.CustomDataSource;
|
||||||
import com.rax.vital.common.datasource.MongoDBSource;
|
//import com.rax.vital.common.datasource.MongoDBSource;
|
||||||
import com.rax.vital.v2.medicine.dto.MedicineDTO;
|
//import com.rax.vital.v2.medicine.dto.MedicineDTO;
|
||||||
import com.rax.vital.v2.medicine.service.AIMedicineService;
|
//import com.rax.vital.v2.medicine.service.AIMedicineService;
|
||||||
import com.rax.vital.v2.medicine.service.DoctorMedicineService;
|
//import com.rax.vital.v2.medicine.service.DoctorMedicineService;
|
||||||
import com.rax.vital.v2.medicine.service.FlagService;
|
//import com.rax.vital.v2.medicine.service.FlagService;
|
||||||
import com.rax.vital.v2.medicine.service.SurgeryServiceV2;
|
//import com.rax.vital.v2.medicine.service.SurgeryServiceV2;
|
||||||
import lombok.RequiredArgsConstructor;
|
//import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
//import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
//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.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.socket.TextMessage;
|
//import org.springframework.web.socket.TextMessage;
|
||||||
import org.springframework.web.socket.WebSocketMessage;
|
//import org.springframework.web.socket.WebSocketMessage;
|
||||||
import org.springframework.web.socket.WebSocketSession;
|
//import org.springframework.web.socket.WebSocketSession;
|
||||||
|
//
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.util.*;
|
//import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
//import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* project_name: remote-control-backend
|
// * project_name: remote-control-backend
|
||||||
* time: 2024/8/20 15:09
|
// * time: 2024/8/20 15:09
|
||||||
* author: republicline
|
// * author: republicline
|
||||||
* 新的计时器任务, 用于推送生命体征数据和药物信息数据到前端
|
// * 新的计时器任务, 用于推送生命体征数据和药物信息数据到前端
|
||||||
*/
|
// */
|
||||||
@RefreshScope
|
//@RefreshScope
|
||||||
@Component
|
//@Component
|
||||||
@RequiredArgsConstructor
|
//@RequiredArgsConstructor
|
||||||
public class VitalSignTimerV2 {
|
//public class VitalSignTimerV2 {
|
||||||
// MongoDB的地址
|
// // MongoDB的地址
|
||||||
@Value("${vital-sign.mongodb.host}")
|
// @Value("${vital-sign.mongodb.host}")
|
||||||
private String mongoDBHost;
|
// private String mongoDBHost;
|
||||||
|
//
|
||||||
// MongoDB的用户名
|
// // MongoDB的用户名
|
||||||
@Value("${vital-sign.mongodb.username}")
|
// @Value("${vital-sign.mongodb.username}")
|
||||||
private String mongoUsername;
|
// private String mongoUsername;
|
||||||
|
//
|
||||||
// MongoDB的用户的密码
|
// // MongoDB的用户的密码
|
||||||
@Value("${vital-sign.mongodb.password}")
|
// @Value("${vital-sign.mongodb.password}")
|
||||||
private String mongoPassword;
|
// private String mongoPassword;
|
||||||
|
//
|
||||||
private final SurgeryServiceV2 surgeryServiceV2;
|
// private final SurgeryServiceV2 surgeryServiceV2;
|
||||||
|
//
|
||||||
private final AIMedicineService aiMedicineService;
|
// private final AIMedicineService aiMedicineService;
|
||||||
|
//
|
||||||
private final AIMedicineTimer aiMedicineTimer;
|
// private final AIMedicineTimer aiMedicineTimer;
|
||||||
|
//
|
||||||
private final DoctorMedicineService doctorMedicineService;
|
// private final DoctorMedicineService doctorMedicineService;
|
||||||
|
//
|
||||||
private final FlagService flagService;
|
// private final FlagService flagService;
|
||||||
|
//
|
||||||
// 定时任务容器
|
// // 定时任务容器
|
||||||
private static final Map<String, TimerTask> timerTaskMap = new ConcurrentHashMap<>();
|
// private static final Map<String, TimerTask> timerTaskMap = new ConcurrentHashMap<>();
|
||||||
|
//
|
||||||
// 主控人员容器, 建立连接放入存值,生命体征信息 key:数据库名 value:网页解析的token用户名
|
// // 主控人员容器, 建立连接放入存值,生命体征信息 key:数据库名 value:网页解析的token用户名
|
||||||
private static final Map<String, String> masterControlMap = new ConcurrentHashMap<>();
|
// private static final Map<String, String> masterControlMap = new ConcurrentHashMap<>();
|
||||||
|
//
|
||||||
// 链接工具类容器 ket, 主要用于关闭数据库连接
|
// // 链接工具类容器 ket, 主要用于关闭数据库连接
|
||||||
private static final Map<String, CustomDataSource> dataSourceMap = new ConcurrentHashMap<>();
|
// private static final Map<String, CustomDataSource> dataSourceMap = new ConcurrentHashMap<>();
|
||||||
|
//
|
||||||
|
//
|
||||||
// 推送生命体征数据和药物信息数据
|
// // 推送生命体征数据和药物信息数据
|
||||||
public void sendMedicalMessage(String database, String username, WebSocketSession session) {
|
// public void sendMedicalMessage(String database, String username, WebSocketSession session) {
|
||||||
if (!masterControlMap.containsKey(database)) {
|
// if (!masterControlMap.containsKey(database)) {
|
||||||
masterControlMap.put(database, username);
|
// masterControlMap.put(database, username);
|
||||||
}
|
// }
|
||||||
String sessionId = session.getId();
|
// String sessionId = session.getId();
|
||||||
|
//
|
||||||
TimerTask task = timerTaskMap.get(sessionId);
|
// TimerTask task = timerTaskMap.get(sessionId);
|
||||||
if (task != null) {
|
// if (task != null) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
CustomDataSource dataSource = dataSourceMap.get(sessionId);
|
// CustomDataSource dataSource = dataSourceMap.get(sessionId);
|
||||||
if (dataSource == null) {
|
// if (dataSource == null) {
|
||||||
dataSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, database);
|
// dataSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, database);
|
||||||
dataSourceMap.put(sessionId, dataSource);
|
// dataSourceMap.put(sessionId, dataSource);
|
||||||
dataSource.open();
|
// dataSource.open();
|
||||||
}
|
// }
|
||||||
CustomDataSource finalMongoDBSource = dataSource;
|
// CustomDataSource finalMongoDBSource = dataSource;
|
||||||
TimerTask timerTask = new TimerTask() {
|
// TimerTask timerTask = new TimerTask() {
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
|
//
|
||||||
MongoTemplate template = finalMongoDBSource.getConnection();
|
// MongoTemplate template = finalMongoDBSource.getConnection();
|
||||||
JSONObject jsonObject = new JSONObject();
|
// JSONObject jsonObject = new JSONObject();
|
||||||
// 生命体征信息
|
// // 生命体征信息
|
||||||
List vitalSignsList = surgeryServiceV2.getVitalSignsList(template);
|
// List vitalSignsList = surgeryServiceV2.getVitalSignsList(template);
|
||||||
jsonObject.put("vitalSignsList", vitalSignsList);
|
// jsonObject.put("vitalSignsList", vitalSignsList);
|
||||||
|
//
|
||||||
// 标记信息
|
// // 标记信息
|
||||||
Map flags = flagService.getFlags(template);
|
// Map flags = flagService.getFlags(template);
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* flag
|
// * flag
|
||||||
* aiFlag 1代表AI给药 0代表医生给药
|
// * aiFlag 1代表AI给药 0代表医生给药
|
||||||
* reFlag 1代表维持期 0代表诱导期
|
// * reFlag 1代表维持期 0代表诱导期
|
||||||
* endFlag 1代表手术进行 0代表手术结束
|
// * endFlag 1代表手术进行 0代表手术结束
|
||||||
* linkFlag 1泵异常 0正常
|
// * linkFlag 1泵异常 0正常
|
||||||
*/
|
// */
|
||||||
jsonObject.put("flags", flags);
|
// jsonObject.put("flags", flags);
|
||||||
Map<String, Object> medicineRateMap = new HashMap<>();
|
// Map<String, Object> medicineRateMap = new HashMap<>();
|
||||||
if (flags.get("aiFlag") != null && flags.get("aiFlag").equals("1")) {
|
// if (flags.get("aiFlag") != null && flags.get("aiFlag").equals("1")) {
|
||||||
// ai给药信息
|
// // ai给药信息
|
||||||
medicineRateMap = aiMedicineService.getAiMedicine(template);
|
// medicineRateMap = aiMedicineService.getAiMedicine(template);
|
||||||
} else if (flags.get("aiFlag") != null && flags.get("aiFlag").equals("0")) {
|
// } else if (flags.get("aiFlag") != null && flags.get("aiFlag").equals("0")) {
|
||||||
// 医生给药信息
|
// // 医生给药信息
|
||||||
medicineRateMap = doctorMedicineService.getDocMedicine(template);
|
// medicineRateMap = doctorMedicineService.getDocMedicine(template);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ArrayList<MedicineDTO> medicineList = new ArrayList<>(8);
|
// ArrayList<MedicineDTO> medicineList = new ArrayList<>(8);
|
||||||
medicineList.add(new MedicineDTO("1", "丙泊酚", "0", "0"));
|
// medicineList.add(new MedicineDTO("1", "丙泊酚", "0", "0"));
|
||||||
medicineList.add(new MedicineDTO("2", "舒芬太尼", "0", "0"));
|
// medicineList.add(new MedicineDTO("2", "舒芬太尼", "0", "0"));
|
||||||
medicineList.add(new MedicineDTO("3", "瑞芬太尼", "0", "0"));
|
// medicineList.add(new MedicineDTO("3", "瑞芬太尼", "0", "0"));
|
||||||
medicineList.add(new MedicineDTO("4", "顺阿曲库胺", "0", "0"));
|
// medicineList.add(new MedicineDTO("4", "顺阿曲库胺", "0", "0"));
|
||||||
medicineList.add(new MedicineDTO("5", "尼卡地平", "0", "0"));
|
// medicineList.add(new MedicineDTO("5", "尼卡地平", "0", "0"));
|
||||||
medicineList.add(new MedicineDTO("6", "艾司洛尔", "0", "0"));
|
// medicineList.add(new MedicineDTO("6", "艾司洛尔", "0", "0"));
|
||||||
medicineList.add(new MedicineDTO("7", "麻黄素", "0", "0"));
|
// medicineList.add(new MedicineDTO("7", "麻黄素", "0", "0"));
|
||||||
medicineList.add(new MedicineDTO("8", "阿托品", "0", "0"));
|
// medicineList.add(new MedicineDTO("8", "阿托品", "0", "0"));
|
||||||
|
//
|
||||||
if (medicineRateMap != null && !medicineRateMap.isEmpty()) {
|
// if (medicineRateMap != null && !medicineRateMap.isEmpty()) {
|
||||||
for (String key : medicineRateMap.keySet()) {
|
// for (String key : medicineRateMap.keySet()) {
|
||||||
for (MedicineDTO medicineDTO : medicineList) {
|
// for (MedicineDTO medicineDTO : medicineList) {
|
||||||
if (medicineDTO.getMedicineName().equals(key)) {
|
// if (medicineDTO.getMedicineName().equals(key)) {
|
||||||
medicineDTO.setMedicineRate(medicineRateMap.get(key).toString());
|
// medicineDTO.setMedicineRate(medicineRateMap.get(key).toString());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
jsonObject.put("rateModTime", medicineRateMap.get("Time"));
|
// jsonObject.put("rateModTime", medicineRateMap.get("Time"));
|
||||||
} else {
|
// } else {
|
||||||
jsonObject.put("rateModTime", "0");
|
// jsonObject.put("rateModTime", "0");
|
||||||
}
|
// }
|
||||||
// 总的药量信息
|
// // 总的药量信息
|
||||||
Map<String, Object> countMedicineMap = aiMedicineService.getCountMedicine(template);
|
// Map<String, Object> countMedicineMap = aiMedicineService.getCountMedicine(template);
|
||||||
if (countMedicineMap != null && !countMedicineMap.isEmpty()) {
|
// if (countMedicineMap != null && !countMedicineMap.isEmpty()) {
|
||||||
for (String key : countMedicineMap.keySet()) {
|
// for (String key : countMedicineMap.keySet()) {
|
||||||
for (MedicineDTO medicineDTO : medicineList) {
|
// for (MedicineDTO medicineDTO : medicineList) {
|
||||||
if ((medicineDTO.getMedicineName() + "Sum").equals(key)) {
|
// if ((medicineDTO.getMedicineName() + "Sum").equals(key)) {
|
||||||
medicineDTO.setMedicineRate(countMedicineMap.get(key).toString());
|
// medicineDTO.setMedicineRate(countMedicineMap.get(key).toString());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
jsonObject.put("medicineList", medicineList);
|
// jsonObject.put("medicineList", medicineList);
|
||||||
jsonObject.put("msgType", "msg");
|
// jsonObject.put("msgType", "msg");
|
||||||
// 如果是人工给药展示人工给药的内容
|
// // 如果是人工给药展示人工给药的内容
|
||||||
WebSocketMessage message = new TextMessage(jsonObject.toJSONString().getBytes());
|
// WebSocketMessage message = new TextMessage(jsonObject.toJSONString().getBytes());
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
session.sendMessage(message);
|
// session.sendMessage(message);
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
// throw new RuntimeException(e);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
// 定时任务,设置1秒
|
// // 定时任务,设置1秒
|
||||||
Timer timer = new Timer();
|
// Timer timer = new Timer();
|
||||||
timer.schedule(timerTask, 0, 2000);
|
// timer.schedule(timerTask, 0, 2000);
|
||||||
timerTaskMap.put(sessionId, timerTask);
|
// timerTaskMap.put(sessionId, timerTask);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
// 发送给药数据到unity
|
// // 发送给药数据到unity
|
||||||
public void sendMedicalMessageToUnity(String database, String username, WebSocketSession session, String flag, String medicine, String value) throws IOException {
|
// public void sendMedicalMessageToUnity(String database, String username, WebSocketSession session, String flag, String medicine, String value) throws IOException {
|
||||||
JSONObject result = new JSONObject();
|
// JSONObject result = new JSONObject();
|
||||||
if (masterControlMap.containsKey(database) && masterControlMap.get(database).equals(username)) {
|
// if (masterControlMap.containsKey(database) && masterControlMap.get(database).equals(username)) {
|
||||||
// 给药到unity
|
// // 给药到unity
|
||||||
WebSocketSession unitySession = aiMedicineTimer.getUnitySession(database);
|
// WebSocketSession unitySession = aiMedicineTimer.getUnitySession(database);
|
||||||
result.put("medicine", medicine);
|
// result.put("medicine", medicine);
|
||||||
result.put("value", value);
|
// result.put("value", value);
|
||||||
result.put("flag", flag);
|
// result.put("flag", flag);
|
||||||
result.put("msgType", "addMedicine");
|
// result.put("msgType", "addMedicine");
|
||||||
unitySession.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
// unitySession.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||||
} else {
|
// } else {
|
||||||
result.put("flag", flag);
|
// result.put("flag", flag);
|
||||||
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");
|
// result.put("msgType", "msg");
|
||||||
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
// session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 指定停止定时任务
|
// // 指定停止定时任务
|
||||||
public void stopTimerTask(String sessionId) {
|
// public void stopTimerTask(String sessionId) {
|
||||||
TimerTask timerTask = timerTaskMap.get(sessionId);
|
// TimerTask timerTask = timerTaskMap.get(sessionId);
|
||||||
if (timerTask != null) {
|
// if (timerTask != null) {
|
||||||
timerTask.cancel();
|
// timerTask.cancel();
|
||||||
CustomDataSource dataSource = dataSourceMap.get(sessionId);
|
// CustomDataSource dataSource = dataSourceMap.get(sessionId);
|
||||||
dataSource.close();
|
// dataSource.close();
|
||||||
timerTaskMap.remove(sessionId);
|
// timerTaskMap.remove(sessionId);
|
||||||
dataSourceMap.remove(sessionId);
|
// dataSourceMap.remove(sessionId);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
server:
|
||||||
|
port: 6679
|
||||||
|
servlet:
|
||||||
|
context-path: /admin
|
||||||
|
address: 0.0.0.0
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
# 定时任务属性配置
|
# 定时任务属性配置
|
||||||
quartz:
|
quartz:
|
||||||
|
@ -39,10 +45,12 @@ spring:
|
||||||
username: root
|
username: root
|
||||||
password: Xg137839
|
password: Xg137839
|
||||||
# 一期
|
# 一期
|
||||||
|
# url: jdbc:mysql://localhost:3306/rax_backend1?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&nullCatalogMeansCurrent=true
|
||||||
url: jdbc:mysql://110.41.142.124:3306/rax_backend1?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&nullCatalogMeansCurrent=true
|
url: jdbc:mysql://110.41.142.124:3306/rax_backend1?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&nullCatalogMeansCurrent=true
|
||||||
data:
|
data:
|
||||||
redis:
|
redis:
|
||||||
host: 110.41.142.124
|
host: 110.41.142.124
|
||||||
|
# host: localhost
|
||||||
port: 16373
|
port: 16373
|
||||||
password: rax137839
|
password: rax137839
|
||||||
connect-timeout: 5000
|
connect-timeout: 5000
|
||||||
|
@ -96,13 +104,13 @@ mybatis-plus:
|
||||||
|
|
||||||
|
|
||||||
vital-sign:
|
vital-sign:
|
||||||
except-database: admin,config,local
|
|
||||||
information-database: information
|
|
||||||
mongodb:
|
mongodb:
|
||||||
host: 110.41.142.124:27017
|
host: localhost
|
||||||
password: Xg137839mg
|
port: 27017
|
||||||
username: useradmin
|
username: xxx
|
||||||
|
password: xxx
|
||||||
|
except-database: admin,config
|
||||||
|
information-database: adaw
|
||||||
mysql:
|
mysql:
|
||||||
host: 110.41.142.124:3306
|
host: 110.41.142.124:3306
|
||||||
password: Xg137839
|
password: Xg137839
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: application-loc.yml
|
active: loc
|
||||||
|
|
||||||
|
|
||||||
server:
|
|
||||||
port: 6379
|
|
||||||
servlet:
|
|
||||||
context-path: /admin
|
|
||||||
|
|
||||||
gateway:
|
gateway:
|
||||||
# 前端密码登录解密密钥,和前端 .env 保存一致(16位)
|
# 前端密码登录解密密钥,和前端 .env 保存一致(16位)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user