Browse Source

fix 输注监控实时传输

A17404李放 3 năm trước cách đây
mục cha
commit
b1f4d4c575

+ 3 - 1
coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceManualMapper.java

@@ -1,9 +1,11 @@
 package com.coffee.bus.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.coffee.bus.entity.BusDeviceManualEntity;
 import com.coffee.bus.service.dto.ManualMonitorQuery;
 import com.coffee.bus.service.dto.ManualMonitorResult;
+import com.coffee.bus.service.dto.PatientMonitorResult;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -22,5 +24,5 @@ public interface BusDeviceManualMapper extends BaseMapper<BusDeviceManualEntity>
      * 查询其他监控信息列表
      * @return
      */
-    List<ManualMonitorResult> selectMonitor(@Param("query") ManualMonitorQuery query);
+    IPage<ManualMonitorResult> selectMonitor(IPage<ManualMonitorResult> page,@Param("query") ManualMonitorQuery query);
 }

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

@@ -40,4 +40,6 @@ public interface BusPatientMapper extends BaseMapper<BusPatientEntity> {
      * @return
      */
     IPage<PatientMonitorResult> selectMonitor(IPage<PatientMonitorResult> page, @Param("query") PatientMonitorQuery query);
+
+    PatientMonitorResult findByPatientCode(@Param("tenantId") String tenantId,@Param("patientCode")String patientCode);
 }

+ 4 - 1
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceManualService.java

@@ -1,10 +1,12 @@
 package com.coffee.bus.service;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.coffee.bus.entity.BusClinicEntity;
 import com.coffee.bus.entity.BusDeviceManualEntity;
 import com.coffee.bus.mapper.BusDeviceManualMapper;
 import com.coffee.bus.service.dto.ManualMonitorQuery;
 import com.coffee.bus.service.dto.ManualMonitorResult;
+import com.coffee.bus.service.dto.PatientMonitorResult;
 import com.coffee.common.crud.BaseService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -56,6 +58,7 @@ public class LocalBusDeviceManualService extends BaseService<BusDeviceManualMapp
     }
 
     public List<ManualMonitorResult> selectMonitor(ManualMonitorQuery query){
-        return this.baseMapper.selectMonitor(query);
+        Page<ManualMonitorResult> page = new Page<>(0, 500, false);
+        return this.baseMapper.selectMonitor(page,query).getRecords();
     }
 }

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

@@ -167,4 +167,15 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
         patientOperator.setBedNo(clinic.getBedNo());
         patientOperator.setWard(clinic.getWard());
     }
+
+    /**
+     * 根据病号查询临床监控记录
+     * @author lifang
+     * @param patientCode 病号
+     * @param tenantId 医院id
+     * @return
+     */
+    public PatientMonitorResult lookMonitorByPatientCode(String patientCode,String tenantId){
+        return this.baseMapper.findByPatientCode(tenantId,patientCode);
+    }
 }

+ 1 - 15
coffee-system/src/main/java/com/coffee/bus/utils/WsPublishUtils.java

@@ -1,18 +1,10 @@
 package com.coffee.bus.utils;
 
