|
|
@@ -2,6 +2,7 @@ package com.nb.bus.hospital.config;
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.nb.bus.hospital.config.bean.FunctionAnalConfig;
|
|
|
@@ -15,6 +16,7 @@ import com.nb.bus.utils.WsPublishUtils;
|
|
|
import com.nb.common.cache.ConfigStorage;
|
|
|
import com.nb.common.cache.value.Value;
|
|
|
import com.nb.common.entity.AbstractMsgId;
|
|
|
+import com.nb.common.util.ExceptionUtil;
|
|
|
import com.nb.common.util.RedissonUtil;
|
|
|
import lombok.Builder;
|
|
|
import lombok.Data;
|
|
|
@@ -107,11 +109,13 @@ public class HospitalFunctionAnalConfigHandler extends AbstractHospitalConfigHan
|
|
|
}
|
|
|
|
|
|
Long startTime=endTime-TimeUnit.MINUTES.toMillis(insufficientTime);
|
|
|
-
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
+ long delStartTime =now - TimeUnit.DAYS.toMillis(7);
|
|
|
//获取该次输注过程中,以当前输注上传时间为结束时间,以判定时间区间为区间范围的时间窗口数据
|
|
|
Collection<Object> valueRange = redissonUtil.getValueRange(analSortKey, startTime, true, endTime, true);
|
|
|
if(CollUtil.isEmpty(valueRange)){
|
|
|
- log.warn("设备【{}】判定低输注时,从缓存获取得分数据为空,设备信息【{}】",source.getId(), JSONUtil.toJsonStr(source));
|
|
|
+ //缓存中只保留7天的历史数据
|
|
|
+ log.warn("消息【{}】,设备【{}】判定低输注时,从缓存获取得分数据为空,设备信息【{}】",source.getMsgId(),source.getId(), JSONUtil.toJsonStr(source));
|
|
|
return;
|
|
|
}
|
|
|
List<AnalEntity> anals = valueRange.stream().map(Value::simple).map(value -> value.as(AnalEntity.class)).collect(Collectors.toList());
|
|
|
@@ -130,7 +134,7 @@ public class HospitalFunctionAnalConfigHandler extends AbstractHospitalConfigHan
|
|
|
subCount=Math.subtractExact(source.getPcaInvalidCount(), Optional.ofNullable(firstAnal.getPcaInvalidCount()).orElse(0));
|
|
|
}
|
|
|
if(subCount>=analConfig.getInsufficientCount()){
|
|
|
- log.info("设备:{}镇痛不足--实时判定",source.getDeviceId());
|
|
|
+ log.info("消息【{}】,设备【{}】由引起镇痛不足--实时判定",source.getMsgId(),source.getDeviceId());
|
|
|
source.setWarnAnalgesicPoor(true);
|
|
|
//镇痛消失延迟队列
|
|
|
RDelayedQueue<AbstractMsgId> noneAnalDelayedQueue = redissonUtil.getDelayedQueue("none-" + getId(), e -> {
|
|
|
@@ -143,6 +147,7 @@ public class HospitalFunctionAnalConfigHandler extends AbstractHospitalConfigHan
|
|
|
.tenantId(firstAnal.getTenantId())
|
|
|
.timeout(analConfig.getDisappearTime())
|
|
|
.unit(TimeUnit.MINUTES)
|
|
|
+ .iotMsgId(source.getMsgId())
|
|
|
.infusionId(firstAnal.getInfusionId())
|
|
|
.historyId(firstAnal.getHistoryId())
|
|
|
.timestamp(new Date())
|
|
|
@@ -150,14 +155,20 @@ public class HospitalFunctionAnalConfigHandler extends AbstractHospitalConfigHan
|
|
|
redissonUtil.offerQueue(noneAnalDelayedQueue,noneAnal,noneAnal.getTimeout(),noneAnal.getUnit());
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
- log.debug("镇痛不足缓存解析失败,设备号【{}】",source.getDeviceId(),e);
|
|
|
+ log.debug("消息【{}】,镇痛不足缓存解析失败,设备号【{}】",source.getMsgId(),source.getDeviceId(), ExceptionUtil.getExceptionMsg(e));
|
|
|
}
|
|
|
|
|
|
+ int delCount = redissonUtil.removeRangeScore(analSortKey, delStartTime, true, startTime, false);
|
|
|
+ if(delCount!=0){
|
|
|
+ log.info("消息【{}】,设备【{}】清除了【{}】-【{}】时间段内【{}】条PCA缓存数据",source.getMsgId(),source.getDeviceId(),new Date(delStartTime),new Date(now),delCount);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 描述: 镇痛消失处理
|
|
|
+ * 取消镇痛时,谨遵询谁引起谁取消的原则
|
|
|
+ * 即根据阿里云所发送的消息id进行判定
|
|
|
* @author lifang
|
|
|
* @date 2022/5/30 21:09
|
|
|
* @param noneAnal
|
|
|
@@ -172,9 +183,12 @@ public class HospitalFunctionAnalConfigHandler extends AbstractHospitalConfigHan
|
|
|
}
|
|
|
//镇痛不足取消
|
|
|
if(Boolean.TRUE.equals(infusionHistory.getWarnAnalgesicPoor())){
|
|
|
- log.info("设备:{}取消镇痛不足",deviceId);
|
|
|
+ log.info("消息【{}】,设备【{}】取消镇痛不足",noneAnal.getIotMsgId(),deviceId);
|
|
|
+ //那条消息引起的镇痛不足,就由那条消息的取消镇痛不足任务来结束
|
|
|
infusionHistoryService.update(new UpdateWrapper<BusInfusionHistoryEntity>().lambda()
|
|
|
.eq(BusInfusionHistoryEntity::getId,infusionHistory.getId())
|
|
|
+ .eq(BusInfusionHistoryEntity::getWarnAnalgesicPoor,true)
|
|
|
+ .eq(BusInfusionHistoryEntity::getMsgId,noneAnal.getIotMsgId())
|
|
|
.set(BusInfusionHistoryEntity::getWarnAnalgesicPoor,false));
|
|
|
deviceRegistry.getOperator(deviceId).setAlarmOrWarn(null);
|
|
|
//发布推送
|
|
|
@@ -209,6 +223,7 @@ public class HospitalFunctionAnalConfigHandler extends AbstractHospitalConfigHan
|
|
|
private String historyId;
|
|
|
private Date timestamp;
|
|
|
private String infusionId;
|
|
|
+ private String iotMsgId;
|
|
|
}
|
|
|
|
|
|
}
|