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

📄 ordermgrimpl.java

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

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.dao.DataAccessException;

import com.yuanchung.sales.dao.order.OrderDAO;
import com.yuanchung.sales.exception.ApplicationException;
import com.yuanchung.sales.model.customer.Customer;
import com.yuanchung.sales.model.customer.CustomerContact;
import com.yuanchung.sales.model.order.Order;
import com.yuanchung.sales.model.user.User;
import com.yuanchung.sales.service.order.OrderMgr;
import com.yuanchung.sales.util.Constants;
import com.yuanchung.sales.util.SessionMgr;
import com.yuanchung.sales.vo.CustomerVo;
import com.yuanchung.sales.vo.order.CustomerOrderVo;
import com.yuanchung.sales.vo.order.OrderVo;

//import com.yuanchung.sales.vo.right.WebRightsView;

public class OrderMgrImpl implements OrderMgr {

	private static Logger logger = Logger.getLogger(OrderMgrImpl.class);
	private OrderDAO orderDao;
	
	public OrderDAO getOrderDao() {
		return orderDao;
	}

	public void setOrderDao(OrderDAO orderDao) {
		this.orderDao = orderDao;
	}
	
/*
	private AuthorizationMgr authorizationMgr;
	private UtilDAO utilDao;

	public UtilDAO getUtilDao() {
		return utilDao;
	}

	public void setUtilDao(UtilDAO utilDao) {
		this.utilDao = utilDao;
	}

	public void setAuthorizationMgr(AuthorizationMgr authorizationMgr) {
		this.authorizationMgr = authorizationMgr;
	}
*/
	
	// 1.根据ID查找客户
	public Customer getCustomerById(int customerId) throws ApplicationException {
		try {
			return orderDao.getCustomerById(customerId);
		} catch (Exception e) {
			e.printStackTrace();
			throw new ApplicationException(Constants.WITHOUTDATA);
		}
	}

	// 2.新增订单
	public boolean addOrder(Order order) throws ApplicationException {
		try {
			orderDao.save(order);
		} catch (Exception e) {
			throw new ApplicationException(Constants.ADDORDEREXCEPTION);
		}
		return true;
	}

