ApplicationEvent.java 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.yihu.jw.event;
  2. import com.yihu.jw.job.InternetUpdateJob;
  3. import com.yihu.jw.job.PrescriptionStatusUpdateJob;
  4. import com.yihu.jw.job.QuartzHelper;
  5. import com.yihu.jw.util.SystemConf;
  6. import org.slf4j.Logger;
  7. import org.slf4j.LoggerFactory;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.context.ApplicationListener;
  10. import org.springframework.context.event.ContextRefreshedEvent;
  11. import org.springframework.stereotype.Service;
  12. import java.util.HashMap;
  13. /**
  14. * Created by zdm on 2017/3/10.
  15. */
  16. @Service
  17. public class ApplicationEvent implements ApplicationListener<ContextRefreshedEvent> {
  18. private Logger logger = LoggerFactory.getLogger(ApplicationEvent.class);
  19. @Autowired
  20. QuartzHelper quartzHelper;
  21. @Override
  22. public void onApplicationEvent(ContextRefreshedEvent ContextRefreshedEvent) {
  23. try {
  24. //互联网医院处方状态更新job
  25. if (!quartzHelper.isExistJob("prescriptionStatus_update_job")) {
  26. String trigger = SystemConf.getInstance().getSystemProperties().getProperty("prescriptionStatus_update_job");
  27. quartzHelper.addJob(PrescriptionStatusUpdateJob.class, trigger, "prescriptionStatus_update_job", new HashMap<String, Object>());
  28. logger.info("prescriptionStatus_update_job job success");
  29. } else {
  30. logger.info("prescriptionStatus_update_job job exist");
  31. }
  32. //互联网医院 监管平台上报 job
  33. if (!quartzHelper.isExistJob("internet_update_job")) {
  34. String trigger = SystemConf.getInstance().getSystemProperties().getProperty("internet_update_job");
  35. quartzHelper.addJob(InternetUpdateJob.class, trigger, "internet_update_job", new HashMap<String, Object>());
  36. logger.info("internet_update_job job success");
  37. } else {
  38. logger.info("internet_update_job job exist");
  39. }
  40. } catch (Exception e) {
  41. logger.info("followup_plan_remind job start failed");
  42. }
  43. }
  44. }