|
|
@@ -4,11 +4,10 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.coffee.bus.entity.BusDeviceAlarmEntity;
|
|
|
-import com.coffee.bus.entity.BusDeviceUsingEntity;
|
|
|
+import com.coffee.bus.entity.BusDeviceRunningEntity;
|
|
|
import com.coffee.bus.enums.DeviceAlarmEnum;
|
|
|
import com.coffee.bus.listener.event.bean.DeviceAlarmEvent;
|
|
|
import com.coffee.bus.registry.constant.DeviceKeyConstant;
|
|
|
@@ -21,7 +20,7 @@ import com.coffee.bus.registry.patient.PatientRegistry;
|
|
|
import com.coffee.bus.registry.patient.bean.DeviceTimeSmallInfo;
|
|
|
import com.coffee.bus.registry.patient.bean.PatientCacheInfo;
|
|
|
import com.coffee.bus.service.LocalBusDeviceAlarmService;
|
|
|
-import com.coffee.bus.service.LocalBusDeviceUsingService;
|
|
|
+import com.coffee.bus.service.LocalBusDeviceRunningService;
|
|
|
import com.coffee.bus.service.LocalBusPatientService;
|
|
|
import com.coffee.common.cache.value.Value;
|
|
|
import com.coffee.common.config.websocket.WebSocketConstant;
|
|
|
@@ -51,7 +50,7 @@ public class DeviceInfoListener {
|
|
|
|
|
|
private final RedisTemplate redisTemplate;
|
|
|
|
|
|
- private final LocalBusDeviceUsingService deviceUsingService;
|
|
|
+ private final LocalBusDeviceRunningService deviceUsingService;
|
|
|
|
|
|
private final LocalBusPatientService patientService;
|
|
|
|
|
|
@@ -74,7 +73,7 @@ public class DeviceInfoListener {
|
|
|
synchronized (infoEvent.getDeviceId()){
|
|
|
log.info("开始处理时间------------------------[{}]",System.currentTimeMillis());
|
|
|
/****************处理泵数据 todo 后续交由上游处理****************/
|
|
|
- BusDeviceUsingEntity device = infoEvent.getContent();
|
|
|
+ BusDeviceRunningEntity device = infoEvent.getContent();
|
|
|
//1、判断该设备是否已和医院绑定并开启使用
|
|
|
String deviceId = device.getDeviceId();
|
|
|
DeviceOperator<DeviceCacheInfo> deviceOperator = deviceRegistry.getDevice(deviceId);
|
|
|
@@ -124,8 +123,8 @@ public class DeviceInfoListener {
|
|
|
if (currentBindDevice.getStartTime().before(device.getStartTime())) {
|
|
|
log.error("病号:[{}],之前主泵为:[{}],现在主泵为:[{}]",device.getPatientCode(),bindDeviceId,deviceId);
|
|
|
//设置当前上传信息的泵为主泵,将旧泵设置为副泵吗,并更新病人绑定泵的信息, todo 发生泵重复报警
|
|
|
- deviceUsingService.update(new UpdateWrapper<BusDeviceUsingEntity>().lambda().eq(BusDeviceUsingEntity::getDeviceId,deviceId).set(BusDeviceUsingEntity::getMaster,1));
|
|
|
- deviceUsingService.update(new UpdateWrapper<BusDeviceUsingEntity>().lambda().eq(BusDeviceUsingEntity::getDeviceId,bindDeviceId).set(BusDeviceUsingEntity::getMaster,0));
|
|
|
+ deviceUsingService.update(new UpdateWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getDeviceId,deviceId).set(BusDeviceRunningEntity::getMaster,1));
|
|
|
+ deviceUsingService.update(new UpdateWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getDeviceId,bindDeviceId).set(BusDeviceRunningEntity::getMaster,0));
|
|
|
}else {
|
|
|
device.setMaster(0);
|
|
|
}
|
|
|
@@ -162,9 +161,9 @@ public class DeviceInfoListener {
|
|
|
if(master.isPresent()){
|
|
|
log.error("病号:[{}],主泵变为[{}]",originPatientCode,master.get().getDeviceId());
|
|
|
deviceUsingService
|
|
|
- .update(new UpdateWrapper<BusDeviceUsingEntity>().lambda()
|
|
|
- .eq(BusDeviceUsingEntity::getDeviceId,master.get().getDeviceId())
|
|
|
- .set(BusDeviceUsingEntity::getMaster,1));
|
|
|
+ .update(new UpdateWrapper<BusDeviceRunningEntity>().lambda()
|
|
|
+ .eq(BusDeviceRunningEntity::getDeviceId,master.get().getDeviceId())
|
|
|
+ .set(BusDeviceRunningEntity::getMaster,1));
|
|
|
//更新泵原来绑定病人缓存信息
|
|
|
originPatientOperator.setBindDeviceId(master.get().getDeviceId());
|
|
|
}
|
|
|
@@ -216,7 +215,7 @@ public class DeviceInfoListener {
|
|
|
* @param pump
|
|
|
* @param patientOperator
|
|
|
*/
|
|
|
- private void initPatient(BusDeviceUsingEntity pump, PatientOperator patientOperator) {
|
|
|
+ private void initPatient(BusDeviceRunningEntity pump, PatientOperator patientOperator) {
|
|
|
//填充病人名称和病人性别
|
|
|
pump.setPatientName(patientOperator.getName());
|
|
|
pump.setPatientSex(patientOperator.getGender());
|
|
|
@@ -227,7 +226,7 @@ public class DeviceInfoListener {
|
|
|
* @param pump
|
|
|
* @param deviceOperator
|
|
|
*/
|
|
|
- private void initDevice(BusDeviceUsingEntity pump, DeviceOperator deviceOperator){
|
|
|
+ private void initDevice(BusDeviceRunningEntity pump, DeviceOperator deviceOperator){
|
|
|
//处理无泵状态(即泵首次与医院进行绑定)
|
|
|
Date now = new Date();
|
|
|
//设置注册时间和泵的开始时间
|
|
|
@@ -243,7 +242,7 @@ public class DeviceInfoListener {
|
|
|
* @param device 设备信息
|
|
|
* @param deviceOperator 设备操作符
|
|
|
*/
|
|
|
- private void handleAlarm(String historyId,BusDeviceUsingEntity device,DeviceOperator deviceOperator){
|
|
|
+ private void handleAlarm(String historyId, BusDeviceRunningEntity device, DeviceOperator deviceOperator){
|
|
|
Value value = deviceOperator.getValue(DeviceKeyConstant.ALARM);
|
|
|
BusDeviceAlarmEntity alarm = new BusDeviceAlarmEntity(device.getDeviceId(),device.getAlarm(),new Date(),0,historyId,device.getClinicId(),device.getClassification());
|
|
|
if(Objects.isNull(value.get())){
|
|
|
@@ -273,9 +272,9 @@ public class DeviceInfoListener {
|
|
|
|
|
|
// @Scheduled(cron = "0/15 * * * * ?")
|
|
|
public void send() throws InterruptedException {
|
|
|
-// List<BusDeviceUsingEntity> list = deviceUsingService.list();
|
|
|
+// List<BusDeviceRunningEntity> list = deviceUsingService.list();
|
|
|
// list.forEach(pump->{
|
|
|
- BusDeviceUsingEntity pump = new BusDeviceUsingEntity();
|
|
|
+ BusDeviceRunningEntity pump = new BusDeviceRunningEntity();
|
|
|
pump.setClassification("-1");
|
|
|
pump.setDeviceId("123");
|
|
|
pump.setPatientCode("456");
|
|
|
@@ -289,7 +288,7 @@ public class DeviceInfoListener {
|
|
|
|
|
|
Thread.sleep(5000);
|
|
|
|
|
|
- BusDeviceUsingEntity pump1 = new BusDeviceUsingEntity();
|
|
|
+ BusDeviceRunningEntity pump1 = new BusDeviceRunningEntity();
|
|
|
pump1.setDeviceId("456");
|
|
|
pump1.setClassification("-1");
|
|
|
pump1.setPatientCode("456");
|
|
|
@@ -303,7 +302,7 @@ public class DeviceInfoListener {
|
|
|
|
|
|
Thread.sleep(5000);
|
|
|
|
|
|
- BusDeviceUsingEntity pump2 = new BusDeviceUsingEntity();
|
|
|
+ BusDeviceRunningEntity pump2 = new BusDeviceRunningEntity();
|
|
|
pump2.setDeviceId("456");
|
|
|
pump2.setClassification("-1");
|
|
|
pump2.setPatientCode("789");
|