|
@@ -1,12 +1,15 @@
|
|
|
package com.coffee.bus.websocket.listener;
|
|
package com.coffee.bus.websocket.listener;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.coffee.bus.bean.HisInfo;
|
|
import com.coffee.bus.bean.HisInfo;
|
|
|
import com.coffee.bus.entity.BusClinicEntity;
|
|
import com.coffee.bus.entity.BusClinicEntity;
|
|
|
|
|
+import com.coffee.bus.entity.BusPumpEntity;
|
|
|
import com.coffee.bus.entity.BusPumpHistoryEntity;
|
|
import com.coffee.bus.entity.BusPumpHistoryEntity;
|
|
|
import com.coffee.bus.entity.BusPatientEntity;
|
|
import com.coffee.bus.entity.BusPatientEntity;
|
|
|
import com.coffee.bus.listener.event.bean.HistoryInfoEvent;
|
|
import com.coffee.bus.listener.event.bean.HistoryInfoEvent;
|
|
@@ -16,11 +19,16 @@ import com.coffee.bus.service.*;
|
|
|
import com.coffee.common.config.websocket.WebSocketConstant;
|
|
import com.coffee.common.config.websocket.WebSocketConstant;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.checkerframework.checker.units.qual.A;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.context.event.EventListener;
|
|
import org.springframework.context.event.EventListener;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -32,7 +40,6 @@ import java.util.stream.Collectors;
|
|
|
* @createTime 2022年03月29日 15:23:00
|
|
* @createTime 2022年03月29日 15:23:00
|
|
|
*/
|
|
*/
|
|
|
@Component
|
|
@Component
|
|
|
-@AllArgsConstructor
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
public class HistoryInfoListener {
|
|
public class HistoryInfoListener {
|
|
|
|
|
|
|
@@ -46,6 +53,25 @@ public class HistoryInfoListener {
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate;
|
|
private final RedisTemplate redisTemplate;
|
|
|
|
|
|
|
|
|
|
+ private final LocalBusPumpService pumpService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ public HistoryInfoListener(ScriptManager scriptManager, LocalBusPatientService patientService, LocalBusClinicService clinicService, LocalBusPumpHistoryService historyService, RedisTemplate redisTemplate, LocalBusPumpService pumpService) {
|
|
|
|
|
+ this.scriptManager = scriptManager;
|
|
|
|
|
+ this.patientService = patientService;
|
|
|
|
|
+ this.clinicService = clinicService;
|
|
|
|
|
+ this.historyService = historyService;
|
|
|
|
|
+ this.redisTemplate = redisTemplate;
|
|
|
|
|
+ this.pumpService = pumpService;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private HistoryInfoListener historyInfoListener;
|
|
|
|
|
+
|
|
|
|
|
+ @PostConstruct
|
|
|
|
|
+ public void init(){
|
|
|
|
|
+ historyInfoListener= SpringUtil.getBean(HistoryInfoListener.class);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@EventListener
|
|
@EventListener
|
|
|
public void historyInfoListener(HistoryInfoEvent infoEvent){
|
|
public void historyInfoListener(HistoryInfoEvent infoEvent){
|
|
|
log.info("接收到了医院数据,[{}]",infoEvent.getContent());
|
|
log.info("接收到了医院数据,[{}]",infoEvent.getContent());
|
|
@@ -84,7 +110,7 @@ public class HistoryInfoListener {
|
|
|
//判断临床的唯一性
|
|
//判断临床的唯一性
|
|
|
BusClinicEntity currentClinic = clinicService.getCurrentClinic(hisInfo.getHospitalId(), hisInfo.getPatientCode());
|
|
BusClinicEntity currentClinic = clinicService.getCurrentClinic(hisInfo.getHospitalId(), hisInfo.getPatientCode());
|
|
|
if (currentClinic==null) {
|
|
if (currentClinic==null) {
|
|
|
- updateClinic(clinic,requestId);
|
|
|
|
|
|
|
+ historyInfoListener.updateClinic(clinic,requestId);
|
|
|
}else {
|
|
}else {
|
|
|
//临床信息已存在,判断上传信息是否发生重复,是否为最新临床信息
|
|
//临床信息已存在,判断上传信息是否发生重复,是否为最新临床信息
|
|
|
if(currentClinic.getName().equals(clinic.getName())&¤tClinic.getStartTime().equals(clinic.getStartTime())){
|
|
if(currentClinic.getName().equals(clinic.getName())&¤tClinic.getStartTime().equals(clinic.getStartTime())){
|
|
@@ -92,7 +118,7 @@ public class HistoryInfoListener {
|
|
|
return ;
|
|
return ;
|
|
|
}else {
|
|
}else {
|
|
|
//不同的临床信息,则进行更新
|
|
//不同的临床信息,则进行更新
|
|
|
- updateClinic(clinic,requestId);
|
|
|
|
|
|
|
+ historyInfoListener.updateClinic(clinic,requestId);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//发送临床信息
|
|
//发送临床信息
|
|
@@ -100,7 +126,17 @@ public class HistoryInfoListener {
|
|
|
redisTemplate.convertAndSend(topic, clinic);
|
|
redisTemplate.convertAndSend(topic, clinic);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void updateClinic(BusClinicEntity clinic,Long requestId){
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 针对临床信息更新设备以及设备历史信息
|
|
|
|
|
+ * @param clinic
|
|
|
|
|
+ * @param clinic
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ @Async
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public void updateClinic(BusClinicEntity clinic,Long requestId){
|
|
|
clinic.setId(String.valueOf(IdWorker.getId()));
|
|
clinic.setId(String.valueOf(IdWorker.getId()));
|
|
|
//找到此病号信息且未绑定临床号,获取临床绑定设备号,并将临床信息与此次信息进行绑定
|
|
//找到此病号信息且未绑定临床号,获取临床绑定设备号,并将临床信息与此次信息进行绑定
|
|
|
List<BusPumpHistoryEntity> historyList = historyService.list(
|
|
List<BusPumpHistoryEntity> historyList = historyService.list(
|
|
@@ -114,10 +150,22 @@ public class HistoryInfoListener {
|
|
|
.isNull(BusPumpHistoryEntity::getClinicId));
|
|
.isNull(BusPumpHistoryEntity::getClinicId));
|
|
|
if (CollectionUtil.isNotEmpty(historyList)) {
|
|
if (CollectionUtil.isNotEmpty(historyList)) {
|
|
|
//历史信息与临床号绑定
|
|
//历史信息与临床号绑定
|
|
|
- historyList.forEach(history->history.setClinicId(clinic.getId()));
|
|
|
|
|
|
|
+ historyList.forEach(history-> history.fillClinic(clinic));
|
|
|
historyService.updateBatchById(historyList);
|
|
historyService.updateBatchById(historyList);
|
|
|
clinic.setDeviceCodes(historyList.stream().map(BusPumpHistoryEntity::getDeviceId).collect(Collectors.toSet()));
|
|
clinic.setDeviceCodes(historyList.stream().map(BusPumpHistoryEntity::getDeviceId).collect(Collectors.toSet()));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ pumpService.update(new UpdateWrapper<BusPumpEntity>()
|
|
|
|
|
+ .lambda()
|
|
|
|
|
+ .eq(BusPumpEntity::getPatientCode,clinic.getPatientCode())
|
|
|
|
|
+ .eq(BusPumpEntity::getTenantId,clinic.getTenantId())
|
|
|
|
|
+ .isNull(BusPumpEntity::getClinicId)
|
|
|
|
|
+ .set(BusPumpEntity::getClinicId,clinic.getId())
|
|
|
|
|
+ .set(BusPumpEntity::getPatientSex,clinic.getPatientGender())
|
|
|
|
|
+ .set(BusPumpEntity::getWard,clinic.getWard())
|
|
|
|
|
+ .set(BusPumpEntity::getBedNo,clinic.getBedNo())
|
|
|
|
|
+ .set(BusPumpEntity::getPatientName,clinic.getPatientName()));
|
|
|
|
|
+
|
|
|
clinicService.save(clinic);
|
|
clinicService.save(clinic);
|
|
|
log.info("新增临床信息,[{}]",clinic);
|
|
log.info("新增临床信息,[{}]",clinic);
|
|
|
}
|
|
}
|