A17404李放 3 лет назад
Родитель
Сommit
e7ab883ec5
19 измененных файлов с 226 добавлено и 61 удалено
  1. 3 2
      coffee-common/src/main/java/com/coffee/common/config/websocket/handler/Subscribe.java
  2. 3 0
      coffee-system/src/main/java/com/coffee/aliyun/AliyunIotSubscribeClient.java
  3. 11 4
      coffee-system/src/main/java/com/coffee/bus/controller/BusAlarmController.java
  4. 4 4
      coffee-system/src/main/java/com/coffee/bus/controller/BusPatientController.java
  5. 94 19
      coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceAlarmEntity.java
  6. 0 1
      coffee-system/src/main/java/com/coffee/bus/entity/BusInfusionHistoryEntity.java
  7. 6 0
      coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceAlarmMapper.java
  8. 4 3
      coffee-system/src/main/java/com/coffee/bus/registry/device/ClusterDeviceOperator.java
  9. 4 1
      coffee-system/src/main/java/com/coffee/bus/registry/device/ClusterDeviceRegistry.java
  10. 2 2
      coffee-system/src/main/java/com/coffee/bus/registry/device/DeviceOperator.java
  11. 6 0
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceAlarmService.java
  12. 14 0
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceRunningService.java
  13. 30 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/AlarmQuery.java
  14. 11 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/ClinicAnalInfusionRecord.java
  15. 1 1
      coffee-system/src/main/java/com/coffee/bus/service/dto/ClinicStatsReturnResult.java
  16. 0 2
      coffee-system/src/main/java/com/coffee/bus/service/dto/PatientMonitorDetailResult.java
  17. 18 21
      coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java
  18. 1 1
      coffee-system/src/main/resources/mapper/bus/BusClinicMapper.xml
  19. 14 0
      coffee-system/src/main/resources/mapper/bus/BusDeviceAlarmMapper.xml

+ 3 - 2
coffee-common/src/main/java/com/coffee/common/config/websocket/handler/Subscribe.java

@@ -83,7 +83,8 @@ public abstract class Subscribe implements WsHandler {
             subScribeTopic =
             subScribeTopic =
                     params.stream().map(param -> getTopic(message.getProductName(), param, loginUser.getTenantId()))
                     params.stream().map(param -> getTopic(message.getProductName(), param, loginUser.getTenantId()))
                             .collect(Collectors.toList());
                             .collect(Collectors.toList());
-        }else {
+        }
+        else {
             subScribeTopic = Collections.singletonList(getTopic(message.getProductName(), null, loginUser.getTenantId()));
             subScribeTopic = Collections.singletonList(getTopic(message.getProductName(), null, loginUser.getTenantId()));
         }
         }
 
 
@@ -96,7 +97,7 @@ public abstract class Subscribe implements WsHandler {
 //            subScribeTopic.forEach(topicWrapper->this.subscribe(channelContext,topicWrapper));
 //            subScribeTopic.forEach(topicWrapper->this.subscribe(channelContext,topicWrapper));
         }else {
         }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()));
         log.error("订阅成功{}",subScribeTopic.stream().map(TopicWrapper::getTopic).collect(Collectors.toList()));
 
 

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

@@ -9,6 +9,7 @@ import org.apache.qpid.jms.JmsConnectionListener;
 import org.apache.qpid.jms.message.JmsInboundMessageDispatch;
 import org.apache.qpid.jms.message.JmsInboundMessageDispatch;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
 import javax.crypto.Mac;
 import javax.crypto.Mac;
