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

📄 customeraction.java

📁 基于Sturts+Spring+Hibernate的一个高级销售管理系统。内容丰富
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
			forward = "userLogin";
		}
		return mapping.findForward(forward);
	}

	/**
	 * 显示客户的详细;
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 */
	public ActionForward showDetail(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws ApplicationException {
		String id = request.getParameter("id");
		Customer customer = customerMgr.getCustomerById(Integer.parseInt(id));
		CustomerForm customerForm = new CustomerForm();
		try {
			BeanUtils.copyProperties(customerForm, customer);
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
		request.setAttribute("customer", customerForm);
		return mapping.findForward("customerDetail");
	}

	/**
	 * 显示出被冻结的客户;
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 */
	public ActionForward listDeleteData(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws ApplicationException {
		User user = SessionMgr.getCustSession(request);

		String forward = "listDeleteData";
		List<CustomerVo> customers = null;
		customers = customerMgr.getCustomerByDelete();
		System.out.println("一共有几个选项:" + customers.size());
		String currentPage = request.getParameter("currentPage");
		XPage xpage = new XPage(request.getContextPath()
				+ "/customer.do?method=listDeleteData", customers.size(), 1, 8,
				customers);
		if (currentPage != null && !currentPage.equals("")) {
			xpage.setCurrentItems(Integer.parseInt(currentPage));
		} else {
			xpage.setCurrentItems(1);
		}
		xpage.setPageBar();
		request.setAttribute("xpage", xpage);
		return mapping.findForward(forward);
	}

	// ------------------------------------更新后------------------------------------//

	/**
	 * 
	 * 搜索客户相关项
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException抛出应用异常
	 */
	public ActionForward correlation(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws ApplicationException {
		CustomerForm cForm = (CustomerForm) form;
		// String customerId = request.getParameter("customerId");
		String customerId = cForm.getCustomerId();
		String forward = "customerCorrelation";// 跳转到客户相关项

		if (!StringTool.isNotBlank(customerId)) { // 若传入的参数为空
			throw new IllegalParameterException(
					Constants.ILLEALPARAMGOGALEXCEPTION);
		}

		try {
			// 搜索出相应客户
			Customer customer = customerMgr.getCustomerById(Integer
					.parseInt(customerId));
			CustomerVo customerVo = new CustomerVo();
			BeanUtils.copyProperties(customerVo, customer);
			// 2009-02-24 add
			if (cForm.getDelRights() == null || cForm.getModifyRights() == null
					|| "".equals(cForm.getDelRights())
					|| "".equals(cForm.getModifyRights())) {
				//查找
				User user = SessionMgr.getCustSession(request);
				Rights rights = SessionMgr.getJspRightsControl(request)
						.get("1").getRightsMap().get("104");
				String userIds = authorizationMgr.findUserDataRange(rights
						.getId(), user);
				if (!authorizationMgr.isRights(user.getId(), userIds)) {
					return mapping.findForward("noRights");
				} else {
					// 删除(数据范围)
					Rights delRights = SessionMgr.getJspRightsControl(request).get("1")
							.getRightsMap().get("103");
					String delUserIds = authorizationMgr.findUserDataRange(delRights
							.getId(), user);
					logger.debug("delUserIds : " + delUserIds);
					// 修改(数据范围)
					Rights modifyRights = SessionMgr.getJspRightsControl(request).get("1")
							.getRightsMap().get("102");
					String modifyUserIds = authorizationMgr.findUserDataRange(modifyRights
							.getId(), user);
					if(authorizationMgr.isRights(user.getId(), delUserIds)){
						customerVo.setDelRights("y");
					}
					if(authorizationMgr.isRights(user.getId(), modifyUserIds)){
						customerVo.setModifyRights("y");
					}
				}
			} else {
				customerVo.setDelRights(cForm.getDelRights());
				customerVo.setModifyRights(cForm.getModifyRights());
			}
			// end
			request.setAttribute("customerVo", customerVo);

			// 根据修改人的ID查找上次修改人
			User modifyMan = customerMgr.getCustomerDao().getUserById(
					customerVo.getModifyManId());
			request.setAttribute("modifyUser", new UserVo(modifyMan.getId(),
					modifyMan.getFamilyName()));

			// 搜索相关联系人
			List contacts = relationManage.getEntities(
					ClassCodeMgr.CUSTOMER_CONTACTINT, ClassCodeMgr.CUSTOMERINT,
					Integer.parseInt(customerId));
			List<ContactVo> contactVoList = relationManage
					.contactsToContactVos(contacts);
			request.setAttribute("contacts", contactVoList);
			request.setAttribute("contactSize", contactVoList.size());

			// 搜索业务机会
			List busiOpports = relationManage.getEntities(
					ClassCodeMgr.BUSINESS_OPPORTINT, ClassCodeMgr.CUSTOMERINT,
					Integer.parseInt(customerId));
			List<BusinessOpportunityVo> busiOpportList = relationManage
					.busiOpportToBusiOpportVos(busiOpports);
			request.setAttribute("busiOpports", busiOpportList);
			request.setAttribute("busiOpportSize", busiOpportList.size());
			logger.debug("业务机会。。。");

			// 搜索未处理的任务
			List<ActivityTaskVo> imCompletedRasks = relationManage
					.getActivityRasksByRelation(
							CorrelationConstant.CUSTOMERRELATION, Integer
									.parseInt(customerId), 1);
			request.setAttribute("imCompletedRasks", imCompletedRasks);
			request
					.setAttribute("imCompletedRaskSize", imCompletedRasks
							.size());
			logger.debug("未处理的任务。。。" + imCompletedRasks);

			// 搜索未处理的事件
			List<EventVo> imCompletedEvents = relationManage
					.getEventByRelation(CorrelationConstant.CUSTOMERRELATION,
							Integer.parseInt(customerId), true);
			request.setAttribute("imCompletedEvents", imCompletedEvents);
			request.setAttribute("imCompletedEventSize", imCompletedEvents
					.size());
			logger.debug("未处理的事件。。。" + imCompletedEvents);

			// 搜索任务历史---已经完成的任务
			List<ActivityTaskVo> completedRasks = relationManage
					.getActivityRasksByRelation(
							CorrelationConstant.CUSTOMERRELATION, Integer
									.parseInt(customerId),
							Constants.RASKEXECUTEED);
			request.setAttribute("completedRasks", completedRasks);
			request.setAttribute("completedRaskSize", completedRasks.size());
			logger.debug("已处理的任务。。。" + completedRasks);

			// 搜索历史事件----过期事件
			List<EventVo> completedEvents = relationManage.getEventByRelation(
					CorrelationConstant.CUSTOMERRELATION, Integer
							.parseInt(customerId), false);
			request.setAttribute("completedEvents", completedEvents);
			request.setAttribute("completedEventSize", completedEvents.size());
			logger.debug("已过期的事件。。。" + completedEvents);
		} catch (Exception e) {
			e.printStackTrace();
			throw new ApplicationException(Constants.WITHOUTDATA);
		}
		return mapping.findForward(forward);
	}

	public CustomerMgr getCustomerMgr() {
		return customerMgr;
	}

	/**
	 * 创建联系人
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 */
	public ActionForward createContact(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws ApplicationException {
		String customerId = request.getParameter("customerId");

		if (!StringTool.isNotBlank(customerId)) { // 若传入的参数为空
			throw new IllegalParameterException(
					Constants.ILLEALPARAMGOGALEXCEPTION);
		}
		try {
			// 搜索出相应客户
			Customer c = customerMgr.getCustomerById(Integer
					.parseInt(customerId));
			request.setAttribute("customerVo", new CustomerVo(c.getId(), c
					.getCustomerName()));

		} catch (Exception e) {
			e.printStackTrace();
			throw new ApplicationException(Constants.WITHOUTDATA);
		}
		return mapping.findForward("newContact");
	}

	/**
	 * 新建任务
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 *             2008-11-07 by 张明强 copied liu's
	 */
	public ActionForward createNewTask(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws ApplicationException {
		String customerId = request.getParameter("customerId");
		logger.error("参数为。。。" + customerId);
		if (!StringTool.isNotBlank(customerId)) {
			logger.debug("the param you input is illegal");
			request.setAttribute(Constants.ERRMSG, Constants.INPUTBANK);
			throw new IllegalParameterException(
					"the param you input is illegal");
		}
		try {
			Customer customer = customerMgr.getCustomerById(Integer
					.parseInt(customerId));
			logger.error("有到这里吗。。。" + customer);
			request.setAttribute("CorrelationVo", new CorrelationVo(customer
					.getId(), customer.getCustomerName()));

			// 保存客户相关项编码
			request.setAttribute("customerRelation",
					CorrelationConstant.CUSTOMERRELATION);

			ConfigMgr configMgr = ConfigMgr.getInstance();// 取出相关项类;
			Map<String, String> correlationsMap = configMgr
					.getAllCorrelations();// 获取相关项对应的键值对;
			if (correlationsMap != null && correlationsMap.size() > 0) {

				request.setAttribute("correlationsMap", correlationsMap);// 把键值对存放到request范围内;
			}
		} catch (Exception e) {
			request.setAttribute(Constants.ERRMSG, Constants.WITHOUTDATA);
			throw new IllegalParameterException(
					"the param you input is illegal");
		}
		return mapping.findForward("toAddTask");// 转发到添加任务活动的页面;
	}

	/**
	 * 新建事件
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 *             2008-11-07 by 张明强 copied liu's
	 */
	public ActionForward createNewEvent(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws ApplicationException {
		String customerId = request.getParameter("customerId");
		logger.error("参数为。。。" + customerId);
		if (!StringTool.isNotBlank(customerId)) {
			logger.debug("the param you input is illegal");
			request.setAttribute(Constants.ERRMSG, Constants.INPUTBANK);
			throw new IllegalParameterException(
					"the param you input is illegal");
		}
		try {
			Customer customer = customerMgr.getCustomerById(Integer
					.parseInt(customerId));
			logger.error("有到这里吗。。。" + customer);
			request.setAttribute("CorrelationVo", new CorrelationVo(customer
					.getId(), customer.getCustomerName()));

			// 保存客户相关项编码
			request.setAttribute("customerRelation",
					CorrelationConstant.CUSTOMERRELATION);

			ConfigMgr configMgr = ConfigMgr.getInstance();// 取出相关项类;
			Map<String, String> correlationsMap = configMgr
					.getAllCorrelations();// 获取相关项对应的键值对;
			if (correlationsMap != null && correlationsMap.size() > 0) {
				request.setAttribute("correlationsMap", correlationsMap);// 把键值对存放到request范围内;
			}
		} catch (Exception e) {
			request.setAttribute(Constants.ERRMSG, Constants.WITHOUTDATA);
			throw new IllegalParameterException(
					"the param you input is illegal");
		}
		return mapping.findForward("toAddEvent");// 转发到添加任务活动的页面;
	}

	/**
	 * 新建业务机会
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws ApplicationException
	 */
	public ActionForward newBusiOpport(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws ApplicationException {
		String customerId = request.getParameter("customerId");
		logger.error("参数为。。。" + customerId);
		if (!StringTool.isNotBlank(customerId)) {
			logger.debug("the param you input is illegal");
			request.setAttribute(Constants.ERRMSG, Constants.INPUTBANK);
			throw new IllegalParameterException(
					"the param you input is illegal");
		}
		try {
			Customer customer = customerMgr.getCustomerById(Integer
					.parseInt(customerId));
			logger.error("有到这里吗。。。" + customer);
			request.setAttribute("customerVo", new CustomerVo(customer.getId(),
					customer.getCustomerName()));
		} catch (Exception e) {
			request.setAttribute(Constants.ERRMSG, Constants.WITHOUTDATA);
			throw new IllegalParameterException(
					"the param you input is illegal");
		}
		return new ActionForward("/busiOpport/newBusiOpport.jsp");// 防止重定向
	}
}

⌨️ 快捷键说明

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