StartCommand.java 1.07 KB
package com.bsth;


import com.bsth.server_rs.thread.RfidCardInfoPersistenceThread;
import com.bsth.service.Line2SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;


/**
 * 随应用启动运行
 * @author PanZhao
 *
 */
@Component
public class StartCommand implements CommandLineRunner{

	@Autowired
	Line2SystemService line2SystemService;

	@Autowired
	RfidCardInfoPersistenceThread rfidCardInfoPersistenceThread;

	@Override
	public void run(String... arg0){
		
		try {
			//将增量的线路load到对照清单
			line2SystemService.loadByLineInfo();

			ScheduledExecutorService sexec = Application.mainServices;
			//定时将人车卡数据入库
			sexec.scheduleWithFixedDelay(rfidCardInfoPersistenceThread, 120, 60 * 5, TimeUnit.SECONDS);
			//OldWSClient.returnCCInfo();
			//OldWSClient.getCurrentDayPlan();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}