فهرست منبع

Merge remote-tracking branch 'origin/dev' into zsl

15638522405 3 سال پیش
والد
کامیت
a19e7ecbbe
57فایلهای تغییر یافته به همراه824 افزوده شده و 613 حذف شده
  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. 20 35
      coffee-common/src/main/java/com/coffee/common/config/websocket/DefaultMessageListener.java
  5. 0 1
      coffee-common/src/main/java/com/coffee/common/config/websocket/DefaultWebSocketMsgHandler.java
  6. 16 0
      coffee-common/src/main/java/com/coffee/common/config/websocket/TopicMessage.java
  7. 34 96
      coffee-common/src/main/java/com/coffee/common/config/websocket/handler/Subscribe.java
  8. 2 1
      coffee-common/src/main/java/com/coffee/common/entity/GenericEntity.java
  9. 46 0
      coffee-common/src/main/java/com/coffee/common/util/RedissonUtil.java
  10. 6 0
      coffee-framework/pom.xml
  11. 174 0
      coffee-framework/src/main/java/com/coffee/framework/config/RedissonClientAutoConfiguration.java
  12. 11 0
      coffee-system/src/main/java/com/coffee/bus/bean/GeoPoint.java
  13. 0 11
      coffee-system/src/main/java/com/coffee/bus/bean/config/Config.java
  14. 0 97
      coffee-system/src/main/java/com/coffee/bus/bean/config/EvalConfig.java
  15. 0 55
      coffee-system/src/main/java/com/coffee/bus/bean/config/OtherConfig.java
  16. 0 62
      coffee-system/src/main/java/com/coffee/bus/bean/config/UndoConfig.java
  17. 39 0
      coffee-system/src/main/java/com/coffee/bus/config/HospitalConfigHandler.java
  18. 46 0
      coffee-system/src/main/java/com/coffee/bus/config/HospitalFunctionOtherConfigHandler.java
  19. 1 1
      coffee-system/src/main/java/com/coffee/bus/controller/BusAlarmController.java
  20. 43 49
      coffee-system/src/main/java/com/coffee/bus/controller/BusClinicController.java
  21. 1 1
      coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceManualController.java
  22. 0 28
      coffee-system/src/main/java/com/coffee/bus/controller/BusHospitalConfigController.java
  23. 0 1
      coffee-system/src/main/java/com/coffee/bus/controller/BusPatientController.java
  24. 2 5
      coffee-system/src/main/java/com/coffee/bus/entity/BusHospitalEntity.java
  25. 2 1
      coffee-system/src/main/java/com/coffee/bus/entity/PatientDeviceRepeatDomain.java
  26. 61 0
      coffee-system/src/main/java/com/coffee/bus/entity/common/CommonDeviceParam.java
  27. 3 8
      coffee-system/src/main/java/com/coffee/bus/enums/ConfigEnum.java
  28. 12 9
      coffee-system/src/main/java/com/coffee/bus/his/HisScriptSession.java
  29. 5 4
      coffee-system/src/main/java/com/coffee/bus/his/HisScriptSessionManager.java
  30. 1 3
      coffee-system/src/main/java/com/coffee/bus/registry/Operator.java
  31. 1 8
      coffee-system/src/main/java/com/coffee/bus/registry/patient/ClusterPatientOperator.java
  32. 0 2
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceHistoryService.java
  33. 2 1
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusHospitalService.java
  34. 2 1
      coffee-system/src/main/java/com/coffee/bus/service/dto/ClinicAnalClinicRecord.java
  35. 2 1
      coffee-system/src/main/java/com/coffee/bus/service/dto/ClinicResult.java
  36. 2 1
      coffee-system/src/main/java/com/coffee/bus/service/dto/DeviceResult.java
  37. 2 1
      coffee-system/src/main/java/com/coffee/bus/service/dto/ManualMonitorResult.java
  38. 3 1
      coffee-system/src/main/java/com/coffee/bus/service/dto/MonitorStatusStatsCountResult.java
  39. 3 1
      coffee-system/src/main/java/com/coffee/bus/service/dto/MonitorTimeStatsCountResult.java
  40. 5 3
      coffee-system/src/main/java/com/coffee/bus/service/dto/PatientDeviceNoneResult.java
  41. 5 3
      coffee-system/src/main/java/com/coffee/bus/service/dto/PatientDeviceRepeatResult.java
  42. 2 1
      coffee-system/src/main/java/com/coffee/bus/service/dto/PatientMonitorDetailResult.java
  43. 2 1
      coffee-system/src/main/java/com/coffee/bus/service/dto/PatientMonitorQuery.java
  44. 2 1
      coffee-system/src/main/java/com/coffee/bus/service/dto/PatientMonitorResult.java
  45. 25 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionAnalConfig.java
  46. 27 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionAutoUndoConfig.java
  47. 19 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionExtraConfig.java
  48. 29 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionManualUndoConfig.java
  49. 21 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionOtherConfig.java
  50. 20 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/function/FunctionUndoConfig.java
  51. 23 67
      coffee-system/src/main/java/com/coffee/bus/utils/WsPublishUtils.java
  52. 1 3
      coffee-system/src/main/java/com/coffee/bus/web/handler/CheckSignHandler.java
  53. 1 1
      coffee-system/src/main/java/com/coffee/bus/web/handler/TenantIdHandler.java
  54. 4 7
      coffee-system/src/main/java/com/coffee/bus/websocket/WebSocketCloseHandler.java
  55. 43 18
      coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java
  56. 2 2
      coffee-system/src/main/resources/mapper/bus/BusPatientMapper.xml
  57. 15 0
      pom.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));
     }
 
 }

+ 20 - 35
coffee-common/src/main/java/com/coffee/common/config/websocket/DefaultMessageListener.java

@@ -1,25 +1,18 @@
 package com.coffee.common.config.websocket;
 
-import cn.hutool.core.collection.CollectionUtil;
-import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
-import com.coffee.common.cache.value.Value;
-import com.coffee.common.config.websocket.handler.TopicWrapper;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.data.redis.connection.Message;
-import org.springframework.data.redis.connection.MessageListener;
+import org.redisson.api.RPatternTopic;
+import org.redisson.api.listener.PatternMessageListener;
 import org.tio.core.ChannelContext;
 import org.tio.core.Tio;
 import org.tio.core.utils.TioUtils;
 import org.tio.websocket.common.WsPacket;
 import org.tio.websocket.common.WsResponse;
 
-import java.util.HashSet;
-import java.util.Set;
-
 /**
  * @author lifang
  * @version 1.0.0
@@ -29,34 +22,26 @@ import java.util.Set;
  */
 @Data
 @Slf4j
