alerttaskevent.java

来自「基于Sturts+Spring+Hibernate的一个高级销售管理系统。内容丰」· Java 代码 · 共 287 行

JAVA
287
字号
package com.yuanchung.sales.util;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimerTask;

import javax.servlet.http.HttpServletResponse;
import com.commerceware.cmpp.*;
import org.apache.log4j.Logger;
import com.yuanchung.sales.model.user.User;
import com.yuanchung.sales.service.taskevent.TaskEventMgr;

public class AlertTaskEvent extends TimerTask {
	private static Logger logger = Logger.getLogger(AlertTaskEvent.class);
	private HttpServletResponse response;
	private TaskEventMgr taskEventMgr;
	private User user;
	private int flag;
	private String type;
	private Date date;
	private static cmppe_result result;
	private static CMPP cmpp;
	private static conn_desc connDesc;

	/**
	 * @author 陆文邦
	 * @空构造函数;
	 * @date:2008-12-17;
	 */
	public AlertTaskEvent() {

	}

	/**
	 * @author 陆文邦
	 * @param user
	 * @param flag
	 * @param taskEventMgr
	 * @param response
	 * @param type
	 * @time 2008-11-17;
	 */
	public AlertTaskEvent(User user, int flag, TaskEventMgr taskEventMgr,
			HttpServletResponse response, String type) {
		this.user = user;
		this.flag = flag;
		this.taskEventMgr = taskEventMgr;
		this.response = response;
		this.type = type;
	}

