欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SSH+JSP+EasyUI+Mysql实现的CRM客户关系管理系统(客户信息管理、产品信息管理、系统管理、角色权限管理)

程序员文章站 2022-07-14 22:32:35
...

SSH CRM客户管理系统

CRM系统用来管理和维护公司的客户,节省了人力维护的成本,可以更好的优化和提升公司管理的效率,并更好的留存客户。

功能实现截图:

主要功能点:
1.登录管理模块:用户使用正确的账号和密码,登录到系统内部。
2.客户管理模块:可以添加,修改,删除,查询客户信息,通过这个模块就可以录入客户的详细信息。
3.产品管理模块:通过这个模块可以对企业的产品进行管理,增加,修改,删除,查询产品信息。正是因为这个模块,才可能为客户快速的推送服务。
4.系统管理模块:系统管理模块的目的就是定义角色,不同的角色拥有不同的权限。

页面:

登录页面:
SSH+JSP+EasyUI+Mysql实现的CRM客户关系管理系统(客户信息管理、产品信息管理、系统管理、角色权限管理)
主界面:
SSH+JSP+EasyUI+Mysql实现的CRM客户关系管理系统(客户信息管理、产品信息管理、系统管理、角色权限管理)

产品信息管理:
SSH+JSP+EasyUI+Mysql实现的CRM客户关系管理系统(客户信息管理、产品信息管理、系统管理、角色权限管理)
客户信息管理:
SSH+JSP+EasyUI+Mysql实现的CRM客户关系管理系统(客户信息管理、产品信息管理、系统管理、角色权限管理)
角色管理:
SSH+JSP+EasyUI+Mysql实现的CRM客户关系管理系统(客户信息管理、产品信息管理、系统管理、角色权限管理)

系统分析和流程图

1、系统总用例图
SSH+JSP+EasyUI+Mysql实现的CRM客户关系管理系统(客户信息管理、产品信息管理、系统管理、角色权限管理)
客户管理用例图:
SSH+JSP+EasyUI+Mysql实现的CRM客户关系管理系统(客户信息管理、产品信息管理、系统管理、角色权限管理)
产品管理用例图:
SSH+JSP+EasyUI+Mysql实现的CRM客户关系管理系统(客户信息管理、产品信息管理、系统管理、角色权限管理)
系统管理用例图:
SSH+JSP+EasyUI+Mysql实现的CRM客户关系管理系统(客户信息管理、产品信息管理、系统管理、角色权限管理)

2、系统功能流程图:
SSH+JSP+EasyUI+Mysql实现的CRM客户关系管理系统(客户信息管理、产品信息管理、系统管理、角色权限管理)
3、数据库E-R图:
SSH+JSP+EasyUI+Mysql实现的CRM客户关系管理系统(客户信息管理、产品信息管理、系统管理、角色权限管理)

技术点介绍

本系统的实际分为两个部分,一个是前端的实现,一个是后台的实现。对于后台部分设计,根据需求分析,采用SSH作为系统的主体框架,整合mysql数据库提供数据上的支持。前端的设计,关系到客户与系统交互的友好性,采用jsp技术来实现。需要的工具有myeclipse,tomcat(可以是myeclipse自带的tomcat),mysql(配合使用HeidiSql)

代码

