⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 taskeventmgrimpl.java

📁 基于Sturts+Spring+Hibernate的一个高级销售管理系统。内容丰富
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
package com.yuanchung.sales.service.taskevent.impl;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.mail.MessagingException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;

import com.yuanchung.sales.constants.CorrelationConstant;
import com.yuanchung.sales.constants.SystemConstant;
import com.yuanchung.sales.dao.taskEvent.EventDAO;
import com.yuanchung.sales.dao.taskEvent.TaskDAO;
import com.yuanchung.sales.dao.util.UtilDAO;
import com.yuanchung.sales.exception.ApplicationException;
import com.yuanchung.sales.exception.TooManyValueException;
import com.yuanchung.sales.model.admin.Rights;
import com.yuanchung.sales.model.businessOpportunity.BusinessOpportunity;
import com.yuanchung.sales.model.customer.Customer;
import com.yuanchung.sales.model.customer.CustomerContact;
import com.yuanchung.sales.model.taskEvent.ActivityTask;
import com.yuanchung.sales.model.taskEvent.Event;
import com.yuanchung.sales.model.user.User;
import com.yuanchung.sales.model.userDefined.UserDefined;
import com.yuanchung.sales.model.userDefined.UserField;
import com.yuanchung.sales.model.userDefined.UserFilter;
import com.yuanchung.sales.service.admin.authorization.AuthorizationMgr;
import com.yuanchung.sales.service.taskevent.TaskEventMgr;
import com.yuanchung.sales.struts.taskevent.form.EventForm;
import com.yuanchung.sales.util.Constants;
import com.yuanchung.sales.util.DateTimeTool;
import com.yuanchung.sales.util.KeyBean;
import com.yuanchung.sales.util.PageController;
import com.yuanchung.sales.util.SessionMgr;
import com.yuanchung.sales.util.StringTool;
import com.yuanchung.sales.util.UtilGetIp;
import com.yuanchung.sales.util.emailutil.MailAuthenticator;
import com.yuanchung.sales.util.emailutil.MailBox;
import com.yuanchung.sales.vo.CustomerVo;
import com.yuanchung.sales.vo.busiOpport.BusinessOpportunityVo;
import com.yuanchung.sales.vo.contact.ContactVo;
import com.yuanchung.sales.vo.right.WebRightsView;
import com.yuanchung.sales.vo.taskEvent.Activity;
import com.yuanchung.sales.vo.taskEvent.ActivityDefinedVo;
import com.yuanchung.sales.vo.taskEvent.ActivityTaskVo;
import com.yuanchung.sales.vo.taskEvent.TaskEventVo;
import com.yuanchung.sales.vo.user.UserVo;

/**
 * @author 陆文邦;
 * @date 创建时间 2008-11-1;
 * @function 处理活动任务和事件的组件模块中间业务层;
 */
@SuppressWarnings("unchecked")
// 剔除未检查的警告;
public class TaskEventMgrImpl implements TaskEventMgr {

	private static Logger logger = Logger.getLogger(TaskEventMgrImpl.class);// 加入日志记录;

	private TaskDAO taskDAO;// spring注入任务DAO接口

	private EventDAO eventDAO;// spring注入事件DAO接口

	private AuthorizationMgr authorizationMgr;
	
	private UtilDAO utilDao;

	/**
	 * @author 陆文邦;
	 * @function 设置活动任务dao;
	 * @param raskDAO;
	 * @return 空;
	 */
	public void setTaskDAO(TaskDAO taskDAO) {
		this.taskDAO = taskDAO;
	}

	/**
	 * @author 陆文邦;
	 * @function 设置事件DAO;
	 * @param eventDAO:
	 *            把该eventDAO设置给该本类的eventDAO;
	 * @return 空;
	 */
	public void setEventDAO(EventDAO eventDAO) {
		this.eventDAO = eventDAO;
	}

	/**
	 * @author 陆文邦;
	 * @function:获取活动任务DAO;
	 * @param:无;
	 * @return: 返回任务活动;
	 */
	public TaskDAO getTaskDAO() {
		return taskDAO;
	}

	/**
	 * @author 陆文邦;
	 * @function:获取事件DAO;
	 * @param:无;
	 * @return:返回事件DAO;
	 */
	public EventDAO getEventDAO() {
		return eventDAO;
	}

	/**
	 * @author 陆文邦;
	 * @date 2008-11-17;
	 * @function 获取全部用户;
	 * @param flag根据任务活动状态来搜索;
	 * @return 返回全部用户的列表;
	 * @修改时间:
	 * @修改人:
	 */
	public List<User> getAllUsers(String userIds) throws ApplicationException {
		try {
			return taskDAO.getAllUsers(userIds);
		} catch (Exception e) {
			e.printStackTrace();
			throw new ApplicationException(Constants.FINDUSEREXCEPTION);
		}
	}

	/**
	 * @author 陆文邦;
	 * @date 2008-11-17;
	 * @function 用于获取搜索符合条件的用户
	 * @param 用userName参数模糊搜索;
	 * @param flag
	 *            根据状态来搜索记录;
	 * @return 返回搜索的用户列表;
	 * @修改时间:
	 * @修改人:
	 */
	public List<UserVo> getUsersByNameLike(String familyName)
			throws ApplicationException {
		try {
			List users = taskDAO.getUsersByNameLike(familyName);
			List<UserVo> userVos = new ArrayList<UserVo>();
			if (users != null) {
				for (Object o : users) {
					User user = (User) o;
					userVos.add(new UserVo(user.getId(), user.getFamilyName()));
				}
			}
			return userVos;
		} catch (Exception e) {
			e.printStackTrace();
			throw new ApplicationException(Constants.FINDUSEREXCEPTION);
		}
	}

