mirror of
https://gitee.com/republicline/rax-remote-v2.git
synced 2025-08-24 06:04:57 +08:00
fixed: 修正生命体征这部分的返回json内容,便于处理
This commit is contained in:
parent
39341f6c20
commit
9b2daf8452
1
pom.xml
1
pom.xml
|
@ -98,7 +98,6 @@
|
|||
<module>upms</module>
|
||||
<!-- 通用模块 -->
|
||||
<module>common</module>
|
||||
|
||||
<module>daily-plan</module>
|
||||
</modules>
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
|
||||
import org.springframework.web.socket.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
|
@ -26,7 +27,7 @@ public class AddMedicineHandler implements WebSocketHandler {
|
|||
private OAuth2AuthorizationService authorizationService;
|
||||
|
||||
// 发送心跳任务的定时任务容器
|
||||
private Map<String, ScheduledExecutorService> timerTaskMap = new ConcurrentHashMap();
|
||||
private Map<String, ScheduledExecutorService> timerTaskMap = new ConcurrentHashMap<>();
|
||||
|
||||
@Autowired
|
||||
private AIMedicineTimer aiMedicineTimer;
|
||||
|
@ -38,6 +39,7 @@ public class AddMedicineHandler implements WebSocketHandler {
|
|||
startHeartbeat(session);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
|
||||
// String decode = URLDecoder.decode(session.getUri().getQuery());
|
||||
|
@ -61,6 +63,20 @@ public class AddMedicineHandler implements WebSocketHandler {
|
|||
aiMedicineTimer.initWeb(databaseName, session);
|
||||
vitalSignTimerWS.initWeb(databaseName, session);
|
||||
}
|
||||
|
||||
// 处理网页端接收到消息后的相应内容
|
||||
if ("webResponseConnection".equals(msgType)) {
|
||||
String webConnectionFlag = jsonObject.getString("webConnectionFlag");
|
||||
// 给unity端发送网页端拒绝连接
|
||||
aiMedicineTimer.sendConnectionResponseToUnity(patientName,idNum,date,databaseName, webConnectionFlag);
|
||||
}
|
||||
|
||||
// 处理web端请求或断开连接
|
||||
if ("webRequestConnection".equals(msgType)) {
|
||||
String webRequestFlag = jsonObject.getString("webConnectionFlag");
|
||||
aiMedicineTimer.sendWebRequestConnectionMsg(patientName,idNum,date,databaseName, webRequestFlag);
|
||||
}
|
||||
|
||||
if (aiMedicineTimer.getUnitySession(databaseName) != null) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("msg", "unity端已登录");
|
||||
|
@ -84,28 +100,26 @@ public class AddMedicineHandler implements WebSocketHandler {
|
|||
}
|
||||
}
|
||||
|
||||
// 处理网页端接收到消息后的相应内容
|
||||
if ("webResponseConnection".equals(msgType)) {
|
||||
String webConnectionFlag = jsonObject.getString("webConnectionFlag");
|
||||
// 给unity端发送网页端拒绝连接
|
||||
aiMedicineTimer.sendConnectionResponseToUnity(patientName,idNum,date,databaseName, webConnectionFlag);
|
||||
}
|
||||
|
||||
// 处理web端请求或断开连接
|
||||
if ("webRequestConnection".equals(msgType)) {
|
||||
String webRequestFlag = jsonObject.getString("webConnectionFlag");
|
||||
aiMedicineTimer.sendWebRequestConnectionMsg(patientName,idNum,date,databaseName, webRequestFlag);
|
||||
}
|
||||
|
||||
// 处理发送给药相关
|
||||
if ("addMedicine".equals(msgType) && aiMedicineTimer.getWebSession(databaseName) != null && aiMedicineTimer.getUnitySession(databaseName) != null
|
||||
&& aiMedicineTimer.isReady(databaseName)) {
|
||||
// todo 注意修改
|
||||
// flag 1 代表人工给药, 0代表AI给药
|
||||
// flag 0 代表人工给药, 1代表AI给药
|
||||
vitalSignTimerWS.changeWSAIFlag(databaseName, "admin", session, jsonObject.getString("flag"),
|
||||
jsonObject.getString("medicine"), jsonObject.getString("value"));
|
||||
|
||||
}
|
||||
|
||||
// 展示网页端延迟信息
|
||||
if ("ping".equals(msgType)) {
|
||||
Long timeStamp = jsonObject.getLong("msg");
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("msgType", "pong");
|
||||
// 当前时间戳
|
||||
result.put("msg", new Date().getTime() - timeStamp);
|
||||
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,7 +158,7 @@ public class AddMedicineHandler implements WebSocketHandler {
|
|||
e.printStackTrace();
|
||||
stopHeartbeat(session);
|
||||
}
|
||||
}, 0, 10, TimeUnit.SECONDS);
|
||||
}, 0, 30, TimeUnit.SECONDS);
|
||||
timerTaskMap.put(session.getId(), heartbeatExecutor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,11 @@ import com.rax.vital.timer.AIMedicineTimer;
|
|||
import com.rax.vital.timer.VitalSignTimerWS;
|
||||
import com.rax.vital.util.DatabaseNameUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.joda.time.LocalDateTime;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.socket.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
|
@ -82,12 +84,12 @@ public class MachineFeedbackHandler implements WebSocketHandler {
|
|||
|
||||
if (aiMedicineTimer.getWebSession(databaseName) != null) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("msg", "网站端已登录");
|
||||
result.put("msg", "网页端已登录");
|
||||
result.put("msgType", "msg");
|
||||
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||
} else {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("msg", "网站端未登录");
|
||||
result.put("msg", "网页端未登录");
|
||||
result.put("msgType", "msg");
|
||||
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||
}
|
||||
|
@ -108,6 +110,28 @@ public class MachineFeedbackHandler implements WebSocketHandler {
|
|||
&& aiMedicineTimer.isReady(databaseName)) {
|
||||
vitalSignTimerWS.sendMachineFlag(databaseName, code, session);
|
||||
}
|
||||
|
||||
// 展示unity端延迟信息
|
||||
if ("ping".equals(msgType)) {
|
||||
Long timeStamp = jsonObject.getLong("msg");
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("msgType", "pong");
|
||||
// 当前时间戳
|
||||
result.put("msg", new Date().getTime() - timeStamp);
|
||||
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||
}
|
||||
|
||||
// unity收到给药信息后回复把此消息推送给web
|
||||
if ("getMedicine".equals(msgType)) {
|
||||
JSONObject getMedicineMsg = new JSONObject();
|
||||
getMedicineMsg.put("msgType", "getMedicine");
|
||||
getMedicineMsg.put("patientName", patientName);
|
||||
getMedicineMsg.put("idNum", idNum);
|
||||
getMedicineMsg.put("date", date);
|
||||
getMedicineMsg.put(jsonObject.getString("medicine"), jsonObject.getString("value"));
|
||||
WebSocketSession webSession = aiMedicineTimer.getWebSession(databaseName);
|
||||
webSession.sendMessage(new TextMessage(getMedicineMsg.toJSONString().getBytes()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -147,7 +171,7 @@ public class MachineFeedbackHandler implements WebSocketHandler {
|
|||
e.printStackTrace();
|
||||
stopHeartbeat(session);
|
||||
}
|
||||
}, 0, 10, TimeUnit.SECONDS);
|
||||
}, 0, 30, TimeUnit.SECONDS);
|
||||
timerTaskMap.put(session.getId(), heartbeatExecutor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,9 +46,7 @@ public class MedicineHandler implements WebSocketHandler {
|
|||
String patientName = jsonObject.getString("patientName");
|
||||
String idNum = jsonObject.getString("idNum");
|
||||
String date = jsonObject.getString("date");
|
||||
System.out.println("medicineHandler-jsonObject = " + jsonObject.toJSONString());
|
||||
String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||
System.out.println("medicineHandler-databaseName = " + databaseName);
|
||||
vitalSignTimerWS.createAndSendWSMessageMongo(databaseName, "admin", session);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,30 +66,31 @@ public class MedicineController {
|
|||
vitalSignTimer.createAndSendMessageMongo(databaseName, username, simpSessionId);
|
||||
}
|
||||
|
||||
@MessageMapping("/changeAIFlag")
|
||||
public void changeAIFlag(MessageHeaders messageHeaders, String body) {
|
||||
LinkedMultiValueMap nativeHeaders = (LinkedMultiValueMap) messageHeaders.get("nativeHeaders");
|
||||
ArrayList tokenList = (ArrayList) nativeHeaders.get("token");
|
||||
String token = (String) tokenList.get(0);
|
||||
OAuth2Authorization authorization = authorizationService.findByToken(token, OAuth2TokenType.ACCESS_TOKEN);
|
||||
|
||||
String username = authorization.getPrincipalName();
|
||||
String simpSessionId = messageHeaders.get("simpSessionId", String.class);
|
||||
|
||||
JSONObject params = JSONObject.parseObject(body);
|
||||
// 病人名
|
||||
String patientName = params.getString("patientName");
|
||||
// 病人身份证
|
||||
String idNum = params.getString("idNum");
|
||||
// yyyyMMdd
|
||||
String date = params.getString("date");
|
||||
String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||
vitalSignTimer.changeAIFlag(databaseName, username, simpSessionId, params.getString("flag"),
|
||||
params.getString("medicine"), params.getString("value"));
|
||||
}
|
||||
// @MessageMapping("/changeAIFlag")
|
||||
// public void changeAIFlag(MessageHeaders messageHeaders, String body) {
|
||||
// LinkedMultiValueMap nativeHeaders = (LinkedMultiValueMap) messageHeaders.get("nativeHeaders");
|
||||
// ArrayList tokenList = (ArrayList) nativeHeaders.get("token");
|
||||
// String token = (String) tokenList.get(0);
|
||||
// OAuth2Authorization authorization = authorizationService.findByToken(token, OAuth2TokenType.ACCESS_TOKEN);
|
||||
//
|
||||
// String username = authorization.getPrincipalName();
|
||||
// String simpSessionId = messageHeaders.get("simpSessionId", String.class);
|
||||
//
|
||||
// JSONObject params = JSONObject.parseObject(body);
|
||||
// // 病人名
|
||||
// String patientName = params.getString("patientName");
|
||||
// // 病人身份证
|
||||
// String idNum = params.getString("idNum");
|
||||
// // yyyyMMdd
|
||||
// String date = params.getString("date");
|
||||
// String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||
// vitalSignTimer.changeAIFlag(databaseName, username, simpSessionId, params.getString("flag"),
|
||||
// params.getString("medicine"), params.getString("value"));
|
||||
// }
|
||||
|
||||
@PostMapping("/getPatientInfo")
|
||||
public R getPatientInfo(String patientName, String idNum, String date) {
|
||||
// todo : 存疑
|
||||
String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||
return vitalSignsService.getPatientInfo(databaseName);
|
||||
}
|
||||
|
|
|
@ -15,4 +15,10 @@ public interface AIMedicineService {
|
|||
List<Map> getAIMedicine(Connection connection);
|
||||
|
||||
void changeAIFlagMedicine(MongoTemplate template, String flag, String medicine, String value);
|
||||
|
||||
// 获取累计用药量
|
||||
List getCountMedicine(MongoTemplate template);
|
||||
|
||||
// 获取ai给药信息
|
||||
List getAiMedicine(MongoTemplate template);
|
||||
}
|
||||
|
|
|
@ -164,4 +164,38 @@ public class AIMedicineServiceImpl implements AIMedicineService {
|
|||
template.insert(medicineObj, "doctormedicinetable");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getCountMedicine(MongoTemplate template) {
|
||||
Query query = new Query();
|
||||
query.limit(1);
|
||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
||||
List<Map> aiMedicines = template.find(query, Map.class, "fktable");
|
||||
if (!aiMedicines.isEmpty()) {
|
||||
Map medicine = new HashMap();
|
||||
for (Map map : aiMedicines) {
|
||||
medicine.put("丙泊酚sum", map.get("cumu_1"));
|
||||
medicine.put("舒芬太尼sum", map.get("cumu_2"));
|
||||
medicine.put("瑞芬太尼sum", map.get("cumu_3"));
|
||||
medicine.put("顺阿曲库胺sum", map.get("cumu_4"));
|
||||
medicine.put("尼卡地平sum", map.get("cumu_5"));
|
||||
medicine.put("艾司洛尔sum", map.get("cumu_6"));
|
||||
medicine.put("麻黄素sum", map.get("cumu_7"));
|
||||
medicine.put("阿托品sum", map.get("cumu_8"));
|
||||
medicine.put("Time", map.get("Time"));
|
||||
}
|
||||
aiMedicines.remove(0);
|
||||
aiMedicines.add(medicine);
|
||||
}
|
||||
return aiMedicines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getAiMedicine(MongoTemplate template) {
|
||||
Query query = new Query();
|
||||
query.limit(1);
|
||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
||||
List<Map> aimedicinetable = template.find(query, Map.class, "aimedicinetable");
|
||||
return aimedicinetable;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,13 +37,16 @@ public class FlagServiceImpl implements FlagService {
|
|||
Map flagMap = new HashMap();
|
||||
Query query = new Query();
|
||||
query.limit(1);
|
||||
query.with(Sort.by(Sort.Order.desc("_id")));
|
||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
||||
List<Map> linkTable = template.find(query, Map.class, "linktable");
|
||||
flagMap.put("linktable", linkTable);
|
||||
System.out.println("linkTable = " + linkTable);
|
||||
flagMap.put("linkFlag", linkTable.get(0).get("Flag"));
|
||||
List<Map> aiFlagTable = template.find(query, Map.class, "aiflagtable");
|
||||
flagMap.put("aiflagtable", aiFlagTable);
|
||||
System.out.println("aiFlagTable = " + aiFlagTable);
|
||||
flagMap.put("aiFlag", aiFlagTable.get(0).get("Flag"));
|
||||
List<Map> endFlagTable = template.find(query, Map.class, "endflagtable");
|
||||
flagMap.put("endflagtable", endFlagTable);
|
||||
System.out.println("endFlagTable = " + endFlagTable);
|
||||
flagMap.put("endFlag", endFlagTable.get(0).get("Flag"));
|
||||
return flagMap;
|
||||
}
|
||||
|
||||
|
@ -57,7 +60,6 @@ public class FlagServiceImpl implements FlagService {
|
|||
@Override
|
||||
public Map getFlag(MongoTemplate template) {
|
||||
Map allFlag = new HashMap();
|
||||
|
||||
Query query1 = new Query();
|
||||
query1.limit(1);
|
||||
query1.with(Sort.by(Sort.Order.desc("_id")));
|
||||
|
|
|
@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.bson.BsonRegularExpression;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.data.domain.ScrollPosition;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mongodb.SpringDataMongoDB;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
|
|
|
@ -147,7 +147,7 @@ public class AIMedicineTimer {
|
|||
// 网页端拒绝连接
|
||||
setWebStatus(databaseName, false);
|
||||
unityMsg = new JSONObject();
|
||||
unityMsg.put("msgType", "connection refused");
|
||||
unityMsg.put("msgType", "webResponseConnection");
|
||||
unityMsg.put("webConnectionFlag", "0");
|
||||
unityMsg.put("patientName", patientName);
|
||||
unityMsg.put("idNum", idNum);
|
||||
|
|
|
@ -99,7 +99,7 @@ public class VitalSignTimerWS {
|
|||
dataSourceMap.put(sessionId, dataSource);
|
||||
dataSource.open();
|
||||
}
|
||||
|
||||
System.out.println("mongoDBName = " + database);
|
||||
CustomDataSource finalMongoDBSource = dataSource;
|
||||
TimerTask timerTask = new TimerTask() {
|
||||
@Override
|
||||
|
@ -107,19 +107,38 @@ public class VitalSignTimerWS {
|
|||
|
||||
MongoTemplate template = finalMongoDBSource.getConnection();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
// 生命体征信息
|
||||
List vitalSignsList = vitalSignsService.getVitalSignsList(template);
|
||||
jsonObject.put("vitalSignsList", vitalSignsList);
|
||||
List aiMedicineList = aiMedicineService.getAIMedicine(template);
|
||||
jsonObject.put("aiMedicineList", aiMedicineList);
|
||||
// List docMedicineList = doctorMedicineService.getDocMedicine(template);
|
||||
// jsonObject.put("docMedicineList", docMedicineList);
|
||||
List revulsionList = revulsionService.getRevulsionServiceList(template);
|
||||
jsonObject.put("revulsionList", revulsionList);
|
||||
|
||||
// // 诱导期给药信息
|
||||
// List revulsionList = revulsionService.getRevulsionServiceList(template);
|
||||
// jsonObject.put("revulsionList", revulsionList);
|
||||
// 标记信息
|
||||
Map flags = flagService.getFlags(template);
|
||||
// flag
|
||||
// aiFlag 1代表AI给药 0代表医生给药
|
||||
// reFlag 1代表维持期 0代表诱导期
|
||||
// endFlag 1代表手术进行 0代表手术结束
|
||||
// linkFlag 1泵异常 0正常
|
||||
jsonObject.put("flags", flags);
|
||||
if (flags.get("aiFlag")!= null && flags.get("aiFlag").equals("1")){
|
||||
// ai给药信息
|
||||
List aiMedicineList = aiMedicineService.getAiMedicine(template);
|
||||
jsonObject.put("medicineRate", aiMedicineList);
|
||||
}else if (flags.get("aiFlag")!= null && flags.get("aiFlag").equals("0")){
|
||||
// 医生给药信息
|
||||
List docMedicineList = doctorMedicineService.getDocMedicine(template);
|
||||
jsonObject.put("medicineRate", docMedicineList);
|
||||
}
|
||||
// 总的药量信息
|
||||
List countMedicineList = aiMedicineService.getCountMedicine(template);
|
||||
jsonObject.put("countMedicine", countMedicineList);
|
||||
jsonObject.put("msgType", "msg");
|
||||
|
||||
// 如果是人工给药展示人工给药的内容
|
||||
WebSocketMessage message = new TextMessage(jsonObject.toJSONString().getBytes());
|
||||
|
||||
try {
|
||||
session.sendMessage(message);
|
||||
} catch (IOException e) {
|
||||
|
@ -261,7 +280,7 @@ public class VitalSignTimerWS {
|
|||
}
|
||||
|
||||
public synchronized void setMachineSessionMap(WebSocketSession session) {
|
||||
// machineSessionMap.put(session.getId(), session);
|
||||
machineSessionMap.put(session.getId(), session);
|
||||
}
|
||||
|
||||
public void removeMachineSessionMap(WebSocketSession session) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
active: prod
|
||||
application:
|
||||
name: ${project.artifactId}
|
||||
# 定时任务属性配置
|
||||
|
|
Loading…
Reference in New Issue
Block a user