|
|
@@ -1,6 +1,8 @@
|
|
|
package com.nb.web.service.bus.hospital;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
@@ -9,6 +11,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.nb.web.api.bean.Script;
|
|
|
import com.nb.web.api.entity.BusHospitalConfigEntity;
|
|
|
import com.nb.web.api.entity.BusInfusionHistoryEntity;
|
|
|
+import com.nb.web.api.enums.DeviceStatusEnum;
|
|
|
import com.nb.web.service.bus.entity.*;
|
|
|
import com.nb.web.service.bus.hospital.config.*;
|
|
|
import com.nb.web.service.bus.hospital.config.bean.*;
|
|
|
@@ -61,8 +64,18 @@ public class HospitalManager {
|
|
|
|
|
|
private HisUpdateEntity updateConfig;
|
|
|
|
|
|
- private ScheduledExecutorService singleThreadEventExecutor= Executors.newSingleThreadScheduledExecutor();
|
|
|
- private ScheduledFuture<?> schedule=null;
|
|
|
+ /**
|
|
|
+ * 从his拉取信息的线程
|
|
|
+ */
|
|
|
+ private ScheduledExecutorService singleHisExecutor = Executors.newSingleThreadScheduledExecutor();
|
|
|
+
|
|
|
+ private ScheduledFuture<?> hisSchedule =null;
|
|
|
+ /**
|
|
|
+ * 更新补偿设备状态的线程
|
|
|
+ */
|
|
|
+ private ScheduledExecutorService singleOffsetsDeviceExecutor = Executors.newSingleThreadScheduledExecutor();
|
|
|
+
|
|
|
+
|
|
|
private LocalBusHospitalService hospitalService;
|
|
|
|
|
|
private LocalBusPatientService patientService;
|
|
|
@@ -83,6 +96,24 @@ public class HospitalManager {
|
|
|
this.codeHandler=new HospitalPatientCodeHandler(storage,hospitalId);
|
|
|
this.infusionHistoryService=SpringUtil.getBean(LocalBusInfusionHistoryService.class);
|
|
|
init(configStorageManager);
|
|
|
+
|
|
|
+ singleOffsetsDeviceExecutor.scheduleWithFixedDelay(()->{
|
|
|
+ List<BusInfusionHistoryEntity> infusions = infusionHistoryService.list(new QueryWrapper<BusInfusionHistoryEntity>()
|
|
|
+ .lambda()
|
|
|
+ .eq(BusInfusionHistoryEntity::getFinished, false)
|
|
|
+ .eq(BusInfusionHistoryEntity::getIsUndo, false));
|
|
|
+ infusions
|
|
|
+ .parallelStream()
|
|
|
+ .forEach(infusionInfo->{
|
|
|
+ BusDeviceRunningEntity source = BeanUtil.toBean(infusionInfo, BusDeviceRunningEntity.class);
|
|
|
+ source.setInfusionId(infusionInfo.getId());
|
|
|
+ autoUndoConfigHandler.handler(source);
|
|
|
+ finishMonitorConfigHandler.handler(source);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ 0, Math.addExact(30,RandomUtil.randomInt(0,60)),TimeUnit.MINUTES);
|
|
|
}
|
|
|
|
|
|
private void init(ConfigStorageManager configStorageManager){
|
|
|
@@ -206,15 +237,15 @@ public class HospitalManager {
|
|
|
||!Boolean.TRUE.equals(updateConfig.getEnable())
|
|
|
||null==updateConfig.getInterval()
|
|
|
||updateConfig.getInterval()<0){
|
|
|
- if(schedule!=null&&!schedule.isCancelled()){
|
|
|
+ if(hisSchedule !=null&&!hisSchedule.isCancelled()){
|
|
|
//如果有定时任务正在运行,则关闭
|
|
|
- schedule.cancel(true);
|
|
|
+ hisSchedule.cancel(true);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
- schedule = singleThreadEventExecutor.schedule(() -> {
|
|
|
+ hisSchedule = singleHisExecutor.schedule(() -> {
|
|
|
scheduleHis();
|
|
|
- singleThreadEventExecutor.schedule(this::scheduleHis, updateConfig.getInterval(), TimeUnit.MINUTES);
|
|
|
+ singleHisExecutor.schedule(this::scheduleHis, updateConfig.getInterval(), TimeUnit.MINUTES);
|
|
|
}, updateConfig.getInterval(), TimeUnit.MINUTES);
|
|
|
|
|
|
}
|