	/**
	 * @author 陆文邦;
	 * @date 2008-11-17;
	 * @function 用于获取搜索符合条件的客户;
	 * @param 用userName参数模糊搜索;
	 * @param flag
	 *            根据状态来搜索记录;
	 * @return 返回搜索的客户列表;
	 * @修改时间:
	 * @修改人:
	 */
	public List<CustomerVo> getCustomerByNameLike(String name)
			throws ApplicationException {
		try {
			List customerList = taskDAO.getCustomerByNameLike(name);
			List<CustomerVo> result = new ArrayList<CustomerVo>();
			for (Object o : customerList) {
				Customer c = (Customer) o;
				result.add(new CustomerVo(c.getId(), c.getCustomerName(), c
						.getPhone()));
			}
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			throw new ApplicationException(Constants.FINDCONTACTEXCEPTION);
		}
	}

	/**
	 * @author 陆文邦;
	 * @date 2008-11-17;
	 * @function 用于获取搜索符合条件的联系人;
	 * @param name
	 * @return
	 * @throws ApplicationException
	 * @修改时间:
	 * @修改人:
	 */
	public List<ContactVo> getCustomerContactByNameLike(String name)
			throws ApplicationException {
		try {
			List customerContactList = taskDAO
					.getCustomerContactByNameLike(name);
			List<ContactVo> contactVos = new ArrayList<ContactVo>();
			if (customerContactList != null) {
				for (Object o : customerContactList) {
					CustomerContact cc = (CustomerContact) o;
					String customerName = null;
					if (cc.getCustomer() != null) {// 判断联系是否有客户;
						customerName = cc.getCustomer().getCustomerName();// 如果有,用有客户的联系人构造函数;
						contactVos.add(new ContactVo(cc.getId(), cc.getName(),
								customerName));
					} else {
						contactVos.add(new ContactVo(cc.getId(), cc.getName()));// 没有客户的联系人构造函数;
					}
				}
			}
			return contactVos;
		} catch (Exception e) {
			e.printStackTrace();
			throw new ApplicationException(Constants.FINDCUSTOMEREXCEPTION);
		}
	}

	/**
	 * @author 陆文邦;
	 * @date 2008-11-17;
	 * @function 用于获取搜索符合条件的联系人;
	 * @param name
	 * @return
	 * @throws ApplicationException
	 * @修改时间:
	 * @修改人:
	 */
	public List<BusinessOpportunityVo> getOpportByNameLike(String name)
			throws ApplicationException {
		try {
			List opportList = taskDAO.getOpportByNameLike(name);
			List<BusinessOpportunityVo> result = new ArrayList<BusinessOpportunityVo>();
			if (opportList != null) {
				for (Object o : opportList) {
					BusinessOpportunity bo = (BusinessOpportunity) o;
					String customerName = bo.getCustomer().getCustomerName();
					if (customerName == null) {// 判断业务机会的客户名称是否为空;
						result.add(new BusinessOpportunityVo(bo.getId(), bo
								.getBusiOpportName()));
					} else {
						result.add(new BusinessOpportunityVo(bo.getId(), bo
								.getBusiOpportName(), customerName));
					}
				}
			}
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			throw new ApplicationException(Constants.FINDBUSIOPPORTEXCEPTION);
		}
	}

	/**
	 * @author 陆文邦;
	 * @date 2008-11-17;
	 * @function 搜索全部的联系人;
	 * @param flag;根据记录状态来搜索;
	 * @return 返回搜索的联系人;
	 * @修改时间:
	 * @修改人:
	 */
	public List<CustomerContact> getAllCustomerContacts(Integer flag)
			throws ApplicationException {
		try {
			return taskDAO.getAllCustomerContacts(Constants.ACTIVEFLAG);
		} catch (Exception e) {
			e.printStackTrace();
			throw new ApplicationException(Constants.FINDCONTACTEXCEPTION);
		}
	}

	/**
	 * @author 陆文邦;
	 * @date 2008-11-17;
	 * @function 根据相关项类型搜索具体记录;
	 * @param id为相关项标识
	 * @return 返回相关项里的相关记录;
	 * @修改时间:
	 * @修改人:
	 */
	public List getAllfunctionRecordCollection(Integer id)
			throws ApplicationException {
		try {
			if (id.toString().equals(CorrelationConstant.CUSTOMERRELATION)) {
				return taskDAO.getAllCustomers(Constants.ACTIVEFLAG);// 返回全部激活的客户;
			} else if (id.toString().equals(
					CorrelationConstant.BUSIOPPORTRELATION)) {
				return taskDAO.getAllOpports(Constants.ACTIVEFLAG);// 返回全部激活的业务机会;
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new ApplicationException(Constants.FINDEXCEPTION);
		}
		return null;
	}

	/**
	 * @author 陆文邦;
	 * @date 2008-11-17;
	 * @function 添加任务活动;
	 * @param 保存taskPojo参数的实例
	 * @return 返回是否保存成功;
	 * @修改时间:
	 * @修改人:
	 */
	public boolean addTask(ActivityTask taskPojo, String userStr, String path,
			User user) throws ApplicationException {
		String[] uid = null;
		boolean flag = false;
		User assigner = null;
		String html = null;
		if (!"".equals(userStr) && userStr != null) {
			uid = userStr.split(",");
			for (int i = 0; i < uid.length; i++) {
				Integer id = Integer.parseInt(uid[i]);
				assigner = taskDAO.getUserById(id);

⌨️ 快捷键说明

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