Browse Source

update 缓存方式由redisTemplate 改为redisson

A17404李放 3 years ago
parent
commit
5a3466870b
30 changed files with 374 additions and 328 deletions
  1. 2 1
      coffee-admin/src/test/java/com/coffee/admin/BusHospitalTest.java
  2. 29 16
      coffee-common/src/main/java/com/coffee/common/cache/ClusterConfigStorage.java
  3. 5 4
      coffee-common/src/main/java/com/coffee/common/cache/manager/ClusterConfigStorageManager.java
  4. 11 0
      coffee-system/src/main/java/com/coffee/bus/bean/GeoPoint.java
  5. 0 11
      coffee-system/src/main/java/com/coffee/bus/bean/config/Config.java
  6. 0 97
      coffee-system/src/main/java/com/coffee/bus/bean/config/EvalConfig.java
  7. 0 55
      coffee-system/src/main/java/com/coffee/bus/bean/config/OtherConfig.java
  8. 0 62
      coffee-system/src/main/java/com/coffee/bus/bean/config/UndoConfig.java
  9. 39 0
      coffee-system/src/main/java/com/coffee/bus/config/HospitalConfigHandler.java
  10. 46 0
      coffee-system/src/main/java/com/coffee/bus/config/HospitalFunctionOtherConfigHandler.java
  11. 1 1
      coffee-system/src/main/java/com/coffee/bus/controller/BusAlarmController.java
  12. 0 28
      coffee-system/src/main/java/com/coffee/bus/controller/BusHospitalConfigController.java
  13. 2 5
      coffee-system/src/main/java/com/coffee/bus/entity/BusHospitalEntity.java
  14. 61 0
      coffee-system/src/main/java/com/coffee/bus/entity/common/CommonDeviceParam.java
  15. 3 8
      coffee-system/src/main/java/com/coffee/bus/enums/ConfigEnum.java
  16. 12 9
      coffee-system/src/main/java/com/coffee/bus/his/HisScriptSession.java
  17. 5 4
      coffee-system/src/main/java/com/coffee/bus/his/HisScriptSessionManager.java
  18. 1 3
      coffee-system/src/main/java/com/coffee/bus/registry/Operator.java
  19. 1 8
      coffee-system/src/main/java/com/coffee/bus/registry/patient/ClusterPatientOperator.java
  20. 2 1
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusHospitalService.java
  21. 25 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionAnalConfig.java
  22. 27 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionAutoUndoConfig.java
  23. 19 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionExtraConfig.java
  24. 29 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionManualUndoConfig.java
  25. 21 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionOtherConfig.java
  26. 20 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionUndoConfig.java
  27. 1 3
      coffee-system/src/main/java/com/coffee/bus/web/handler/CheckSignHandler.java
  28. 1 1
      coffee-system/src/main/java/com/coffee/bus/web/handler/TenantIdHandler.java
  29. 10 10
      coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java
  30. 1 1
      coffee-system/src/main/resources/mapper/bus/BusPatientMapper.xml

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

@@ -1,6 +1,7 @@
 package com.coffee.admin;
 
 import cn.dev33.satoken.stp.StpUtil;
+import com.coffee.bus.bean.GeoPoint;
 import com.coffee.bus.bean.Script;
 import com.coffee.bus.controller.BusHospitalController;
 import com.coffee.bus.entity.BusHospitalEntity;
@@ -37,7 +38,7 @@ public class BusHospitalTest {
         busHospitalEntity.setAddress("河南长垣");
         busHospitalEntity.setAreaCode("453400");
 
-        BusHospitalEntity.GeoPoint geoPoint = new BusHospitalEntity.GeoPoint();
+        GeoPoint geoPoint = new GeoPoint();
         geoPoint.setLat("101");
         geoPoint.setLon("1010");
         busHospitalEntity.setCoordinate(geoPoint);

+ 29 - 16
coffee-common/src/main/java/com/coffee/common/cache/ClusterConfigStorage.java

@@ -1,9 +1,12 @@
 package com.coffee.common.cache;
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.baomidou.mybatisplus.annotation.IEnum;
 import com.coffee.common.cache.value.Value;
+import org.redisson.api.RMap;
+import org.redisson.api.RedissonClient;
 import org.springframework.cache.Cache;
 import org.springframework.cache.CacheManager;
 import org.springframework.data.redis.core.BoundHashOperations;
@@ -17,9 +20,9 @@ import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 public class ClusterConfigStorage implements ConfigStorage {
-    private  BoundHashOperations boundHashOperations;
-    public ClusterConfigStorage(RedisTemplate redisTemplate,String name){
-        boundHashOperations = redisTemplate.opsForSet().getOperations().boundHashOps(name);
+    private final RMap<String, Object>  cacheMap;
+    public ClusterConfigStorage(RedissonClient redissonClient,String name){
+        cacheMap = SpringUtil.getBean(RedissonClient.class).getMap(name);
     }
 
     @Override
@@ -27,7 +30,8 @@ public class ClusterConfigStorage implements ConfigStorage {
         if (StrUtil.isEmpty(key)) {
             return null;
         }
-        return Value.simple(boundHashOperations.get(key));
+//        return Value.simple(boundHashOperations.get(key));
+        return Value.simple(cacheMap.get(key));
     }
 
     @Override
@@ -43,7 +47,8 @@ public class ClusterConfigStorage implements ConfigStorage {
                 map.put(k,v);
             }
         });
-        boundHashOperations.putAll(map);
+//        boundHashOperations.putAll(map);
+        cacheMap.putAll(map);
         return true;
     }
 
