ソースを参照

add 实时推送
update 输注监护适配安卓端

A17404李放 3 年 前
コミット
bbfad5f6bd

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

@@ -52,7 +52,7 @@ public class BusPatientController  {
     @PostMapping("/no_page")
     @SaCheckPermission("bus:patient:query")
     @ApiOperation(value = "输注监控列表",notes = "病人监控管理列表,权限【bus:patient:query】")
-    public R<List<PatientMonitorDomain>> selectPage(@RequestBody PatientMonitorQuery query){
+    public R<List<PatientMonitorResult>> selectPage(@RequestBody PatientMonitorQuery query){
         return R.success(patientService.selectAll(query));
     }
 
@@ -192,8 +192,8 @@ public class BusPatientController  {
     @GetMapping("/monitor/{monitorType}/{patientCode}")
     @SaCheckPermission("device:patient:query")
     @ApiOperation(value = "查看病人当前监控详情",notes = "查看病人当前监控详情,权限标识为【device:patient:query】")
-    public R<PatientMonitorResult> monitor(@PathVariable("monitorType")@ApiParam(value = "是否为有泵监控",example = "0、无泵,1、有泵") Boolean haveDevice,@PathVariable("patientCode")@ApiParam(value = "病号") String patientCode){
-        PatientMonitorResult result = new PatientMonitorResult();
+    public R<PatientMonitorDetailResult> monitor(@PathVariable("monitorType")@ApiParam(value = "是否为有泵监控",example = "0、无泵,1、有泵") Boolean haveDevice, @PathVariable("patientCode")@ApiParam(value = "病号") String patientCode){
+        PatientMonitorDetailResult result = new PatientMonitorDetailResult();
         if(haveDevice){
             BusPatientEntity patient = patientService.getOne(new QueryWrapper<BusPatientEntity>().lambda()
                     .eq(BusPatientEntity::getCode, patientCode).last("limit 1"));

+ 0 - 230
coffee-system/src/main/java/com/coffee/bus/entity/PatientMonitorDomain.java

@@ -1,230 +0,0 @@
-package com.coffee.bus.entity;
-
-import cn.hutool.core.util.StrUtil;
-import com.coffee.bus.enums.*;
-import com.coffee.common.enums.SexEnum;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * @author lifang
- * @version 1.0.0
- * @ClassName PatientMonitorDomain.java
- * @Description TODO
- * @createTime 2022年04月21日 15:57:00
- */
-@ApiModel("病人监控实体")
-@Data
-public class PatientMonitorDomain {
-    @ApiModelProperty(value = "病号")
-    private String patientCode;
-
-    @ApiModelProperty(value = "病人名称")
-    private String patientName;
-
-    @ApiModelProperty(value = "性别")
-    private SexEnum gender;
-
-    @ApiModelProperty(value = "病人报警信息",example = "泵重复,无泵")
-    private PatientAlarmEnum patientAlarm;
-
-    @ApiModelProperty(value = "设备id")
-    private String deviceId;
-
-    @ApiModelProperty(value = "泵别名")
-    private String deviceAlias;
-
-    @ApiModelProperty(value = "临床号")
-    private String clinicId;
-
-    @ApiModelProperty(value = "病区")
-    private String ward;
-
-    @ApiModelProperty(value = "床号")
-    private String bedNo;
-
-    @ApiModelProperty(value = "总量")
-    private Integer totalDose;
-
-    @ApiModelProperty(value = "公共参数-首次量")
-    private Integer firstDose;
-
-    @ApiModelProperty(value = "公共参数-电量",readOnly = true)
-    private Integer electricQuantity;
-
-    @ApiModelProperty(value = "公共参数-剩余量")
-    private BigDecimal remainDose;
-
-    @ApiModelProperty(value = "公共参数-已输入量")
-    private BigDecimal inputDose;
-
-    @ApiModelProperty(value = "公共参数-追加量")
-    private BigDecimal appendDose;
-
-    @ApiModelProperty(value = "公共参数-追加锁时")
-    private BigDecimal appendLockTime;
-
-    @ApiModelProperty(value = "公共参数-极限量")
-    private BigDecimal maxDose;
-
-    @ApiModelProperty(value = "公共参数-自控锁时")
-    private BigDecimal selfControlLockTime;
-
-    @ApiModelProperty(value = "公共参数-自控次数")
-    private BigDecimal selfControlCount;
-
-    @ApiModelProperty(value = "公共参数-pca有效次数")
-    private Integer pcaValidCount;
-
-    @ApiModelProperty(value = "公共参数-pca无效次数")
-    private Integer pcaInvalidCount;
-
-    @ApiModelProperty(value = "公共参数-pca总按次数")
-    private Integer pcaTotalCount;
-
-    @ApiModelProperty(value = "持续泵参数-持续量")
-    private BigDecimal continueDose;
-
-    @ApiModelProperty(value = "脉冲泵参数-脉冲量")
-    private Integer pulseDose;
-
-    @ApiModelProperty(value = "脉冲泵参数-脉冲锁时")
-    private Integer pulseLockTime;
-
-    @ApiModelProperty(value = "脉冲泵参数-脉冲首次锁时")
-    private Integer pulseFirstLockTime;
-
-    @ApiModelProperty(value = "智能泵参数-加档周期")
-    private BigDecimal flowUpCycle;
-
-    @ApiModelProperty(value = "智能泵参数-减档周期")
-    private BigDecimal flowDownCycle;
-
-    @ApiModelProperty(value = "智能泵参数-计次")
-    private BigDecimal flowCount;
-
-    @ApiModelProperty(value = "智能泵参数-上限")
-    private BigDecimal flowUpLimit;
-
-    @ApiModelProperty(value = "智能泵参数-下限")
-    private BigDecimal flowDownLimit;
-
-    @ApiModelProperty(value = "智能泵参数-自调比例")
-    private BigDecimal flowAdjustRate;
-
-
-    @ApiModelProperty(value = "泵运行状态")
-    private DeviceStatusEnum deviceRunState;
-
-    @ApiModelProperty(value = "报警信息")
-    private DeviceAlarmEnum deviceAlarm;
-
-    @ApiModelProperty(value = "输注开始时间,即本次运行开机时间")
-    private Date infusionStartTime;
-
-    @ApiModelProperty(value = "备注")
-    private String remark;
-
-    @ApiModelProperty(value = "泵类型")
-    private DeviceTypeEnum deviceType;
-
-    @ApiModelProperty(value = "麻醉医生")
-    private String anaDoctor;
-
-    @ApiModelProperty(value = "麻醉方式")
-    private String anaType;
-
-    @ApiModelProperty(value = "镇痛方式")
-    private String analType;
-
-    @ApiModelProperty(value = "手术医生")
-    private String surgeryDoctor;
-
-    @ApiModelProperty(value = "手术名称")
-    private String surgeryName;
-
-    @ApiModelProperty(value = "当前病人是否已结束临床,根据此参数+监护开始时间计算总监护时间",
-            notes = "false:监护时长=当前时间-监护开始时间 ,true:监护时长=监护结束时间-监护开始时间")
-    private Boolean clinicFinished;
-
-    @ApiModelProperty("当前病人监护结束时间")
-    private Date monitorEndTime;
-
-    @ApiModelProperty("当前病人监护开始时间")
-    private Date monitorStartTime;
-
-    @ApiModelProperty(value = "输注即将结束提醒",hidden = true)
-    @JsonIgnore
-    private Boolean warnWillFinished;
-
-    @ApiModelProperty(value = "镇痛不足提醒",hidden = true)
-    @JsonIgnore
-    private Boolean warnAnalgesicPoor;
-
-    @ApiModelProperty(value = "电量偏低提醒",hidden = true)
-    @JsonIgnore
-    private Boolean warnLowBattery;
-
-    @ApiModelProperty(value = "加减档提示",readOnly = true)
-    @JsonIgnore
-    private FlowStatusEnum warnFlow;
-
-    @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();
-    }
-}

+ 1 - 0
coffee-system/src/main/java/com/coffee/bus/enums/DeviceManualEnum.java

@@ -16,6 +16,7 @@ import lombok.Getter;
 @AllArgsConstructor
 @JsonFormat(shape = JsonFormat.Shape.OBJECT)
 public enum DeviceManualEnum implements IEnum<Integer> {
+    none(-1,"无设备"),
     machine(0,"机械泵"),
     electronPulse(1,"电子脉冲泵"),
     electron(2,"电子泵"),

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/mapper/BusPatientMapper.java

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.entity.PatientDeviceRepeatDomain;
-import com.coffee.bus.entity.PatientMonitorDomain;
+import com.coffee.bus.service.dto.PatientMonitorResult;
 import com.coffee.bus.service.dto.PatientDeviceNoneResult;
 import com.coffee.bus.service.dto.PatientMonitorQuery;
 import org.apache.ibatis.annotations.Mapper;
@@ -39,5 +39,5 @@ public interface BusPatientMapper extends BaseMapper<BusPatientEntity> {
      * @param query
      * @return
      */
-    IPage<PatientMonitorDomain> selectMonitor(IPage<PatientMonitorDomain> page,@Param("query") PatientMonitorQuery query);
+    IPage<PatientMonitorResult> selectMonitor(IPage<PatientMonitorResult> page, @Param("query") PatientMonitorQuery query);
 }

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

@@ -3,15 +3,12 @@ package com.coffee.bus.service;
 import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 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.BusPatientEntity;
 import com.coffee.bus.entity.PatientDeviceRepeatDomain;
-import com.coffee.bus.entity.PatientMonitorDomain;
-import com.coffee.bus.mapper.BusClinicMapper;
+import com.coffee.bus.service.dto.PatientMonitorResult;
 import com.coffee.bus.mapper.BusPatientMapper;
 import com.coffee.bus.registry.patient.PatientOperator;
 import com.coffee.bus.registry.patient.PatientRegistry;
@@ -20,11 +17,9 @@ import com.coffee.bus.service.dto.PatientDeviceNoneResult;
 import com.coffee.bus.service.dto.PatientDeviceRepeatResult;
 import com.coffee.bus.service.dto.PatientMonitorQuery;
 import com.coffee.common.crud.BaseService;
-import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
-import org.springframework.data.domain.PageRequest;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -117,11 +112,11 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
         return this.baseMapper.selectNoneDevice();
     }
 
-    public List<PatientMonitorDomain> selectAll(PatientMonitorQuery query) {
-        Page<PatientMonitorDomain> page = new Page<>(0, 500, false);
-        IPage<PatientMonitorDomain> result = this.baseMapper.selectMonitor(page,query);
+    public List<PatientMonitorResult> selectAll(PatientMonitorQuery query) {
+        Page<PatientMonitorResult> page = new Page<>(0, 500, false);
+        IPage<PatientMonitorResult> result = this.baseMapper.selectMonitor(page,query);
         if(CollectionUtil.isNotEmpty(result.getRecords())){
-            result.getRecords().forEach(PatientMonitorDomain::handleWarn);
+            result.getRecords().forEach(PatientMonitorResult::handleWarn);
         }
         return result.getRecords();
     }

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

@@ -21,6 +21,6 @@ public class ManualMonitorQuery {
     /**
      * @see  com.coffee.bus.enums.DeviceManualEnum
      */
-    @ApiModelProperty("设备类型;0、机械泵;1、电子脉冲泵;2、电子泵;3、其他泵")
+    @ApiModelProperty("设备类型;-1、无设备;0、机械泵;1、电子脉冲泵;2、电子泵;3、其他泵")
     private List<Integer> types;
 }

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

@@ -0,0 +1,35 @@
+package com.coffee.bus.service.dto;
+
+import com.coffee.bus.entity.BusClinicEntity;
+import com.coffee.bus.entity.BusDeviceManualEntity;
+import com.coffee.bus.entity.BusInfusionHistoryEntity;
+import com.coffee.bus.entity.BusPatientEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName PatientMonitorDetailResult.java
+ * @Description TODO
+ * @createTime 2022年04月23日 11:39:00
+ */
+@ApiModel("病人监控信息返回结果")
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class PatientMonitorDetailResult {
+    @ApiModelProperty("病人信息")
+    private BusPatientEntity patient;
+    @ApiModelProperty("最后输注信息")
+    private BusInfusionHistoryEntity infusion;
+    @ApiModelProperty("手术信息")
+    private BusClinicEntity clinic;
+    @ApiModelProperty("无泵时查看")
+    private BusDeviceManualEntity deviceManual;
+}

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

@@ -11,6 +11,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.sql.Timestamp;
 import java.util.*;
 /**
  * @author lifang
@@ -22,12 +23,33 @@ import java.util.*;
 @Data
 @ApiModel("病人监控查询参数")
 public class PatientMonitorQuery {
-    @ApiModelProperty("模糊查询,病区、床号、姓名、住院号")
+    @ApiModelProperty("模糊查询,床号、姓名、住院号,WEB端专用字段,安卓端请看下方")
     private String blurry;
 
     @ApiModelProperty("病区查询集合")
     private List<String> wards;
 
+    @ApiModelProperty("WEB端请传输blurry-床号")
+    private String bedNo;
+
+    @ApiModelProperty("WEB端请传输blurry-病人姓名")
+    private String name;
+
+    @ApiModelProperty("WEB端请传输blurry-住院号")
+    private String code;
+
+    @ApiModelProperty("安卓端使用-麻醉医生")
+    private String anaDoctor;
+
+    @ApiModelProperty("安卓端使用-手术名称")
+    private String surgeName;
+
+    @ApiModelProperty("安卓端使用-性别")
+    private Integer gender;
+
+    @ApiModelProperty("安卓端使用-麻醉方式")
+    private String anaType;
+
     /**
      * @see  DeviceTypeEnum #value
      */
@@ -69,8 +91,12 @@ public class PatientMonitorQuery {
     private List<WarnEnum> warns;
 
     @ApiModelProperty("查询时间区间")
-    private List<Date> timeRange;
+    private List<Timestamp> timeRange;
 
+    /**
+     * 将前端的提醒查询做统一封装,做请求处理
+     * @param warns
+     */
     public void setWarns(List<WarnEnum> warns) {
         this.warns = warns;
         if(CollectionUtil.isNotEmpty(warns)){
@@ -88,4 +114,11 @@ public class PatientMonitorQuery {
             });
         }
     }
+
+
+    public void setBlurry(String blurry){
+        this.setBedNo(blurry);
+        this.setName(blurry);
+        this.setCode(blurry);
+    }
 }

+ 216 - 15
coffee-system/src/main/java/com/coffee/bus/service/dto/PatientMonitorResult.java

@@ -1,29 +1,230 @@
 package com.coffee.bus.service.dto;
 
-import com.coffee.bus.entity.BusClinicEntity;
-import com.coffee.bus.entity.BusDeviceManualEntity;
-import com.coffee.bus.entity.BusInfusionHistoryEntity;
-import com.coffee.bus.entity.BusPatientEntity;
+import cn.hutool.core.util.StrUtil;
+import com.coffee.bus.enums.*;
+import com.coffee.common.enums.SexEnum;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.math.BigDecimal;
+import java.util.Date;
+
 /**
  * @author lifang
  * @version 1.0.0
  * @ClassName PatientMonitorResult.java
  * @Description TODO
- * @createTime 2022年04月23日 11:39:00
+ * @createTime 2022年04月21日 15:57:00
  */
-@ApiModel("病人监控信息返回结果")
+@ApiModel("病人监控实体")
 @Data
 public class PatientMonitorResult {
-    @ApiModelProperty("病人信息")
-    private BusPatientEntity patient;
-    @ApiModelProperty("最后输注信息")
-    private BusInfusionHistoryEntity infusion;
-    @ApiModelProperty("手术信息")
-    private BusClinicEntity clinic;
-    @ApiModelProperty("无泵时查看")
-    private BusDeviceManualEntity deviceManual;
-}
+    @ApiModelProperty(value = "病号")
+    private String patientCode;
+
+    @ApiModelProperty(value = "病人名称")
+    private String patientName;
+
+    @ApiModelProperty(value = "性别")
+    private SexEnum gender;
+
+    @ApiModelProperty(value = "病人报警信息",example = "泵重复,无泵")
+    private PatientAlarmEnum patientAlarm;
+
+    @ApiModelProperty(value = "设备id")
+    private String deviceId;
+
+    @ApiModelProperty(value = "泵别名")
+    private String deviceAlias;
+
+    @ApiModelProperty(value = "临床号")
+    private String clinicId;
+
+    @ApiModelProperty(value = "病区")
+    private String ward;
+
+    @ApiModelProperty(value = "床号")
+    private String bedNo;
+
+    @ApiModelProperty(value = "总量")
+    private Integer totalDose;
+
+    @ApiModelProperty(value = "公共参数-首次量")
+    private Integer firstDose;
+
+    @ApiModelProperty(value = "公共参数-电量",readOnly = true)
+    private Integer electricQuantity;
+
+    @ApiModelProperty(value = "公共参数-剩余量")
+    private BigDecimal remainDose;
+
+    @ApiModelProperty(value = "公共参数-已输入量")
+    private BigDecimal inputDose;
+
+    @ApiModelProperty(value = "公共参数-追加量")
+    private BigDecimal appendDose;
+
+    @ApiModelProperty(value = "公共参数-追加锁时")
+    private BigDecimal appendLockTime;
+
+    @ApiModelProperty(value = "公共参数-极限量")
+    private BigDecimal maxDose;
+
+    @ApiModelProperty(value = "公共参数-自控锁时")
+    private BigDecimal selfControlLockTime;
+
+    @ApiModelProperty(value = "公共参数-自控次数")
+    private BigDecimal selfControlCount;
+
+    @ApiModelProperty(value = "公共参数-pca有效次数")
+    private Integer pcaValidCount;
+
+    @ApiModelProperty(value = "公共参数-pca无效次数")
+    private Integer pcaInvalidCount;
+
+    @ApiModelProperty(value = "公共参数-pca总按次数")
+    private Integer pcaTotalCount;
+
+    @ApiModelProperty(value = "持续泵参数-持续量")
+    private BigDecimal continueDose;
+
+    @ApiModelProperty(value = "脉冲泵参数-脉冲量")
+    private Integer pulseDose;
+
+    @ApiModelProperty(value = "脉冲泵参数-脉冲锁时")
+    private Integer pulseLockTime;
+
+    @ApiModelProperty(value = "脉冲泵参数-脉冲首次锁时")
+    private Integer pulseFirstLockTime;
+
+    @ApiModelProperty(value = "智能泵参数-加档周期")
+    private BigDecimal flowUpCycle;
+
+    @ApiModelProperty(value = "智能泵参数-减档周期")
+    private BigDecimal flowDownCycle;
+
+    @ApiModelProperty(value = "智能泵参数-计次")
+    private BigDecimal flowCount;
+
+    @ApiModelProperty(value = "智能泵参数-上限")
+    private BigDecimal flowUpLimit;
+
+    @ApiModelProperty(value = "智能泵参数-下限")
+    private BigDecimal flowDownLimit;
+
+    @ApiModelProperty(value = "智能泵参数-自调比例")
+    private BigDecimal flowAdjustRate;
+
+
+    @ApiModelProperty(value = "泵运行状态")
+    private DeviceStatusEnum deviceRunState;
+
+    @ApiModelProperty(value = "报警信息")
+    private DeviceAlarmEnum deviceAlarm;
+
+    @ApiModelProperty(value = "输注开始时间,即本次运行开机时间")
+    private Date infusionStartTime;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    @ApiModelProperty(value = "泵类型")
+    private DeviceTypeEnum deviceType;
+
+    @ApiModelProperty(value = "麻醉医生")
+    private String anaDoctor;
+
+    @ApiModelProperty(value = "麻醉方式")
+    private String anaType;
+
+    @ApiModelProperty(value = "镇痛方式")
+    private String analType;
+
+    @ApiModelProperty(value = "手术医生")
+    private String surgeryDoctor;
+
+    @ApiModelProperty(value = "手术名称")
+    private String surgeryName;
+
+    @ApiModelProperty(value = "当前病人是否已结束临床,根据此参数+监护开始时间计算总监护时间",
+            notes = "false:监护时长=当前时间-监护开始时间 ,true:监护时长=监护结束时间-监护开始时间")
+    private Boolean clinicFinished;
+
+    @ApiModelProperty("当前病人监护结束时间")
+    private Date monitorEndTime;
+
+    @ApiModelProperty("当前病人监护开始时间")
+    private Date monitorStartTime;
+
+    @ApiModelProperty(value = "输注即将结束提醒",hidden = true)
+    @JsonIgnore
+    private Boolean warnWillFinished;
+
+    @ApiModelProperty(value = "镇痛不足提醒",hidden = true)
+    @JsonIgnore
+    private Boolean warnAnalgesicPoor;
+
+    @ApiModelProperty(value = "电量偏低提醒",hidden = true)
+    @JsonIgnore
+    private Boolean warnLowBattery;
+
+    @ApiModelProperty(value = "加减档提示",readOnly = true)
+    @JsonIgnore
+    private FlowStatusEnum warnFlow;
+
+    @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();
+    }
+}

+ 22 - 0
coffee-system/src/main/java/com/coffee/bus/utils/WsPublishUtils.java

@@ -0,0 +1,22 @@
+package com.coffee.bus.utils;
+
+import cn.hutool.extra.spring.SpringUtil;
+import org.springframework.data.redis.core.RedisTemplate;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName WsPushUtils.java
+ * @Description ws发布消息工具类
+ * @createTime 2022年05月07日 11:34:00
+ */
+public class WsPublishUtils {
+    private static RedisTemplate redisTemplate;
+
+    public static void publish(String topic,Object msg){
+        if(redisTemplate==null){
+            redisTemplate= SpringUtil.getBean(RedisTemplate.class);
+        }
+        redisTemplate.convertAndSend(topic, msg);
+    }
+}

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

@@ -23,6 +23,8 @@ import com.coffee.bus.registry.patient.PatientRegistry;
 import com.coffee.bus.registry.patient.bean.DeviceTimeSmallInfo;
 import com.coffee.bus.registry.patient.bean.PatientCacheInfo;
 import com.coffee.bus.service.*;
+import com.coffee.bus.service.dto.PatientMonitorDetailResult;
+import com.coffee.bus.utils.WsPublishUtils;
 import com.coffee.common.config.websocket.WebSocketConstant;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -111,7 +113,7 @@ public class DeviceInfoListener {
             //处理设备运行数据,     判断是否为注册后第一次开机,判断是否为新的输注信息
             boolean first = handleRunningInfo(device, deviceOperator,newInfusion,cacheOperation);
             //处理输注参数
-            handleInfusion(device,deviceOperator,newInfusion,cacheOperation);
+            BusInfusionHistoryEntity infusionHistory = handleInfusion(device, deviceOperator, newInfusion, cacheOperation);
             //处理历史运行数据
             BusDeviceHistoryEntity history=handleRunningHistory(device);
             //处理报警信息
@@ -131,9 +133,13 @@ public class DeviceInfoListener {
             //医院相关配置处理
             handleHospitalConfig(device,cacheOperation);
 
-            //则推送设备上报消息
-            String topic = WebSocketConstant.getDeviceInfoDetailTopic(null, device.getId(), device.getTenantId());
-            redisTemplate.convertAndSend(topic, device);
+            //则推送设备上报输注消息
+            cacheOperation.add(()->{
+                WsPublishUtils.publish(WebSocketConstant.getPatientMonitor(null, device.getPatientCode(), device.getTenantId()),
+                        new PatientMonitorDetailResult(null,infusionHistory,null,null));
+                return null;
+            });
+
             //所有事务处理完成后更新缓存信息
             cacheOperation.forEach(Supplier::get);
         }
@@ -288,6 +294,9 @@ public class DeviceInfoListener {
                         patientOperator.setAllDevice(remainPatientBindDevices);
                         //更换输注信息后,将最新的输注信息传输实时传输给前端 //todo
 
+                        WsPublishUtils.publish(WebSocketConstant.getPatientMonitor(null,patientCode, hospitalId),
+                                new PatientMonitorDetailResult(null,infusionHistoryService.getById(newMasterId),null,null));
+
                         return null;
                     });
                     if(remainPatientBindDevices.size()==1){
@@ -342,7 +351,7 @@ public class DeviceInfoListener {
      * @param newInfusion 是否创建新的输注记录
      * @param cacheOperation 缓存操作
      */
-    private void handleInfusionHistory(BusDeviceRunningEntity device, DeviceOperator<DeviceCacheInfo> deviceOperator, AtomicBoolean newInfusion, List<Supplier<?>> cacheOperation) {
+    private BusInfusionHistoryEntity handleInfusionHistory(BusDeviceRunningEntity device, DeviceOperator<DeviceCacheInfo> deviceOperator, AtomicBoolean newInfusion, List<Supplier<?>> cacheOperation) {
         BusInfusionHistoryEntity infusionHistory = BusInfusionHistoryEntity.parseRunningInfo(device);
         String originInfusionId = deviceOperator.getInfusionId();
         if (newInfusion.get()) {
@@ -362,6 +371,7 @@ public class DeviceInfoListener {
             deviceOperator.setInfusionId(device.getInfusionId());
             return null;
         });
+        return infusionHistory;
     }
 
     /**
@@ -371,11 +381,11 @@ public class DeviceInfoListener {
      * @param  newInfusion 是否为新的输注记录
      * @param cacheOperation 缓存操作
      */
-    private void handleInfusion(BusDeviceRunningEntity device, DeviceOperator<DeviceCacheInfo> deviceOperator, AtomicBoolean newInfusion, List<Supplier<?>> cacheOperation) {
+    private BusInfusionHistoryEntity handleInfusion(BusDeviceRunningEntity device, DeviceOperator<DeviceCacheInfo> deviceOperator, AtomicBoolean newInfusion, List<Supplier<?>> cacheOperation) {
         PatientOperator<PatientCacheInfo> operator = patientRegistry.getOperator(device.getPatientCode(), device.getTenantId());
         device.setClinicId(operator.getClinicId());
 
-        handleInfusionHistory(device,deviceOperator,newInfusion,cacheOperation);
+        BusInfusionHistoryEntity infusionHistory = handleInfusionHistory(device, deviceOperator, newInfusion, cacheOperation);
         BusInfusionModifyEntity busInfusionModify = BusInfusionModifyEntity.parseRunningInfo(device);
         String signHex = busInfusionModify.signParam(sign);
         String infusionParam = deviceOperator.getInfusionParam();
@@ -415,6 +425,7 @@ public class DeviceInfoListener {
                     .eq(BusInfusionModifyEntity::getInfusionId, device.getInfusionId()).orderByDesc(BusInfusionModifyEntity::getModifyTime).last("limit 1"));
             device.setInfusionModifyId(modify.getId());
         }
+        return infusionHistory;
     }
 
 
@@ -467,11 +478,4 @@ public class DeviceInfoListener {
             });
         }
     }
-
-    public static void main(String[] args) {
-        DeviceAlarmEnum[] enumConstants = DeviceAlarmEnum.class.getEnumConstants();
-        for (DeviceAlarmEnum enumConstant : enumConstants) {
-
-        }
-    }
 }

+ 18 - 19
coffee-system/src/main/resources/mapper/bus/BusDeviceManualMapper.xml

@@ -19,20 +19,25 @@
 
     <select id="selectMonitor" resultMap="monitorResult" parameterType="com.coffee.bus.service.dto.ManualMonitorQuery">
         select
-            c.patient_code as patient_code,
-            c.patient_name as patient_name,
-            c.patient_gender as patient_gender,
-            c.patient_age as patient_age,
-            c.ward as ward,
-            c.bed_no as bed_no,
-            c.`name` as surgery_name,
-            c.ana_doctor as ana_doctor,
-            c.start_time as start_time,
-            dm.type as device_type
-            from
-            (select * from bus_clinic where monitor_type=0 and finished=0 ) as c
-            left JOIN (select clinic_id,type from bus_device_manual
+        c.patient_code as patient_code,
+        c.patient_name as patient_name,
+        c.patient_gender as patient_gender,
+        c.patient_age as patient_age,
+        c.ward as ward,
+        c.bed_no as bed_no,
+        c.`name` as surgery_name,
+        c.ana_doctor as ana_doctor,
+        c.start_time as start_time,
+        IFNULL(dm.type,-1) as device_type
+        from
+        (select * from bus_clinic where monitor_type=0 and finished=0 ) as c
+        left JOIN  bus_device_manual as dm on c.id=dm.clinic_id
         <where>
+            <if test="query.blurry != null">
+                (
+                c.`bed_no` like concat('%', #{query.blurry}, '%') or c.`patient_code` like concat('%', #{query.blurry}, '%') or c.ward LIKE concat('%', #{query.blurry}, '%') OR c.patient_name LIKE concat('%', #{query.blurry}, '%')
+                )
+            </if>
             <if test="query.types != null and query.types.size > 0">
                 and type in
                 <foreach item="type" index="index" collection="query.types" open="(" separator="," close=")">
@@ -40,12 +45,6 @@
                 </foreach>
             </if>
         </where>
-            ) as dm on c.id=dm.clinic_id
-        <where>
-            <if test="query.blurry != null">
-                c.`bed_no` like concat('%', #{query.blurry}, '%') or c.`patient_code` like concat('%', #{query.blurry}, '%') or c.ward LIKE concat('%', #{query.blurry}, '%') OR c.patient_name LIKE concat('%', #{query.blurry}, '%')
-            </if>
-        </where>
     </select>
 
 </mapper>

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

@@ -19,7 +19,7 @@
         <result column="master" property="master"/>
     </resultMap>
 
-    <resultMap id="monitorResult" type="com.coffee.bus.entity.PatientMonitorDomain">
+    <resultMap id="monitorResult" type="com.coffee.bus.service.dto.PatientMonitorResult">
         <result column="patient_name" property="patientName"/>
         <result column="patient_code" property="patientCode"/>
         <result column="gender" property="gender"/>
@@ -185,7 +185,13 @@
         c.surgery_doctor as surgery_doctor,
         c.surgery_name as surgery_name
         from
-        (select * from bus_patient)
+        (select * from bus_patient
+        <where>
+            <if test="query.timeRange != null and query.timeRange.size >0">
+                and tmp_finished &gt; #{query.timeRange[0]} and  tmp_finished &lt; #{query.timeRange[1]}
+            </if>
+        </where>
+        )
         as p
         join
         (select * from bus_infusion_history
@@ -203,7 +209,6 @@
                     #{type, jdbcType=VARCHAR}
                 </foreach>
             </if>
-
             <choose>
                 <when test="query.deviceStatus != null and query.deviceStatus.size > 0">
                     and (
@@ -247,11 +252,31 @@
         ) as i on p.infusion_id=i.id
         join (select device_id,alias from bus_device_running) as r on r.device_id=i.device_id
         left join bus_clinic c on i.clinic_id=c.id
-        <where>
-            <if test="query.blurry != null">
-                p.`name` like concat('%', #{query.blurry}, '%') or p.`code` like concat('%', #{query.blurry}, '%') or i.ward LIKE concat('%', #{query.blurry}, '%') OR i.bed_no LIKE concat('%', #{query.blurry}, '%')
-            </if>
-        </where>
-
+        <if test="query.bedNo!=null || query.name!=null || query.code!=null || query.anaDoctor!=null || query.surgeName!=null ||query.gender!=null ||query.anaType!=null">
+            <where>
+                (1=0
+                <if test="query.bedNo!=null">
+                    or i.bed_no LIKE concat('%', #{query.bedNo}, '%')
+                </if>
+                <if test="query.name!=null">
+                    or p.`name` LIKE concat('%', #{query.name}, '%')
+                </if>
+                <if test="query.code!=null">
+                    or p.`code` LIKE concat('%', #{query.code}, '%')
+                </if>
+                <if test="query.anaDoctor!=null">
+                    or c.`ana_doctor` like concat('%', #{query.anaDoctor}, '%')
+                </if>
+                <if test="query.surgeName!=null">
+                    or c.`surgery_name` like concat('%',#{query.surgeName}, '%')
+                </if>
+                <if test="query.gender!=null">
+                    or p.gender LIKE concat('%', #{query.gender}, '%')
+                </if>
+                <if test="query.anaType!=null">
+                    or c.ana_type LIKE concat('%', #{query.anaType}, '%')
+                </if>)
+            </where>
+        </if>
     </select>
 </mapper>