⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clintmanageaction.java

📁 自己制作的联通CRM,支持客户分类,管理,升级,积分管理等等..
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.jn0801.clientmanage.action;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

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

import org.apache.commons.beanutils.BeanUtils;
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.jn0801.clientmanage.AddressBean;
import com.jn0801.clientmanage.Addressimpt;
import com.jn0801.clientmanage.ClientInf;
import com.jn0801.clientmanage.Clientimpt;
import com.jn0801.clientmanage.form.ClintmanageForm;
import com.jn0801.common.UserInfo;
import com.jn0801.login.systemuser.SystemuserBean;

/** 
 * MyEclipse Struts
 * Creation date: 08-14-2008
 * 
 * XDoclet definition:
 * @struts.action path="/clintmanage" name="clintmanageForm" input="/form/clintmanage.jsp" parameter="tag" scope="request" validate="true"
 */
public class ClintmanageAction extends DispatchAction {
	
	private ClientInf clentimptimp;
	
	
	
	public ClientInf getClentimptimp() {
		return clentimptimp;
	}
	public void setClentimptimp(ClientInf clentimptimp) {
		this.clentimptimp = clentimptimp;
	}
	
	
	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * 获取所有的客户资料
	 */
	public ActionForward getalluser(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		ClintmanageForm clintmanageForm = (ClintmanageForm) form;// TODO Auto-generated method stub
		Clientimpt c=new Clientimpt();
		HttpSession session=request.getSession();
		SystemuserBean systembean=(SystemuserBean)session.getAttribute("userbean");
		int nid=systembean.getNid();
		List list=c.listGradeRule1(null, null,request);
		request.setAttribute("userlist", list);
		request.setAttribute("nid", nid);
		
		Addressimpt addressimpt=new Addressimpt();
		AddressBean addressbean=new AddressBean();
		List<AddressBean> list1=addressimpt.listaddress(0);
		request.setAttribute("list", list1);
		return mapping.findForward("clientall");
	}
	
	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * 导出客户资料
	 */
	public ActionForward out(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		ClintmanageForm clintmanageForm = (ClintmanageForm) form;// TODO Auto-generated method stub
		BufferedWriter bw=null;
		//File file = new File();
		String dir = this.servlet.getServletContext().getRealPath(
		"daochu");
		
		try {
			SimpleDateFormat sdf1=new SimpleDateFormat("yyyyMMddHHmmss");
			Date date = new Date();
			String datenow = sdf1.format(date);
			bw = new BufferedWriter(new FileWriter(dir+File.separator+datenow+".txt",true));
		} catch (IOException e2) {
			// TODO 自动生成 catch 块
			e2.printStackTrace();
		}
		
		PrintWriter out = null;
		try {
			out = response.getWriter();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		String[] txtList = clintmanageForm.getDaochu();
		Clientimpt c=new Clientimpt();
		if (clintmanageForm.getDaochu() != null
				&& !clintmanageForm.getDaochu().equals("")) {

			for (int i = 0; i < txtList.length; i++) {
					int m=Integer.parseInt(txtList[i]);
					System.out.println("编号:"+txtList[i]);
					List list=c.listGradeRule(null, null, m);
					for (int j = 0; j < list.size(); j++) {
						UserInfo userinfo=(UserInfo)list.get(j);
					try {
						bw.write(String.valueOf(userinfo.getUserid())+"    ");
						bw.write(userinfo.getPhone()+"\n");
						bw.flush();
						out
						.println("<script>alert('导出成功!!!!');window.history.back();</script>");
					} catch (IOException e) {
						// TODO 自动生成 catch 块
						e.printStackTrace();
					}
					
				}
			}
		}
		else
		{
			out
			.println("<script>alert('不能导出空的信息!!!!');window.history.back();</script>");
		}

		return null;
	}
	public ActionForward out1(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		ClintmanageForm clintmanageForm = (ClintmanageForm) form;// TODO Auto-generated method stub
		OutputStream output = null;
		InputStream input = null;
		BufferedWriter bw=null;
		//File file = new File();
		String filename=null;
		String filename1=null;
		String dir = this.servlet.getServletContext().getRealPath(
		"daochu");
		
		try {
			SimpleDateFormat sdf1=new SimpleDateFormat("yyyyMMddHHmmss");
			Date date = new Date();
			String datenow = sdf1.format(date);
			filename1=datenow+".txt";
			filename=dir+File.separator+filename1;
			bw = new BufferedWriter(new FileWriter(filename,true));
		} catch (IOException e2) {
			// TODO 自动生成 catch 块
			e2.printStackTrace();
		}
		

		String[] txtList = clintmanageForm.getDaochu();
		Clientimpt c=new Clientimpt();
		if (clintmanageForm.getDaochu() != null
				&& !clintmanageForm.getDaochu().equals("")) 
		{

			for (int i = 0; i < txtList.length; i++) {
					int m=Integer.parseInt(txtList[i]);
					System.out.println("编号:"+txtList[i]);
					List list=c.listGradeRule(null, null, m);
					for (int j = 0; j < list.size(); j++) {
						UserInfo userinfo=(UserInfo)list.get(j);
					try {
						bw.write(String.valueOf(userinfo.getUserid())+"    ");
						bw.write(userinfo.getPhone()+"    ");
						bw.write(userinfo.getIntegralsign()+"    ");
						bw.write(userinfo.getUsername()+"    ");
						bw.write(userinfo.getPapertype()+"    ");
						bw.write(userinfo.getPaperid()+"    ");
						bw.write(String.valueOf(userinfo.getServetype())+"    ");
						bw.write(userinfo.getArea()+"    ");
						bw.write(userinfo.getCity()+"    ");
						bw.write(userinfo.getBusinessroom()+"    ");
						bw.write(String.valueOf(userinfo.getOptiontype())+"    ");
						bw.write(String.valueOf(userinfo.getMainoption())+"    ");
						bw.write(userinfo.getRegtime()+"    "+"\r\n");
						
						
						bw.flush();
						
					} catch (IOException e) {
						// TODO 自动生成 catch 块
						e.printStackTrace();
					}
					
				}
			}
			try {
				try {
					input = new FileInputStream(filename);
				} catch (FileNotFoundException e) {
					// TODO 自动生成 catch 块
					e.printStackTrace();
				}
				response.setHeader("Content-disposition", "attachment;filename="
						+ new String(filename1.getBytes("GBK"), "ISO-8859-1"));
			} catch (UnsupportedEncodingException e) {
				// TODO 自动生成 catch 块
				e.printStackTrace();
			}
			
			response
					.setContentType("application/x-msdownload;charset=UTF-8");
			try {
				output = response.getOutputStream();
				int n = 0;
				byte[] b = new byte[1024];
				while ((n = input.read(b, 0, b.length)) != -1) {
					output.write(b, 0, n);
					output.flush();
					
				}
				output.close();
			} catch (IOException e) {
				// TODO 自动生成 catch 块
				//e.printStackTrace();
			}
		}
		else
		{
			PrintWriter out = null;
			try {
				out = response.getWriter();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
			out
			.println("<script>alert('不能导出空的信息!!!!');window.history.back();</script>");
		}
		return null;
	}
	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * 获取所要的客户资料
	 */
	public ActionForward getuser(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		ClintmanageForm clintmanageForm = (ClintmanageForm) form;// TODO Auto-generated method stub
		Clientimpt c=new Clientimpt();
		int userid=Integer.parseInt(request.getParameter("userid"));
		List list=c.listGradeRule(null, null,userid);
		UserInfo userinfo=(UserInfo)list.get(0);
		
		Long clientmanagerid=userinfo.getClientmanagerid();
		int id=Integer.parseInt(String.valueOf(clientmanagerid));
		
		List list2=c.getuser1(id);
		SystemuserBean systembean=(SystemuserBean)list2.get(0);
		
		request.setAttribute("user", list.get(0));
		request.setAttribute("systembean", systembean);
		//int a = intValue(new Long(11));
		
		return mapping.findForward("clientinfo");
	}
	
	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * 删除客户资料
	 */
	public ActionForward deletuser(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

⌨️ 快捷键说明

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