You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.8 KiB
Java
49 lines
1.8 KiB
Java
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.ChsYbHcxxGgService;
|
|
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 YbChsHcxxGgTask implements SchedulingConfigurer {
|
|
|
|
@Resource
|
|
private ScheduledMapper scheduledDao;
|
|
|
|
@Resource
|
|
private ChsYbHcxxGgService ybHcxxGgService;
|
|
|
|
final Logger logger = LoggerFactory.getLogger(DownloadProductInfoTask.class);
|
|
|
|
@Override
|
|
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
|
|
scheduledTaskRegistrar.addTriggerTask(() -> process(),
|
|
triggerContext -> {
|
|
ScheduledRequest scheduledRequest = new ScheduledRequest();
|
|
scheduledRequest.setCronName("ybChsHcxxGgTask");
|
|
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("开始执行更新医保数据YbHcxxGg");
|
|
ybHcxxGgService.updateForEachYbHcxxList();
|
|
}
|
|
}
|