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

📄 eventaction.java

📁 基于Sturts+Spring+Hibernate的一个高级销售管理系统。内容丰富
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
				String year = request.getParameter("year");
				String month = request.getParameter("month");
				String weekOfYear = request.getParameter("weekOfYear");
				request.setAttribute("year", year);
				request.setAttribute("month", month);
				request.setAttribute("weekOfYear", weekOfYear);
			} else if (timeType.equals("date")) {
				String year = request.getParameter("year");
				String dayOfYear = request.getParameter("dayOfYear");
				request.setAttribute("year", year);
				request.setAttribute("dayOfYear", dayOfYear);
			}
			request.setAttribute("timeType", timeType);
		}
		if ("sin".equals(type)) {
			return mapping.findForward("modifySingleEvent");
		} else {
			return mapping.findForward("modifySystemEvent");
		}
	}

	/**
	 * 函数功能: 修改旗标,删除事件; 程序作者: 陆文邦; 创建时间: 2008-12-24;
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 */
	public ActionForward deleteEventByTime(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws ApplicationException {
		User user = SessionMgr.getCustSession(request); // 获取当前正在操作的用户;
		if (user == null) {
			return mapping.findForward("login"); // 如果session不存在用户,重新登陆;
		}
		Integer id = Integer.parseInt(request.getParameter("id"));
		taskEventMgr.mergeEventFlag(id, Constants.PASSIVITY);// 修改删除;
		String timeType = request.getParameter("timeType");
		if (timeType != null) {
			String year = request.getParameter("year");
			String month = request.getParameter("month");
			if (timeType.equals("date")) {
				String dayOfYear = request.getParameter("dayOfYear");
				return new ActionForward("/event.do?method=getDateEvents&year="
						+ year + "&dayOfYear=" + dayOfYear, true);
			} else if (timeType.equals("week")) {
				String weekOfYear = request.getParameter("weekOfYear");
				return new ActionForward("/event.do?method=getWeekEvents&year="
						+ year + "&month=" + month + "&weekOfYear="
						+ weekOfYear, true);
			} else if (timeType.equals("month")) {
				return new ActionForward(
						"/event.do?method=getMonthEvents&year=" + year
								+ "&month=" + month, true);
			}
		}
		return null;
	}

	/**
	 * @author 福建圆创软件;
	 * @function 处理页面上的日历事件bean,封装成持久类pojo来操作;
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return 返回一个日历事件的持久类对象;
	 * @throws ApplicationException
	 */
	/*
	 * private Event handleEvent(ActionForm form, HttpServletRequest request)
	 * throws ApplicationException {
	 * 
	 * User currentUser = SessionMgr.getCustSession(request);// 当前正在操作的用户;
	 * EventForm eventForm = (EventForm) form;// 获取页面封装的form Event event = new
	 * Event();// 实例化一个任务活动的持久对象; try { BeanUtils.copyProperties(event,
	 * eventForm);// 把form的属性复制到持久类pojo的属性;
	 * 
	 *//** 获取用户,把用户存储到持久类中* */
	/*
	 * Integer assignerId = event.getAssignerId();// 获取页面传过来的用户id;
	 * logger.debug("用户:" + currentUser.getUserName() + " 在 " + new Date() +
	 * "搜索id为" + assignerId + "的用户!");
	 * 
	 *//** 设置修改人的对象和修改时间* */
	/*
	 * event.setLastModifyTime(DateTimeTool .getCurrentDate("yyyy-MM-dd
	 * HH:mm:ss"));// 上次修改时间; event.setModifyManId(currentUser.getId());//
	 * 上次修改人;
	 * 
	 * event.setUser(currentUser);// 设置创建人;
	 * 
	 *//** 判断页面上的具体记录是否为空,如果为空则相关类也为空* */
	/*
	 * String recordName = eventForm.getRecordName();// 页面输入相关项具体记录的名称; if
	 * (recordName == null || recordName.equals("")) {// 如果相关项的具体记录名称为空
	 * event.setFunctionId(null);// 相关项也设置为空; event.setRecordId(null);//
	 * 相关项具体记录也为空; }
	 * 
	 *//** 判断页面上的联系人名称是否为空,如果为空把联系人id设置为空* */
	/*
	 * String contactName = eventForm.getContactName();// 页面输入联系人的名称; if
	 * (contactName != null && !(contactName.equals(""))) {// 判断联系人的名称是否为空;
	 * Integer cid = eventForm.getContactId(); CustomerContact customerContact =
	 * null; if (cid != null) { customerContact =
	 * taskEventMgr.getCustomerContactById(cid); } if (customerContact != null) {
	 * event.setCustomerContact(customerContact); } } } catch
	 * (IllegalAccessException e) { e.printStackTrace(); } catch
	 * (InvocationTargetException e) { e.printStackTrace(); } return event; }
	 */

	/**
	 * 函数功能:删除事件(从查看事件详细页面删除) 程序作者:陆文邦; 创建时间:2008-12-30;
	 */
	public ActionForward deleteEventByType(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws ApplicationException {
		User user = SessionMgr.getCustSession(request); // 获取当前正在操作的用户;
		if (user == null) {
			return mapping.findForward("login"); // 如果session不存在用户,重新登陆;
		}
		String type = request.getParameter("type");// 判断用户是否要删除序列还是单个;
		String timeType = request.getParameter("timeType");// 跳转的类型(月,周,日)
		String id = request.getParameter("id");
		Event event = null;
		String seq = null;
		if (id != null) {
			event = taskEventMgr.getEventById(Integer.parseInt(id));
			seq = event.getEventSeq();
		}

		if ("sin".equals(type)) {
			taskEventMgr.getEventDAO().mergeEventFlag(Integer.parseInt(id),
					Constants.PASSIVITY);// 修改该事件的状态,(假删除)
			if (timeType != null && !("".equals(timeType))) {
				String year = request.getParameter("year");
				String month = request.getParameter("month");
				if (timeType.equals("date")) {
					String dayOfYear = request.getParameter("dayOfYear");
					return new ActionForward(
							"/event.do?method=getDateEvents&year=" + year
									+ "&dayOfYear=" + dayOfYear, true);
				} else if (timeType.equals("week")) {
					String weekOfYear = request.getParameter("weekOfYear");
					return new ActionForward(
							"/event.do?method=getWeekEvents&year=" + year
									+ "&month=" + month + "&weekOfYear="
									+ weekOfYear, true);
				} else if (timeType.equals("month")) {
					return new ActionForward(
							"/event.do?method=getMonthEvents&year=" + year
									+ "&month=" + month, true);
				}
			} else {
				return new ActionForward("/task.do?method=getAllTasks", true);// 返回首页
			}
		} else if ("sys".equals(type)) {
			taskEventMgr.mergeEventsFlagBySeq(seq, Constants.PASSIVITY);// 修改该事件系列的状态,过期的不能删除;
			return new ActionForward("/task.do?method=getAllTasks", true);// 删除系列的返回路径;
		}
		return null;
	}

	/**
	 * 删除事件
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 */
	public ActionForward deleteEvent(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws ApplicationException {
		String id = request.getParameter("id");
		// 前置条件
		if (!StringTool.isNotBlank(id)) {
			request.setAttribute(Constants.ERRMSG, Constants.INPUTBANK);
			throw new ApplicationException("the param you input is illegal");
		}

		User user = SessionMgr.getCustSession(request);
		// 删除任务
		relationManage.updateEntitysStates(user.getId(), DateTimeTool
				.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
				ClassCodeMgr.EVENTCODEINT, Integer.parseInt(id),
				Constants.DELETESELF, Constants.PASSIVITY);

		return mapping.findForward("getAllEvent");
	}

	/**
	 * 程序员 陆文邦
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 */
	public ActionForward deleteEventByDate(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws ApplicationException {
		return null;
	}

	/**
	 * @author 陆文邦
	 * @date 2008-12-18;
	 * @function 查找相关的任务和事件;
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return 显示任务和事件的列表;
	 * @throws ApplicationException
	 */
	public ActionForward alertTaskEvent(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws ApplicationException {
		User user = SessionMgr.getCustSession(request); // 获取当前正在操作的用户;
		if (user == null) {
			return mapping.findForward("login"); // 如果session不存在用户,重新登陆;
		}
		List taskEvents = taskEventMgr.getTaskEventList(user,
				Constants.ACTIVEFLAG);
		request.setAttribute("taskEvents", taskEvents);
		return mapping.findForward("alertTaskEvent");
	}

	/**
	 * 函数功能: 跳转到添加事件的页面; 程序作者: 陆文邦; 创建时间: 2009-1-4
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 */

	public ActionForward toAddFloEvent(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws ApplicationException {
		User user = SessionMgr.getCustSession(request); // 获取当前正在操作的用户;
		if (user == null) {
			return mapping.findForward("login"); // 如果session不存在用户,重新登陆;
		}

		String type = request.getParameter("type");
		String oid = request.getParameter("id");
		if ("task".equals(type)) {
				showDetailTask(form, request);// 抽取出来处理详细任务活动以及相关信息的方法;
		} else {
			String id = request.getParameter("id");
			logger.debug("传进来的事件id号码:" + id);
			Event event = null;
			if (id != null) {
				event = taskEventMgr.getEventById(Integer.parseInt(id));
				request.setAttribute("event", event);
			}
		}
		ConfigMgr configMgr = ConfigMgr.getInstance(); // 取出相关项类;
		Map<String, String> correlationsMap = configMgr.getAllCorrelations(); // 获取相关项对应的键值对;
		if (correlationsMap != null && correlationsMap.size() > 0) {
			logger.debug("用户:" + user.getUserName() + " 成功搜索相关项类型!");
			request.setAttribute("correlationsMap", correlationsMap); // 把键值对存放到request范围内;
		}
		request.setAttribute("type", type);//设置来源类型;
		request.setAttribute("oid", oid);//设置来源对象;
		return mapping.findForward("toNewEvent");
	}

	/**
	 * @author 陆文邦;
	 * @function 搜索某个任务活动以及相关信息的通用方法;
	 * @param request
	 * @throws ApplicationException
	 */
	private void showDetailTask(ActionForm form, HttpServletRequest request)
			throws ApplicationException {

		/** 获取任务活动,转存到视图层的bean中后存储到request范围; * */
		User currentUser = SessionMgr.getCustSession(request);// 获取当前正在操作的用户;
		Integer id = Integer.parseInt(request.getParameter("id"));// 该id为任务活动的内码id主键;
		ActivityTask task = taskEventMgr.getTsakById(id);// 搜索这个id的任务活动;
		logger.debug("用户:" + currentUser.getUserName() + " 在 " + new Date()
				+ "搜索id为" + id + "的任务活动!");
		TaskForm taskForm = new TaskForm();// 实例化一个页面上的任务活动对象;
		try {
			BeanUtils.copyProperties(taskForm, task);// 把持久类的任务活动对象属性复制到视图层的任务活动bean当中;
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}

		/** 获取被分配人,存储到request范围;* */
		Integer assignerId = task.getAssignerId();// 被分配人id
		User user = taskEventMgr.getUserById(assignerId);// 获取被分配人对象;
		logger.debug("用户:" + currentUser.getUserName() + " 在 " + new Date()
				+ "搜索id为" + assignerId + "的用户!");
		request.setAttribute("user", user);// 把被分配人传到request范围;

		/** 获取上次修改人,存储到request范围;* */
		Integer modifyUid = task.getModifyManId();// 获取上次修改人的id;
		User modifyUser = taskEventMgr.getUserById(modifyUid);// 获取该修改人的对象;
		logger.debug("用户:" + currentUser.getUserName() + " 在 " + new Date()
				+ "搜索id为" + modifyUid + "的用户!");
		request.setAttribute("modifyUser", modifyUser);// 把上次修改人传到request范围;

		User creator = task.getUser();
		request.setAttribute("creator", creator);
		/** 获取任务活动的相关联系人,存储到request范围;* */
		CustomerContact contact = task.getCustomerContact();// 获取联系人id
		Integer contactId = null;
		if (contact != null) {
			contactId = contact.getId();
		}
		if (contactId != null) {// 判断任务活动的联系人是否为空;
			CustomerContact customerContact = taskEventMgr
					.getCustomerContactById(contactId);// 获取任务活动的相关联系人;
			logger.debug("用户:" + currentUser.getUserName() + " 在 " + new Date()
					+ "搜索id为" + contactId + "的联系人!");
			taskForm.setContactName(customerContact.getName());// 把联系人名称储存到任务活动对象的联系人名称上面;
			taskForm.setContactId(contactId);
			request.setAttribute("customerContact", customerContact);// 需要把联系人对象存放到request范围里,因为联系人电话和邮箱需要用到;
		}

		/** 通过获取相关项id,判断该相关类型后传回具体的记录对象* */
		String functionId = task.getFunctionId();// 获取相关项;
		Integer rid = task.getRecordId();// 获取具体记录的id;
		if (functionId != null && !functionId.equals("")) {// 如果相关项不为空;
			Integer fid = Integer.parseInt(functionId);
			switch (fid) {
			case 1: {
				Customer customer = taskEventMgr.getCustomerByRid(rid);// 根据相关项具体记录id搜索记录;
				logger.debug("用户:" + currentUser.getUserName() + " 在 "
						+ new Date() + "搜索id为" + rid + "的客户!");
				taskForm.setRecordName(customer.getCustomerName());// 把客户名称设置到任务活动中的具体实体名;
				taskForm.setRecordId(customer.getId());// 把客户id设置到任务活动中的具体实体id;
			}
				break;
			case 2: {
				BusinessOpportunity opport = taskEventMgr.getOpportByRid(rid);// 根据相关项具体记录id搜索记录;
				logger.debug("用户:" + currentUser.getUserName() + " 在 "
						+ new Date() + "搜索id为" + rid + "的业务机会!");
				taskForm.setRecordName(opport.getBusiOpportName());// 把业务机会名称设置到任务活动中的具体实体名;
				taskForm.setRecordId(opport.getId());// 把业务机会id设置到任务活动中的具体实体id;
			}
				break;
			}
		}
		request.setAttribute("task", taskForm);// 把该任务活动传到request范围;
	}
}

⌨️ 快捷键说明

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