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

📄 customermgrimpl.java

📁 基于Sturts+Spring+Hibernate的一个高级销售管理系统。内容丰富
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				ud = customerDao.getUserDefinedById(Integer.parseInt(optionId));
				// 取得相应显示字段
				UserField userField = customerDao.getUserFieldByOption(ud);
				String[] fieldArray = userField.getFieldName().split(",");// 将显示字段转换成数组
				for (String o : fieldArray) {
					fields.add(o);
					System.out.println(o);
				}
				return fields;
			} else {// 默认所有客户
				return null;
			}
		}
		return null;
	}

	// 根据客户id搜索客户
	public Customer getCustomerById(int customerId) throws ApplicationException {
		try {
			return customerDao.getById(customerId);
		} catch (Exception e) {
			throw new ApplicationException(Constants.SEARCHCUSTOMEREXCEPTION);
		}
	}

	// 将客户po封装成vo
	public CustomerVo transaformCustomerPoToVo(String customerId)
			throws ApplicationException {
		CustomerVo customerVo = null;
		try {
			Customer c = getCustomerById(Integer.parseInt(customerId));
			if (c != null) {
				customerVo = new CustomerVo(c.getId(), c.getCustomerName(), c
						.getCreateTime(), c.getLegalRepresent(),
						c.getBizType(), c.getRegisterCapital(), c
								.getIndustryOf(), c.getEmployeeNum(), c
								.getRegionOf(), c.getCommunAddr(),
						c.getPhone(), c.getFax(), c.getZipCode(), c
								.getWebSite(), c.getEmail(),
						c.getHonestGrade(), c.getManagerLevel(), c
								.getBreedVisualize(), c.getCustomerState(), c
								.getCustomerSource(), c.getRemark(), c
								.getProvince(), c.getCity(), c.getCounty(), c
								.getUser());
			}
			return customerVo;
		} catch (Exception e) {
			throw new ApplicationException(Constants.ENCAPSULATIONEXCEPTION);
		}
	}

	// 修改客户
	public boolean updateCustomer(Customer customer)
			throws ApplicationException {
		try {
			customerDao.update(customer);
		} catch (Exception e) {
			throw new ApplicationException(Constants.UPDATECUSTOMEREXCEPTION);
		}
		return true;
	}

	// 删除客户
	public boolean deleteCustomer(int customerId) throws ApplicationException {
		try {
			// 查找该客户下的所有联系人
			List contacts = customerDao.findContactByCustomerId(customerId);
			if (contacts != null) {
				for (Object o : contacts) {
					CustomerContact contact = (CustomerContact) o;
					// 将联系人状态---flag设为2
					contact.setFlag(Constants.ACTIVEFLAG);
				}
			}
			Customer customer = customerDao.getById(customerId);

		} catch (Exception e) {
			throw new ApplicationException(Constants.DELETECUSTOMEREXCEPTION);
		}
		return true;
	}

	// 获得分页显示类
	public PageController getPageController(int currentPage, HttpSession session)
			throws ApplicationException {
		try {
			List customers = (List) session.getAttribute("customers");
			int pageCount = (Integer)session.getAttribute("pageCount");
			System.out.println("有几条记录2:" + customers.size());
			PageController pageController = new PageController(null, pageCount, currentPage, Constants.PAGE_SEARCH_COUNT, customers);
			logger.debug("next1" + currentPage);
			pageController.setCurrentItems(currentPage);
			logger.debug("next2");
			pageController.setPageBar();
			logger.debug("over");
			if(session.getAttribute("pageCount") != null){
				session.removeAttribute("pageCount");
			}
			if(session.getAttribute("customers") != null){
				session.removeAttribute("customers");
			}
			return pageController;
		} catch (Exception e) {
			throw new ApplicationException(Constants.XPAGEEXCEPTION);
		}
	}

	// 将客户选项po封装成vo
	public CustomerDefinedVo transaformCustomerDefinedPoToVo(
			UserDefined userDefined) throws ApplicationException {
		CustomerDefinedVo cdVo = null;
		if (userDefined != null) {
			List<UserFilter> userFilters = customerDao
					.getUserFilterByOption(userDefined);
			UserField userField = customerDao.getUserFieldByOption(userDefined);// 搜索显示字段
			List<String> preField = new ArrayList<String>();
			String[] fieldArray = userField.getFieldName().split(",");// 将显示字段转换成数组
			for (String o : fieldArray) {// 搜索用户自定义客户字段
				preField.add(o);
			}
			List<String> noUserFields = StringTool.filterString(preField);// 提取剩余的字段
			cdVo = new CustomerDefinedVo(userDefined.getId(), userDefined
					.getDefinedName(), userDefined.getType(), userFilters,
					noUserFields, preField);
		}
		return cdVo;
	}

	// 根据id搜索客户选项
	public UserDefined getUserDefinedById(int optionId)
			throws ApplicationException {
		try {
			return customerDao.getUserDefinedById(optionId);
		} catch (Exception e) {
			throw new ApplicationException(Constants.SEARCHOPTIONEXCEPTION);
		}
	}

	// 修改用户选项
	public boolean updateOption(UserDefined userDefined)
			throws ApplicationException {
		try {
			customerDao.updateUserDefined(userDefined);
		} catch (Exception e) {
			throw new ApplicationException(Constants.UPDATEOPTIONEXCEPTION);
		}
		return true;
	}

	// 根据id搜索用户过滤条件
	public UserFilter getUserFilterById(String filterId)
			throws ApplicationException {
		try {
			return customerDao.getUserFilter(Integer.parseInt(filterId));
		} catch (Exception e) {
			throw new ApplicationException(Constants.SEARCHFILTEREXCEPTION);
		}
	}

	// 修改用户选项
	public boolean updateUserFilter(UserFilter userFilter)
			throws ApplicationException {
		try {
			customerDao.updateUserFilter(userFilter);

		} catch (Exception e) {
			throw new ApplicationException(Constants.UPDATEFILTEREXCEPTION);
		}
		return true;
	}

	// 根据选项搜索显示字段
	public UserField getUserFieldByOption(UserDefined userDefined)
			throws ApplicationException {
		try {
			return customerDao.getUserFieldByOption(userDefined);
		} catch (Exception e) {
			throw new ApplicationException(Constants.SEARCHFIELDEXCEPTION);
		}
	}

	// 修改显示字段
	public boolean updateUserField(UserField userField)
			throws ApplicationException {
		try {
			customerDao.updateUserField(userField);
		} catch (Exception e) {
			throw new ApplicationException(Constants.UPDATEFIELDEXCEPTION);
		}
		return true;
	}

	// 删除过滤条件
	public boolean deleteFilter(UserFilter userFilter)
			throws ApplicationException {
		try {
			customerDao.deleteFilter(userFilter);
		} catch (Exception e) {
			throw new ApplicationException(Constants.DELETEFILTEREXCEPTION);
		}
		return true;
	}

	/**
	 * 处理左页面的最新客户;
	 */
	public List<Customer> getTopCustomer() throws ApplicationException {
		try {
			return customerDao.getTopCustomer();
		} catch (Exception e) {
			throw new ApplicationException(Constants.FINDCUSTOMEREXCEPTION);
		}
	}

	public List<Customer> getCustomerByName(String nameLike)
			throws ApplicationException {
		try {
			return customerDao.getCustomerByName(nameLike);
		} catch (Exception e) {
			throw new ApplicationException(Constants.FINDCUSTOMEREXCEPTION);
		}
	}

	public boolean clearCustomer(Integer id) throws ApplicationException {
		try {
			customerDao.clearCustomer(id);
		} catch (Exception e) {
			throw new ApplicationException(Constants.DELETEFIALURE);
		}
		return true;
	}

	// 查找被删除的客户
	public List<CustomerVo> getCustomerByDelete() throws ApplicationException {
		try {
			List customers = null;
			List<CustomerVo> customerVos = new ArrayList<CustomerVo>();
			if (customers != null) {
				for (Object o : customers) {
					Customer customer = (Customer) o;
					// 查找上一次修改人
					User user = customerDao.getUserById(customer
							.getModifyManId());
					logger.debug("修改人名称:" + user.getFamilyName());
					if (user != null) {
						customerVos.add(new CustomerVo(customer.getId(),
								customer.getCustomerName(), customer
										.getLastModifyTime(), user
										.getFamilyName()));
					}
				}
			}
			return customerVos;
		} catch (Exception e) {
			throw new ApplicationException(Constants.FINDCUSTOMEREXCEPTION);
		}
	}

	// -------------------------------------------更新后---------------------------------//
	public List<ContactVo> getContactByCustomerId(String customerId)
			throws ApplicationException {
		try {
			if (StringTool.isNotBlank(customerId)) {
				List contacts = customerDao.findContactByCustomerId(Integer
						.parseInt(customerId));
				List<ContactVo> contactList = new ArrayList<ContactVo>();
				for (Object o : contacts) {
					CustomerContact contact = (CustomerContact) o;
					contactList.add(new ContactVo());
				}
				return contactList;
			} else {
				return null;
			}
		} catch (Exception e) {
			throw new ApplicationException(Constants.FINDCONTACTEXCEPTION);
		}
	}

	public List<Customer> getCustomerByUser(User user)
			throws ApplicationException {
		// TODO Auto-generated method stub
		return null;
	}	
}

⌨️ 快捷键说明

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