ApplicationEvent.java 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package com.yihu.wlyy.event;
  2. import com.yihu.wlyy.job.QuartzHelper;
  3. import com.yihu.wlyy.job.SignEndJob;
  4. import com.yihu.wlyy.util.SystemConf;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.context.ApplicationListener;
  7. import org.springframework.context.event.ContextRefreshedEvent;
  8. import org.springframework.stereotype.Service;
  9. import java.util.HashMap;
  10. /**
  11. * Created by lyr-pc on 2017/3/10.
  12. */
  13. @Service
  14. public class ApplicationEvent implements ApplicationListener<ContextRefreshedEvent>{
  15. @Autowired
  16. QuartzHelper quartzHelper;
  17. @Override
  18. public void onApplicationEvent(ContextRefreshedEvent ContextRefreshedEvent) {
  19. try {
  20. // 启动签约到期处理JOB
  21. if (!quartzHelper.isExistJob("sign_end_job")) {
  22. String trigger = SystemConf.getInstance().getSystemProperties().getProperty("sign_end_job_trigger");
  23. quartzHelper.addJob(SignEndJob.class, trigger, "sign_end_job", new HashMap<String, Object>());
  24. System.out.println("sign end job start success");
  25. } else {
  26. System.out.println("sign end job exist");
  27. }
  28. } catch (Exception e) {
  29. System.out.println("sign end job start failed");
  30. }
  31. }
  32. }