首页

java CRM客户管理系统源码(含数据库脚本)

java

2020-6-27

package com.web.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.bean.BaseDict;
import com.bean.Customer;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.util.ValueStack;
import com.service.CustomerService;
import com.web.commons.Page;

@Controller("customerAction")
@Scope("prototype")
@ParentPackage("struts-default")
@Namespace("/customer")
@Results({ @Result(name = "addUI", type = "dispatcher", location = "/jsp/customer/add.jsp"),
		@Result(name = "listCustomer", type = "dispatcher", location = "/jsp/customer/list.jsp"),
		@Result(name = "allCustomer", type = "redirectAction", location = "findAllCustomer"),
		@Result(name = "editUI", type = "dispatcher", location = "/jsp/customer/edit.jsp"),
		@Result(name = "industryCount", type = "dispatcher", location = "/jsp/statistic/indlist.jsp"),
		@Result(name = "sourceCount", type = "dispatcher", location = "/jsp/statistic/soulist.jsp")
})

		
public class CustomerAction extends ActionSupport implements ModelDriven<Customer> {
	private List list;
	private Integer curNum;
	
	private Page<Customer> page;

	private List<BaseDict> customerSources;

	private List<BaseDict> customerLevels;

	@Resource(name = "customerService")
	private CustomerService customerService;

	private Customer customer = new Customer();

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

	@Override
	public Customer getModel() {

		return customer;
	}
	
	/**
	 * 客户行业统计
	 * @return
	 */
	@Action("customerIndustryCount")
	public String customerIndustryCount() {
		list=customerService.customerIndustryCount();
		return "industryCount";
	}
	/**
	 * 客户来源统计
	 * @return
	 */
	@Action("customerSourceCount")
	public String customerSourceCount() {
		list=customerService.findCustomerSourceCount();
		
		return "sourceCount";
	}
	/**
	 * 编辑客户
	 * @return
	 */
	@Action("editCustomer")
	public String editCustomer() {
		customerService.updateCustomer(customer);
		return "allCustomer";
	}

	/**
	 * 获取编辑页面并且回显数据
	 * 
	 * @return
	 */
	@Action("editUICustomer")
	public String editUICustomer() {
		// 查询获取客户来源
		customerSources = customerService.findAllCustomerSource();

		// 查询所有客户级别
		customerLevels = customerService.findAllCustomerLevel();
			//此处自己定义对象是为了避免和customer对象造成混淆,模型中的customer和查出获得到的两个customer不是同一个对象,所以如果直接压栈,将会是空
		Customer c=customerService.findByIdCustomer(customer.getCust_id());
		//把获取到的对象压入值栈
		ActionContext.getContext().getValueStack().push(c);
		return "editUI";
	}

	/**
	 * 根据客户id删除指定的客户
	 * 
	 * @return
	 */
	@Action("removeCustomer")
	public String removeCustomer() {
		customerService.removeByIdCustomer(customer.getCust_id());
		return "allCustomer";
	}

	/**
	 * 获取添加页面的方法
	 * 
	 * @return
	 */
	@Action("addUICustomer")
	public String addUICustomer() {
		// 查询获取客户来源
		customerSources = customerService.findAllCustomerSource();

		// 查询所有客户级别
		customerLevels = customerService.findAllCustomerLevel();
		return "addUI";
	}

