feat: 定时任务更新阿里数据补偿功能
							parent
							
								
									378174251d
								
							
						
					
					
						commit
						eed301b50f
					
				| @ -1,49 +1,49 @@ | ||||
| //package com.glxp.udidl.admin.thread;
 | ||||
| //
 | ||||
| //import com.glxp.udidl.admin.dao.info.ScheduledMapper;
 | ||||
| //import com.glxp.udidl.admin.entity.info.ScheduledEntity;
 | ||||
| //import com.glxp.udidl.admin.req.info.ScheduledRequest;
 | ||||
| //import com.glxp.udidl.admin.service.chsapi.ChsYbHcxxService;
 | ||||
| //import com.glxp.udidl.admin.service.collect.ThirdAliDrugService;
 | ||||
| //import org.slf4j.Logger;
 | ||||
| //import org.slf4j.LoggerFactory;
 | ||||
| //import org.springframework.scheduling.annotation.EnableScheduling;
 | ||||
| //import org.springframework.scheduling.annotation.SchedulingConfigurer;
 | ||||
| //import org.springframework.scheduling.config.ScheduledTaskRegistrar;
 | ||||
| //import org.springframework.scheduling.support.CronTrigger;
 | ||||
| //import org.springframework.stereotype.Component;
 | ||||
| //
 | ||||
| //import javax.annotation.Resource;
 | ||||
| //
 | ||||
| //@Component
 | ||||
| //@EnableScheduling
 | ||||
| //public class ThirdAliDrugTask implements SchedulingConfigurer {
 | ||||
| //
 | ||||
| //    @Resource
 | ||||
| //    private ScheduledMapper scheduledDao;
 | ||||
| //
 | ||||
| //    @Resource
 | ||||
| //    private ThirdAliDrugService thirdAliDrugService;
 | ||||
| //
 | ||||
| //    final Logger logger = LoggerFactory.getLogger(ThirdAliDrugTask.class);
 | ||||
| //
 | ||||
| //    @Override
 | ||||
| //    public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
 | ||||
| //        scheduledTaskRegistrar.addTriggerTask(() -> process(),
 | ||||
| //                triggerContext -> {
 | ||||
| //                    ScheduledRequest scheduledRequest = new ScheduledRequest();
 | ||||
| //                    scheduledRequest.setCronName("thirdAliDrugTask");
 | ||||
| //                    ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
 | ||||
| //                    String cron = scheduledEntity.getCron();
 | ||||
| //                    if (cron.isEmpty()) {
 | ||||
| //                        logger.error("cron is null");
 | ||||
| //                    }
 | ||||
| //                    return new CronTrigger(cron).nextExecutionTime(triggerContext);
 | ||||
| //                });
 | ||||
| //    }
 | ||||
| //
 | ||||
| //    private void process() {
 | ||||
| //        System.out.println("开始执行更新阿里健康数据");
 | ||||
| //        thirdAliDrugService.updateThirdAliDrugTask();
 | ||||
| //    }
 | ||||
| //}
 | ||||
| package com.glxp.udidl.admin.thread; | ||||
| 
 | ||||
| import com.glxp.udidl.admin.dao.info.ScheduledMapper; | ||||
| import com.glxp.udidl.admin.entity.info.ScheduledEntity; | ||||
| import com.glxp.udidl.admin.req.info.ScheduledRequest; | ||||
| import com.glxp.udidl.admin.service.chsapi.ChsYbHcxxService; | ||||
| import com.glxp.udidl.admin.service.collect.ThirdAliDrugService; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.scheduling.annotation.EnableScheduling; | ||||
| import org.springframework.scheduling.annotation.SchedulingConfigurer; | ||||
| import org.springframework.scheduling.config.ScheduledTaskRegistrar; | ||||
| import org.springframework.scheduling.support.CronTrigger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import javax.annotation.Resource; | ||||
| 
 | ||||
| @Component | ||||
| @EnableScheduling | ||||
| public class ThirdAliDrugTask implements SchedulingConfigurer { | ||||
| 
 | ||||
|     @Resource | ||||
|     private ScheduledMapper scheduledDao; | ||||
| 
 | ||||
|     @Resource | ||||
|     private ThirdAliDrugService thirdAliDrugService; | ||||
| 
 | ||||
|     final Logger logger = LoggerFactory.getLogger(ThirdAliDrugTask.class); | ||||
| 
 | ||||
|     @Override | ||||
|     public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { | ||||
|         scheduledTaskRegistrar.addTriggerTask(() -> process(), | ||||
|                 triggerContext -> { | ||||
|                     ScheduledRequest scheduledRequest = new ScheduledRequest(); | ||||
|                     scheduledRequest.setCronName("thirdAliDrugTask"); | ||||
|                     ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest); | ||||
|                     String cron = scheduledEntity.getCron(); | ||||
|                     if (cron.isEmpty()) { | ||||
|                         logger.error("cron is null"); | ||||
|                     } | ||||
|                     return new CronTrigger(cron).nextExecutionTime(triggerContext); | ||||
|                 }); | ||||
|     } | ||||
| 
 | ||||
|     private void process() { | ||||
|         System.out.println("开始执行更新阿里健康数据"); | ||||
|         thirdAliDrugService.updateThirdAliDrugTask(); | ||||
|     } | ||||
| } | ||||
|  | ||||
					Loading…
					
					
				
		Reference in New Issue