12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package com.sinosoft.common.quartz;
- import java.util.ArrayList;
- import java.util.List;
- import org.apache.log4j.Logger;
- import org.quartz.Job;
- import org.quartz.JobDataMap;
- import org.quartz.JobExecutionContext;
- import org.quartz.JobExecutionException;
- import com.formaction.Utils;
- import com.sinosoft.common.Util;
- import com.sinosoft.lz.system.sms.dao.SmsDao;
- /**
- * 发送短信的定时任务,
- * @author zhuanghuiliang
- * @date 2015-10-13
- */
- public class Job4ShortMessage implements Job{
- private Logger log = Logger.getLogger(this.getClass());
- @Override
- public void execute(JobExecutionContext jobexecutioncontext) throws JobExecutionException {
- // TODO Auto-generated method stub
- System.out.println("start Job4ShortMessage **************************************************************");
- JobDataMap dataMap = jobexecutioncontext.getJobDetail().getJobDataMap();
- //取得参数
- String params = dataMap.getString("params");
- //要发送的消息
- String msg = Utils.getParameter("msg", params) == null ? "" : Utils.getParameter("msg", params);
- //接收短信的号码
- String numbers = Utils.getParameter("numbers", params) == null ? "" : Utils.getParameter("numbers", params);
- System.out.println("msg" + msg + ",numbers==" + numbers);
- //短信发送dao
- SmsDao sms = new SmsDao();
- //存放用户id的list
- List<String> list =new ArrayList<String>();
- for(int i = 0;i<numbers.split(",").length;i++){
- //将用户id放入list中
- list.add(numbers.split(",")[i]);
- }
- try {
- //发送短信
- sms.saveSms("发布通知单信息",list, Util.getDateTime("yyyy-MM-dd HH:mm:ss"),msg, "");
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- log.error(e.getMessage(),e);
- }
- }
- }
|