consaction.java

来自「一套自己原先在学校作的CRM,大家指点下」· Java 代码 · 共 122 行

JAVA
122
字号
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.crm.action.rept;

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

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.crm.pojo.All;
import com.crm.pojo.Dict;
import com.crm.service.IClientBiz;
import com.crm.service.IDictBiz;

/** 
 * MyEclipse Struts
 * Creation date: 10-15-2008
 * 
 * XDoclet definition:
 * @struts.action path="/cust" name="clientForm" parameter="operate" scope="request" validate="true"
 */
public class ConsAction extends DispatchAction {
	private String fangshi="1";
	private IClientBiz clientBiz;
	private IDictBiz dictBiz;
	public void setDictBiz(IDictBiz dictBiz) {
		this.dictBiz = dictBiz;
	}
	public void setClientBiz(IClientBiz clientBiz) {
		this.clientBiz = clientBiz;
	}
	public ActionForward toList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		fangshi="1";
		this.page(fangshi, request);
		return mapping.findForward("cons");
	}
	public ActionForward doFind(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		fangshi=request.getParameter("fangshi");
		this.page(fangshi, request);
		return mapping.findForward("cons");
	}
	
	
	public void page(String fangshi,HttpServletRequest request){
		int pageSize=10;//一页查几行		
		int pageNo=1;//第几页查
		if(request.getParameter("pageNo")==null || request.getParameter("pageNo").equals("")){
			pageNo=1;
		}else{
			pageNo=Integer.parseInt(request.getParameter("pageNo"));
		}
		List listAll=dictBiz.finAll();
		List<All> consList=new ArrayList<All>();
		for(int i=0;i<listAll.size();i++){
			Dict dict=(Dict) listAll.get(i);
			//按等级设置
			if(fangshi.equals("1")){
				if(dict.getTypes().equals("企业客户等级")){
					String names=dict.getNames();
					List listCount=clientBiz.find(fangshi,names,pageNo,pageSize);
					All all=null;
					if(listCount.size()==0){
						all=new All(0,names);
					}else{
						all=new All(Integer.parseInt(listCount.get(0).toString()),names);
					}
					consList.add(all);
					request.setAttribute("fangshi", 1);
				}
			}
			//满意度
			else if(fangshi.equals("2")){
				if(dict.getTypes().equals("满意度")){
					String names=dict.getVal();
					List listCount=clientBiz.find(fangshi,names,pageNo,pageSize);
					All all=null;
					if(listCount.size()==0){
						all=new All(0,names);
					}else{
						all=new All(Integer.parseInt(listCount.get(0).toString()),names);
					}
					consList.add(all);
					request.setAttribute("fangshi", 2);
				}
			}
			//按信用度
			else{
				if(dict.getTypes().equals("信任度")){
					String names=dict.getVal();
					List listCount=clientBiz.find(fangshi,names,pageNo,pageSize);
					All all=null;
					if(listCount.size()==0){
						all=new All(0,names);
					}else{
						all=new All(Integer.parseInt(listCount.get(0).toString()),names);
					}
					consList.add(all);
					request.setAttribute("fangshi", 3);
				}
			}
			
		}
		
		int count=consList.size();
		int page=count%pageSize==0?count/pageSize:count/pageSize+1;//一共多少页
		request.setAttribute("page", page);
		request.setAttribute("pageSize", pageSize);
		request.setAttribute("pageNo", pageNo);
		request.setAttribute("count", count);
		request.setAttribute("consList", consList);
	}
}

⌨️ 快捷键说明

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