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

📄 serviceorderdaoimpl.java

📁 基于Sturts+Spring+Hibernate的一个高级销售管理系统。内容丰富
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
				hql.append(" and so.customerContact.name"
						+ userFilter.getOperator() + " "
						+ userFilter.getFilterValue());
			} else if (userFilter.getFilterName().equals(
					StringTool.getSOFieldName("8"))) {
				hql.append(" and so.category.name" + userFilter.getOperator()
						+ " " + userFilter.getFilterValue());
			} else if (userFilter.getFilterName().equals(
					StringTool.getSOFieldName("9"))) {
				hql.append(" and so.faultLevel.name" + userFilter.getOperator()
						+ " " + userFilter.getFilterValue());
			} else if (userFilter.getFilterName().equals(
					StringTool.getSOFieldName("10"))) {
				hql.append(" and so.source.name" + userFilter.getOperator()
						+ " " + userFilter.getFilterValue());
			} else if (userFilter.getFilterName().equals(
					StringTool.getSOFieldName("11"))) {
				hql.append(" and so.engineer.familyName"
						+ StringTool.getSOFieldName("11") + " "
						+ userFilter.getOperator() + " "
						+ userFilter.getFilterValue());
			} else if (userFilter.getFilterName().equals(
					StringTool.getSOFieldName("12"))) {
				hql.append(" and so.visiter.familyName"
						+ userFilter.getOperator() + " "
						+ userFilter.getFilterValue());
			} else if (userFilter.getFilterName().equals(
					StringTool.getSOFieldName("13"))) {
				hql.append(" and so." + StringTool.getSOFieldName("13") + " "
						+ userFilter.getOperator() + " "
						+ userFilter.getFilterValue());
			} else if (userFilter.getFilterName().equals(
					StringTool.getSOFieldName("14"))) {
				hql.append(" and so." + StringTool.getSOFieldName("14") + " "
						+ userFilter.getOperator() + " "
						+ userFilter.getFilterValue());
			}
		}
	}


	
	// 更新该用户所有自定义的选项为非默认的搜索选项
	public void updateMyAllOption(int type, int isDefined, User user) {
		final String hql = "update UserDefined as ud set ud.isDefined = "
				+ isDefined + " where ud.type=" + type + " and ud.user.id ="
				+ user.getId();
		logger.debug("更新语句是:" + hql);
		try {
			Query query = super.getSession().createQuery(hql);
			query.executeUpdate();
			logger.debug("更新成功");
		} catch (RuntimeException re) {
			log.error("update all failed", re);
			throw re;
		}
	}
	
	//*********************************用户 客户 联系人的调用的方法******************************************************//
	// 取所有的用户进行指派
	public List<User> getUserPage(String familyName, String path, int currentPage,
			int rowsPerPage) {
		StringBuffer hql = new StringBuffer("from User u where 1=1 and u.id!=0");
		if (familyName != null && !"".equals(familyName)
				&& !"null".equals(familyName)) {
			hql.append(" and u.familyName like '%" + familyName + "%' ");
		}
		hql.append(" order by u.id ");
		logger.debug("--hql--:" + hql);
		List<User> userList = null;
		try {
			Query query = super.getSession().createQuery(hql.toString());
			query.setFirstResult((currentPage - 1) * rowsPerPage);
			query.setMaxResults(rowsPerPage);
			userList = query.list();
		} catch (RuntimeException re) {
			logger.error(re.getMessage());
			throw re;
		}
		return userList;
	}
	//取所有的用户数
	public int getUserPageCount(String familyName){
		StringBuffer hql = new StringBuffer("select count(*) from User u where 1=1 and u.id!=0");
		if (familyName != null && !"".equals(familyName)
				&& !"null".equals(familyName)) {
			hql.append(" and u.familyName like '%" + familyName + "%' ");
		}
		int count = 0;
		try {
			Query query = this.getSession().createQuery(hql.toString());
			List list = query.list();
			Object o = (Object)list.get(0);
			count = Integer.parseInt(o.toString());
		} catch (RuntimeException re) {
			logger.error(re.getMessage());
			throw re;
		}
		return count;
	}

	// 通过id取得用户
	public User getUserById(int userId) {
		try {
			User user = (User) getHibernateTemplate().get(
					"com.yuanchung.sales.model.user.User", userId);
			return user;
		} catch (RuntimeException re) {
			logger.error(re.getMessage());
			throw re;
		}
	}
	// 查找所有的客户
	public List<Customer> searchCustomers(String customerName, String path,
			int currentPage, int rowsPerPage) {
		int count = 0;
		List<Customer> customerList = null;
		StringBuffer hql = new StringBuffer("from Customer cust where 1=1 and cust.flag = 1");//flag = 1表示只搜索激活的客户
		if (customerName != null && !"".equals(customerName)
				&& !"null".equals(customerName)) {
			hql.append(" and cust.customerName like '%" + customerName + "%'");
		}
		logger.debug("取所有的客户hql======" + hql.toString());
		try {
			Query query = super.getSession().createQuery(hql.toString());
			query.setFirstResult((currentPage - 1) * rowsPerPage);
			query.setMaxResults(rowsPerPage);
			customerList = query.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
		return customerList;
	}
	
	// 查找所有的客户个数
	public int searchCustomersCount(String customerName) {
		int count = 0;
		StringBuffer hql = new StringBuffer("select count(*) from Customer cust where 1=1 and cust.flag = 1");//flag = 1表示只搜索激活的客户
		if (customerName != null && !"".equals(customerName)
				&& !"null".equals(customerName)) {
			hql.append(" and cust.customerName like '%" + customerName + "%'");
		}
		logger.debug("取所有的客户hql======" + hql.toString());
		try {
			Query query = super.getSession().createQuery(hql.toString());
			List list = query.list();
			Object o = (Object)list.get(0);
			count = Integer.parseInt(o.toString());
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
		return count;
	}
	
	// 查找所有的联系人
	public List<CustomerContact> searchContacters(int customerId, String name, String path,
			int currentPage, int rowsPerPage) {
		List<CustomerContact> customerContactList = null;
		StringBuffer hql = new StringBuffer("from CustomerContact contact");
		hql.append(" where 1=1 and contact.flag = 1");//flag = 1表示只搜索激活的联系人
		if (customerId != 0) {
			hql.append(" and contact.customer.id=" + customerId);
		}
		if (name != null && !"".equals(name) && !"null".equals(name)) {
			hql.append(" and contact.name like '%" + name + "%'");
		}
		logger.debug("取所有的联系人hql======" + hql.toString());
		try {
			Query query = super.getSession().createQuery(hql.toString());
			query.setFirstResult((currentPage - 1) * rowsPerPage);
			query.setMaxResults(rowsPerPage);
			customerContactList = query.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
		return customerContactList;
	}
	
	// 查找所有的联系人个数
	public int searchContactersCount(int customerId, String name) {
		int count = 0;
		StringBuffer hql = new StringBuffer("select count(*) from CustomerContact contact");
		hql.append(" where 1=1 and contact.flag = 1");//flag = 1表示只搜索激活的联系人
		if (customerId != 0) {
			hql.append(" and contact.customer.id=" + customerId);
		}
		if (name != null && !"".equals(name) && !"null".equals(name)) {
			hql.append(" and contact.name like '%" + name + "%'");
		}
		logger.debug("取所有的联系人hql======" + hql.toString());
		try {
			Query query = super.getSession().createQuery(hql.toString());
			List list = query.list();
			Object o = (Object)list.get(0);
			count = Integer.parseInt(o.toString());
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
		return count;
	}

	// 通过id取联系人
	public Customer getCustomerById(int customerId) {
		try {
			return (Customer) getHibernateTemplate().get(Customer.class,
					customerId);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	// 通过id取联系人
	public CustomerContact getContactById(int contactId) {
		try {
			return (CustomerContact) getHibernateTemplate().get(
					CustomerContact.class, contactId);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
	//通过客户ID查找联系人
	public List<CustomerContact> getContactByCustomerId(int customerId){
		List<CustomerContact> customerContactList = null;
		String hql = "from CustomerContact cc where cc.customer.id="+customerId;
		try {
			customerContactList = this.getSession().createQuery(hql).list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
		return customerContactList;
	}
	//保存临时联系人
	public void saveCustomerContact(CustomerContact customerContact){
		try{
			getHibernateTemplate().save(customerContact);
		}catch(RuntimeException re){
			logger.error("save CustomerContact failed");
		}
	}
	
	//取ID最大的联系人也就是刚保存的联系人
	public CustomerContact getCustomerContactByMaxId(){
		CustomerContact customerContact = null;
		try {
			String queryString1 = "from CustomerContact cc";
			String queryString2 = "from CustomerContact cc where cc.id = (select max(id) from CustomerContact where 1=1)";
			List<ServiceOrder> solist1 = super.getSession().createQuery(
					queryString1).list();
			if (solist1.size()>0) {
				List<CustomerContact> solist2 = super.getSession().createQuery(
						queryString2).list();
				customerContact = solist2.get(0);
			}
		} catch (RuntimeException re) {
			log.error("find by customerContact failed", re);
			throw re;
		}
		return customerContact;
	}
	
	//*********************************在线问题单调用的方法********************************************//
	// 在线获取客户服务单
	public List<ServiceOrder> getMyOnlineOrder(String state, int flag, int customerId,
			String path, int currentPage, int rowsPerPage) {
		List<ServiceOrder> serviceOrderList = null;
		StringBuffer hql = new StringBuffer(
				"from ServiceOrder so where 1=1 and so.customer.id="
						+ customerId);
		hql.append(" and so.flag =" + flag);
		if (state != null && !"".equals(state) && !"null".equals(state)) {
			hql.append(" and so.state ='" + state + "'");
		}
		hql.append(" order by so.createTime desc");
		logger.debug("在线获取客户服务单hql======" + hql.toString());
		try {
			Query query = super.getSession().createQuery(hql.toString());
			query.setFirstResult((currentPage - 1) * rowsPerPage);
			query.setMaxResults(rowsPerPage);
			serviceOrderList = query.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
		return serviceOrderList;
	}
	
	// 在线获取客户服务单个数
	public int getMyOnlineOrderCount(String state, int flag, int customerId) {
		int count = 0;
		StringBuffer hql = new StringBuffer(
				"select count(*) from ServiceOrder so where 1=1 and so.customer.id="
						+ customerId);
		hql.append(" and so.flag =" + flag);
		if (state != null && !"".equals(state) && !"null".equals(state)) {
			hql.append(" and so.state ='" + state + "'");
		}
		hql.append(" order by so.createTime desc");
		logger.debug("在线获取客户服务单hql======" + hql.toString());
		try {
			Query query = super.getSession().createQuery(hql.toString());
			List list = query.list();
			Object o = (Object)list.get(0);
			count = Integer.parseInt(o.toString());
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
		return count;
	}
}

⌨️ 快捷键说明

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