@@ -85,6 +86,8 @@ public class AliyunIotSubscribeClient {
 
 
     @Getter
     @Getter
     private List<Connection> connections = null;
     private List<Connection> connections = null;
+
+    @Async
     public void start(MessageListener messageListener) throws Exception {
     public void start(MessageListener messageListener) throws Exception {
         // 先关闭一下
         // 先关闭一下
         close();
         close();

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

@@ -2,19 +2,19 @@ package com.coffee.bus.controller;
 
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import com.baomidou.mybatisplus.core.mapper.Mapper;
 import com.baomidou.mybatisplus.core.mapper.Mapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.coffee.bus.service.dto.AlarmQuery;
+import com.coffee.bus.entity.BusClinicEntity;
 import com.coffee.bus.entity.BusDeviceAlarmEntity;
 import com.coffee.bus.entity.BusDeviceAlarmEntity;
-import com.coffee.bus.enums.DeviceTypeEnum;
 import com.coffee.bus.service.LocalBusDeviceAlarmService;
 import com.coffee.bus.service.LocalBusDeviceAlarmService;
 import com.coffee.common.crud.BaseService;
 import com.coffee.common.crud.BaseService;
 import com.coffee.common.crud.controller.BaseCrudController;
 import com.coffee.common.crud.controller.BaseCrudController;
 import com.coffee.common.result.R;
 import com.coffee.common.result.R;
 import io.swagger.annotations.*;
 import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
-import org.springframework.util.ReflectionUtils;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
-import java.lang.reflect.Field;
-
 /**
 /**
  * @author lifang
  * @author lifang
  * @version 1.0.0
  * @version 1.0.0
@@ -42,6 +42,13 @@ public class BusAlarmController extends BaseCrudController<BusDeviceAlarmEntity,
         return R.success();
         return R.success();
     }
     }
 
 
+
+    @PostMapping("/query/page")
+    @SaCheckPermission("bus:alarm:query")
+    @ApiOperation(value = "分页查询",notes = "权限:【bus:alarm:query】")
+    public R<IPage<BusDeviceAlarmEntity>> page(@RequestBody@Validated AlarmQuery query){
+        return R.success(deviceAlarmService.page(query));
+    }
     @Override
     @Override
     public BaseService<? extends Mapper<BusDeviceAlarmEntity>, BusDeviceAlarmEntity, String> getService() {
     public BaseService<? extends Mapper<BusDeviceAlarmEntity>, BusDeviceAlarmEntity, String> getService() {
         return deviceAlarmService;
         return deviceAlarmService;

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

@@ -92,18 +92,18 @@ public class BusPatientController  implements BaseQueryController<BusPatientEnti
             @ApiResponse(code = 500,message = "没有选择病号"),
             @ApiResponse(code = 500,message = "没有选择病号"),
             @ApiResponse(code =200 ,message = "若存在不可以结束的临床信息,将会把该临床的主泵信息返回",response = BusDeviceRunningEntity.class)
             @ApiResponse(code =200 ,message = "若存在不可以结束的临床信息,将会把该临床的主泵信息返回",response = BusDeviceRunningEntity.class)
     })
     })
-    public R<List<BusDeviceRunningEntity>> judgeFinished(@RequestBody List<String> patientCodes){
+    public R<Boolean> judgeFinished(@RequestBody List<String> patientCodes){
         if(CollectionUtil.isEmpty(patientCodes)){
         if(CollectionUtil.isEmpty(patientCodes)){
             throw new CustomException("请选择一个病患");
             throw new CustomException("请选择一个病患");
         }
         }
 
 
-        return R.success(deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>()
+        return R.success(CollectionUtil.isNotEmpty(deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>()
                 .lambda()
                 .lambda()
                 .select(BusDeviceRunningEntity::getDeviceId,BusDeviceRunningEntity::getPatientCode,BusDeviceRunningEntity::getRunState,BusDeviceRunningEntity::getAlarm)
                 .select(BusDeviceRunningEntity::getDeviceId,BusDeviceRunningEntity::getPatientCode,BusDeviceRunningEntity::getRunState,BusDeviceRunningEntity::getAlarm)
                 .eq(BusDeviceRunningEntity::getMaster,true)
                 .eq(BusDeviceRunningEntity::getMaster,true)
                 .eq(BusDeviceRunningEntity::getMonitorType,true)
                 .eq(BusDeviceRunningEntity::getMonitorType,true)
                 .ne(BusDeviceRunningEntity::getRunState, DeviceStatusEnum.Shutdown)
                 .ne(BusDeviceRunningEntity::getRunState, DeviceStatusEnum.Shutdown)
-                .in(BusDeviceRunningEntity::getPatientCode,patientCodes)));
+                .in(BusDeviceRunningEntity::getPatientCode,patientCodes))));
     }
     }
 
 
     @PostMapping("/do/{monitorType}/finished")
     @PostMapping("/do/{monitorType}/finished")
@@ -243,7 +243,7 @@ public class BusPatientController  implements BaseQueryController<BusPatientEnti
             BusPatientEntity patient = patientService.getOne(new QueryWrapper<BusPatientEntity>().lambda()
             BusPatientEntity patient = patientService.getOne(new QueryWrapper<BusPatientEntity>().lambda()
                     .eq(BusPatientEntity::getCode, patientCode).last("limit 1"));
                     .eq(BusPatientEntity::getCode, patientCode).last("limit 1"));
             BusInfusionHistoryEntity infusion = infusionService.getById(patient.getInfusionId());
             BusInfusionHistoryEntity infusion = infusionService.getById(patient.getInfusionId());
-            result.setPatient(patient);
+            infusion.setAlias(deviceRunningService.getAliasName(infusion.getDeviceId()));
             result.setInfusion(infusion);
             result.setInfusion(infusion);
             BusDeviceRunningEntity deviceRunning = deviceRunningService.getOne(new QueryWrapper<BusDeviceRunningEntity>()
             BusDeviceRunningEntity deviceRunning = deviceRunningService.getOne(new QueryWrapper<BusDeviceRunningEntity>()
                     .lambda()
                     .lambda()

+ 94 - 19
coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceAlarmEntity.java

@@ -1,11 +1,19 @@
 package com.coffee.bus.entity;
 package com.coffee.bus.entity;
 
 
+import cn.hutool.crypto.asymmetric.Sign;
+import cn.hutool.json.JSONObject;
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.coffee.bus.entity.common.CommonDeviceParam;
 import com.coffee.bus.enums.DeviceAlarmEnum;
 import com.coffee.bus.enums.DeviceAlarmEnum;
+import com.coffee.bus.enums.DeviceStatusEnum;
+import com.coffee.bus.enums.FlowStatusEnum;
 import com.coffee.common.entity.TenantGenericEntity;
 import com.coffee.common.entity.TenantGenericEntity;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
+import jdk.nashorn.internal.ir.EmptyNode;
 import lombok.Data;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.EqualsAndHashCode;
 import lombok.ToString;
 import lombok.ToString;
@@ -28,23 +36,15 @@ public class BusDeviceAlarmEntity extends TenantGenericEntity<String,String> {
     @ApiModelProperty(value = "设备唯一编码",readOnly = true)
     @ApiModelProperty(value = "设备唯一编码",readOnly = true)
     private String deviceId;
     private String deviceId;
 
 
-    @ApiModelProperty(value = "报警信息")
-    private DeviceAlarmEnum alarm;
-
     @ApiModelProperty(value = "报警时间")
     @ApiModelProperty(value = "报警时间")
-    private Date alarmTime;
-
+    private Date uploadTime;
 
 
     @ApiModelProperty(value = "报警原因")
     @ApiModelProperty(value = "报警原因")
     private String cause;
     private String cause;
 
 
-    @ApiModelProperty(value = "报警是否正在进行",hidden = true)
-    @JsonIgnoreProperties(allowSetters = true)
-    private Boolean doing;
-
-
-    @ApiModelProperty(value = "是否已处理 0、未处理,1、已处理,暂未使用")
-    private Boolean dealing;
+    @ApiModelProperty(value = "是否为报警信息",hidden = true)
+    @JsonIgnoreProperties
+    private Boolean alarm;
 
 
     @ApiModelProperty(value = "报警记录所绑定的历史记录id,后续用于更新操作",hidden = true)
     @ApiModelProperty(value = "报警记录所绑定的历史记录id,后续用于更新操作",hidden = true)
     @JsonIgnoreProperties(allowSetters = true)
     @JsonIgnoreProperties(allowSetters = true)
@@ -53,20 +53,95 @@ public class BusDeviceAlarmEntity extends TenantGenericEntity<String,String> {
     @ApiModelProperty(value = "输注记录")
     @ApiModelProperty(value = "输注记录")
     private String infusionId;
     private String infusionId;
 
 
+    @ApiModelProperty(value = "泵运行状态",readOnly = true)
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
+    private DeviceStatusEnum runState;
 
 
-    @ApiModelProperty(value = "设备标识",readOnly = true,hidden = true)
-    @JsonIgnoreProperties(allowSetters = true)
-    private String classification;
+    @ApiModelProperty(value = "报警信息",readOnly = true)
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
+    private DeviceAlarmEnum alarmState;
+
+    @ApiModelProperty(value = "输注即将结束提醒",readOnly = true)
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
+    private Boolean warnWillFinished;
+
+    @ApiModelProperty(value = "镇痛不足提醒",readOnly = true)
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
+    private Boolean warnAnalgesicPoor;
+
+    @ApiModelProperty(value = "电量偏低提醒",readOnly = true)
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
+    private Boolean warnLowBattery;
 
 
-    public static BusDeviceAlarmEntity parseRunningInfo(BusDeviceHistoryEntity history){
+    @ApiModelProperty(value = "加减档提示",readOnly = true)
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
+    private FlowStatusEnum warnFlow;
+
+    public static BusDeviceAlarmEntity parseHistory(BusDeviceHistoryEntity history){
         BusDeviceAlarmEntity entity = new BusDeviceAlarmEntity();
         BusDeviceAlarmEntity entity = new BusDeviceAlarmEntity();
         entity.setDeviceId(history.getDeviceId());
         entity.setDeviceId(history.getDeviceId());
-        entity.setAlarm(history.getAlarm());
-        entity.setAlarmTime(history.getUploadTime());
+        entity.setUploadTime(history.getUploadTime());
+        if (history.getAlarm() != null && !DeviceAlarmEnum.None.equals(history.getAlarm())) {
+            entity.setAlarm(true);
+        }
         entity.setHistoryId(history.getId());
         entity.setHistoryId(history.getId());
         entity.setInfusionId(history.getInfusionId());
         entity.setInfusionId(history.getInfusionId());
-        entity.setClassification(history.getClassification());
+        entity.setRunState(history.getRunState());
+        entity.setAlarmState(history.getAlarm());
+        entity.setWarnWillFinished(history.getWarnWillFinished());
+        entity.setWarnAnalgesicPoor(history.getWarnAnalgesicPoor());
+        entity.setWarnLowBattery(history.getWarnLowBattery());
+        entity.setWarnFlow(history.getWarnFlow());
         entity.setTenantId(history.getTenantId());
         entity.setTenantId(history.getTenantId());
         return entity;
         return entity;
     }
     }
+
+    public static BusDeviceAlarmEntity parseRunning(BusDeviceRunningEntity source){
+        BusDeviceAlarmEntity entity = new BusDeviceAlarmEntity();
+        entity.setDeviceId(source.getDeviceId());
+        entity.setUploadTime(source.getUploadTime());
+        if (source.getAlarm() != null && !DeviceAlarmEnum.None.equals(source.getAlarm())) {
+            entity.setAlarm(true);
+        }
+        entity.setHistoryId(source.getId());
+        entity.setInfusionId(source.getInfusionId());
+        entity.setRunState(source.getRunState());
+        entity.setAlarmState(source.getAlarm());
+        entity.setWarnWillFinished(source.getWarnWillFinished());
+        entity.setWarnAnalgesicPoor(source.getWarnAnalgesicPoor());
+        entity.setWarnLowBattery(source.getWarnLowBattery());
+        entity.setWarnFlow(source.getWarnFlow());
+        entity.setTenantId(source.getTenantId());
+        return entity;
+    }
+
+    public String signParm(Sign sign){
+        JSONObject param = new JSONObject(true);
+        param.putOpt("runState",String.valueOf(this.getRunState()));
+        param.putOpt("alarmState",String.valueOf(this.getAlarmState()));
+        param.putOpt("warnWillFinished",String.valueOf(this.getWarnWillFinished()));
+        param.putOpt("warnAnalgesicPoor",String.valueOf(this.getWarnAnalgesicPoor()));
+        param.putOpt("warnLowBattery",String.valueOf(this.getWarnLowBattery()));
+        param.putOpt("warnFlow",String.valueOf(this.getWarnFlow()));
+        return sign.signHex(param.toString());
+    }
+
+    public static boolean alarmOrWarn(CommonDeviceParam history){
+        if (history.getAlarm() != null && !DeviceAlarmEnum.None.equals(history.getAlarm())) {
+            return true;
+        }
+        if (Boolean.TRUE.equals(history.getWarnAnalgesicPoor())) {
+            return true;
+        }
+        if (Boolean.TRUE.equals(history.getWarnLowBattery())) {
+            return true;
+        }
+        if (Boolean.TRUE.equals(history.getWarnWillFinished())) {
+            return true;
+        }
+        if (history.getWarnFlow()!=null) {
+            return true;
+        }
+        return false;
+    }
 }
 }

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

@@ -167,7 +167,6 @@ public class BusInfusionHistoryEntity extends CommonDeviceParam<String,String> {
         this.setRunState(DeviceRunStatusUtils.getRunStatus(items.getInteger(PumpParams.runStatus)));
         this.setRunState(DeviceRunStatusUtils.getRunStatus(items.getInteger(PumpParams.runStatus)));
         this.setAlarm(DeviceAlarmUtils.getAlarm(items.getInteger(PumpParams.alarmStatus)));
         this.setAlarm(DeviceAlarmUtils.getAlarm(items.getInteger(PumpParams.alarmStatus)));
         // 预报
         // 预报
-
     }
     }
 
 
 }
 }

+ 6 - 0
coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceAlarmMapper.java

@@ -1,8 +1,13 @@
 package com.coffee.bus.mapper;
 package com.coffee.bus.mapper;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.coffee.bus.entity.BusClinicEntity;
 import com.coffee.bus.entity.BusDeviceAlarmEntity;
 import com.coffee.bus.entity.BusDeviceAlarmEntity;
+import com.coffee.bus.service.dto.AlarmQuery;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 
 /**
 /**
  * @author lifang
  * @author lifang
@@ -14,4 +19,5 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 @Mapper
 public interface BusDeviceAlarmMapper extends BaseMapper<BusDeviceAlarmEntity> {
 public interface BusDeviceAlarmMapper extends BaseMapper<BusDeviceAlarmEntity> {
 
 
+    IPage<BusDeviceAlarmEntity> pageQuery(Page<BusDeviceAlarmEntity> page, @Param("query") AlarmQuery query);
 }
 }

+ 4 - 3
coffee-system/src/main/java/com/coffee/bus/registry/device/ClusterDeviceOperator.java

@@ -8,6 +8,7 @@ import com.coffee.bus.registry.device.bean.DeviceCacheInfo;
 import com.coffee.common.cache.ConfigStorage;
 import com.coffee.common.cache.ConfigStorage;
 import com.coffee.common.cache.value.Value;
 import com.coffee.common.cache.value.Value;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
+import org.python.antlr.ast.Str;
 
 
 import java.util.Date;
 import java.util.Date;
 import java.util.*;
 import java.util.*;
@@ -124,13 +125,13 @@ public class ClusterDeviceOperator implements DeviceOperator<DeviceCacheInfo> {
     }
     }
 
 
     @Override
     @Override
-    public void setAlarm(DeviceAlarmEnum alarm) {
+    public void setAlarm(String alarm) {
         configStorage.setConfig(DeviceKeyConstant.ALARM,alarm);
         configStorage.setConfig(DeviceKeyConstant.ALARM,alarm);
     }
     }
 
 
     @Override
     @Override
-    public DeviceAlarmEnum getAlarm() {
-        return getValue(DeviceKeyConstant.ALARM).as(DeviceAlarmEnum.class);
+    public String getAlarm() {
+        return getValue(DeviceKeyConstant.ALARM).asString();
     }
     }
 
 
     @Override
     @Override

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

@@ -3,6 +3,7 @@ package com.coffee.bus.registry.device;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.coffee.bus.entity.BusDeviceAlarmEntity;
 import com.coffee.bus.entity.BusDeviceEntity;
 import com.coffee.bus.entity.BusDeviceEntity;
 import com.coffee.bus.entity.BusDeviceRunningEntity;
 import com.coffee.bus.entity.BusDeviceRunningEntity;
 import com.coffee.bus.entity.BusInfusionModifyEntity;
 import com.coffee.bus.entity.BusInfusionModifyEntity;
@@ -56,7 +57,6 @@ public class ClusterDeviceRegistry implements DeviceRegistry {
                 //设备运行信息
                 //设备运行信息
                 deviceOperator.setUsingId(runningInfo.getId());
                 deviceOperator.setUsingId(runningInfo.getId());
                 deviceOperator.setClassification(runningInfo.getClassification());
                 deviceOperator.setClassification(runningInfo.getClassification());
-                deviceOperator.setAlarm(runningInfo.getAlarm());
                 deviceOperator.setAlias(runningInfo.getAlias());
                 deviceOperator.setAlias(runningInfo.getAlias());
                 deviceOperator.setUndo(runningInfo.getIsUndo());
                 deviceOperator.setUndo(runningInfo.getIsUndo());
                 if(StrUtil.isNotEmpty(runningInfo.getInfusionId())){
                 if(StrUtil.isNotEmpty(runningInfo.getInfusionId())){
@@ -66,6 +66,9 @@ public class ClusterDeviceRegistry implements DeviceRegistry {
                         deviceOperator.setInfusionParam(infusionModify.signParam(DeviceInfoListener.sign));
                         deviceOperator.setInfusionParam(infusionModify.signParam(DeviceInfoListener.sign));
                     }
                     }
                 }
                 }
+                if (BusDeviceAlarmEntity.alarmOrWarn(runningInfo)) {
+                    deviceOperator.setAlarm(BusDeviceAlarmEntity.parseRunning(runningInfo).signParm(DeviceInfoListener.sign));
+                }
                 deviceOperator.setMaster(runningInfo.getMaster());
                 deviceOperator.setMaster(runningInfo.getMaster());
                 deviceOperator.setStartTime(runningInfo.getStartTime());
                 deviceOperator.setStartTime(runningInfo.getStartTime());
                 deviceOperator.setStatus(runningInfo.getRunState());
                 deviceOperator.setStatus(runningInfo.getRunState());

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

@@ -142,13 +142,13 @@ public interface DeviceOperator<T> extends Operator<T> {
      * 设置当前设备报警信息
      * 设置当前设备报警信息
      * @param alarm
      * @param alarm
      */
      */
-    void setAlarm(DeviceAlarmEnum alarm);
+    void setAlarm(String alarm);
 
 
     /**
     /**
      * 获取当前设备报警信息
      * 获取当前设备报警信息
      * @return
      * @return
      */
      */
-    DeviceAlarmEnum getAlarm();
+    String getAlarm();
 
 
     /**
     /**
      * 设置当前设备输注参数
      * 设置当前设备输注参数

+ 6 - 0
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceAlarmService.java

@@ -2,8 +2,11 @@ package com.coffee.bus.service;
 
 
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.coffee.bus.entity.BusClinicEntity;
 import com.coffee.bus.entity.BusDeviceAlarmEntity;
 import com.coffee.bus.entity.BusDeviceAlarmEntity;
 import com.coffee.bus.mapper.BusDeviceAlarmMapper;
 import com.coffee.bus.mapper.BusDeviceAlarmMapper;
+import com.coffee.bus.service.dto.AlarmQuery;
 import com.coffee.common.crud.BaseService;
 import com.coffee.common.crud.BaseService;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -34,6 +37,9 @@ public class LocalBusDeviceAlarmService extends BaseService<BusDeviceAlarmMapper
 
 
     }
     }
 
 
+    public IPage<BusDeviceAlarmEntity> page(AlarmQuery query){
+        return this.baseMapper.pageQuery(query.getPage(),query);
+    }
     /**
     /**
      * 添加报警原因
      * 添加报警原因
      * @param id
      * @param id

+ 14 - 0
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceRunningService.java

@@ -1,6 +1,7 @@
 package com.coffee.bus.service;
 package com.coffee.bus.service;
 
 
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.entity.BusPatientEntity;
@@ -70,6 +71,19 @@ public class LocalBusDeviceRunningService extends BaseService<BusDeviceRunningMa
 
 
     }
     }
 
 
+    /**
+     * 描述: 获取设备别名
+     * @author lifang
+     * @date 2022/5/16 17:32
+     * @param deviceId
+     * @return String
+     */
+    public String getAliasName(String deviceId){
+        if(StrUtil.isBlank(deviceId)){
+            return null;
+        }
+        return deviceRegistry.getOperator(deviceId).getAlias();
+    }
     /**
     /**
      * 批量撤泵
      * 批量撤泵
      * @param undoConfigs 批量撤泵配置
      * @param undoConfigs 批量撤泵配置

+ 30 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/AlarmQuery.java

@@ -0,0 +1,30 @@
+package com.coffee.bus.service.dto;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.coffee.bus.entity.BusDeviceAlarmEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName AlarmQuery.java
+ * @Description TODO
+ * @createTime 2022年05月16日 21:28:00
+ */
+@Data
+@ApiModel("报警信息查询参数")
+public class AlarmQuery {
+    @ApiModelProperty("临床id")
+    @NotNull(message = "临床id不能为空")
+    private String clinicId;
+    @ApiModelProperty("设备id")
+    @NotNull(message = "设备id不能为空")
+    private String deviceId;
+    @ApiModelProperty("分页参数")
+    @NotNull(message = "分页参数不能为空")
+    private Page<BusDeviceAlarmEntity> page;
+}

+ 11 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/ClinicAnalInfusionRecord.java

@@ -1,8 +1,10 @@
 package com.coffee.bus.service.dto;
 package com.coffee.bus.service.dto;
 
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.coffee.bus.entity.BusInfusionHistoryEntity;
 import com.coffee.bus.entity.BusInfusionHistoryEntity;
 import com.coffee.bus.entity.common.DeviceProperties;
 import com.coffee.bus.entity.common.DeviceProperties;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
@@ -21,9 +23,18 @@ public class ClinicAnalInfusionRecord extends DeviceProperties<String,String> {
     @ApiModelProperty("参数修改记录")
     @ApiModelProperty("参数修改记录")
     private List<ClinicAnalInfusionModify> modifies;
     private List<ClinicAnalInfusionModify> modifies;
 
 
+    @ApiModelProperty("泵别名")
+    private String alias;
+
     @ApiModelProperty("是否打印")
     @ApiModelProperty("是否打印")
     private boolean print;
     private boolean print;
 
 
+    @ApiModelProperty(value = "当前输注记录数据最后上传时间",readOnly = true,hidden = true)
+    private Date lastUploadTime;
+
+    @ApiModelProperty(value = "输注开始时间,即本次运行开机时间",readOnly = true)
+    private Date startTime;
+
     public static ClinicAnalInfusionRecord parse(BusInfusionHistoryEntity source){
     public static ClinicAnalInfusionRecord parse(BusInfusionHistoryEntity source){
         ClinicAnalInfusionRecord result = new ClinicAnalInfusionRecord();
         ClinicAnalInfusionRecord result = new ClinicAnalInfusionRecord();
         BeanUtil.copyProperties(source,result);
         BeanUtil.copyProperties(source,result);

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

@@ -51,7 +51,7 @@ public class ClinicStatsReturnResult implements Serializable {
             appendDoses.add(queryResult.getAppendDose()!=null?queryResult.getAppendDose():BigDecimal.ZERO);
             appendDoses.add(queryResult.getAppendDose()!=null?queryResult.getAppendDose():BigDecimal.ZERO);
             inputDoses.add( queryResult.getInputDose()!=null?queryResult.getInputDose():BigDecimal.ZERO);
             inputDoses.add( queryResult.getInputDose()!=null?queryResult.getInputDose():BigDecimal.ZERO);
             validCounts.add(queryResult.getValidCount()!=null?queryResult.getValidCount():0);
             validCounts.add(queryResult.getValidCount()!=null?queryResult.getValidCount():0);
-            validCounts.add(queryResult.getInValidCount()!=null?queryResult.getInValidCount():0);
+            inValidCounts.add(queryResult.getInValidCount()!=null?queryResult.getInValidCount():0);
             uploadTimes.add(uploadTime);
             uploadTimes.add(uploadTime);
 
 
             result.setContinueDose(continueDoses);
             result.setContinueDose(continueDoses);

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

@@ -24,8 +24,6 @@ import javax.validation.constraints.NotNull;
 @AllArgsConstructor
 @AllArgsConstructor
 @NoArgsConstructor
 @NoArgsConstructor
 public class PatientMonitorDetailResult {
 public class PatientMonitorDetailResult {
-    @ApiModelProperty("病人信息")
-    private BusPatientEntity patient;
     @ApiModelProperty("最后输注信息")
     @ApiModelProperty("最后输注信息")
     private BusInfusionHistoryEntity infusion;
     private BusInfusionHistoryEntity infusion;
     @ApiModelProperty("手术信息")
     @ApiModelProperty("手术信息")

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

@@ -13,7 +13,6 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.coffee.bus.entity.*;
 import com.coffee.bus.entity.*;
-import com.coffee.bus.enums.DeviceAlarmEnum;
 import com.coffee.bus.enums.PatientAlarmEnum;
 import com.coffee.bus.enums.PatientAlarmEnum;
 import com.coffee.bus.registry.device.DeviceRegistry;
 import com.coffee.bus.registry.device.DeviceRegistry;
 import com.coffee.bus.listener.event.bean.DeviceInfoEvent;
 import com.coffee.bus.listener.event.bean.DeviceInfoEvent;
@@ -25,7 +24,6 @@ import com.coffee.bus.registry.patient.bean.DeviceTimeSmallInfo;
 import com.coffee.bus.registry.patient.bean.PatientCacheInfo;
 import com.coffee.bus.registry.patient.bean.PatientCacheInfo;
 import com.coffee.bus.service.*;
 import com.coffee.bus.service.*;
 import com.coffee.bus.utils.WsPublishUtils;
 import com.coffee.bus.utils.WsPublishUtils;
-import com.coffee.common.config.websocket.WebSocketConstant;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.context.event.EventListener;
 import org.springframework.context.event.EventListener;
@@ -33,7 +31,6 @@ import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 import java.util.*;
 import java.util.*;
 import java.util.List;
 import java.util.List;
-import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.function.Supplier;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
@@ -117,8 +114,8 @@ public class DeviceInfoListener {
             handleInfusion(device, deviceOperator, newInfusion, cacheOperation);
             handleInfusion(device, deviceOperator, newInfusion, cacheOperation);
             //处理历史运行数据
             //处理历史运行数据
             BusDeviceHistoryEntity history=handleRunningHistory(device);
             BusDeviceHistoryEntity history=handleRunningHistory(device);
-            //处理报警信息
-            handleAlarm(history,deviceOperator,cacheOperation);
+            //处理报警、提醒信息
+            handleAlarmOrWarn(history,deviceOperator,cacheOperation);
             //todo 流速图处理
             //todo 流速图处理
             if(first){
             if(first){
                 deviceService.update(new UpdateWrapper<BusDeviceEntity>().lambda().eq(BusDeviceEntity::getDeviceId,deviceId).set(BusDeviceEntity::getType,device.getType()));
                 deviceService.update(new UpdateWrapper<BusDeviceEntity>().lambda().eq(BusDeviceEntity::getDeviceId,deviceId).set(BusDeviceEntity::getType,device.getType()));
@@ -473,27 +470,27 @@ public class DeviceInfoListener {
      * @param history 设备当前数据的历史数据
      * @param history 设备当前数据的历史数据
      * @param deviceOperator 设备操作符
      * @param deviceOperator 设备操作符
      */
      */
-    private void handleAlarm(BusDeviceHistoryEntity history,DeviceOperator deviceOperator,List<Supplier<?>> cacheOperation){
-        //不存在报警信息
-        if(history.getAlarm()==null||history.getAlarm().equals(DeviceAlarmEnum.None)){
+    private void handleAlarmOrWarn(BusDeviceHistoryEntity history, DeviceOperator deviceOperator, List<Supplier<?>> cacheOperation){
+        if (BusDeviceAlarmEntity.alarmOrWarn(history)) {
+            //获取上一状态下的报警信息
+            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;
+                });
+
+            }
+        }else {
             cacheOperation.add(()->{
             cacheOperation.add(()->{
                 deviceOperator.setAlarm(null);
                 deviceOperator.setAlarm(null);
                 return null;
                 return null;
             });
             });
             return;
             return;
         }
         }
-        //获取上一状态下的报警信息
-        DeviceAlarmEnum originAlarm = deviceOperator.getAlarm();
-        DeviceAlarmEnum alarm = history.getAlarm();
-        //产生新的报警信息或报警信息发生变化
-        if(originAlarm==null||originAlarm!=alarm){
-            BusDeviceAlarmEntity deviceAlarm = BusDeviceAlarmEntity.parseRunningInfo(history);
-            alarmService.save(deviceAlarm);
-            cacheOperation.add(()->{
-                //todo 发布报警信息
-                deviceOperator.setAlarm(alarm);
-                return null;
-            });
-        }
     }
     }
 }
 }

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

@@ -65,7 +65,7 @@
         left JOIN (select * from bus_device_history
         left JOIN (select * from bus_device_history
         <where>
         <where>
             <if test="query.infusionModifyIds != null and query.infusionModifyIds.size > 0">
             <if test="query.infusionModifyIds != null and query.infusionModifyIds.size > 0">
-                and infusionModifyIds in
+                and infusion_modify_id in
                 <foreach item="infusionModifyId" index="index" collection="query.infusionModifyIds" open="(" separator="," close=")">
                 <foreach item="infusionModifyId" index="index" collection="query.infusionModifyIds" open="(" separator="," close=")">
                     #{infusionModifyId, jdbcType=VARCHAR}
                     #{infusionModifyId, jdbcType=VARCHAR}
                 </foreach>
                 </foreach>

+ 14 - 0
coffee-system/src/main/resources/mapper/bus/BusDeviceAlarmMapper.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.coffee.bus.mapper.BusDeviceAlarmMapper">
+
+
+    <select id="pageQuery" parameterType="com.coffee.bus.service.dto.AlarmQuery" resultType="com.coffee.bus.entity.BusDeviceAlarmEntity">
+        select a.* from
+        bus_device_alarm as a
+        join (select * from bus_infusion_history where clinic_id=#{query.clinicId} and device_id=#{query.deviceId}) as h
+        on a.infusion_id=h.id
+    </select>
+
+
+</mapper>