	@Override
	public void run() {// 处理需要提醒的任务获取事件;
		int length = taskEventMgr.getTasksByNow(user.getId());
		if (length > 0) {
			// 发短信或者发邮件;
			String phone = user.getPhone();
		}
	}
		/*Date date = new Date();
		String dateStr = new SimpleDateFormat("yyyy-MM-dd").format(date);
		String timeStr = new SimpleDateFormat("HH:mm:ss").format(date);
		String hourStr = new SimpleDateFormat("HH").format(date);
		String minStr = new SimpleDateFormat("mm").format(date);
		StringBuffer realMinStr = new StringBuffer();
		System.out.println(hourStr);
		if (Integer.parseInt(hourStr) > 12) {
			realMinStr.append("下午 ").append(Integer.parseInt(hourStr) - 12)
					.append(":" + minStr);
		} else if (Integer.parseInt(hourStr) == 12) {
			realMinStr.append("下午 ").append(Integer.parseInt(hourStr)).append(
					":" + minStr);
		} else {
			realMinStr.append("上午 ").append(Integer.parseInt(hourStr)).append(
					":" + minStr);
		}
		String wakeUpTime = null;
		if (realMinStr.toString().equals("上午 12:00")) {
			wakeUpTime = "1";
		} else if (realMinStr.toString().equals("上午 12:30")) {
			wakeUpTime = "2";
		} else if (realMinStr.toString().equals("上午 1:00")) {
			wakeUpTime = "3";
		} else if (realMinStr.toString().equals("上午 1:30")) {
			wakeUpTime = "4";
		} else if (realMinStr.toString().equals("上午 2:00")) {
			wakeUpTime = "5";
		} else if (realMinStr.toString().equals("上午 2:30")) {
			wakeUpTime = "6";
		} else if (realMinStr.toString().equals("上午 3:00")) {
			wakeUpTime = "7";
		} else if (realMinStr.toString().equals("上午 3:30")) {
			wakeUpTime = "8";
		} else if (realMinStr.toString().equals("上午 4:00")) {
			wakeUpTime = "9";
		} else if (realMinStr.toString().equals("上午 4:30")) {
			wakeUpTime = "10";
		} else if (realMinStr.toString().equals("上午 5:00")) {
			wakeUpTime = "11";
		} else if (realMinStr.toString().equals("上午 5:30")) {
			wakeUpTime = "12";
		} else if (realMinStr.toString().equals("上午 6:00")) {
			wakeUpTime = "13";
		} else if (realMinStr.toString().equals("上午 6:30")) {
			wakeUpTime = "14";
		} else if (realMinStr.toString().equals("上午 7:00")) {
			wakeUpTime = "15";
		} else if (realMinStr.toString().equals("上午 7:30")) {
			wakeUpTime = "16";
		} else if (realMinStr.toString().equals("上午 8:00")) {
			wakeUpTime = "17";
		} else if (realMinStr.toString().equals("上午 8:30")) {
			wakeUpTime = "18";
		} else if (realMinStr.toString().equals("上午 9:00")) {
			wakeUpTime = "19";
		} else if (realMinStr.toString().equals("上午 9:30")) {
			wakeUpTime = "20";
		} else if (realMinStr.toString().equals("上午 10:00")) {
			wakeUpTime = "21";
		} else if (realMinStr.toString().equals("上午 10:30")) {
			wakeUpTime = "22";
		} else if (realMinStr.toString().equals("上午 11:00")) {
			wakeUpTime = "23";
		} else if (realMinStr.toString().equals("上午 11:30")) {
			wakeUpTime = "24";
		} else if (realMinStr.toString().equals("下午 12:00")) {
			wakeUpTime = "25";
		} else if (realMinStr.toString().equals("下午 12:30")) {
			wakeUpTime = "26";
		} else if (realMinStr.toString().equals("下午 1:00")) {
			wakeUpTime = "27";
		} else if (realMinStr.toString().equals("下午 1:30")) {
			wakeUpTime = "28";
		} else if (realMinStr.toString().equals("下午 2:00")) {
			wakeUpTime = "29";
		} else if (realMinStr.toString().equals("下午 2:30")) {
			wakeUpTime = "30";
		} else if (realMinStr.toString().equals("下午 3:03")) {
			wakeUpTime = "31";
		} else if (realMinStr.toString().equals("下午 3:30")) {
			wakeUpTime = "32";
		} else if (realMinStr.toString().equals("下午 4:00")) {
			wakeUpTime = "33";
		} else if (realMinStr.toString().equals("下午 4:30")) {
			wakeUpTime = "34";
		} else if (realMinStr.toString().equals("下午 5:00")) {
			wakeUpTime = "35";
		} else if (realMinStr.toString().equals("下午 5:30")) {
			wakeUpTime = "36";
		} else if (realMinStr.toString().equals("下午 6:00")) {
			wakeUpTime = "37";
		} else if (realMinStr.toString().equals("下午 6:30")) {
			wakeUpTime = "38";
		} else if (realMinStr.toString().equals("下午 7:00")) {
			wakeUpTime = "39";
		} else if (realMinStr.toString().equals("下午 7:30")) {
			wakeUpTime = "40";
		} else if (realMinStr.toString().equals("下午 8:00")) {
			wakeUpTime = "41";
		} else if (realMinStr.toString().equals("下午 8:30")) {
			wakeUpTime = "42";
		} else if (realMinStr.toString().equals("下午 9:00")) {
			wakeUpTime = "43";
		} else if (realMinStr.toString().equals("下午 9:30")) {
			wakeUpTime = "44";
		} else if (realMinStr.toString().equals("下午 10:00")) {
			wakeUpTime = "45";
		} else if (realMinStr.toString().equals("下午 10:30")) {
			wakeUpTime = "46";
		} else if (realMinStr.toString().equals("下午 11:00")) {
			wakeUpTime = "47";
		} else if (realMinStr.toString().equals("下午 11:30")) {
			wakeUpTime = "48";
		}
		System.out.println("姑姑" + realMinStr.toString() + " 手机号码:"
				+ user.getPhone());
		if (wakeUpTime != null) {
			List taskList = taskEventMgr.getTasksByNow(flag, user, dateStr,
					wakeUpTime);
			int length = taskList.size();
			System.out.println("大小:" + length);
			if (length > 0) {
				// 发短信或者发邮件;
				String phone = user.getPhone();
				
				}
			}
		}*/
		// System.out.println("单了大小:"+eventList.size());
		/*
		 * for(int i=0;i<eventList.size();i++){ event
		 * System.out.println(eventList); }
		 */
		// System.out.println(user.getFamilyName());
		/*
		 * date = new Date(); int timeInt = 0; String dateStr = new
		 * SimpleDateFormat("yyyy-MM-dd").format(date); String timeStr = new
		 * SimpleDateFormat("HH-mm-ss").format(date);// 24小时制; int hourInt =
		 * Integer.parseInt(timeStr.substring(0, 2));// 小时; int minInt =
		 * Integer.parseInt(timeStr.substring(3, 5));// 分钟; int secInt =
		 * Integer.parseInt(timeStr.substring(6, 8));// 秒钟; if (hourInt < 1) {
		 * if(minInt<30) { timeInt = 1; } else { timeInt = 2; } } else if
		 * (hourInt < 2) { if(minInt<30) { timeInt = 3; } else { timeInt = 4; } }
		 * else if (hourInt < 3) { if(minInt<30) { timeInt = 5; } else {
		 * timeInt = 6; } } else if (hourInt < 4) { if(minInt<30) { timeInt =
		 * 7; } else { timeInt = 8; } } else if (hourInt < 5) { if(minInt<30) {
		 * timeInt = 9; } else { timeInt = 10; } } else if (hourInt < 6) {
		 * if(minInt<30) { timeInt = 11; } else { timeInt = 12; } } else if
		 * (hourInt < 7) { if(minInt<30) { timeInt = 13; } else { timeInt = 14; } }
		 * else if (hourInt < 8) { if(minInt<30) { timeInt = 15; } else {
		 * timeInt = 16; } } else if (hourInt < 9) { if(minInt<30) { timeInt =
		 * 17; } else { timeInt = 18; } } else if (hourInt < 10) { if(minInt<30) {
		 * timeInt = 19; } else { timeInt = 20; } } else if (hourInt < 11) {
		 * if(minInt<30) { timeInt = 21; } else { timeInt = 22; } } else if
		 * (hourInt < 12) { if(minInt<30) { timeInt = 23; } else { timeInt =
		 * 24; } } else if (hourInt < 13) { if(minInt<30) { timeInt = 25; }
		 * else { timeInt = 26; } } else if (hourInt < 14) { if(minInt<30) {
		 * timeInt = 27; } else { timeInt = 28; } } else if (hourInt < 15) {
		 * if(minInt<30) { timeInt = 29; } else { timeInt = 30; } } else if
		 * (hourInt < 16) { if(minInt<30) { timeInt = 31; } else { timeInt =
		 * 32; } } else if (hourInt < 17) { if(minInt<30) { timeInt = 33; }
		 * else { timeInt = 34; } } else if (hourInt < 18) { if(minInt<30) {
		 * timeInt = 35; } else { timeInt = 36; } } else if (hourInt < 19) {
		 * if(minInt<30) { timeInt = 37; } else { timeInt = 38; } } else if
		 * (hourInt < 20) { if(minInt<30) { timeInt = 39; } else { timeInt =
		 * 40; } } else if (hourInt < 21) { if(minInt<30) { timeInt = 41; }
		 * else { timeInt = 42; } } else if (hourInt < 22) { if(minInt<30) {
		 * timeInt = 43; } else { timeInt = 44; } } else if (hourInt < 23) {
		 * if(minInt<30) { timeInt = 45; } else { timeInt = 46; } } else if
		 * (hourInt < 24) { if(minInt<30) { timeInt = 47; } else { timeInt =
		 * 48; } } List taskList = null; System.out.println("半小时走一次");
		 * //System.out.println(user.getFamilyName()+"事件处理"); if(minInt==0) {
		 * try { taskList = taskEventMgr.getAllTasks(flag, user, null); } catch
		 * (ApplicationException e) { e.printStackTrace(); } int len =
		 * taskList.size(); if(len>0) { for(int i = 0; i< len; i++) {
		 * ActivityTask task =(ActivityTask) taskList.get(i);
		 * System.out.println(task.getSubject());
		 * if(task.getWakeUpDate().equals(dateStr)) {//今天日期;
		 * if(task.getWakeUpTime().equals(timeInt)) {//现在时间; try {
		 * response.getWriter().print("<script>alert('XXXX!')</script>"); }
		 * catch (IOException e) { e.printStackTrace(); } } } } } }
		 */

	public HttpServletResponse getResponse() {
		return response;
	}

	public void setResponse(HttpServletResponse response) {
		this.response = response;
	}

	public TaskEventMgr getTaskEventMgr() {
		return taskEventMgr;
	}

	public void setTaskEventMgr(TaskEventMgr taskEventMgr) {
		this.taskEventMgr = taskEventMgr;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public int getFlag() {
		return flag;
	}

	public void setFlag(int flag) {
		this.flag = flag;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?