-import cn.hutool.extra.spring.SpringUtil;
-import cn.hutool.json.JSONUtil;
-import com.alibaba.fastjson.JSON;
-import com.coffee.bus.entity.BusDeviceEntity;
-import com.coffee.bus.enums.DeviceTypeEnum;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
+
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
-import org.springframework.util.SerializationUtils;
 
 /**
  * @author lifang
@@ -27,13 +19,7 @@ import org.springframework.util.SerializationUtils;
 public class WsPublishUtils {
     private final RedisTemplate redisTemplate;
 
-    private final ObjectMapper objectMapper;
     public void publish(String topic,Object msg){
-//        try {
-//            redisTemplate.convertAndSend(topic,objectMapper.writeValueAsString(msg));
-//        } catch (JsonProcessingException e) {
-//            log.error("ws消息发布,解析失败,推送消息:【】",msg.toString());
-//        }
         redisTemplate.convertAndSend(topic,msg);
     }
 }

+ 11 - 4
coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java

@@ -26,6 +26,7 @@ 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 io.reactivex.internal.operators.completable.CompletableFromRunnable;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.context.event.EventListener;
@@ -34,6 +35,7 @@ import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 import java.util.*;
 import java.util.List;
+import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
@@ -136,8 +138,11 @@ public class DeviceInfoListener {
 
             //则推送设备上报输注消息
             cacheOperation.add(()->{
-                wsPublishUtils.publish(WebSocketConstant.getPatientMonitor(null, device.getPatientCode(), device.getTenantId()).getTopic(),
-                        new PatientMonitorDetailResult(null,infusionHistory,null,null));
+                //异步推送
+                CompletableFuture.runAsync(()->{
+                    wsPublishUtils.publish(WebSocketConstant.getPatientMonitor(null, device.getPatientCode(), device.getTenantId()).getTopic(),
+                            patientService.lookMonitorByPatientCode(device.getPatientCode(),device.getTenantId()));
+                });
                 return null;
             });
 
@@ -295,8 +300,10 @@ public class DeviceInfoListener {
                         patientOperator.setAllDevice(remainPatientBindDevices);
                         //更换输注信息后,将最新的输注信息传输实时传输给前端 //todo
 
-                        wsPublishUtils.publish(WebSocketConstant.getPatientMonitor(null,patientCode, hospitalId).getTopic(),
-                                new PatientMonitorDetailResult(null,infusionHistoryService.getById(newMasterId),null,null));
+                        CompletableFuture.runAsync(()->{
+                            wsPublishUtils.publish(WebSocketConstant.getPatientMonitor(null,patientCode, hospitalId).getTopic(),
+                                    patientService.lookMonitorByPatientCode(patientCode,hospitalId));
+                        });
 
                         return null;
                     });

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

@@ -281,4 +281,67 @@
             </where>
         </if>
     </select>
+
+
+    <select id="findByPatientCode" resultMap="monitorResult">
+        select
+        p.`name` as patient_name,
+        p.`code` as patient_code,
+        p.gender as gender,
+        p.alarm as patient_alarm,
+        p.tmp_finished as tmp_finished,
+        p.monitor_start_time as monitor_start_time,
+        p.monitor_end_time as monitor_end_time,
+        i.device_id as device_id,
+        i.clinic_id as clinic_id,
+        i.ward as ward,
+        i.bed_no as bed_no,
+        i.total_dose as total_dose,
+        i.first_dose as first_dose,
+        i.remain_dose as remain_dose,
+        i.input_dose as input_dose,
+        i.append_dose as append_dose,
+        i.append_lock_time as append_lock_time,
+        i.max_dose as max_dose,
+        i.electric_quantity as electric_quantity,
+        i.warn_flow as warn_flow,
+        i.self_control_count as self_control_count,
+        i.self_control_lock_time as self_control_lock_time,
+        i.pca_valid_count as pca_valid_count,
+        i.pca_invalid_count as pca_invalid_count,
+        i.pca_total_count as pca_total_count,
+        i.continue_dose as continue_dose,
+        i.pulse_dose as pulse_dose,
+        i.pulse_lock_time as pulse_lock_time,
+        i.pulse_first_lock_time as pulse_first_lock_time,
+        i.flow_up_cycle as flow_up_cycle,
+        i.flow_down_cycle as flow_down_cycle,
+        i.flow_count as flow_count,
+        i.flow_up_limit as flow_up_limit,
+        i.flow_down_limit as flow_down_limit,
+        i.flow_adjust_rate as flow_adjust_rate,
+        i.run_state as run_state,
+        i.warn_will_finished as warn_will_finished,
+        i.warn_analgesic_poor as warn_analgesic_poor,
+        i.warn_low_battery as warn_low_battery,
+        i.alarm as device_alarm,
+        i.start_time as infusion_start_time,
+        i.remark as remark,
+        i.type as device_type,
+        r.alias as device_alias,
+        c.ana_doctor as ana_doctor,
+        c.patient_age as patient_age,
+        c.ana_type as ana_type,
+        c.anal_type as anal_type,
+        c.surgery_doctor as surgery_doctor,
+        c.surgery_name as surgery_name
+        from
+        (select * from bus_patient where tenant_id=#{tenantId} and code=#{patientCode} )
+        as p
+        join
+          bus_infusion_history 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
+        limit 1
+    </select>
 </mapper>