package org.springblade.code.Scheduling;
|
|
import com.vci.mdm.service.CodeDuckingServiceI;
|
import com.vci.starter.web.enumpck.BooleanEnum;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.PostConstruct;
|
import javax.annotation.Resource;
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
|
/**
|
* 集成任务定时器
|
* 插入dockingtask中
|
* 从dockingtask中取出来数据,推送出去的操作
|
*/
|
@Component
|
public class DockingScheduling {
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
@Resource
|
private CodeDuckingServiceI codeDuckingServiceI;
|
|
@Value("${docking.insertCache2:false}")
|
public boolean INSERT_CACHE2;
|
|
/**
|
* 是否初始化完成了
|
*/
|
public static volatile String FINISH_INIT = "false";
|
|
/**
|
* 在初始化完成后执行
|
*/
|
@PostConstruct()
|
public void onInit(){
|
FINISH_INIT = "true";
|
}
|
|
//默认每分钟执行方法
|
@Scheduled(cron = "${docking.cron:0 0/10 * * * ?}")
|
public void scheduled() {
|
if(INSERT_CACHE2 && BooleanEnum.TRUE.getValue().equalsIgnoreCase(FINISH_INIT)) {
|
codeDuckingServiceI.DockingScheduing();
|
SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.");
|
String time = formatter.format(new Date());
|
String outinfo = "============在 "+time+" 执行了主数据集成数据推送";
|
logger.info(outinfo);
|
}
|
}
|
}
|