|
|
@@ -3,9 +3,13 @@ package com.coffee.bus.utils;
|
|
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.coffee.bus.entity.BusClinicEntity;
|
|
|
import com.coffee.bus.entity.BusPatientEntity;
|
|
|
import com.coffee.bus.enums.PatientAlarmEnum;
|
|
|
+import com.coffee.bus.service.LocalBusClinicService;
|
|
|
import com.coffee.bus.service.LocalBusPatientService;
|
|
|
+import com.coffee.bus.service.dto.MonitorStatusStatsCountResult;
|
|
|
+import com.coffee.bus.service.dto.PatientMonitorResult;
|
|
|
import com.coffee.common.config.websocket.WebSocketConstant;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -14,6 +18,8 @@ import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
+import java.io.Serializable;
|
|
|
+
|
|
|
/**
|
|
|
* @author lifang
|
|
|
* @version 1.0.0
|
|
|
@@ -27,8 +33,9 @@ import org.springframework.util.Assert;
|
|
|
public class WsPublishUtils {
|
|
|
private final RedisTemplate redisTemplate;
|
|
|
private final LocalBusPatientService patientService;
|
|
|
- @Async
|
|
|
- public void publish(String topic,Object msg){
|
|
|
+ private final LocalBusClinicService clinicService;
|
|
|
+
|
|
|
+ private void publish(String topic,TopicMessage msg){
|
|
|
redisTemplate.convertAndSend(topic,msg);
|
|
|
}
|
|
|
|
|
|
@@ -43,8 +50,19 @@ public class WsPublishUtils {
|
|
|
@Async
|
|
|
public void publishPatientMonitor(String patientCode,String tenantId){
|
|
|
Assert.hasText(tenantId,"医院id不能为空");
|
|
|
+ PatientMonitorResult message = patientService.lookMonitorByPatientCode(patientCode, tenantId);
|
|
|
this.publish(WebSocketConstant.getPatientMonitor(null, patientCode, tenantId).getTopic(),
|
|
|
- patientService.lookMonitorByPatientCode(patientCode,tenantId));
|
|
|
+ new TopicMessage<PatientMonitorResult>() {
|
|
|
+ @Override
|
|
|
+ public PatientMonitorResult getMessage() {
|
|
|
+ return message;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public String getParam() {
|
|
|
+ return patientCode;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -57,7 +75,17 @@ public class WsPublishUtils {
|
|
|
@Async
|
|
|
public void publishMonitorStateCount(String tenantId){
|
|
|
Assert.hasText(tenantId,"医院id不能为空");
|
|
|
- this.publish(WebSocketConstant.getMonitorStateCount(tenantId).getTopic(),patientService.statusStats(tenantId));
|
|
|
+ MonitorStatusStatsCountResult message = patientService.statusStats(tenantId);
|
|
|
+ this.publish(WebSocketConstant.getMonitorStateCount(tenantId).getTopic(), new TopicMessage<MonitorStatusStatsCountResult>() {
|
|
|
+ @Override
|
|
|
+ public MonitorStatusStatsCountResult getMessage() {
|
|
|
+ return message;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public String getParam() {
|
|
|
+ return tenantId;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -70,8 +98,18 @@ public class WsPublishUtils {
|
|
|
@Async
|
|
|
public void publishPatientAdd(String patientCode,String tenantId){
|
|
|
Assert.hasText(tenantId,"医院id不能为空");
|
|
|
+ JSONObject message = new JSONObject().putOpt("patientCode", patientCode);
|
|
|
this.publish(WebSocketConstant.getPatientAdd(tenantId).getTopic(),
|
|
|
- new JSONObject().putOpt("patientCode",patientCode));
|
|
|
+ new TopicMessage<JSONObject>() {
|
|
|
+ @Override
|
|
|
+ public JSONObject getMessage() {
|
|
|
+ return message;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public String getParam() {
|
|
|
+ return tenantId;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
/**
|
|
|
* 描述: 推送医院临床设备重复数量统计
|
|
|
@@ -83,9 +121,19 @@ public class WsPublishUtils {
|
|
|
@Async
|
|
|
public void publishDeviceRepeat(String tenantId){
|
|
|
Assert.hasText(tenantId,"医院id不能为空");
|
|
|
+ JSONObject message = new JSONObject().putOpt("count", patientService.count(new QueryWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getTenantId, tenantId)
|
|
|
+ .eq(BusPatientEntity::getAlarm, PatientAlarmEnum.DEVICE_REPEAT)));
|
|
|
this.publish(WebSocketConstant.getDeviceRepeat(tenantId).getTopic(),
|
|
|
- new JSONObject().putOpt("count", patientService.count(new QueryWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getTenantId,tenantId)
|
|
|
- .eq(BusPatientEntity::getAlarm, PatientAlarmEnum.DEVICE_REPEAT)))
|
|
|
+ new TopicMessage<JSONObject>() {
|
|
|
+ @Override
|
|
|
+ public JSONObject getMessage() {
|
|
|
+ return message;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public String getParam() {
|
|
|
+ return tenantId;
|
|
|
+ }
|
|
|
+ }
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -99,9 +147,54 @@ public class WsPublishUtils {
|
|
|
@Async
|
|
|
public void publishDeviceNone(String tenantId){
|
|
|
Assert.hasText(tenantId,"医院id不能为空");
|
|
|
+ JSONObject message = new JSONObject().putOpt("count", patientService.count(new QueryWrapper<BusPatientEntity>()
|
|
|
+ .lambda().eq(BusPatientEntity::getTenantId, tenantId)
|
|
|
+ .eq(BusPatientEntity::getAlarm, PatientAlarmEnum.DEVICE_NONE)));
|
|
|
this.publish(WebSocketConstant.getDeviceNone(tenantId).getTopic(),
|
|
|
- new JSONObject().putOpt("count", patientService.count(new QueryWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getTenantId,tenantId)
|
|
|
- .eq(BusPatientEntity::getAlarm, PatientAlarmEnum.DEVICE_NONE)))
|
|
|
+ new TopicMessage<JSONObject>() {
|
|
|
+ @Override
|
|
|
+ public JSONObject getMessage() {
|
|
|
+ return message;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public String getParam() {
|
|
|
+ return tenantId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 描述: 推送临床设备总数量统计
|
|
|
+ * @author lifang
|
|
|
+ * @date 2022/5/13 9:39
|
|
|
+ * @param
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ @Async
|
|
|
+ public void publishMonitorTotalCount(String tenantId){
|
|
|
+ Assert.hasText(tenantId,"医院id不能为空");
|
|
|
+ JSONObject message = new JSONObject().putOpt("count", clinicService.count(new QueryWrapper<BusClinicEntity>().lambda()
|
|
|
+ .eq(BusClinicEntity::getMonitorType,true)
|
|
|
+ .eq(BusClinicEntity::getTenantId,tenantId)
|
|
|
+ .eq(BusClinicEntity::getFinished,false)));
|
|
|
+ this.publish(WebSocketConstant.getMonitorTotalCount(tenantId).getTopic(),
|
|
|
+ new TopicMessage<JSONObject>() {
|
|
|
+ @Override
|
|
|
+ public JSONObject getMessage() {
|
|
|
+ return message;
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public String getParam() {
|
|
|
+ return tenantId;
|
|
|
+ }
|
|
|
+ }
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ public interface TopicMessage<T> extends Serializable {
|
|
|
+ T getMessage();
|
|
|
+ String getParam();
|
|
|
+ }
|
|
|
}
|