SignEndJob.java 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package com.yihu.wlyy.job;
  2. import com.yihu.wlyy.service.app.followup.FollowUpService;
  3. import com.yihu.wlyy.util.DateUtil;
  4. import org.quartz.Job;
  5. import org.quartz.JobExecutionContext;
  6. import org.quartz.JobExecutionException;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.jdbc.core.JdbcTemplate;
  9. import org.springframework.web.context.support.SpringBeanAutowiringSupport;
  10. import java.util.Calendar;
  11. import java.util.Date;
  12. /**
  13. * Created by lyr-pc on 2017/3/9.
  14. */
  15. public class SignEndJob implements Job {
  16. @Autowired
  17. JdbcTemplate jdbcTemplate;
  18. @Override
  19. public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
  20. try {
  21. System.out.println("sign end job start");
  22. SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
  23. Calendar today = Calendar.getInstance();
  24. today.add(Calendar.DATE, -1);
  25. String date = DateUtil.dateToStrShort(today.getTime());
  26. String start = date + " 00:00:00";
  27. String end = date + " 23:59:59";
  28. String sql = "update wlyy_sign_family set status = -4 where end >= ? and end <= ? and status > 0";
  29. int sucess = jdbcTemplate.update(sql, start, end);
  30. String sqlT = "update wlyy_doctor_team set del = '0' where del = '1' and code in (select team_code from wlyy_sign_family where end >= ? and end <= ? and status > 0)";
  31. String sqlTm = "update wlyy_doctor_team_member set del = '0' where del = '1' and team in (select team_code from wlyy_sign_family where end >= ? and end <= ? and status > 0)";
  32. int sucessT = jdbcTemplate.update(sqlT, start, end);
  33. int sucessTm = jdbcTemplate.update(sqlTm, start, end);
  34. System.out.println("sign end job end");
  35. } catch (Exception e) {
  36. e.printStackTrace();
  37. System.out.println("sign end job failed");
  38. }
  39. }
  40. }