mirror of
https://gitee.com/republicline/rax-remote-v2.git
synced 2025-08-24 03:34:57 +08:00
登录功能;
This commit is contained in:
parent
c0c7cbb9a5
commit
5427e3bdd5
|
@ -411,6 +411,7 @@ INSERT INTO `sys_oauth_client_details` VALUES (4, 'mp', NULL, 'mp', 'server', 'p
|
|||
INSERT INTO `sys_oauth_client_details` VALUES (5, 'pig', NULL, 'pig', 'server', 'password,refresh_token,authorization_code,client_credentials,mobile', 'http://localhost:4040/sso1/login,http://localhost:4041/sso1/login,http://localhost:8080/renren-admin/sys/oauth2-sso,http://localhost:8090/sys/oauth2-sso', NULL, 43200, 2592001, '{\"enc_flag\":\"1\",\"captcha_flag\":\"1\",\"online_quantity\":\"1\"}', 'false', '0', '', 'admin', NULL, '2023-03-08 11:32:41');
|
||||
INSERT INTO `sys_oauth_client_details` VALUES (6, 'test', NULL, 'test', 'server', 'password,refresh_token', NULL, NULL, 43200, 2592001, '{ \"enc_flag\":\"1\",\"captcha_flag\":\"0\"}', 'true', '0', ' ', ' ', NULL, NULL);
|
||||
INSERT INTO `sys_oauth_client_details` VALUES (7, 'social', NULL, 'social', 'server', 'password,refresh_token,mobile', NULL, NULL, 43200, 2592001, '{ \"enc_flag\":\"0\",\"captcha_flag\":\"0\"}', 'true', '0', ' ', ' ', NULL, NULL);
|
||||
INSERT INTO `sys_oauth_client_details` VALUES (8, 'rax', NULL, 'rax', 'server', 'password,refresh_token,mobile', NULL, NULL, 43200, 2592001, '{ \"enc_flag\":\"1\",\"captcha_flag\":\"0\"}', 'true', '0', ' ', ' ', NULL, NULL);
|
||||
COMMIT;
|
||||
|
||||
-- ----------------------------
|
||||
|
|
|
@ -16,8 +16,8 @@ spring:
|
|||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password: Xg137839
|
||||
url: jdbc:mysql://110.41.142.124:3306/rax_backend?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&nullCatalogMeansCurrent=true
|
||||
password: root
|
||||
url: jdbc:mysql://localhost:3306/rax_backend?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&nullCatalogMeansCurrent=true
|
||||
# 定时任务属性配置
|
||||
quartz:
|
||||
properties:
|
||||
|
@ -51,9 +51,9 @@ spring:
|
|||
|
||||
gateway:
|
||||
# 前端密码登录解密密钥,和前端 .env 保存一致(16位)
|
||||
encodeKey: thanks,pig4cloud
|
||||
encodeKey: thanks,rax
|
||||
# 跳过验证码的客户端 clientId1,clientId2
|
||||
ignore-clients: test,raxQiankun
|
||||
ignore-clients: test,rax
|
||||
|
||||
# 本地文件系统
|
||||
file:
|
||||
|
@ -106,3 +106,7 @@ vital-sign:
|
|||
host: localhost:27017
|
||||
password: root
|
||||
username: root
|
||||
mysql:
|
||||
host: localhost:3306
|
||||
password: root
|
||||
username: root
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* mongoDB链接工具类
|
||||
* mongoDB连接工具类
|
||||
*/
|
||||
public class MongoDBSource {
|
||||
|
||||
|
@ -33,6 +33,10 @@ public class MongoDBSource {
|
|||
// mongo的客户端
|
||||
private MongoClient mongoClient;
|
||||
|
||||
private MongoTemplate template;
|
||||
|
||||
private SimpleMongoClientDatabaseFactory simpleMongoClientDatabaseFactory;
|
||||
|
||||
// 被使用的数量
|
||||
@Getter
|
||||
private int count = 0;
|
||||
|
@ -44,7 +48,7 @@ public class MongoDBSource {
|
|||
this.database = database;
|
||||
}
|
||||
|
||||
public MongoTemplate open() {
|
||||
public void open() {
|
||||
MongoClientSettings.Builder mongoBuilder = MongoClientSettings.builder();
|
||||
// mongodb://账户:密码@ip:端口/数据库名?authSource=admin
|
||||
String connectionUrl = "mongodb://" + this.username + ":" + this.password + "@" + this.host + "/" + this.database + "?authSource=admin";
|
||||
|
@ -62,9 +66,12 @@ public class MongoDBSource {
|
|||
builder.maxWaitTime(60000, TimeUnit.MILLISECONDS);
|
||||
});
|
||||
mongoClient = MongoClients.create(mongoBuilder.build(), SpringDataMongoDB.driverInformation());
|
||||
SimpleMongoClientDatabaseFactory simpleMongoClientDatabaseFactory = new SimpleMongoClientDatabaseFactory(mongoClient, database);
|
||||
MongoTemplate mongoTemplate = new MongoTemplate(simpleMongoClientDatabaseFactory);
|
||||
return mongoTemplate;
|
||||
simpleMongoClientDatabaseFactory = new SimpleMongoClientDatabaseFactory(mongoClient, database);
|
||||
}
|
||||
|
||||
public MongoTemplate getTemplate() {
|
||||
template = new MongoTemplate(simpleMongoClientDatabaseFactory);
|
||||
return template;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
|
|
|
@ -7,25 +7,37 @@ import lombok.SneakyThrows;
|
|||
|
||||
import java.sql.Connection;
|
||||
|
||||
/**
|
||||
* mySQL连接工具类
|
||||
*/
|
||||
public class MySQLSource {
|
||||
|
||||
// 地址
|
||||
private String host;
|
||||
|
||||
// 密码
|
||||
private String password;
|
||||
|
||||
// 账户
|
||||
private String username;
|
||||
|
||||
// 数据库
|
||||
private String database;
|
||||
|
||||
// 数据库驱动
|
||||
private String driver = "com.mysql.cj.jdbc.Driver";
|
||||
|
||||
// 使用的数量
|
||||
@Getter
|
||||
private int count = 0;
|
||||
|
||||
// 数据源
|
||||
private DruidDataSource dataSource;
|
||||
|
||||
// 连接池
|
||||
private DruidPooledConnection druidPooledConnection;
|
||||
|
||||
// 连接
|
||||
private Connection connection;
|
||||
|
||||
public MySQLSource(String host, String password, String username, String database) {
|
||||
|
@ -36,18 +48,22 @@ public class MySQLSource {
|
|||
}
|
||||
|
||||
@SneakyThrows
|
||||
public Connection open() {
|
||||
public void open() {
|
||||
dataSource = new DruidDataSource();
|
||||
dataSource.setUrl("jdbc:mysql://" + this.host + "/" + this.database);
|
||||
dataSource.setDriverClassName(driver);
|
||||
dataSource.setUsername(this.username);
|
||||
dataSource.setPassword(this.password);
|
||||
dataSource.setMinIdle(10);
|
||||
dataSource.setMaxActive(120);
|
||||
dataSource.setMaxWait(60000);
|
||||
druidPooledConnection = dataSource.getConnection();
|
||||
}
|
||||
|
||||
public Connection getConnection() {
|
||||
connection = druidPooledConnection.getConnection();
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
try {
|
||||
|
|
|
@ -33,9 +33,9 @@ public class MedicineController {
|
|||
public void doctorMedicine(String body) {
|
||||
JSONObject params = JSONObject.parseObject(body);
|
||||
if ("stop".equals(params.getString("status"))) {
|
||||
vitalSignTimer.stopTimerTask(params.getString("db"), params.getString("user"));
|
||||
vitalSignTimer.stopTimerTaskMongo(params.getString("db"), params.getString("user"));
|
||||
} else {
|
||||
vitalSignTimer.createAndSendMessage(params.getString("db"));
|
||||
vitalSignTimer.createAndSendMessageMongo(params.getString("db"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,9 +2,17 @@ package com.rax.vital.medicine.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.rax.vital.medicine.entity.AIMedicine;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* AI给药
|
||||
*/
|
||||
public interface AIMedicineService extends IService<AIMedicine> {
|
||||
public interface AIMedicineService {
|
||||
List<Map> getMongoAIMedicine(MongoTemplate template);
|
||||
|
||||
List<Map> getMysqlAIMedicine(Connection connection);
|
||||
}
|
||||
|
|
|
@ -2,9 +2,18 @@ package com.rax.vital.medicine.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.rax.vital.medicine.entity.DoctorMedicine;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 医生给药
|
||||
*/
|
||||
public interface DoctorMedicineService extends IService<DoctorMedicine> {
|
||||
public interface DoctorMedicineService {
|
||||
|
||||
List<Map> getDocMedicineMongo(MongoTemplate template);
|
||||
|
||||
List<Map> getDocMedicineMysql(Connection connection);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.rax.vital.medicine.service;
|
||||
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface FlagService {
|
||||
List<Map> getFlagMongo(MongoTemplate template);
|
||||
|
||||
Map getFlagMysql(Connection connection);
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
package com.rax.vital.medicine.service;
|
||||
|
||||
import com.rax.vital.datasource.MongoDBSource;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -11,10 +13,16 @@ import java.util.Map;
|
|||
public interface VitalSignsService {
|
||||
|
||||
/**
|
||||
* 获取最新一条生命体征数据
|
||||
* 获取MongoDB最新一条生命体征数据
|
||||
*
|
||||
* @param mongoDBSource
|
||||
* @return
|
||||
*/
|
||||
List<Map> getVitalSignsList(MongoDBSource mongoDBSource);
|
||||
List<Map> getVitalSignsList(MongoTemplate template);
|
||||
|
||||
/**
|
||||
* 获取MySQL最新一条生命体征数据
|
||||
* @param connection
|
||||
* @return
|
||||
*/
|
||||
List<Map> getVitalSignsList(Connection connection);
|
||||
}
|
||||
|
|
|
@ -6,13 +6,55 @@ import com.rax.vital.medicine.mapper.AIMedicineMapper;
|
|||
import com.rax.vital.medicine.service.AIMedicineService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* AI给药
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class AIMedicineServiceImpl extends ServiceImpl<AIMedicineMapper, AIMedicine> implements AIMedicineService {
|
||||
public class AIMedicineServiceImpl implements AIMedicineService {
|
||||
|
||||
@Override
|
||||
public List<Map> getMongoAIMedicine(MongoTemplate template) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map> getMysqlAIMedicine(Connection connection) {
|
||||
List<Map> medicineList = new ArrayList<>();
|
||||
try {
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet resultSet = statement.executeQuery("SELECT id, phase, `丙泊酚`, `舒芬太尼`, `瑞芬太尼`, `顺阿曲库胺`, `尼卡地平`, `艾司洛尔`, `麻黄素`, `阿托品`, time FROM `AIMedicineTable` ORDER BY time LIMIT 1;");
|
||||
while (resultSet.next()) {
|
||||
Map medicine = new HashMap();
|
||||
medicine.put("id", resultSet.getString("id"));
|
||||
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("time", resultSet.getString("time"));
|
||||
medicineList.add(medicine);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return medicineList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,55 @@ import com.rax.vital.medicine.mapper.DoctorMedicineMapper;
|
|||
import com.rax.vital.medicine.service.DoctorMedicineService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 医生给药
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class DoctorMedicineServiceImpl extends ServiceImpl<DoctorMedicineMapper, DoctorMedicine> implements DoctorMedicineService {
|
||||
public class DoctorMedicineServiceImpl implements DoctorMedicineService {
|
||||
|
||||
@Override
|
||||
public List<Map> getDocMedicineMongo(MongoTemplate template) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map> getDocMedicineMysql(Connection connection) {
|
||||
List<Map> medicineList = new ArrayList<>();
|
||||
try {
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet resultSet = statement.executeQuery("SELECT id, phase, `丙泊酚`, `舒芬太尼`, `瑞芬太尼`, `顺阿曲库胺`, `尼卡地平`, `艾司洛尔`, `麻黄素`, `阿托品`, time FROM `DoctorMedicineTable` ORDER BY time LIMIT 1;");
|
||||
while (resultSet.next()) {
|
||||
Map medicine = new HashMap();
|
||||
medicine.put("id", resultSet.getString("id"));
|
||||
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("time", resultSet.getString("time"));
|
||||
medicineList.add(medicine);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return medicineList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package com.rax.vital.medicine.service.impl;
|
||||
|
||||
import com.rax.vital.medicine.service.FlagService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class FlagServiceImpl implements FlagService {
|
||||
|
||||
@Override
|
||||
public List<Map> getFlagMongo(MongoTemplate template) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getFlagMysql(Connection connection) {
|
||||
Map allFlag = new HashMap();
|
||||
try {
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet resultSet = statement.executeQuery("SELECT * FROM `EndFlagTable` ORDER BY time LIMIT 1;");
|
||||
List<Map> endFlagList = new ArrayList<>();
|
||||
while (resultSet.next()) {
|
||||
Map flag = new HashMap();
|
||||
flag.put("id", resultSet.getString(0));
|
||||
flag.put("flag", resultSet.getString(1));
|
||||
flag.put("time", resultSet.getString(2));
|
||||
endFlagList.add(flag);
|
||||
}
|
||||
allFlag.put("endFlag", endFlagList);
|
||||
|
||||
ResultSet aiRe = statement.executeQuery("SELECT * FROM `AIFlagTable` ORDER BY time LIMIT 1;");
|
||||
List<Map> aiFlagList = new ArrayList<>();
|
||||
while (aiRe.next()) {
|
||||
Map flag = new HashMap();
|
||||
flag.put("id", aiRe.getString(0));
|
||||
flag.put("flag", aiRe.getString(1));
|
||||
flag.put("convertFlag", aiRe.getString(2));
|
||||
flag.put("time", aiRe.getString(3));
|
||||
aiFlagList.add(flag);
|
||||
}
|
||||
allFlag.put("aiFlag", aiFlagList);
|
||||
|
||||
ResultSet reRe = statement.executeQuery("SELECT * FROM `ReFlagTable` ORDER BY time LIMIT 1;");
|
||||
List<Map> reFlagList = new ArrayList<>();
|
||||
while (reRe.next()) {
|
||||
Map flag = new HashMap();
|
||||
flag.put("id", reRe.getString(0));
|
||||
flag.put("flag", reRe.getString(1));
|
||||
flag.put("time", reRe.getString(2));
|
||||
reFlagList.add(flag);
|
||||
}
|
||||
allFlag.put("reFlag", reFlagList);
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return allFlag;
|
||||
}
|
||||
}
|
|
@ -9,6 +9,12 @@ import org.springframework.data.mongodb.core.query.Criteria;
|
|||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -23,13 +29,11 @@ public class VitalSignServiceImpl implements VitalSignsService {
|
|||
/**
|
||||
* 获取生命体征最新一条数据
|
||||
*
|
||||
* @param mongoDBSource
|
||||
* @author zhaoyz
|
||||
* @date 2024/2/29
|
||||
*/
|
||||
@Override
|
||||
public List<Map> getVitalSignsList(MongoDBSource mongoDBSource) {
|
||||
MongoTemplate template = mongoDBSource.open();
|
||||
public List<Map> getVitalSignsList(MongoTemplate template) {
|
||||
Query query = new Query();
|
||||
Criteria criteria = new Criteria();
|
||||
criteria.where("");
|
||||
|
@ -38,4 +42,34 @@ public class VitalSignServiceImpl implements VitalSignsService {
|
|||
List<Map> cs = template.find(query, Map.class, "cs");
|
||||
return cs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map> getVitalSignsList(Connection connection) {
|
||||
List<Map> vitalList = new ArrayList<>();
|
||||
try {
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet resultSet = statement.executeQuery("SELECT id, phase, bis, hr, sbp, dbp, st, temp, spo2, etco2, ppg, abg, tof, time FROM `featuretable` ORDER BY time DESC LIMIT 1;");
|
||||
while (resultSet.next()) {
|
||||
Map vital = new HashMap();
|
||||
vital.put("id", resultSet.getString("id"));
|
||||
vital.put("phase", resultSet.getString("phase"));
|
||||
vital.put("bis", resultSet.getString("bis"));
|
||||
vital.put("hr", resultSet.getString("hr"));
|
||||
vital.put("sbp", resultSet.getString("sbp"));
|
||||
vital.put("dbp", resultSet.getString("dbp"));
|
||||
vital.put("st", resultSet.getString("st"));
|
||||
vital.put("temp", resultSet.getString("temp"));
|
||||
vital.put("spo2", resultSet.getString("spo2"));
|
||||
vital.put("etco2", resultSet.getString("etco2"));
|
||||
vital.put("ppg", resultSet.getString("ppg"));
|
||||
vital.put("abg", resultSet.getString("abg"));
|
||||
vital.put("tof", resultSet.getString("tof"));
|
||||
vital.put("time", resultSet.getString("time"));
|
||||
vitalList.add(vital);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return vitalList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,16 +2,19 @@ package com.rax.vital.timer;
|
|||
|
||||
import com.rax.common.security.util.SecurityUtils;
|
||||
import com.rax.vital.datasource.MongoDBSource;
|
||||
import com.rax.vital.datasource.MySQLSource;
|
||||
import com.rax.vital.medicine.service.AIMedicineService;
|
||||
import com.rax.vital.medicine.service.DoctorMedicineService;
|
||||
import com.rax.vital.medicine.service.FlagService;
|
||||
import com.rax.vital.medicine.service.VitalSignsService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
@ -29,40 +32,65 @@ public class VitalSignTimer {
|
|||
|
||||
private final VitalSignsService vitalSignsService;
|
||||
|
||||
// 定时任务容器
|
||||
private static final Map<String, TimerTask> timerTaskMap = new HashMap<>(300);
|
||||
private final AIMedicineService aiMedicineService;
|
||||
|
||||
private final DoctorMedicineService doctorMedicineService;
|
||||
|
||||
private final FlagService flagService;
|
||||
|
||||
// mongoDB定时任务容器
|
||||
private static final Map<String, TimerTask> timerMongoTaskMap = new HashMap<>(300);
|
||||
|
||||
// mongoDB链接工具类容器
|
||||
private static final Map<String, MongoDBSource> mongoDBSourceMap = new HashMap<>(300);
|
||||
|
||||
// mysql定时任务容器
|
||||
private static final Map<String, TimerTask> timerMysqlTaskMap = new HashMap<>(300);
|
||||
|
||||
// mysql链接容器
|
||||
private static final Map<String, MySQLSource> mysqlConnectionMap = new HashMap(300);
|
||||
|
||||
// MongoDB的地址
|
||||
@Value("${vital-sign.mongodb.host}")
|
||||
private String mongoDBHost;
|
||||
|
||||
// MongoDB的用户名
|
||||
@Value("${vital-sign.mongodb.username}")
|
||||
private String username;
|
||||
private String mongoUsername;
|
||||
|
||||
// MongoDB的用户的密码
|
||||
@Value("${vital-sign.mongodb.password}")
|
||||
private String password;
|
||||
private String mongoPassword;
|
||||
|
||||
// mysql地址
|
||||
@Value("${vital-sign.mysql.host}")
|
||||
private String mysqlHost;
|
||||
|
||||
// mysql用户名
|
||||
@Value("${vital-sign.mysql.username}")
|
||||
private String mysqlUsername;
|
||||
|
||||
// mysql用户密码
|
||||
@Value("${vital-sign.mysql.password}")
|
||||
private String mysqlPassword;
|
||||
|
||||
/**
|
||||
* 根据当前用户和患者数据库进行查询生命体征和用药信息并推送
|
||||
* 根据当前用户和患者数据库进行查询生命体征和用药信息并推送,数据库类型是MongoDB
|
||||
*
|
||||
* @author zhaoyz
|
||||
*/
|
||||
public void createAndSendMessage(String database) {
|
||||
public void createAndSendMessageMongo(String database) {
|
||||
String account = SecurityUtils.getUser().getUsername();
|
||||
TimerTask task = timerTaskMap.get(account + "-" + database);
|
||||
TimerTask task = timerMongoTaskMap.get(account + "-" + database);
|
||||
if (task != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
MongoDBSource mongoDBSource = mongoDBSourceMap.get(database);
|
||||
if (mongoDBSource == null) {
|
||||
mongoDBSource = new MongoDBSource(mongoDBHost, password, username, database);
|
||||
mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, database);
|
||||
mongoDBSourceMap.put(database, mongoDBSource);
|
||||
mongoDBSource.open();
|
||||
mongoDBSource.increaseCount();
|
||||
}
|
||||
|
||||
|
@ -70,7 +98,8 @@ public class VitalSignTimer {
|
|||
TimerTask timerTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<Map> vitalSignsList = vitalSignsService.getVitalSignsList(finalMongoDBSource);
|
||||
MongoTemplate template = finalMongoDBSource.getTemplate();
|
||||
List<Map> vitalSignsList = vitalSignsService.getVitalSignsList(template);
|
||||
HashMap<String, Object> result = new HashMap();
|
||||
result.put("vitalSignsList", vitalSignsList);
|
||||
simpMessagingTemplate.convertAndSendToUser(account, "/doctorMedicine", vitalSignsList);
|
||||
|
@ -80,22 +109,59 @@ public class VitalSignTimer {
|
|||
// 定时任务,设置1秒
|
||||
Timer timer = new Timer();
|
||||
timer.schedule(timerTask, 0, 1000);
|
||||
timerMongoTaskMap.put(account + "-" + database, timerTask);
|
||||
}
|
||||
|
||||
timerTaskMap.put(account + "-" + database, timerTask);
|
||||
public void createAndSendMessageMySQL(String database) {
|
||||
String account = SecurityUtils.getUser().getUsername();
|
||||
TimerTask task = timerMysqlTaskMap.get(account + "-" + database);
|
||||
if (task != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
MySQLSource mySQLSource = mysqlConnectionMap.get(database);
|
||||
if (mySQLSource == null) {
|
||||
mySQLSource = new MySQLSource(mysqlHost, mysqlPassword, mysqlUsername, database);
|
||||
mysqlConnectionMap.put(database, mySQLSource);
|
||||
mySQLSource.open();
|
||||
mySQLSource.increaseCount();
|
||||
}
|
||||
|
||||
MySQLSource finalMySQLSource = mySQLSource;
|
||||
TimerTask timerTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
HashMap<String, Object> result = new HashMap();
|
||||
Connection connection = finalMySQLSource.getConnection();
|
||||
List<Map> vitalSignsList = vitalSignsService.getVitalSignsList(connection);
|
||||
result.put("vitalSignsList", vitalSignsList);
|
||||
List<Map> aiMedicineList = aiMedicineService.getMysqlAIMedicine(connection);
|
||||
result.put("aiMedicineList", aiMedicineList);
|
||||
List<Map> docMedicineList = doctorMedicineService.getDocMedicineMysql(connection);
|
||||
result.put("docMedicineList", docMedicineList);
|
||||
Map flag = flagService.getFlagMysql(connection);
|
||||
result.put("flag", flag);
|
||||
simpMessagingTemplate.convertAndSendToUser(account, "/doctorMedicine", vitalSignsList);
|
||||
}
|
||||
};
|
||||
// 定时任务,设置1秒
|
||||
Timer timer = new Timer();
|
||||
timer.schedule(timerTask, 0, 1000);
|
||||
timerMysqlTaskMap.put(account + "-" + database, timerTask);
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止指定的某个用户查询的患者数据库定时器
|
||||
* 停止指定的某个用户查询的患者数据库定时器,数据库类型是MongoDB
|
||||
*
|
||||
* @param database
|
||||
* @param user
|
||||
* @author zhaoyz
|
||||
*/
|
||||
public synchronized void stopTimerTask(String database, String user) {
|
||||
TimerTask timerTask = timerTaskMap.get(user + "-" + database);
|
||||
public synchronized void stopTimerTaskMongo(String database, String user) {
|
||||
TimerTask timerTask = timerMongoTaskMap.get(user + "-" + database);
|
||||
if (timerTask != null) {
|
||||
timerTask.cancel();
|
||||
timerTaskMap.remove(user + "-" + database);
|
||||
timerMongoTaskMap.remove(user + "-" + database);
|
||||
|
||||
MongoDBSource mongoDBSource = mongoDBSourceMap.get(database);
|
||||
mongoDBSource.decreaseCount();
|
||||
|
@ -107,5 +173,20 @@ public class VitalSignTimer {
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized void stopTimerTaskMySQL(String database, String user) {
|
||||
TimerTask timerTask = timerMysqlTaskMap.get(user + "-" + database);
|
||||
if (timerTask != null) {
|
||||
timerTask.cancel();
|
||||
timerMysqlTaskMap.remove(user + "-" + database);
|
||||
|
||||
MySQLSource mySQLSource = mysqlConnectionMap.get(database);
|
||||
mySQLSource.decreaseCount();
|
||||
int count = mySQLSource.getCount();
|
||||
if (count == 0) {
|
||||
mySQLSource.close();
|
||||
mysqlConnectionMap.remove(database);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user