页面设计:
登录页面:login.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="cn">
<!-- BEGIN HEAD -->
<head>
	<meta charset="utf-8" />
	<title>login.jsp</title>
	<meta content="width=device-width, initial-scale=1.0" name="viewport" />
	<meta content="" name="description" />
	<meta content="" name="author" />
	<jsp:include page="/media/ui_css.jsp"></jsp:include>
	<!-- BEGIN PAGE LEVEL STYLES -->
	<link href="<%=basePath%>media/css/login-soft.css" rel="stylesheet" type="text/css"/>
	<!-- END PAGE LEVEL STYLES -->
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="login">
	<!-- BEGIN LOGO -->
	<div class="logo"> </div>
	<!-- END LOGO -->
	<!-- BEGIN LOGIN -->
	<div class="content">
		<!-- begin 登录提示框 -->
		<div style="display:none;"><a href="#myModal2" role="button" id="btnerr" class="btn btn-danger" data-toggle="modal"></a></div>
		<div id="myModal2" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2" aria-hidden="true">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
				<h3 id="myModalLabel2" style="color:black;">提示信息</h3>
			</div>
			<div class="modal-body" >
				<p id="errmsg" style="color:black;"></p>
			</div>
			<div class="modal-footer">
				<button data-dismiss="modal" class="btn green">取消</button>
			</div>
		</div>
		<!-- end 登录提示框 -->
		<!-- BEGIN LOGIN FORM -->
		<form class="form-vertical login-form" action="hr_emp!login" method="post" >
			<h3 class="form-title" style="text-align: center;">CRM管理系统登录</h3>
			<div class="alert alert-error hide">
				<button class="close" data-dismiss="alert"></button>
				<span>请输入您的用户名和密码.</span>
			</div>
			<div class="control-group">
				<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
				<label class="control-label visible-ie8 visible-ie9">用户名</label>
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-user"></i>
						<input class="m-wrap placeholder-no-fix" type="text" placeholder="用户名" name="name"/>
					</div>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label visible-ie8 visible-ie9">密码</label>
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-lock"></i>
						<input class="m-wrap placeholder-no-fix" type="password" placeholder="密码" name="pwd"/>
					</div>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label visible-ie8 visible-ie9">验证码</label>
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-tag"></i>
						<input class="m-wrap placeholder-no-fix" type="text" placeholder="验证码" name="inpcode" style="width:100px;"/>
						<iframe src="<%=basePath%>hr_emp!ajaxValidateCode" id="iframecode" style="height:34px; width:85px; margin: 0px;" frameborder="0" scrolling="no" ></iframe>
						<div style="float: right;" >
							<a href="#" id="showcode"  class="btn blue" style="width: 28px; height: 20px;"><i class="icon-refresh" style="margin:2px 8px;"></i></a>
						</div>
					</div>
				</div>
			</div>
			<div class="form-actions">
				<button type="submit" class="btn blue pull-right">
				登录 <i class="m-icon-swapright m-icon-white"></i>
				</button>
			</div>
			<div class="forget-password">
				<h4>忘记密码 ?</h4>
				<p>
				  点击 <a href="javascript:;" class="" id="forget-password">这里</a>
					找回你的密码.
				</p>
			</div>
			<div class="create-account">
				<p>还没有账号 ?&nbsp; 
					<a href="javascript:;" id="register-btn" class="">注册账号</a>
				</p>
			</div>
		</form>
		<!-- END LOGIN FORM -->        
		<!-- BEGIN FORGOT PASSWORD FORM -->
		<form class="form-vertical forget-form" action="index.html">
			<h3 class="">忘记密码 ?</h3>
			<p>输入您的电子邮件地址重置您的密码.</p>
			<div class="control-group">
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-envelope"></i>
						<input class="m-wrap placeholder-no-fix" type="text" placeholder="邮箱" name="email" />
					</div>
				</div>
			</div>
			<div class="form-actions">
				<button type="button" id="back-btn" class="btn">
				<i class="m-icon-swapleft"></i> 返回
				</button>
				<button type="submit" class="btn blue pull-right">
				提交 <i class="m-icon-swapright m-icon-white"></i>
				</button>            
			</div>
		</form>
		<!-- END FORGOT PASSWORD FORM -->
		<!-- BEGIN REGISTRATION FORM -->
		<form class="form-vertical register-form" action="index.html">
			<h3 class="">注册</h3>
			<p>在下面输入您的帐户资料:</p>
			<div class="control-group">
				<label class="control-label visible-ie8 visible-ie9">用户名</label>
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-user"></i>
						<input class="m-wrap placeholder-no-fix" type="text" placeholder="用户名" name="username"/>
					</div>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label visible-ie8 visible-ie9">密码</label>
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-lock"></i>
						<input class="m-wrap placeholder-no-fix" type="password" id="register_password" placeholder="密码" name="password"/>
					</div>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label visible-ie8 visible-ie9">请重新输入您的密码</label>
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-ok"></i>
						<input class="m-wrap placeholder-no-fix" type="password" placeholder="重复密码" name="rpassword"/>
					</div>
				</div>
			</div>
			<div class="control-group">
				<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
				<label class="control-label visible-ie8 visible-ie9">邮箱</label>
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-envelope"></i>
						<input class="m-wrap placeholder-no-fix" type="text" placeholder="邮箱" name="email"/>
					</div>
				</div>
			</div>
			<div class="control-group">
				<div class="controls">
					<label class="checkbox">
					<input type="checkbox" name="tnc"/> 我同意 <a href="#">服务条件</a><a href="#">隐私政策</a>
					</label>  
					<div id="register_tnc_error"></div>
				</div>
			</div>
			<div class="form-actions">
				<button id="register-back-btn" type="button" class="btn">
				<i class="m-icon-swapleft"></i>  返回
				</button>
				<button type="submit" id="register-submit-btn" class="btn blue pull-right">
				注册 <i class="m-icon-swapright m-icon-white"></i>
				</button>            
			</div>
		</form>
		<!-- END REGISTRATION FORM -->
	</div>
	<!-- END LOGIN -->
	<!-- BEGIN COPYRIGHT -->
	<div class="copyright">2017 &copy; Asiainfo - CRM客户关系管理系统</div>
	<!-- END COPYRIGHT -->
	<jsp:include page="/media/ui_js.jsp"></jsp:include>
	<!-- BEGIN PAGE LEVEL PLUGINS -->
	<script src="<%=basePath%>media/js/jquery.validate.min.js" type="text/javascript"></script>
	<script src="<%=basePath%>media/js/jquery.backstretch.min.js" type="text/javascript"></script>
	<!-- END PAGE LEVEL PLUGINS -->
	<!-- BEGIN PAGE LEVEL SCRIPTS -->
	<script src="<%=basePath%>media/js/app.js" type="text/javascript"></script>
	<script src="<%=basePath%>media/js/login-soft.js" type="text/javascript"></script>       
	<!-- END PAGE LEVEL SCRIPTS --> 
	<script>
		jQuery(document).ready(function() {     
		  App.init();
		  Login.init();
		});
		$(function(){
			$("#showcode").click(function(){
				var url="<%=basePath%>hr_emp!ajaxValidateCode?v="+new Date().valueOf();
				window.parent.frames[0].location.href=url;
			});
			
			var err='${err}';
			if(err!=''){
				$("#errmsg").text(err);
				$("#btnerr").click();
			}
		});
	</script>
	<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>

