fix: 一期代码.
This commit is contained in:
parent
f2d7305ed7
commit
80ebac1242
|
|
@ -11,21 +11,17 @@ import org.springframework.context.annotation.ComponentScan;
|
|||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2018年06月21日
|
||||
* <p>
|
||||
* 用户统一管理系统
|
||||
* 禁用MongoDB数据库自动连接
|
||||
*/
|
||||
|
||||
@EnableRaxDoc(value = "admin")
|
||||
@EnableRaxResourceServer
|
||||
@EnableScheduling // 开启定时任务 -> 清除日志相关内容
|
||||
// 一期下面解注, 二期注释掉
|
||||
@SpringBootApplication(exclude = MongoAutoConfiguration.class)
|
||||
//@SpringBootApplication
|
||||
@ComponentScan(
|
||||
basePackages = {"com.rax"},
|
||||
excludeFilters = {
|
||||
@ComponentScan.Filter(type = FilterType.REGEX, pattern = "com.rax.vital.v1.*")
|
||||
@ComponentScan.Filter(type = FilterType.REGEX, pattern = "com.rax.vital.v2.*")
|
||||
})
|
||||
public class RaxAdminApplication extends SpringBootServletInitializer {
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
|
@ -76,21 +77,6 @@ public class SysHospitalController {
|
|||
return R.ok(myHospitalList);
|
||||
}
|
||||
|
||||
// @SysLog(value = "添加医院管理员")
|
||||
// @PostMapping("/saveHospitalManager")
|
||||
// @Operation(description = "添加医院管理员", summary = "添加医院管理员")
|
||||
// @PreAuthorize("@pms.hasPermission('sys_hospital_manager_add')")
|
||||
// R saveHospitalManager(String userId, String hospitalId) {
|
||||
// boolean status = sysHospitalService.saveHospitalManager(userId, hospitalId);
|
||||
// return R.ok(status);
|
||||
// }
|
||||
|
||||
// @PostMapping("/getHospitalManager")
|
||||
// @Operation(description = "获取医院管理员", summary = "获取医院呢管理员")
|
||||
// R getHospitalManager(String hospitalId) {
|
||||
// List list = sysHospitalService.getHospitalManager(hospitalId);
|
||||
// return R.ok(list);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -110,6 +96,16 @@ public class SysHospitalController {
|
|||
return R.ok(sysHospitalService.getCurrentHospital());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医院信息, 详细, 给仪器端使用
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getCurrentHospitalInfo")
|
||||
R getCurrentHospitalInfo() {
|
||||
return R.ok(sysHospitalService.getCurrentHospitalInfo());
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/getCountByProvince")
|
||||
R getCountByProvince() {
|
||||
return R.ok(sysHospitalService.getCountByProvince());
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.rax.admin.api.dto.UserDTO;
|
||||
import com.rax.admin.api.entity.SysUser;
|
||||
import com.rax.admin.api.vo.UserExcelVO;
|
||||
import com.rax.admin.service.SysHospitalService;
|
||||
import com.rax.admin.service.SysRoleService;
|
||||
import com.rax.admin.service.SysUserService;
|
||||
import com.rax.admin.utils.AuthUtils;
|
||||
import com.rax.common.core.constant.CommonConstants;
|
||||
|
|
@ -48,12 +46,6 @@ public class SysUserController {
|
|||
|
||||
private final SysUserService userService;
|
||||
|
||||
private final SysRoleService roleService;
|
||||
|
||||
private final static String ADMIN_ROLE_CODE = "ROLE_ADMIN";
|
||||
|
||||
private final SysHospitalService sysHospitalService;
|
||||
|
||||
private final static String PASSWD_PATTERN = "^[a-zA-Z0-9]{8,16}$";
|
||||
|
||||
private final static String ACCOUNT_PATTERN = "^[a-zA-Z0-9]{2,16}$";
|
||||
|
|
@ -72,22 +64,9 @@ public class SysUserController {
|
|||
.eq(StrUtil.isNotBlank(phone), SysUser::getPhone, phone));
|
||||
if (user == null) {
|
||||
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERINFO_EMPTY, username));
|
||||
} else {
|
||||
// List<SysRole> rolesByUserId = roleService.findRolesByUserId(user.getUserId());
|
||||
// boolean isAdmin = false;
|
||||
// for (SysRole role : rolesByUserId) {
|
||||
// if (ADMIN_ROLE_CODE.equals(role.getRoleCode())) {
|
||||
// isAdmin = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (isAdmin) {
|
||||
// sysHospitalService.changeHospital("", String.valueOf(user.getUserId()));
|
||||
// } else {
|
||||
// sysHospitalService.changeHospital(String.valueOf(user.getHospitalId()), String.valueOf(user.getUserId()));
|
||||
// }
|
||||
return R.ok(userService.findUserInfo(user));
|
||||
}
|
||||
return R.ok(userService.findUserInfo(user));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -182,8 +161,9 @@ public class SysUserController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 分页查询用户信息, 查询当前医院, 如果当前医院为null且具有管理员权限, 则查询所有
|
||||
* 分页查询用户信息, 查询当前医院, 如果当前医院为0且具有管理员权限, 则查询所有
|
||||
* 只能查询到当前医院的医生信息.
|
||||
*
|
||||
* @param page 参数集
|
||||
* @param userDTO 查询参数列表
|
||||
* @return 用户集合
|
||||
|
|
@ -191,27 +171,25 @@ public class SysUserController {
|
|||
@PostMapping("/page")
|
||||
public R getUserPage(Page page, UserDTO userDTO) {
|
||||
RaxUser user = SecurityUtils.getUser();
|
||||
System.out.println("user = " + user);
|
||||
boolean access = AuthUtils.authAdmin(user);
|
||||
if (!access) {
|
||||
userDTO.setHospitalId(user.getHospitalId());
|
||||
}else {
|
||||
} else {
|
||||
// 超级管理员查询, 获取当前医院
|
||||
Long currentHospital = AuthUtils.getCurrentHospital(user);
|
||||
System.out.println("currentHospital = " + currentHospital);
|
||||
if (currentHospital != null && currentHospital == 0) {
|
||||
userDTO.setHospitalId(null);
|
||||
} else {
|
||||
userDTO.setHospitalId(currentHospital);
|
||||
}
|
||||
}
|
||||
|
||||
return R.ok(userService.getUsersWithRolePage(page, userDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询用户
|
||||
* 查询所有的用户信息, 属于系统后台管理功能
|
||||
*
|
||||
* @return 用户集合
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
|
|
|
|||
|
|
@ -78,4 +78,6 @@ public interface SysHospitalService extends IService<SysHospital> {
|
|||
Map getCountByCity(String province);
|
||||
|
||||
boolean changeHospital(String id);
|
||||
|
||||
Map getCurrentHospitalInfo();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ public class SysHospitalServiceImpl extends ServiceImpl<SysHospitalMapper, SysHo
|
|||
/**
|
||||
* 这里的currentHospital, 针对管理员Role_ADMIN是获取当前医院
|
||||
* 其余的角色则直接从token获取,无需存储到redis
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -149,6 +150,20 @@ public class SysHospitalServiceImpl extends ServiceImpl<SysHospitalMapper, SysHo
|
|||
return Convert.toStr(user.getHospitalId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getCurrentHospitalInfo() {
|
||||
String currentHospital = getCurrentHospital();
|
||||
if (currentHospital == null) {
|
||||
return null;
|
||||
}
|
||||
SysHospital one = this.lambdaQuery().eq(SysHospital::getId, currentHospital).one();
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("id", one.getId());
|
||||
map.put("name", one.getName());
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map getCountByProvince() {
|
||||
List<Map> list = sysHospitalMapper.getCountByProvince();
|
||||
|
|
@ -186,4 +201,6 @@ public class SysHospitalServiceImpl extends ServiceImpl<SysHospitalMapper, SysHo
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import com.rax.admin.service.SysLogService;
|
|||
import com.rax.admin.utils.AuthUtils;
|
||||
import com.rax.common.security.service.RaxUser;
|
||||
import com.rax.common.security.util.SecurityUtils;
|
||||
import org.jacoco.agent.rt.internal_3570298.core.internal.flow.IFrame;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ public class MongoDBSource extends CustomDataSource {
|
|||
mongoBuilder.applyConnectionString(new ConnectionString(connectionUrl));
|
||||
mongoBuilder.applyToConnectionPoolSettings(builder -> {
|
||||
// 允许的最大连接数。
|
||||
builder.maxSize(120);
|
||||
builder.maxSize(60);
|
||||
// 最小连接数。
|
||||
builder.minSize(1);
|
||||
// 池连接可以存活的最长时间。零值表示寿命没有限制。超过其生命周期的池连接将被关闭并在必要时由新连接替换
|
||||
builder.maxConnectionLifeTime(0, TimeUnit.SECONDS);
|
||||
// 池连接的最大空闲时间。零值表示对空闲时间没有限制。超过其空闲时间的池连接将被关闭并在必要时由新连接替换
|
||||
builder.maxConnectionIdleTime(6, TimeUnit.MINUTES);
|
||||
builder.maxConnectionIdleTime(60, TimeUnit.SECONDS);
|
||||
// 默认最大连接时间120s;
|
||||
builder.maxWaitTime(60000, TimeUnit.MILLISECONDS);
|
||||
});
|
||||
|
|
@ -63,7 +63,16 @@ public class MongoDBSource extends CustomDataSource {
|
|||
}
|
||||
|
||||
public void close() {
|
||||
mongoClient.close();
|
||||
try {
|
||||
if (mongoClient != null) {
|
||||
mongoClient.close();
|
||||
}
|
||||
if (simpleMongoClientDatabaseFactory != null) {
|
||||
simpleMongoClientDatabaseFactory.destroy();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,14 @@
|
|||
package com.rax.vital.common.util;
|
||||
|
||||
import com.rax.admin.api.entity.SysLog;
|
||||
import com.rax.common.security.service.RaxUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
import org.springframework.security.oauth2.core.OAuth2AccessToken;
|
||||
import org.springframework.security.oauth2.server.authorization.OAuth2Authorization;
|
||||
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
|
||||
import org.springframework.security.oauth2.server.authorization.OAuth2TokenType;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
import java.net.URI;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class MedicineHandler implements WebSocketHandler {
|
|||
} else {
|
||||
String patientName = jsonObject.getString("patientName");
|
||||
String idNum = jsonObject.getString("idNum");
|
||||
String databaseName = patientName + idNum;
|
||||
String databaseName = idNum;
|
||||
vitalSignTimerWS.createAndSendMessageMySQL(databaseName, username, session);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,7 +156,8 @@ public class ChatServiceImpl implements ChatService {
|
|||
@Override
|
||||
public void sendMessageMysql(String username, String patientName, String idNum, String date, WebSocketSession session, String msg) {
|
||||
CustomDataSource dataSource = datasourceMap.get(session.getId());
|
||||
String databaseName = patientName + idNum;
|
||||
// String databaseName = patientName + idNum;
|
||||
String databaseName = idNum;
|
||||
ArrayList<Map> history = new ArrayList<>();
|
||||
|
||||
if (dataSource == null) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package com.rax.vital.v2.config;
|
||||
|
||||
import com.mongodb.ConnectionString;
|
||||
import com.mongodb.MongoClientSettings;
|
||||
import com.mongodb.client.MongoClient;
|
||||
import com.mongodb.client.MongoClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Configuration
|
||||
public class MongoConfig {
|
||||
|
||||
@Bean
|
||||
public MongoClient mongoClient() {
|
||||
MongoClientSettings.Builder mongoBuilder = MongoClientSettings.builder();
|
||||
String connectionUrl = "mongodb://useradmin:Xg137839mg@110.41.142.124:27017/information?authSource=admin";
|
||||
mongoBuilder.applyConnectionString(new ConnectionString(connectionUrl));
|
||||
mongoBuilder.applyToConnectionPoolSettings(builder -> {
|
||||
// 允许的最大连接数。
|
||||
builder.maxSize(120);
|
||||
// 最小连接数。
|
||||
builder.minSize(1);
|
||||
// 池连接可以存活的最长时间。零值表示寿命没有限制。超过其生命周期的池连接将被关闭并在必要时由新连接替换
|
||||
builder.maxConnectionLifeTime(0, TimeUnit.SECONDS);
|
||||
// 池连接的最大空闲时间。零值表示对空闲时间没有限制。超过其空闲时间的池连接将被关闭并在必要时由新连接替换
|
||||
builder.maxConnectionIdleTime(60, TimeUnit.MINUTES);
|
||||
// 默认最大连接时间6min;
|
||||
builder.maxWaitTime(6, TimeUnit.MINUTES);
|
||||
});
|
||||
return MongoClients.create(mongoBuilder.build());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SimpleMongoClientDatabaseFactory mongoDbFactory(MongoClient mongoClient) {
|
||||
return new SimpleMongoClientDatabaseFactory(mongoClient, "information");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MongoTemplate mongoTemplate(SimpleMongoClientDatabaseFactory mongoDbFactory) {
|
||||
return new MongoTemplate(mongoDbFactory);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -12,6 +12,10 @@ import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
|
|||
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
|
||||
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor;
|
||||
|
||||
/**
|
||||
* socket配置类
|
||||
* 这里使用spring托管每个socketHandler 单例
|
||||
*/
|
||||
@EnableWebSocket
|
||||
@Configuration
|
||||
public class WebSocketConfig implements WebSocketConfigurer {
|
||||
|
|
|
|||
|
|
@ -1,47 +1,47 @@
|
|||
package com.rax.vital.v2.config;
|
||||
|
||||
import com.rax.vital.v2.interceptor.WSChannelInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.messaging.simp.config.ChannelRegistration;
|
||||
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
|
||||
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
|
||||
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSocketMessageBroker
|
||||
public class WebSocketStompConfig implements WebSocketMessageBrokerConfigurer {
|
||||
|
||||
@Autowired
|
||||
private WSChannelInterceptor wsChannelInterceptor;
|
||||
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
registry.addEndpoint("/rax/chat", "/rax/SurgeryData")
|
||||
.setAllowedOrigins("*");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureMessageBroker(MessageBrokerRegistry registry) {
|
||||
// 第一个值表示客户端发送心跳消息的间隔时间,第二个值表示服务端发送心跳消息的间隔时间
|
||||
long [] heartbeat = {60000, 60000};
|
||||
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
|
||||
threadPoolTaskScheduler.initialize();
|
||||
registry.enableSimpleBroker("/topic").setTaskScheduler(threadPoolTaskScheduler).setHeartbeatValue(heartbeat);
|
||||
registry.setApplicationDestinationPrefixes("/front");
|
||||
registry.setUserDestinationPrefix("/topic/user");
|
||||
}
|
||||
|
||||
/**
|
||||
* stomp未登录验证
|
||||
*
|
||||
* @param registration
|
||||
*/
|
||||
@Override
|
||||
public void configureClientInboundChannel(ChannelRegistration registration) {
|
||||
registration.interceptors(wsChannelInterceptor);
|
||||
}
|
||||
|
||||
}
|
||||
//package com.rax.vital.v2.config;
|
||||
//
|
||||
//import com.rax.vital.v2.interceptor.WSChannelInterceptor;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.messaging.simp.config.ChannelRegistration;
|
||||
//import org.springframework.messaging.simp.config.MessageBrokerRegistry;
|
||||
//import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
//import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
|
||||
//import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
|
||||
//import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
|
||||
//
|
||||
//@Configuration
|
||||
//@EnableWebSocketMessageBroker
|
||||
//public class WebSocketStompConfig implements WebSocketMessageBrokerConfigurer {
|
||||
//
|
||||
// @Autowired
|
||||
// private WSChannelInterceptor wsChannelInterceptor;
|
||||
//
|
||||
// @Override
|
||||
// public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
// registry.addEndpoint("/rax/chat", "/rax/SurgeryData")
|
||||
// .setAllowedOrigins("*");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void configureMessageBroker(MessageBrokerRegistry registry) {
|
||||
// // 第一个值表示客户端发送心跳消息的间隔时间,第二个值表示服务端发送心跳消息的间隔时间
|
||||
// long [] heartbeat = {60000, 60000};
|
||||
// ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
|
||||
// threadPoolTaskScheduler.initialize();
|
||||
// registry.enableSimpleBroker("/topic").setTaskScheduler(threadPoolTaskScheduler).setHeartbeatValue(heartbeat);
|
||||
// registry.setApplicationDestinationPrefixes("/front");
|
||||
// registry.setUserDestinationPrefix("/topic/user");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * stomp未登录验证
|
||||
// *
|
||||
// * @param registration
|
||||
// */
|
||||
// @Override
|
||||
// public void configureClientInboundChannel(ChannelRegistration registration) {
|
||||
// registration.interceptors(wsChannelInterceptor);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.*;
|
||||
|
|
@ -24,7 +25,6 @@ import java.util.concurrent.*;
|
|||
@Component
|
||||
public class AddMedicineHandler implements WebSocketHandler {
|
||||
|
||||
|
||||
@Autowired
|
||||
private VitalSignTimerV2 vitalSignTimerV2;
|
||||
|
||||
|
|
@ -63,6 +63,7 @@ public class AddMedicineHandler implements WebSocketHandler {
|
|||
// yyyyMMdd
|
||||
String date = jsonObject.getString("date");
|
||||
String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||
|
||||
// 将网站端的dbName作为key session作为Value存入Map 以便后续判断状态
|
||||
if ("init".equals(msgType)) {
|
||||
aiMedicineTimer.initWeb(databaseName, session);
|
||||
|
|
@ -187,7 +188,5 @@ public class AddMedicineHandler implements WebSocketHandler {
|
|||
log.error("addMedicineHandler-sendMsgAsync error: {}", e.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@ import com.rax.vital.common.util.GetHttpParamUtil;
|
|||
import com.rax.vital.common.util.SysLoggerBuilder;
|
||||
import com.rax.vital.common.util.TokenUtil;
|
||||
import com.rax.vital.v2.medicine.service.ChatService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.*;
|
||||
|
||||
|
|
@ -24,7 +22,7 @@ import java.util.concurrent.TimeUnit;
|
|||
@Component
|
||||
public class ChatHandler implements WebSocketHandler {
|
||||
|
||||
@Resource
|
||||
@Autowired
|
||||
private ChatService chatService;
|
||||
|
||||
@Autowired
|
||||
|
|
@ -36,7 +34,6 @@ public class ChatHandler implements WebSocketHandler {
|
|||
@Autowired
|
||||
private TokenUtil tokenUtil;
|
||||
|
||||
|
||||
private Map<String, ScheduledExecutorService> timerTaskMap = new ConcurrentHashMap();
|
||||
|
||||
@Override
|
||||
|
|
@ -64,6 +61,7 @@ public class ChatHandler implements WebSocketHandler {
|
|||
String msg = jsonObject.getString("msg");
|
||||
String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||
chatService.sendMessage(databaseName, username, session, msg);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ import com.rax.admin.api.entity.SysLog;
|
|||
import com.rax.admin.service.SysLogService;
|
||||
import com.rax.vital.common.util.DatabaseNameUtil;
|
||||
import com.rax.vital.common.util.SysLoggerBuilder;
|
||||
import com.rax.vital.common.util.TokenUtil;
|
||||
import com.rax.vital.v2.timer.AIMedicineTimer;
|
||||
import com.rax.vital.v2.timer.VitalSignTimerV2;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -25,8 +23,6 @@ import java.util.concurrent.*;
|
|||
@Component
|
||||
public class MachineFeedbackHandler implements WebSocketHandler {
|
||||
|
||||
@Autowired
|
||||
private VitalSignTimerV2 vitalSignTimerV2;
|
||||
|
||||
@Autowired
|
||||
private SysLoggerBuilder sysLoggerBuilder;
|
||||
|
|
@ -34,9 +30,6 @@ public class MachineFeedbackHandler implements WebSocketHandler {
|
|||
@Autowired
|
||||
private SysLogService sysLogService;
|
||||
|
||||
@Autowired
|
||||
private TokenUtil tokenUtil;
|
||||
|
||||
private Map<String, ScheduledExecutorService> timerTaskMap = new ConcurrentHashMap();
|
||||
|
||||
@Autowired
|
||||
|
|
@ -96,7 +89,8 @@ public class MachineFeedbackHandler implements WebSocketHandler {
|
|||
aiMedicineTimer.sendConnectionResponseToWeb(patientName, idNum, date, databaseName, unityConnectionFlag);
|
||||
}
|
||||
|
||||
if (aiMedicineTimer.getUnitySession(databaseName) != null && aiMedicineTimer.getWebSession(databaseName) != null
|
||||
if (aiMedicineTimer.getUnitySession(databaseName) != null
|
||||
&& aiMedicineTimer.getWebSession(databaseName) != null
|
||||
&& aiMedicineTimer.isReady(databaseName)) {
|
||||
// vitalSignTimerWS.sendMachineFlag(databaseName, code, session);
|
||||
JSONObject msg = new JSONObject();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import com.rax.vital.common.util.GetHttpParamUtil;
|
|||
import com.rax.vital.common.util.SysLoggerBuilder;
|
||||
import com.rax.vital.common.util.TokenUtil;
|
||||
import com.rax.vital.v2.timer.VitalSignTimerV2;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -50,7 +49,6 @@ public class MedicineHandler implements WebSocketHandler {
|
|||
@Override
|
||||
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) {
|
||||
|
||||
|
||||
String payload = (String) message.getPayload();
|
||||
JSONObject jsonObject = JSONObject.parseObject(payload);
|
||||
|
||||
|
|
@ -67,6 +65,7 @@ public class MedicineHandler implements WebSocketHandler {
|
|||
String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||
vitalSignTimerV2.sendMedicalMessage(databaseName, username, session);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,50 +1,50 @@
|
|||
package com.rax.vital.v2.medicine.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.rax.vital.v2.medicine.service.ChatService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.handler.annotation.MessageMapping;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.oauth2.server.authorization.OAuth2Authorization;
|
||||
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
|
||||
import org.springframework.security.oauth2.server.authorization.OAuth2TokenType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Controller
|
||||
public class ChatController {
|
||||
|
||||
@Autowired
|
||||
private ChatService chatService;
|
||||
|
||||
@Autowired
|
||||
private OAuth2AuthorizationService authorizationService;
|
||||
|
||||
@MessageMapping("/sendMessage")
|
||||
public void sendMessage(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);
|
||||
if (authorization != null) {
|
||||
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 msg = params.getString("msg");
|
||||
chatService.sendMessage(username, patientName, idNum, date, simpSessionId, msg);
|
||||
} else {
|
||||
throw new AccessDeniedException("Access is denied");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//package com.rax.vital.v2.medicine.controller;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import com.rax.vital.v2.medicine.service.ChatService;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.messaging.MessageHeaders;
|
||||
//import org.springframework.messaging.handler.annotation.MessageMapping;
|
||||
//import org.springframework.security.access.AccessDeniedException;
|
||||
//import org.springframework.security.oauth2.server.authorization.OAuth2Authorization;
|
||||
//import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
|
||||
//import org.springframework.security.oauth2.server.authorization.OAuth2TokenType;
|
||||
//import org.springframework.stereotype.Controller;
|
||||
//import org.springframework.util.LinkedMultiValueMap;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//
|
||||
//@Controller
|
||||
//public class ChatController {
|
||||
//
|
||||
// @Autowired
|
||||
// private ChatService chatService;
|
||||
//
|
||||
// @Autowired
|
||||
// private OAuth2AuthorizationService authorizationService;
|
||||
//
|
||||
// @MessageMapping("/sendMessage")
|
||||
// public void sendMessage(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);
|
||||
// if (authorization != null) {
|
||||
// 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 msg = params.getString("msg");
|
||||
// chatService.sendMessage(username, patientName, idNum, date, simpSessionId, msg);
|
||||
// } else {
|
||||
// throw new AccessDeniedException("Access is denied");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,11 @@ package com.rax.vital.v2.medicine.controller;
|
|||
|
||||
import com.rax.common.core.util.R;
|
||||
import com.rax.vital.common.util.DatabaseNameUtil;
|
||||
import com.rax.vital.v2.medicine.service.DoctorMedicineService;
|
||||
import com.rax.vital.v2.medicine.service.SurgeryServiceV2;
|
||||
import com.rax.vital.v2.medicine.service.IMedicineService;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
|
@ -24,31 +22,23 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
@RequestMapping("/medicine")
|
||||
public class MedicineController {
|
||||
|
||||
// @Autowired
|
||||
// private VitalSignTimer vitalSignTimer;
|
||||
|
||||
@Autowired
|
||||
private OAuth2AuthorizationService authorizationService;
|
||||
|
||||
@Autowired
|
||||
private DoctorMedicineService doctorMedicineService;
|
||||
|
||||
@Autowired
|
||||
private SurgeryServiceV2 surgeryServiceV2;
|
||||
private IMedicineService medicineService;
|
||||
|
||||
|
||||
@PostMapping("/getPatientInfo")
|
||||
public R getPatientInfo(String patientName, String idNum, String date) {
|
||||
// todo : 存疑
|
||||
String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||
return surgeryServiceV2.getPatientInfo(databaseName);
|
||||
return medicineService.getPatientInfo(databaseName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/getPatientPage")
|
||||
public R getPatientPage(String name, String dept, long offset, int limit) {
|
||||
return R.ok(surgeryServiceV2.getPatientPage(name, dept, offset, limit));
|
||||
return R.ok(medicineService.getPatientPage(name, dept, offset, limit));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -56,7 +46,7 @@ public class MedicineController {
|
|||
*/
|
||||
@PostMapping("/getSurgeryCount")
|
||||
public R getSurgeryCount(String start, String end) {
|
||||
return R.ok(surgeryServiceV2.getSurgeryCount(start, end));
|
||||
return R.ok(medicineService.getSurgeryCount(start, end));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -65,7 +55,7 @@ public class MedicineController {
|
|||
*/
|
||||
@PostMapping("/getSurgeryDuration")
|
||||
public R getSurgeryDuration(String start, String end) {
|
||||
return R.ok(surgeryServiceV2.getSurgeryDuration(start, end));
|
||||
return R.ok(medicineService.getSurgeryDuration(start, end));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -73,7 +63,7 @@ public class MedicineController {
|
|||
*/
|
||||
@PostMapping("/getSurgeryTypeProportion")
|
||||
public R getSurgeryTypeProportion(String start, String end) {
|
||||
return R.ok(surgeryServiceV2.getSurgeryTypeProportion(start, end));
|
||||
return R.ok(medicineService.getSurgeryTypeProportion(start, end));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -81,7 +71,7 @@ public class MedicineController {
|
|||
*/
|
||||
@PostMapping("/getSurgeryOtherDuration")
|
||||
public R getSurgeryOtherDuration(String start, String end) {
|
||||
return R.ok(surgeryServiceV2.getSurgeryOtherDuration(start, end));
|
||||
return R.ok(medicineService.getSurgeryOtherDuration(start, end));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -90,7 +80,7 @@ public class MedicineController {
|
|||
*/
|
||||
@PostMapping("/getPatientSurgeryList")
|
||||
public R getPatientSurgeryList(String name, String code, String surgery, String type) {
|
||||
return R.ok(surgeryServiceV2.getPatientSurgeryList(name, code, surgery, type));
|
||||
return R.ok(medicineService.getPatientSurgeryList(name, code, surgery, type));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -98,7 +88,7 @@ public class MedicineController {
|
|||
*/
|
||||
@PostMapping("/getSurgeryTableData")
|
||||
public R getSurgeryTableData(String name, String code, String date, String table) {
|
||||
return R.ok(surgeryServiceV2.getSurgeryTableData(name, code, date, table));
|
||||
return R.ok(medicineService.getSurgeryTableData(name, code, date, table));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import org.springframework.web.socket.WebSocketSession;
|
|||
import java.io.IOException;
|
||||
|
||||
public interface ChatService {
|
||||
void sendMessage(String username, String patientName, String idNum, String date, String simpSessionId, String msg);
|
||||
|
||||
void sendMessage(String dbName, String username, WebSocketSession session, String msg) throws IOException;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,91 @@
|
|||
package com.rax.vital.v2.medicine.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.rax.common.core.util.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @project_name: rax-remote-v2
|
||||
* @time: 2024/9/10 17:00
|
||||
* @author: republicline
|
||||
* @description: 针对固定连接, information库的优化项
|
||||
*/
|
||||
public interface IMedicineService {
|
||||
/**
|
||||
* 获取患者基本信息
|
||||
*
|
||||
* @param databaseName
|
||||
* @return
|
||||
*/
|
||||
R getPatientInfo(String databaseName);
|
||||
|
||||
/**
|
||||
* 获取患者列表, informationDB中获取, 查询 surgery_info 表
|
||||
*
|
||||
* @param name
|
||||
* @param dept
|
||||
* @param offset
|
||||
* @param limit
|
||||
* @return
|
||||
*/
|
||||
Page getPatientPage(String name, String dept, long offset, int limit);
|
||||
|
||||
/**
|
||||
* 统计手术的数量
|
||||
*
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
List getSurgeryCount(String start, String end);
|
||||
|
||||
/**
|
||||
* 统计手术时长
|
||||
*
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
List getSurgeryDuration(String start, String end);
|
||||
|
||||
/**
|
||||
* 统计手术类型比例
|
||||
*
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
List getSurgeryTypeProportion(String start, String end);
|
||||
|
||||
/**
|
||||
* 代补充
|
||||
*
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
List getSurgeryOtherDuration(String start, String end);
|
||||
|
||||
/**
|
||||
* 获取患者手术列表
|
||||
*
|
||||
* @param name
|
||||
* @param code
|
||||
* @param surgery
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
List getPatientSurgeryList(String name, String code, String surgery, String type);
|
||||
|
||||
/**
|
||||
* 根据患者名称 or 入院号, 查询术后患者的各项信息 -> 用药信息, 给药信息, 生命体征信息
|
||||
*
|
||||
* @param name
|
||||
* @param code
|
||||
* @param date
|
||||
* @param table
|
||||
* @return
|
||||
*/
|
||||
List getSurgeryTableData(String name, String code, String date, String table);
|
||||
}
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
package com.rax.vital.v2.medicine.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.rax.common.core.util.R;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -22,81 +20,5 @@ public interface SurgeryServiceV2 {
|
|||
*/
|
||||
List<Map> getVitalSignsList(MongoTemplate template);
|
||||
|
||||
/**
|
||||
* 获取患者基本信息
|
||||
*
|
||||
* @param databaseName
|
||||
* @return
|
||||
*/
|
||||
R getPatientInfo(String databaseName);
|
||||
|
||||
/**
|
||||
* 获取患者列表, informationDB中获取, 查询 surgery_info 表
|
||||
*
|
||||
* @param name
|
||||
* @param dept
|
||||
* @param offset
|
||||
* @param limit
|
||||
* @return
|
||||
*/
|
||||
Page getPatientPage(String name, String dept, long offset, int limit);
|
||||
|
||||
/**
|
||||
* 统计手术的数量
|
||||
*
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
List getSurgeryCount(String start, String end);
|
||||
|
||||
/**
|
||||
* 统计手术时长
|
||||
*
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
List getSurgeryDuration(String start, String end);
|
||||
|
||||
/**
|
||||
* 统计手术类型比例
|
||||
*
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
List getSurgeryTypeProportion(String start, String end);
|
||||
|
||||
/**
|
||||
* 代补充
|
||||
*
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
List getSurgeryOtherDuration(String start, String end);
|
||||
|
||||
/**
|
||||
* 获取患者手术列表
|
||||
*
|
||||
* @param name
|
||||
* @param code
|
||||
* @param surgery
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
List getPatientSurgeryList(String name, String code, String surgery, String type);
|
||||
|
||||
/**
|
||||
* 根据患者名称 or 入院号, 查询术后患者的各项信息 -> 用药信息, 给药信息, 生命体征信息
|
||||
*
|
||||
* @param name
|
||||
* @param code
|
||||
* @param date
|
||||
* @param table
|
||||
* @return
|
||||
*/
|
||||
List getSurgeryTableData(String name, String code, String date, String table);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,12 @@ import com.rax.admin.api.entity.SysUser;
|
|||
import com.rax.admin.service.SysUserService;
|
||||
import com.rax.vital.common.datasource.CustomDataSource;
|
||||
import com.rax.vital.common.datasource.MongoDBSource;
|
||||
import com.rax.vital.common.util.DatabaseNameUtil;
|
||||
import com.rax.vital.v2.medicine.service.ChatService;
|
||||
import org.bson.Document;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.socket.TextMessage;
|
||||
|
|
@ -29,9 +27,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
@Service
|
||||
public class ChatServiceImpl implements ChatService {
|
||||
|
||||
@Autowired
|
||||
private SimpMessagingTemplate simpMessagingTemplate;
|
||||
|
||||
@Autowired
|
||||
private SysUserService SysUserService;
|
||||
|
||||
|
|
@ -66,38 +61,6 @@ public class ChatServiceImpl implements ChatService {
|
|||
@Value("${vital-sign.mysql.password}")
|
||||
private String mysqlPassword;
|
||||
|
||||
@Override
|
||||
public void sendMessage(String username, String patientName, String idNum, String date, String simpSessionId, String msg) {
|
||||
CustomDataSource mongoDBSource = datasourceMap.get(simpSessionId);
|
||||
|
||||
if (mongoDBSource == null) {
|
||||
String databaseName = DatabaseNameUtil.encrypt(patientName) + "_" + DatabaseNameUtil.encrypt(idNum) + "_" + date;
|
||||
mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, databaseName);
|
||||
datasourceMap.put(simpSessionId, mongoDBSource);
|
||||
mongoDBSource.open();
|
||||
}
|
||||
|
||||
SysUser sysUser = SysUserService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, username));
|
||||
|
||||
Map param = new HashMap();
|
||||
|
||||
MongoTemplate template = mongoDBSource.getConnection();
|
||||
Document document = new Document();
|
||||
document.put("content", msg);
|
||||
param.put("content", msg);
|
||||
String now = DateUtil.now();
|
||||
document.put("create_time", now);
|
||||
param.put("createTime", now);
|
||||
document.put("create_user", username);
|
||||
String name = sysUser.getName();
|
||||
document.put("create_name", name);
|
||||
param.put("createName", name);
|
||||
document.put("deleted", 0);
|
||||
document.put("revoked", 0);
|
||||
template.insert(document, "t_chat");
|
||||
|
||||
simpMessagingTemplate.convertAndSendToUser(patientName + idNum + date, "/chatroomMessage", param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String databaseName, String username, WebSocketSession session, String msg) throws IOException {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,306 @@
|
|||
package com.rax.vital.v2.medicine.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.rax.common.core.util.R;
|
||||
import com.rax.vital.common.datasource.MongoDBSource;
|
||||
import com.rax.vital.common.util.DatabaseNameUtil;
|
||||
import com.rax.vital.v2.medicine.service.IMedicineService;
|
||||
import org.bson.BsonRegularExpression;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.*;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @project_name: rax-remote-v2
|
||||
* @time: 2024/9/10 17:01
|
||||
* @author: republicline
|
||||
* @description: 针对于固定数据源的读取配置操作.
|
||||
*/
|
||||
@Service
|
||||
public class MedicineService implements IMedicineService {
|
||||
|
||||
@Autowired
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
@Override
|
||||
public R getPatientInfo(String databaseName) {
|
||||
// MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, databaseName);
|
||||
// mongoDBSource.open();
|
||||
// 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();
|
||||
|
||||
if (StringUtils.hasText(name)) {
|
||||
Criteria criteria = new Criteria("姓名");
|
||||
criteria.regex(new BsonRegularExpression(".*" + name + ".*"));
|
||||
query.addCriteria(criteria);
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(dept)) {
|
||||
Criteria criteria = new Criteria("科室");
|
||||
criteria.regex(new BsonRegularExpression(dept));
|
||||
query.addCriteria(criteria);
|
||||
}
|
||||
|
||||
query.with(Sort.by(Sort.Order.desc("住院时间")));
|
||||
query.skip(offset).limit(limit);
|
||||
List<Map> list = mongoTemplate.find(query, Map.class, "patient_info");
|
||||
long count = mongoTemplate.count(query, "patient_info");
|
||||
Page page = new Page();
|
||||
page.setRecords(list);
|
||||
page.setTotal(count);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getSurgeryCount(String start, String end) {
|
||||
// 按医院查询
|
||||
// RaxUser user = SecurityUtils.getUser();
|
||||
// Long currentHospital = AuthUtils.getCurrentHospital(user);
|
||||
|
||||
|
||||
// Criteria hosCriteria = Criteria.where("hospitalId")
|
||||
// .is(hospitalId);
|
||||
|
||||
Criteria criteria = Criteria.where("Time")
|
||||
.gte(start)
|
||||
.lte(end);
|
||||
Aggregation aggregation = Aggregation.newAggregation(
|
||||
// Aggregation.match(hosCriteria),
|
||||
Aggregation.match(criteria),
|
||||
Aggregation.project("Time")
|
||||
.and(DateOperators.DateFromString.fromStringOf("Time").withFormat("%Y-%m-%d %H:%M:%S")).as("timeDate"),
|
||||
Aggregation.project("timeDate")
|
||||
.and(DateOperators.DateToString.dateOf("timeDate").toString("%Y-%m-%d")).as("time"),
|
||||
Aggregation.group("time").count().as("count"),
|
||||
Aggregation.project("_id","count"),
|
||||
Aggregation.sort(Sort.by(Sort.Direction.ASC, "_id"))
|
||||
);
|
||||
AggregationResults<Map> results = mongoTemplate.aggregate(aggregation, "surgery_info", Map.class);
|
||||
List<Map> mappedResults = results.getMappedResults();
|
||||
return mappedResults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getSurgeryDuration(String start, String end) {
|
||||
|
||||
List<AggregationOperation> operations = new ArrayList<>();
|
||||
|
||||
Criteria criteria = new Criteria("Time");
|
||||
criteria.gte(start);
|
||||
criteria.lte(end);
|
||||
operations.add(Aggregation.match(criteria));
|
||||
|
||||
|
||||
ProjectionOperation timeToDateOperation = Aggregation.project()
|
||||
.andExpression("{$toLong: '$Surgery_duration(min)'}").as("Surgery_duration(min)")
|
||||
.andExpression("{$toDate: '$Time'}").as("day");
|
||||
operations.add(timeToDateOperation);
|
||||
|
||||
ProjectionOperation timeFormatOperation = Aggregation.project()
|
||||
.andInclude("Surgery_duration(min)")
|
||||
.andExpression("{ $dateToString: { format: '%Y-%m-%d', date: '$day' } }").as("time");
|
||||
operations.add(timeFormatOperation);
|
||||
|
||||
operations.add(Aggregation.group("$time").sum("Surgery_duration(min)").as("count"));
|
||||
|
||||
operations.add(Aggregation.project()
|
||||
.andInclude("_id")
|
||||
.andExpression("count").divide(60).as("count"));
|
||||
|
||||
operations.add(Aggregation.project()
|
||||
.andInclude("_id")
|
||||
.andExpression("{$round: {'$count', 1}}").as("duration"));
|
||||
|
||||
operations.add(Aggregation.project()
|
||||
.andInclude("duration")
|
||||
.andExpression("{$toDate: '$_id'}").as("time"));
|
||||
|
||||
operations.add(Aggregation.project()
|
||||
.andInclude("duration")
|
||||
.andExpression("{ $dateToString: { format: '%d', date: '$time' } }").as("_id"));
|
||||
|
||||
operations.add(Aggregation.sort(Sort.Direction.ASC, "_id"));
|
||||
|
||||
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 getSurgeryTypeProportion(String start, String end) {
|
||||
|
||||
// RaxUser user = SecurityUtils.getUser();
|
||||
// Long currentHospital = AuthUtils.getCurrentHospital(user);
|
||||
|
||||
|
||||
|
||||
Aggregation aggregation = Aggregation.newAggregation(
|
||||
Aggregation.match(Criteria.where("Time")
|
||||
.gte(start)
|
||||
.lte(end)),
|
||||
// Aggregation.match(Criteria.where("hospitalId")
|
||||
// .is(currentHospital)),
|
||||
Aggregation.group("Surgery_type").count().as("count")
|
||||
);
|
||||
List<Map> mappedResults = mongoTemplate.aggregate(aggregation, "surgery_info", Map.class).getMappedResults();
|
||||
|
||||
return mappedResults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getSurgeryOtherDuration(String start, String end) {
|
||||
// MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, informationDatabase);
|
||||
// mongoDBSource.open();
|
||||
// MongoTemplate template = mongoDBSource.getConnection();
|
||||
List<AggregationOperation> operations = new ArrayList<>();
|
||||
|
||||
Criteria criteria = new Criteria("Time");
|
||||
criteria.gte(start);
|
||||
criteria.lte(end);
|
||||
operations.add(Aggregation.match(criteria));
|
||||
|
||||
ProjectionOperation timeToDateOperation = Aggregation.project()
|
||||
.andExpression("{$toLong: '$Aianaesthesia_duration(min)'}").as("Aianaesthesia_duration(min)")
|
||||
.andExpression("{$toLong: '$Doctoranaesthesia_duration(min)'}").as("Doctoranaesthesia_duration(min)")
|
||||
.andExpression("{$toDate: '$Time'}").as("time");
|
||||
operations.add(timeToDateOperation);
|
||||
|
||||
ProjectionOperation timeFormatOperation = Aggregation.project()
|
||||
.andInclude("Aianaesthesia_duration(min)")
|
||||
.andInclude("Doctoranaesthesia_duration(min)")
|
||||
.andExpression("{ $dateToString: { format: '%Y-%m-%d', date: '$time' } }").as("time");
|
||||
operations.add(timeFormatOperation);
|
||||
|
||||
operations.add(Aggregation.group("$time")
|
||||
.sum("Aianaesthesia_duration(min)").as("aicount")
|
||||
.sum("Doctoranaesthesia_duration(min)").as("doccount"));
|
||||
|
||||
operations.add(Aggregation.project()
|
||||
.andInclude("_id")
|
||||
.andExpression("aicount").divide(60).as("aicount")
|
||||
.andExpression("doccount").divide(60).as("doccount"));
|
||||
|
||||
operations.add(Aggregation.project()
|
||||
.andInclude("_id")
|
||||
.andExpression("{$round: {'$aicount', 1}}").as("aicount")
|
||||
.andExpression("{$round: {'$doccount', 1}}").as("doccount"));
|
||||
|
||||
operations.add(Aggregation.sort(Sort.Direction.ASC, "_id"));
|
||||
|
||||
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();
|
||||
// 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,21 +1,11 @@
|
|||
package com.rax.vital.v2.medicine.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.rax.common.core.util.R;
|
||||
import com.rax.vital.common.datasource.MongoDBSource;
|
||||
import com.rax.vital.common.util.DatabaseNameUtil;
|
||||
import com.rax.vital.v2.medicine.service.SurgeryServiceV2;
|
||||
import org.bson.BsonRegularExpression;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.*;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -23,26 +13,11 @@ import java.util.Map;
|
|||
* project_name:remote-control-backend
|
||||
* time:2024/8/23 16:23
|
||||
* author:republicline
|
||||
* 术中信息服务实现
|
||||
* 术中信息服务实现 V2, 针对mongoDB数据库
|
||||
*/
|
||||
@Component
|
||||
public class SurgeryServiceV2Impl implements SurgeryServiceV2 {
|
||||
@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;
|
||||
|
||||
@Value("${vital-sign.except-database}")
|
||||
private String exceptDatabase;
|
||||
|
||||
@Value("${vital-sign.information-database}")
|
||||
private String informationDatabase;
|
||||
|
||||
@Override
|
||||
public List<Map> getVitalSignsList(MongoTemplate template) {
|
||||
|
|
@ -69,295 +44,5 @@ public class SurgeryServiceV2Impl implements SurgeryServiceV2 {
|
|||
return vitalList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R getPatientInfo(String databaseName) {
|
||||
MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, databaseName);
|
||||
mongoDBSource.open();
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page getPatientPage(String name, String dept, long offset, int limit) {
|
||||
MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, informationDatabase);
|
||||
mongoDBSource.open();
|
||||
MongoTemplate template = mongoDBSource.getConnection();
|
||||
Query query = new Query();
|
||||
|
||||
if (StringUtils.hasText(name)) {
|
||||
Criteria criteria = new Criteria("姓名");
|
||||
criteria.regex(new BsonRegularExpression(".*" + name + ".*"));
|
||||
query.addCriteria(criteria);
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(dept)) {
|
||||
Criteria criteria = new Criteria("科室");
|
||||
criteria.regex(new BsonRegularExpression(dept));
|
||||
query.addCriteria(criteria);
|
||||
}
|
||||
|
||||
query.with(Sort.by(Sort.Order.desc("住院时间")));
|
||||
query.skip(offset).limit(limit);
|
||||
List<Map> list = template.find(query, Map.class, "patient_info");
|
||||
long count = template.count(query, "patient_info");
|
||||
Page page = new Page();
|
||||
page.setRecords(list);
|
||||
page.setTotal(count);
|
||||
mongoDBSource.close();
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getSurgeryCount(String start, String end) {
|
||||
MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, informationDatabase);
|
||||
mongoDBSource.open();
|
||||
MongoTemplate template = mongoDBSource.getConnection();
|
||||
List<AggregationOperation> operations = new ArrayList<>();
|
||||
|
||||
// Criteria criteria = new Criteria("Time");
|
||||
// criteria.gte(start);
|
||||
// criteria.lte(end);
|
||||
|
||||
Criteria criteria = Criteria.where("Time")
|
||||
.gte(start)
|
||||
.lte(end);
|
||||
|
||||
|
||||
operations.add(Aggregation.match(criteria));
|
||||
|
||||
ProjectionOperation timeToDateOperation = Aggregation.project()
|
||||
.andExpression("Time").as("Time")
|
||||
.andExpression("{$toDate: '$Time'}").as("time");
|
||||
operations.add(timeToDateOperation);
|
||||
|
||||
ProjectionOperation timeFormatOperation = Aggregation.project()
|
||||
.andExpression("{ $dateToString: { format: '%Y-%m-%d', date: '$time' } }").as("time");
|
||||
operations.add(timeFormatOperation);
|
||||
|
||||
operations.add(Aggregation.group("$time").count().as("count"));
|
||||
|
||||
operations.add(Aggregation.project()
|
||||
.andInclude("count")
|
||||
.andExpression("{$toDate: '$_id'}").as("time"));
|
||||
|
||||
operations.add(Aggregation.project()
|
||||
.andInclude("count")
|
||||
.andExpression("{ $dateToString: { format: '%d', date: '$time' } }").as("time"));
|
||||
|
||||
operations.add(Aggregation.sort(Sort.Direction.ASC, "time"));
|
||||
|
||||
TypedAggregation typedAggregation = new TypedAggregation(Map.class, operations);
|
||||
AggregationResults<Map> aggregate = template.aggregate(typedAggregation, "surgery_info", Map.class);
|
||||
List<Map> mappedResults = aggregate.getMappedResults();
|
||||
mongoDBSource.close();
|
||||
return mappedResults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getSurgeryDuration(String start, String end) {
|
||||
MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, informationDatabase);
|
||||
mongoDBSource.open();
|
||||
MongoTemplate template = mongoDBSource.getConnection();
|
||||
List<AggregationOperation> operations = new ArrayList<>();
|
||||
|
||||
Criteria criteria = new Criteria("Time");
|
||||
criteria.gte(start);
|
||||
criteria.lte(end);
|
||||
operations.add(Aggregation.match(criteria));
|
||||
|
||||
|
||||
ProjectionOperation timeToDateOperation = Aggregation.project()
|
||||
.andExpression("{$toLong: '$Surgery_duration(min)'}").as("Surgery_duration(min)")
|
||||
.andExpression("{$toDate: '$Time'}").as("day");
|
||||
operations.add(timeToDateOperation);
|
||||
|
||||
ProjectionOperation timeFormatOperation = Aggregation.project()
|
||||
.andInclude("Surgery_duration(min)")
|
||||
.andExpression("{ $dateToString: { format: '%Y-%m-%d', date: '$day' } }").as("time");
|
||||
operations.add(timeFormatOperation);
|
||||
|
||||
operations.add(Aggregation.group("$time").sum("Surgery_duration(min)").as("count"));
|
||||
|
||||
operations.add(Aggregation.project()
|
||||
.andInclude("_id")
|
||||
.andExpression("count").divide(60).as("count"));
|
||||
|
||||
operations.add(Aggregation.project()
|
||||
.andInclude("_id")
|
||||
.andExpression("{$round: {'$count', 1}}").as("duration"));
|
||||
|
||||
operations.add(Aggregation.project()
|
||||
.andInclude("duration")
|
||||
.andExpression("{$toDate: '$_id'}").as("time"));
|
||||
|
||||
operations.add(Aggregation.project()
|
||||
.andInclude("duration")
|
||||
.andExpression("{ $dateToString: { format: '%d', date: '$time' } }").as("_id"));
|
||||
|
||||
operations.add(Aggregation.sort(Sort.Direction.ASC, "_id"));
|
||||
|
||||
TypedAggregation typedAggregation = new TypedAggregation(Map.class, operations);
|
||||
AggregationResults<Map> aggregate = template.aggregate(typedAggregation, "surgery_info", Map.class);
|
||||
List<Map> mappedResults = aggregate.getMappedResults();
|
||||
mongoDBSource.close();
|
||||
return mappedResults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getSurgeryTypeProportion(String start, String end) {
|
||||
MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, informationDatabase);
|
||||
mongoDBSource.open();
|
||||
MongoTemplate template = mongoDBSource.getConnection();
|
||||
List<AggregationOperation> operations = new ArrayList<>();
|
||||
|
||||
Criteria criteria = new Criteria("Time");
|
||||
criteria.gte(start);
|
||||
criteria.lte(end);
|
||||
operations.add(Aggregation.match(criteria));
|
||||
|
||||
operations.add(Aggregation.group("$Surgery_type").count().as("count"));
|
||||
|
||||
TypedAggregation typedAggregation = new TypedAggregation(Map.class, operations);
|
||||
AggregationResults<Map> aggregate = template.aggregate(typedAggregation, "surgery_info", Map.class);
|
||||
List<Map> mappedResults = aggregate.getMappedResults();
|
||||
mongoDBSource.close();
|
||||
return mappedResults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getSurgeryOtherDuration(String start, String end) {
|
||||
MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, informationDatabase);
|
||||
mongoDBSource.open();
|
||||
MongoTemplate template = mongoDBSource.getConnection();
|
||||
List<AggregationOperation> operations = new ArrayList<>();
|
||||
|
||||
Criteria criteria = new Criteria("Time");
|
||||
criteria.gte(start);
|
||||
criteria.lte(end);
|
||||
operations.add(Aggregation.match(criteria));
|
||||
|
||||
ProjectionOperation timeToDateOperation = Aggregation.project()
|
||||
.andExpression("{$toLong: '$Aianaesthesia_duration(min)'}").as("Aianaesthesia_duration(min)")
|
||||
.andExpression("{$toLong: '$Doctoranaesthesia_duration(min)'}").as("Doctoranaesthesia_duration(min)")
|
||||
.andExpression("{$toDate: '$Time'}").as("time");
|
||||
operations.add(timeToDateOperation);
|
||||
|
||||
ProjectionOperation timeFormatOperation = Aggregation.project()
|
||||
.andInclude("Aianaesthesia_duration(min)")
|
||||
.andInclude("Doctoranaesthesia_duration(min)")
|
||||
.andExpression("{ $dateToString: { format: '%Y-%m-%d', date: '$time' } }").as("time");
|
||||
operations.add(timeFormatOperation);
|
||||
|
||||
operations.add(Aggregation.group("$time")
|
||||
.sum("Aianaesthesia_duration(min)").as("aicount")
|
||||
.sum("Doctoranaesthesia_duration(min)").as("doccount"));
|
||||
|
||||
operations.add(Aggregation.project()
|
||||
.andInclude("_id")
|
||||
.andExpression("aicount").divide(60).as("aicount")
|
||||
.andExpression("doccount").divide(60).as("doccount"));
|
||||
|
||||
operations.add(Aggregation.project()
|
||||
.andInclude("_id")
|
||||
.andExpression("{$round: {'$aicount', 1}}").as("aicount")
|
||||
.andExpression("{$round: {'$doccount', 1}}").as("doccount"));
|
||||
|
||||
operations.add(Aggregation.sort(Sort.Direction.ASC, "_id"));
|
||||
|
||||
TypedAggregation typedAggregation = new TypedAggregation(Map.class, operations);
|
||||
AggregationResults<Map> aggregate = template.aggregate(typedAggregation, "surgery_info", Map.class);
|
||||
List<Map> mappedResults = aggregate.getMappedResults();
|
||||
mongoDBSource.close();
|
||||
return mappedResults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getPatientSurgeryList(String name, String code, String surgery, String type) {
|
||||
if (StringUtils.hasText(code)) {
|
||||
MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, informationDatabase);
|
||||
mongoDBSource.open();
|
||||
MongoTemplate template = mongoDBSource.getConnection();
|
||||
|
||||
if (!StringUtils.hasText(name)) {
|
||||
Query query = new Query();
|
||||
Criteria criteria = new Criteria("住院号");
|
||||
criteria.regex(new BsonRegularExpression(code));
|
||||
query.addCriteria(criteria);
|
||||
List<Map> list = template.find(query, Map.class, "patient_info");
|
||||
if (!list.isEmpty()) {
|
||||
Map patient = list.get(0);
|
||||
name = (String) patient.get("姓名");
|
||||
} else {
|
||||
mongoDBSource.close();
|
||||
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 = template.find(query, Map.class, "surgery_info");
|
||||
mongoDBSource.close();
|
||||
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)) {
|
||||
MongoDBSource mongoDBSource = new MongoDBSource(mongoDBHost, mongoPassword, mongoUsername, informationDatabase);
|
||||
mongoDBSource.open();
|
||||
MongoTemplate template = mongoDBSource.getConnection();
|
||||
// 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 = template.find(query, Map.class, "patient_info");
|
||||
if (!list.isEmpty()) {
|
||||
Map patient = list.get(0);
|
||||
name = (String) patient.get("姓名");
|
||||
}
|
||||
mongoDBSource.close();
|
||||
}
|
||||
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<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
* project_name: remote-control-backend
|
||||
* time: 2024/8/20 15:09
|
||||
* author: republicline
|
||||
* 新的计时器任务, 和一期代码解耦
|
||||
* 新的计时器任务, 用于推送生命体征数据和药物信息数据到前端
|
||||
*/
|
||||
@RefreshScope
|
||||
@Component
|
||||
|
|
@ -94,11 +94,14 @@ public class VitalSignTimerV2 {
|
|||
|
||||
// 标记信息
|
||||
Map flags = flagService.getFlags(template);
|
||||
// flag
|
||||
// aiFlag 1代表AI给药 0代表医生给药
|
||||
// reFlag 1代表维持期 0代表诱导期
|
||||
// endFlag 1代表手术进行 0代表手术结束
|
||||
// linkFlag 1泵异常 0正常
|
||||
|
||||
/**
|
||||
* flag
|
||||
* aiFlag 1代表AI给药 0代表医生给药
|
||||
* reFlag 1代表维持期 0代表诱导期
|
||||
* endFlag 1代表手术进行 0代表手术结束
|
||||
* linkFlag 1泵异常 0正常
|
||||
*/
|
||||
jsonObject.put("flags", flags);
|
||||
Map<String, Object> medicineRateMap = new HashMap<>();
|
||||
if (flags.get("aiFlag") != null && flags.get("aiFlag").equals("1")) {
|
||||
|
|
|
|||
|
|
@ -83,9 +83,6 @@ aliyun:
|
|||
signName: AAceshi #阿里云签名名
|
||||
templateCode: SMS_471660037 # 模板code
|
||||
|
||||
# 配置版本信息
|
||||
project:
|
||||
version: v1
|
||||
|
||||
#--------------如下配置尽量不要变动-------------
|
||||
# mybatis-plus 配置
|
||||
|
|
@ -119,16 +116,22 @@ spring:
|
|||
port: 16373
|
||||
password: rax137839
|
||||
connect-timeout: 5000
|
||||
# database: 0 # 二期
|
||||
database: 1 # 一期
|
||||
|
||||
# 数据库相关配置
|
||||
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&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_backend?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&nullCatalogMeansCurrent=true
|
||||
|
||||
server:
|
||||
port: 6379
|
||||
port: 6679 #一期
|
||||
# port: 6379 #二期
|
||||
servlet:
|
||||
context-path: /admin
|
||||
|
||||
|
|
@ -162,7 +165,8 @@ spring:
|
|||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: root
|
||||
password: root
|
||||
url: jdbc:mysql://localhost:3306/rax_backend2?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&nullCatalogMeansCurrent=true
|
||||
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://localhost:3306/rax_backend?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&nullCatalogMeansCurrent=true # 二期
|
||||
|
||||
server:
|
||||
port: 9999
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package com.rax.admin.timmer;
|
||||
|
||||
import com.rax.vital.common.util.GetHttpParamUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* project_name:remote-control-backend
|
||||
* time:2024/9/3 15:28
|
||||
*/
|
||||
public class Test111 {
|
||||
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String url = "http://127.0.0.1:8080/upms/upms-biz/user/login?token=1";
|
||||
Map params = GetHttpParamUtil.getParams(url);
|
||||
String token = (String) params.get("token");
|
||||
System.out.println("params = " + params);
|
||||
System.out.println("token = " + token);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() throws URISyntaxException {
|
||||
URI uri = new URI("ws://localhost:6379/admin/rax/addMedicine?a=1&b=2&c=3");
|
||||
// 解析获取参数
|
||||
String query = uri.getQuery();
|
||||
String a = GetHttpParamUtil.getParam(query, "a");
|
||||
String b = GetHttpParamUtil.getParam(query, "b");
|
||||
System.out.println("a = " + a);
|
||||
System.out.println("b = " + b);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test3(){
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.rax.admin.timmer;
|
||||
|
||||
import com.rax.common.security.service.RaxUser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.security.oauth2.core.OAuth2AccessToken;
|
||||
import org.springframework.security.oauth2.server.authorization.OAuth2Authorization;
|
||||
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
|
||||
import org.springframework.security.oauth2.server.authorization.OAuth2TokenType;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* project_name:remote-control-backend
|
||||
* time:2024/9/3 17:10
|
||||
*/
|
||||
@SpringBootTest
|
||||
public class TestWithContainer {
|
||||
|
||||
@Autowired
|
||||
private OAuth2AuthorizationService authorizationService;
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
String token = "S1wM67-fdCG9cc7bJEpFtWH1WGacyQIiiOpBmQcrdDto0jSWwNPvn79bi3xTlWne5LtMe1IoKCKKWzA-7ctQkrvl7KV3e0pNrbUm8pt-TdLWgAeVXyqGT3DgirKb36hv";
|
||||
OAuth2Authorization byToken = authorizationService.findByToken(token, OAuth2TokenType.ACCESS_TOKEN);
|
||||
Map<String, Object> attributes = byToken.getAttributes();
|
||||
attributes.forEach(
|
||||
(key, value) -> {
|
||||
System.out.println(key + " = " + value);
|
||||
}
|
||||
);
|
||||
String principalName = byToken.getPrincipalName();
|
||||
OAuth2Authorization.Token<OAuth2AccessToken> accessToken = byToken.getAccessToken();
|
||||
Map<String, Object> claims = accessToken.getClaims();
|
||||
RaxUser o = (RaxUser) accessToken.getClaims().get("user_info");
|
||||
Long hospitalId = o.getHospitalId();
|
||||
System.out.println("hospitalId = " + hospitalId);
|
||||
System.out.println("======================");
|
||||
claims.forEach(
|
||||
(key, value) -> {
|
||||
System.out.println(key + " = " + value);
|
||||
}
|
||||
);
|
||||
System.out.println("principalName = " + principalName);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package com.rax.admin.timmer;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.rax.admin.api.entity.SysLog;
|
||||
import com.rax.admin.mapper.SysLogMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* project_name:remote-control-backend
|
||||
* time:2024/8/29 11:22
|
||||
*/
|
||||
@SpringBootTest
|
||||
class TimedTaskServiceTest {
|
||||
|
||||
@Autowired
|
||||
private SysLogMapper sysLogMapper;
|
||||
|
||||
|
||||
@Test
|
||||
void scheduled() {
|
||||
// 查询系统的全部用户的集合
|
||||
QueryWrapper<SysLog> sysLogQueryWrapper = new QueryWrapper<>();
|
||||
sysLogQueryWrapper.select("distinct create_by");
|
||||
List<String> userList = sysLogMapper.selectList(sysLogQueryWrapper)
|
||||
.stream().map(SysLog::getCreateBy).toList();
|
||||
System.out.println("userList = " + userList);
|
||||
// 获取30天前的时间
|
||||
// String agoDate = getDate(new Date(), 30);
|
||||
|
||||
for (String user : userList) {
|
||||
// 查询指定用户的日志集合id
|
||||
LambdaQueryWrapper<SysLog> sysLogWrapper = new LambdaQueryWrapper<>();
|
||||
String time = "2024-07-30 13:42:45";
|
||||
sysLogWrapper.eq(SysLog::getCreateBy, user)
|
||||
.le(SysLog::getCreateTime, "2024-07-30 13:42:45");
|
||||
List<Long> idList = sysLogMapper.selectListByTime(user, time)
|
||||
.stream()
|
||||
.map(SysLog::getId)
|
||||
.toList();
|
||||
System.out.println("user = " + user + ", listszie=" + idList.size() + ", List = " + idList);
|
||||
if (!idList.isEmpty()) {
|
||||
sysLogMapper.deleteBatchByIds(idList);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDate() {
|
||||
// 将 java.util.Date 转换为 java.time.LocalDateTime
|
||||
LocalDateTime localDateTime = new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
|
||||
// 计算 days 天前的日期时间
|
||||
LocalDateTime daysAgo = localDateTime.minusDays(30);
|
||||
|
||||
// 格式化为年月日时分秒
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
String format = daysAgo.format(formatter);
|
||||
System.out.println(format);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user