基本信息
源码名称:java CRM客户管理系统源码(含数据库脚本)
源码大小:19.05M
文件格式:.rar
开发语言:Java
更新时间:2019-03-06
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
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; } }