主页面:index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="cn">
<!-- BEGIN HEAD -->
<head>
	<meta charset="utf-8" />
	<title>login.jsp</title>
	<meta content="width=device-width, initial-scale=1.0" name="viewport" />
	<meta content="" name="description" />
	<meta content="" name="author" />
	<jsp:include page="/media/ui_css.jsp"></jsp:include>
	<!-- BEGIN PAGE LEVEL STYLES -->
	<link href="<%=basePath%>media/css/login-soft.css" rel="stylesheet" type="text/css"/>
	<!-- END PAGE LEVEL STYLES -->
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="login">
	<!-- BEGIN LOGO -->
	<div class="logo"> </div>
	<!-- END LOGO -->
	<!-- BEGIN LOGIN -->
	<div class="content">
		<!-- begin 登录提示框 -->
		<div style="display:none;"><a href="#myModal2" role="button" id="btnerr" class="btn btn-danger" data-toggle="modal"></a></div>
		<div id="myModal2" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2" aria-hidden="true">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
				<h3 id="myModalLabel2" style="color:black;">提示信息</h3>
			</div>
			<div class="modal-body" >
				<p id="errmsg" style="color:black;"></p>
			</div>
			<div class="modal-footer">
				<button data-dismiss="modal" class="btn green">取消</button>
			</div>
		</div>
		<!-- end 登录提示框 -->
		<!-- BEGIN LOGIN FORM -->
		<form class="form-vertical login-form" action="hr_emp!login" method="post" >
			<h3 class="form-title" style="text-align: center;">CRM管理系统登录</h3>
			<div class="alert alert-error hide">
				<button class="close" data-dismiss="alert"></button>
				<span>请输入您的用户名和密码.</span>
			</div>
			<div class="control-group">
				<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
				<label class="control-label visible-ie8 visible-ie9">用户名</label>
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-user"></i>
						<input class="m-wrap placeholder-no-fix" type="text" placeholder="用户名" name="name"/>
					</div>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label visible-ie8 visible-ie9">密码</label>
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-lock"></i>
						<input class="m-wrap placeholder-no-fix" type="password" placeholder="密码" name="pwd"/>
					</div>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label visible-ie8 visible-ie9">验证码</label>
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-tag"></i>
						<input class="m-wrap placeholder-no-fix" type="text" placeholder="验证码" name="inpcode" style="width:100px;"/>
						<iframe src="<%=basePath%>hr_emp!ajaxValidateCode" id="iframecode" style="height:34px; width:85px; margin: 0px;" frameborder="0" scrolling="no" ></iframe>
						<div style="float: right;" >
							<a href="#" id="showcode"  class="btn blue" style="width: 28px; height: 20px;"><i class="icon-refresh" style="margin:2px 8px;"></i></a>
						</div>
					</div>
				</div>
			</div>
			<div class="form-actions">
				<button type="submit" class="btn blue pull-right">
				登录 <i class="m-icon-swapright m-icon-white"></i>
				</button>
			</div>
			<div class="forget-password">
				<h4>忘记密码 ?</h4>
				<p>
				  点击 <a href="javascript:;" class="" id="forget-password">这里</a>
					找回你的密码.
				</p>
			</div>
			<div class="create-account">
				<p>还没有账号 ?&nbsp; 
					<a href="javascript:;" id="register-btn" class="">注册账号</a>
				</p>
			</div>
		</form>
		<!-- END LOGIN FORM -->        
		<!-- BEGIN FORGOT PASSWORD FORM -->
		<form class="form-vertical forget-form" action="index.html">
			<h3 class="">忘记密码 ?</h3>
			<p>输入您的电子邮件地址重置您的密码.</p>
			<div class="control-group">
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-envelope"></i>
						<input class="m-wrap placeholder-no-fix" type="text" placeholder="邮箱" name="email" />
					</div>
				</div>
			</div>
			<div class="form-actions">
				<button type="button" id="back-btn" class="btn">
				<i class="m-icon-swapleft"></i> 返回
				</button>
				<button type="submit" class="btn blue pull-right">
				提交 <i class="m-icon-swapright m-icon-white"></i>
				</button>            
			</div>
		</form>
		<!-- END FORGOT PASSWORD FORM -->
		<!-- BEGIN REGISTRATION FORM -->
		<form class="form-vertical register-form" action="index.html">
			<h3 class="">注册</h3>
			<p>在下面输入您的帐户资料:</p>
			<div class="control-group">
				<label class="control-label visible-ie8 visible-ie9">用户名</label>
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-user"></i>
						<input class="m-wrap placeholder-no-fix" type="text" placeholder="用户名" name="username"/>
					</div>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label visible-ie8 visible-ie9">密码</label>
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-lock"></i>
						<input class="m-wrap placeholder-no-fix" type="password" id="register_password" placeholder="密码" name="password"/>
					</div>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label visible-ie8 visible-ie9">请重新输入您的密码</label>
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-ok"></i>
						<input class="m-wrap placeholder-no-fix" type="password" placeholder="重复密码" name="rpassword"/>
					</div>
				</div>
			</div>
			<div class="control-group">
				<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
				<label class="control-label visible-ie8 visible-ie9">邮箱</label>
				<div class="controls">
					<div class="input-icon left">
						<i class="icon-envelope"></i>
						<input class="m-wrap placeholder-no-fix" type="text" placeholder="邮箱" name="email"/>
					</div>
				</div>
			</div>
			<div class="control-group">
				<div class="controls">
					<label class="checkbox">
					<input type="checkbox" name="tnc"/> 我同意 <a href="#">服务条件</a><a href="#">隐私政策</a>
					</label>  
					<div id="register_tnc_error"></div>
				</div>
			</div>
			<div class="form-actions">
				<button id="register-back-btn" type="button" class="btn">
				<i class="m-icon-swapleft"></i>  返回
				</button>
				<button type="submit" id="register-submit-btn" class="btn blue pull-right">
				注册 <i class="m-icon-swapright m-icon-white"></i>
				</button>            
			</div>
		</form>
		<!-- END REGISTRATION FORM -->
	</div>
	<!-- END LOGIN -->
	<!-- BEGIN COPYRIGHT -->
	<div class="copyright">2017 &copy; Asiainfo - CRM客户关系管理系统</div>
	<!-- END COPYRIGHT -->
	<jsp:include page="/media/ui_js.jsp"></jsp:include>
	<!-- BEGIN PAGE LEVEL PLUGINS -->
	<script src="<%=basePath%>media/js/jquery.validate.min.js" type="text/javascript"></script>
	<script src="<%=basePath%>media/js/jquery.backstretch.min.js" type="text/javascript"></script>
	<!-- END PAGE LEVEL PLUGINS -->
	<!-- BEGIN PAGE LEVEL SCRIPTS -->
	<script src="<%=basePath%>media/js/app.js" type="text/javascript"></script>
	<script src="<%=basePath%>media/js/login-soft.js" type="text/javascript"></script>       
	<!-- END PAGE LEVEL SCRIPTS --> 
	<script>
		jQuery(document).ready(function() {     
		  App.init();
		  Login.init();
		});
		$(function(){
			$("#showcode").click(function(){
				var url="<%=basePath%>hr_emp!ajaxValidateCode?v="+new Date().valueOf();
				window.parent.frames[0].location.href=url;
			});
			
			var err='${err}';
			if(err!=''){
				$("#errmsg").text(err);
				$("#btnerr").click();
			}
		});
	</script>
	<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>

