| | |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ltkj.common.enums.DataSourceType; |
| | | import com.ltkj.db.DataSourceConfig; |
| | | import com.ltkj.db.DataSourceContextHolder; |
| | |
| | | public void init() { |
| | | DataSourceContextHolder.setDataSourceKey(DataSourceType.MASTER.name()); |
| | | // 获取所有需要同步日志的用户列表 |
| | | List<DictHosp> hospList = dictHospService.list(); |
| | | LambdaQueryWrapper<DictHosp> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(DictHosp::getIsAutoAsyncJg,1); |
| | | List<DictHosp> hospList = dictHospService.list(wrapper); |
| | | hospList.forEach(this::createTask); // 为每个用户创建任务 |
| | | // 定时检查是否有新的用户需要添加任务 |
| | | schedulePeriodicTaskCheck(); |
| | |
| | | // 检查并添加新的用户任务 |
| | | public void checkAndAddNewTasks() { |
| | | // 获取所有需要同步日志的用户列表 |
| | | List<DictHosp> hospList = dictHospService.list(); |
| | | LambdaQueryWrapper<DictHosp> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(DictHosp::getIsAutoAsyncJg,1); |
| | | List<DictHosp> hospList = dictHospService.list(wrapper); |
| | | hospList.forEach(this::createTask); |
| | | taskScheduler.schedule(this::checkAndAddNewTasks, Instant.now().plus(2, ChronoUnit.MINUTES)); |
| | | } |