package QCM.Quartz; import QCM.JHY01.JHY0103.AddThirdInfo; import org.springframework.context.ApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import java.util.TimerTask; public class AutoBilletConsumeDataTask extends TimerTask { private ApplicationContext context; public AutoBilletConsumeDataTask(ServletContext servletContext) { context = WebApplicationContextUtils.getWebApplicationContext(servletContext); } private boolean fristStart = true;// 首次启动 AddThirdInfo ati; @Override public void run() { if (fristStart) { fristStart = false; try { // (建议不使用后台开线程循环的这种方式自动判定) ati = new AddThirdInfo();; } catch (Exception ex) { System.out.print("创建自动发送一体化接口失败:" + ex.getMessage()); } } try { ati.sendYTHWarrantyDetail(); ati.sendCancelYTHWarrantyDetail(); } catch (Exception ex) { ex.printStackTrace(); } } }