@@ -53,47 +58,55 @@ public class ClusterConfigStorage implements ConfigStorage {
             return true;
         }
         if(value==null){
-            boundHashOperations.delete(key);
+            cacheMap.remove(key);
+//            boundHashOperations.delete(key);
         }else {
             if(value instanceof IEnum){
                 value=((IEnum) value).getValue();
             }
-            boundHashOperations.put(key,value);
+//            boundHashOperations.put(key,value);
+            cacheMap.put(key,value);
         }
         return true;
     }
 
     @Override
     public Value getAndRemove(String key) {
-        Value value = Value.simple(boundHashOperations.get(key));
-        boundHashOperations.delete(key);
-        return value;
+//        Value value = Value.simple(boundHashOperations.get(key));
+//        boundHashOperations.delete(key);
+
+        return      Value.simple(cacheMap.remove(key));
     }
 
     @Override
     public Boolean remove(String key) {
-        boundHashOperations.delete(key);
+//        boundHashOperations.delete(key);
+        cacheMap.remove(key);
         return true;
     }
 
     @Override
     public Boolean remove(Collection<String> key) {
-        boundHashOperations.delete(key);
+//        boundHashOperations.delete(key);
+        cacheMap.fastRemove(key.toArray(new String[CollectionUtil.size(key)]));
         return true;
     }
 
     @Override
     public Boolean clear() {
-        boundHashOperations.delete(boundHashOperations.keys());
+//        boundHashOperations.delete(boundHashOperations.keys());
+        cacheMap.readAllMap();
         return true;
     }
 
     @Override
     public Map<String, Value> getKeys(Collection<String> keys) {
         Map<String, Value> result = new HashMap<>();
-        keys.parallelStream().forEach(key->{
-            result.put(key,getConfig(key));
-        });
+        Map<String, Object> map = cacheMap.readAllMap();
+//        keys.parallelStream().forEach(key->{
+//            result.put(key,getConfig(key));
+//        });
+        map.forEach((k,v)->result.put(k,Value.simple(v)));
         return result;
     }
 }

+ 5 - 4
coffee-common/src/main/java/com/coffee/common/cache/manager/ClusterConfigStorageManager.java

@@ -2,6 +2,7 @@ package com.coffee.common.cache.manager;
 
 import com.coffee.common.cache.ClusterConfigStorage;
 import com.coffee.common.cache.ConfigStorage;
+import org.redisson.api.RedissonClient;
 import org.springframework.cache.CacheManager;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
