Forráskód Böngészése

add 病人信息缓存
add 设备信息缓存

18339543638 3 éve
szülő
commit
db649fc702

+ 2 - 1
coffee-admin/src/main/test/java/com/coffee/admin/BusNetpumpTest.java

@@ -33,12 +33,13 @@ public class BusNetpumpTest {
 //        StpUtil.login();
         BusPumpEntity netPumpEntity = new BusPumpEntity();
         netPumpEntity.setWarn(NetPumpWarnEnum.ComingEnd);
+        netPumpEntity.setId("1507903748141658113");
         netPumpEntity.setAlias("1");
         netPumpEntity.setBedNo("1");
         netPumpEntity.setDeviceId("123");
         netPumpEntity.setTenantId("123");
         netPumpEntity.setRegisterTime(new Date());
-        netPumpService.save(netPumpEntity);
+        netPumpService.updateById(netPumpEntity);
     }
 
     @Test

+ 6 - 3
coffee-system/src/main/java/com/coffee/bus/entity/BusPumpEntity.java

@@ -1,6 +1,7 @@
 package com.coffee.bus.entity;
 
 import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.coffee.bus.enums.NetPumpWarnEnum;
@@ -12,6 +13,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+import lombok.ToString;
 import lombok.experimental.Accessors;
 import org.apache.ibatis.type.EnumOrdinalTypeHandler;
 import java.math.BigDecimal;
@@ -25,6 +27,7 @@ import java.util.Date;
  * @author fanfan
  * @since 2020-07-03
  */
