fixed: 修正生命体征这部分的返回json内容,便于处理
This commit is contained in:
parent
9b2daf8452
commit
ea24609c7e
|
@ -5,7 +5,6 @@ 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.*;
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ public class WSChannelInterceptor implements ChannelInterceptor {
|
|||
@Autowired
|
||||
private OAuth2AuthorizationService authorizationService;
|
||||
|
||||
@Autowired
|
||||
private VitalSignTimer vitalSignTimer;
|
||||
// @Autowired
|
||||
// private VitalSignTimer vitalSignTimer;
|
||||
|
||||
@Autowired
|
||||
private ChatService chatService;
|
||||
|
@ -53,9 +53,9 @@ public class WSChannelInterceptor implements ChannelInterceptor {
|
|||
|
||||
if (StompCommand.DISCONNECT.equals(accessor.getCommand())
|
||||
|| StompCommand.UNSUBSCRIBE.equals(accessor.getCommand()) || StompCommand.ABORT.equals(accessor.getCommand())) {
|
||||
String simpSessionId = (String) accessor.getHeader("simpSessionId");
|
||||
vitalSignTimer.stopTimerTaskMongo(simpSessionId);
|
||||
chatService.stopTimerTask(simpSessionId);
|
||||
// String simpSessionId = (String) accessor.getHeader("simpSessionId");
|
||||
// vitalSignTimer.stopTimerTaskMongo(simpSessionId);
|
||||
// chatService.stopTimerTask(simpSessionId);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
|
|
|
@ -33,8 +33,8 @@ import java.util.ArrayList;
|
|||
@RequestMapping("/medicine")
|
||||
public class MedicineController {
|
||||
|
||||
@Autowired
|
||||
private VitalSignTimer vitalSignTimer;
|
||||
// @Autowired
|
||||
// private VitalSignTimer vitalSignTimer;
|
||||
|
||||
@Autowired
|
||||
private OAuth2AuthorizationService authorizationService;
|
||||
|
@ -45,26 +45,26 @@ public class MedicineController {
|
|||
@Autowired
|
||||
private DoctorMedicineService doctorMedicineService;
|
||||
|
||||
@MessageMapping("/getSurgeryData")
|
||||
public void doctorMedicine(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.createAndSendMessageMongo(databaseName, username, simpSessionId);
|
||||
}
|
||||
// @MessageMapping("/getSurgeryData")
|
||||
// public void doctorMedicine(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.createAndSendMessageMongo(databaseName, username, simpSessionId);
|
||||
// }
|
||||
|
||||
// @MessageMapping("/changeAIFlag")
|
||||
// public void changeAIFlag(MessageHeaders messageHeaders, String body) {
|
||||
|
|
|
@ -1,4 +1,16 @@
|
|||
package com.rax.vital.medicine.dto;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MedicineDTO {
|
||||
private String linkNum;
|
||||
private String medicineName;
|
||||
private String medicineRate;
|
||||
private String countMedicine;
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ public interface AIMedicineService {
|
|||
void changeAIFlagMedicine(MongoTemplate template, String flag, String medicine, String value);
|
||||
|
||||
// 获取累计用药量
|
||||
List getCountMedicine(MongoTemplate template);
|
||||
Map getCountMedicine(MongoTemplate template);
|
||||
|
||||
// 获取ai给药信息
|
||||
List getAiMedicine(MongoTemplate template);
|
||||
Map getAiMedicine(MongoTemplate template);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.Map;
|
|||
*/
|
||||
public interface DoctorMedicineService {
|
||||
|
||||
List<Map> getDocMedicine(MongoTemplate template);
|
||||
Map getDocMedicine(MongoTemplate template);
|
||||
|
||||
List<Map> getDocMedicine(Connection connection);
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ public class AIMedicineServiceImpl implements AIMedicineService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List getCountMedicine(MongoTemplate template) {
|
||||
public Map getCountMedicine(MongoTemplate template) {
|
||||
Query query = new Query();
|
||||
query.limit(1);
|
||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
||||
|
@ -187,15 +187,15 @@ public class AIMedicineServiceImpl implements AIMedicineService {
|
|||
aiMedicines.remove(0);
|
||||
aiMedicines.add(medicine);
|
||||
}
|
||||
return aiMedicines;
|
||||
return aiMedicines.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getAiMedicine(MongoTemplate template) {
|
||||
public Map getAiMedicine(MongoTemplate template) {
|
||||
Query query = new Query();
|
||||
query.limit(1);
|
||||
query.limit(2);
|
||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
||||
List<Map> aimedicinetable = template.find(query, Map.class, "aimedicinetable");
|
||||
return aimedicinetable;
|
||||
return aimedicinetable.get(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,12 +26,12 @@ import java.util.Map;
|
|||
public class DoctorMedicineServiceImpl implements DoctorMedicineService {
|
||||
|
||||
@Override
|
||||
public List<Map> getDocMedicine(MongoTemplate template) {
|
||||
public Map getDocMedicine(MongoTemplate template) {
|
||||
Query query = new Query();
|
||||
query.limit(1);
|
||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
||||
List<Map> doctorMedicineTable = template.find(query, Map.class, "doctormedicinetable");
|
||||
return doctorMedicineTable;
|
||||
return doctorMedicineTable.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,15 +39,23 @@ public class FlagServiceImpl implements FlagService {
|
|||
query.limit(1);
|
||||
query.with(Sort.by(Sort.Order.desc("Time")));
|
||||
List<Map> linkTable = template.find(query, Map.class, "linktable");
|
||||
System.out.println("linkTable = " + linkTable);
|
||||
flagMap.put("linkFlag", linkTable.get(0).get("Flag"));
|
||||
List<Map> aiFlagTable = template.find(query, Map.class, "aiflagtable");
|
||||
System.out.println("aiFlagTable = " + aiFlagTable);
|
||||
flagMap.put("aiFlag", aiFlagTable.get(0).get("Flag"));
|
||||
List<Map> endFlagTable = template.find(query, Map.class, "endflagtable");
|
||||
System.out.println("endFlagTable = " + endFlagTable);
|
||||
flagMap.put("endFlag", endFlagTable.get(0).get("Flag"));
|
||||
return flagMap;
|
||||
if (linkTable != null && linkTable.size() > 0
|
||||
&& aiFlagTable != null && aiFlagTable.size() > 0
|
||||
&& endFlagTable != null && endFlagTable.size() > 0) {
|
||||
|
||||
flagMap.put("linkFlag", linkTable.get(0).get("Flag"));
|
||||
flagMap.put("aiFlag", aiFlagTable.get(0).get("Flag"));
|
||||
flagMap.put("endFlag", endFlagTable.get(0).get("Flag"));
|
||||
return flagMap;
|
||||
|
||||
} else {
|
||||
flagMap.put("linkFlag", "");
|
||||
flagMap.put("aiFlag", "");
|
||||
flagMap.put("endFlag", "");
|
||||
return flagMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -80,17 +80,17 @@ public class VitalSignServiceImpl implements VitalSignsService {
|
|||
|
||||
if (vitalList != null && vitalList.size() > 0) {
|
||||
Map map = vitalList.get(0);
|
||||
Double bis = (Double) map.get("BIS");
|
||||
Double bis = Double.valueOf((String) map.get("BIS"));
|
||||
map.put("BIS_except", bis <= 40 || bis >= 60);
|
||||
Double hr = (Double) map.get("HR");
|
||||
Double hr = Double.valueOf((String) map.get("HR"));
|
||||
map.put("HR_except", hr <= 50 || hr >= 80);
|
||||
Double sbp = (Double) map.get("SBP");
|
||||
Double sbp = Double.valueOf((String) map.get("SBP"));
|
||||
map.put("SBP_except", sbp <= 90 || sbp >= 120);
|
||||
Double dbp = (Double) map.get("DBP");
|
||||
Double dbp = Double.valueOf((String) map.get("DBP"));
|
||||
map.put("DBP_except", dbp <= 60 || dbp >= 90);
|
||||
Double st = (Double) map.get("ST");
|
||||
Double st = Double.valueOf((String) map.get("ST"));
|
||||
map.put("ST_except", st <= -0.2 || st >= 0.2);
|
||||
Double etCO2 = (Double) map.get("EtCO2");
|
||||
Double etCO2 = Double.valueOf((String) map.get("EtCO2"));
|
||||
map.put("EtCO2_except", etCO2 <= 30 || etCO2 >= 45);
|
||||
}
|
||||
return vitalList;
|
||||
|
@ -121,7 +121,7 @@ public class VitalSignServiceImpl implements VitalSignsService {
|
|||
vital.put("ABG", resultSet.getString("ABG"));
|
||||
vital.put("TOF", resultSet.getString("TOF"));
|
||||
vital.put("Time", resultSet.getString("Time"));
|
||||
Double bis = resultSet.getDouble("BIS");
|
||||
Double bis = resultSet.getDouble("BIS");
|
||||
vital.put("BIS_except", bis <= 40 || bis >= 60);
|
||||
Double hr = resultSet.getDouble("HR");
|
||||
vital.put("HR_except", hr <= 50 || hr >= 80);
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
* @date 2024/2/29
|
||||
*/
|
||||
@RefreshScope
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class VitalSignTimer {
|
||||
|
||||
|
@ -81,52 +80,52 @@ public class VitalSignTimer {
|
|||
*
|
||||
* @author zhaoyz
|
||||
*/
|
||||
public void createAndSendMessageMongo(String database, String username, String simpSessionId) {
|
||||
|
||||
synchronized (username) {
|
||||
if (!masterControlMap.containsKey(database)) {
|
||||
masterControlMap.put(database, username);
|
||||
}
|
||||
}
|
||||
|
||||
TimerTask task = timerMongoTaskMap.get(simpSessionId);
|
||||
if (task != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
MongoDBSource mongoDBSource = mongoDBSourceMap.get(simpSessionId);
|
||||
if (mongoDBSource == null) {
|
||||
mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, database);
|
||||
mongoDBSourceMap.put(simpSessionId, mongoDBSource);
|
||||
mongoDBSource.open();
|
||||
}
|
||||
|
||||
MongoDBSource finalMongoDBSource = mongoDBSource;
|
||||
TimerTask timerTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
MongoTemplate template = finalMongoDBSource.getConnection();
|
||||
HashMap<String, Object> result = new HashMap();
|
||||
List vitalSignsList = vitalSignsService.getVitalSignsList(template);
|
||||
result.put("vitalSignsList", vitalSignsList);
|
||||
List aiMedicineList = aiMedicineService.getAIMedicine(template);
|
||||
result.put("aiMedicineList", aiMedicineList);
|
||||
List docMedicineList = doctorMedicineService.getDocMedicine(template);
|
||||
result.put("docMedicineList", docMedicineList);
|
||||
List revulsionList = revulsionService.getRevulsionServiceList(template);
|
||||
result.put("revulsionList", revulsionList);
|
||||
Map flags = flagService.getFlags(template);
|
||||
result.put("flags", flags);
|
||||
|
||||
simpMessagingTemplate.convertAndSendToUser(username + ":" + database, "/surgeryData", result);
|
||||
}
|
||||
};
|
||||
// 定时任务,设置1秒
|
||||
Timer timer = new Timer();
|
||||
timer.schedule(timerTask, 0, 1000);
|
||||
timerMongoTaskMap.put(simpSessionId, timerTask);
|
||||
}
|
||||
// public void createAndSendMessageMongo(String database, String username, String simpSessionId) {
|
||||
//
|
||||
// synchronized (username) {
|
||||
// if (!masterControlMap.containsKey(database)) {
|
||||
// masterControlMap.put(database, username);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// TimerTask task = timerMongoTaskMap.get(simpSessionId);
|
||||
// if (task != null) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// MongoDBSource mongoDBSource = mongoDBSourceMap.get(simpSessionId);
|
||||
// if (mongoDBSource == null) {
|
||||
// mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, database);
|
||||
// mongoDBSourceMap.put(simpSessionId, mongoDBSource);
|
||||
// mongoDBSource.open();
|
||||
// }
|
||||
//
|
||||
// MongoDBSource finalMongoDBSource = mongoDBSource;
|
||||
// TimerTask timerTask = new TimerTask() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
//
|
||||
// MongoTemplate template = finalMongoDBSource.getConnection();
|
||||
// HashMap<String, Object> result = new HashMap();
|
||||
// List vitalSignsList = vitalSignsService.getVitalSignsList(template);
|
||||
// result.put("vitalSignsList", vitalSignsList);
|
||||
// List aiMedicineList = aiMedicineService.getAIMedicine(template);
|
||||
// result.put("aiMedicineList", aiMedicineList);
|
||||
// List docMedicineList = doctorMedicineService.getDocMedicine(template);
|
||||
// result.put("docMedicineList", docMedicineList);
|
||||
// List revulsionList = revulsionService.getRevulsionServiceList(template);
|
||||
// result.put("revulsionList", revulsionList);
|
||||
// Map flags = flagService.getFlags(template);
|
||||
// result.put("flags", flags);
|
||||
//
|
||||
// simpMessagingTemplate.convertAndSendToUser(username + ":" + database, "/surgeryData", result);
|
||||
// }
|
||||
// };
|
||||
// // 定时任务,设置1秒
|
||||
// Timer timer = new Timer();
|
||||
// timer.schedule(timerTask, 0, 1000);
|
||||
// timerMongoTaskMap.put(simpSessionId, timerTask);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import com.rax.vital.datasource.CustomDataSource;
|
||||
import com.rax.vital.datasource.MongoDBSource;
|
||||
import com.rax.vital.datasource.MySQLSource;
|
||||
import com.rax.vital.medicine.dto.MedicineDTO;
|
||||
import com.rax.vital.medicine.service.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
@ -16,10 +17,7 @@ import org.springframework.web.socket.WebSocketSession;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@RefreshScope
|
||||
|
@ -122,20 +120,52 @@ public class VitalSignTimerWS {
|
|||
// endFlag 1代表手术进行 0代表手术结束
|
||||
// linkFlag 1泵异常 0正常
|
||||
jsonObject.put("flags", flags);
|
||||
if (flags.get("aiFlag")!= null && flags.get("aiFlag").equals("1")){
|
||||
Map<String, Object> medicineRateMap = new HashMap<>();
|
||||
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")){
|
||||
medicineRateMap = aiMedicineService.getAiMedicine(template);
|
||||
} else if (flags.get("aiFlag") != null && flags.get("aiFlag").equals("0")) {
|
||||
// 医生给药信息
|
||||
List docMedicineList = doctorMedicineService.getDocMedicine(template);
|
||||
jsonObject.put("medicineRate", docMedicineList);
|
||||
medicineRateMap = doctorMedicineService.getDocMedicine(template);
|
||||
}
|
||||
|
||||
// 写上面会存在线程安全问题
|
||||
ArrayList<MedicineDTO> medicineList = new ArrayList<>();
|
||||
medicineList.add(new MedicineDTO("1", "丙泊酚", "0", "0"));
|
||||
medicineList.add(new MedicineDTO("2", "舒芬太尼", "0", "0"));
|
||||
medicineList.add(new MedicineDTO("3", "瑞芬太尼", "0", "0"));
|
||||
medicineList.add(new MedicineDTO("4", "顺阿曲库胺", "0", "0"));
|
||||
medicineList.add(new MedicineDTO("5", "尼卡地平", "0", "0"));
|
||||
medicineList.add(new MedicineDTO("6", "艾司洛尔", "0", "0"));
|
||||
medicineList.add(new MedicineDTO("7", "麻黄素", "0", "0"));
|
||||
medicineList.add(new MedicineDTO("8", "阿托品", "0", "0"));
|
||||
|
||||
if (medicineRateMap != null && !medicineRateMap.isEmpty()) {
|
||||
for (String key : medicineRateMap.keySet()) {
|
||||
for (MedicineDTO medicineDTO : medicineList) {
|
||||
if (medicineDTO.getMedicineName().equals(key)) {
|
||||
medicineDTO.setMedicineRate(medicineRateMap.get(key).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
jsonObject.put("rateModTime",medicineRateMap.get("Time"));
|
||||
}else {
|
||||
jsonObject.put("rateModTime","0");
|
||||
}
|
||||
// 总的药量信息
|
||||
List countMedicineList = aiMedicineService.getCountMedicine(template);
|
||||
jsonObject.put("countMedicine", countMedicineList);
|
||||
jsonObject.put("msgType", "msg");
|
||||
Map<String, Object> countMedicineMap = aiMedicineService.getCountMedicine(template);
|
||||
if (countMedicineMap != null && !countMedicineMap.isEmpty()) {
|
||||
for (String key : countMedicineMap.keySet()) {
|
||||
for (MedicineDTO medicineDTO : medicineList) {
|
||||
if ((medicineDTO.getMedicineName() + "Sum").equals(key)) {
|
||||
medicineDTO.setMedicineRate(countMedicineMap.get(key).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jsonObject.put("medicineList", medicineList);
|
||||
jsonObject.put("msgType", "msg");
|
||||
// 如果是人工给药展示人工给药的内容
|
||||
WebSocketMessage message = new TextMessage(jsonObject.toJSONString().getBytes());
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user