@@ -19,19 +20,19 @@ import java.util.concurrent.ConcurrentHashMap;
 
 @Component
 public class ClusterConfigStorageManager implements ConfigStorageManager {
-    private final RedisTemplate redisTemplate;
 
+    private final RedissonClient redissonClient;
 
 
     private Map<String,ClusterConfigStorage > storageMap=new ConcurrentHashMap<>();
 
-    public ClusterConfigStorageManager(RedisTemplate redisTemplate) {
-        this.redisTemplate = redisTemplate;
+    public ClusterConfigStorageManager(RedissonClient redissonClient) {
+        this.redissonClient = redissonClient;
     }
 
     @Override
     public ConfigStorage getStorage(String id) {
-        return  storageMap.computeIfAbsent(id, __ -> new ClusterConfigStorage(redisTemplate,id));
+        return  storageMap.computeIfAbsent(id, __ -> new ClusterConfigStorage(redissonClient,id));
     }
 
 }

+ 11 - 0
coffee-system/src/main/java/com/coffee/bus/bean/GeoPoint.java

@@ -0,0 +1,11 @@
+package com.coffee.bus.bean;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class  GeoPoint implements Serializable {
+    private String lon;
+    private String lat;
+}

+ 0 - 11
coffee-system/src/main/java/com/coffee/bus/bean/config/Config.java

@@ -1,11 +0,0 @@
-package com.coffee.bus.bean.config;
-
-/**
- * @author lifang
- * @version 1.0.0
- * @ClassName Config.java
- * @Description TODO
- * @createTime 2022年04月12日 11:14:00
- */
-public abstract class Config {
-}

+ 0 - 97
coffee-system/src/main/java/com/coffee/bus/bean/config/EvalConfig.java

@@ -1,97 +0,0 @@
-package com.coffee.bus.bean.config;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-/**
- * @author lifang
- * @version 1.0.0
- * @ClassName EvalConfig.java
- * @Description 医院评价设置
- * @createTime 2022年04月12日 10:17:00
- */
-@Data
-@ApiModel("医院功能配置--评价设置")
-public class EvalConfig extends Config{
-
-    @ApiModelProperty(value = "评价提醒时间")
-    private Integer remindTime;
-
-    @ApiModelProperty(value = "已评价提醒间隔")
-    private Integer interval;
-
-    @ApiModelProperty(value = "疼痛评分静止")
-    private  Boolean statics;
-
-    @ApiModelProperty(value = "疼痛评分活动")
-    private  Boolean activity;
-
-    @ApiModelProperty(value = "镇静评分")
-    private  Boolean calm;
-
-    @ApiModelProperty(value = "左上肢")
-    private  Boolean leftArm;
-
-    @ApiModelProperty(value = "左下肢")
-    private  Boolean leftLeg;
-
-    @ApiModelProperty(value = "右上肢")
-    private  Boolean rightArm;
-
-    @ApiModelProperty(value = "右下肢")
-    private  Boolean rightLeg;
-
-    @ApiModelProperty(value = "恶心呕吐")
-    private  Boolean nauseaVomit;
-
-    @ApiModelProperty(value = "瘙痒")
-    private  Boolean itch;
-
-    @ApiModelProperty(value = "眩晕")
-    private  Boolean vertigo;
-
-    @ApiModelProperty(value = "咽喉疼痛")
-    private  Boolean soreThroat;
-
-    @ApiModelProperty(value = "尿潴留")
-    private  Boolean uroschesis;
-
-    @ApiModelProperty(value = "呼吸抑制")
-    private  Boolean breathDepression;
-
-    @ApiModelProperty(value = "声音嘶哑")
-    private  Boolean hoarseness;
-
-    @ApiModelProperty(value = "认知障碍")
-    private  Boolean cognitionObstacle;
-
-    @ApiModelProperty(value = "其他")
-    private  Boolean other;
-
-    @ApiModelProperty(value = "满意度")
-    private  Boolean satisfaction;
-
-
-    @ApiModelProperty(value = "评价时间",hidden = true)
-    private  Boolean evaluateTime;
-
-    @ApiModelProperty(value = "评价人")
-    private  Boolean evaluator;
-
-    @ApiModelProperty(value = "收缩压")
-    private  Boolean  shrinkPressure;
-
-
-    @ApiModelProperty(value = "舒张压")
-    private  Boolean  diastolicPressure;
-
-    @ApiModelProperty(value = "心率")
-    private  Boolean heartRate;
-
-    @ApiModelProperty(value = "呼吸频率")
-    private  Boolean breathRate;
-
-    @ApiModelProperty(value = "血氧饱和度")
-    private  Boolean bloodOxygenSaturation;
-}

+ 0 - 55
coffee-system/src/main/java/com/coffee/bus/bean/config/OtherConfig.java

@@ -1,55 +0,0 @@
-package com.coffee.bus.bean.config;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author lifang
- * @version 1.0.0
- * @ClassName OtherConfig.java
- * @Description TODO
- * @createTime 2022年04月12日 10:17:00
- */
-@Data
-@NoArgsConstructor
-@ApiModel("医院功能配置--其他设置")
-public class OtherConfig extends Config{
-
-    @ApiModelProperty("镇痛不足设置")
-    private Anal anal;
-
-    @ApiModelProperty("其他设置")
-    private Other other;
-
-    @Data
-    @NoArgsConstructor
-    @ApiModel("镇痛不足设置")
-    public static class Anal{
-        @ApiModelProperty("镇痛不足时间判定")
-        private Integer insufficientTime;
-        @ApiModelProperty("镇痛不足类型设置")
-        private Boolean valid;
-        @ApiModelProperty("镇痛不足次数设置")
-        private Integer insufficientCount;
-        @ApiModelProperty("镇痛不足提醒消失时间设置")
-        private Integer disappearTime;
-    }
-
-    @Data
-    @NoArgsConstructor
-    @ApiModel("其他设置")
-    public static class Other{
-        /**
-         * 不在服务区设置
-         */
-        @ApiModelProperty("不在服务区设置")
-        private Integer noSignal;
-        /**
-         * 低输注时间设置
-         */
-        @ApiModelProperty("低输注时间设置")
-        private Integer lowInfusion;
-    }
-}

+ 0 - 62
coffee-system/src/main/java/com/coffee/bus/bean/config/UndoConfig.java

@@ -1,62 +0,0 @@
-package com.coffee.bus.bean.config;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author lifang
- * @version 1.0.0
- * @ClassName ManualUndoConfig.java
- * @Description 医院撤泵设置
- * @createTime 2022年04月12日 10:17:00
- */
-@Data
-@ApiModel("医院功能配置--撤泵配置")
-public class UndoConfig extends Config{
-
-    @ApiModelProperty("自动撤泵")
-    private  AutoUndo auto;
-
-    @ApiModelProperty("手动撤泵")
-    private ManualUndo manual;
-    /**
-     * 自动撤泵
-     */
-    @ApiModel("自动撤泵")
-    @Data
-    @NoArgsConstructor
-    public static class AutoUndo{
-        @ApiModelProperty("开始自动撤泵")
-        private Boolean enable;
-        @ApiModelProperty("自动撤泵人类型")
-        private String undoByType;
-        @ApiModelProperty("自动撤泵人姓名")
-        private String undoBy;
-        @ApiModelProperty("关机到撤泵时间")
-        private Integer shutDownInterval;
-        @ApiModelProperty("不在服务区到撤泵时间")
-        private Integer noSignalInterval;
-    }
-
-    /**
-     * 手动撤泵
-     */
-    @ApiModel("手动撤泵")
-    @Data
-    @NoArgsConstructor
-    public static class  ManualUndo{
-        @ApiModelProperty("开启手动撤泵配置")
-        private Boolean enable;
-        @ApiModelProperty("撤泵人为空检测")
-        private Boolean undoByCheck;
-        @ApiModelProperty("销毁人为空检测")
-        private Boolean destroyerCheck;
-        @ApiModelProperty("见证人为空检测")
-        private Boolean witnessesCheck;
-        @ApiModelProperty("不在服务区撤泵时间")
-        private Boolean undoTime;
-
-    }
-}

+ 39 - 0
coffee-system/src/main/java/com/coffee/bus/config/HospitalConfigHandler.java

@@ -0,0 +1,39 @@
+package com.coffee.bus.config;
+
+import cn.hutool.core.util.ClassUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.coffee.bus.enums.ConfigEnum;
+
+import java.util.Map;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName HospitalConfigHandler.java
+ * @Description 医院配置处理器
+ * @createTime 2022年05月18日 10:33:00
+ */
+public interface HospitalConfigHandler<T> {
+
+    ConfigEnum getType();
+
+    String getDescription();
+
+    /**
+     * 描述: 设置配置参数
+     * @author lifang
+     * @date 2022/5/18 10:34
+     * @param map
+     * @return void
+     */
+    void setConfig(Map<String,Object> map);
+
+    /**
+     * 描述: 处理传入数据
+     * @author lifang
+     * @date 2022/5/18 10:34
+     * @param source 处理数据
+     * @return void
+     */
+    void handler(T source);
+}

+ 46 - 0
coffee-system/src/main/java/com/coffee/bus/config/HospitalFunctionOtherConfigHandler.java

@@ -0,0 +1,46 @@
+package com.coffee.bus.config;
+
+import cn.hutool.json.JSONUtil;
+import com.coffee.bus.entity.BusDeviceRunningEntity;
+import com.coffee.bus.enums.ConfigEnum;
+import com.coffee.bus.service.dto.function.FunctionOtherConfig;
+import com.coffee.common.cache.ClusterConfigStorage;
+
+import org.redisson.api.RedissonClient;
+import org.springframework.data.redis.core.RedisTemplate;
+
+import java.util.Map;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName HospitalFunctionOtherConfigHandler.java
+ * @Description 其他配置
+ * @createTime 2022年05月18日 11:25:00
+ */
+public class HospitalFunctionOtherConfigHandler extends ClusterConfigStorage implements HospitalConfigHandler<BusDeviceRunningEntity> {
+
+    public HospitalFunctionOtherConfigHandler(RedissonClient redissonClient, String name) {
+        super(redissonClient, name);
+    }
+
+    @Override
+    public ConfigEnum getType() {
+        return ConfigEnum.other;
+    }
+
+    @Override
+    public String getDescription() {
+        return "进行镇痛不足判定、不在服务区判定、低输注判定";
+    }
+
+    @Override
+    public void setConfig(Map<String, Object> map) {
+        JSONUtil.toBean(JSONUtil.toJsonStr(map), FunctionOtherConfig.class);
+    }
+
+    @Override
+    public void handler(BusDeviceRunningEntity source) {
+
+    }
+}

+ 1 - 1
coffee-system/src/main/java/com/coffee/bus/controller/BusAlarmController.java

@@ -30,7 +30,7 @@ public class BusAlarmController extends BaseCrudController<BusDeviceAlarmEntity,
 
     private final LocalBusDeviceAlarmService deviceAlarmService;
 
-    @PutMapping("/cause/{id}")
+    @PostMapping("/cause/{id}")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "cause",value = "报警原因",dataTypeClass = String.class,required = true,example = "设备误报"),
             @ApiImplicitParam(name = "id",value = "报警信息id",dataTypeClass = String.class,required = true)

