Browse Source

update BusDeviceUsingEntity 改为BusDeviceRunningEntity

18339543638 3 years ago
parent
commit
1cd9c2d3a4
21 changed files with 89 additions and 105 deletions
  1. 2 2
      coffee-admin/src/test/java/com/coffee/admin/AliyunTest.java
  2. 7 9
      coffee-admin/src/test/java/com/coffee/admin/BusNetpumpTest.java
  3. 2 2
      coffee-system/src/main/java/com/coffee/aliyun/AliyunConsumerGroupService.java
  4. 1 1
      coffee-system/src/main/java/com/coffee/aliyun/AliyunIotSubscribeClient.java
  5. 1 0
      coffee-system/src/main/java/com/coffee/aliyun/PlatformAccount.java
  6. 8 8
      coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceRunningController.java
  7. 2 2
      coffee-system/src/main/java/com/coffee/bus/controller/vo/NoPumpConfig.java
  8. 1 1
      coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceHistoryEntity.java
  9. 1 1
      coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceRunningEntity.java
  10. 0 4
      coffee-system/src/main/java/com/coffee/bus/listener/event/bean/DeviceAlarmEvent.java
  11. 5 5
      coffee-system/src/main/java/com/coffee/bus/listener/event/bean/DeviceInfoEvent.java
  12. 2 2
      coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceRunningMapper.java
  13. 6 6
      coffee-system/src/main/java/com/coffee/bus/registry/device/ClusterDeviceRegistry.java
  14. 2 3
      coffee-system/src/main/java/com/coffee/bus/registry/device/DeviceOperator.java
  15. 2 3
      coffee-system/src/main/java/com/coffee/bus/registry/device/bean/DeviceCacheInfo.java
  16. 1 1
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusClinicService.java
  17. 11 11
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceRunningService.java
  18. 7 7
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusPatientService.java
  19. 0 8
      coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceAlarmListener.java
  20. 16 17
      coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java
  21. 12 12
      coffee-system/src/main/java/com/coffee/bus/websocket/listener/HistoryInfoListener.java

+ 2 - 2
coffee-admin/src/test/java/com/coffee/admin/AliyunTest.java

@@ -1,7 +1,7 @@
 package com.coffee.admin;
 
+import com.coffee.bus.entity.BusDeviceRunningEntity;
 import com.coffee.bus.entity.BusDeviceUsedEntity;
-import com.coffee.bus.entity.BusDeviceUsingEntity;
 import com.coffee.bus.listener.event.bean.DeviceInfoEvent;
 import com.coffee.bus.service.LocalBusDeviceUsedService;
 import org.junit.Test;