Dao层:
产品信息Dao:crmProductCategoryDao.java

package com.crm.dao;

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

import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.crm.info.CrmProductCategory;
import com.crm.vobj.ProductCategory;
import com.haha.hibernate.HibernateDao;

/**
 * 客户产品分类表
 * 
 * @author 凯
 * 
 */
@Repository("crmProductCategoryDao")
public class CrmProductCategoryDao extends
		HibernateDao<CrmProductCategory, Integer> {
	/**
	 * 获取 产品树状节点
	 * 
	 * @return
	 */
	public List<ProductCategory> getProductCategories() {
		List<CrmProductCategory> list = this.getSession()
				.createCriteria(CrmProductCategory.class)
				.add(Restrictions.eq("isdelete", 1))
				.add(Restrictions.eq("parentid", 0)).list();
		List<ProductCategory> categories = new ArrayList<ProductCategory>();
		for (CrmProductCategory cpc : list) {
			ProductCategory category = new ProductCategory();
			category.setDeleteTime(cpc.getDeleteTime());
			category.setHrEmployee(cpc.getHrEmployee());
			category.setId(cpc.getId());
			category.setProductCategory(cpc.getProductCategory());
			category.setProductIcon(cpc.getProductIcon());
			category.setParentid(cpc.getParentid());
			category.setCrmProducts(cpc.getCrmProducts());
			category.setIsdelete(cpc.getIsdelete());
			category.categories = this.getSession()
					.createCriteria(CrmProductCategory.class)
					.add(Restrictions.eq("isdelete", 1))
					.add(Restrictions.eq("parentid", cpc.getId())).list();
			categories.add(category);
		}
		return categories;
	}

	/**
	 * ajax 查询子类别
	 * 
	 * @param padid
	 * @return
	 */
	public List<CrmProductCategory> findChildCate(int padid) {
		List<CrmProductCategory> list = this.getSession()
				.createCriteria(CrmProductCategory.class)
				.add(Restrictions.eq("isdelete", 1))
				.add(Restrictions.eq("parentid", padid)).list();
		return list;
	}

	/**
	 * ajax查询全部父类别
	 * 
	 * @return
	 */
	public List<CrmProductCategory> findAll() {
		return this.getSession().createCriteria(CrmProductCategory.class)
				.add(Restrictions.eq("isdelete", 1))
				.add(Restrictions.eq("parentid", 0)).list();
	}

	/**
	 * ajax 获取最大的ID
	 * 
	 * @return
	 */
	public int getMaxId() {
		try {
			int id = (Integer) getSession()
					.createCriteria(CrmProductCategory.class)
					.setProjection(Projections.max("id")).uniqueResult();
			return id;
		} catch (Exception e) {
			e.printStackTrace();
			return -1;
		}

	}

	/**
	 * ajax 查询全部的子节点
	 * 
	 * @return
	 */
	public List<CrmProductCategory> findAllChildCate() {
		return this.getSession().createCriteria(CrmProductCategory.class)
				.add(Restrictions.eq("isdelete", 1))
				.add(Restrictions.ne("parentid", 0)).list();
	}
	
	public List<CrmProductCategory> findTrashAll() {
		return this.getSession().createCriteria(CrmProductCategory.class)
				.add(Restrictions.eq("isdelete", 0)).list();
	}

}