	/**
	 * 查询所有客户
	 * 
	 * @return
	 */
	@Action("findAllCustomer")
	public String findAllCustomer() {
		//1.创建离线查询东西
		DetachedCriteria dCriteria = DetachedCriteria.forClass(Customer.class);
		//2.拼装查询条件
		//判断是否提供了客户名称,此处将使用apach提供的判断字符串的工具类commm-lang3.jar isNotBlank()可以去掉空格后判断字符串部位null或者""
		if (StringUtils.isNotBlank(customer.getCust_name())) {
			//添加条件,模糊查询客户名称
			dCriteria.add(Restrictions.like("cust_name","%" customer.getCust_name() "%"));
		}
		//判断是否提供了客户行业
		if (StringUtils.isNotBlank(customer.getCust_industry())) {
			//添加条件,模糊查询客户行业
			dCriteria.add(Restrictions.like("cust_industry","%" customer.getCust_industry() "%"));
		}
		//判断是否提供了客户来源
		if (customer.getCust_source()!=null && StringUtils.isNotBlank(customer.getCust_source().getDict_id())) {
			//精确查询客户来源
			dCriteria.add(Restrictions.eq("cust_source",customer.getCust_source()));
		}
		//判断是否提供了客户级别
		if (customer.getCust_level()!=null && StringUtils.isNotBlank(customer.getCust_level().getDict_id())) {
			//精确查询客户级别
			dCriteria.add(Restrictions.eq("cust_level",customer.getCust_level()));
		}
		//3.按条件查询客户信息
		page = customerService.findAllCustomer(dCriteria, curNum);
		//4.查询获取客户来源
		customerSources = customerService.findAllCustomerSource();
		
		//5.查询所有客户级别
		customerLevels = customerService.findAllCustomerLevel();
		return "listCustomer";
	}

	/**
	 * 新增客户
	 * 
	 * @return
	 */
	@Action("addCustomer")
	public String addCustomer() {
		customerService.saveCustomer(customer);
		return "allCustomer";
	}

	// 把查询到的信息放在值栈中
	 

	public List<BaseDict> getCustomerSources() {
		return customerSources;
	}

	public Page<Customer> getPage() {
		return page;
	}

	public void setPage(Page<Customer> page) {
		this.page = page;
	}

	public void setCustomerSources(List<BaseDict> customerSources) {
		this.customerSources = customerSources;
	}

	public List<BaseDict> getCustomerLevels() {
		return customerLevels;
	}

	public void setCustomerLevels(List<BaseDict> customerLevels) {
		this.customerLevels = customerLevels;
	}

	public Integer getCurNum() {
		return curNum;
	}

	public void setCurNum(Integer curNum) {
		this.curNum = curNum;
	}

	public List getList() {
		return list;
	}

	public void setList(List list) {
		this.list = list;
	}

	 

}

