|
|
@@ -66,7 +66,6 @@ public class DeviceInfoListener {
|
|
|
private final Executor executor;
|
|
|
private final HospitalManagerRegister hospitalManagerRegister;
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 监听上传的数据信息,
|
|
|
* 若设备详情发生变化,则及时通知相应的ws通道
|
|
|
@@ -106,6 +105,12 @@ public class DeviceInfoListener {
|
|
|
handleHospitalConfig(device,cacheOperation);
|
|
|
|
|
|
if(device.isNewInfusion()){
|
|
|
+ deviceService.update(new UpdateWrapper<BusDeviceEntity>()
|
|
|
+ .lambda()
|
|
|
+ .eq(BusDeviceEntity::getDeviceId,device.getDeviceId())
|
|
|
+ .set(BusDeviceEntity::getInfusionId,device.getInfusionId())
|
|
|
+ .set(BusDeviceEntity::getType,device.getType())
|
|
|
+ );
|
|
|
infusionHistoryService.save(infusionHistory);
|
|
|
}else {
|
|
|
infusionHistoryService.updateById(infusionHistory);
|
|
|
@@ -116,8 +121,10 @@ public class DeviceInfoListener {
|
|
|
wsPublishUtils.publishPatientMonitor(device.getPatientCode(),device.getTenantId());
|
|
|
wsPublishUtils.publishMonitorStateCount(device.getTenantId());
|
|
|
}
|
|
|
- if (Boolean.TRUE.equals(device.isInfusionModify())||DeviceStatusEnum.Shutdown.equals(device.getRunState())) {
|
|
|
- wsPublishUtils.publishDeviceNone(device.getTenantId());
|
|
|
+ if (Boolean.TRUE.equals(device.isResetUndo())||Boolean.TRUE.equals(device.isInfusionModify())) {
|
|
|
+ if (Boolean.TRUE.equals(device.isInfusionModify())) {
|
|
|
+ wsPublishUtils.publishDeviceNone(device.getTenantId());
|
|
|
+ }
|
|
|
wsPublishUtils.publishDeviceRepeat(device.getTenantId());
|
|
|
}
|
|
|
if (Boolean.TRUE.equals(device.isResetClinic())) {
|
|
|
@@ -136,6 +143,7 @@ public class DeviceInfoListener {
|
|
|
|
|
|
//所有事务处理完成后更新缓存信息
|
|
|
cacheOperation.forEach(Supplier::get);
|
|
|
+ log.info("设备数据处理结束:{}",JSONUtil.toJsonStr(infoEvent.getContent()));
|
|
|
log.info("设备数据处理耗时:{}",(System.currentTimeMillis()-startTime));
|
|
|
}
|
|
|
}
|
|
|
@@ -167,36 +175,40 @@ public class DeviceInfoListener {
|
|
|
device.setMaster(true);
|
|
|
String deviceId = device.getDeviceId();
|
|
|
PatientOperator currentPatientOperator = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode());
|
|
|
- if(device.isInfusionModify()){
|
|
|
- if(device.isNewInfusion()){
|
|
|
+ if(Boolean.TRUE.equals(device.isResetUndo())||device.isInfusionModify()){
|
|
|
+ if(Boolean.TRUE.equals(device.isResetUndo())||device.isNewInfusion()){
|
|
|
//只有在新开启输注时进行判断,1、判断当前输注的病号是否存在其他正在进行的输注 2、判断该设备上一次输注绑定的病号是否没有任何输注
|
|
|
long runningInfusionCount = infusionHistoryService.count(new QueryWrapper<BusInfusionHistoryEntity>().lambda()
|
|
|
.eq(BusInfusionHistoryEntity::getFinished, false)
|
|
|
+ .eq(BusInfusionHistoryEntity::getIsUndo,false)
|
|
|
.eq(BusInfusionHistoryEntity::getPatientCode, device.getPatientCode())
|
|
|
.eq(BusInfusionHistoryEntity::getTenantId, device.getTenantId()));
|
|
|
patientService.update(new UpdateWrapper<BusPatientEntity>()
|
|
|
.lambda()
|
|
|
.eq(BusPatientEntity::getCode,device.getPatientCode())
|
|
|
.eq(BusPatientEntity::getTenantId,device.getTenantId())
|
|
|
- .set(BusPatientEntity::getInfusionId,device.getInfusionId())
|
|
|
+ //已撤泵重启的输注不再作为主泵进行判定
|
|
|
+ .set(Boolean.FALSE.equals(device.isResetUndo()),BusPatientEntity::getInfusionId,device.getInfusionId())
|
|
|
.set(runningInfusionCount>0,BusPatientEntity::getAlarm,PatientAlarmEnum.DEVICE_REPEAT)
|
|
|
.set(runningInfusionCount==0,BusPatientEntity::getAlarm,PatientAlarmEnum.NONE));
|
|
|
- BusInfusionHistoryEntity lastInfusion = infusionHistoryService.lastInfusion(deviceId);
|
|
|
- if(lastInfusion!=null&&ObjectUtil.notEqual(device.getPatientCode(),lastInfusion.getPatientCode())){
|
|
|
- //输注设备被占用
|
|
|
- BusInfusionHistoryEntity normalInfusion = infusionHistoryService.deviceOccupation(lastInfusion);
|
|
|
- if(normalInfusion!=null){
|
|
|
- patientRegistry.getOperator(lastInfusion.getTenantId(), lastInfusion.getPatientCode()).setBindDeviceId(normalInfusion.getDeviceId());
|
|
|
- suppliers.add(()->{
|
|
|
- wsPublishUtils.publishPatientMonitor(lastInfusion.getPatientCode(),lastInfusion.getTenantId());
|
|
|
- return null;
|
|
|
- });
|
|
|
+ if(device.isNewInfusion()){
|
|
|
+ BusInfusionHistoryEntity lastInfusion = infusionHistoryService.lastInfusion(deviceId);
|
|
|
+ if(lastInfusion!=null&&ObjectUtil.notEqual(device.getPatientCode(),lastInfusion.getPatientCode())){
|
|
|
+ //输注设备被占用
|
|
|
+ BusInfusionHistoryEntity normalInfusion = infusionHistoryService.deviceOccupation(lastInfusion);
|
|
|
+ if(normalInfusion!=null){
|
|
|
+ patientRegistry.getOperator(lastInfusion.getTenantId(), lastInfusion.getPatientCode()).setBindDeviceId(normalInfusion.getDeviceId());
|
|
|
+ suppliers.add(()->{
|
|
|
+ wsPublishUtils.publishPatientMonitor(lastInfusion.getPatientCode(),lastInfusion.getTenantId());
|
|
|
+ return null;
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- if(clinicFinished){
|
|
|
- clinicService.resetClinic(device.getClinicId());
|
|
|
- device.setResetClinic(true);
|
|
|
- }
|
|
|
+// if(clinicFinished){
|
|
|
+// clinicService.resetClinic(device.getClinicId());
|
|
|
+// device.setResetClinic(true);
|
|
|
+// }
|
|
|
device.setMaster(true);
|
|
|
suppliers.add(()->{
|
|
|
currentPatientOperator.setBindDeviceId(deviceId);
|
|
|
@@ -253,6 +265,9 @@ public class DeviceInfoListener {
|
|
|
device.setNewInfusion(false);
|
|
|
infusionHistory.setStartTime(device.getStartTime());
|
|
|
infusionHistory.setId(originInfusionId);
|
|
|
+ BusInfusionHistoryEntity originInfusion = infusionHistoryService.getById(originInfusionId);
|
|
|
+ device.setResetUndo(Boolean.TRUE.equals(originInfusion.getIsUndo()));
|
|
|
+ device.setMaster(false);
|
|
|
}
|
|
|
device.setInfusionId(infusionHistory.getId());
|
|
|
cacheOperation.add(()->{
|
|
|
@@ -281,35 +296,23 @@ public class DeviceInfoListener {
|
|
|
String signHex = busInfusionModify.signParam();
|
|
|
String infusionParam = deviceOperator.getInfusionParam();
|
|
|
boolean clinicFinished = clinicService.isFinished(device.getClinicId());
|
|
|
- if(ObjectUtil.notEqual(signHex,infusionParam)){
|
|
|
- device.setInfusionModify(true);
|
|
|
- infusionModifyService.save(busInfusionModify);
|
|
|
- device.setInfusionModifyId(busInfusionModify.getId());
|
|
|
- device.setModifyTime(busInfusionModify.getModifyTime());
|
|
|
+ //1、输注已撤泵,重新开启
|
|
|
+ if(Boolean.TRUE.equals(device.isResetUndo())||ObjectUtil.notEqual(signHex,infusionParam)){
|
|
|
+ if(ObjectUtil.notEqual(signHex,infusionParam)){
|
|
|
+ device.setInfusionModify(true);
|
|
|
+ infusionModifyService.save(busInfusionModify);
|
|
|
+ device.setInfusionModifyId(busInfusionModify.getId());
|
|
|
+ device.setModifyTime(busInfusionModify.getModifyTime());
|
|
|
+ }
|
|
|
handlePatient(device,clinicFinished,cacheOperation);
|
|
|
cacheOperation.add(()->{
|
|
|
- deviceOperator.setInfusionParam(signHex);
|
|
|
- deviceOperator.setModifyTime(device.getUploadTime());
|
|
|
+ if(device.isInfusionModify()){
|
|
|
+ deviceOperator.setInfusionParam(signHex);
|
|
|
+ deviceOperator.setModifyTime(device.getUploadTime());
|
|
|
+ }
|
|
|
return null;
|
|
|
});
|
|
|
- device.setIsUndo(false);
|
|
|
}else {
|
|
|
- //判断临床是否已结束,若临床已结束,则采用当前输注作为主输注开启临床
|
|
|
- if(clinicFinished){
|
|
|
- clinicService.resetClinic(device.getClinicId());
|
|
|
- patientService.update(new UpdateWrapper<BusPatientEntity>()
|
|
|
- .lambda()
|
|
|
- .eq(BusPatientEntity::getCode,device.getPatientCode())
|
|
|
- .eq(BusPatientEntity::getTenantId,device.getTenantId())
|
|
|
- .set(BusPatientEntity::getInfusionId,device.getInfusionId()));
|
|
|
- PatientOperator patientOperator = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode());
|
|
|
- device.setMaster(true);
|
|
|
- device.setResetClinic(true);
|
|
|
- cacheOperation.add(()->{
|
|
|
- patientOperator.setBindDeviceId(device.getDeviceId());
|
|
|
- return null;
|
|
|
- });
|
|
|
- }
|
|
|
//填充当前参数修改记录id
|
|
|
BusInfusionModifyEntity modify =infusionModifyService.recentModify(device.getClinicId(),device.getTenantId());
|
|
|
if(modify==null){
|
|
|
@@ -323,6 +326,22 @@ public class DeviceInfoListener {
|
|
|
// infusionHistoryService.deviceShutDown(device.getInfusionId(),device.getPatientCode(),device.getTenantId());
|
|
|
// }
|
|
|
}
|
|
|
+ //判断临床是否已结束,若临床已结束,则采用当前输注作为主输注开启临床
|
|
|
+ if(clinicFinished){
|
|
|
+ clinicService.resetClinic(device.getClinicId());
|
|
|
+ patientService.update(new UpdateWrapper<BusPatientEntity>()
|
|
|
+ .lambda()
|
|
|
+ .eq(BusPatientEntity::getCode,device.getPatientCode())
|
|
|
+ .eq(BusPatientEntity::getTenantId,device.getTenantId())
|
|
|
+ .set(BusPatientEntity::getInfusionId,device.getInfusionId()));
|
|
|
+ PatientOperator patientOperator = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode());
|
|
|
+ device.setMaster(true);
|
|
|
+ device.setResetClinic(true);
|
|
|
+ cacheOperation.add(()->{
|
|
|
+ patientOperator.setBindDeviceId(device.getDeviceId());
|
|
|
+ return null;
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|