客户信息管理Dao:crmCustomerDao.java

package com.crm.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.crm.info.CrmCustomer;
import com.crm.info.CrmFollow;
import com.crm.vobj.CrmCustomeVobj;
import com.haha.hibernate.HibernateDao;

/**
 * 客户表
 * 
 * @author 凯
 * 
 */
@Repository("crmCustomerDao")
public class CrmCustomerDao extends HibernateDao<CrmCustomer, Integer> {

	public List<CrmCustomer> findAllByWhere(CrmCustomeVobj cy) {
		if (cy == null) {
			return findAll();
		}
		Criteria c = createCriter(this.getSession(), cy);
		return c.add(Restrictions.eq("isdelete", 1)).list();
	}

	public List<CrmCustomer> findAll() {
		return getSession().createCriteria(CrmCustomer.class)
				.add(Restrictions.eq("isdelete", 1)).list();
	}

	private Criteria createCriter(Session s, CrmCustomeVobj cy) {
		Criteria c = s.createCriteria(CrmCustomer.class);
		if (cy.getCustomer() != null && cy.getCustomer().length() > 0) {
			// 公司不为空
			c.add(Restrictions.ilike("customer", cy.getCustomer(),
					MatchMode.ANYWHERE));
		}
		if (cy.getDepartmentId() != null && cy.getDepartmentId() > 0) {
			// 部门不为空
			c.add(Restrictions.eq("hrDepartment.id", cy.getDepartmentId()));
		}
		if (cy.getEmployeeId() != null && cy.getEmployeeId() > 0) {
			// 部门不为空
			c.add(Restrictions.eq("hrEmployeeByEmployeeId.id",
					cy.getEmployeeId()));
		}
		if (cy.getTel() != null && cy.getTel().length() > 0) {
			// 电话不为空
			c.add(Restrictions.ilike("tel", cy.getTel(), MatchMode.ANYWHERE));
		}
		if (cy.getCreateDateStart() != null) {
			// 创建时间起始不为空
			c.add(Restrictions.ge("createDate", cy.getCreateDateStart()));
		}
		if (cy.getCreateDateEnd() != null) {
			// 创建时间末尾不为空
			c.add(Restrictions.le("createDate", cy.getCreateDateEnd()));
		}
		if (cy.getProvincesId() != null && cy.getProvincesId() > 0) {
			// 省份不为空
			c.add(Restrictions.eq("paramCityByProvincesId.id",
					cy.getProvincesId()));
		}
		if (cy.getCityId() != null && cy.getCityId() > 0) {
			// 城市不为空
			c.add(Restrictions.eq("paramCityByCityId.id", cy.getCityId()));
		}
		if (cy.getLastfollowStart() != null) {
			// 创建时间起始不为空
			c.add(Restrictions.ge("lastfollow", cy.getLastfollowStart()));
		}
		if (cy.getLastfollowEnd() != null) {
			// 创建时间末尾不为空
			c.add(Restrictions.le("lastfollow", cy.getLastfollowEnd()));
		}
		if (cy.getCustomertypeId() != null && cy.getCustomertypeId() > 0) {
			// 员工类型不为空
			c.add(Restrictions.eq("paramSysparamByCustomertypeId.id",
					cy.getCustomertypeId()));
		}
		if (cy.getCustomerlevelId() != null && cy.getCustomerlevelId() > 0) {
			// 员工级别不为空
			c.add(Restrictions.eq("paramSysparamByCustomerlevelId.id",
					cy.getCustomerlevelId()));
		}
		return c;
	}

