|
|
@@ -3,8 +3,9 @@ package com.coffee.bus.websocket.listener;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.coffee.bus.device.DeviceOperator;
|
|
|
-import com.coffee.bus.device.DeviceRegistry;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
+import com.coffee.bus.registry.device.DeviceOperator;
|
|
|
+import com.coffee.bus.registry.device.DeviceRegistry;
|
|
|
import com.coffee.bus.entity.BusPumpEntity;
|
|
|
import com.coffee.bus.enums.NetPumpStatusEnum;
|
|
|
import com.coffee.bus.listener.event.bean.DeviceAlarmEvent;
|
|
|
@@ -12,7 +13,6 @@ import com.coffee.bus.listener.event.bean.DeviceInfoEvent;
|
|
|
import com.coffee.bus.service.LocalBusPumpService;
|
|
|
import com.coffee.bus.service.LocalBusPatientService;
|
|
|
import com.coffee.common.config.websocket.WebSocketConstant;
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.event.EventListener;
|
|
|
@@ -21,7 +21,6 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import javax.annotation.PostConstruct;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
@@ -35,7 +34,6 @@ import java.util.List;
|
|
|
* @createTime 2022年03月27日 11:21:00
|
|
|
*/
|
|
|
@Component
|
|
|
-@AllArgsConstructor
|
|
|
@Slf4j
|
|
|
public class DeviceInfoListener {
|
|
|
|
|
|
@@ -55,12 +53,6 @@ public class DeviceInfoListener {
|
|
|
this.deviceRegistry=deviceRegistry;
|
|
|
}
|
|
|
|
|
|
- private DeviceInfoListener deviceInfoListener;
|
|
|
-
|
|
|
- @PostConstruct
|
|
|
- public void init(){
|
|
|
- deviceInfoListener=SpringUtil.getBean(DeviceInfoListener.class);
|
|
|
- }
|
|
|
/**
|
|
|
* 监听上传的数据信息,
|
|
|
* 若设备详情发生变化,则及时通知相应的ws通道
|
|
|
@@ -78,36 +70,31 @@ public class DeviceInfoListener {
|
|
|
return ;
|
|
|
}
|
|
|
BusPumpEntity exist = deviceRunInfoService.getByDeviceId(device.getDeviceId());
|
|
|
- //2、设备信息发生变化
|
|
|
device.setMonitorType(1);
|
|
|
- if(exist==null){
|
|
|
- //3、将设备和医院、病人进行绑定
|
|
|
+ //首次运行需要与病人、语言进行绑定
|
|
|
+ if(deviceOperator.isFirst()){
|
|
|
+ //处理无泵状态(即泵首次与医院进行绑定)
|
|
|
Date now = new Date();
|
|
|
+
|
|
|
+ //设置注册时间和泵的开始时间
|
|
|
+ device.setId(String.valueOf(IdWorker.getId()));
|
|
|
+
|
|
|
device.setRegisterTime(now);
|
|
|
device.setStartTime(now);
|
|
|
device.setAlias(deviceOperator.getAlias());
|
|
|
- //获取设备绑定医院
|
|
|
+ //设备绑定医院
|
|
|
device.setTenantId(deviceOperator.getTenantId());
|
|
|
+
|
|
|
+ //缓存存储泵的开始时间和注册时间
|
|
|
+ deviceOperator.updateRegisterTime(now);
|
|
|
+ deviceOperator.updateStartTime(now);
|
|
|
+
|
|
|
//判断是否存在临床信息 ,拉取临床信息
|
|
|
deviceRunInfoService.save(device);
|
|
|
}
|
|
|
-// else if(exist.getIsUndo()){
|
|
|
-//// 已撤泵
|
|
|
-// return;
|
|
|
-// }
|
|
|
else {
|
|
|
- device.setStartTime(exist.getStartTime());
|
|
|
- device.setRegisterTime(exist.getRegisterTime());
|
|
|
- device.setPatientCode(exist.getPatientCode());
|
|
|
- device.setPatientName(exist.getPatientName());
|
|
|
- device.setPatientSex(exist.getPatientSex());
|
|
|
- device.setTenantId(deviceOperator.getTenantId());
|
|
|
- device.setClinicId(exist.getClinicId());
|
|
|
- device.setWard(exist.getWard());
|
|
|
- device.setBedNo(exist.getBedNo());
|
|
|
- device.setAlias(exist.getAlias());
|
|
|
- device.setRemark(exist.getRemark());
|
|
|
- device.setId(exist.getId());
|
|
|
+// fillDeviceInfoFromCache(device,deviceOperator);
|
|
|
+// deviceRunInfoService.updateById(device);
|
|
|
}
|
|
|
//病号是否进行换泵操作
|
|
|
if (patientService.isChangedDevice(device.getTenantId(),device.getPatientCode(),device.getDeviceId(),device.getStartTime())) {
|
|
|
@@ -149,6 +136,24 @@ public class DeviceInfoListener {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 从缓存中填充设备信息
|
|
|
+ */
|
|
|
+ public void fillDeviceInfoFromCache(BusPumpEntity device,DeviceOperator operator){
|
|
|
+ device.setStartTime(operator.getStartTime());
|
|
|
+ device.setRegisterTime(operator.getRegisterTime());
|
|
|
+ device.setPatientCode(operator.getPatientCode());
|
|
|
+ device.setPatientName(operator.getPatientName());
|
|
|
+ device.setPatientSex(operator.getGender());
|
|
|
+ device.setTenantId(operator.getTenantId());
|
|
|
+ device.setClinicId(operator.getClinicId());
|
|
|
+ device.setWard(operator.getWard());
|
|
|
+ device.setBedNo(operator.getBedNo());
|
|
|
+ device.setAlias(operator.getAlias());
|
|
|
+ device.setRemark(operator.getRemark());
|
|
|
+ device.setId(operator.getRunId());
|
|
|
+ }
|
|
|
+
|
|
|
@Scheduled(cron = "0/3 * * * * ?")
|
|
|
public void send(){
|
|
|
List<BusPumpEntity> list = deviceRunInfoService.list();
|