@@ -29,7 +29,7 @@ public class AliyunTest {
 
     @Test
     public void test001(){
-        BusDeviceUsingEntity pump = new BusDeviceUsingEntity();
+        BusDeviceRunningEntity pump = new BusDeviceRunningEntity();
         pump.setAlias("123456777");
         DeviceInfoEvent event = new DeviceInfoEvent(this,pump,"123");
         applicationContext.publishEvent(event);

+ 7 - 9
coffee-admin/src/test/java/com/coffee/admin/BusNetpumpTest.java

@@ -1,16 +1,14 @@
 package com.coffee.admin;
 
-import com.coffee.bus.controller.BusDeviceUsingController;
-import com.coffee.bus.entity.BusDeviceUsingEntity;
-import com.coffee.bus.enums.NetPumpWarnEnum;
-import com.coffee.bus.service.LocalBusDeviceUsingService;
+import com.coffee.bus.controller.BusDeviceRunningController;
+import com.coffee.bus.entity.BusDeviceRunningEntity;
+import com.coffee.bus.service.LocalBusDeviceRunningService;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
-import java.util.Date;
 import java.util.List;
 
 /**
@@ -24,14 +22,14 @@ import java.util.List;
 @SpringBootTest(classes = AdminApplication.class)
 public class BusNetpumpTest {
     @Autowired
-    private LocalBusDeviceUsingService netPumpService;
+    private LocalBusDeviceRunningService netPumpService;
 
     @Autowired
-    private BusDeviceUsingController netPumpController;
+    private BusDeviceRunningController netPumpController;
     @Test
     public void save(){
 //        StpUtil.login();
-        BusDeviceUsingEntity netPumpEntity = new BusDeviceUsingEntity();
+        BusDeviceRunningEntity netPumpEntity = new BusDeviceRunningEntity();
 //        netPumpEntity.setWarn(NetPumpWarnEnum.ComingEnd);
         netPumpEntity.setId("1507903748141658113");
         netPumpEntity.setAlias("1");
@@ -43,7 +41,7 @@ public class BusNetpumpTest {
 
     @Test
     public void query(){
-        List<BusDeviceUsingEntity> list = netPumpService.list();
+        List<BusDeviceRunningEntity> list = netPumpService.list();
         System.out.println(list);
     }
 

+ 2 - 2
coffee-system/src/main/java/com/coffee/aliyun/AliyunConsumerGroupService.java

@@ -2,7 +2,7 @@ package com.coffee.aliyun;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.coffee.bus.entity.BusDeviceUsingEntity;
+import com.coffee.bus.entity.BusDeviceRunningEntity;
 import com.coffee.bus.enums.DeviceEnum;
 import com.coffee.bus.listener.event.bean.DeviceInfoEvent;
 import lombok.AllArgsConstructor;
@@ -168,7 +168,7 @@ public class AliyunConsumerGroupService {
 
 
                 // 发布设备信息事件
-                DeviceInfoEvent deviceInfoEvent = new DeviceInfoEvent(this,new BusDeviceUsingEntity(),"123456");
+                DeviceInfoEvent deviceInfoEvent = new DeviceInfoEvent(this,new BusDeviceRunningEntity(),"123456");
                 applicationContext.publishEvent(deviceInfoEvent);
 
             }else if(topic.matches("[\\w\\/]+thing/liftcycle$")){// 设备生命周期

+ 1 - 1
coffee-system/src/main/java/com/coffee/aliyun/AliyunIotSubscribeClient.java

@@ -44,7 +44,7 @@ public class AliyunIotSubscribeClient {
         this.aliyunUid = platformAccount.getAliyunUid();
         this.iotInstanceId = platformAccount.getIotInstanceId();
         //
-        setClientIdAndHost();
+//        setClientIdAndHost();
     }
 
     // 设置客户端id和host

+ 1 - 0
coffee-system/src/main/java/com/coffee/aliyun/PlatformAccount.java

@@ -19,6 +19,7 @@ import org.springframework.context.annotation.Configuration;
  */
 @Data
 @ConfigurationProperties(prefix = "aliyun")
+@Configuration
 public class PlatformAccount {
     private String accessKey = "LTAI4FhB19MgQuviGxwA3aod";
     private String accessSecret = "cQQVkATR0yv2G9CEtfjAhEGBepPDRs";

+ 8 - 8
coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceUsingController.java → coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceRunningController.java

@@ -6,10 +6,10 @@ import cn.dev33.satoken.stp.StpLogic;
 import com.baomidou.mybatisplus.core.mapper.Mapper;
 import com.coffee.bus.controller.vo.NoPumpConfig;
 import com.coffee.bus.controller.vo.UndoConfig;
-import com.coffee.bus.entity.BusDeviceUsingEntity;
+import com.coffee.bus.entity.BusDeviceRunningEntity;
 import com.coffee.bus.enums.DeviceStatusEnum;
 import com.coffee.bus.enums.NetPumpWarnEnum;
-import com.coffee.bus.service.LocalBusDeviceUsingService;
+import com.coffee.bus.service.LocalBusDeviceRunningService;
 import com.coffee.common.crud.BaseService;
 import com.coffee.common.crud.controller.BaseQueryController;
 import com.coffee.common.result.R;
@@ -28,9 +28,9 @@ import org.springframework.web.bind.annotation.*;
 @RestController
 @AllArgsConstructor
 @RequestMapping({"/bus/netpump","/bus/device/using"})
-@Api(tags = "网络泵管理",description = "统一权限前缀(bus:pump),例如新增bus:pump:add")
-public class BusDeviceUsingController implements BaseQueryController<BusDeviceUsingEntity, String> {
-    private final LocalBusDeviceUsingService netPumpService;
+@Api(tags = "网络泵管理",description = "统一权限前缀(bus:device),例如新增bus:device:add")
+public class BusDeviceRunningController implements BaseQueryController<BusDeviceRunningEntity, String> {
+    private final LocalBusDeviceRunningService netPumpService;
 
     @GetMapping("/warn/dict")
     @ApiOperation(value = "网络泵提醒信息枚举,无权限配置")
@@ -46,7 +46,7 @@ public class BusDeviceUsingController implements BaseQueryController<BusDeviceUs
     }
 
     @PostMapping("/undo")
-    @SaCheckPermission("bus:pump:undo")
+    @SaCheckPermission("bus:device:undo")
     @ApiOperation(value = "进行撤泵操作,权限为bus:pump:undo")
     public R undo(@RequestBody UndoConfig undoConfig){
         netPumpService.undo(undoConfig);
@@ -54,7 +54,7 @@ public class BusDeviceUsingController implements BaseQueryController<BusDeviceUs
     }
 
     @PostMapping("/nopump")
-    @SaCheckPermission("bus:pump:add")
+    @SaCheckPermission("bus:device:add")
     @ApiOperation(value = "新增无泵数据,权限为bus:pump:add")
     public R saveNoPump(@RequestBody NoPumpConfig noPump){
 
@@ -76,7 +76,7 @@ public class BusDeviceUsingController implements BaseQueryController<BusDeviceUs
     }
 
     @Override
-    public BaseService<? extends Mapper<BusDeviceUsingEntity>, BusDeviceUsingEntity, String> getService() {
+    public BaseService<? extends Mapper<BusDeviceRunningEntity>, BusDeviceRunningEntity, String> getService() {
         return netPumpService;
     }
 }

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/controller/vo/NoPumpConfig.java

@@ -1,7 +1,7 @@
 package com.coffee.bus.controller.vo;
 
 import com.coffee.bus.entity.BusClinicEntity;
-import com.coffee.bus.entity.BusDeviceUsingEntity;
+import com.coffee.bus.entity.BusDeviceRunningEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -17,7 +17,7 @@ import lombok.Data;
 @ApiModel("新增无泵监护配置")
 public class NoPumpConfig {
     @ApiModelProperty("泵数据")
-    private BusDeviceUsingEntity pump;
+    private BusDeviceRunningEntity pump;
     @ApiModelProperty("手术信息")
     private BusClinicEntity clinic;
     @ApiModelProperty("医院号")

+ 1 - 1
coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceHistoryEntity.java

@@ -154,7 +154,7 @@ public class BusDeviceHistoryEntity extends TenantGenericEntity<String,String> {
         this.bedNo=clinic.getBedNo();
     }
 
-    public static BusDeviceHistoryEntity of(BusDeviceUsingEntity pump, BusClinicEntity clinic){
+    public static BusDeviceHistoryEntity of(BusDeviceRunningEntity pump, BusClinicEntity clinic){
         BusDeviceHistoryEntity history = new BusDeviceHistoryEntity();
 
         //临床信息

+ 1 - 1
coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceUsingEntity.java → coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceRunningEntity.java

@@ -35,7 +35,7 @@ import java.util.Date;
 @Accessors(chain = true)
 @TableName(value = "bus_device_using",autoResultMap = true)
 @ApiModel(value="设备运行状态", description="设备运行状态")
-public class BusDeviceUsingEntity extends TenantGenericEntity<String,String> {
+public class BusDeviceRunningEntity extends TenantGenericEntity<String,String> {
 
     @ApiModelProperty(value = "网络泵id",readOnly = true)
     private String deviceId;

+ 0 - 4
coffee-system/src/main/java/com/coffee/bus/listener/event/bean/DeviceAlarmEvent.java

@@ -1,14 +1,10 @@
 package com.coffee.bus.listener.event.bean;
 
 import com.coffee.bus.entity.BusDeviceAlarmEntity;
-import com.coffee.bus.entity.BusDeviceUsingEntity;
-import com.coffee.bus.enums.DeviceAlarmEnum;
-import lombok.Data;
 import lombok.Getter;
 import org.springframework.context.ApplicationEvent;
 
 import java.time.Clock;
-import java.util.Date;
 
 /**
  * @author lifang

+ 5 - 5
coffee-system/src/main/java/com/coffee/bus/listener/event/bean/DeviceInfoEvent.java

@@ -1,6 +1,6 @@
 package com.coffee.bus.listener.event.bean;
 
-import com.coffee.bus.entity.BusDeviceUsingEntity;
+import com.coffee.bus.entity.BusDeviceRunningEntity;
 import lombok.Getter;
 import org.springframework.context.ApplicationEvent;
 
@@ -13,7 +13,7 @@ import java.time.Clock;
  * @ClassName DeviceInfoEvent.java
  * @Description 所有通过第三方传过来的数据,请先解析成netpump格式类型,然后分发到系统中
  *
- * @see  BusDeviceUsingEntity
+ * @see  BusDeviceRunningEntity
  * @createTime 2022年03月21日 16:21:00
  */
 @Getter
@@ -22,7 +22,7 @@ public class DeviceInfoEvent extends ApplicationEvent {
     /**
      * 设备属性值
      */
-    private final BusDeviceUsingEntity content;
+    private final BusDeviceRunningEntity content;
 
     /**
      * 设备id,即泵设备号
@@ -30,13 +30,13 @@ public class DeviceInfoEvent extends ApplicationEvent {
     private final String deviceId;
 
 
-    public DeviceInfoEvent(Object source, @NotNull BusDeviceUsingEntity content, @NotNull String deviceId) {
+    public DeviceInfoEvent(Object source, @NotNull BusDeviceRunningEntity content, @NotNull String deviceId) {
         super(source);
         this.content=content;
         this.deviceId=deviceId;
     }
 
-    public DeviceInfoEvent(Object source, Clock clock, @NotNull BusDeviceUsingEntity content, @NotNull String deviceId) {
+    public DeviceInfoEvent(Object source, Clock clock, @NotNull BusDeviceRunningEntity content, @NotNull String deviceId) {
         super(source, clock);
         this.content=content;
         this.deviceId=deviceId;

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceUsingMapper.java → coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceRunningMapper.java

@@ -1,7 +1,7 @@
 package com.coffee.bus.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.coffee.bus.entity.BusDeviceUsingEntity;
+import com.coffee.bus.entity.BusDeviceRunningEntity;
 import org.apache.ibatis.annotations.Mapper;
 
 /**
@@ -12,5 +12,5 @@ import org.apache.ibatis.annotations.Mapper;
  * @createTime 2022年03月19日 09:15:00
  */
 @Mapper
-public interface BusDeviceUsingMapper extends BaseMapper<BusDeviceUsingEntity> {
+public interface BusDeviceRunningMapper extends BaseMapper<BusDeviceRunningEntity> {
 }

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

@@ -4,11 +4,11 @@ import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.coffee.bus.entity.BusDeviceEntity;
-import com.coffee.bus.entity.BusDeviceUsingEntity;
+import com.coffee.bus.entity.BusDeviceRunningEntity;
 import com.coffee.bus.registry.RegistryConstant;
 import com.coffee.bus.registry.device.bean.DeviceCacheInfo;
 import com.coffee.bus.service.LocalBusDeviceService;
-import com.coffee.bus.service.LocalBusDeviceUsingService;
+import com.coffee.bus.service.LocalBusDeviceRunningService;
 import com.coffee.common.cache.manager.ClusterConfigStorageManager;
 import com.coffee.common.cache.value.Value;
 import lombok.AllArgsConstructor;
@@ -26,7 +26,7 @@ import java.util.Map;
 @AllArgsConstructor
 @Service
 public class ClusterDeviceRegistry implements DeviceRegistry {
-    private final LocalBusDeviceUsingService pumpService;
+    private final LocalBusDeviceRunningService pumpService;
     private final LocalBusDeviceService deviceService;
     private final ClusterConfigStorageManager configStorageManager;
 
@@ -40,7 +40,7 @@ public class ClusterDeviceRegistry implements DeviceRegistry {
         Map<String, Value> result = deviceOperator.getAll();
         if(result==null||result.size()==0){
             //从数据库中获取数据
-            BusDeviceUsingEntity pump = pumpService.getOne(new QueryWrapper<BusDeviceUsingEntity>().lambda().eq(BusDeviceUsingEntity::getDeviceId, deviceId));
+            BusDeviceRunningEntity pump = pumpService.getOne(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getDeviceId, deviceId));
             BusDeviceEntity device = deviceService.getOne(new QueryWrapper<BusDeviceEntity>().lambda()
                     .eq(BusDeviceEntity::getDeviceId, deviceId));
             if(device==null){
@@ -56,8 +56,8 @@ public class ClusterDeviceRegistry implements DeviceRegistry {
                 deviceOperator.setUsingId(pump.getId());
                 //判断泵是否医院绑定发生变化
                 if(device.getTenantId().equals(pump.getTenantId())){
-                    pumpService.update(new UpdateWrapper<BusDeviceUsingEntity>().lambda()
-                            .eq(BusDeviceUsingEntity::getDeviceId,deviceId).set(BusDeviceUsingEntity::getTenantId,device.getTenantId()));
+                    pumpService.update(new UpdateWrapper<BusDeviceRunningEntity>().lambda()
+                            .eq(BusDeviceRunningEntity::getDeviceId,deviceId).set(BusDeviceRunningEntity::getTenantId,device.getTenantId()));
                 }
 
             }

+ 2 - 3
coffee-system/src/main/java/com/coffee/bus/registry/device/DeviceOperator.java

@@ -1,9 +1,8 @@
 package com.coffee.bus.registry.device;
 
-import com.coffee.bus.entity.BusDeviceUsingEntity;
+import com.coffee.bus.entity.BusDeviceRunningEntity;
 import com.coffee.bus.enums.DeviceStatusEnum;
 import com.coffee.bus.registry.Operator;
-import org.python.antlr.ast.Str;
 
 import java.util.Date;
 
@@ -67,7 +66,7 @@ public interface DeviceOperator<T> extends Operator<T> {
 
     /**
      * 设置设备运行id
-     * @see BusDeviceUsingEntity
+     * @see BusDeviceRunningEntity
      * @param usingId
      */
     void setUsingId(String usingId);

+ 2 - 3
coffee-system/src/main/java/com/coffee/bus/registry/device/bean/DeviceCacheInfo.java

@@ -1,12 +1,11 @@
 package com.coffee.bus.registry.device.bean;
 
-import com.coffee.bus.entity.BusDeviceUsingEntity;
+import com.coffee.bus.entity.BusDeviceRunningEntity;
 import com.coffee.bus.enums.DeviceStatusEnum;
 import com.coffee.bus.registry.CacheInfo;
 import com.coffee.bus.registry.RegistryConstant;
 import lombok.Builder;
 import lombok.Data;
-import org.python.antlr.ast.Str;
 //import com.coffee.common.cache.*;
 import java.util.Date;
 
@@ -49,7 +48,7 @@ public class DeviceCacheInfo implements CacheInfo {
 
     /**
      * 运行泵主键id
-     * @see BusDeviceUsingEntity
+     * @see BusDeviceRunningEntity
      */
     private String usingId;
 

+ 1 - 1
coffee-system/src/main/java/com/coffee/bus/service/LocalBusClinicService.java

@@ -21,7 +21,7 @@ import org.springframework.stereotype.Service;
 public class LocalBusClinicService extends BaseService<BusClinicMapper, BusClinicEntity,String> {
     @Autowired
     @Lazy
-    private LocalBusDeviceUsingService netPumpService;
+    private LocalBusDeviceRunningService netPumpService;
     @Override
     public void validateBeforeSave(BusClinicEntity entity) {
 

+ 11 - 11
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceUsingService.java → coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceRunningService.java

@@ -4,9 +4,9 @@ import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.coffee.bus.controller.vo.UndoConfig;
 import com.coffee.bus.entity.BusClinicEntity;
-import com.coffee.bus.entity.BusDeviceUsingEntity;
+import com.coffee.bus.entity.BusDeviceRunningEntity;
 import com.coffee.bus.entity.BusDeviceHistoryEntity;
-import com.coffee.bus.mapper.BusDeviceUsingMapper;
+import com.coffee.bus.mapper.BusDeviceRunningMapper;
 import com.coffee.common.crud.BaseService;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
@@ -27,16 +27,16 @@ import java.util.stream.Collectors;
  */
 @Service
 @AllArgsConstructor
-public class LocalBusDeviceUsingService extends BaseService<BusDeviceUsingMapper, BusDeviceUsingEntity,String> {
+public class LocalBusDeviceRunningService extends BaseService<BusDeviceRunningMapper, BusDeviceRunningEntity,String> {
     private final LocalBusClinicService clinicService;
     private final LocalBusDeviceHistoryService historyService;
     @Override
-    public void validateBeforeSave(BusDeviceUsingEntity entity) {
+    public void validateBeforeSave(BusDeviceRunningEntity entity) {
 
     }
 
     @Override
-    public void validateBeforeUpdate(BusDeviceUsingEntity entity) {
+    public void validateBeforeUpdate(BusDeviceRunningEntity entity) {
 
     }
 
@@ -46,12 +46,12 @@ public class LocalBusDeviceUsingService extends BaseService<BusDeviceUsingMapper
     }
 
     public boolean firstRegister(String deviceId){
-        return this.getOne(new QueryWrapper<BusDeviceUsingEntity>().lambda().eq(BusDeviceUsingEntity::getDeviceId,deviceId))!=null;
+        return this.getOne(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getDeviceId,deviceId))!=null;
     }
 
 
-    public BusDeviceUsingEntity getByDeviceId(String deviceId){
-        return this.getOne(new QueryWrapper<BusDeviceUsingEntity>().lambda().eq(BusDeviceUsingEntity::getDeviceId,deviceId));
+    public BusDeviceRunningEntity getByDeviceId(String deviceId){
+        return this.getOne(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getDeviceId,deviceId));
     }
     /**
      * 撤泵操作
@@ -64,9 +64,9 @@ public class LocalBusDeviceUsingService extends BaseService<BusDeviceUsingMapper
             return;
         }
         /****************将撤泵记录存入到泵的使用历史记录中***************/
-        List<BusDeviceUsingEntity> pumps = this.listByIds(ids);
+        List<BusDeviceRunningEntity> pumps = this.listByIds(ids);
         //获取有泵监护的临床信息
-        Set<String> clinicIds = pumps.stream().map(BusDeviceUsingEntity::getClinicId).collect(Collectors.toSet());
+        Set<String> clinicIds = pumps.stream().map(BusDeviceRunningEntity::getClinicId).collect(Collectors.toSet());
         List<BusClinicEntity> clinics = clinicService.listByIds(clinicIds);
         Map<String, List<BusClinicEntity>> clinicMap = clinics.stream().collect(Collectors.groupingBy(BusClinicEntity::getId));
         //泵的撤泵数据插入到历史数据中
@@ -84,7 +84,7 @@ public class LocalBusDeviceUsingService extends BaseService<BusDeviceUsingMapper
 
         /****************将泵改为撤泵状态***************/
         this.updateBatchById(ids.stream().map(id->{
-            BusDeviceUsingEntity pump = new BusDeviceUsingEntity();
+            BusDeviceRunningEntity pump = new BusDeviceRunningEntity();
             pump.setId(id);
             pump.setIsUndo(true);
             return pump;

+ 7 - 7
coffee-system/src/main/java/com/coffee/bus/service/LocalBusPatientService.java

@@ -2,7 +2,7 @@ package com.coffee.bus.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
-import com.coffee.bus.entity.BusDeviceUsingEntity;
+import com.coffee.bus.entity.BusDeviceRunningEntity;
 import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.mapper.BusPatientMapper;
 import com.coffee.common.crud.BaseService;
@@ -25,7 +25,7 @@ import java.util.Date;
 @AllArgsConstructor
 @Slf4j
 public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPatientEntity,String> {
-    private final LocalBusDeviceUsingService netPumpService;
+    private final LocalBusDeviceRunningService netPumpService;
     @Override
     public void validateBeforeSave(BusPatientEntity entity) {
 
@@ -60,9 +60,9 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
      * @return
      */
     public boolean isChangedDevice(String hospitalId, String patientCode, String checkDeviceId, Date checkStartTime){
-        BusDeviceUsingEntity existDevice = netPumpService
-                .getOne(new QueryWrapper<BusDeviceUsingEntity>().lambda().eq(BusDeviceUsingEntity::getTenantId, hospitalId)
-                        .eq(BusDeviceUsingEntity::getPatientCode, patientCode));
+        BusDeviceRunningEntity existDevice = netPumpService
+                .getOne(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getTenantId, hospitalId)
+                        .eq(BusDeviceRunningEntity::getPatientCode, patientCode));
         if(existDevice==null){
             return true;
         }
@@ -82,8 +82,8 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
     @Transactional(rollbackFor = Exception.class)
     public void changePump(String hospitalId,String patientCode,String newDeviceId){
         log.info("医院id:[{}],病号:[{}],进行换泵操作,现设备id:[{}]",patientCode,hospitalId,newDeviceId);
-        netPumpService.update(new UpdateWrapper<BusDeviceUsingEntity>().lambda().eq(BusDeviceUsingEntity::getPatientCode,patientCode).set(BusDeviceUsingEntity::getMaster,0));
-        netPumpService.update(new UpdateWrapper<BusDeviceUsingEntity>().lambda().eq(BusDeviceUsingEntity::getDeviceId,newDeviceId).set(BusDeviceUsingEntity::getMaster,1));
+        netPumpService.update(new UpdateWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getPatientCode,patientCode).set(BusDeviceRunningEntity::getMaster,0));
+        netPumpService.update(new UpdateWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getDeviceId,newDeviceId).set(BusDeviceRunningEntity::getMaster,1));
     }
 
 

+ 0 - 8
coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceAlarmListener.java

@@ -3,23 +3,15 @@ package com.coffee.bus.websocket.listener;
 import cn.hutool.core.lang.Assert;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.coffee.bus.entity.BusDeviceAlarmEntity;
-import com.coffee.bus.entity.BusDeviceUsingEntity;
-import com.coffee.bus.enums.DeviceStatusEnum;
 import com.coffee.bus.listener.event.bean.DeviceAlarmEvent;
 import com.coffee.bus.service.LocalBusDeviceAlarmService;
-import com.coffee.bus.service.LocalBusDeviceUsingService;
 import com.coffee.common.config.websocket.WebSocketConstant;
 import lombok.AllArgsConstructor;
 import org.springframework.context.event.EventListener;
 import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Arrays;
-import java.util.List;
-import java.util.function.Predicate;
-
 /**
  * @author lifang
  * @version 1.0.0

+ 16 - 17
coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java

@@ -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");

+ 12 - 12
coffee-system/src/main/java/com/coffee/bus/websocket/listener/HistoryInfoListener.java

@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.coffee.bus.bean.HisInfo;
 import com.coffee.bus.entity.BusClinicEntity;
-import com.coffee.bus.entity.BusDeviceUsingEntity;
+import com.coffee.bus.entity.BusDeviceRunningEntity;
 import com.coffee.bus.entity.BusDeviceHistoryEntity;
 import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.listener.event.bean.HistoryInfoEvent;
@@ -50,10 +50,10 @@ public class HistoryInfoListener {
 
     private final RedisTemplate redisTemplate;
 
-    private final LocalBusDeviceUsingService pumpService;
+    private final LocalBusDeviceRunningService pumpService;
 
     @Autowired
-    public HistoryInfoListener(ScriptManager scriptManager, LocalBusPatientService patientService, LocalBusClinicService clinicService, LocalBusDeviceHistoryService historyService, RedisTemplate redisTemplate, LocalBusDeviceUsingService pumpService) {
+    public HistoryInfoListener(ScriptManager scriptManager, LocalBusPatientService patientService, LocalBusClinicService clinicService, LocalBusDeviceHistoryService historyService, RedisTemplate redisTemplate, LocalBusDeviceRunningService pumpService) {
         this.scriptManager = scriptManager;
         this.patientService = patientService;
         this.clinicService = clinicService;
@@ -152,16 +152,16 @@ public class HistoryInfoListener {
             clinic.setDeviceCodes(historyList.stream().map(BusDeviceHistoryEntity::getDeviceId).collect(Collectors.toSet()));
         }
 
-        pumpService.update(new UpdateWrapper<BusDeviceUsingEntity>()
+        pumpService.update(new UpdateWrapper<BusDeviceRunningEntity>()
                 .lambda()
-                .eq(BusDeviceUsingEntity::getPatientCode,clinic.getPatientCode())
-                .eq(BusDeviceUsingEntity::getTenantId,clinic.getTenantId())
-                .isNull(BusDeviceUsingEntity::getClinicId)
-                .set(BusDeviceUsingEntity::getClinicId,clinic.getId())
-                .set(BusDeviceUsingEntity::getPatientSex,clinic.getPatientGender())
-                .set(BusDeviceUsingEntity::getWard,clinic.getWard())
-                .set(BusDeviceUsingEntity::getBedNo,clinic.getBedNo())
-                .set(BusDeviceUsingEntity::getPatientName,clinic.getPatientName()));
+                .eq(BusDeviceRunningEntity::getPatientCode,clinic.getPatientCode())
+                .eq(BusDeviceRunningEntity::getTenantId,clinic.getTenantId())
+                .isNull(BusDeviceRunningEntity::getClinicId)
+                .set(BusDeviceRunningEntity::getClinicId,clinic.getId())
+                .set(BusDeviceRunningEntity::getPatientSex,clinic.getPatientGender())
+                .set(BusDeviceRunningEntity::getWard,clinic.getWard())
+                .set(BusDeviceRunningEntity::getBedNo,clinic.getBedNo())
+                .set(BusDeviceRunningEntity::getPatientName,clinic.getPatientName()));
 
         clinicService.save(clinic);
         log.info("新增临床信息,[{}]",clinic);