32443100803d25818309f9482d0dc5b3d3a796cc.svn-base 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.sinosoft.common.quartz;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import org.apache.log4j.Logger;
  5. import org.quartz.Job;
  6. import org.quartz.JobDataMap;
  7. import org.quartz.JobExecutionContext;
  8. import org.quartz.JobExecutionException;
  9. import com.formaction.Utils;
  10. import com.sinosoft.common.Util;
  11. import com.sinosoft.lz.system.sms.dao.SmsDao;
  12. /**
  13. * 发送短信的定时任务,
  14. * @author zhuanghuiliang
  15. * @date 2015-10-13
  16. */
  17. public class Job4ShortMessage implements Job{
  18. private Logger log = Logger.getLogger(this.getClass());
  19. @Override
  20. public void execute(JobExecutionContext jobexecutioncontext) throws JobExecutionException {
  21. // TODO Auto-generated method stub
  22. System.out.println("start Job4ShortMessage **************************************************************");
  23. JobDataMap dataMap = jobexecutioncontext.getJobDetail().getJobDataMap();
  24. //取得参数
  25. String params = dataMap.getString("params");
  26. //要发送的消息
  27. String msg = Utils.getParameter("msg", params) == null ? "" : Utils.getParameter("msg", params);
  28. //接收短信的号码
  29. String numbers = Utils.getParameter("numbers", params) == null ? "" : Utils.getParameter("numbers", params);
  30. System.out.println("msg" + msg + ",numbers==" + numbers);
  31. //短信发送dao
  32. SmsDao sms = new SmsDao();
  33. //存放用户id的list
  34. List<String> list =new ArrayList<String>();
  35. for(int i = 0;i<numbers.split(",").length;i++){
  36. //将用户id放入list中
  37. list.add(numbers.split(",")[i]);
  38. }
  39. try {
  40. //发送短信
  41. sms.saveSms("发布通知单信息",list, Util.getDateTime("yyyy-MM-dd HH:mm:ss"),msg, "");
  42. } catch (ClassNotFoundException e) {
  43. // TODO Auto-generated catch block
  44. e.printStackTrace();
  45. log.error(e.getMessage(),e);
  46. }
  47. }
  48. }