A17404李放 3 years ago
parent
commit
3568ebe42a

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

@@ -61,11 +61,11 @@ public abstract class Subscribe implements WsHandler {
         //需要处理的主题
         if (CollectionUtil.isNotEmpty(params)) {
             subScribeTopic =
-                    params.stream().map(param -> getTopic(message.getProductName(), param, loginUser.getTenantId()))
+                    params.stream().map(param -> getTopic(message.getProductName(), param, message.getTenantId()))
                             .collect(Collectors.toList());
         }
         else {
-            subScribeTopic = Collections.singletonList(getTopic(message.getProductName(), null, loginUser.getTenantId()));
+            subScribeTopic = Collections.singletonList(getTopic(message.getProductName(), null, message.getTenantId()));
         }
 
         MessagingRequest.Type type = message.getType();

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

@@ -1,10 +1,14 @@
 package com.coffee.bus.bean;
 
+import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import java.io.Serializable;
 
 @Data
+@AllArgsConstructor
+@NoArgsConstructor
 public class  GeoPoint implements Serializable {
     private String lon;
     private String lat;

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

@@ -228,19 +228,22 @@ public class BusPatientController  implements BaseQueryController<BusPatientEnti
         //泵切换完成后,对病号报警解除
         deviceRunningService.undo(undoConfig,false);
         //判断当前病号下是否还存在副泵
-        long count = deviceRunningService.count(new QueryWrapper<BusDeviceRunningEntity>().lambda()
+        List<BusDeviceRunningEntity> runningInfo = deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>().lambda()
                 .eq(BusDeviceRunningEntity::getPatientCode, undoConfig.getPatientCode())
                 .eq(BusDeviceRunningEntity::getTenantId, undoConfig.getTenantId())
-                .eq(BusDeviceRunningEntity::getMaster, false)
                 .eq(BusDeviceRunningEntity::getIsUndo, false));
         //处理缓存信息
         PatientOperator<PatientCacheInfo> operator = patientRegistry.getOperator(undoConfig.getTenantId(), undoConfig.getPatientCode());
-        String bindDeviceId = operator.getBindDeviceId();
-        Set<DeviceTimeSmallInfo> allDevice = operator.getAllDevice();
-        Optional<DeviceTimeSmallInfo> first = allDevice.stream().filter(device -> device.getDeviceId().equals(bindDeviceId)).findFirst();
-        operator.setAllDevice(Collections.singleton(first.get()));
-        if(count>0){
+        if(runningInfo.size()>1){
             //仅撤泵,病号报警不解除
+            Set<DeviceTimeSmallInfo> allDevice = runningInfo.stream().map(running -> DeviceTimeSmallInfo.of(running.getDeviceId(), running.getStartTime())).collect(Collectors.toSet());
+            operator.setAllDevice(allDevice);
+            Optional<BusDeviceRunningEntity> master = runningInfo.stream().filter(running -> Boolean.TRUE.equals(running.getMaster())).findAny();
+            if(master.isPresent()){
+                operator.setBindDeviceId(master.get().getDeviceId());
+            }else {
+                operator.setBindDeviceId(null);
+            }
             return R.success();
         }
         patientService.update(new UpdateWrapper<BusPatientEntity>().lambda()

+ 11 - 12
coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceRunningEntity.java

@@ -144,17 +144,16 @@ public class BusDeviceRunningEntity extends CommonDeviceParam<String,String> {
         if (DeviceStatusEnum.StartUp.equals(this.getRunState())&& DeviceTypeEnum.continuous.equals(this.getType())) {
             return this;
         }
-        BusDeviceRunningEntity runningEntity = new BusDeviceRunningEntity();
-        runningEntity.setId(this.getId());
-        runningEntity.setAlias(this.getAlias());
-        runningEntity.setDeviceId(this.getDeviceId());
-        runningEntity.setRunState(this.getRunState());
-        runningEntity.setClassification(this.getClassification());
-        runningEntity.setDataNumber(this.getDataNumber());
-        runningEntity.setType(this.getType());
-        runningEntity.setMonitorType(this.getMonitorType());
-        runningEntity.setUploadTime(this.getUploadTime());
-
+        BusDeviceRunningEntity result = new BusDeviceRunningEntity();
+        result.setId(this.getId());
+        result.setAlias(this.getAlias());
+        result.setDeviceId(this.getDeviceId());
+        result.setRunState(this.getRunState());
+        result.setClassification(this.getClassification());
+        result.setDataNumber(this.getDataNumber());
+        result.setType(this.getType());
+        result.setMonitorType(this.getMonitorType());
+        result.setUploadTime(this.getUploadTime());
 
 //        runningEntity.setInfusionModifyId(this.getInfusionModifyId());
 //        f
@@ -162,7 +161,7 @@ public class BusDeviceRunningEntity extends CommonDeviceParam<String,String> {
 //        runningEntity.setStartTime(this.getStartTime());
 //        runningEntity.setClinicId(this.getClinicId());
 
-        return runningEntity;
+        return result;
     }
 
 

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/hospital/config/HospitalAutoUndoConfigHandler.java

@@ -72,7 +72,7 @@ public class HospitalAutoUndoConfigHandler extends  AbstractHospitalConfigHandle
         if(config==null||!Boolean.TRUE.equals(config.isEnable())|| Objects.isNull(config.getNoSignalInterval())){
             return;
         }
-        RDelayedQueue noSignalUndoDelay = redissonUtil.getDelayedQueue(getId() +"-noSignalUndo"+ "-" + tenantId + "-" +device, e -> {
+        RDelayedQueue noSignalUndoDelay = redissonUtil.getDelayedQueue(getId() +"-noSignalUndo", e -> {
             if(e instanceof UndoEntity){
                 this.handleShutdown((UndoEntity) e);
             }
@@ -100,7 +100,7 @@ public class HospitalAutoUndoConfigHandler extends  AbstractHospitalConfigHandle
      * @return void
      */
     private void judgeShutdown(BusDeviceRunningEntity source,   FunctionAutoUndoConfig config ){
-        RDelayedQueue shutdownUndoDelay = redissonUtil.getDelayedQueue(getId() +"-shutdownUndo"+ "-" + source.getTenantId() + "-" + source.getDeviceId(), e -> {
+        RDelayedQueue shutdownUndoDelay = redissonUtil.getDelayedQueue(getId() +"-shutdownUndo", e -> {
             if(e instanceof UndoEntity){
                 this.handleShutdown((UndoEntity) e);
             }

+ 3 - 3
coffee-system/src/main/java/com/coffee/bus/hospital/config/HospitalFinishMonitorConfigHandler.java

@@ -69,7 +69,7 @@ public class HospitalFinishMonitorConfigHandler extends AbstractHospitalConfigHa
         if(config==null||!Boolean.TRUE.equals(config.isEnable())|| Objects.isNull(config.getNoSignalInterval())){
             return;
         }
-        RDelayedQueue<AbstractMsgId> noSignalFinishDelay = redissonUtil.getDelayedQueue(getId() +"-noSignalFinish"+ "-" + tenantId + "-" +device, e -> {
+        RDelayedQueue<AbstractMsgId> noSignalFinishDelay = redissonUtil.getDelayedQueue(getId() +"-noSignalFinish", e -> {
             if(e instanceof FinishMonitorEntity){
                 this.handleFinishMonitor((FinishMonitorEntity) e);
             }
@@ -98,7 +98,7 @@ public class HospitalFinishMonitorConfigHandler extends AbstractHospitalConfigHa
      * @return void
      */
     private void judgeShutdown(BusDeviceRunningEntity source,FunctionFinishMonitorConfig config){
-        RDelayedQueue<AbstractMsgId> shutdownFinishDelay = redissonUtil.getDelayedQueue(getId() +"-ShutdownFinish"+ "-" + source.getTenantId() + "-" + source.getDeviceId(), e -> {
+        RDelayedQueue<AbstractMsgId> shutdownFinishDelay = redissonUtil.getDelayedQueue(getId() +"-ShutdownFinish", e -> {
             if(e instanceof FinishMonitorEntity){
                 this.handleFinishMonitor((FinishMonitorEntity) e);
             }
@@ -121,7 +121,7 @@ public class HospitalFinishMonitorConfigHandler extends AbstractHospitalConfigHa
         }
 
         //不在服务区延迟队列清空
-        RDelayedQueue<AbstractMsgId> noSignalFinishDelay = redissonUtil.getDelayedQueue(getId() +"-noSignalFinish"+ "-" + source.getTenantId() + "-" +source.getDeviceId(), e -> {
+        RDelayedQueue<AbstractMsgId> noSignalFinishDelay = redissonUtil.getDelayedQueue(getId() +"-noSignalFinish", e -> {
             if(e instanceof FinishMonitorEntity){
                 this.handleFinishMonitor((FinishMonitorEntity) e);
             }

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/hospital/config/HospitalFunctionAnalConfigHandler.java

@@ -75,7 +75,7 @@ public class HospitalFunctionAnalConfigHandler extends AbstractHospitalConfigHan
      * @return void
      */
     private void handlerAnal(BusDeviceRunningEntity source,FunctionAnalConfig analConfig){
-        RDelayedQueue<AbstractMsgId>  delayedQueue = redissonUtil.getDelayedQueue(getId() + "-" + source.getTenantId() + "-" + source.getDeviceId(), e -> {
+        RDelayedQueue<AbstractMsgId>  delayedQueue = redissonUtil.getDelayedQueue(getId().name(), e -> {
             if(e instanceof AnalEntity){
                 this.judgeAnalPoor((AnalEntity) e);
             }
@@ -120,7 +120,7 @@ public class HospitalFunctionAnalConfigHandler extends AbstractHospitalConfigHan
      */
     private void judgeAnalPoor(AnalEntity anal){
         //镇痛消失延迟队列
-        RDelayedQueue<AbstractMsgId> noneAnalDelayedQueue = redissonUtil.getDelayedQueue("none-" + getId()+"-" + anal.getTenantId()+"-" + anal.getDeviceId(), e -> {
+        RDelayedQueue<AbstractMsgId> noneAnalDelayedQueue = redissonUtil.getDelayedQueue("none-" + getId(), e -> {
             if(e instanceof NoneAnalEntity){
                 handleNoneAnal((NoneAnalEntity) e);
             }

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/hospital/config/HospitalFunctionExtraConfigHandler.java

@@ -87,7 +87,7 @@ public class HospitalFunctionExtraConfigHandler  extends  AbstractHospitalConfig
         if(DeviceStatusEnum.Shutdown.equals(source.getRunState())){
             return;
         }
-        RDelayedQueue<AbstractMsgId> delayedQueue = redissonUtil.getDelayedQueue(getId() +"-signal"+ "-" + source.getTenantId() + "-" + source.getDeviceId(), e -> {
+        RDelayedQueue<AbstractMsgId> delayedQueue = redissonUtil.getDelayedQueue(getId() +"-signal", e -> {
             if(e instanceof  NoSignalEntity){
                 this.handleNoSignal((NoSignalEntity) e);
             }
@@ -154,7 +154,7 @@ public class HospitalFunctionExtraConfigHandler  extends  AbstractHospitalConfig
      * @return void
      */
     private void judgeLowInfusion(BusDeviceRunningEntity source,int interval){
-        RDelayedQueue<AbstractMsgId> delayedQueue = redissonUtil.getDelayedQueue(getId() +"-lowFusion"+ "-" + source.getTenantId() + "-" + source.getDeviceId(), e -> {
+        RDelayedQueue<AbstractMsgId> delayedQueue = redissonUtil.getDelayedQueue(getId() +"-lowFusion", e -> {
             if(e instanceof  LowInfusionEntity){
                 handleLowInfusion((LowInfusionEntity)e);
             }

+ 9 - 0
coffee-system/src/main/java/com/coffee/bus/mapper/BusInfusionModifyMapper.java

@@ -3,6 +3,7 @@ package com.coffee.bus.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.coffee.bus.entity.BusInfusionModifyEntity;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * @author 龙三郎
@@ -14,4 +15,12 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface BusInfusionModifyMapper extends BaseMapper<BusInfusionModifyEntity> {
 
+    /**
+     * 描述: 找到所给手术最近一次修改参数信息
+     * @author lifang
+     * @date 2022/5/25 14:37
+     * @param clinicId
+     * @return BusInfusionModifyEntity
+     */
+    BusInfusionModifyEntity recentModify(@Param("clinicId") String clinicId,@Param("tenantId") String tenantId);
 }

+ 4 - 0
coffee-system/src/main/java/com/coffee/bus/service/LocalBusInfusionModifyService.java

@@ -28,4 +28,8 @@ public class LocalBusInfusionModifyService extends BaseService<BusInfusionModify
     public void validateBeforeDelete(String id) {
 
     }
+
+    public BusInfusionModifyEntity recentModify(String clinicId,String tenantId){
+        return this.baseMapper.recentModify(clinicId,tenantId);
+    }
 }

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

@@ -272,7 +272,9 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
                 if(DeviceStatusEnum.Running.equals(monitor.getDeviceRunState())){
                     result.setRunningCount(result.getRunningCount()+1);
                 }
-                //todo 待结束数量
+                if(monitor.getDeviceRunState()!=null&&(DeviceStatusEnum.Shutdown.equals(monitor.getDeviceRunState())||DeviceStatusEnum.NoSignal.equals(monitor.getDeviceRunState()))){
+                    result.setAlarmCount(result.getAlarmCount()+1);
+                }
                 //报警数量
                 if(monitor.getDeviceAlarm()!=null&&!monitor.getDeviceAlarm().equals(DeviceAlarmEnum.None)){
                     result.setAlarmCount(result.getAlarmCount()+1);

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

@@ -89,16 +89,14 @@ public class DeviceInfoListener {
             log.info("开始处理时间------------------------[{}]",System.currentTimeMillis());
             /****************处理泵数据 todo 后续交由上游处理****************/
             BusDeviceRunningEntity device = infoEvent.getContent();
+//            device=device.startUpHandle();
             device.setMonitorType(true);
-            device.setMaster(true);
+
             //1、判断该设备是否已和医院绑定并开启使用
             String deviceId = device.getDeviceId();
             device.setUploadTime(device.getUploadTime()==null?new Date():device.getUploadTime());
             DeviceOperator<DeviceCacheInfo> deviceOperator = deviceRegistry.getOperator(deviceId);
-//            if (deviceOperator==null||!Boolean.TRUE.equals(deviceOperator.getEnable())) {
-//                log.warn("设备[{}]暂不可用,数据已丢弃",deviceId);
-//                return ;
-//            }
+            device.setMaster(deviceOperator.getMaster());
 
             //数据准确性判断
             String classification = device.getClassification();
@@ -241,9 +239,6 @@ public class DeviceInfoListener {
         }
         //更新泵所绑定当前病人缓存信息
         suppliers.add(()->{
-            Set<DeviceTimeSmallInfo> allDevice = Optional.ofNullable(currentPatientOperator.getAllDevice()).orElse(new HashSet<>());
-            allDevice.add(DeviceTimeSmallInfo.of(deviceId,device.getStartTime()));
-            currentPatientOperator.setAllDevice(allDevice);
             if(Boolean.TRUE.equals(device.getMaster())){
                 currentPatientOperator.setBindDeviceId(deviceId);
             }
@@ -261,68 +256,57 @@ public class DeviceInfoListener {
      */
     private void handleConflictOriginPatient(String deviceId, String hospitalId, String patientCode, List<Supplier<?>> suppliers){
         PatientOperator<PatientCacheInfo> patientOperator = patientRegistry.getOperator(hospitalId, patientCode);
-        Set<DeviceTimeSmallInfo> allDevice = patientOperator.getAllDevice();
         //过滤掉已换绑的泵,获取剩余所绑定的泵数据
-        if(CollectionUtils.isNotEmpty(allDevice)){
-            Set<DeviceTimeSmallInfo> remainPatientBindDevices = allDevice.stream()
-                    .filter(bindDevice -> !deviceId.equals(bindDevice.getDeviceId()))
-                    .collect(Collectors.toSet());
-            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)
-                );
+        List<BusDeviceRunningEntity> currentBindDevices = deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getTenantId, patientCode)
+                .eq(BusDeviceRunningEntity::getTenantId, hospitalId)
+                .ne(BusDeviceRunningEntity::getDeviceId, deviceId));
+        if(CollectionUtil.isEmpty(currentBindDevices)){
+            log.warn("病号:【{}】临床发生无泵报警",patientCode);
+            patientService.update(new UpdateWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode,patientCode)
+                    .eq(BusPatientEntity::getTenantId,hospitalId)
+                    .set(BusPatientEntity::getAlarm, PatientAlarmEnum.DEVICE_NONE)
+            );
+            suppliers.add(()->{
+                //发起无泵报警,处理原先泵的无泵信息
+                patientOperator.setBindDeviceId(null);
+                wsPublishUtils.publishDeviceNone(hospitalId);
+                wsPublishUtils.publishPatientMonitor(patientCode,hospitalId);
+                //发起无泵报警后,将该病人最后一条输注作为显示信息实时传输给前端
+                return null;
+            });
+        }else {
+            //将开始时间最大的泵设置为主泵
+            Optional<BusDeviceRunningEntity> master = currentBindDevices.stream().max((o1,o2)->
+                    o1.getStartTime().equals(o2.getStartTime())?0:o1.getStartTime().before(o2.getStartTime()) ? -1 : 1
+            );
+            UpdateWrapper<BusPatientEntity> update = new UpdateWrapper<>();
+            if(master.isPresent()){
+                log.warn("病号:[{}],主泵变为[{}]",patientCode,master.get().getDeviceId());
+                deviceRunningService
+                        .update(new UpdateWrapper<BusDeviceRunningEntity>().lambda()
+                                .eq(BusDeviceRunningEntity::getDeviceId,master.get().getDeviceId())
+                                .set(BusDeviceRunningEntity::getMaster,true));
+                DeviceOperator<DeviceCacheInfo> operator = deviceRegistry.getOperator(master.get().getDeviceId());
+                //更换输注信息
+                update.lambda().eq(BusPatientEntity::getCode, patientCode)
+                        .eq(BusPatientEntity::getTenantId, hospitalId)
+                        .set(BusPatientEntity::getInfusionId, operator.getInfusionId());
                 suppliers.add(()->{
-                    //发起无泵报警,处理原先泵的无泵信息
-                    patientOperator.setBindDeviceId(null);
-                    patientOperator.setAllDevice(new HashSet<>());
-                    wsPublishUtils.publishDeviceNone(hospitalId);
+                    String newMasterId = master.get().getDeviceId();
+                    patientOperator.setBindDeviceId(newMasterId);
+                    //更换输注信息后,将最新的输注信息传输实时传输给前端
                     wsPublishUtils.publishPatientMonitor(patientCode,hospitalId);
-                    //发起无泵报警后,将该病人最后一条输注作为显示信息实时传输给前端
+                    wsPublishUtils.publishDeviceRepeat(hospitalId);
                     return null;
                 });
-            }else {
-                //将开始时间最大的泵设置为主泵
-                Optional<DeviceTimeSmallInfo> master = remainPatientBindDevices.stream().max((o1,o2)->
-                        o1.getStartTime().equals(o2.getStartTime())?0:o1.getStartTime().before(o2.getStartTime()) ? -1 : 1
-
-                );
-                UpdateWrapper<BusPatientEntity> update = new UpdateWrapper<>();
-                if(master.isPresent()){
-                    log.warn("病号:[{}],主泵变为[{}]",patientCode,master.get().getDeviceId());
-                    deviceRunningService
-                            .update(new UpdateWrapper<BusDeviceRunningEntity>().lambda()
-                                    .eq(BusDeviceRunningEntity::getDeviceId,master.get().getDeviceId())
-                                    .set(BusDeviceRunningEntity::getMaster,true));
-                    DeviceOperator<DeviceCacheInfo> operator = deviceRegistry.getOperator(master.get().getDeviceId());
-                    //更换输注信息
-                    update.lambda().eq(BusPatientEntity::getCode, patientCode)
-                            .eq(BusPatientEntity::getTenantId, hospitalId)
-                            .set(BusPatientEntity::getInfusionId, operator.getInfusionId());
-                    suppliers.add(()->{
-                        String newMasterId = master.get().getDeviceId();
-                        patientOperator.setBindDeviceId(newMasterId);
-                        patientOperator.setAllDevice(remainPatientBindDevices);
-                        //更换输注信息后,将最新的输注信息传输实时传输给前端
-                        wsPublishUtils.publishPatientMonitor(patientCode,hospitalId);
-                        wsPublishUtils.publishDeviceRepeat(hospitalId);
-                        return null;
-                    });
-                    if(remainPatientBindDevices.size()==1){
-                        //泵重复—>正常
-                        update.lambda()
-                                .set(BusPatientEntity::getAlarm, null);
-                    }
-                    patientService.update(update);
+                if(CollectionUtil.size(currentBindDevices)==1){
+                    //泵重复—>正常
+                    update.lambda()
+                            .set(BusPatientEntity::getAlarm, null);
                 }
+                patientService.update(update);
 
             }
-        }else {
-            suppliers.add(()->{
-                patientOperator.setBindDeviceId(null);
-                return null;
-            });
         }
     }
 
@@ -406,13 +390,12 @@ public class DeviceInfoListener {
         BusInfusionModifyEntity busInfusionModify = BusInfusionModifyEntity.parseRunningInfo(device);
         String signHex = busInfusionModify.signParam(sign);
         String infusionParam = deviceOperator.getInfusionParam();
-
-        BusClinicEntity clinic = clinicService.getById(device.getClinicId());
         //输注参数已发生变化
         if(ObjectUtil.notEqual(signHex,infusionParam)){
+            BusClinicEntity clinic = clinicService.getById(device.getClinicId());
             infusionModifyService.save(busInfusionModify);
             device.setInfusionModifyId(busInfusionModify.getId());
-            device.setModifyTime(busInfusionModify.getUpdateTime());
+            device.setModifyTime(busInfusionModify.getModifyTime());
             //参数发生变化后,进行判断
             if(clinic!=null&&Boolean.TRUE.equals(clinic.getFinished())&&device.isNewInfusion()){
                 //若临床已结束,则只有新的输注能够进行泵冲突处理
@@ -434,16 +417,18 @@ public class DeviceInfoListener {
                 return null;
             });
         }else {
-            String bindDeviceId = patientOperator.getBindDeviceId();
-            if (device.getDeviceId().equals(bindDeviceId)) {
-                device.setMaster(true);
-            }else {
-                device.setMaster(false);
-            }
+//            String bindDeviceId = patientOperator.getBindDeviceId();
+//            if (device.getDeviceId().equals(bindDeviceId)) {
+//                device.setMaster(true);
+//            }else {
+//                device.setMaster(false);
+//            }
             //填充当前参数修改记录id
-            BusInfusionModifyEntity modify = infusionModifyService.getOne(new QueryWrapper<BusInfusionModifyEntity>().lambda()
-                    .select(BusInfusionModifyEntity::getId)
-                    .eq(BusInfusionModifyEntity::getInfusionId, device.getInfusionId()).orderByDesc(BusInfusionModifyEntity::getModifyTime).last("limit 1"));
+            BusInfusionModifyEntity modify =infusionModifyService.recentModify(device.getClinicId(),device.getTenantId());
+            if(modify==null){
+                modify=busInfusionModify;
+                infusionModifyService.save(modify);
+            }
             device.setInfusionModifyId(modify.getId());
         }
         return infusionHistory;

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

@@ -98,7 +98,7 @@
                     and monitor_type=#{query.monitorType}
                 </if>
                 <if test="query.surgeryName!=null">
-                    and name like concat('%',#{query.surgeryName},'%')
+                    and surgery_name like concat('%',#{query.surgeryName},'%')
                 </if>
                 <if test="query.patientName!=null">
                     and patient_name like concat('%',#{query.patientName},'%')

+ 23 - 0
coffee-system/src/main/resources/mapper/bus/BusInfusionModifyMapper.xml

@@ -0,0 +1,23 @@
+<?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.BusInfusionModifyMapper">
+
+
+    <select id="recentModify" resultType="com.coffee.bus.entity.BusInfusionModifyEntity">
+        select m.* from bus_infusion_modify as m JOIN
+        (select * from bus_infusion_history
+        <where>
+            clinic_id=#{clinicId}
+            <if test="tenantId!=null">
+                tenant_id=#{tenantId}
+            </if>
+        </where>
+
+        ) as h on  m.infusion_id=h.id order by m.modify_time desc limit 1
+    </select>
+
+
+
+
+
+</mapper>

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

@@ -272,8 +272,9 @@
             </where>
             ) as i on p.infusion_id=i.id
             join (select device_id,alias from bus_device) as d on d.device_id=i.device_id
-            join (select * from bus_clinic where finished=0
+            join (select * from bus_clinic
             <where>
+                finished=0
                 <if test="query.timeRange != null and query.timeRange.size >0">
                     and monitor_start_time &gt; #{query.timeRange[0]} and  monitor_start_time &lt; #{query.timeRange[1]}
                 </if>
@@ -389,7 +390,7 @@
                     and tenant_id=#{tenantId}
                 </if>
             </where>
-            ) as c on p.clinic_id=c.id
+            ) as c on p.code=c.patient_code
             <where>
                 <if test="alarmValue!=null">
                     and p.alarm=#{alarmValue}