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

📄 messagemanageaction.java

📁 JAVA实现的中小型企业CRM客户关系管理系统
💻 JAVA
字号:
//Created by MyEclipse Struts// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.0/xslt/JavaClass.xslpackage com.crm.message;import java.io.IOException;import java.io.PrintWriter;import java.util.HashMap;import java.util.List;import java.util.Map;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;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.springframework.context.ApplicationContext;import org.springframework.web.struts.DispatchActionSupport;import com.crm.custinfo.ICustInfoDAO;import com.crm.custinfo.po.CustInfo;import com.crm.message.po.Message;import com.crm.mydict.IMyDictDAO;import com.crm.sms.SimpleSender;import com.crm.user.po.UserInfo;/**  *  * Creation date: ${datenow} *  * XDoclet definition: * @struts.action path="/usermanage" name="usermanageForm" input="/user/usermanage.jsp" scope="request" validate="true" */public class MessagemanageAction extends DispatchActionSupport {		// --------------------------------------------------------- Instance Variables	// --------------------------------------------------------- Methods	/** 	 * Method execute	 * @param mapping	 * @param form	 * @param request	 * @param response	 * @return ActionForward	 */	public ActionForward list(		ActionMapping mapping,		ActionForm form,		HttpServletRequest request,		HttpServletResponse response) {		MessagemanageForm messagemanageForm = (MessagemanageForm) form;		Message Message = new Message();		try{			BeanUtils.copyProperties(Message,messagemanageForm);			//BeanUtils.describe(MessagemanageForm);		}catch(Exception e){					}		ApplicationContext context = this.getWebApplicationContext();		IMessageDAO dao = (IMessageDAO)context.getBean("Messagedao");		//MessageDAO dao = new MessageDAO();		List Messagelist = dao.getMessageList(Message,request);		request.setAttribute("Messagelist",Messagelist);				// TODO Auto-generated method stub		return mapping.findForward("Messagelist");	}		/** 	 * Method execute	 * @param mapping	 * @param form	 * @param request	 * @param response	 * @return ActionForward	 */	public ActionForward initadd(  		ActionMapping mapping,		ActionForm form,		HttpServletRequest request,		HttpServletResponse response) {		MessagemanageForm messagemanageForm = (MessagemanageForm) form;		ApplicationContext context= this.getWebApplicationContext();		UserInfo userinfo = (UserInfo)request.getSession().getAttribute("user");		ICustInfoDAO custdao = (ICustInfoDAO)context.getBean("custinfodao");		CustInfo custInfo = custdao.getCustInfo(Integer.parseInt(messagemanageForm.getCust_id()));		IMessageDAO messagedao = (IMessageDAO)context.getBean("messagedao");				Message message = new Message();		message.setCust_id(messagemanageForm.getCust_id());		List messagelist = messagedao.getMessageList(message, request);				messagemanageForm.setEmployee_id(userinfo.getId());		messagemanageForm.setEmployee_name(userinfo.getEmployee_name());		messagemanageForm.setCust_id(custInfo.getId().toString());		messagemanageForm.setCust_name(custInfo.getCust_name());				Map phonelist = new HashMap();		if(isPhone(custInfo.getTelephone())){			phonelist.put(custInfo.getTelephone(), custInfo.getTelephone());		}		if(isPhone(custInfo.getMobile())){			phonelist.put(custInfo.getMobile(), custInfo.getMobile());		}		if(isPhone(custInfo.getElesephone())){			phonelist.put(custInfo.getElesephone(), custInfo.getElesephone());		}				request.setAttribute("phonelist", phonelist);		request.setAttribute("messagelist", messagelist);		messagemanageForm.setTask("add");				return mapping.findForward("messageadd");	}		//电话号码验证		private boolean isPhone(String phone){			System.out.println("phone="+phone);			if(null==phone )return false;			phone = phone.trim();			if("".equals(phone)) return false;			if(phone.length()<7) return false;						return true;					}		/** 		 * Method execute		 * @param mapping		 * @param form		 * @param request		 * @param response		 * @return ActionForward		 */		public ActionForward add(			ActionMapping mapping,			ActionForm form,			HttpServletRequest request,			HttpServletResponse response) {			MessagemanageForm messagemanageForm = (MessagemanageForm) form;			Message message = new Message();			try{				BeanUtils.copyProperties(message,messagemanageForm);				//BeanUtils.describe(MessagemanageForm);			}catch(Exception e){				 			}			ApplicationContext context = this.getWebApplicationContext();			IMessageDAO dao = (IMessageDAO)context.getBean("messagedao");			String phone = messagemanageForm.getPhone();			if(phone!=null){				phone = phone.trim();			}			String sCode = SimpleSender.sendMessage(phone, messagemanageForm.getMessage());			System.out.println("sCode="+sCode);			//scode==num=0&success=&faile=13559541932&err=企业用户验证失败&errid=6010			//scode==num=1&success=13559541932&faile=&err=发送成功!&errid=0			String errCode = "";			if("-1".equals(sCode)||sCode.indexOf("发送成功")<0){//短信发送失败				message.setIssend("0");				errCode="发送失败!请确认电话号码是否正确,网络是否畅通";			}else{//成功				message.setIssend("1");				errCode="发送成功";			}						dao.addMessage(message);			try {				PrintWriter out = response.getWriter();				out.println("<script language='javascript'>alert('"+errCode+"!');location.href='"+request.getContextPath()+"/manage/custinfo.do?paramtype=querylist&stype=3';</script>");			} catch (IOException e) {				// TODO Auto-generated catch block				e.printStackTrace();			}			return null;			//return mapping.findForward("Messagelist");		}			/** 	 * Method execute	 * @param mapping	 * @param form	 * @param request	 * @param response	 * @return ActionForward	 */	public ActionForward detail(		ActionMapping mapping,		ActionForm form,		HttpServletRequest request,		HttpServletResponse response) {		MessagemanageForm MessagemanageForm = (MessagemanageForm) form;			MessagemanageForm.setTask("modify");		return mapping.findForward("Messageedit");	}		/** 	 * Method execute	 * @param mapping	 * @param form	 * @param request	 * @param response	 * @return ActionForward	 */	public ActionForward modify(		ActionMapping mapping,		ActionForm form,		HttpServletRequest request,		HttpServletResponse response) {		MessagemanageForm MessagemanageForm = (MessagemanageForm) form;		ApplicationContext context = this.getWebApplicationContext();		IMessageDAO dao = (IMessageDAO)context.getBean("Messagedao");		Message Message = new Message();		return null;	}		private void addTypeList(HttpServletRequest request){		ApplicationContext context = this.getWebApplicationContext();		IMyDictDAO dictdao = (IMyDictDAO)context.getBean("mydictdao");	}}

⌨️ 快捷键说明

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