|
|
@@ -89,16 +89,14 @@ public class DeviceInfoListener {
|
|
|
log.info("开始处理时间------------------------[{}]",System.currentTimeMillis());
|
|
|
/****************处理泵数据 todo 后续交由上游处理****************/
|
|
|
BusDeviceRunningEntity device = infoEvent.getContent();
|
|
|
+// device=device.startUpHandle();
|
|
|
device.setMonitorType(true);
|
|
|
- device.setMaster(true);
|
|
|
+
|
|
|
//1、判断该设备是否已和医院绑定并开启使用
|
|
|
String deviceId = device.getDeviceId();
|
|
|
device.setUploadTime(device.getUploadTime()==null?new Date():device.getUploadTime());
|
|
|
DeviceOperator<DeviceCacheInfo> deviceOperator = deviceRegistry.getOperator(deviceId);
|
|
|
-// if (deviceOperator==null||!Boolean.TRUE.equals(deviceOperator.getEnable())) {
|
|
|
-// log.warn("设备[{}]暂不可用,数据已丢弃",deviceId);
|
|
|
-// return ;
|
|
|
-// }
|
|
|
+ device.setMaster(deviceOperator.getMaster());
|
|
|
|
|
|
//数据准确性判断
|
|
|
String classification = device.getClassification();
|
|
|
@@ -241,9 +239,6 @@ public class DeviceInfoListener {
|
|
|
}
|
|
|
//更新泵所绑定当前病人缓存信息
|
|
|
suppliers.add(()->{
|
|
|
- Set<DeviceTimeSmallInfo> allDevice = Optional.ofNullable(currentPatientOperator.getAllDevice()).orElse(new HashSet<>());
|
|
|
- allDevice.add(DeviceTimeSmallInfo.of(deviceId,device.getStartTime()));
|
|
|
- currentPatientOperator.setAllDevice(allDevice);
|
|
|
if(Boolean.TRUE.equals(device.getMaster())){
|
|
|
currentPatientOperator.setBindDeviceId(deviceId);
|
|
|
}
|
|
|
@@ -261,68 +256,57 @@ public class DeviceInfoListener {
|
|
|
*/
|
|
|
private void handleConflictOriginPatient(String deviceId, String hospitalId, String patientCode, List<Supplier<?>> suppliers){
|
|
|
PatientOperator<PatientCacheInfo> patientOperator = patientRegistry.getOperator(hospitalId, patientCode);
|
|
|
- Set<DeviceTimeSmallInfo> allDevice = patientOperator.getAllDevice();
|
|
|
//过滤掉已换绑的泵,获取剩余所绑定的泵数据
|
|
|
- if(CollectionUtils.isNotEmpty(allDevice)){
|
|
|
- Set<DeviceTimeSmallInfo> remainPatientBindDevices = allDevice.stream()
|
|
|
- .filter(bindDevice -> !deviceId.equals(bindDevice.getDeviceId()))
|
|
|
- .collect(Collectors.toSet());
|
|
|
- if(CollectionUtil.isEmpty(remainPatientBindDevices)){
|
|
|
- log.warn("病号:【{}】临床发生无泵报警",patientCode);
|
|
|
- patientService.update(new UpdateWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode,patientCode)
|
|
|
- .eq(BusPatientEntity::getTenantId,hospitalId)
|
|
|
- .set(BusPatientEntity::getAlarm, PatientAlarmEnum.DEVICE_NONE)
|
|
|
- );
|
|
|
+ List<BusDeviceRunningEntity> currentBindDevices = deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getTenantId, patientCode)
|
|
|
+ .eq(BusDeviceRunningEntity::getTenantId, hospitalId)
|
|
|
+ .ne(BusDeviceRunningEntity::getDeviceId, deviceId));
|
|
|
+ if(CollectionUtil.isEmpty(currentBindDevices)){
|
|
|
+ log.warn("病号:【{}】临床发生无泵报警",patientCode);
|
|
|
+ patientService.update(new UpdateWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode,patientCode)
|
|
|
+ .eq(BusPatientEntity::getTenantId,hospitalId)
|
|
|
+ .set(BusPatientEntity::getAlarm, PatientAlarmEnum.DEVICE_NONE)
|
|
|
+ );
|
|
|
+ suppliers.add(()->{
|
|
|
+ //发起无泵报警,处理原先泵的无泵信息
|
|
|
+ patientOperator.setBindDeviceId(null);
|
|
|
+ wsPublishUtils.publishDeviceNone(hospitalId);
|
|
|
+ wsPublishUtils.publishPatientMonitor(patientCode,hospitalId);
|
|
|
+ //发起无泵报警后,将该病人最后一条输注作为显示信息实时传输给前端
|
|
|
+ return null;
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ //将开始时间最大的泵设置为主泵
|
|
|
+ Optional<BusDeviceRunningEntity> master = currentBindDevices.stream().max((o1,o2)->
|
|
|
+ o1.getStartTime().equals(o2.getStartTime())?0:o1.getStartTime().before(o2.getStartTime()) ? -1 : 1
|
|
|
+ );
|
|
|
+ UpdateWrapper<BusPatientEntity> update = new UpdateWrapper<>();
|
|
|
+ if(master.isPresent()){
|
|
|
+ log.warn("病号:[{}],主泵变为[{}]",patientCode,master.get().getDeviceId());
|
|
|
+ deviceRunningService
|
|
|
+ .update(new UpdateWrapper<BusDeviceRunningEntity>().lambda()
|
|
|
+ .eq(BusDeviceRunningEntity::getDeviceId,master.get().getDeviceId())
|
|
|
+ .set(BusDeviceRunningEntity::getMaster,true));
|
|
|
+ DeviceOperator<DeviceCacheInfo> operator = deviceRegistry.getOperator(master.get().getDeviceId());
|
|
|
+ //更换输注信息
|
|
|
+ update.lambda().eq(BusPatientEntity::getCode, patientCode)
|
|
|
+ .eq(BusPatientEntity::getTenantId, hospitalId)
|
|
|
+ .set(BusPatientEntity::getInfusionId, operator.getInfusionId());
|
|
|
suppliers.add(()->{
|
|
|
- //发起无泵报警,处理原先泵的无泵信息
|
|
|
- patientOperator.setBindDeviceId(null);
|
|
|
- patientOperator.setAllDevice(new HashSet<>());
|
|
|
- wsPublishUtils.publishDeviceNone(hospitalId);
|
|
|
+ String newMasterId = master.get().getDeviceId();
|
|
|
+ patientOperator.setBindDeviceId(newMasterId);
|
|
|
+ //更换输注信息后,将最新的输注信息传输实时传输给前端
|
|
|
wsPublishUtils.publishPatientMonitor(patientCode,hospitalId);
|
|
|
- //发起无泵报警后,将该病人最后一条输注作为显示信息实时传输给前端
|
|
|
+ wsPublishUtils.publishDeviceRepeat(hospitalId);
|
|
|
return null;
|
|
|
});
|
|
|
- }else {
|
|
|
- //将开始时间最大的泵设置为主泵
|
|
|
- Optional<DeviceTimeSmallInfo> master = remainPatientBindDevices.stream().max((o1,o2)->
|
|
|
- o1.getStartTime().equals(o2.getStartTime())?0:o1.getStartTime().before(o2.getStartTime()) ? -1 : 1
|
|
|
-
|
|
|
- );
|
|
|
- UpdateWrapper<BusPatientEntity> update = new UpdateWrapper<>();
|
|
|
- if(master.isPresent()){
|
|
|
- log.warn("病号:[{}],主泵变为[{}]",patientCode,master.get().getDeviceId());
|
|
|
- deviceRunningService
|
|
|
- .update(new UpdateWrapper<BusDeviceRunningEntity>().lambda()
|
|
|
- .eq(BusDeviceRunningEntity::getDeviceId,master.get().getDeviceId())
|
|
|
- .set(BusDeviceRunningEntity::getMaster,true));
|
|
|
- DeviceOperator<DeviceCacheInfo> operator = deviceRegistry.getOperator(master.get().getDeviceId());
|
|
|
- //更换输注信息
|
|
|
- update.lambda().eq(BusPatientEntity::getCode, patientCode)
|
|
|
- .eq(BusPatientEntity::getTenantId, hospitalId)
|
|
|
- .set(BusPatientEntity::getInfusionId, operator.getInfusionId());
|
|
|
- suppliers.add(()->{
|
|
|
- String newMasterId = master.get().getDeviceId();
|
|
|
- patientOperator.setBindDeviceId(newMasterId);
|
|
|
- patientOperator.setAllDevice(remainPatientBindDevices);
|
|
|
- //更换输注信息后,将最新的输注信息传输实时传输给前端
|
|
|
- wsPublishUtils.publishPatientMonitor(patientCode,hospitalId);
|
|
|
- wsPublishUtils.publishDeviceRepeat(hospitalId);
|
|
|
- return null;
|
|
|
- });
|
|
|
- if(remainPatientBindDevices.size()==1){
|
|
|
- //泵重复—>正常
|
|
|
- update.lambda()
|
|
|
- .set(BusPatientEntity::getAlarm, null);
|
|
|
- }
|
|
|
- patientService.update(update);
|
|
|
+ if(CollectionUtil.size(currentBindDevices)==1){
|
|
|
+ //泵重复—>正常
|
|
|
+ update.lambda()
|
|
|
+ .set(BusPatientEntity::getAlarm, null);
|
|
|
}
|
|
|
+ patientService.update(update);
|
|
|
|
|
|
}
|
|
|
- }else {
|
|
|
- suppliers.add(()->{
|
|
|
- patientOperator.setBindDeviceId(null);
|
|
|
- return null;
|
|
|
- });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -406,13 +390,12 @@ public class DeviceInfoListener {
|
|
|
BusInfusionModifyEntity busInfusionModify = BusInfusionModifyEntity.parseRunningInfo(device);
|
|
|
String signHex = busInfusionModify.signParam(sign);
|
|
|
String infusionParam = deviceOperator.getInfusionParam();
|
|
|
-
|
|
|
- BusClinicEntity clinic = clinicService.getById(device.getClinicId());
|
|
|
//输注参数已发生变化
|
|
|
if(ObjectUtil.notEqual(signHex,infusionParam)){
|
|
|
+ BusClinicEntity clinic = clinicService.getById(device.getClinicId());
|
|
|
infusionModifyService.save(busInfusionModify);
|
|
|
device.setInfusionModifyId(busInfusionModify.getId());
|
|
|
- device.setModifyTime(busInfusionModify.getUpdateTime());
|
|
|
+ device.setModifyTime(busInfusionModify.getModifyTime());
|
|
|
//参数发生变化后,进行判断
|
|
|
if(clinic!=null&&Boolean.TRUE.equals(clinic.getFinished())&&device.isNewInfusion()){
|
|
|
//若临床已结束,则只有新的输注能够进行泵冲突处理
|
|
|
@@ -434,16 +417,18 @@ public class DeviceInfoListener {
|
|
|
return null;
|
|
|
});
|
|
|
}else {
|
|
|
- String bindDeviceId = patientOperator.getBindDeviceId();
|
|
|
- if (device.getDeviceId().equals(bindDeviceId)) {
|
|
|
- device.setMaster(true);
|
|
|
- }else {
|
|
|
- device.setMaster(false);
|
|
|
- }
|
|
|
+// String bindDeviceId = patientOperator.getBindDeviceId();
|
|
|
+// if (device.getDeviceId().equals(bindDeviceId)) {
|
|
|
+// device.setMaster(true);
|
|
|
+// }else {
|
|
|
+// device.setMaster(false);
|
|
|
+// }
|
|
|
//填充当前参数修改记录id
|
|
|
- BusInfusionModifyEntity modify = infusionModifyService.getOne(new QueryWrapper<BusInfusionModifyEntity>().lambda()
|
|
|
- .select(BusInfusionModifyEntity::getId)
|
|
|
- .eq(BusInfusionModifyEntity::getInfusionId, device.getInfusionId()).orderByDesc(BusInfusionModifyEntity::getModifyTime).last("limit 1"));
|
|
|
+ BusInfusionModifyEntity modify =infusionModifyService.recentModify(device.getClinicId(),device.getTenantId());
|
|
|
+ if(modify==null){
|
|
|
+ modify=busInfusionModify;
|
|
|
+ infusionModifyService.save(modify);
|
|
|
+ }
|
|
|
device.setInfusionModifyId(modify.getId());
|
|
|
}
|
|
|
return infusionHistory;
|