| | |
| | | package com.ltkj.web.config.timer; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.ltkj.framework.datasource.DynamicDataSourceContextHolder; |
| | | import com.ltkj.hosp.domain.TjJcycxm; |
| | | import com.ltkj.hosp.mapper.TestMapper; |
| | | import com.ltkj.hosp.service.*; |
| | | import com.ltkj.hosp.sqlDomain.LtkjExamJcbgd; |
| | | import com.ltkj.hosp.sqlDomain.LtkjExamJcsqd; |
| | | import com.ltkj.hosp.sqlDomain.LtkjHybgd; |
| | | import com.ltkj.hosp.sqlDomain.LtkjHysqd; |
| | | import com.ltkj.hosp.sqlDomain.*; |
| | | import com.ltkj.system.service.ISysConfigService; |
| | | import jodd.util.StringUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Profile; |
| | |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | @Profile("!dev") |
| | | @Profile("!dev & !prod & !test") |
| | | public class DefaultScheduled { |
| | | |
| | | |
| | |
| | | private TestMapper testMapper; |
| | | @Resource |
| | | private TjAsyncService asyncService; |
| | | @Autowired |
| | | private TjJcycxmService jcycxmService; |
| | | @Autowired |
| | | private AwsService awsService; |
| | | |
| | | |
| | | private final ReentrantLock reentrantLock = new ReentrantLock(); |
| | |
| | | private void exec() { |
| | | String dsqkssj = configService.selectConfigByKey("dsqkssj"); |
| | | String dsqjssj = configService.selectConfigByKey("dsqjssj"); |
| | | String yqbm = configService.selectConfigByKey("common_api_service_hospbm"); |
| | | String dqyyyqbm = configService.selectConfigByKey("dqyyyqbm"); |
| | | boolean panduandangqianshijian = panduandangqianshijian(dsqkssj, dsqjssj); |
| | | log.info("定时器自动同步检验检查结果"); |
| | | log.info("当前时间是否在 " + dsqkssj + " 点到 " + dsqjssj + " 点之间: " + panduandangqianshijian); |
| | | String dsrwsjjg = configService.selectConfigByKey("dsrwsjjg"); |
| | | boolean lock = reentrantLock.tryLock(); |
| | |
| | | if (null != jy && !jy.isEmpty()) { |
| | | log.info("同步检验人员 执行数量->{}", jy.size()); |
| | | for (String s : jy) { |
| | | // TjOrder order = orderService.getOrderByTjNum(s); |
| | | extractedjianyan(s); |
| | | extractedjianyan(s,dqyyyqbm); |
| | | } |
| | | } |
| | | |
| | |
| | | if (null != jc && !jc.isEmpty()) { |
| | | log.info("同步检查人员 执行数量->{}", jc.size()); |
| | | for (String s : jc) { |
| | | // TjOrder order = orderService.getOrderByTjNum(s); |
| | | extractedjiancha(s); |
| | | extractedjiancha(s,dqyyyqbm); |
| | | } |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | |
| | | Integer object = (Integer) map.get("total"); |
| | | log.info("执行存储过程后出参->{}", object); |
| | | if (null != object && object.equals(1)) { |
| | | if (null != jc && !jc.isEmpty()) { |
| | | for (String s : jc) { |
| | | jcycxmService.deletedByTjh(s); |
| | | List<LtkjExamJcsqd> list = jcsqdService.getLtkjJcsqdByTjh(s); |
| | | if(null !=list && !list.isEmpty()){ |
| | | for (LtkjExamJcsqd jcsqd : list) { |
| | | if(StringUtil.isNotBlank(jcsqd.getJgzt())){ |
| | | String[] split = jcsqd.getJgzt().replaceAll("\n", "").split("。|;|;"); |
| | | for (String jg : split) { |
| | | if(StringUtil.isNotBlank(jg) && !jg.contains("未见异常") |
| | | && !jg.contains("未见明显异常") && !jg.contains("未见占位") && !jg.contains("未见") |
| | | && !jg.contains("未见明显")&& !jg.contains("正常")&& !jg.contains("双侧椎间孔无狭窄")){ |
| | | TjJcycxm jcycxm=new TjJcycxm(); |
| | | jcycxm.setTjh(s); |
| | | jcycxm.setYqid(yqbm); |
| | | String[] split1 = jcsqd.getJcxmid().split(";"); |
| | | jcycxm.setProId(split1[0]); |
| | | jcycxm.setProName(jcsqd.getJcxmmc()); |
| | | jcycxm.setCreateTime(new Date()); |
| | | jcycxm.setJcjg(jg); |
| | | jcycxmService.save(jcycxm); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | long end = System.currentTimeMillis(); |
| | | log.info("同步结束 耗时:{}秒", (end - start) / 1000); |
| | | // 动态获取下次任务的间隔 |
| | |
| | | } catch (Exception e) { |
| | | scheduleNextTask(Long.parseLong(dsrwsjjg)); |
| | | log.error("定时器执行报错"); |
| | | e.printStackTrace(); |
| | | log.error(String.valueOf(e)); |
| | | // e.printStackTrace(); |
| | | } finally { |
| | | reentrantLock.unlock(); |
| | | } |
| | |
| | | return time.isAfter(LocalTime.of(Integer.parseInt(kssj), 0)) && time.isBefore(LocalTime.of(Integer.parseInt(jssj), 0)); |
| | | } |
| | | |
| | | private void extractedjianyan(String s) { |
| | | private void extractedjianyan(String s,String dqyyyqbm) { |
| | | try { |
| | | List<LtkjHysqd> hysqdList = testMapper.getCcXZxYyLtkjHysqdByLisVi(s); |
| | | List<Aws> awsList = testMapper.getWsxmLtkjHysqdByLisViBySLAVEWS(s); |
| | | if(null !=awsList && !awsList.isEmpty()){ |
| | | log.info(awsList.toString()); |
| | | testMapper.delWsxmjg(s); |
| | | log.info("删除外送项目成功"); |
| | | awsService.saveBatch(awsList); |
| | | log.info("保存外送项目成功"); |
| | | } |
| | | List<LtkjHysqd> wssq = testMapper.getWsxmLtkjHysqdByLisVi(s); |
| | | if(null !=wssq && !wssq.isEmpty()){ |
| | | for (LtkjHysqd hysqd : wssq) { |
| | | LtkjHysqd jybgid = ltkjHysqdService.getLtkjHysqdByTjhAndTmh(hysqd.getTjh(), hysqd.getTmh()); |
| | | if (null != jybgid) { |
| | | ltkjHysqdService.deletedLtkjHysqdByTjhAndTmh(hysqd.getTjh(), hysqd.getTmh()); |
| | | ltkjHybgdService.deletedLtkjHybgdByTjhAndTmh(hysqd.getTmh()); |
| | | } |
| | | if (ltkjHysqdService.save(hysqd)) { |
| | | List<LtkjHybgd> wsbg = testMapper.getWsxmLtkjHybgdByLisVi(s); |
| | | ltkjHybgdService.saveBatch(wsbg); |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<LtkjHysqd> hysqdList = testMapper.getCcXZxYyLtkjHysqdByLisVi(s,dqyyyqbm); |
| | | if (null != hysqdList && !hysqdList.isEmpty()) { |
| | | for (LtkjHysqd hysqd : hysqdList) { |
| | | LtkjHysqd jybgid = ltkjHysqdService.getLtkjHysqdByTjhAndTmh(hysqd.getTjh(), hysqd.getTmh()); |
| | |
| | | } |
| | | if (ltkjHysqdService.save(hysqd)) { |
| | | List<LtkjHybgd> hybgdList = testMapper.getCcXZxYyLtkjHybgdByLisVi(hysqd.getTmh()); |
| | | // List<LtkjHybgd> wsbg = testMapper.getWsxmLtkjHybgdByLisVi(s); |
| | | // if(null !=wsbg && !wsbg.isEmpty())hybgdList.addAll(wsbg); |
| | | ltkjHybgdService.saveBatch(hybgdList); |
| | | } |
| | | } |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | log.info("同步检验数据失败"); |
| | | throw new RuntimeException(e); |
| | | // throw new RuntimeException(e); |
| | | log.error(String.valueOf(e)); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | private void extractedjiancha(String s) { |
| | | private void extractedjiancha(String s,String dqyyyqbm) { |
| | | |
| | | try { |
| | | List<LtkjExamJcsqd> jcsqdList = testMapper.getCcXZxYyPacsLtkjExamJcsqd(s); |
| | | List<LtkjExamJcsqd> jcsqdList = testMapper.getCcXZxYyPacsLtkjExamJcsqd(s,dqyyyqbm); |
| | | if (null != jcsqdList && !jcsqdList.isEmpty()) { |
| | | DynamicDataSourceContextHolder.clearDataSourceType(); |
| | | jcsqdService.deletedLtkjJcsqdByTjhAndTmh(s); |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | log.info("同步检查数据失败"); |
| | | throw new RuntimeException(e); |
| | | // throw new RuntimeException(e); |
| | | log.error(String.valueOf(e)); |
| | | } |
| | | } |
| | | } |