|
|
@@ -1,6 +1,7 @@
|
|
|
package com.nb.mq.listener;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
@@ -24,6 +25,7 @@ import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.messaging.handler.annotation.Payload;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.Optional;
|
|
|
@@ -54,7 +56,6 @@ public class RabbitMqListener {
|
|
|
* @return void
|
|
|
*/
|
|
|
@RabbitListener(queuesToDeclare = @Queue("cloud.patient"))
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
public void patientQueue(@Payload String body) {
|
|
|
log.info("消息队列中,病人队列{cloud.patient},接受消息:{}",body);
|
|
|
BusHospitalLogEntity hospitalLog = new BusHospitalLogEntity();
|
|
|
@@ -70,39 +71,45 @@ public class RabbitMqListener {
|
|
|
PatientMonitorDetailResult patientDetail = patientClient.lookPatientDetail(patientId);
|
|
|
BusClinicEntity existClinic = patientDetail.getClinic();
|
|
|
if(Boolean.TRUE.equals(clinic.getFinished())){
|
|
|
- //进行撤泵处理
|
|
|
- clinicClient.finish(existClinic.getId(),existClinic.getTenantId());
|
|
|
- if (patientDetail.getInfusion()!=null) {
|
|
|
- //刷新分包标识
|
|
|
- deviceClient.refreshClassification(patientDetail.getInfusion().getDeviceId());
|
|
|
+ if(ObjectUtil.isNull(existClinic)||
|
|
|
+ ObjectUtil.isNull(existClinic.getUndoConfig())||
|
|
|
+ ObjectUtil.notEqual(clinic.getUndoConfig(),
|
|
|
+ existClinic.getUndoConfig())){
|
|
|
+ //避免重复撤泵,进行撤泵处理
|
|
|
+ clinicClient.finish(existClinic.getId(),existClinic.getTenantId(),clinic.getUndoConfig());
|
|
|
+ if (patientDetail.getInfusion()!=null) {
|
|
|
+ //刷新分包标识
|
|
|
+ deviceClient.refreshClassification(patientDetail.getInfusion().getDeviceId());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ clinic.setFinished(null);
|
|
|
+ clinicClient.update(existClinic.getId(),clinic);
|
|
|
}
|
|
|
- return;
|
|
|
- }
|
|
|
- //当上一个临床状态为已结束时,对比临床信息是否发生改变,生成新的临床信息
|
|
|
- boolean sameClinic=false;
|
|
|
- if(StrUtil.isNotEmpty(existClinic.getId())){
|
|
|
- sameClinic=(clinic.getSurgeryName()+
|
|
|
- Optional.ofNullable(clinic.getWard()).orElse("")+
|
|
|
- Optional.ofNullable(clinic.getBedNo()).orElse("")).equals(
|
|
|
- existClinic.getSurgeryName()+
|
|
|
- Optional.ofNullable(existClinic.getWard()).orElse("")+
|
|
|
- Optional.ofNullable(existClinic.getBedNo()).orElse(""));
|
|
|
- }
|
|
|
- if(!sameClinic){
|
|
|
- //为了避免网络延迟,开始时间往前推1个小时
|
|
|
- clinic.setStartTime(DateUtil.offsetHour(new Date(),0));
|
|
|
-
|
|
|
- clinic=clinicClient.insertFromHis(clinic);
|
|
|
- clinicClient.setCurrentClinicByHis(clinic,Boolean.TRUE.equals(existClinic.getFinished()));
|
|
|
}else {
|
|
|
- clinic.setStartTime(existClinic.getStartTime());
|
|
|
- clinicClient.update(existClinic.getId(),clinic);
|
|
|
+ //当上一个临床状态为已结束时,对比临床信息是否发生改变,生成新的临床信息
|
|
|
+ boolean sameClinic=false;
|
|
|
+ if(StrUtil.isNotEmpty(existClinic.getId())){
|
|
|
+ sameClinic=(clinic.getSurgeryName()).equals(
|
|
|
+ existClinic.getSurgeryName());
|
|
|
+ }
|
|
|
+ if(!sameClinic){
|
|
|
+ //为了避免网络延迟,开始时间往前推1个小时
|
|
|
+ clinic.setStartTime(DateUtil.offsetHour(new Date(),0));
|
|
|
+
|
|
|
+ clinic=clinicClient.insertFromHis(clinic);
|
|
|
+ clinicClient.setCurrentClinicByHis(clinic,Boolean.TRUE.equals(existClinic.getFinished()));
|
|
|
+ }else {
|
|
|
+ clinic.setStartTime(existClinic.getStartTime());
|
|
|
+ clinicClient.update(existClinic.getId(),clinic);
|
|
|
+ }
|
|
|
}
|
|
|
hospitalLog.setResult(JSONUtil.toJsonStr(clinic));
|
|
|
+ hospitalLog.setSuccess(true);
|
|
|
}catch (Exception e){
|
|
|
log.info("消息队列【cloud.patient】处理消息{}失败,",body,e);
|
|
|
hospitalLog.setMessage(ExceptionUtil.getExceptionMsg(e));
|
|
|
hospitalLog.setSuccess(false);
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
}
|
|
|
long entTime = System.currentTimeMillis();
|
|
|
hospitalLog.setUseTime(entTime-startTime);
|
|
|
@@ -117,7 +124,6 @@ public class RabbitMqListener {
|
|
|
* @return void
|
|
|
*/
|
|
|
@RabbitListener(queuesToDeclare = @Queue("cloud.pump"))
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
public void pumpQueue(@Payload String body) {
|
|
|
BusHospitalLogEntity hospitalLog = new BusHospitalLogEntity();
|
|
|
hospitalLog.setMsgId(IdWorker.getIdStr());
|
|
|
@@ -143,6 +149,7 @@ public class RabbitMqListener {
|
|
|
log.info("消息队列【cloud.pump】处理消息{}失败,",body,e);
|
|
|
hospitalLog.setMessage(ExceptionUtil.getExceptionMsg(e));
|
|
|
hospitalLog.setSuccess(false);
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
}
|
|
|
long entTime = System.currentTimeMillis();
|
|
|
hospitalLog.setUseTime(entTime-startTime);
|
|
|
@@ -191,6 +198,7 @@ public class RabbitMqListener {
|
|
|
log.info("消息队列【cloud.analgesicScore】处理消息{}失败,",body,e);
|
|
|
hospitalLog.setMessage(ExceptionUtil.getExceptionMsg(e));
|
|
|
hospitalLog.setSuccess(false);
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
}
|
|
|
long entTime = System.currentTimeMillis();
|
|
|
hospitalLog.setUseTime(entTime-startTime);
|