|
|
@@ -9,6 +9,7 @@ import cn.hutool.crypto.SignUtil;
|
|
|
import cn.hutool.crypto.asymmetric.Sign;
|
|
|
import cn.hutool.crypto.asymmetric.SignAlgorithm;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
@@ -26,7 +27,6 @@ import com.coffee.bus.registry.patient.PatientRegistry;
|
|
|
import com.coffee.bus.registry.patient.bean.DeviceTimeSmallInfo;
|
|
|
import com.coffee.bus.registry.patient.bean.PatientCacheInfo;
|
|
|
import com.coffee.bus.service.*;
|
|
|
-import com.coffee.bus.websocket.handler.DeviceInfoHook;
|
|
|
import com.coffee.common.config.websocket.WebSocketConstant;
|
|
|
import com.coffee.common.enums.SexEnum;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
@@ -78,7 +78,6 @@ public class DeviceInfoListener {
|
|
|
|
|
|
private final LocalBusClinicService clinicService;
|
|
|
|
|
|
- private final List<DeviceInfoHook> deviceInfoHooks;
|
|
|
/**
|
|
|
* 监听上传的数据信息,
|
|
|
* 若设备详情发生变化,则及时通知相应的ws通道
|
|
|
@@ -113,49 +112,30 @@ public class DeviceInfoListener {
|
|
|
throw new RuntimeException("设备数据中分包标识不能为空");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
log.info("接收到设备数据:[{}]",infoEvent.getContent().toString());
|
|
|
AtomicBoolean newInfusion=new AtomicBoolean(false);
|
|
|
- AtomicBoolean valid = new AtomicBoolean(true);
|
|
|
//缓存操作
|
|
|
List<Supplier<?>> cacheOperation=new ArrayList<>();
|
|
|
//处理设备运行数据, 判断是否为注册后第一次开机,判断是否为新的输注信息
|
|
|
boolean first = handleRunningInfo(device, deviceOperator,newInfusion,cacheOperation);
|
|
|
-
|
|
|
- //临床已结束,且设备非主设备
|
|
|
- if(!valid.get()){
|
|
|
- log.error("设备[{}]所绑定临床已结束且未关机,将数据[{}]丢弃",device.getDeviceId(),device.toString());
|
|
|
- return;
|
|
|
- }else {
|
|
|
- //todo 重启临床数据
|
|
|
- }
|
|
|
-
|
|
|
//处理输注参数
|
|
|
handleInfusion(device,deviceOperator,newInfusion,cacheOperation);
|
|
|
-
|
|
|
//处理历史运行数据
|
|
|
BusDeviceHistoryEntity history=handleRunningHistory(device);
|
|
|
//处理报警信息
|
|
|
handleAlarm(history,deviceOperator,cacheOperation);
|
|
|
-
|
|
|
- //如果是主泵信息且产生了新的输注,则与当前病号进行绑定
|
|
|
- if(Boolean.TRUE.equals(device.getMaster())&&newInfusion.get()){
|
|
|
- patientService.update(new UpdateWrapper<BusPatientEntity>()
|
|
|
- .lambda()
|
|
|
- .eq(BusPatientEntity::getCode,device.getPatientCode())
|
|
|
- .eq(BusPatientEntity::getTenantId,device.getTenantId())
|
|
|
- .set(BusPatientEntity::getInfusionId,device.getInfusionId()));
|
|
|
- }
|
|
|
-
|
|
|
//todo 流速图处理
|
|
|
if(first){
|
|
|
+ //首次上传数据,开启病号监控时长
|
|
|
+ patientService.update(new UpdateWrapper<BusPatientEntity>()
|
|
|
+ .lambda().eq(BusPatientEntity::getCode,device.getPatientCode())
|
|
|
+ .eq(BusPatientEntity::getTenantId,device.getTenantId()).set(BusPatientEntity::getMonitorStartTime,device.getStartTime()));
|
|
|
deviceUsingService.save(device);
|
|
|
}else {
|
|
|
deviceUsingService.updateById(device);
|
|
|
}
|
|
|
//医院相关配置处理
|
|
|
handleHospitalConfig(device,cacheOperation);
|
|
|
- /****************处理泵与患者关系****************/
|
|
|
|
|
|
//则推送设备上报消息
|
|
|
String topic = WebSocketConstant.getDeviceInfoDetailTopic(null, device.getId(), device.getTenantId());
|
|
|
@@ -183,22 +163,12 @@ public class DeviceInfoListener {
|
|
|
device.setIsUndo(deviceOperator.getUndo());
|
|
|
//todo 这部分操作交由上游处理
|
|
|
device.setTenantId(deviceOperator.getTenantId());
|
|
|
-
|
|
|
-// PatientOperator<PatientCacheInfo> patientOperator = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode());
|
|
|
-// Boolean finished = patientOperator.getFinished();
|
|
|
if(!classification.equals(originClassify)){
|
|
|
newInfusion.set(true);
|
|
|
//启动新的输注,则撤泵标识取消
|
|
|
device.setIsUndo(false);
|
|
|
//分包标识发生了改变,设备开机时间重新计算
|
|
|
device.setStartTime(new Date());
|
|
|
- //todo 处理临床数据
|
|
|
-// if(Boolean.TRUE.equals(finished)){
|
|
|
-// 将临床重新开启
|
|
|
-// clinicService
|
|
|
-// .update(new UpdateWrapper<BusClinicEntity>().lambda().eq(BusClinicEntity::getId,patientOperator.getClinicId())
|
|
|
-// .set(BusClinicEntity::getFinished,false));
|
|
|
-// }
|
|
|
}
|
|
|
boolean first=false;
|
|
|
if(StrUtil.isNullOrUndefined(usingId)){
|
|
|
@@ -396,18 +366,38 @@ public class DeviceInfoListener {
|
|
|
String infusionParam = deviceOperator.getInfusionParam();
|
|
|
//输注参数已发生变化
|
|
|
if(ObjectUtil.notEqual(signHex,infusionParam)){
|
|
|
- //输注参数改变
|
|
|
infusionModifyService.save(busInfusionModify);
|
|
|
- //输注参数变化后重启临床并且主副泵判断 todo
|
|
|
- if (CollectionUtil.isNotEmpty(deviceInfoHooks)) {
|
|
|
- deviceInfoHooks.forEach(hook->hook.infusionParamModify(device,deviceOperator,cacheOperation,newInfusion.get()));
|
|
|
+ device.setInfusionModifyId(busInfusionModify.getId());
|
|
|
+ //参数发生变化后,进行判断
|
|
|
+ PatientOperator<PatientCacheInfo> patientOperator = patientRegistry.getOperator(device.getTenantId(),device.getPatientCode());
|
|
|
+
|
|
|
+ if(Boolean.TRUE.equals(patientOperator.getFinished())){
|
|
|
+ //若临床已结束,则只有新的输注能够进行泵冲突处理
|
|
|
+ if(newInfusion.get()){
|
|
|
+ handlePatient(device,cacheOperation);
|
|
|
+ clinicService
|
|
|
+ .update(new UpdateWrapper<BusClinicEntity>().lambda().eq(BusClinicEntity::getId,patientOperator.getClinicId())
|
|
|
+ .set(BusClinicEntity::getFinished,false));
|
|
|
+ cacheOperation.add(()->{
|
|
|
+ //重启临床
|
|
|
+ patientOperator.setFinished(false);
|
|
|
+ return null;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ handlePatient(device,cacheOperation);
|
|
|
}
|
|
|
- handlePatient(device,cacheOperation);
|
|
|
//todo 输注参数发生变化
|
|
|
cacheOperation.add(()->{
|
|
|
deviceOperator.setInfusionParam(signHex);
|
|
|
return null;
|
|
|
});
|
|
|
+ }else {
|
|
|
+ //填充当前参数修改记录id
|
|
|
+ BusInfusionModifyEntity modify = infusionModifyService.getOne(new QueryWrapper<BusInfusionModifyEntity>().lambda()
|
|
|
+ .select(BusInfusionModifyEntity::getId)
|
|
|
+ .eq(BusInfusionModifyEntity::getInfusionId, device.getInfusionId()).orderByDesc(BusInfusionModifyEntity::getModifyTime).last("limit 1"));
|
|
|
+ device.setInfusionModifyId(modify.getId());
|
|
|
}
|
|
|
}
|
|
|
|