	/**
	 * 查看某客户的跟进 数据
	 * 
	 * @param id
	 * @return
	 */
	public List<CrmFollow> findOne(int id) {
		return this.getSession().createCriteria(CrmFollow.class)
				.add(Restrictions.eq("crmCustomer.id", id))
				.add(Restrictions.eq("isdelete", 1)).list();

	}
	
	public List<CrmCustomer> findTrashAll(){
		return getSession().createCriteria(CrmCustomer.class).add(Restrictions.eq("isdelete", 0)).list();
	}
}

action层:CrmProductCategoryAction.java

package com.crm.action;

import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.crm.biz.CrmProductCategoryBiz;
import com.crm.info.CrmProductCategory;
import com.crm.tools.Scopes;
import com.crm.tools.WebTools;
import com.opensymphony.xwork2.ActionSupport;
@Scope("prototype")
@Controller("crmProductCategoryAction")
public class CrmProductCategoryAction extends ActionSupport {
	
	private CrmProductCategoryBiz crmProductCategoryBiz;
	private int id;

	public void setId(int id) {
		this.id = id;
	}
	public void setCrmProductCategoryBiz(CrmProductCategoryBiz crmProductCategoryBiz) {
		this.crmProductCategoryBiz = crmProductCategoryBiz;
	}
	
