| | |
| | | |
| | | 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; |
| | |
| | | import com.ltkj.hosp.service.*; |
| | | import com.ltkj.hosp.sqlDomain.*; |
| | | import com.ltkj.system.service.ISysConfigService; |
| | | import com.ltkj.web.controller.system.SysConfigController; |
| | | import jodd.util.StringUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private IDictHospService dictHospService; |
| | | @Autowired |
| | | private DataSourceConfig dataSourceConfig; |
| | | @Autowired |
| | | private SysConfigController configController; |
| | | |
| | | private final Map<String, ReentrantLock> lockMap = new ConcurrentHashMap<>(); |
| | | |
| | |
| | | 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(); |
| | |
| | | // 将该用户ID添加到已调度任务集合中 |
| | | scheduledTasks.add(dictHosp.getCode()); |
| | | // 创建定时任务,任务将在15分钟后执行 |
| | | taskScheduler.schedule(() -> { |
| | | /* taskScheduler.schedule(() -> { |
| | | try { |
| | | // 执行任务的超时控制 |
| | | taskScheduler.schedule(() -> { |
| | | executeTask(dictHosp); |
| | | }, Instant.now()); |
| | | |
| | | } catch (Exception e) { |
| | | log.error("创建任务时发生异常:{}", e.getMessage()); |
| | | } |
| | | }, Instant.now().plus(15, ChronoUnit.MINUTES));*/ |
| | | log.info("任务创建成功 ->{}",dictHosp.getCode()); |
| | | // 执行任务的超时控制 |
| | | taskScheduler.schedule(() -> { |
| | | executeTask(dictHosp); |
| | | }, Instant.now().plus(15, ChronoUnit.MINUTES)); |
| | | } |
| | | |
| | |
| | | boolean panduandangqianshijian = panduandangqianshijian(dsqkssj, dsqjssj); |
| | | if (!panduandangqianshijian) { |
| | | if (lock) { |
| | | log.info("任务开始执行时间 -> {}", dateTimeFormat.format(new Date())); |
| | | log.info("{}任务开始执行时间 -> {}",dictHosp.getCode(), dateTimeFormat.format(new Date())); |
| | | long start = System.currentTimeMillis(); |
| | | // 查询任务数据 |
| | | log.info("开始执行同步 执行院区->{}", dictHosp.getCode()); |
| | |
| | | |
| | | |
| | | if (null != jy && !jy.isEmpty()) { |
| | | log.info("同步检验人员 执行数量->{}", jy.size()); |
| | | log.info("{}同步检验人员 执行数量->{}{}",dictHosp.getCode(), jy.size(),JSONUtil.toJsonStr(jy)); |
| | | for (String s : jy) { |
| | | extractedjianyan(s,dictHosp.getCode()); |
| | | } |
| | |
| | | |
| | | |
| | | if (null != jc && !jc.isEmpty()) { |
| | | log.info("同步检查人员 执行数量->{}", jc.size()); |
| | | log.info("{}同步检查人员 执行数量->{}{}",dictHosp.getCode(), jc.size(),JSONUtil.toJsonStr(jc)); |
| | | for (String s : jc) { |
| | | extractedjiancha(s,dictHosp.getCode()); |
| | | } |
| | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | testMapper.tjplUpdateDetatilByVi(map); |
| | | Integer object = (Integer) map.get("total"); |
| | | log.info("执行存储过程后出参->{}", object); |
| | | log.info("{}执行存储过程后出参->{}",dictHosp.getCode(), object); |
| | | if (null != object && object.equals(1)) { |
| | | if (null != jc && !jc.isEmpty()) { |
| | | for (String s : jc) { |
| | |
| | | if(StringUtil.isBlank(regex)) regex= "。|;|;|,|,"; |
| | | String[] split = jcsqd.getJgzt().replaceAll("\n", "").split(regex); |
| | | for (String jg : split) { |
| | | if(StringUtil.isNotBlank(jg) && !jg.contains("未见异常") |
| | | boolean b = configController.apiJcycpdgjz(jg); |
| | | if(!b){ |
| | | TjJcycxm jcycxm=new TjJcycxm(); |
| | | jcycxm.setTjh(s); |
| | | jcycxm.setYqid(dictHosp.getCode()); |
| | | String[] split1 = jcsqd.getJcxmid().split(";"); |
| | | jcycxm.setProId(split1[0]); |
| | | jcycxm.setProName(jcsqd.getJcxmmc()); |
| | | jcycxm.setCreateTime(new Date()); |
| | | jcycxm.setJcjg(jg); |
| | | jcycxmService.save(jcycxm); |
| | | } |
| | | /* if(StringUtil.isNotBlank(jg) && !jg.contains("未见异常") |
| | | && !jg.contains("未见明显异常") && !jg.contains("未见占位") && !jg.contains("未见") |
| | | && !jg.contains("未见明显")&& !jg.contains("正常")&& !jg.contains("双侧椎间孔无狭窄")&& !jg.contains("无殊")){ |
| | | TjJcycxm jcycxm=new TjJcycxm(); |
| | |
| | | jcycxm.setCreateTime(new Date()); |
| | | jcycxm.setJcjg(jg); |
| | | jcycxmService.save(jcycxm); |
| | | } |
| | | }*/ |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | long end = System.currentTimeMillis(); |
| | | log.info("同步结束 耗时:{}秒", (end - start) / 1000); |
| | | log.info("{}同步结束 耗时:{}秒",dictHosp.getCode(), (end - start) / 1000); |
| | | }else { |
| | | log.info("执行存储过程出参失败"); |
| | | } |
| | |
| | | |
| | | // 检查并添加新的用户任务 |
| | | public void checkAndAddNewTasks() { |
| | | 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); |
| | | log.info("检查并添加需要同步的医院列表:{}", JSONUtil.toJsonStr(hospList)); |
| | | hospList.forEach(this::createTask); |
| | | taskScheduler.schedule(this::checkAndAddNewTasks, Instant.now().plus(2, ChronoUnit.MINUTES)); |
| | | } |
| | |
| | | |
| | | try { |
| | | List<LtkjExamJcsqd> jcsqdList = testMapper.getCcXZxYyPacsLtkjExamJcsqd(s,hospId); |
| | | log.info("{}自动同步检查申请单数据:{}",hospId,JSONUtil.toJsonStr(jcsqdList)); |
| | | if (null != jcsqdList && !jcsqdList.isEmpty()) { |
| | | DynamicDataSourceContextHolder.clearDataSourceType(); |
| | | jcsqdService.deletedLtkjJcsqdByTjhAndTmh(s); |
| | | jcbgdService.deletedLtkjJcbgdByTjhAndTmh(s); |
| | | jcsqdService.saveBatch(jcsqdList); |
| | | List<LtkjExamJcbgd> jcbgdList = testMapper.getCcXZxYyPacsLtkjExamJcbgd(s,hospId); |
| | | DynamicDataSourceContextHolder.clearDataSourceType(); |
| | | // DynamicDataSourceContextHolder.clearDataSourceType(); |
| | | log.info("{}自动同步检查报告单数据:{}",hospId,JSONUtil.toJsonStr(jcbgdList)); |
| | | if (null != jcbgdList && !jcbgdList.isEmpty()) jcbgdService.saveBatch(jcbgdList); |
| | | DynamicDataSourceContextHolder.clearDataSourceType(); |
| | | } |