|
@@ -39,17 +39,10 @@ import java.util.concurrent.TimeUnit;
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
public class HospitalFunctionAnalConfigHandler extends AbstractHospitalConfigHandler<FunctionAnalConfig,BusDeviceRunningEntity> {
|
|
public class HospitalFunctionAnalConfigHandler extends AbstractHospitalConfigHandler<FunctionAnalConfig,BusDeviceRunningEntity> {
|
|
|
|
|
|
|
|
- private LocalBusDeviceAlarmService alarmService;
|
|
|
|
|
- //最后一次镇痛不足报警任务对象
|
|
|
|
|
- private AnalEntity lastAnalWarn;
|
|
|
|
|
-
|
|
|
|
|
- //最后一次取消镇痛不足报警任务对象
|
|
|
|
|
- private NoneAnalEntity lastNoneAnal;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public HospitalFunctionAnalConfigHandler(ConfigStorage configStorage, String hospitalId, RedissonUtil redissonUtil, LocalBusInfusionHistoryService infusionHistoryService, DeviceRegistry deviceRegistry, WsPublishUtils wsPublishUtils,LocalBusDeviceAlarmService alarmService) {
|
|
public HospitalFunctionAnalConfigHandler(ConfigStorage configStorage, String hospitalId, RedissonUtil redissonUtil, LocalBusInfusionHistoryService infusionHistoryService, DeviceRegistry deviceRegistry, WsPublishUtils wsPublishUtils,LocalBusDeviceAlarmService alarmService) {
|
|
|
super(configStorage, hospitalId, redissonUtil, infusionHistoryService, deviceRegistry, wsPublishUtils);
|
|
super(configStorage, hospitalId, redissonUtil, infusionHistoryService, deviceRegistry, wsPublishUtils);
|
|
|
- this.alarmService=alarmService;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -91,19 +84,8 @@ public class HospitalFunctionAnalConfigHandler extends AbstractHospitalConfigHan
|
|
|
//新输注清空缓存记录
|
|
//新输注清空缓存记录
|
|
|
redissonUtil.clearScoreSortSet(analSortKey);
|
|
redissonUtil.clearScoreSortSet(analSortKey);
|
|
|
}
|
|
}
|
|
|
- redissonUtil.addScoreSortSet(analSortKey,source.getUploadTime().getTime(),source);
|
|
|
|
|
-
|
|
|
|
|
- Integer insufficientTime = analConfig.getInsufficientTime();
|
|
|
|
|
- Integer insufficientCount = analConfig.getInsufficientCount();
|
|
|
|
|
- Boolean valid = analConfig.getValid();
|
|
|
|
|
- if(valid==null||(insufficientTime==null||insufficientTime<=0)||
|
|
|
|
|
- (insufficientCount==null||insufficientCount<=0)){
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- Long endTime = source.getUploadTime().getTime();
|
|
|
|
|
- Long startTime=endTime-TimeUnit.MINUTES.toMillis(insufficientTime);
|
|
|
|
|
|
|
|
|
|
- lastAnalWarn = AnalEntity.builder()
|
|
|
|
|
|
|
+ AnalEntity anal = AnalEntity.builder()
|
|
|
.deviceId(source.getDeviceId())
|
|
.deviceId(source.getDeviceId())
|
|
|
.pcaValidCount(source.getPcaValidCount())
|
|
.pcaValidCount(source.getPcaValidCount())
|
|
|
.pcaInvalidCount(source.getPcaInvalidCount())
|
|
.pcaInvalidCount(source.getPcaInvalidCount())
|
|
@@ -117,6 +99,18 @@ public class HospitalFunctionAnalConfigHandler extends AbstractHospitalConfigHan
|
|
|
.infusionId(source.getInfusionId())
|
|
.infusionId(source.getInfusionId())
|
|
|
.build();
|
|
.build();
|
|
|
|
|
|
|
|
|
|
+ redissonUtil.addScoreSortSet(analSortKey,source.getUploadTime().getTime(),anal);
|
|
|
|
|
+
|
|
|
|
|
+ Integer insufficientTime = analConfig.getInsufficientTime();
|
|
|
|
|
+ Integer insufficientCount = analConfig.getInsufficientCount();
|
|
|
|
|
+ Boolean valid = analConfig.getValid();
|
|
|
|
|
+ if(valid==null||(insufficientTime==null||insufficientTime<=0)||
|
|
|
|
|
+ (insufficientCount==null||insufficientCount<=0)){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Long endTime = source.getUploadTime().getTime();
|
|
|
|
|
+ Long startTime=endTime-TimeUnit.MINUTES.toMillis(insufficientTime);
|
|
|
|
|
+
|
|
|
//获取该次输注过程中,以当前输注上传时间为结束时间,以判定时间区间为区间范围的时间窗口数据
|
|
//获取该次输注过程中,以当前输注上传时间为结束时间,以判定时间区间为区间范围的时间窗口数据
|
|
|
Collection<ScoredEntry<Object>> scoreRange = redissonUtil.getRange(analSortKey, startTime.intValue(), endTime.intValue());
|
|
Collection<ScoredEntry<Object>> scoreRange = redissonUtil.getRange(analSortKey, startTime.intValue(), endTime.intValue());
|
|
|
Optional<ScoredEntry<Object>> min = scoreRange.stream().max(Comparator.comparing(ScoredEntry::getScore));
|
|
Optional<ScoredEntry<Object>> min = scoreRange.stream().max(Comparator.comparing(ScoredEntry::getScore));
|
|
@@ -143,7 +137,7 @@ public class HospitalFunctionAnalConfigHandler extends AbstractHospitalConfigHan
|
|
|
handleAnalFinish((NoneAnalEntity) e);
|
|
handleAnalFinish((NoneAnalEntity) e);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- NoneAnalEntity.builder()
|
|
|
|
|
|
|
+ NoneAnalEntity noneAnal = NoneAnalEntity.builder()
|
|
|
.deviceId(firstAnal.getDeviceId())
|
|
.deviceId(firstAnal.getDeviceId())
|
|
|
.tenantId(firstAnal.getTenantId())
|
|
.tenantId(firstAnal.getTenantId())
|
|
|
.timeout(analConfig.getDisappearTime())
|
|
.timeout(analConfig.getDisappearTime())
|
|
@@ -152,7 +146,7 @@ public class HospitalFunctionAnalConfigHandler extends AbstractHospitalConfigHan
|
|
|
.historyId(firstAnal.getHistoryId())
|
|
.historyId(firstAnal.getHistoryId())
|
|
|
.timestamp(new Date())
|
|
.timestamp(new Date())
|
|
|
.build();
|
|
.build();
|
|
|
- redissonUtil.offerQueue(noneAnalDelayedQueue,lastNoneAnal,lastNoneAnal.getTimeout(),lastNoneAnal.getUnit());
|
|
|
|
|
|
|
+ redissonUtil.offerQueue(noneAnalDelayedQueue,noneAnal,noneAnal.getTimeout(),noneAnal.getUnit());
|
|
|
}
|
|
}
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
log.debug("镇痛不足缓存解析失败,设备号【{}】",source.getDeviceId(),e);
|
|
log.debug("镇痛不足缓存解析失败,设备号【{}】",source.getDeviceId(),e);
|
|
@@ -161,70 +155,6 @@ public class HospitalFunctionAnalConfigHandler extends AbstractHospitalConfigHan
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 描述: 处理镇痛不足情况以及判断镇痛不足消失
|
|
|
|
|
- * @author lifang
|
|
|
|
|
- * @date 2022/5/19 9:14
|
|
|
|
|
- * @param
|
|
|
|
|
- * @return void
|
|
|
|
|
- */
|
|
|
|
|
- private void handleAnalPoorAndJudgeFinish(AnalEntity anal){
|
|
|
|
|
- //镇痛消失延迟队列
|
|
|
|
|
- RDelayedQueue<AbstractMsgId> noneAnalDelayedQueue = redissonUtil.getDelayedQueue("none-" + getId(), e -> {
|
|
|
|
|
- if(e instanceof NoneAnalEntity){
|
|
|
|
|
- handleAnalFinish((NoneAnalEntity) e);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- String deviceId = anal.getDeviceId();
|
|
|
|
|
- BusInfusionHistoryEntity infusionHistory = infusionHistoryService.getById(anal.getInfusionId());
|
|
|
|
|
- if(Boolean.TRUE.equals(infusionHistory.getFinished())){
|
|
|
|
|
- //泵已换绑医院,无需再处理
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- //PCA差值
|
|
|
|
|
- int subCount=0;
|
|
|
|
|
- if(anal.isJudgeByValid()){
|
|
|
|
|
- subCount=Math.subtractExact(infusionHistory.getPcaValidCount(), Optional.ofNullable(anal.getPcaValidCount()).orElse(0));
|
|
|
|
|
- }else {
|
|
|
|
|
- subCount=Math.subtractExact(infusionHistory.getPcaInvalidCount(), Optional.ofNullable(anal.getPcaInvalidCount()).orElse(0));
|
|
|
|
|
- }
|
|
|
|
|
- if(subCount>anal.getThreshold()){
|
|
|
|
|
- log.info("设备:{}镇痛不足--延迟判定",deviceId);
|
|
|
|
|
- //触发阈值,设置为镇痛不足
|
|
|
|
|
- if(!Boolean.TRUE.equals(infusionHistory.getWarnAnalgesicPoor())){
|
|
|
|
|
- infusionHistoryService.update(new UpdateWrapper<BusInfusionHistoryEntity>().lambda().eq(BusInfusionHistoryEntity::getId,infusionHistory.getId())
|
|
|
|
|
- .set(BusInfusionHistoryEntity::getWarnAnalgesicPoor,true));
|
|
|
|
|
- //报警/提醒缓存重置
|
|
|
|
|
- deviceRegistry.getOperator(deviceId).setAlarmOrWarn(null);
|
|
|
|
|
-
|
|
|
|
|
- //发布推送
|
|
|
|
|
- wsPublishUtils.publishPatientMonitor(infusionHistory.getPatientCode(),infusionHistory.getTenantId());
|
|
|
|
|
-
|
|
|
|
|
- //记录镇痛不足报警
|
|
|
|
|
- Date uploadTime=new Date(anal.getTimestamp().getTime()+anal.getUnit().toMillis(anal.getTimeout()));
|
|
|
|
|
- BusDeviceAlarmEntity alarm = BusDeviceAlarmEntity.insufficient(anal.getDeviceId(),anal.getInfusionId(),anal.getHistoryId(),anal.getTenantId(),uploadTime);
|
|
|
|
|
- alarmService.save(alarm);
|
|
|
|
|
- }
|
|
|
|
|
- if(lastNoneAnal!=null){
|
|
|
|
|
- noneAnalDelayedQueue.remove(lastNoneAnal);
|
|
|
|
|
- }
|
|
|
|
|
- }else {
|
|
|
|
|
- //没有触发阈值,发入镇痛消失处理
|
|
|
|
|
- FunctionAnalConfig config = this.getConfig().as(FunctionAnalConfig.class);
|
|
|
|
|
- lastNoneAnal = NoneAnalEntity.builder()
|
|
|
|
|
- .deviceId(anal.getDeviceId())
|
|
|
|
|
- .tenantId(anal.getTenantId())
|
|
|
|
|
- .timeout(config.getDisappearTime())
|
|
|
|
|
- .unit(TimeUnit.MINUTES)
|
|
|
|
|
- .infusionId(anal.getInfusionId())
|
|
|
|
|
- .historyId(anal.getHistoryId())
|
|
|
|
|
- .timestamp(new Date())
|
|
|
|
|
- .build();
|
|
|
|
|
- redissonUtil.offerQueue(noneAnalDelayedQueue,lastNoneAnal,lastNoneAnal.getTimeout(),lastNoneAnal.getUnit());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 描述: 镇痛消失处理
|
|
* 描述: 镇痛消失处理
|
|
|
* @author lifang
|
|
* @author lifang
|