	public String execute() {
		List<CrmProductCategory> categories=crmProductCategoryBiz.findAll();
		Scopes.getRequestMap().put("cates",categories);
		return SUCCESS;
	}
	
	public String delCate(){
		if (crmProductCategoryBiz.deleteCate(id)) {
			Scopes.getRequestMap().put("data","success");
		}else{
			Scopes.getRequestMap().put("data","failed");
		}
		return "ajax";
	}
	//&productCategory="+jqInputs[0].value+"&parentid="+jqInputs[1].value+"&productIcon="+jqInputs[2].value;
	private String productCategory,productIcon;
	private Integer parentid;
	public void setParentid(Integer parentid) {
		this.parentid = parentid;
	}

	public void setProductCategory(String productCategory) {
		this.productCategory = productCategory;
	}
	
	public void setProductIcon(String productIcon) {
		this.productIcon = productIcon;
	}

	public String saveCate(){
		CrmProductCategory category=new CrmProductCategory();
		category.setParentid(parentid);
		category.setProductCategory(productCategory);
		category.setProductIcon(productIcon);
		category.setIsdelete(1);
		if (crmProductCategoryBiz.saveCate(category)) {
			Scopes.getRequestMap().put("data","success");
		}else{
			Scopes.getRequestMap().put("data","failed");
		}
		return "ajax";
	}
	
	public String updateCate(){
		CrmProductCategory category=new CrmProductCategory();
		category.setParentid(parentid);
		category.setProductCategory(productCategory);
		category.setProductIcon(productIcon);
		category.setId(id);
		//System.out.println(category.getParentid()+"--"+category.getProductIcon()+"--"+category.getProductCategory());
		if (crmProductCategoryBiz.updateCate(category)) {
			Scopes.getRequestMap().put("data","success");
		}else{
			Scopes.getRequestMap().put("data","failed");
		}
		return "ajax";
	}
	
	public String getMaxId(){
		int id=crmProductCategoryBiz.getMaxId()+1;
		Scopes.getRequestMap().put("data",+id);
		return "ajax";
	}

	public String ajaxGetCate() {
		List<CrmProductCategory> categories = crmProductCategoryBiz.findCate();
		WebTools.jsonClearCategories(categories);
		String data = WebTools.convertJson(categories);
		Scopes.getRequestMap().put("data", data);
		return "ajax";
	}

	public String ajaxGetChildCate() {
		List<CrmProductCategory> categories =crmProductCategoryBiz.findChildCate(parentid);
		WebTools.jsonClearCategories(categories);
		String data = WebTools.convertJson(categories);
		Scopes.getRequestMap().put("data", data);
		return "ajax";
	}

	public String ajaxGetAllChildCate() {
		List<CrmProductCategory> categories = crmProductCategoryBiz.findAllChildCate();
		WebTools.jsonClearCategories(categories);
		String data = WebTools.convertJson(categories);
		Scopes.getRequestMap().put("data", data);
		return "ajax";
	}
	