+ 0 - 28
coffee-system/src/main/java/com/coffee/bus/controller/BusHospitalConfigController.java

@@ -1,16 +1,11 @@
 package com.coffee.bus.controller;
 
 import com.baomidou.mybatisplus.core.mapper.Mapper;
-import com.coffee.bus.bean.config.EvalConfig;
-import com.coffee.bus.bean.config.OtherConfig;
-import com.coffee.bus.bean.config.UndoConfig;
 import com.coffee.bus.entity.BusHospitalConfigEntity;
 import com.coffee.bus.service.LocalBusHospitalConfigService;
 import com.coffee.common.crud.BaseService;
 import com.coffee.common.crud.controller.BaseCrudController;
-import com.coffee.common.result.R;
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.web.bind.annotation.*;
 
@@ -28,29 +23,6 @@ import org.springframework.web.bind.annotation.*;
 public class BusHospitalConfigController extends BaseCrudController<BusHospitalConfigEntity, String> {
     private final LocalBusHospitalConfigService hospitalConfigService;
 
-    @PostMapping("/eval")
-    @ApiOperation(value = "",hidden = true)
-    @Deprecated
-    public R evalConfig(@RequestBody EvalConfig evalConfig){
-        return R.success();
-    }
-
-
-    @PostMapping("/other")
-    @ApiOperation(value = "",hidden = true)
-    @Deprecated
-    public R otherConfig(@RequestBody OtherConfig evalConfig){
-        return R.success();
-    }
-
-
-    @PostMapping("/undo")
-    @ApiOperation(value = "",hidden = true)
-    @Deprecated
-    public R undoConfig(@RequestBody UndoConfig evalConfig){
-        return R.success();
-    }
-
 
     /**
      * 权限控制前缀

+ 2 - 5
coffee-system/src/main/java/com/coffee/bus/entity/BusHospitalEntity.java

@@ -2,6 +2,7 @@ package com.coffee.bus.entity;
 
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import com.coffee.bus.bean.GeoPoint;
 import com.coffee.bus.bean.Script;
 import com.coffee.bus.his.strategy.HisStrategyEnum;
 import com.coffee.common.entity.RecordCreationEntity;
@@ -138,9 +139,5 @@ public class BusHospitalEntity implements RecordModifierEntity, RecordCreationEn
     @TableLogic(value = "0",delval = "1")
     private Integer isDelete;
 
-    @Data
-    public static class  GeoPoint{
-        private String lon;
-        private String lat;
-    }
+
 }

+ 61 - 0
coffee-system/src/main/java/com/coffee/bus/entity/common/CommonDeviceParam.java

@@ -1,10 +1,13 @@
 package com.coffee.bus.entity.common;
 
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.coffee.bus.enums.DeviceAlarmEnum;
 import com.coffee.bus.enums.DeviceStatusEnum;
 import com.coffee.bus.enums.FlowStatusEnum;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.experimental.Accessors;
@@ -30,18 +33,76 @@ public class CommonDeviceParam<PK,TN>  extends DeviceProperties<PK,TN>  {
 
     @ApiModelProperty(value = "输注即将结束提醒",readOnly = true)
     @TableField(updateStrategy = FieldStrategy.IGNORED)
+    @JsonIgnore
     private Boolean warnWillFinished;
 
     @ApiModelProperty(value = "镇痛不足提醒",readOnly = true)
     @TableField(updateStrategy = FieldStrategy.IGNORED)
+    @JsonIgnore
     private Boolean warnAnalgesicPoor;
 
     @ApiModelProperty(value = "电量偏低提醒",readOnly = true)
     @TableField(updateStrategy = FieldStrategy.IGNORED)
+    @JsonIgnore
     private Boolean warnLowBattery;
 
     @ApiModelProperty(value = "加减档提示",readOnly = true)
     @TableField(updateStrategy = FieldStrategy.IGNORED)
+    @JsonIgnore
     private FlowStatusEnum warnFlow;
 
+    @TableField(exist = false)
+    @ApiModelProperty("提醒字段")
+    private String warns;
+
+    private void judgeWarnWillFinished() {
+        if(!Boolean.TRUE.equals(this.warnWillFinished)){
+            return;
+        }
+        if (StrUtil.isEmpty(this.warns)) {
+            this.warns="输注即将结束;";
+        }else {
+            this.warns=this.warns+"输注即将结束;";
+        }
+    }
+
+    private void judgeWarnAnalgesicPoor() {
+        if(!Boolean.TRUE.equals(this.warnAnalgesicPoor)){
+            return;
+        }
+        if (StrUtil.isEmpty(this.warns)) {
+            this.warns="镇痛不足;";
+        }else {
+            this.warns=this.warns+"镇痛不足;";
+        }
+    }
+
+    private void judgeWarnLowBattery() {
+        if(!Boolean.TRUE.equals(this.warnLowBattery)){
+            return;
+        }
+        if (StrUtil.isEmpty(this.warns)) {
+            this.warns="电量偏低;";
+        }else {
+            this.warns=this.warns+"电量偏低;";
+        }
+    }
+
+    private void judgeWarnFlow() {
+        if(this.warnFlow==null){
+            return;
+        }
+        if (StrUtil.isEmpty(this.warns)) {
+            this.warns=warnFlow.getText()+";";
+        }else {
+            this.warns=this.warns+warnFlow.getText()+";";
+        }
+    }
+
+    public void handleWarn(){
+        judgeWarnAnalgesicPoor();
+        judgeWarnFlow();
+        judgeWarnLowBattery();
+        judgeWarnWillFinished();
+    }
 }

+ 3 - 8
coffee-system/src/main/java/com/coffee/bus/enums/ConfigEnum.java

@@ -1,10 +1,6 @@
 package com.coffee.bus.enums;
 
 import com.baomidou.mybatisplus.annotation.IEnum;
-import com.coffee.bus.bean.config.EvalConfig;
-import com.coffee.bus.bean.config.OtherConfig;
-import com.coffee.bus.bean.config.UndoConfig;
-import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.AllArgsConstructor;
 import lombok.Getter;
 
@@ -18,11 +14,10 @@ import lombok.Getter;
 @Getter
 @AllArgsConstructor
 public enum  ConfigEnum implements IEnum<Integer> {
-    undo(0,"撤泵配置", UndoConfig.class),
-    eval(1,"评价配置", EvalConfig.class),
-    other(2,"其他配置", OtherConfig.class);
+    undo(0,"撤泵配置"),
+    eval(1,"评价配置"),
+    other(2,"其他配置");
 
     private Integer value;
     private String text;
-    private Class configClass;
 }

+ 12 - 9
coffee-system/src/main/java/com/coffee/bus/his/HisScriptSession.java

@@ -22,8 +22,10 @@ import com.coffee.bus.service.LocalBusClinicService;
 import com.coffee.bus.service.LocalBusHospitalService;
 import com.coffee.common.cache.ClusterConfigStorage;
 import com.coffee.common.cache.value.Value;
+import com.coffee.common.exception.CustomException;
 import com.coffee.common.result.R;
 import lombok.extern.slf4j.Slf4j;
+import org.redisson.api.RedissonClient;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.util.Assert;
 import org.springframework.web.context.request.async.DeferredResult;
@@ -55,30 +57,31 @@ public class HisScriptSession {
     private ClusterConfigStorage clusterConfigStorage;
     private LocalBusHospitalService hospitalService;
     private Map<String,HisRequest> hisRequestMap=new ConcurrentHashMap<>();
+
     public HisScriptSession(String hospitalId, ChannelContext channelContext, ScriptManager scriptManager,
-                            RedisTemplate redisTemplate, LocalBusClinicService clinicService, LocalBusHospitalService hospitalService) {
+                            RedissonClient redissonClient, LocalBusClinicService clinicService, LocalBusHospitalService hospitalService) {
         this.hospitalId = hospitalId;
         this.channelContext = channelContext;
         this.scriptManager = scriptManager;
         this.clinicService = clinicService;
         this.hospitalService=hospitalService;
-        init(redisTemplate,hospitalId,hospitalService);
+        init(redissonClient,hospitalId,hospitalService);
     }
 
-    public HisScriptSession(String hospitalId, ScriptManager scriptManager, RedisTemplate redisTemplate, LocalBusClinicService clinicService,LocalBusHospitalService hospitalService) {
+    public HisScriptSession(String hospitalId, ScriptManager scriptManager, RedissonClient redissonClient, LocalBusClinicService clinicService,LocalBusHospitalService hospitalService) {
         this.hospitalId = hospitalId;
         this.scriptManager = scriptManager;
         this.clinicService = clinicService;
         this.hospitalService=hospitalService;
-        init(redisTemplate,hospitalId,hospitalService);
+        init(redissonClient,hospitalId,hospitalService);
     }
 
-    private void init(RedisTemplate redisTemplate,String hospitalId,LocalBusHospitalService hospitalService){
+    private void init(RedissonClient redissonClient, String hospitalId, LocalBusHospitalService hospitalService){
         BusHospitalEntity hospital = hospitalService.getById(hospitalId);
         if(hospital==null){
             throw new RuntimeException(String.format("医院{%s}不存在,获取医院脚本会话失败",hospitalId));
         }
-        clusterConfigStorage=new ClusterConfigStorage(redisTemplate,hospitalId);
+        clusterConfigStorage=new ClusterConfigStorage(redissonClient,hospitalId);
         clusterConfigStorage.setConfig("info",hospital);
     }
 
@@ -113,9 +116,9 @@ public class HisScriptSession {
      * @return BusClinicEntity
      */
     public  DeferredResult<R<BusClinicEntity>>  syncGetPatientInfo(String patientCode, long timeout, TimeUnit unit){
-//        if (!isOnline()) {
-//            throw new CustomException("医院不在线,拉取信息失败");
-//        }
+        if (!isOnline()) {
+            throw new CustomException("医院不在线,拉取信息失败");
+        }
         String messageId = IdWorker.getIdStr();
         DeferredResult<R<BusClinicEntity>> result = new DeferredResult<>(unit.toMillis(timeout));
         HisRequest request = HisRequest.builder()

+ 5 - 4
coffee-system/src/main/java/com/coffee/bus/his/HisScriptSessionManager.java

@@ -3,6 +3,7 @@ package com.coffee.bus.his;
 import com.coffee.bus.script.ScriptManager;
 import com.coffee.bus.service.LocalBusClinicService;
 import com.coffee.bus.service.LocalBusHospitalService;
+import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
@@ -22,14 +23,14 @@ public class HisScriptSessionManager {
     private Map<String,HisScriptSession> sessionMap=new ConcurrentHashMap<>();
     private LocalBusClinicService clinicService;
     private ScriptManager scriptManager;
-    private RedisTemplate redisTemplate;
+    private RedissonClient redissonClient;
     private LocalBusHospitalService hospitalService;
 
     @Autowired
-    public HisScriptSessionManager(LocalBusClinicService clinicService, ScriptManager scriptManager, RedisTemplate redisTemplate, LocalBusHospitalService hospitalService) {
+    public HisScriptSessionManager(LocalBusClinicService clinicService, ScriptManager scriptManager, RedissonClient redissonClient, LocalBusHospitalService hospitalService) {
         this.clinicService = clinicService;
         this.scriptManager = scriptManager;
-        this.redisTemplate = redisTemplate;
+        this.redissonClient = redissonClient;
         this.hospitalService = hospitalService;
     }
 
@@ -52,7 +53,7 @@ public class HisScriptSessionManager {
      * @return HisScriptSession
      */
     public HisScriptSession register(String hospitalId){
-        return new HisScriptSession(hospitalId, scriptManager,redisTemplate, clinicService,hospitalService);
+        return new HisScriptSession(hospitalId, scriptManager,redissonClient, clinicService,hospitalService);
     }
 
     /**

+ 1 - 3
coffee-system/src/main/java/com/coffee/bus/registry/Operator.java

@@ -1,10 +1,8 @@
 package com.coffee.bus.registry;
 
-import cn.hutool.core.util.ObjectUtil;
+
 import com.coffee.common.cache.ConfigStorage;
 import com.coffee.common.cache.value.Value;
-import org.springframework.cache.support.SimpleValueWrapper;
-import org.springframework.util.CollectionUtils;
 import org.springframework.util.ReflectionUtils;
 
 import java.lang.reflect.Field;

+ 1 - 8
coffee-system/src/main/java/com/coffee/bus/registry/patient/ClusterPatientOperator.java

@@ -138,14 +138,7 @@ public class ClusterPatientOperator implements PatientOperator<PatientCacheInfo>
 
     @Override
     public Set<DeviceTimeSmallInfo> getAllDevice() {
-        Set<Map<String,Object>> set = getValue(PatientKeyConstant.DEVICES).as(HashSet.class);
-        if(CollectionUtil.isNotEmpty(set)){
-            return set.stream()
-                    .map(JSONUtil::toJsonStr)
-                    .map(json-> JSONUtil.toBean(json,DeviceTimeSmallInfo.class))
-                    .collect(Collectors.toSet());
-        }
-        return new HashSet<>();
+        return getValue(PatientKeyConstant.DEVICES).as(HashSet.class);
     }
 
     @Override

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

@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.coffee.bus.bean.GeoPoint;
 import com.coffee.bus.entity.BusHospitalEntity;
 import com.coffee.bus.his.HisScriptSession;
 import com.coffee.bus.his.HisScriptSessionManager;
@@ -107,7 +108,7 @@ public class LocalBusHospitalService extends BaseService<BusHospitalMapper, BusH
         hospital.setId("1");
         hospital.setName("驼人医疗器械有限公司");
         hospital.setRemark("系统级医院,不可删除、修改");
-        BusHospitalEntity.GeoPoint geoPoint = new BusHospitalEntity.GeoPoint();
+        GeoPoint geoPoint = new GeoPoint();
         geoPoint.setLon("35.135106");
         geoPoint.setLat("114.658855");
         hospital.setCoordinate(geoPoint);

+ 25 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionAnalConfig.java

@@ -0,0 +1,25 @@
+package com.coffee.bus.service.dto.function;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName FunctionAnalConfig.java
+ * @Description TODO
+ * @createTime 2022年05月18日 10:18:00
+ */
+@ApiModel("镇痛不足配置")
+@Data
+public class FunctionAnalConfig {
+    @ApiModelProperty("镇痛不足提醒消失时间")
+    private Integer disappearTime;
+    @ApiModelProperty("镇痛不足判定次数")
+    private Integer insufficientCount;
+    @ApiModelProperty("镇痛不足判定时间")
+    private Integer insufficientTime;
+    @ApiModelProperty("镇痛不足判定 pca有效 pca无效")
+    private Boolean valid;
+}

+ 27 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionAutoUndoConfig.java

@@ -0,0 +1,27 @@
+package com.coffee.bus.service.dto.function;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName FunctionAutoUndoConfig.java
+ * @Description TODO
+ * @createTime 2022年05月18日 08:42:00
+ */
+@ApiModel("自动撤泵配置")
+@Data
+public class FunctionAutoUndoConfig {
+    @ApiModelProperty("是否开启自动撤泵")
+    private boolean enable;
+    @ApiModelProperty("不在服务区撤泵时间间隔")
+    private Integer noSignalInterval;
+    @ApiModelProperty("关机撤泵时间间隔")
+    private Integer shutDownInterval;
+    @ApiModelProperty("自动撤泵人姓名")
+    private String undoBy;
+    @ApiModelProperty("自动撤泵人是否为麻醉医生")
+    private boolean undoByType;
+}

+ 19 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionExtraConfig.java

@@ -0,0 +1,19 @@
+package com.coffee.bus.service.dto.function;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName FunctionExtraConfig.java
+ * @Description TODO
+ * @createTime 2022年05月18日 10:22:00
+ */
+@ApiModel("其他配置中的其他配置")
+public class FunctionExtraConfig {
+    @ApiModelProperty("低输注时间设置")
+    private Integer lowInfusion;
+    @ApiModelProperty("不在服务区时间设置")
+    private Integer noSignal;
+}

+ 29 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionManualUndoConfig.java

@@ -0,0 +1,29 @@
+package com.coffee.bus.service.dto.function;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName FunctionAutoUndoConfig.java
+ * @Description TODO
+ * @createTime 2022年05月18日 08:42:00
+ */
+@ApiModel("手动撤泵配置")
+@Data
+public class FunctionManualUndoConfig {
+    @ApiModelProperty("是否开启手动撤泵配置")
+    private boolean enable;
+    @ApiModelProperty("撤泵人为空检测")
+    private boolean undoByCheck;
+    @ApiModelProperty("销毁人为空检测")
+    private boolean destroyerCheck;
+    @ApiModelProperty("见证人为空检测")
+    private boolean witnessesCheck;
+    @ApiModelProperty("不在服务区到撤泵时间,当设备处于不在服务区状态时,过了一定的时间间隔才能手动撤泵")
+    @Deprecated
+    private Integer undoTime;
+
+}

+ 21 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionOtherConfig.java

@@ -0,0 +1,21 @@
+package com.coffee.bus.service.dto.function;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName FunctionOtherConfig.java
+ * @Description TODO
+ * @createTime 2022年05月18日 08:54:00
+ */
+@Data
+@ApiModel("其他配置")
+public class FunctionOtherConfig {
+    @ApiModelProperty("其他配置")
+    private FunctionExtraConfig other;
+    @ApiModelProperty("镇痛不足配置")
+    private FunctionAnalConfig anal;
+}

+ 20 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionUndoConfig.java

@@ -0,0 +1,20 @@
+package com.coffee.bus.service.dto.function;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName FunctionUndoConfig.java
+ * @Description TODO
+ * @createTime 2022年05月18日 08:33:00
+ */
+@ApiModel("撤泵功能配置")
+@Data
+public class FunctionUndoConfig {
+    private FunctionAutoUndoConfig auto;
+
+    private FunctionManualUndoConfig manual;
+
+}

+ 1 - 3
coffee-system/src/main/java/com/coffee/bus/handler/CheckSignHandler.java → coffee-system/src/main/java/com/coffee/bus/web/handler/CheckSignHandler.java

@@ -1,4 +1,4 @@
-package com.coffee.bus.handler;
+package com.coffee.bus.web.handler;
 
 import cn.hutool.core.io.IoUtil;
 import cn.hutool.core.util.StrUtil;
@@ -7,8 +7,6 @@ import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.coffee.common.result.R;
 import com.coffee.common.result.ResultCode;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Profile;
 import org.springframework.web.servlet.HandlerInterceptor;
 
 import javax.servlet.http.HttpServletRequest;

+ 1 - 1
coffee-system/src/main/java/com/coffee/bus/handler/TenantIdHandler.java → coffee-system/src/main/java/com/coffee/bus/web/handler/TenantIdHandler.java

@@ -1,4 +1,4 @@
-package com.coffee.bus.handler;
+package com.coffee.bus.web.handler;
 
 import com.coffee.common.bo.LoginUser;
 import com.coffee.common.util.SecurityUtil;

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

@@ -216,13 +216,7 @@ public class DeviceInfoListener {
         PatientOperator<PatientCacheInfo> currentPatientOperator = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode());
         String bindDeviceId = currentPatientOperator.getBindDeviceId();
         //当前病号所绑定的泵发生了改变,对当前病号进行处理
-        if(!StrUtil.isNullOrUndefined(bindDeviceId)&&!deviceId.equals(bindDeviceId)){
-            handleConflictCurrentPatient(device,suppliers);
-            suppliers.add(()->{
-                wsPublishUtils.publishDeviceRepeat(device.getTenantId());
-                return null;
-            });
-        }else if(StrUtil.isNullOrUndefined(bindDeviceId)){
+        if(StrUtil.isNullOrUndefined(bindDeviceId)){
             //当前的病号之前为无泵状态,无泵 -》 有泵 做处理  修改缓存信息
             log.error("病号:【{}】临床发生由无泵转为有泵",device.getPatientCode());
             patientService.update(new UpdateWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode,device.getPatientCode())
@@ -234,6 +228,12 @@ public class DeviceInfoListener {
                 wsPublishUtils.publishDeviceNone(device.getTenantId());
                 return null;
             });
+        }else if(ObjectUtil.notEqual(deviceId,bindDeviceId)){
+            handleConflictCurrentPatient(device,suppliers);
+            suppliers.add(()->{
+                wsPublishUtils.publishDeviceRepeat(device.getTenantId());
+                return null;
+            });
         }else {
             if(newInfusion.get()){
                 patientService.update(new UpdateWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode,device.getPatientCode())
@@ -272,8 +272,8 @@ public class DeviceInfoListener {
             if(CollectionUtil.isEmpty(remainPatientBindDevices)){
                 log.warn("病号:【{}】临床发生无泵报警",patientCode);
                 patientService.update(new UpdateWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode,patientCode)
-                                .eq(BusPatientEntity::getTenantId,hospitalId)
-                                .set(BusPatientEntity::getAlarm, PatientAlarmEnum.DEVICE_NONE)
+                        .eq(BusPatientEntity::getTenantId,hospitalId)
+                        .set(BusPatientEntity::getAlarm, PatientAlarmEnum.DEVICE_NONE)
                 );
                 suppliers.add(()->{
                     //todo 发起无泵报警,处理原先泵的无泵信息
@@ -336,7 +336,7 @@ public class DeviceInfoListener {
         String deviceId = device.getDeviceId();
         PatientOperator<PatientCacheInfo> patientOperator = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode());
         String bindDeviceId = patientOperator.getBindDeviceId();
-        if(!StrUtil.isNullOrUndefined(bindDeviceId)&&!deviceId.equals(bindDeviceId)){
+        if(ObjectUtil.notEqual(deviceId,bindDeviceId)){
             //泵号发生改变,获取病号绑定的泵信息,判断绑定的泵开始时间,将开始时间稍后的泵设置为主泵
             DeviceOperator<DeviceCacheInfo> patientCurrentBindDevice = deviceRegistry.getOperator(bindDeviceId);
             Date startTime = patientCurrentBindDevice.getStartTime();

+ 1 - 1
coffee-system/src/main/resources/mapper/bus/BusPatientMapper.xml

@@ -130,7 +130,7 @@
          c.ana_type as ana_type,
          c.anal_type as anal_type,
          c.surgery_doctor as surgery_doctor,
-         c.asa as asa
+         c.asa as asa,
          c.formula as formula,
          c.finished as finished,
          c.config_person as config_person