远程表字段更改
This commit is contained in:
parent
5a500d30cf
commit
8032c1bfff
|
@ -1,6 +1,8 @@
|
|||
package com.rax.vital.medicine.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.rax.common.core.util.R;
|
||||
import com.rax.vital.medicine.service.VitalSignsService;
|
||||
import com.rax.vital.timer.VitalSignTimer;
|
||||
import com.rax.vital.util.DatabaseNameUtil;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
|
@ -14,6 +16,9 @@ import org.springframework.security.oauth2.server.authorization.OAuth2Authorizat
|
|||
import org.springframework.security.oauth2.server.authorization.OAuth2TokenType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -23,9 +28,10 @@ import java.util.List;
|
|||
*
|
||||
* @date 2024.2.19
|
||||
*/
|
||||
@Controller
|
||||
@RestController
|
||||
@Tag(description = "medicine", name = "人工和AI用药管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
@RequestMapping("/medicine")
|
||||
public class MedicineController {
|
||||
|
||||
@Autowired
|
||||
|
@ -34,6 +40,9 @@ public class MedicineController {
|
|||
@Autowired
|
||||
private OAuth2AuthorizationService authorizationService;
|
||||
|
||||
@Autowired
|
||||
VitalSignsService vitalSignsService;
|
||||
|
||||
@MessageMapping("/getSurgeryData")
|
||||
public void doctorMedicine(MessageHeaders messageHeaders, String body) {
|
||||
LinkedMultiValueMap nativeHeaders = (LinkedMultiValueMap) messageHeaders.get("nativeHeaders");
|
||||
|
@ -76,4 +85,10 @@ public class MedicineController {
|
|||
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) {
|
||||
String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||
return vitalSignsService.getPatientInfo(databaseName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.rax.vital.medicine.service;
|
||||
|
||||
import com.rax.common.core.util.R;
|
||||
import com.rax.vital.datasource.MongoDBSource;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
|
||||
|
@ -25,4 +26,6 @@ public interface VitalSignsService {
|
|||
* @return
|
||||
*/
|
||||
List<Map> getVitalSignsList(Connection connection);
|
||||
|
||||
R getPatientInfo(String databaseName);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package com.rax.vital.medicine.service.impl;
|
||||
|
||||
import com.rax.common.core.util.R;
|
||||
import com.rax.vital.datasource.MongoDBSource;
|
||||
import com.rax.vital.medicine.service.VitalSignsService;
|
||||
import com.rax.vital.timer.VitalSignTimer;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bson.Document;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
|
@ -25,9 +29,20 @@ import java.util.Map;
|
|||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
@RefreshScope
|
||||
public class VitalSignServiceImpl implements VitalSignsService {
|
||||
|
||||
@Value("${vital-sign.mongodb.host}")
|
||||
private String mongoDBHost;
|
||||
|
||||
// MongoDB的用户名
|
||||
@Value("${vital-sign.mongodb.username}")
|
||||
private String mongoUsername;
|
||||
|
||||
// MongoDB的用户的密码
|
||||
@Value("${vital-sign.mongodb.password}")
|
||||
private String mongoPassword;
|
||||
|
||||
/**
|
||||
* 获取生命体征最新一条数据
|
||||
*
|
||||
|
@ -88,4 +103,16 @@ public class VitalSignServiceImpl implements VitalSignsService {
|
|||
}
|
||||
return vitalList;
|
||||
}
|
||||
|
||||
public R getPatientInfo(String databaseName) {
|
||||
MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, databaseName);
|
||||
mongoDBSource.open();
|
||||
MongoTemplate template = mongoDBSource.getTemplate();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -334,16 +334,19 @@ public class VitalSignTimer {
|
|||
if (machineDatabaseSessionMap.containsKey(database)) {
|
||||
String sessionId = machineDatabaseSessionMap.get(database);
|
||||
WebSocketSession machineSession = machineSessionMap.get(sessionId);
|
||||
JSONObject medicineJson = new JSONObject();
|
||||
medicineJson.put(medicine, value);
|
||||
medicineJson.put("flag", flag);
|
||||
machineSession.sendMessage(new TextMessage(medicineJson.toJSONString().getBytes()));
|
||||
result.put(medicine, value);
|
||||
result.put("flag", flag);
|
||||
machineSession.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||
} else {
|
||||
result.put("flag", flag);
|
||||
result.put("medicine", medicine);
|
||||
result.put("msg", "设备端未连接");
|
||||
result.put("status", 1);
|
||||
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||
}
|
||||
} else {
|
||||
result.put("flag", flag);
|
||||
result.put("medicine", medicine);
|
||||
result.put("status", 1);
|
||||
result.put("msg", "不是主控人员");
|
||||
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||
|
@ -396,5 +399,4 @@ public class VitalSignTimer {
|
|||
session.sendMessage(new TextMessage(result.toJSONString().getBytes()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user