|
@@ -1,7 +1,7 @@
|
|
|
package com.coffee.bus.websocket.listener;
|
|
package com.coffee.bus.websocket.listener;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
-import cn.hutool.core.swing.RobotUtil;
|
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.crypto.SignUtil;
|
|
import cn.hutool.crypto.SignUtil;
|
|
@@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.coffee.bus.entity.*;
|
|
import com.coffee.bus.entity.*;
|
|
|
import com.coffee.bus.enums.DeviceAlarmEnum;
|
|
import com.coffee.bus.enums.DeviceAlarmEnum;
|
|
|
import com.coffee.bus.enums.DeviceEnum;
|
|
import com.coffee.bus.enums.DeviceEnum;
|
|
|
|
|
+import com.coffee.bus.listener.event.bean.HisEvent;
|
|
|
import com.coffee.bus.registry.device.DeviceRegistry;
|
|
import com.coffee.bus.registry.device.DeviceRegistry;
|
|
|
import com.coffee.bus.listener.event.bean.DeviceInfoEvent;
|
|
import com.coffee.bus.listener.event.bean.DeviceInfoEvent;
|
|
|
import com.coffee.bus.registry.device.bean.DeviceCacheInfo;
|
|
import com.coffee.bus.registry.device.bean.DeviceCacheInfo;
|
|
@@ -25,6 +26,7 @@ import com.coffee.bus.registry.patient.bean.DeviceTimeSmallInfo;
|
|
|
import com.coffee.bus.registry.patient.bean.PatientCacheInfo;
|
|
import com.coffee.bus.registry.patient.bean.PatientCacheInfo;
|
|
|
import com.coffee.bus.service.*;
|
|
import com.coffee.bus.service.*;
|
|
|
import com.coffee.common.config.websocket.WebSocketConstant;
|
|
import com.coffee.common.config.websocket.WebSocketConstant;
|
|
|
|
|
+import com.coffee.common.enums.SexEnum;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.context.event.EventListener;
|
|
import org.springframework.context.event.EventListener;
|
|
@@ -33,7 +35,6 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
-import java.awt.*;
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -85,7 +86,7 @@ public class DeviceInfoListener {
|
|
|
BusDeviceRunningEntity device = infoEvent.getContent();
|
|
BusDeviceRunningEntity device = infoEvent.getContent();
|
|
|
//1、判断该设备是否已和医院绑定并开启使用
|
|
//1、判断该设备是否已和医院绑定并开启使用
|
|
|
String deviceId = device.getDeviceId();
|
|
String deviceId = device.getDeviceId();
|
|
|
- DeviceOperator<DeviceCacheInfo> deviceOperator = deviceRegistry.getDevice(deviceId);
|
|
|
|
|
|
|
+ DeviceOperator<DeviceCacheInfo> deviceOperator = deviceRegistry.getOperator(deviceId);
|
|
|
if (deviceOperator==null||!Boolean.TRUE.equals(deviceOperator.getEnable())) {
|
|
if (deviceOperator==null||!Boolean.TRUE.equals(deviceOperator.getEnable())) {
|
|
|
log.warn("设备[{}]暂不可用,数据已丢弃",deviceId);
|
|
log.warn("设备[{}]暂不可用,数据已丢弃",deviceId);
|
|
|
return ;
|
|
return ;
|
|
@@ -164,7 +165,7 @@ public class DeviceInfoListener {
|
|
|
device.setStartTime(new Date());
|
|
device.setStartTime(new Date());
|
|
|
}else {
|
|
}else {
|
|
|
|
|
|
|
|
- PatientOperator<PatientCacheInfo> patient = patientRegistry.getPatient(device.getTenantId(), device.getPatientCode());
|
|
|
|
|
|
|
+ PatientOperator<PatientCacheInfo> patient = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode());
|
|
|
Boolean finished = patient.getFinished();
|
|
Boolean finished = patient.getFinished();
|
|
|
if(Boolean.TRUE.equals(finished)){
|
|
if(Boolean.TRUE.equals(finished)){
|
|
|
//分包标识未改变且临床已结束 ,则此次数据无效
|
|
//分包标识未改变且临床已结束 ,则此次数据无效
|
|
@@ -203,8 +204,8 @@ public class DeviceInfoListener {
|
|
|
*/
|
|
*/
|
|
|
private void handlePatient(BusDeviceRunningEntity device,List<Supplier<?>> suppliers){
|
|
private void handlePatient(BusDeviceRunningEntity device,List<Supplier<?>> suppliers){
|
|
|
String deviceId = device.getDeviceId();
|
|
String deviceId = device.getDeviceId();
|
|
|
- DeviceOperator<DeviceCacheInfo> currentDeviceOperator = deviceRegistry.getDevice(deviceId);
|
|
|
|
|
- PatientOperator<PatientCacheInfo> currentPatientOperator = patientRegistry.getPatient(device.getTenantId(), device.getPatientCode());
|
|
|
|
|
|
|
+ DeviceOperator<DeviceCacheInfo> currentDeviceOperator = deviceRegistry.getOperator(deviceId);
|
|
|
|
|
+ PatientOperator<PatientCacheInfo> currentPatientOperator = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode());
|
|
|
String bindDeviceId = currentPatientOperator.getBindDeviceId();
|
|
String bindDeviceId = currentPatientOperator.getBindDeviceId();
|
|
|
//当前病号所绑定的泵发生了改变,对当前病号进行处理
|
|
//当前病号所绑定的泵发生了改变,对当前病号进行处理
|
|
|
if(!StrUtil.isNullOrUndefined(bindDeviceId)&&!deviceId.equals(bindDeviceId)){
|
|
if(!StrUtil.isNullOrUndefined(bindDeviceId)&&!deviceId.equals(bindDeviceId)){
|
|
@@ -234,7 +235,7 @@ public class DeviceInfoListener {
|
|
|
* 病患信息处理,当泵所绑定病号发生变化时,处理泵原来所绑定病号信息
|
|
* 病患信息处理,当泵所绑定病号发生变化时,处理泵原来所绑定病号信息
|
|
|
*/
|
|
*/
|
|
|
private void handleConflictOriginPatient(String deviceId, String hospitalId, String patientCode, List<Supplier<?>> suppliers){
|
|
private void handleConflictOriginPatient(String deviceId, String hospitalId, String patientCode, List<Supplier<?>> suppliers){
|
|
|
- PatientOperator<PatientCacheInfo> patientOperator = patientRegistry.getPatient(hospitalId, patientCode);
|
|
|
|
|
|
|
+ PatientOperator<PatientCacheInfo> patientOperator = patientRegistry.getOperator(hospitalId, patientCode);
|
|
|
Set<DeviceTimeSmallInfo> allDevice = patientOperator.getAllDevice();
|
|
Set<DeviceTimeSmallInfo> allDevice = patientOperator.getAllDevice();
|
|
|
//过滤掉已换绑的泵,获取剩余所绑定的泵数据
|
|
//过滤掉已换绑的泵,获取剩余所绑定的泵数据
|
|
|
if(CollectionUtils.isNotEmpty(allDevice)){
|
|
if(CollectionUtils.isNotEmpty(allDevice)){
|
|
@@ -281,11 +282,11 @@ public class DeviceInfoListener {
|
|
|
*/
|
|
*/
|
|
|
private void handleConflictCurrentPatient(BusDeviceRunningEntity device, List<Supplier<?>> suppliers){
|
|
private void handleConflictCurrentPatient(BusDeviceRunningEntity device, List<Supplier<?>> suppliers){
|
|
|
String deviceId = device.getDeviceId();
|
|
String deviceId = device.getDeviceId();
|
|
|
- PatientOperator<PatientCacheInfo> patientOperator = patientRegistry.getPatient(device.getTenantId(), device.getPatientCode());
|
|
|
|
|
|
|
+ PatientOperator<PatientCacheInfo> patientOperator = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode());
|
|
|
String bindDeviceId = patientOperator.getBindDeviceId();
|
|
String bindDeviceId = patientOperator.getBindDeviceId();
|
|
|
if(!StrUtil.isNullOrUndefined(bindDeviceId)&&!deviceId.equals(bindDeviceId)){
|
|
if(!StrUtil.isNullOrUndefined(bindDeviceId)&&!deviceId.equals(bindDeviceId)){
|
|
|
//泵号发生改变,获取病号绑定的泵信息,判断绑定的泵开始时间,将开始时间稍后的泵设置为主泵
|
|
//泵号发生改变,获取病号绑定的泵信息,判断绑定的泵开始时间,将开始时间稍后的泵设置为主泵
|
|
|
- DeviceOperator<DeviceCacheInfo> patientCurrentBindDevice = deviceRegistry.getDevice(bindDeviceId);
|
|
|
|
|
|
|
+ DeviceOperator<DeviceCacheInfo> patientCurrentBindDevice = deviceRegistry.getOperator(bindDeviceId);
|
|
|
Date startTime = patientCurrentBindDevice.getStartTime();
|
|
Date startTime = patientCurrentBindDevice.getStartTime();
|
|
|
if (startTime==null||startTime.before(device.getStartTime())) {
|
|
if (startTime==null||startTime.before(device.getStartTime())) {
|
|
|
log.error("病号:[{}],之前主泵为:[{}],现在主泵为:[{}]",device.getPatientCode(),bindDeviceId,deviceId);
|
|
log.error("病号:[{}],之前主泵为:[{}],现在主泵为:[{}]",device.getPatientCode(),bindDeviceId,deviceId);
|
|
@@ -417,7 +418,7 @@ public class DeviceInfoListener {
|
|
|
public void send() throws InterruptedException {
|
|
public void send() throws InterruptedException {
|
|
|
// List<BusDeviceRunningEntity> list = deviceUsingService.list();
|
|
// List<BusDeviceRunningEntity> list = deviceUsingService.list();
|
|
|
// list.forEach(pump->{
|
|
// list.forEach(pump->{
|
|
|
- while (count>3){
|
|
|
|
|
|
|
+ while (count>1){
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
++count;
|
|
++count;
|
|
@@ -482,5 +483,19 @@ public class DeviceInfoListener {
|
|
|
pump3.setPcaTotalCount(RandomUtil.randomInt(100));
|
|
pump3.setPcaTotalCount(RandomUtil.randomInt(100));
|
|
|
SpringUtil.publishEvent(new DeviceInfoEvent(this,pump3,pump3.getDeviceId()));
|
|
SpringUtil.publishEvent(new DeviceInfoEvent(this,pump3,pump3.getDeviceId()));
|
|
|
// });
|
|
// });
|
|
|
|
|
+ Thread.sleep(5000);
|
|
|
|
|
+ String now = DateUtil.now();
|
|
|
|
|
+ BusClinicEntity clinic = new BusClinicEntity();
|
|
|
|
|
+ clinic.setPatientCode("456");
|
|
|
|
|
+ clinic.setName("临床:"+ now);
|
|
|
|
|
+ clinic.setPatientName("病号:"+now);
|
|
|
|
|
+ clinic.setPatientGender(SexEnum.MAN);
|
|
|
|
|
+ clinic.setPatientAge(12);
|
|
|
|
|
+ clinic.setWard("病区:"+now);
|
|
|
|
|
+ clinic.setBedNo("床号:"+now);
|
|
|
|
|
+ clinic.setTenantId("1505808170691784706");
|
|
|
|
|
+ clinic.setStartTime(new Date());
|
|
|
|
|
+ SpringUtil.publishEvent(new HisEvent(this,Arrays.asList(clinic),clinic.getTenantId()));
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|