|
|
@@ -4,7 +4,7 @@ package com.nb.web.service.bus.utils;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
-import com.nb.web.api.enums.PatientAlarmEnum;
|
|
|
+import com.nb.web.service.bus.constant.RabbitMQConstant;
|
|
|
import com.nb.web.service.bus.mapper.BusPatientMapper;
|
|
|
import com.nb.web.service.bus.service.LocalBusPatientService;
|
|
|
import com.nb.web.service.bus.service.dto.MonitorStatusStatsCountResult;
|
|
|
@@ -12,9 +12,11 @@ import com.nb.web.api.feign.result.PatientMonitorResult;
|
|
|
import com.nb.common.websocket.TopicMessage;
|
|
|
import com.nb.common.websocket.WebSocketConstant;
|
|
|
import com.nb.common.config.utils.RedissonUtil;
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
@@ -29,13 +31,20 @@ import java.util.Collection;
|
|
|
* @createTime 2022年05月07日 11:34:00
|
|
|
*/
|
|
|
@Configuration
|
|
|
-@AllArgsConstructor
|
|
|
@Slf4j
|
|
|
public class WsPublishUtils implements Serializable{
|
|
|
- private final LocalBusPatientService patientService;
|
|
|
- private final BusPatientMapper patientMapper;
|
|
|
- private final RedissonUtil redissonUtil;
|
|
|
+ @Autowired
|
|
|
+ private LocalBusPatientService patientService;
|
|
|
+ @Autowired
|
|
|
+ private BusPatientMapper patientMapper;
|
|
|
+ @Autowired
|
|
|
+ private RedissonUtil redissonUtil;
|
|
|
+ @Autowired
|
|
|
+ private RabbitTemplate rabbitTemplate;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ @Lazy
|
|
|
+ private WsPublishUtils self;
|
|
|
private void publish(String topic,TopicMessage msg){
|
|
|
redissonUtil.getTopic(topic).publishAsync(msg);
|
|
|
}
|
|
|
@@ -56,14 +65,28 @@ public class WsPublishUtils implements Serializable{
|
|
|
if (log.isDebugEnabled()) {
|
|
|
log.debug("推送病号当前状态,【{}】",JSONUtil.toJsonStr(message));
|
|
|
}
|
|
|
+ //输注消息 发送至消息队列
|
|
|
+
|
|
|
if(message!=null){
|
|
|
message.handleWarn();
|
|
|
this.publish(WebSocketConstant.getPatientMonitor(null, patientId, tenantId).getTopic(),
|
|
|
TopicMessage.of(message,patientId)
|
|
|
);
|
|
|
+ self.asyncSendPatientMonitorMessage(message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Async
|
|
|
+ public void asyncSendPatientMonitorMessage(Object message) {
|
|
|
+ String msg = JSONUtil.toJsonStr(message);
|
|
|
+ log.debug("发送患者监护信息到队列: message={}", msg);
|
|
|
+ rabbitTemplate.convertAndSend(
|
|
|
+ RabbitMQConstant.TOPIC_EXCHANGE_NAME,
|
|
|
+ RabbitMQConstant.ROUTING_KEY_PATIENT_MONITOR,
|
|
|
+ msg
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
@Async
|
|
|
public void asyncPublishPatientMonitor(String patientId,String tenantId){
|
|
|
this.publishPatientMonitor(patientId,tenantId);
|