	public String trashAll(){
		Scopes.getRequestMap().put("cates",crmProductCategoryBiz.findTrashAll());
		return "trash";
	}
	public String trashDel(){
		crmProductCategoryBiz.deleteById(id);
		return trashAll();
	}
	public String trashAdd(){
		crmProductCategoryBiz.doTrashAdd(id);
		return trashAll();
	}
}

客户Action:CrmCustomerAction.java

package com.crm.action;

import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.crm.biz.CrmContactBiz;
import com.crm.biz.CrmCustomerBiz;
import com.crm.info.CrmContact;
import com.crm.info.CrmCustomer;
import com.crm.tools.Scopes;
import com.crm.tools.WebTools;
import com.crm.vobj.CrmCustomeVobj;
import com.crm.vobj.EmpDepVobj;
import com.opensymphony.xwork2.ActionSupport;

@Scope("prototype")
@Controller("crmCustomerAction")
public class CrmCustomerAction extends ActionSupport {

	private CrmCustomerBiz crmCustomerBiz;
	
	public void setCrmCustomerBiz(CrmCustomerBiz crmCustomerBiz) {
		this.crmCustomerBiz = crmCustomerBiz;
	}
	private CrmContactBiz crmContactBiz;

	public void setCrmContactBiz(CrmContactBiz crmContactBiz) {
		this.crmContactBiz = crmContactBiz;
	}
	//条件查询
	private CrmCustomeVobj bwvobj;
	
	public CrmCustomeVobj getBwvobj() {
		return bwvobj;
	}

	public void setBwvobj(CrmCustomeVobj bwvobj) {
		this.bwvobj = bwvobj;
	}
	private int id;

	public void setId(int id) {
		this.id = id;
	}
	private CrmCustomer customer;
	private CrmContact contact;
	public CrmContact getContact() {
		return contact;
	}

	public void setContact(CrmContact contact) {
		this.contact = contact;
	}

	public CrmCustomer getCustomer() {
		return customer;
	}

	public void setCustomer(CrmCustomer customer) {
		this.customer = customer;
	}

	public String execute(){
		Scopes.getRequestMap().put("bywhere", crmCustomerBiz.findAllByWhere(bwvobj));
		return SUCCESS;
	}
	
	public String findOne(){
		CrmCustomer customer = crmCustomerBiz.findOne(id);
		Scopes.getRequestMap().put("one", customer);
		return "toupdate";
	}
	
	public String add(){
		CrmCustomer newcust = crmCustomerBiz.addCustomer(customer);
		contact.setCrmCustomer(newcust);
		crmContactBiz.add(contact);
		return "add";
	}
	
	public String update(){
		crmCustomerBiz.update(customer);
		return "update";
	}
	
	public String delete(){
		crmCustomerBiz.deleteFalse(id);
		return "delete";
	}
	
	public String ajaxGetAllCustomer(){
		List<CrmCustomer> customers=crmCustomerBiz.findAll();
		WebTools.jsonClearCustomer(customers);
		String data=WebTools.convertJson(customers);
		Scopes.getRequestMap().put("data", data);
		return "ajax";
	}
	public String ajaxGetDepEmp(){
		CrmCustomer cus = crmCustomerBiz.findOne(id);
		EmpDepVobj edvobj=new EmpDepVobj();
		edvobj.setDepid(cus.getHrDepartment().getId());
		edvobj.setDepname(cus.getHrDepartment().getDName());
		edvobj.setEmpid(cus.getHrEmployeeByEmployeeId().getId());
		edvobj.setEmpname(cus.getHrEmployeeByEmployeeId().getName());
		String data = WebTools.convertJson(edvobj);
		Scopes.getRequestMap().put("data", data);
		return "ajax";
	}
	
	public String trashAll(){
		Scopes.getRequestMap().put("bywhere", crmCustomerBiz.findTrashAll());
		return "trash";
	}
	public String trashAdd(){
		crmCustomerBiz.doTrashAdd(id);
		return trashAll();
	}
	public String trashDel(){
		crmCustomerBiz.deleteById(id);
		return trashAll();
	}
}

写在最后

码代码不容易,需要的同学可以参考学习,全部代码不能都贴出,如果需要可以+博主V交流获取(Code2Life2)
最后,别忘了一键三连哦