Ver código fonte

update 缓存方式

A17404李放 3 anos atrás
pai
commit
8e3338b6e3

+ 43 - 18
nb-system/src/main/java/com/coffee/bus/registry/device/ClusterDeviceOperator.java

@@ -14,7 +14,6 @@ import com.coffee.common.util.RedissonUtil;
 import org.redisson.api.RMapCache;
 import java.math.BigDecimal;
 import java.util.Date;
-import java.util.concurrent.TimeUnit;
 
 /**
  * @author lifang
@@ -109,12 +108,12 @@ public class ClusterDeviceOperator implements DeviceOperator {
         Value value = getValue(DeviceKeyConstant.START_TIME);
         if(value==null){
             BusInfusionHistoryEntity lastInfusion = getLastInfusion();
-            if(lastInfusion!=null){
-                value=Value.simple(lastInfusion.getStartTime());
-                setStartTime(lastInfusion.getStartTime());
+            if(lastInfusion==null){
+                value=Value.simple(null);
             }else {
-                return null;
+                value=Value.simple(lastInfusion.getStartTime());
             }
+            setStartTime(lastInfusion==null?null:lastInfusion.getStartTime());
 
         }
         return value.asDate();
@@ -130,8 +129,12 @@ public class ClusterDeviceOperator implements DeviceOperator {
         Value value = getValue(DeviceKeyConstant.PATIENT_CODE);
         if(value==null){
             BusInfusionHistoryEntity lastInfusion = getLastInfusion();
-            value=Value.simple(lastInfusion.getPatientCode());
-            setPatientCode(lastInfusion.getPatientCode());
+            if(lastInfusion==null){
+                value=Value.simple(null);
+            }else {
+                value=Value.simple(lastInfusion.getPatientCode());
+            }
+            setPatientCode(lastInfusion==null?null:lastInfusion.getPatientCode());
         }
         return value.asString();
     }
@@ -146,9 +149,15 @@ public class ClusterDeviceOperator implements DeviceOperator {
         Value value = getValue(DeviceKeyConstant.ALARM);
         if(value==null){
             BusInfusionHistoryEntity lastInfusion = getLastInfusion();
-            String signParm = BusDeviceAlarmEntity.parseRunning(lastInfusion).signParm();
-            value=Value.simple(signParm);
-            setAlarmOrWarn(signParm);
+            if(lastInfusion==null){
+                value=Value.simple(null);
+                setAlarmOrWarn(null);
+            }else {
+                String signParm = BusDeviceAlarmEntity.parseRunning(lastInfusion).signParm();
+                value=Value.simple(signParm);
+                setAlarmOrWarn(signParm);
+            }
+
         }
         return value.asString();
     }
@@ -202,8 +211,12 @@ public class ClusterDeviceOperator implements DeviceOperator {
         Value value = getValue(DeviceKeyConstant.CLASSIFY);
         if(value==null){
             BusInfusionHistoryEntity lastInfusion = getLastInfusion();
-            value=Value.simple(lastInfusion.getClassification());
-            setClassification(lastInfusion.getClassification());
+            if(lastInfusion==null){
+                value=Value.simple(null);
+            }else {
+                value=Value.simple(lastInfusion.getClassification());
+            }
+            setClassification(lastInfusion==null?null:lastInfusion.getClassification());
         }
         return value.asString();
     }
@@ -214,8 +227,12 @@ public class ClusterDeviceOperator implements DeviceOperator {
         Value value = getValue(DeviceKeyConstant.CONTINUE_DOSE);
         if(value==null){
             BusInfusionHistoryEntity lastInfusion = getLastInfusion();
-            value=Value.simple(lastInfusion.getContinueDose());
-            setContinueDose(lastInfusion.getContinueDose());
+            if(lastInfusion==null){
+                value=Value.simple(null);
+            }else {
+                value=Value.simple(lastInfusion.getContinueDose());
+            }
+            setContinueDose(lastInfusion==null?null:lastInfusion.getContinueDose());
         }
         return value.as(BigDecimal.class);
 
@@ -236,8 +253,12 @@ public class ClusterDeviceOperator implements DeviceOperator {
         Value value = getValue(DeviceKeyConstant.VALID_PCA);
         if(value==null){
             BusInfusionHistoryEntity lastInfusion = getLastInfusion();
-            value=Value.simple(lastInfusion.getPcaValidCount());
-            setLastPcaValidCount(lastInfusion.getPcaValidCount());
+            if(lastInfusion==null){
+                value=Value.simple(null);
+            }else {
+                value=Value.simple(lastInfusion.getPcaValidCount());
+            }
+            setLastPcaValidCount(lastInfusion==null?null:lastInfusion.getPcaValidCount());
         }
         return value.asInt();
     }
@@ -252,8 +273,12 @@ public class ClusterDeviceOperator implements DeviceOperator {
         Value value = getValue(DeviceKeyConstant.APPEND_DOSE);
         if(value==null){
             BusInfusionHistoryEntity lastInfusion = getLastInfusion();
-            value=Value.simple(lastInfusion.getTotalAppendDose());
-            setTotalAppendDose(lastInfusion.getTotalAppendDose());
+            if(lastInfusion==null){
+                value=Value.simple(null);
+            }else {
+                value=Value.simple(lastInfusion.getTotalAppendDose());
+            }
+            setTotalAppendDose(lastInfusion==null?null:lastInfusion.getTotalAppendDose());
         }
         return value.as(BigDecimal.class);
     }

+ 2 - 3
nb-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java

@@ -68,6 +68,7 @@ public class DeviceInfoListener {
     private final LocalBusDeviceService deviceService;
 
     private final Executor executor;
+
     private final HospitalManagerRegister hospitalManagerRegister;
 
     /**
@@ -370,9 +371,7 @@ public class DeviceInfoListener {
         }
 
         cacheOperation.add(()->{
-            if(device.isNewInfusion()){
-                deviceOperator.setLastPcaValidCount(Optional.ofNullable(device.getPcaValidCount()).orElse(0));
-            }
+            deviceOperator.setLastPcaValidCount(Optional.ofNullable(device.getPcaValidCount()).orElse(0));
             deviceOperator.setTotalAppendDose(Optional.ofNullable(device.getTotalAppendDose()).orElse(BigDecimal.ZERO));
             return null;
         });