|
@@ -12,6 +12,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
|
|
+import com.coffee.bus.config.HospitalFunctionAnalConfigHandler;
|
|
|
|
|
+import com.coffee.bus.config.bean.FunctionAnalConfig;
|
|
|
import com.coffee.bus.entity.*;
|
|
import com.coffee.bus.entity.*;
|
|
|
import com.coffee.bus.enums.PatientAlarmEnum;
|
|
import com.coffee.bus.enums.PatientAlarmEnum;
|
|
|
import com.coffee.bus.registry.device.DeviceRegistry;
|
|
import com.coffee.bus.registry.device.DeviceRegistry;
|
|
@@ -24,8 +26,10 @@ 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.bus.utils.WsPublishUtils;
|
|
import com.coffee.bus.utils.WsPublishUtils;
|
|
|
|
|
+import com.coffee.common.util.RedissonUtil;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.context.event.EventListener;
|
|
import org.springframework.context.event.EventListener;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -70,6 +74,10 @@ public class DeviceInfoListener {
|
|
|
private final WsPublishUtils wsPublishUtils;
|
|
private final WsPublishUtils wsPublishUtils;
|
|
|
|
|
|
|
|
private final LocalBusDeviceService deviceService;
|
|
private final LocalBusDeviceService deviceService;
|
|
|
|
|
+
|
|
|
|
|
+ private final RedissonUtil redissonUtil;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 监听上传的数据信息,
|
|
* 监听上传的数据信息,
|
|
|
* 若设备详情发生变化,则及时通知相应的ws通道
|
|
* 若设备详情发生变化,则及时通知相应的ws通道
|
|
@@ -86,7 +94,7 @@ public class DeviceInfoListener {
|
|
|
/****************处理泵数据 todo 后续交由上游处理****************/
|
|
/****************处理泵数据 todo 后续交由上游处理****************/
|
|
|
BusDeviceRunningEntity device = infoEvent.getContent();
|
|
BusDeviceRunningEntity device = infoEvent.getContent();
|
|
|
device.setMonitorType(true);
|
|
device.setMonitorType(true);
|
|
|
- device.setMaster(true);
|
|
|
|
|
|
|
+ device.setMaster(false);
|
|
|
//1、判断该设备是否已和医院绑定并开启使用
|
|
//1、判断该设备是否已和医院绑定并开启使用
|
|
|
String deviceId = device.getDeviceId();
|
|
String deviceId = device.getDeviceId();
|
|
|
device.setUploadTime(device.getUploadTime()==null?new Date():device.getUploadTime());
|
|
device.setUploadTime(device.getUploadTime()==null?new Date():device.getUploadTime());
|
|
@@ -105,13 +113,14 @@ public class DeviceInfoListener {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
log.info("接收到设备数据:[{}]", JSONUtil.toJsonStr(infoEvent.getContent()));
|
|
log.info("接收到设备数据:[{}]", JSONUtil.toJsonStr(infoEvent.getContent()));
|
|
|
- AtomicBoolean newInfusion=new AtomicBoolean(false);
|
|
|
|
|
//缓存操作
|
|
//缓存操作
|
|
|
List<Supplier<?>> cacheOperation=new ArrayList<>();
|
|
List<Supplier<?>> cacheOperation=new ArrayList<>();
|
|
|
//处理设备运行数据, 判断是否为注册后第一次开机,判断是否为新的输注信息
|
|
//处理设备运行数据, 判断是否为注册后第一次开机,判断是否为新的输注信息
|
|
|
- boolean first = handleRunningInfo(device, deviceOperator,newInfusion,cacheOperation);
|
|
|
|
|
|
|
+ boolean first = handleRunningInfo(device, deviceOperator,cacheOperation);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//处理输注参数
|
|
//处理输注参数
|
|
|
- handleInfusion(device, deviceOperator, newInfusion, cacheOperation);
|
|
|
|
|
|
|
+ handleInfusion(device, deviceOperator, cacheOperation);
|
|
|
//处理历史运行数据
|
|
//处理历史运行数据
|
|
|
BusDeviceHistoryEntity history=handleRunningHistory(device);
|
|
BusDeviceHistoryEntity history=handleRunningHistory(device);
|
|
|
//处理报警、提醒信息
|
|
//处理报警、提醒信息
|
|
@@ -155,10 +164,9 @@ public class DeviceInfoListener {
|
|
|
* 设备运行数据处理,返回是否为第一次接受数据消息
|
|
* 设备运行数据处理,返回是否为第一次接受数据消息
|
|
|
* @param device 接收到的设备信息
|
|
* @param device 接收到的设备信息
|
|
|
* @param deviceOperator 设备缓存信息操作符
|
|
* @param deviceOperator 设备缓存信息操作符
|
|
|
- * @param newInfusion 是否为新的输注
|
|
|
|
|
* @return 是否为第一次接收数据消息
|
|
* @return 是否为第一次接收数据消息
|
|
|
*/
|
|
*/
|
|
|
- private boolean handleRunningInfo( BusDeviceRunningEntity device,DeviceOperator<DeviceCacheInfo> deviceOperator,AtomicBoolean newInfusion,List<Supplier<?>> suppliers){
|
|
|
|
|
|
|
+ private boolean handleRunningInfo( BusDeviceRunningEntity device,DeviceOperator<DeviceCacheInfo> deviceOperator,List<Supplier<?>> suppliers){
|
|
|
//判断此条数据的分包标识是否发生了改变
|
|
//判断此条数据的分包标识是否发生了改变
|
|
|
String originClassify = deviceOperator.getClassification();
|
|
String originClassify = deviceOperator.getClassification();
|
|
|
String classification = device.getClassification();
|
|
String classification = device.getClassification();
|
|
@@ -167,7 +175,7 @@ public class DeviceInfoListener {
|
|
|
//todo 这部分操作交由上游处理
|
|
//todo 这部分操作交由上游处理
|
|
|
device.setTenantId(deviceOperator.getTenantId());
|
|
device.setTenantId(deviceOperator.getTenantId());
|
|
|
if(!classification.equals(originClassify)){
|
|
if(!classification.equals(originClassify)){
|
|
|
- newInfusion.set(true);
|
|
|
|
|
|
|
+ device.setNewInfusion(true);
|
|
|
//启动新的输注,则撤泵标识取消
|
|
//启动新的输注,则撤泵标识取消
|
|
|
device.setIsUndo(false);
|
|
device.setIsUndo(false);
|
|
|
//分包标识发生了改变,设备开机时间重新计算
|
|
//分包标识发生了改变,设备开机时间重新计算
|
|
@@ -182,15 +190,14 @@ public class DeviceInfoListener {
|
|
|
first=true;
|
|
first=true;
|
|
|
}else {
|
|
}else {
|
|
|
device.setId(usingId);
|
|
device.setId(usingId);
|
|
|
- if(!newInfusion.get()){
|
|
|
|
|
|
|
+ if(!device.isNewInfusion()){
|
|
|
device.setStartTime(deviceOperator.getStartTime());
|
|
device.setStartTime(deviceOperator.getStartTime());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
suppliers.add(()->{
|
|
suppliers.add(()->{
|
|
|
//更新设备缓存数据
|
|
//更新设备缓存数据
|
|
|
- if(newInfusion.get()){
|
|
|
|
|
|
|
+ if(device.isNewInfusion()){
|
|
|
deviceOperator.setUndo(false);
|
|
deviceOperator.setUndo(false);
|
|
|
-// patientOperator.setFinished(false);
|
|
|
|
|
}
|
|
}
|
|
|
deviceOperator.setClassification(device.getClassification());
|
|
deviceOperator.setClassification(device.getClassification());
|
|
|
|
|
|
|
@@ -210,7 +217,7 @@ public class DeviceInfoListener {
|
|
|
* @param device 接收到的设备数据
|
|
* @param device 接收到的设备数据
|
|
|
* @return 是否发生了换泵操作
|
|
* @return 是否发生了换泵操作
|
|
|
*/
|
|
*/
|
|
|
- private void handlePatient(BusDeviceRunningEntity device, AtomicBoolean newInfusion,List<Supplier<?>> suppliers){
|
|
|
|
|
|
|
+ private void handlePatient(BusDeviceRunningEntity device,List<Supplier<?>> suppliers){
|
|
|
String deviceId = device.getDeviceId();
|
|
String deviceId = device.getDeviceId();
|
|
|
DeviceOperator<DeviceCacheInfo> currentDeviceOperator = deviceRegistry.getOperator(deviceId);
|
|
DeviceOperator<DeviceCacheInfo> currentDeviceOperator = deviceRegistry.getOperator(deviceId);
|
|
|
PatientOperator<PatientCacheInfo> currentPatientOperator = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode());
|
|
PatientOperator<PatientCacheInfo> currentPatientOperator = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode());
|
|
@@ -221,7 +228,7 @@ public class DeviceInfoListener {
|
|
|
log.error("病号:【{}】临床发生由无泵转为有泵",device.getPatientCode());
|
|
log.error("病号:【{}】临床发生由无泵转为有泵",device.getPatientCode());
|
|
|
patientService.update(new UpdateWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode,device.getPatientCode())
|
|
patientService.update(new UpdateWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode,device.getPatientCode())
|
|
|
.eq(BusPatientEntity::getTenantId,device.getTenantId())
|
|
.eq(BusPatientEntity::getTenantId,device.getTenantId())
|
|
|
- .set(newInfusion.get(),BusPatientEntity::getInfusionId,device.getInfusionId())
|
|
|
|
|
|
|
+ .set(device.isNewInfusion(),BusPatientEntity::getInfusionId,device.getInfusionId())
|
|
|
.set(BusPatientEntity::getAlarm, null)
|
|
.set(BusPatientEntity::getAlarm, null)
|
|
|
);
|
|
);
|
|
|
suppliers.add(()->{
|
|
suppliers.add(()->{
|
|
@@ -235,10 +242,10 @@ public class DeviceInfoListener {
|
|
|
return null;
|
|
return null;
|
|
|
});
|
|
});
|
|
|
}else {
|
|
}else {
|
|
|
- if(newInfusion.get()){
|
|
|
|
|
|
|
+ if(device.isNewInfusion()){
|
|
|
patientService.update(new UpdateWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode,device.getPatientCode())
|
|
patientService.update(new UpdateWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode,device.getPatientCode())
|
|
|
.eq(BusPatientEntity::getTenantId,device.getTenantId())
|
|
.eq(BusPatientEntity::getTenantId,device.getTenantId())
|
|
|
- .set(newInfusion.get(),BusPatientEntity::getInfusionId,device.getInfusionId()));
|
|
|
|
|
|
|
+ .set(device.isNewInfusion(),BusPatientEntity::getInfusionId,device.getInfusionId()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//更新泵所绑定当前病人缓存信息
|
|
//更新泵所绑定当前病人缓存信息
|
|
@@ -364,13 +371,12 @@ public class DeviceInfoListener {
|
|
|
* 处理输注历史记录信息
|
|
* 处理输注历史记录信息
|
|
|
* @param device 设备当前运行数据
|
|
* @param device 设备当前运行数据
|
|
|
* @param deviceOperator 设备数据操作符
|
|
* @param deviceOperator 设备数据操作符
|
|
|
- * @param newInfusion 是否创建新的输注记录
|
|
|
|
|
* @param cacheOperation 缓存操作
|
|
* @param cacheOperation 缓存操作
|
|
|
*/
|
|
*/
|
|
|
- private BusInfusionHistoryEntity handleInfusionHistory(BusDeviceRunningEntity device, DeviceOperator<DeviceCacheInfo> deviceOperator, AtomicBoolean newInfusion, List<Supplier<?>> cacheOperation) {
|
|
|
|
|
|
|
+ private BusInfusionHistoryEntity handleInfusionHistory(BusDeviceRunningEntity device, DeviceOperator<DeviceCacheInfo> deviceOperator, List<Supplier<?>> cacheOperation) {
|
|
|
BusInfusionHistoryEntity infusionHistory = BusInfusionHistoryEntity.parseRunningInfo(device);
|
|
BusInfusionHistoryEntity infusionHistory = BusInfusionHistoryEntity.parseRunningInfo(device);
|
|
|
String originInfusionId = deviceOperator.getInfusionId();
|
|
String originInfusionId = deviceOperator.getInfusionId();
|
|
|
- if (newInfusion.get()) {
|
|
|
|
|
|
|
+ if (device.isNewInfusion()) {
|
|
|
//检测数据库是否存在该输注信息
|
|
//检测数据库是否存在该输注信息
|
|
|
infusionHistory.setId(String.valueOf(IdWorker.getId()));
|
|
infusionHistory.setId(String.valueOf(IdWorker.getId()));
|
|
|
infusionHistoryService.update(new UpdateWrapper<BusInfusionHistoryEntity>().lambda()
|
|
infusionHistoryService.update(new UpdateWrapper<BusInfusionHistoryEntity>().lambda()
|
|
@@ -394,18 +400,17 @@ public class DeviceInfoListener {
|
|
|
* 处理输注信息
|
|
* 处理输注信息
|
|
|
* @param device 设备运行数据
|
|
* @param device 设备运行数据
|
|
|
* @param deviceOperator 设备操作符
|
|
* @param deviceOperator 设备操作符
|
|
|
- * @param newInfusion 是否为新的输注记录
|
|
|
|
|
* @param cacheOperation 缓存操作
|
|
* @param cacheOperation 缓存操作
|
|
|
*/
|
|
*/
|
|
|
- private BusInfusionHistoryEntity handleInfusion(BusDeviceRunningEntity device, DeviceOperator<DeviceCacheInfo> deviceOperator, AtomicBoolean newInfusion, List<Supplier<?>> cacheOperation) {
|
|
|
|
|
|
|
+ private BusInfusionHistoryEntity handleInfusion(BusDeviceRunningEntity device, DeviceOperator<DeviceCacheInfo> deviceOperator, List<Supplier<?>> cacheOperation) {
|
|
|
PatientOperator<PatientCacheInfo> operator = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode(),MapUtil.of("startTime", device.getStartTime()));
|
|
PatientOperator<PatientCacheInfo> operator = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode(),MapUtil.of("startTime", device.getStartTime()));
|
|
|
device.setClinicId(operator.getClinicId());
|
|
device.setClinicId(operator.getClinicId());
|
|
|
|
|
|
|
|
- BusInfusionHistoryEntity infusionHistory = handleInfusionHistory(device, deviceOperator, newInfusion, cacheOperation);
|
|
|
|
|
|
|
+ BusInfusionHistoryEntity infusionHistory = handleInfusionHistory(device, deviceOperator, cacheOperation);
|
|
|
BusInfusionModifyEntity busInfusionModify = BusInfusionModifyEntity.parseRunningInfo(device);
|
|
BusInfusionModifyEntity busInfusionModify = BusInfusionModifyEntity.parseRunningInfo(device);
|
|
|
String signHex = busInfusionModify.signParam(sign);
|
|
String signHex = busInfusionModify.signParam(sign);
|
|
|
String infusionParam = deviceOperator.getInfusionParam();
|
|
String infusionParam = deviceOperator.getInfusionParam();
|
|
|
-
|
|
|
|
|
|
|
+ device.setMaster(true);
|
|
|
//输注参数已发生变化
|
|
//输注参数已发生变化
|
|
|
if(ObjectUtil.notEqual(signHex,infusionParam)){
|
|
if(ObjectUtil.notEqual(signHex,infusionParam)){
|
|
|
infusionModifyService.save(busInfusionModify);
|
|
infusionModifyService.save(busInfusionModify);
|
|
@@ -415,8 +420,8 @@ public class DeviceInfoListener {
|
|
|
|
|
|
|
|
if(Boolean.TRUE.equals(patientOperator.getFinished())){
|
|
if(Boolean.TRUE.equals(patientOperator.getFinished())){
|
|
|
//若临床已结束,则只有新的输注能够进行泵冲突处理
|
|
//若临床已结束,则只有新的输注能够进行泵冲突处理
|
|
|
- if(newInfusion.get()){
|
|
|
|
|
- handlePatient(device,newInfusion,cacheOperation);
|
|
|
|
|
|
|
+ if(device.isNewInfusion()){
|
|
|
|
|
+ handlePatient(device,cacheOperation);
|
|
|
clinicService
|
|
clinicService
|
|
|
.update(new UpdateWrapper<BusClinicEntity>().lambda().eq(BusClinicEntity::getId,patientOperator.getClinicId())
|
|
.update(new UpdateWrapper<BusClinicEntity>().lambda().eq(BusClinicEntity::getId,patientOperator.getClinicId())
|
|
|
.set(BusClinicEntity::getFinished,false));
|
|
.set(BusClinicEntity::getFinished,false));
|
|
@@ -427,7 +432,7 @@ public class DeviceInfoListener {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}else {
|
|
}else {
|
|
|
- handlePatient(device,newInfusion,cacheOperation);
|
|
|
|
|
|
|
+ handlePatient(device,cacheOperation);
|
|
|
}
|
|
}
|
|
|
cacheOperation.add(()->{
|
|
cacheOperation.add(()->{
|
|
|
deviceOperator.setInfusionParam(signHex);
|
|
deviceOperator.setInfusionParam(signHex);
|
|
@@ -473,7 +478,7 @@ public class DeviceInfoListener {
|
|
|
private void handleAlarmOrWarn(BusDeviceHistoryEntity history, DeviceOperator deviceOperator, List<Supplier<?>> cacheOperation){
|
|
private void handleAlarmOrWarn(BusDeviceHistoryEntity history, DeviceOperator deviceOperator, List<Supplier<?>> cacheOperation){
|
|
|
if (BusDeviceAlarmEntity.alarmOrWarn(history)) {
|
|
if (BusDeviceAlarmEntity.alarmOrWarn(history)) {
|
|
|
//获取上一状态下的报警信息
|
|
//获取上一状态下的报警信息
|
|
|
- String lastAlarmSign = deviceOperator.getAlarm();
|
|
|
|
|
|
|
+ String lastAlarmSign = deviceOperator.getAlarmOrWarn();
|
|
|
BusDeviceAlarmEntity alarm = BusDeviceAlarmEntity.parseHistory(history);
|
|
BusDeviceAlarmEntity alarm = BusDeviceAlarmEntity.parseHistory(history);
|
|
|
String alarmSign = alarm.signParm(sign);
|
|
String alarmSign = alarm.signParm(sign);
|
|
|
|
|
|
|
@@ -506,14 +511,14 @@ public class DeviceInfoListener {
|
|
|
if(change!=0){
|
|
if(change!=0){
|
|
|
alarmService.save(alarm);
|
|
alarmService.save(alarm);
|
|
|
cacheOperation.add(()->{
|
|
cacheOperation.add(()->{
|
|
|
- deviceOperator.setAlarm(alarmSign);
|
|
|
|
|
|
|
+ deviceOperator.setAlarmOrWarn(alarmSign);
|
|
|
return null;
|
|
return null;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}else {
|
|
}else {
|
|
|
cacheOperation.add(()->{
|
|
cacheOperation.add(()->{
|
|
|
- deviceOperator.setAlarm(null);
|
|
|
|
|
|
|
+ deviceOperator.setAlarmOrWarn(null);
|
|
|
return null;
|
|
return null;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|