资源下载此资源下载价格为3D币(VIP免费),请先
资源文件列表
crm_project/.classpath , 906
crm_project/.project , 911
crm_project/.settings/.jsdtscope , 567
crm_project/.settings/org.eclipse.jdt.core.prefs , 364
crm_project/.settings/org.eclipse.wst.common.component , 485
crm_project/.settings/org.eclipse.wst.common.project.facet.core.xml , 345
crm_project/.settings/org.eclipse.wst.jsdt.ui.superType.container , 49
crm_project/.settings/org.eclipse.wst.jsdt.ui.superType.name , 6
crm_project/build/classes/com/bean/BaseDict.class , 3071
crm_project/build/classes/com/bean/Customer.class , 3897
crm_project/build/classes/com/bean/LinkMan.class , 3411
crm_project/build/classes/com/bean/User.class , 2697
crm_project/build/classes/com/bean/Visit.class , 2908
crm_project/build/classes/com/dao/BaseDao.class , 404
crm_project/build/classes/com/dao/BaseDictDao.class , 263
crm_project/build/classes/com/dao/CustomerDao.class , 555
crm_project/build/classes/com/dao/impl/BaseDaoImpl.class , 2721
crm_project/build/classes/com/dao/impl/BaseDictDaoImpl.class , 1020
crm_project/build/classes/com/dao/impl/CustomerDaoImpl.class , 3167
crm_project/build/classes/com/dao/impl/LinkManDaoImpl.class , 2602
crm_project/build/classes/com/dao/impl/UserDaoImpl.class , 1536
crm_project/build/classes/com/dao/impl/VisitDaoImpl.class , 2599
crm_project/build/classes/com/dao/LinkManDao.class , 545
crm_project/build/classes/com/dao/UserDao.class , 255
crm_project/build/classes/com/dao/VisitDao.class , 540
crm_project/build/classes/com/interceptor/UserLoginInterceptor.class , 1223
crm_project/build/classes/com/service/CustomerService.class , 712
crm_project/build/classes/com/service/impl/CustomerServiceImpl.class , 3446
crm_project/build/classes/com/service/impl/LinkManServiceImpl.class , 2595
crm_project/build/classes/com/service/impl/UserServiceImpl.class , 1081
crm_project/build/classes/com/service/impl/VisitServiceImpl.class , 2506
crm_project/build/classes/com/service/LinkManService.class , 542
crm_project/build/classes/com/service/UserService.class , 271
crm_project/build/classes/com/service/VisitService.class , 406
crm_project/build/classes/com/test/CRM_ProjectTest.class , 2072
crm_project/build/classes/com/web/action/CustomerAction.class , 6452
crm_project/build/classes/com/web/action/LinkManAction.class , 5627
crm_project/build/classes/com/web/action/UserAction.class , 2516
crm_project/build/classes/com/web/action/VisitAction.class , 6121
crm_project/build/classes/com/web/commons/Page.class , 3421
crm_project/build/classes/config/applicationContext.xml , 3211
crm_project/build/classes/db/crm.sql , 4414
crm_project/build/classes/db/crm数据库.sql , 8750
crm_project/build/classes/log4j.properties , 660
crm_project/src/com/bean/BaseDict.java , 2564
crm_project/src/com/bean/Customer.java , 3416
crm_project/src/com/bean/LinkMan.java , 2712
crm_project/src/com/bean/User.java , 2034
crm_project/src/com/bean/Visit.java , 2336
crm_project/src/com/dao/BaseDao.java , 512
crm_project/src/com/dao/BaseDictDao.java , 236
crm_project/src/com/dao/CustomerDao.java , 1476
crm_project/src/com/dao/impl/BaseDaoImpl.java , 1637
crm_project/src/com/dao/impl/BaseDictDaoImpl.java , 695
crm_project/src/com/dao/impl/CustomerDaoImpl.java , 3231
crm_project/src/com/dao/impl/LinkManDaoImpl.java , 1483
crm_project/src/com/dao/impl/UserDaoImpl.java , 815
crm_project/src/com/dao/impl/VisitDaoImpl.java , 1514
crm_project/src/com/dao/LinkManDao.java , 969
crm_project/src/com/dao/UserDao.java , 323
crm_project/src/com/dao/VisitDao.java , 991
crm_project/src/com/interceptor/UserLoginInterceptor.java , 854
crm_project/src/com/service/CustomerService.java , 1556
crm_project/src/com/service/impl/CustomerServiceImpl.java , 2578
crm_project/src/com/service/impl/LinkManServiceImpl.java , 1807
crm_project/src/com/service/impl/UserServiceImpl.java , 739
crm_project/src/com/service/impl/VisitServiceImpl.java , 1727
crm_project/src/com/service/LinkManService.java , 791
crm_project/src/com/service/UserService.java , 331
crm_project/src/com/service/VisitService.java , 787
crm_project/src/com/test/CRM_ProjectTest.java , 1112
crm_project/src/com/web/action/CustomerAction.java , 6758
crm_project/src/com/web/action/LinkManAction.java , 4794
crm_project/src/com/web/action/UserAction.java , 1819
crm_project/src/com/web/action/VisitAction.java , 4945
crm_project/src/com/web/commons/Page.java , 3202
crm_project/src/config/applicationContext.xml , 3211
crm_project/src/db/crm.sql , 4414
crm_project/src/db/crm数据库.sql , 8750
crm_project/src/log4j.properties , 660
crm_project/WebContent/css/Manage.css , 3155
crm_project/WebContent/css/Style.css , 1557
crm_project/WebContent/images/info.png , 20940
crm_project/WebContent/images/login_1.gif , 9409
crm_project/WebContent/images/login_2.jpg , 89854
crm_project/WebContent/images/login_3.jpg , 17895
crm_project/WebContent/images/login_button.gif , 1559
crm_project/WebContent/images/new_001.jpg , 1279
crm_project/WebContent/images/new_002.jpg , 521
crm_project/WebContent/images/new_003.jpg , 1197
crm_project/WebContent/images/new_005.jpg , 847
crm_project/WebContent/images/new_006.jpg , 502
crm_project/WebContent/images/new_007.jpg , 836
crm_project/WebContent/images/new_008.jpg , 416
crm_project/WebContent/images/new_009.jpg , 402
crm_project/WebContent/images/new_010.jpg , 608
crm_project/WebContent/images/new_011.jpg , 365
crm_project/WebContent/images/new_012.jpg , 612
crm_project/WebContent/images/new_019.jpg , 709
crm_project/WebContent/images/new_020.jpg , 451
crm_project/WebContent/images/new_021.jpg , 714
crm_project/WebContent/images/new_022.jpg , 365
crm_project/WebContent/images/new_023.jpg , 402
crm_project/WebContent/images/new_024.jpg , 611
crm_project/WebContent/images/new_025.jpg , 411
crm_project/WebContent/images/new_026.jpg , 612
crm_project/WebContent/images/new_027.jpg , 319
crm_project/WebContent/images/start.gif , 231
crm_project/WebContent/images/welcome.gif , 3028
crm_project/WebContent/images/yes.png , 20482
crm_project/WebContent/index.jsp , 969
crm_project/WebContent/js/Common.js , 2115
crm_project/WebContent/js/FrameDiv.js , 3728
crm_project/WebContent/js/jquery-1.4.4.min.js , 78601
crm_project/WebContent/jsp/commons/page.jsp , 1110
crm_project/WebContent/jsp/customer/add.jsp , 4639
crm_project/WebContent/jsp/customer/edit.jsp , 4677
crm_project/WebContent/jsp/customer/list.jsp , 6207
crm_project/WebContent/jsp/error.jsp , 2236
crm_project/WebContent/jsp/linkman/add.jsp , 4413
crm_project/WebContent/jsp/linkman/edit.jsp , 4424
crm_project/WebContent/jsp/linkman/list.jsp , 6343
crm_project/WebContent/jsp/statistic/indlist.jsp , 5434
crm_project/WebContent/jsp/statistic/soulist.jsp , 5435
crm_project/WebContent/jsp/success.jsp , 2235
crm_project/WebContent/jsp/visit/add.jsp , 4320
crm_project/WebContent/jsp/visit/edit.jsp , 4357
crm_project/WebContent/jsp/visit/list.jsp , 6129
crm_project/WebContent/login.jsp , 1184
crm_project/WebContent/menu.jsp , 9680
crm_project/WebContent/META-INF/MANIFEST.MF , 39
crm_project/WebContent/top.jsp , 2065
crm_project/WebContent/WEB-INF/lib/antlr-2.7.7.jar , 445288
crm_project/WebContent/WEB-INF/lib/aopalliance-1.0.jar , 4467
crm_project/WebContent/WEB-INF/lib/asm-3.3.jar , 43578
crm_project/WebContent/WEB-INF/lib/asm-commons-3.3.jar , 38275
crm_project/WebContent/WEB-INF/lib/asm-tree-3.3.jar , 21503
crm_project/WebContent/WEB-INF/lib/aspectjweaver-1.8.7.jar , 1865078
crm_project/WebContent/WEB-INF/lib/c3p0-0.9.2.1.jar , 423876
crm_project/WebContent/WEB-INF/lib/commons-beanutils-1.8.3.jar , 232019
crm_project/WebContent/WEB-INF/lib/commons-fileupload-1.3.1.jar , 69002
crm_project/WebContent/WEB-INF/lib/commons-io-2.2.jar , 173587
crm_project/WebContent/WEB-INF/lib/commons-lang3-3.2.jar , 384767
crm_project/WebContent/WEB-INF/lib/commons-logging-1.2.jar , 61829
crm_project/WebContent/WEB-INF/lib/dom4j-1.6.1.jar , 313898
crm_project/WebContent/WEB-INF/lib/freemarker-2.3.22.jar , 1300487
crm_project/WebContent/WEB-INF/lib/geronimo-jta_1.1_spec-1.1.1.jar , 16030
crm_project/WebContent/WEB-INF/lib/hibernate-c3p0-5.0.7.Final.jar , 11577
crm_project/WebContent/WEB-INF/lib/hibernate-commons-annotations-5.0.1.Final.jar , 75288
crm_project/WebContent/WEB-INF/lib/hibernate-core-5.0.7.Final.jar , 5583264
crm_project/WebContent/WEB-INF/lib/hibernate-jpa-2.1-api-1.0.0.Final.jar , 113371
最多只能显示150条信息!
没有账号? 忘记密码?

社交账号快速登录