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;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
CRM项目最新源码

共178个文件
jar:44个
java:32个
class:32个

需积分: 47 36 下载量 68 浏览量
2018-07-03
19:30:50
上传
评论 4
收藏 19.05MB RAR 举报
温馨提示
基于s2s4h5三大框架的注解+xml实现,希望对需要的朋友有所帮助
资源推荐
资源详情
资源评论






收起资源包目录





































































































共 178 条
- 1
- 2
资源评论


飘…
- 粉丝: 467
- 资源: 18
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


安全验证
文档复制为VIP权益,开通VIP直接复制