-public class DefaultMessageListener implements MessageListener {
+public class DefaultMessageListener implements PatternMessageListener<TopicMessage> {
     private final String id;
-    private final TopicWrapper topicWrapper;
     private final ObjectMapper objectMapper;
-    private final  Set<ChannelContext> channelContexts;
+    private final ChannelContext channelContext;
+    private final RPatternTopic rPatternTopic;
+
+
     @Override
-    public void onMessage(Message message, byte[] pattern) {
-        if (CollectionUtil.isNotEmpty(channelContexts)) {
-            Set<ChannelContext> closeChannel = new HashSet<>();
-            channelContexts.parallelStream()
-                    .forEach(channel -> {
-                        if (!TioUtils.checkBeforeIO(channel)) {
-                            closeChannel.add(channel);
-                            return;
-                        }
-                        String json = null;
-                        try {
-                            JSONObject jsonObject = JSONUtil.parseObj(message.toString());
-                            json = objectMapper.writeValueAsString(MessageResponse.of(id, "result", Value.simple( jsonObject.get("param")).asString(),
-                                    JSONUtil.parse(jsonObject.get("message"))));
-                            Tio.send(channel,WsResponse.fromText(json, WsPacket.CHARSET_NAME));
-                        } catch (JsonProcessingException e) {
-                            log.error("ws消息订阅,解析失败,message:【】",message.toString());
-                        }
-                            }
-                    );
-            channelContexts.removeAll(closeChannel);
+    public void onMessage(CharSequence pattern, CharSequence channel, TopicMessage msg) {
+        if (TioUtils.checkBeforeIO(channelContext)) {
+            String json = null;
+            try {
+                json = objectMapper.writeValueAsString(MessageResponse.of(id, "result", msg.getParam(),
+                        JSONUtil.parse(objectMapper.writeValueAsString(msg.getMessage()))));
+                Tio.send(channelContext, WsResponse.fromText(json, WsPacket.CHARSET_NAME));
+            } catch (JsonProcessingException e) {
+                log.error("ws消息订阅,解析失败,message:【】", JSONUtil.toJsonStr(msg));
+            }
+        }else {
+            rPatternTopic.removeListener(this);
         }
     }
-
-}
+}

+ 0 - 1
coffee-common/src/main/java/com/coffee/common/config/websocket/DefaultWebSocketMsgHandler.java

@@ -6,7 +6,6 @@ import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.coffee.common.Constants;
 import com.coffee.common.bo.LoginUser;
-import com.coffee.common.cache.value.Value;
 import com.coffee.common.config.websocket.handler.WsHandler;
 import com.coffee.common.result.R;
 import lombok.AllArgsConstructor;

+ 16 - 0
coffee-common/src/main/java/com/coffee/common/config/websocket/TopicMessage.java

@@ -0,0 +1,16 @@
+package com.coffee.common.config.websocket;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@Data
+@AllArgsConstructor(staticName = "of")
+@NoArgsConstructor
+public class TopicMessage implements Serializable {
+    private Object message;
+    private String param;
+
+}

+ 34 - 96
coffee-common/src/main/java/com/coffee/common/config/websocket/handler/Subscribe.java

@@ -1,30 +1,21 @@
 package com.coffee.common.config.websocket.handler;
 
 import cn.hutool.core.collection.CollectionUtil;
-import cn.hutool.core.util.StrUtil;
 import com.coffee.common.Constants;
 import com.coffee.common.bo.LoginUser;
 import com.coffee.common.config.websocket.DefaultMessageListener;
 import com.coffee.common.config.websocket.MessagingRequest;
+import com.coffee.common.config.websocket.TopicMessage;
 import com.coffee.common.config.websocket.WebSocketConstant;
+import com.coffee.common.util.RedissonUtil;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.extern.slf4j.Slf4j;
+import org.redisson.api.RPatternTopic;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.dao.DataAccessException;
-import org.springframework.data.redis.connection.RedisConnection;
-import org.springframework.data.redis.connection.RedisPubSubCommands;
-import org.springframework.data.redis.connection.Subscription;
-import org.springframework.data.redis.core.RedisCallback;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.util.ConcurrentReferenceHashMap;
 import org.tio.core.ChannelContext;
 
-import javax.annotation.Resource;
 import java.util.*;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.stream.Collectors;
 
 /**
@@ -36,23 +27,15 @@ import java.util.stream.Collectors;
  */
 @Slf4j
 public abstract class Subscribe implements WsHandler {
-    @Autowired
-    private RedisTemplate<String,Object> redisTemplate;
-
     @Autowired
     private ObjectMapper objectMapper;
 
-    public static final String SUBSCRIBE_TOPIC="subscribe-topic";
-    /**
-     * 存储主题与ws通道关联
-     */
-    private static Map<String,Set<ChannelContext>> subscribeTopics=new ConcurrentHashMap<>();
-
-
+    @Autowired
+    private RedissonUtil redissonUtil;
     /**
      * 存储主题与redis通道关联
      */
-    private static Map<String,RedisConnection> redisConnectionMap=new ConcurrentReferenceHashMap<>();
+    private static Map<String, RPatternTopic> topicMap=new ConcurrentReferenceHashMap<>();
 
 
     public TopicWrapper getTopic(String productName,String param,String tenantId){
@@ -60,10 +43,6 @@ public abstract class Subscribe implements WsHandler {
 
     };
 
-    public static Set<ChannelContext> getSubscribeChannel(String topic){
-        return subscribeTopics.get(topic);
-    }
-
 
     @Override
     public void onMessage(MessagingRequest message, ChannelContext channelContext) {
@@ -91,13 +70,10 @@ public abstract class Subscribe implements WsHandler {
         MessagingRequest.Type type = message.getType();
         if(MessagingRequest.Type.sub==type){
             //订阅主题
-            for (TopicWrapper topicWrapper : subScribeTopic) {
-                this.subscribe(channelContext,topicWrapper);
-            }
-//            subScribeTopic.forEach(topicWrapper->this.subscribe(channelContext,topicWrapper));
+            subScribeTopic.forEach(topicWrapper->this.subscribe(channelContext,topicWrapper));
         }else {
             //取消订阅主题
-//            subScribeTopic.forEach(topicWrapper->this.unsubscribe(channelContext,topicWrapper.getTopic()));
+            subScribeTopic.forEach(topicWrapper->this.unsubscribe(channelContext,topicWrapper.getTopic()));
         }
         log.error("订阅成功{}",subScribeTopic.stream().map(TopicWrapper::getTopic).collect(Collectors.toList()));
 
@@ -110,40 +86,8 @@ public abstract class Subscribe implements WsHandler {
      */
     public void subscribe(ChannelContext channelContext, TopicWrapper topicWrapper){
         //同一主题只订阅一次
-        Set<ChannelContext> channelContexts = subscribeTopics.computeIfAbsent(topicWrapper.getTopic(), k -> new HashSet<>());
-        channelContexts.add(channelContext);
-        boolean subscribe=false;
-        RedisConnection redisConnection = redisConnectionMap.get(topicWrapper.getTopic());
-        if(redisConnection==null){
-            subscribe=true;
-        }else {
-            Subscription subscription = redisConnection.getSubscription();
-            if(subscription==null||CollectionUtil.isEmpty(subscription.getPatterns())){
-                subscribe=true;
-            }else {
-                Collection<byte[]> patterns = subscription.getPatterns();
-                for (byte[] pattern : patterns) {
-                    String patternName = new String(pattern);
-                    if(topicWrapper.getTopic().equals(patternName)){
-                        subscribe=true;
-                        break;
-                    }
-                }
-            }
-        }
-        if(subscribe){
-            redisTemplate.execute(new RedisCallback<Object>() {
-                @Override
-                public Object doInRedis(RedisConnection connection) throws DataAccessException {
-                    CompletableFuture.runAsync(()->{
-                        connection.pSubscribe(new DefaultMessageListener(getId(),topicWrapper,objectMapper,channelContexts),topicWrapper.getTopic().getBytes());
-                    });
-                    redisConnectionMap.put(topicWrapper.getTopic(),connection);
-                    return null;
-                }
-            });
-        }
-        getTopicByChannel(channelContext).add(topicWrapper.getTopic());
+        RPatternTopic rTopic = topicMap.computeIfAbsent(topicWrapper.getTopic(),topic->redissonUtil.getPatternTopic(topicWrapper.getTopic()));
+        addTopicListener(rTopic,channelContext, topicWrapper.getTopic());
     };
 
     /**
@@ -152,40 +96,34 @@ public abstract class Subscribe implements WsHandler {
      * @param topic
      */
     public void unsubscribe(ChannelContext channelContext, String topic){
-        if(StrUtil.isEmpty(topic)){
-            return;
-        }
-        AtomicBoolean remove = new AtomicBoolean(false);
-        subscribeTopics.computeIfPresent(topic,(k,v)->{
-            v.remove(channelContext);
-//            if(CollectionUtil.isEmpty(v)){
-                remove.set(true);
-//                redisTemplate.execute(new RedisCallback<Object>() {
-//                    @Override
-//                    public Object doInRedis(RedisConnection connection) throws DataAccessException {
-//                        RedisConnection redisConnection = redisConnectionMap.get(topic);
-//                        if (redisConnection!=null) {
-//                            Optional.ofNullable(redisConnection.getSubscription())
-//                                    .map(subscription -> {
-//                                        subscription.pUnsubscribe(topic.getBytes());
-//                                        return subscription;
-//                                    });
-//                        }
-//                        return null;
-//                    }
-//                });
-//                redisConnectionMap.remove(topic);
-//            }
-            return v;
-        });
+//        if(StrUtil.isEmpty(topic)){
+//            return;
+//        }
+//        topicMap.computeIfPresent(topic,(k,rTopic)->{
+//            rTopic.removeListener( getTopicListener(channelContext,k));
+//            return rTopic;
+//        });
     };
 
 
-    public Set<String> getTopicByChannel(ChannelContext channelContext){
-        Object result = Optional.ofNullable(channelContext.get(SUBSCRIBE_TOPIC)).orElse(new HashSet<>());
-        channelContext.set(SUBSCRIBE_TOPIC,result);
-        return  (Set<String>) result;
+    public Map<String,DefaultMessageListener> getTopicListeners(ChannelContext channelContext){
+        Object result = Optional.ofNullable(channelContext.get("topic")).orElse(new HashMap<String,DefaultMessageListener>());
+        channelContext.set("topic",result);
+        return  (Map<String,DefaultMessageListener>) result;
     }
 
+    public DefaultMessageListener getTopicListener(ChannelContext channelContext,String topic){
+        Map<String,DefaultMessageListener> result = (Map<String, DefaultMessageListener>) Optional.ofNullable(channelContext.get("topic")).orElse(new HashMap<>());
+        return  result.get(topic);
+    }
 
+    public DefaultMessageListener addTopicListener(RPatternTopic rTopic,ChannelContext channelContext,String topic){
+        Map<String, DefaultMessageListener> topicByChannel = getTopicListeners(channelContext);
+        DefaultMessageListener messageListener = topicByChannel.computeIfAbsent(topic, k -> {
+            DefaultMessageListener defaultMessageListener = new DefaultMessageListener(getId(), objectMapper, channelContext,rTopic);
+            rTopic.addListener(TopicMessage.class, defaultMessageListener);
+            return defaultMessageListener;
+        });
+        return  messageListener;
+    }
 }

+ 2 - 1
coffee-common/src/main/java/com/coffee/common/entity/GenericEntity.java

@@ -14,10 +14,11 @@ import org.springframework.validation.annotation.Validated;
 
 
 import javax.validation.constraints.NotNull;
+import java.io.Serializable;
 import java.util.Date;
 
 @Data
-public abstract class  GenericEntity<PK> implements Entity,RecordModifierEntity,RecordCreationEntity {
+public abstract class  GenericEntity<PK> implements Entity,RecordModifierEntity,RecordCreationEntity, Serializable {
     private static final long serialVersionUID = 1L;
 
     @TableId(type = IdType.ASSIGN_ID)

+ 46 - 0
coffee-common/src/main/java/com/coffee/common/util/RedissonUtil.java

@@ -0,0 +1,46 @@
+package com.coffee.common.util;
+
+import cn.hutool.json.JSONUtil;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.redisson.api.RPatternTopic;
+import org.redisson.api.RTopic;
+import org.redisson.api.RedissonClient;
+import org.redisson.client.codec.Codec;
+import org.redisson.codec.JsonJacksonCodec;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName RedissonUtil.java
+ * @Description TODO
+ * @createTime 2022年05月17日 16:16:00
+ */
+@Component
+public class RedissonUtil {
+    @Autowired
+    private RedissonClient redissonClient;
+    @Autowired
+    private ObjectMapper objectMapper;
+    private JsonJacksonCodec jsonObjectCodec;
+
+    @PostConstruct
+    public void init(){
+        jsonObjectCodec=new JsonJacksonCodec(objectMapper);
+    }
+
+    public RPatternTopic getPatternTopic(String pattern){
+        return redissonClient.getPatternTopic(pattern);
+    }
+
+    public RTopic getTopic(String pattern){
+        return redissonClient.getTopic(pattern);
+    }
+
+    public RTopic getTopic(String pattern, Codec codec){
+        return redissonClient.getTopic(pattern,codec);
+    }
+}

+ 6 - 0
coffee-framework/pom.xml

@@ -47,5 +47,11 @@
             <groupId>com.coffee</groupId>
             <artifactId>coffee-system</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>org.redisson</groupId>
+            <artifactId>redisson-spring-boot-starter</artifactId>
+        </dependency>
+
     </dependencies>
 </project>

+ 174 - 0
coffee-framework/src/main/java/com/coffee/framework/config/RedissonClientAutoConfiguration.java

@@ -0,0 +1,174 @@
+//
+// Source code recreated from a .class file by IntelliJ IDEA
+// (powered by Fernflower decompiler)
+//
+
+package com.coffee.framework.config;
+
+import org.redisson.Redisson;
+import org.redisson.api.RedissonClient;
+import org.redisson.config.ClusterServersConfig;
+import org.redisson.config.Config;
+import org.redisson.config.SentinelServersConfig;
+import org.redisson.config.SingleServerConfig;
+import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
+import org.redisson.spring.starter.RedissonProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.AutoConfigureBefore;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
+import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
+import org.springframework.boot.autoconfigure.data.redis.RedisProperties.Sentinel;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.core.io.Resource;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisOperations;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.util.ReflectionUtils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+@Configuration
+@ConditionalOnClass({Redisson.class, RedisOperations.class})
+@AutoConfigureBefore({RedisAutoConfiguration.class})
+@EnableConfigurationProperties({RedissonProperties.class, RedisProperties.class})
+public class RedissonClientAutoConfiguration {
+    private static final String REDIS_PROTOCOL_PREFIX = "redis://";
+    private static final String REDISS_PROTOCOL_PREFIX = "rediss://";
+    @Autowired(
+        required = false
+    )
+    private List<RedissonAutoConfigurationCustomizer> redissonAutoConfigurationCustomizers;
+    @Autowired
+    private RedissonProperties redissonProperties;
+    @Autowired
+    private RedisProperties redisProperties;
+    @Autowired
+    private ApplicationContext ctx;
+
+    public RedissonClientAutoConfiguration() {
+    }
+
+    @Bean(
+        destroyMethod = "shutdown"
+    )
+    @ConditionalOnMissingBean({RedissonClient.class})
+    public RedissonClient redisson() throws IOException {
+        Config config = null;
+        Method clusterMethod = ReflectionUtils.findMethod(RedisProperties.class, "getCluster");
+        Method timeoutMethod = ReflectionUtils.findMethod(RedisProperties.class, "getTimeout");
+        Object timeoutValue = ReflectionUtils.invokeMethod(timeoutMethod, this.redisProperties);
+        int timeout;
+        Method nodesMethod;
+        if (null == timeoutValue) {
+            timeout = 10000;
+        } else if (!(timeoutValue instanceof Integer)) {
+            nodesMethod = ReflectionUtils.findMethod(timeoutValue.getClass(), "toMillis");
+            timeout = ((Long) ReflectionUtils.invokeMethod(nodesMethod, timeoutValue)).intValue();
+        } else {
+            timeout = (Integer)timeoutValue;
+        }
+
+        if (this.redissonProperties.getConfig() != null) {
+            try {
+                config = Config.fromYAML(this.redissonProperties.getConfig());
+            } catch (IOException var13) {
+                try {
+                    config = Config.fromJSON(this.redissonProperties.getConfig());
+                } catch (IOException var12) {
+                    throw new IllegalArgumentException("Can't parse config", var12);
+                }
+            }
+        } else if (this.redissonProperties.getFile() != null) {
+            try {
+                InputStream is = this.getConfigStream();
+                config = Config.fromYAML(is);
+            } catch (IOException var11) {
+                try {
+                    InputStream is = this.getConfigStream();
+                    config = Config.fromJSON(is);
+                } catch (IOException var10) {
+                    throw new IllegalArgumentException("Can't parse config", var10);
+                }
+            }
+        } else if (this.redisProperties.getSentinel() != null) {
+            nodesMethod = ReflectionUtils.findMethod(Sentinel.class, "getNodes");
+            Object nodesValue = ReflectionUtils.invokeMethod(nodesMethod, this.redisProperties.getSentinel());
+            String[] nodes;
+            if (nodesValue instanceof String) {
+                nodes = this.convert(Arrays.asList(((String)nodesValue).split(",")));
+            } else {
+                nodes = this.convert((List)nodesValue);
+            }
+
+            config = new Config();
+            ((SentinelServersConfig)config.useSentinelServers().setMasterName(this.redisProperties.getSentinel().getMaster()).addSentinelAddress(nodes).setDatabase(this.redisProperties.getDatabase()).setConnectTimeout(timeout)).setPassword(this.redisProperties.getPassword());
+        } else {
+            Method method;
+            if (clusterMethod != null && ReflectionUtils.invokeMethod(clusterMethod, this.redisProperties) != null) {
+                Object clusterObject = ReflectionUtils.invokeMethod(clusterMethod, this.redisProperties);
+                method = ReflectionUtils.findMethod(clusterObject.getClass(), "getNodes");
+                List<String> nodesObject = (List) ReflectionUtils.invokeMethod(method, clusterObject);
+                String[] nodes = this.convert(nodesObject);
+                config = new Config();
+                ((ClusterServersConfig)config.useClusterServers().addNodeAddress(nodes).setConnectTimeout(timeout)).setPassword(this.redisProperties.getPassword());
+            } else {
+                config = new Config();
+                String prefix = "redis://";
+                method = ReflectionUtils.findMethod(RedisProperties.class, "isSsl");
+                if (method != null && (Boolean) ReflectionUtils.invokeMethod(method, this.redisProperties)) {
+                    prefix = "rediss://";
+                }
+
+                ((SingleServerConfig)config.useSingleServer().setAddress(prefix + this.redisProperties.getHost() + ":" + this.redisProperties.getPort()).setConnectTimeout(timeout)).setDatabase(this.redisProperties.getDatabase()).setPassword(this.redisProperties.getPassword());
+            }
+        }
+
+        if (this.redissonAutoConfigurationCustomizers != null) {
+            Iterator var19 = this.redissonAutoConfigurationCustomizers.iterator();
+
+            while(var19.hasNext()) {
+                RedissonAutoConfigurationCustomizer customizer = (RedissonAutoConfigurationCustomizer)var19.next();
+                customizer.customize(config);
+            }
+        }
+
+        return Redisson.create(config);
+    }
+
+    private String[] convert(List<String> nodesObject) {
+        List<String> nodes = new ArrayList(nodesObject.size());
+        Iterator var3 = nodesObject.iterator();
+
+        while(true) {
+            while(var3.hasNext()) {
+                String node = (String)var3.next();
+                if (!node.startsWith("redis://") && !node.startsWith("rediss://")) {
+                    nodes.add("redis://" + node);
+                } else {
+                    nodes.add(node);
+                }
+            }
+
+            return (String[])nodes.toArray(new String[nodes.size()]);
+        }
+    }
+
+    private InputStream getConfigStream() throws IOException {
+        Resource resource = this.ctx.getResource(this.redissonProperties.getFile());
+        InputStream is = resource.getInputStream();
+        return is;
+    }
+}

+ 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)

+ 43 - 49
coffee-system/src/main/java/com/coffee/bus/controller/BusClinicController.java

@@ -17,7 +17,6 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 
 /**
@@ -64,54 +63,49 @@ public class BusClinicController {
         }
         //填充临床信息
         result.setClinic(ClinicAnalClinicRecord.parse(clinic));
-        CompletableFuture
-                .runAsync(()->{
-                    //填充评价记录
-                    result.setEvaluations(evaluationService.list(new QueryWrapper<BusEvaluationEntity>().lambda().eq(BusEvaluationEntity::getClinicId,clinicId).orderByAsc(BusEvaluationEntity::getEvaluateTime)));
-                })
-                .thenAcceptAsync(ignore->{
-                    //填充输注记录
-                    List<BusInfusionHistoryEntity> infusionHistories = infusionHistoryService.list(new QueryWrapper<BusInfusionHistoryEntity>().lambda()
-                            .eq(BusInfusionHistoryEntity::getClinicId, clinicId)
-                            .orderByAsc(BusInfusionHistoryEntity::getStartTime));
-
-                    //添加设备别名
-                    Map<String, List<BusInfusionHistoryEntity>> infusionByDeviceId = infusionHistories.stream().collect(Collectors.groupingBy(BusInfusionHistoryEntity::getDeviceId));
-                    infusionByDeviceId.forEach((deviceId,infusions)->{
-                        String alias = deviceRegistry.getOperator(deviceId).getAlias();
-                        infusions.forEach(infusion->infusion.setAlias(alias));
-                    });
-
-                    result.fillUndoInfo(infusionHistories);
-
-
-                    List<String> infusionIds = infusionHistories.stream().map(BusInfusionHistoryEntity::getId).collect(Collectors.toList());
-                    List<BusInfusionModifyEntity> infusionModifies = infusionModifyService.list(new QueryWrapper<BusInfusionModifyEntity>().lambda()
-                            .in(BusInfusionModifyEntity::getInfusionId, infusionIds));
-                    result.fillInfusionRecords(infusionHistories,infusionModifies);
-                })
-                .thenAccept(ignore->{
-                    List<String> infusionIds = result.getInfusionRecords().stream().map(ClinicAnalInfusionRecord::getId).collect(Collectors.toList());
-                    List<BusDeviceHistoryEntity> deviceHistories = deviceHistoryService.list(new QueryWrapper<BusDeviceHistoryEntity>()
-                            .lambda()
-                            .select(BusDeviceHistoryEntity::getInfusionId,BusDeviceHistoryEntity::getPcaValidCount,BusDeviceHistoryEntity::getInfusionModifyId,
-                                    BusDeviceHistoryEntity::getPcaInvalidCount,BusDeviceHistoryEntity::getInputDose,BusDeviceHistoryEntity::getUploadTime)
-                            .in(BusDeviceHistoryEntity::getInfusionId, infusionIds)
-                            .eq(BusDeviceHistoryEntity::getMaster, true));
-                    //标记输注
-                    result.markInfusion(deviceHistories);
-                    List<ClinicStatsQueryResult> statsQueryResults = deviceHistories.stream().map(history -> {
-                        ClinicStatsQueryResult statsQueryResult = new ClinicStatsQueryResult();
-                        statsQueryResult.setInputDose(history.getInputDose());
-                        statsQueryResult.setInValidCount(history.getPcaInvalidCount());
-                        statsQueryResult.setValidCount(history.getPcaValidCount());
-                        statsQueryResult.setUploadTime(history.getUploadTime());
-                        return statsQueryResult;
-                    }).collect(Collectors.toList());
-                    //填充统计信息
-                    result.setStats(ClinicStatsReturnResult.of(statsQueryResults));
-                })
-                .join();
+
+        //填充评价记录
+        result.setEvaluations(evaluationService.list(new QueryWrapper<BusEvaluationEntity>().lambda().eq(BusEvaluationEntity::getClinicId,clinicId).orderByAsc(BusEvaluationEntity::getEvaluateTime)));
+
+
+        //填充输注记录
+        List<BusInfusionHistoryEntity> infusionHistories = infusionHistoryService.list(new QueryWrapper<BusInfusionHistoryEntity>().lambda()
+                .eq(BusInfusionHistoryEntity::getClinicId, clinicId)
+                .orderByAsc(BusInfusionHistoryEntity::getStartTime));
+
+        //添加设备别名
+        Map<String, List<BusInfusionHistoryEntity>> infusionByDeviceId = infusionHistories.stream().collect(Collectors.groupingBy(BusInfusionHistoryEntity::getDeviceId));
+        infusionByDeviceId.forEach((deviceId,infusions)->{
+            String alias = deviceRegistry.getOperator(deviceId).getAlias();
+            infusions.forEach(infusion->infusion.setAlias(alias));
+        });
+
+        result.fillUndoInfo(infusionHistories);
+
+        List<String> infusionIds = infusionHistories.stream().map(BusInfusionHistoryEntity::getId).collect(Collectors.toList());
+        List<BusInfusionModifyEntity> infusionModifies = infusionModifyService.list(new QueryWrapper<BusInfusionModifyEntity>().lambda()
+                .in(BusInfusionModifyEntity::getInfusionId, infusionIds));
+        result.fillInfusionRecords(infusionHistories,infusionModifies);
+
+        List<BusDeviceHistoryEntity> deviceHistories = deviceHistoryService.list(new QueryWrapper<BusDeviceHistoryEntity>()
+                .lambda()
+                .select(BusDeviceHistoryEntity::getInfusionId,BusDeviceHistoryEntity::getPcaValidCount,BusDeviceHistoryEntity::getInfusionModifyId,
+                        BusDeviceHistoryEntity::getPcaInvalidCount,BusDeviceHistoryEntity::getInputDose,BusDeviceHistoryEntity::getUploadTime)
+                .in(BusDeviceHistoryEntity::getInfusionId, infusionIds)
+                .eq(BusDeviceHistoryEntity::getMaster, true));
+        //标记输注
+        result.markInfusion(deviceHistories);
+        List<ClinicStatsQueryResult> statsQueryResults = deviceHistories.stream().map(history -> {
+            ClinicStatsQueryResult statsQueryResult = new ClinicStatsQueryResult();
+            statsQueryResult.setInputDose(history.getInputDose());
+            statsQueryResult.setInValidCount(history.getPcaInvalidCount());
+            statsQueryResult.setValidCount(history.getPcaValidCount());
+            statsQueryResult.setUploadTime(history.getUploadTime());
+            return statsQueryResult;
+        }).collect(Collectors.toList());
+        //填充统计信息
+        result.setStats(ClinicStatsReturnResult.of(statsQueryResults));
+
 
 
         return R.success(result);

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

@@ -58,7 +58,7 @@ public class BusDeviceManualController {
 
     @PostMapping("/no_page")
     @SaCheckPermission("device:manual:query")
-    @ApiOperation(value = "查询其他监控输注列表,不分页",notes = "新增病人信息,权限【device:manual:query】")
+    @ApiOperation(value = "查询其他监控输注列表,不分页",notes = "查询其他监控输注列表,权限【device:manual:query】")
     public R<List<ManualMonitorResult>> list(@RequestBody ManualMonitorQuery query){
         return R.success(deviceManualService.selectMonitor(query));
     }

+ 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();
-    }
-
 
     /**
      * 权限控制前缀

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

@@ -24,7 +24,6 @@ import com.coffee.common.crud.BaseService;
 import com.coffee.common.crud.controller.BaseQueryController;
 import com.coffee.common.exception.CustomException;
 import com.coffee.common.result.R;
-import com.coffee.common.result.ResultCode;
 import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
 import org.springframework.web.bind.annotation.*;

+ 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;
-    }
+
 }

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

@@ -1,6 +1,7 @@
 package com.coffee.bus.entity;
 
 import com.coffee.bus.enums.DeviceAlarmEnum;
+import com.coffee.bus.enums.DeviceStatusEnum;
 import com.coffee.bus.enums.DeviceTypeEnum;
 import com.coffee.common.enums.SexEnum;
 import io.swagger.annotations.ApiModel;
@@ -40,7 +41,7 @@ public class PatientDeviceRepeatDomain {
     @ApiModelProperty("设备别名")
     private String deviceAlias;
     @ApiModelProperty("设备运行状态")
-    private DeviceTypeEnum deviceRunState;
+    private DeviceStatusEnum deviceRunState;
     @ApiModelProperty("设备报警信息")
     private DeviceAlarmEnum deviceAlarm;
     @ApiModelProperty("输注开始时间")

+ 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

+ 0 - 2
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceHistoryService.java

@@ -1,10 +1,8 @@
 package com.coffee.bus.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.coffee.bus.entity.BusDeviceAlarmEntity;
 import com.coffee.bus.entity.BusDeviceHistoryEntity;
 import com.coffee.bus.mapper.BusDeviceHistoryMapper;
-import com.coffee.bus.service.dto.AlarmQuery;
 import com.coffee.bus.service.dto.DeviceHistoryQuery;
 import com.coffee.common.crud.BaseService;
 import org.springframework.stereotype.Service;

+ 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);

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

@@ -10,6 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.hibernate.validator.constraints.Length;
 
+import java.io.Serializable;
 import java.util.List;
 
 /**
@@ -21,7 +22,7 @@ import java.util.List;
  */
 @ApiModel("访视记录单中返回的临床数据")
 @Data
-public class ClinicAnalClinicRecord {
+public class ClinicAnalClinicRecord  implements Serializable {
     private String id;
 
     private String patientCode;

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

@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.io.Serializable;
 import java.util.Date;
 
 /**
@@ -17,7 +18,7 @@ import java.util.Date;
  */
 @Data
 @ApiModel("临床管理接口")
-public class ClinicResult {
+public class ClinicResult  implements Serializable {
     @ApiModelProperty("临床id")
     private String clinicId;
 

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

@@ -9,6 +9,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.io.Serializable;
 import java.util.Date;
 
 /**
@@ -20,7 +21,7 @@ import java.util.Date;
  */
 @Data
 @ApiModel("设备查询结果")
-public class DeviceResult {
+public class DeviceResult  implements Serializable {
     private String id;
     @ApiModelProperty(value = "设备唯一id")
     private String deviceId;

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

@@ -10,6 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.hibernate.validator.constraints.Length;
 
+import java.io.Serializable;
 import java.util.Date;
 import java.util.List;
 
@@ -22,7 +23,7 @@ import java.util.List;
  */
 @Data
 @ApiModel("其他监护查询返回结果")
-public class ManualMonitorResult {
+public class ManualMonitorResult  implements Serializable {
     @ApiModelProperty(value = "临床手术id")
     private String clinicId;
 

+ 3 - 1
coffee-system/src/main/java/com/coffee/bus/service/dto/MonitorStatusStatsCountResult.java

@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.io.Serializable;
+
 /**
  * @author lifang
  * @version 1.0.0
@@ -13,7 +15,7 @@ import lombok.Data;
  */
 @ApiModel("监控状态数量统计结果")
 @Data
-public class MonitorStatusStatsCountResult {
+public class MonitorStatusStatsCountResult  implements Serializable {
 
     @ApiModelProperty("运行数量")
     private int runningCount;

+ 3 - 1
coffee-system/src/main/java/com/coffee/bus/service/dto/MonitorTimeStatsCountResult.java

@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.io.Serializable;
+
 /**
  * @author lifang
  * @version 1.0.0
@@ -13,7 +15,7 @@ import lombok.Data;
  */
 @ApiModel("监控数量按照时间统计结果")
 @Data
-public class MonitorTimeStatsCountResult {
+public class MonitorTimeStatsCountResult  implements Serializable {
 
     @ApiModelProperty("当天")
     private int today;

+ 5 - 3
coffee-system/src/main/java/com/coffee/bus/service/dto/PatientDeviceNoneResult.java

@@ -7,6 +7,8 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.io.Serializable;
+
 /**
  * @author lifang
  * @version 1.0.0
@@ -16,7 +18,7 @@ import lombok.Data;
  */
 @Data
 @ApiModel("病人无设备返回数据")
-public class PatientDeviceNoneResult {
+public class PatientDeviceNoneResult  implements Serializable {
     @ApiModelProperty("病患名称")
     private String name;
 
@@ -56,8 +58,8 @@ public class PatientDeviceNoneResult {
     @ApiModelProperty("手术医生")
     private String surgeryDoctor;
 
-    @ApiModelProperty("手术名称")
-    private String surgeryName;
+    @ApiModelProperty("asa")
+    private String asa;
 
     @ApiModelProperty("配方")
     private String formula;

+ 5 - 3
coffee-system/src/main/java/com/coffee/bus/service/dto/PatientDeviceRepeatResult.java

@@ -1,6 +1,7 @@
 package com.coffee.bus.service.dto;
 
 import com.coffee.bus.enums.DeviceAlarmEnum;
+import com.coffee.bus.enums.DeviceStatusEnum;
 import com.coffee.bus.enums.DeviceTypeEnum;
 import com.coffee.common.enums.SexEnum;
 import io.swagger.annotations.ApiModel;
@@ -9,6 +10,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 
+import java.io.Serializable;
 import java.util.*;
 
 /**
@@ -21,7 +23,7 @@ import java.util.*;
 @Data
 @ApiModel("病人重复设备返回数据")
 @AllArgsConstructor(staticName = "of")
-public class PatientDeviceRepeatResult {
+public class PatientDeviceRepeatResult  implements Serializable {
     @ApiModelProperty("病患名称")
     private String name;
 
@@ -52,7 +54,7 @@ public class PatientDeviceRepeatResult {
     @ApiModel("设备运行小数据集合")
     @Data
     @AllArgsConstructor(staticName = "of")
-    public static class DeviceRunningSmallInfo{
+    public static class DeviceRunningSmallInfo  implements Serializable {
         @ApiModelProperty("设备运行Id")
         private String deviceRunningId;
         @ApiModelProperty("设备名称")
@@ -60,7 +62,7 @@ public class PatientDeviceRepeatResult {
         @ApiModelProperty("设备别名")
         private String deviceAlias;
         @ApiModelProperty("设备运行状态")
-        private DeviceTypeEnum deviceRunState;
+        private DeviceStatusEnum deviceRunState;
         @ApiModelProperty("设备报警信息")
         private DeviceAlarmEnum deviceAlarm;
         @ApiModelProperty("输注开始时间")

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

@@ -11,6 +11,7 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import javax.validation.constraints.NotNull;
+import java.io.Serializable;
 
 /**
  * @author lifang
@@ -23,7 +24,7 @@ import javax.validation.constraints.NotNull;
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
-public class PatientMonitorDetailResult {
+public class PatientMonitorDetailResult  implements Serializable {
     @ApiModelProperty("最后输注信息")
     private BusInfusionHistoryEntity infusion;
     @ApiModelProperty("手术信息")

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

@@ -10,6 +10,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.io.Serializable;
 import java.sql.Timestamp;
 import java.util.*;
 /**
@@ -21,7 +22,7 @@ import java.util.*;
  */
 @Data
 @ApiModel("病人监控查询参数")
-public class PatientMonitorQuery {
+public class PatientMonitorQuery  implements Serializable {
     @ApiModelProperty("模糊查询,床号、姓名、住院号,WEB端专用字段,安卓端请看下方")
     private String blurry;
 

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

@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.Date;
 
@@ -20,7 +21,7 @@ import java.util.Date;
  */
 @ApiModel("病人监控实体")
 @Data
-public class PatientMonitorResult {
+public class PatientMonitorResult implements Serializable {
     @ApiModelProperty(value = "病号")
     private String patientCode;
 

+ 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;
+
+}

+ 23 - 67
coffee-system/src/main/java/com/coffee/bus/utils/WsPublishUtils.java

@@ -1,7 +1,9 @@
 package com.coffee.bus.utils;
 
 
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONObject;
+import com.alibaba.fastjson.serializer.JSONObjectCodec;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.coffee.bus.entity.BusClinicEntity;
 import com.coffee.bus.entity.BusPatientEntity;
@@ -10,9 +12,18 @@ import com.coffee.bus.service.LocalBusClinicService;
 import com.coffee.bus.service.LocalBusPatientService;
 import com.coffee.bus.service.dto.MonitorStatusStatsCountResult;
 import com.coffee.bus.service.dto.PatientMonitorResult;
+import com.coffee.common.config.websocket.TopicMessage;
 import com.coffee.common.config.websocket.WebSocketConstant;
+import com.coffee.common.redis.RedisUtils;
+import com.coffee.common.util.RedissonUtil;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.redisson.RedissonTopic;
+import org.redisson.api.RedissonClient;
+import org.redisson.codec.JsonJacksonCodec;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
@@ -30,13 +41,13 @@ import java.io.Serializable;
 @Component
 @AllArgsConstructor
 @Slf4j
-public class WsPublishUtils {
-    private final RedisTemplate redisTemplate;
+public class WsPublishUtils implements Serializable{
     private final LocalBusPatientService patientService;
     private final LocalBusClinicService clinicService;
+    private final RedissonUtil redissonUtil;
 
     private void publish(String topic,TopicMessage msg){
-        redisTemplate.convertAndSend(topic,msg);
+        redissonUtil.getTopic(topic).publish(msg);
     }
 
     /**
@@ -52,16 +63,7 @@ public class WsPublishUtils {
         Assert.hasText(tenantId,"医院id不能为空");
         PatientMonitorResult message = patientService.lookMonitorByPatientCode(patientCode, tenantId);
         this.publish(WebSocketConstant.getPatientMonitor(null, patientCode, tenantId).getTopic(),
-                new TopicMessage<PatientMonitorResult>() {
-                    @Override
-                    public PatientMonitorResult getMessage() {
-                        return message;
-                    }
-                    @Override
-                    public String getParam() {
-                        return patientCode;
-                    }
-                }
+                TopicMessage.of(message,patientCode)
         );
     }
 
@@ -76,16 +78,9 @@ public class WsPublishUtils {
     public void publishMonitorStateCount(String tenantId){
         Assert.hasText(tenantId,"医院id不能为空");
         MonitorStatusStatsCountResult message = patientService.statusStats(tenantId);
-        this.publish(WebSocketConstant.getMonitorStateCount(tenantId).getTopic(),  new TopicMessage<MonitorStatusStatsCountResult>() {
-            @Override
-            public MonitorStatusStatsCountResult getMessage() {
-                return message;
-            }
-            @Override
-            public String getParam() {
-                return tenantId;
-            }
-        });
+        this.publish(WebSocketConstant.getMonitorStateCount(tenantId).getTopic(),
+                TopicMessage.of(message,tenantId)
+        );
     }
 
     /**
@@ -100,16 +95,7 @@ public class WsPublishUtils {
         Assert.hasText(tenantId,"医院id不能为空");
         JSONObject message = new JSONObject().putOpt("patientCode", patientCode);
         this.publish(WebSocketConstant.getPatientAdd(tenantId).getTopic(),
-                new TopicMessage<JSONObject>() {
-                    @Override
-                    public JSONObject getMessage() {
-                        return message;
-                    }
-                    @Override
-                    public String getParam() {
-                        return tenantId;
-                    }
-                });
+                TopicMessage.of(message,tenantId));
     }
     /**
      * 描述: 推送医院临床设备重复数量统计
@@ -124,16 +110,7 @@ public class WsPublishUtils {
         JSONObject message = new JSONObject().putOpt("count", patientService.count(new QueryWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getTenantId, tenantId)
                 .eq(BusPatientEntity::getAlarm, PatientAlarmEnum.DEVICE_REPEAT)));
         this.publish(WebSocketConstant.getDeviceRepeat(tenantId).getTopic(),
-                new TopicMessage<JSONObject>() {
-                    @Override
-                    public JSONObject getMessage() {
-                        return message;
-                    }
-                    @Override
-                    public String getParam() {
-                        return tenantId;
-                    }
-                }
+                TopicMessage.of(message,tenantId)
         );
     }
 
@@ -151,16 +128,7 @@ public class WsPublishUtils {
                 .lambda().eq(BusPatientEntity::getTenantId, tenantId)
                 .eq(BusPatientEntity::getAlarm, PatientAlarmEnum.DEVICE_NONE)));
         this.publish(WebSocketConstant.getDeviceNone(tenantId).getTopic(),
-                new TopicMessage<JSONObject>() {
-                    @Override
-                    public JSONObject getMessage() {
-                        return message;
-                    }
-                    @Override
-                    public String getParam() {
-                        return tenantId;
-                    }
-                }
+                TopicMessage.of(message,tenantId)
         );
     }
 
@@ -180,21 +148,9 @@ public class WsPublishUtils {
                 .eq(BusClinicEntity::getTenantId,tenantId)
                 .eq(BusClinicEntity::getFinished,false)));
         this.publish(WebSocketConstant.getMonitorTotalCount(tenantId).getTopic(),
-                new TopicMessage<JSONObject>() {
-                    @Override
-                    public JSONObject getMessage() {
-                        return message;
-                    }
-                    @Override
-                    public String getParam() {
-                        return tenantId;
-                    }
-                }
+                TopicMessage.of(message,tenantId)
         );
     }
 
-    public interface TopicMessage<T> extends Serializable {
-        T getMessage();
-        String getParam();
-    }
+
 }

+ 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;

+ 4 - 7
coffee-system/src/main/java/com/coffee/bus/websocket/WebSocketCloseHandler.java

@@ -1,14 +1,11 @@
 package com.coffee.bus.websocket;
 
-import com.coffee.common.config.websocket.MessagingRequest;
+import com.coffee.common.config.websocket.DefaultMessageListener;
 import com.coffee.common.config.websocket.handler.Subscribe;
-import com.coffee.common.config.websocket.handler.WsHandler;
 import org.springframework.stereotype.Component;
 import org.tio.core.ChannelContext;
 
-import java.util.HashSet;
-import java.util.Optional;
-import java.util.Set;
+import java.util.Map;
 
 /**
  * @author lifang
@@ -27,8 +24,8 @@ public class WebSocketCloseHandler extends Subscribe {
     @Override
     public void close(ChannelContext channelContext) {
         //关闭则取消订阅
-        Set<String> topicByChannel = getTopicByChannel(channelContext);
-        topicByChannel.forEach(topic->this.unsubscribe(channelContext,topic));
+        Map<String, DefaultMessageListener> topicListeners = getTopicListeners(channelContext);
+        topicListeners.forEach((topic,listener)->this.unsubscribe(channelContext,topic));
     }
 
     @Override

+ 43 - 18
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();
@@ -476,21 +476,46 @@ public class DeviceInfoListener {
             String lastAlarmSign = deviceOperator.getAlarm();
             BusDeviceAlarmEntity alarm = BusDeviceAlarmEntity.parseHistory(history);
             String alarmSign = alarm.signParm(sign);
-            if(StrUtil.isBlank(lastAlarmSign)||!alarmSign.equals(lastAlarmSign)){
-                alarmService.save(alarm);
-                cacheOperation.add(()->{
-                    //todo 发布报警信息 产生新的报警或提醒信息
-                    deviceOperator.setAlarm(alarmSign);
-                    return null;
-                });
 
+            if(StrUtil.isBlank(lastAlarmSign)||!alarmSign.equals(lastAlarmSign)){
+                //报警及提示发生变化,判断具体变化是由报警引起还是由提示引起
+                BusDeviceRunningEntity lastRunning = deviceRunningService.getOne(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getDeviceId, history.getDeviceId()));
+                int change=5;
+                //防止重复插入
+                if(ObjectUtil.equal(lastRunning.getAlarm(),history.getAlarm())){
+                    alarm.setAlarm(false);
+                    alarm.setAlarmState(null);
+                    --change;
+                }
+                if (ObjectUtil.equal(lastRunning.getWarnAnalgesicPoor(), history.getWarnAnalgesicPoor())) {
+                    alarm.setWarnAnalgesicPoor(false);
+                    --change;
+                }
+                if (ObjectUtil.equal(lastRunning.getWarnFlow(), history.getWarnFlow())) {
+                    alarm.setWarnFlow(null);
+                    --change;
+                }
+                if (ObjectUtil.equal(lastRunning.getWarnLowBattery(), history.getWarnLowBattery())) {
+                    alarm.setWarnLowBattery(false);
+                    --change;
+                }
+                if (ObjectUtil.equal(lastRunning.getWarnWillFinished(), history.getWarnWillFinished())) {
+                    alarm.setWarnWillFinished(false);
+                    --change;
+                }
+                if(change!=0){
+                    alarmService.save(alarm);
+                    cacheOperation.add(()->{
+                        deviceOperator.setAlarm(alarmSign);
+                        return null;
+                    });
+                }
             }
         }else {
             cacheOperation.add(()->{
                 deviceOperator.setAlarm(null);
                 return null;
             });
-            return;
         }
     }
 }

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

@@ -89,7 +89,7 @@
         <result column="ana_type" property="anaType"/>
         <result column="anal_type" property="analType"/>
         <result column="surgery_doctor" property="surgeryDoctor"/>
-        <result column="surgery_name" property="surgeryName"/>
+        <result column="asa" property="asa"/>
         <result column="formula" property="formula"/>
         <result column="finished" property="finished"/>
         <result column="config_person" property="configPerson"/>
@@ -130,7 +130,7 @@
          c.ana_type as ana_type,
          c.anal_type as anal_type,
          c.surgery_doctor as surgery_doctor,
-         c.surgery_name as surgery_name,
+         c.asa as asa,
          c.formula as formula,
          c.finished as finished,
          c.config_person as config_person

+ 15 - 0
pom.xml

@@ -37,6 +37,7 @@
         <tio.version>3.6.0.v20200315-RELEASE</tio.version>
         <jython.version>2.7.1</jython.version>
         <knife4j.version>2.0.7</knife4j.version>
+        <redisson.version>3.13.6</redisson.version>
     </properties>
 
     <modules>
@@ -209,6 +210,20 @@
                 <artifactId>coffee-oss</artifactId>
                 <version>${coffee.project.version}</version>
             </dependency>
+
+            <!-- redisson配置 -->
+            <dependency>
+                <groupId>org.redisson</groupId>
+                <artifactId>redisson-spring-boot-starter</artifactId>
+                <version>${redisson.version}</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.springframework.boot</groupId>
+                        <artifactId>spring-boot-starter-web</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>
+
         </dependencies>
     </dependencyManagement>