	// 3.通过用户搜索所有的客户
	public List<CustomerVo> getCustomerByUser(User user, int flag)
			throws ApplicationException {
		List customers = orderDao.getCustomerByUser(user, flag);
		List<CustomerVo> result = new ArrayList<CustomerVo>();
		try {
			for (Object o : customers) {
				// 强制转换
				Customer c = (Customer) o;
				// 将客户PO封装成VO
				result.add(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 result;
		} catch (Exception e) {
			throw new ApplicationException(Constants.GETCUSTOMEREXCEPTION);
		}

	}

	// 4.根据名称模糊查询客户
	public List<CustomerVo> getCustomerByNamelike(String customerName,
			HttpServletRequest request) throws ApplicationException {
		User user = SessionMgr.getCustSession(request);
		List customers = orderDao.getCustomerByNamelike(user, customerName);
		List<CustomerVo> result = new ArrayList<CustomerVo>();
		try {
			for (Object o : customers) {
				Customer c = (Customer) o;
				result.add(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 result;
		} catch (Exception e) {
			throw new ApplicationException(Constants.GETCUSTOMEREXCEPTION);
		}
	}

	// 5.查询所有的订单
	@SuppressWarnings("unchecked")
	public List<OrderVo> getAllOrder(User user) throws ApplicationException {
		List<OrderVo> result = new ArrayList<OrderVo>();
		List<Order> orders = orderDao.getAllOrder(user);
		try {
			for (Object o : orders) {
				Order oo = (Order) o;
				result.add(new OrderVo(oo.getOrderId(), oo.getOrderDate(), oo
						.getCustomer(), oo.getCustomercontact(), oo
						.getDeliveryDate()));
			}
			return result;
		} catch (Exception e) {
			throw new ApplicationException(Constants.FINDORDEREXCEPTION);
		}
	}

	/*
	 * public List<OrderVo> getAllOrder(String userIds, HttpServletRequest
	 * request) throws ApplicationException {
	 *  }
	 */
	/*
	 * // 初始化用户自定义选项 public UserDefined initUserDefined(User user, String
	 * definedName, int type, Date inDate) throws ApplicationException; //
	 * 增加用户自定义选项 public void addUserDefined(UserDefined userDefined) throws
	 * ApplicationException; // 将值转换字段 public String getStringByField(String
	 * fieldInt); // 增加用户过滤选项 public UserFilter initUserFilter(UserDefined
	 * userDefined, String filterName, String operatorName, String operator,
	 * String filterValue, String filter) throws ApplicationException; // 增加用户过滤
	 * public void addUserFilter(UserFilter userFilter) throws
	 * ApplicationException; // 初始化用户显示字段 public UserField
	 * initUserFiled(UserDefined userDefined, String optionFields) throws
	 * ApplicationException; // 增加用户显示字段 public void addUserFiled(UserField
	 * userField) throws ApplicationException; // 根据用户和类型查找选项 public List<UserDefined>
	 * getOptionsByUserAndType(User user, int type) throws ApplicationException; //
	 * 根据id搜索客户选项 public UserDefined getUserDefinedById(int optionId) throws
	 * ApplicationException; // 将客户选项po封装成vo public BusiOpportDefinedVo
	 * transaformBusiOpportDefinedPoToVo( UserDefined userDefined) throws
	 * ApplicationException;
	 * 
	 * public List<String> filterString(List<String> preField); // 修改用户选项
	 * public boolean updateOption(UserDefined userDefined) throws
	 * ApplicationException; // 根据id搜索用户过滤条件 public UserFilter
	 * getUserFilterById(String filterId) throws ApplicationException; // 修改用户选项
	 * public boolean updateUserFilter(UserFilter userFilter) throws
	 * ApplicationException; // 根据选项搜索显示字段 public UserField
	 * getUserFieldByOption(UserDefined userDefined) throws
	 * ApplicationException; // 修改显示字段 public boolean updateUserField(UserField
	 * userField) throws ApplicationException;
	 */

	// 6.根据客户名称查找订单
	public List<CustomerOrderVo> getOrderByCustomerName(String customerName) throws ApplicationException {
		return orderDao.getOrderByCustomerName(customerName);
	}

	/*
	 * // 7.根据订单号查找订单VO public OrderVo getOrderVoById(int orderId) throws
	 * ApplicationException { try { Order order = this.getOrderById(orderId);
	 * return new
	 * OrderVo(order.getOrderId(),order.getOrderDate(),order.getCustomer(),
	 * order.getCustomercontact(),order.getDeliveryDate()); } catch (Exception
	 * e) { e.printStackTrace(); logger.debug("transform exception"); throw new
	 * ApplicationException("transform exception"); } }
	 */
	
	// 8.编辑订单
	public boolean updateOrder(Order order) throws ApplicationException {
		try {
			orderDao.update(order);
		} catch (Exception e) {
			throw new ApplicationException(Constants.MODIFYORDEREXCEPTION);
		}
		return true;
	}

	// 9.删除订单
	public boolean deletOrder(Order order) throws ApplicationException {
		try {
			orderDao.delete(order);
		} catch (Exception e) {
			e.printStackTrace();
			logger.debug(Constants.DELETEORDEREXCEPTION);
		}
		return true;
	}

	// 10.查看前几张订单
	public List getTopOrder() throws ApplicationException {
		try {
			return orderDao.getTopOrder();
		} catch (Exception e) {
			throw new ApplicationException(Constants.FINDORDEREXCEPTION);
		}
	}

	// 11.查看被删除的订单;
	public List getAllOrderByDelete() throws ApplicationException {
		try {
			return null;
		} catch (Exception e) {
			throw new ApplicationException(Constants.FINDORDEREXCEPTION);
		}
	}

	// 12.根据ID查找联系人
	public CustomerContact getCustomerContactById(int customercontactId)
			throws DataAccessException {
		return orderDao.getCustomerContactById(customercontactId);
	}

	// 13.根据订单号查找订单
	public Order getOrderById(int orderId){
		return orderDao.getOrderById(orderId);
	}

}

⌨️ 快捷键说明

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