+@ToString
 @Data
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
@@ -46,7 +49,7 @@ public class BusPumpEntity extends TenantGenericEntity<String,String> {
     private String patientName;
 
     @ApiModelProperty(value = "病人性别")
-    @TableField(typeHandler = EnumOrdinalTypeHandler.class)
+    @TableField(typeHandler = EnumOrdinalTypeHandler.class,javaType = true)
     private SexEnum patientSex;
 
     @ApiModelProperty(value = "病区")
@@ -92,11 +95,11 @@ public class BusPumpEntity extends TenantGenericEntity<String,String> {
     private Integer totalCount;
 
     @ApiModelProperty(value = "泵运行状态")
-    @TableField(typeHandler = EnumOrdinalTypeHandler.class)
+    @TableField(typeHandler = EnumOrdinalTypeHandler.class,javaType = true)
     private NetPumpStatusEnum runState;
 
     @ApiModelProperty(value = "提醒信息")
-    @TableField(typeHandler = EnumOrdinalTypeHandler.class)
+    @TableField(typeHandler = EnumOrdinalTypeHandler.class,javaType = true)
     private NetPumpWarnEnum warn;
 
     @ApiModelProperty(value = "开始时间")

+ 1 - 0
coffee-system/src/main/java/com/coffee/bus/registry/device/ClusterDeviceRegistry.java

@@ -3,6 +3,7 @@ package com.coffee.bus.registry.device;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.coffee.bus.entity.BusDeviceRegisteredEntity;
 import com.coffee.bus.entity.BusPumpEntity;
 import com.coffee.bus.registry.RegistryConstant;

+ 26 - 89
coffee-system/src/main/java/com/coffee/bus/registry/device/DeviceOperator.java

@@ -1,6 +1,7 @@
 package com.coffee.bus.registry.device;
 
 import cn.hutool.core.util.StrUtil;
+import com.coffee.bus.registry.RegistryConstant;
 import com.coffee.bus.registry.device.bean.DeviceBasicInfo;
 import com.coffee.common.enums.SexEnum;
 import com.coffee.common.redis.RedisUtils;
@@ -29,7 +30,7 @@ public class DeviceOperator {
     private final boolean validate;
 
     public static DeviceOperator of(DeviceBasicInfo deviceBasicInfo,RedisUtils redisUtils){
-        return new DeviceOperator(deviceBasicInfo,redisUtils,StrUtil.isNullOrUndefined(deviceBasicInfo.getDeviceId()));
+        return new DeviceOperator(deviceBasicInfo,redisUtils,!StrUtil.isNullOrUndefined(deviceBasicInfo.getDeviceId()));
     }
     /**
      * 清除缓存
@@ -93,66 +94,6 @@ public class DeviceOperator {
         return this;
     }
 
-
-//
-//    public DeviceOperator updatePatientCode(String patientCode){
-//        if(!validate)return this;
-//        deviceBasicInfo.setPatientCode(patientCode);
-//        redisUtils.hset(deviceBasicInfo.getKey(),"patientCode",patientCode);
-//        return this;
-//    }
-//
-//
-//
-//    public DeviceOperator updatePatientName(String patientName){
-//        if(!validate)return this;
-//        deviceBasicInfo.setPatientName(patientName);
-//        redisUtils.hset(deviceBasicInfo.getKey(),"patientName",patientName);
-//        return this;
-//    }
-//
-//
-//
-//    public DeviceOperator updateGender(SexEnum gender){
-//        if(!validate)return this;
-//        deviceBasicInfo.setGender(gender);
-//        redisUtils.hset(deviceBasicInfo.getKey(),"gender",gender);
-//        return this;
-//    }
-//
-//
-//
-//    public DeviceOperator updateBedNo(String bedNo){
-//        if(!validate)return this;
-//        deviceBasicInfo.setBedNo(bedNo);
-//        redisUtils.hset(deviceBasicInfo.getKey(),"bedNo",bedNo);
-//        return this;
-//    }
-//
-//
-//    public DeviceOperator updateWard(String ward){
-//        if(!validate)return this;
-//        deviceBasicInfo.setWard(ward);
-//        redisUtils.hset(deviceBasicInfo.getKey(),"ward",ward);
-//        return this;
-//    }
-//
-//
-//
-//    public DeviceOperator updateRemark(String remark){
-//        if(!validate)return this;
-//        deviceBasicInfo.setRemark(remark);
-//        redisUtils.hset(deviceBasicInfo.getKey(),"remark",remark);
-//        return this;
-//    }
-//
-//    public DeviceOperator updateClinicId(String clinicId){
-//        if(!validate)return this;
-//        deviceBasicInfo.setClinicId(clinicId);
-//        redisUtils.hset(deviceBasicInfo.getKey(),"clinicId",clinicId);
-//        return this;
-//    }
-
     public String getDeviceId(){
         return deviceBasicInfo.getDeviceId();
     }
@@ -181,33 +122,6 @@ public class DeviceOperator {
         return deviceBasicInfo.getRegisterTime();
     }
 
-//    public String getPatientCode(){
-//        return deviceBasicInfo.getPatientCode();
-//    }
-//
-//    public String getPatientName(){
-//        return deviceBasicInfo.getPatientName();
-//    }
-//
-//    public SexEnum getGender(){
-//        return deviceBasicInfo.getGender();
-//    }
-//
-//    public String getBedNo(){
-//        return deviceBasicInfo.getBedNo();
-//    }
-//
-//    public String getWard(){
-//        return deviceBasicInfo.getWard();
-//    }
-//
-//    public String getRemark(){
-//        return deviceBasicInfo.getRemark();
-//    }
-//
-//    public String getClinicId(){
-//        return deviceBasicInfo.getClinicId();
-//    }
     /**
      * 判断设备在系统中是否存在
      * @return
@@ -234,6 +148,29 @@ public class DeviceOperator {
     }
 
     public Map<String,Object> getMap(){
-        return new HashMap<>();
+        Map<String, Object> result = new HashMap<>();
+        if(null!=deviceBasicInfo.getId()){
+            result.put("id",deviceBasicInfo.getId());
+        }
+        if(null!=deviceBasicInfo.getDeviceId()){
+            result.put("deviceId",deviceBasicInfo.getDeviceId());
+        }
+        if(StrUtil.isNotEmpty(deviceBasicInfo.getAlias())){
+            result.put("alias",deviceBasicInfo.getAlias());
+        }
+        if(null!=deviceBasicInfo.getEnable()){
+            result.put("enable",deviceBasicInfo.getEnable());
+        }
+        if(StrUtil.isNotEmpty(deviceBasicInfo.getTenantId())){
+            result.put("tenantId",deviceBasicInfo.getTenantId());
+        }
+        if(null!=deviceBasicInfo.getStartTime()){
+            result.put("startTime",deviceBasicInfo.getStartTime());
+        }
+        if(null!=deviceBasicInfo.getRegisterTime()){
+            result.put("registerTime",deviceBasicInfo.getRegisterTime());
+        }
+
+        return result;
     }
 }

+ 22 - 16
coffee-system/src/main/java/com/coffee/bus/registry/device/bean/DeviceBasicInfo.java

@@ -3,7 +3,7 @@ package com.coffee.bus.registry.device.bean;
 import com.coffee.bus.entity.BusDeviceRegisteredEntity;
 import com.coffee.bus.entity.BusPumpEntity;
 import com.coffee.bus.registry.CacheInfo;
-import com.coffee.common.enums.SexEnum;
+import com.coffee.bus.registry.RegistryConstant;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
@@ -53,19 +53,14 @@ public class DeviceBasicInfo implements CacheInfo {
 
     private Date registerTime;
 
-//    private String patientCode;
-//
-//    private String patientName;
-//
-//    private SexEnum gender;
-//
-//    private String bedNo;
-//
-//    private String ward;
-//
-//    private String remark;
-//
-//    private String clinicId;
+    @Override
+    public String getKey() {
+        if(key==null){
+            return RegistryConstant.Device+deviceId;
+        }
+        return key;
+    }
+
     /*****泵正在运行状态********/
 
     public DeviceBasicInfo(String key,String deviceId, String alias, Integer enable, String tenantId) {
@@ -76,7 +71,18 @@ public class DeviceBasicInfo implements CacheInfo {
         this.key=key;
     }
 
-    public static DeviceBasicInfo of(String key,String deviceId, String alias, Integer enable, String tenantId) {
+    public DeviceBasicInfo(String key,String deviceId, String alias, Integer enable, String tenantId, String id, Date startTime, Date registerTime) {
+        this.key=key;
+        this.deviceId = deviceId;
+        this.alias = alias;
+        this.enable = enable;
+        this.tenantId = tenantId;
+        this.id = id;
+        this.startTime = startTime;
+        this.registerTime = registerTime;
+    }
+
+    public static DeviceBasicInfo of(String key, String deviceId, String alias, Integer enable, String tenantId) {
         return new DeviceBasicInfo(key,deviceId,alias,enable,tenantId);
     }
 
@@ -85,7 +91,7 @@ public class DeviceBasicInfo implements CacheInfo {
     }
 
     public static DeviceBasicInfo of(String key,BusPumpEntity pump, BusDeviceRegisteredEntity deviceRegistered) {
-        return new DeviceBasicInfo(key,pump.getDeviceId(), pump.getAlias(),deviceRegistered.getEnable(),pump.getTenantId());
+        return new DeviceBasicInfo(key,pump.getDeviceId(), pump.getAlias(),deviceRegistered.getEnable(),pump.getTenantId(),pump.getId(),pump.getStartTime(),pump.getRegisterTime());
     }
 
 }

+ 59 - 5
coffee-system/src/main/java/com/coffee/bus/registry/patient/ClusterPatientRegistry.java

@@ -2,6 +2,8 @@ package com.coffee.bus.registry.patient;
 
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.registry.RegistryConstant;
 import com.coffee.bus.registry.device.DeviceOperator;
 import com.coffee.bus.registry.device.bean.DeviceBasicInfo;
@@ -9,7 +11,10 @@ import com.coffee.bus.registry.patient.bean.PatientCurrentInfo;
 import com.coffee.bus.service.LocalBusPatientService;
 import com.coffee.common.redis.RedisUtils;
 import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Map;
 
@@ -22,21 +27,70 @@ import java.util.Map;
  */
 @AllArgsConstructor
 @Service
+@Slf4j
 public class ClusterPatientRegistry implements PatientRegistry {
     private final RedisUtils redisUtils;
     private final LocalBusPatientService patientService;
     @Override
-    public PatientOperator getPatient(String hospital, String patientCode) {
-        if(StrUtil.isEmpty(hospital)||StrUtil.isEmpty(patientCode)){
+    @Transactional(rollbackFor = Exception.class)
+    public PatientOperator getPatient(String hospitalId, String patientCode) {
+        if(StrUtil.isEmpty(hospitalId)||StrUtil.isEmpty(patientCode)){
             return PatientOperator.of(new PatientCurrentInfo(),redisUtils,null);
         }
-        String key=getId()+hospital+":"+patientCode;
+        String key=getId()+hospitalId+":"+patientCode;
         Map<Object, Object> result = redisUtils.hmget(key);
+        PatientCurrentInfo currentInfo = new PatientCurrentInfo();
+        currentInfo.setKey(key);
         if(result==null||result.size()==0){
-            //从数据库中获取数据
+            //将新数据存入数据库
+            BusPatientEntity patient = new BusPatientEntity();
+            patient.setCode(patientCode);
+            patient.setTenantId(hospitalId);
+            try {
+                //插入前二次判断
+                result=redisUtils.hmget(key);
+                if(result==null||result.size()==0){
+                    log.info("医院[{}]新增病号数据[{}]",hospitalId,patientCode);
+                    patientService.save(patient);
+                }
+            }catch (DuplicateKeyException e){
+                patient = patientService.getOne(new QueryWrapper<BusPatientEntity>()
+                        .lambda().eq(BusPatientEntity::getCode, patientCode)
+                        .eq(BusPatientEntity::getTenantId, hospitalId));
+                currentInfo.setPatientCode(patientCode);
+                currentInfo.setTenantId(hospitalId);
+                currentInfo.setPatientName(patient.getName());
+                currentInfo.setPatientGender(patient.getGender());
+                PatientOperator patientOperator = PatientOperator.of(currentInfo, redisUtils, null);
+                patientOperator.syncCache();
+                return patientOperator;
+            }
+            currentInfo.setPatientCode(patientCode);
+            currentInfo.setTenantId(hospitalId);
+            PatientOperator patientOperator = PatientOperator.of(currentInfo, redisUtils, null);
+            patientOperator.syncCache();
+            return patientOperator;
+
         }
         return PatientOperator.of(JSONUtil.toBean(JSONUtil.toJsonStr(result), PatientCurrentInfo.class),redisUtils,patientCurrentInfo->{
-            //从数据库中刷新数据
+            //从数据库中刷新数据 todo
+            BusPatientEntity patient = patientService.getOne(
+                    new QueryWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode, patientCurrentInfo.getPatientCode())
+                            .eq(BusPatientEntity::getTenantId, patientCurrentInfo.getTenantId()));
+            if(patient==null){
+                //存储新的病人数据
+                patient = new BusPatientEntity();
+                patient.setCode(patientCode);
+                patient.setTenantId(hospitalId);
+                patientService.save(patient);
+                //同步数据 todo
+            }else if(StrUtil.isNotEmpty(patient.getName())){
+                //同步数据 todo
+            }else {
+                patientCurrentInfo.setPatientGender(patient.getGender());
+                patientCurrentInfo.setPatientName(patient.getName());
+                //同步临床数据 todo
+            }
             return patientCurrentInfo;
         });
     }

+ 74 - 13
coffee-system/src/main/java/com/coffee/bus/registry/patient/PatientOperator.java

@@ -6,6 +6,7 @@ import com.coffee.common.enums.SexEnum;
 import com.coffee.common.redis.RedisUtils;
 import lombok.AllArgsConstructor;
 
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
@@ -42,18 +43,6 @@ public class PatientOperator {
         return this;
     }
 
-    /**
-     * 异步从his获取临床数据
-     * @param
-     */
-    public PatientOperator asyncClinicHis(){
-        CompletableFuture.runAsync(()->{
-            // todo his
-        });
-        return this;
-    }
-
-
     /**
      * 是否存在病人
      */
@@ -69,6 +58,22 @@ public class PatientOperator {
         return patientCurrentInfo!=null&&StrUtil.isNotEmpty(patientCurrentInfo.getClinicId());
     }
 
+    /**
+     * 异步从his获取临床数据
+     * @param
+     */
+    public PatientOperator asyncClinicHis(){
+        CompletableFuture.runAsync(()->{
+            // todo his
+        });
+        return this;
+    }
+
+    /**
+     *
+     * @param isNullRefresh 当数据为null时刷新数据
+     * @return
+     */
     public String getPatientName(boolean isNullRefresh){
         String patientName = patientCurrentInfo.getPatientName();
         if(StrUtil.isEmpty(patientName)&&isNullRefresh){
@@ -77,6 +82,38 @@ public class PatientOperator {
         return patientCurrentInfo.getPatientName();
     }
 
+    public String getTenantId(){
+        return patientCurrentInfo.getTenantId();
+    }
+
+    public String getClinicId(boolean isNullRefresh){
+        String clinicId = patientCurrentInfo.getClinicId();
+        if(StrUtil.isEmpty(clinicId)&&isNullRefresh){
+            freshInfo();
+        }
+        return patientCurrentInfo.getClinicId();
+    }
+
+    public Date getClinicStartTime(boolean isNullRefresh){
+        Date clinicStartTime = patientCurrentInfo.getClinicStartTime();
+        if(null!=clinicStartTime&&isNullRefresh){
+            freshInfo();
+        }
+        return patientCurrentInfo.getClinicStartTime();
+    }
+
+    public Boolean getIsFinished(boolean isNullRefresh){
+        Boolean isFinished = patientCurrentInfo.getIsFinished();
+        if(null!=isFinished&&isNullRefresh){
+            freshInfo();
+        }
+        return patientCurrentInfo.getIsFinished();
+    }
+
+    public String getDeviceId(){
+        return patientCurrentInfo.getCurrentDeviceId();
+    }
+
     public SexEnum getPatientGender(boolean isNullRefresh){
         SexEnum patientGender = patientCurrentInfo.getPatientGender();
         if(patientGender==null&&isNullRefresh){
@@ -96,7 +133,31 @@ public class PatientOperator {
 
 
     public Map<String,Object> getMap(){
-        return new HashMap<>();
+        Map<String, Object> result = new HashMap<>();
+        if(StrUtil.isNotEmpty(patientCurrentInfo.getPatientCode())){
+            result.put("patientCode",patientCurrentInfo.getPatientCode());
+        }
+        if(null!=patientCurrentInfo.getPatientGender()){
+            result.put("patientGender",patientCurrentInfo.getPatientGender());
+        }
+        if(StrUtil.isNotEmpty(patientCurrentInfo.getPatientName())){
+            result.put("patientName",patientCurrentInfo.getPatientName());
+        }
+        if(StrUtil.isNotEmpty(patientCurrentInfo.getTenantId())){
+            result.put("tenantId",patientCurrentInfo.getTenantId());
+        }
+        if(StrUtil.isNotEmpty(patientCurrentInfo.getClinicId())){
+            result.put("clinicId",patientCurrentInfo.getClinicId());
+        }
+        if(null!=patientCurrentInfo.getClinicStartTime()){
+            result.put("clinicStartTime",patientCurrentInfo.getClinicStartTime());
+        }if(null!=patientCurrentInfo.getIsFinished()){
+            result.put("isFinished",patientCurrentInfo.getIsFinished());
+        }
+        if(StrUtil.isNotEmpty(patientCurrentInfo.getCurrentDeviceId())){
+            result.put("currentDeviceId",patientCurrentInfo.getCurrentDeviceId());
+        }
+        return result;
     }
 
 }

+ 6 - 2
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceRegisteredService.java

@@ -6,8 +6,11 @@ import com.coffee.bus.mapper.BusDeviceRegisteredMapper;
 import com.coffee.common.crud.BaseService;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.io.Serializable;
 
 /**
@@ -19,10 +22,11 @@ import java.io.Serializable;
  */
 @Service
 @Slf4j
-@AllArgsConstructor
 public class LocalBusDeviceRegisteredService  extends BaseService<BusDeviceRegisteredMapper, BusDeviceRegisteredEntity,String> {
 
-    private final DeviceRegistry deviceRegistry;
+    @Autowired
+    @Lazy
+    private DeviceRegistry deviceRegistry;
     @Override
     public void validateBeforeSave(BusDeviceRegisteredEntity entity) {
 

+ 28 - 34
coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java

@@ -1,5 +1,6 @@
 package com.coffee.bus.websocket.listener;
 
+import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -21,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.event.EventListener;
 import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
@@ -59,6 +61,7 @@ public class DeviceInfoListener {
      * @param infoEvent
      */
     @EventListener
+    @Async
     @Transactional(rollbackFor = Exception.class)
     public void deviceInfoDetail(DeviceInfoEvent infoEvent){
         BusPumpEntity device = infoEvent.getContent();
@@ -66,37 +69,39 @@ public class DeviceInfoListener {
         String deviceId = device.getDeviceId();
         DeviceOperator deviceOperator = deviceRegistry.getDevice(deviceId);
         if (!deviceOperator.canUse()) {
-            log.warn("设备[{}]暂不可用,数据已丢弃");
+            log.warn("设备[{}]暂不可用,数据已丢弃",deviceId);
             return ;
         }
+        log.info("接收到设备数据:[{}]",infoEvent.getContent().toString());
         device.setMonitorType(1);
         //首次运行需要与病人、医院进行绑定
         if(deviceOperator.isFirst()){
             initDevice(device,deviceOperator);
             PatientOperator patientOperator = patientRegistry.getPatient(device.getTenantId(), device.getPatientCode());
             initPatient(device,patientOperator);
-            /**
-             * 判断是否存在临床信息 ,拉取临床信息 todo
-             * @see  com.coffee.bus.registry.patient.PatientOperator 拉取病人信息
-             */
-            deviceRunInfoService.save(device);
+            //二次确认
+            deviceOperator = deviceRegistry.getDevice(deviceId);
+            if(device.getId().equals(deviceOperator.getRunId())){
+                deviceRunInfoService.save(device);
+            }
+
         }
         else {
-//            fillDeviceInfoFromCache(device,deviceOperator);
-//            deviceRunInfoService.updateById(device);
+            device.setId(deviceOperator.getRunId());
+            deviceRunInfoService.updateById(device);
         }
 
         //病号是否进行换泵操作
-        if (patientService.isChangedDevice(device.getTenantId(),device.getPatientCode(),device.getDeviceId(),device.getStartTime())) {
-            patientService.changePump(device.getTenantId(),device.getPatientCode(),device.getDeviceId());
-        }
+//        if (patientService.isChangedDevice(device.getTenantId(),device.getPatientCode(),device.getDeviceId(),device.getStartTime())) {
+//            patientService.changePump(device.getTenantId(),device.getPatientCode(),device.getDeviceId());
+//        }
         //发送设备报警
         if(!deviceOperator.isFirst()){
             //非首次注册,则推送设备消息
             String topic = WebSocketConstant.getDeviceInfoDetailTopic(null, device.getId(), device.getTenantId());
             redisTemplate.convertAndSend(topic, device);
         }
-        SpringUtil.publishEvent(new DeviceAlarmEvent(this,device));
+//        SpringUtil.publishEvent(new DeviceAlarmEvent(this,device));
     }
 
     /**
@@ -137,24 +142,6 @@ 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());
-//    }
-
     /**
      * 初始化设备状态
      * @param pump
@@ -176,19 +163,26 @@ public class DeviceInfoListener {
         //缓存存储泵的开始时间和注册时间
         deviceOperator.updateRegisterTime(now);
         deviceOperator.updateStartTime(now);
+        deviceOperator.updateRunId(pump.getId());
     }
 
-    @Scheduled(cron = "0/3 * * * * ?")
+    @Scheduled(cron = "0/10 * * * * ?")
     public void send(){
-        List<BusPumpEntity> list = deviceRunInfoService.list();
-        list.forEach(pump->{
+//        List<BusPumpEntity> list = deviceRunInfoService.list();
+//        list.forEach(pump->{
+
+        ThreadUtil.concurrencyTest(30,()->  {
+            BusPumpEntity pump = new BusPumpEntity();
+            pump.setDeviceId("123");
+            pump.setPatientCode("456");
             pump.setRemainQuantity(BigDecimal.valueOf(RandomUtil.randomInt(100)));
             pump.setContinueQuantity(BigDecimal.valueOf(RandomUtil.randomInt(100)));
             pump.setSelfControlLockTime(BigDecimal.valueOf(RandomUtil.randomInt(100)));
             pump.setValidTime(RandomUtil.randomInt(100));
             pump.setInvalidTime(RandomUtil.randomInt(100));
             pump.setTotalCount(RandomUtil.randomInt(100));
-            SpringUtil.publishEvent(new DeviceInfoEvent(this,pump,pump.getId()));
+            SpringUtil.publishEvent(new DeviceInfoEvent(this,pump,pump.getDeviceId()));
         });
+//        });
     }
 }