📄 latencygroupaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.jn0801.group;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
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.company.CompanyBean;
import com.jn0801.company.CompanyIFC;
import com.jn0801.login.systemuser.SystemuserBean;
/**
* 潜在集团客户的action
* @author student
*
*/
public class LatencyGroupAction extends DispatchAction {
private CompanyIFC companyifc;
private ProviceIFC proviceifc;
private TypeIFC typeifc;
private CompanyLogIFC companylogifc;
public CompanyLogIFC getCompanylogifc() {
return companylogifc;
}
public void setCompanylogifc(CompanyLogIFC companylogifc) {
this.companylogifc = companylogifc;
}
public TypeIFC getTypeifc() {
return typeifc;
}
public void setTypeifc(TypeIFC typeifc) {
this.typeifc = typeifc;
}
public ProviceIFC getProviceifc() {
return proviceifc;
}
public void setProviceifc(ProviceIFC proviceifc) {
this.proviceifc = proviceifc;
}
public CompanyIFC getCompanyifc() {
return companyifc;
}
public void setCompanyifc(CompanyIFC companyifc) {
this.companyifc = companyifc;
}
/**
* 显业集团客户列表
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward listgroup(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
LatencyGroupForm latencyGroupForm = (LatencyGroupForm) form;
HttpSession session=request.getSession();
SystemuserBean user=(SystemuserBean) session.getAttribute("userbean");
int userid=user.getRealname();
List<CompanyBean> list=new ArrayList<CompanyBean>();
if(userid==10000)
{
CompanyBean companyBean1=new CompanyBean();
list=this.companyifc.listcompanyforall(companyBean1,request);
}
else
{
CompanyBean companyBean=new CompanyBean();
companyBean.setServicemanager(String.valueOf(userid));
companyBean.setCompanystate("'潜在','正式'");
list=this.companyifc.listcompanyforall(companyBean, request);
}
request.setAttribute("grouplist",list);
return mapping.findForward("groupjsp");
}
/**
* 添加潜在集团客户1
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward addlatencygroup(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
LatencyGroupForm latencyGroupForm = (LatencyGroupForm) form;
List<provincecode> list=this.proviceifc.listprovince();
List<typecode> typelist=this.typeifc.listtype();
request.setAttribute("provincelist", list);
request.setAttribute("typelist", typelist);
return mapping.findForward("addjsp");
}
/**
* 省份和城市的AJAX的发送
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws IOException
*/
public ActionForward sendajax(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException {
LatencyGroupForm latencyGroupForm = (LatencyGroupForm) form;
long nid=latencyGroupForm.getNid();
List<provincecode> list=this.proviceifc.listcity(nid);
response.setContentType("text/xml");
PrintWriter out= response.getWriter();
StringBuffer string=new StringBuffer();
string.append("<citys>");
for(provincecode pro:list)
{
string.append("<city>");
string.append("<id>"+pro.getNid()+"</id>");
string.append("<sname>"+pro.getSname()+"</sname>");
string.append("<scode>"+pro.getScode()+"</scode>");
string.append("</city>");
}
string.append("</citys>");
String total = "<?xml version=\"1.0\" encoding=\"GBK\"?>";
total=total+string.toString();
out.println(total);
out.flush();
return null;
}
/**
* 检验集团名字的ajax
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws IOException
*/
public ActionForward checkName(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException{
LatencyGroupForm latencyGroupForm = (LatencyGroupForm) form;
PrintWriter out = null;
String message = "";
out=response.getWriter();
if(request.getParameter("name")!=null && !request.getParameter("name").equals(""))
{
String name=latencyGroupForm.getName();
List list=this.companyifc.listsearchbyname(name);
if(list.size()==1)
{
message="不能起相同的名字";
}else
{
message="正确";
}
}else
{
message="不能为空";
}
out.print(message);
out.flush();
return null;
}
/**
* 添加集团客户2
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws IOException
*/
public ActionForward addCustomer(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException{
LatencyGroupForm latencyGroupForm = (LatencyGroupForm) form;
//根据规则来生成集团客户编号
Date date=new Date();
SimpleDateFormat simple=new SimpleDateFormat("yyyyMM");
String nowtime=simple.format(date.getTime());
nowtime=nowtime.substring(2,6);
//获取省的code
String province=latencyGroupForm.getProvince();
Long pronid=Long.parseLong(province);
List<provincecode> list=this.proviceifc.listcityById(pronid);
String scode=list.get(0).getScode();
//获取市的code
String city=latencyGroupForm.getArea();
Long cityid=Long.parseLong(city);
List<provincecode> citylist=this.proviceifc.listcityById(cityid);
String cityscode=citylist.get(0).getScode();
//获取行业的code
String callingtype=latencyGroupForm.getCallingtype();
Long typeid=Long.parseLong(callingtype);
List<typecode> typelist=this.typeifc.listSearchById(typeid);
String typecode=typelist.get(0).getScode();
//取出最大的的记录数
String maxcount="1000";
CompanyBean companyBean=new CompanyBean();
companyBean.setCallingtype(callingtype);
int count=this.companyifc.getCountforcallingtype(companyBean);
if(count==0)
{
maxcount="1000";
}else
{
List<CompanyBean> maxlist=this.companyifc.listSearchMaxID(companyBean);
if(list!=null)
{
CompanyBean company=maxlist.get(0);
if(company.getCompanyid()!=null && !company.getCompanyid().equals(""))
{
int length=company.getCompanyid().length();
maxcount=company.getCompanyid().substring(length-4,length);
}
}
}
String serial=String.valueOf(Integer.parseInt(maxcount)+1);
//拼凑出编号
String companyid=nowtime+scode+cityscode+typecode+serial;
HttpSession session=request.getSession();
SystemuserBean user=(SystemuserBean) session.getAttribute("userbean");
int userid=user.getRealname();
System.out.println(userid+"....userid");
CompanyBean company=new CompanyBean();
try {
BeanUtils.copyProperties(company, latencyGroupForm);
company.setCompanyid(companyid);
company.setCallingtype(typecode);
if(latencyGroupForm.getCompanylevel().equals("1"))
{
company.setCompanylevel("省级");
}
if(latencyGroupForm.getCompanylevel().equals("2"))
{
company.setCompanylevel("市级");
}
if(userid!=10000)
{
company.setServicemanager(String.valueOf(userid));
}
else
{
company.setServicemanager("0");
}
System.out.println(company.getServicemanager()+"......45456454");
company.setIslogout("0");
company.setCompanystate("录入");
} catch (Exception e) {
}
PrintWriter out = null;
out=response.getWriter();
List mylist=this.companyifc.listsearchbyname(company.getCompanyname());
if(mylist.size()>0)
{
out.print("<script>alert('不能添加相同的集团名!'); window.history.back();</script>");
}
else
{
boolean flag=this.companyifc.savecompany(company,userid);
if(flag)
{
out.print("<script>alert('添加成功!'); window.location.href='latencyGroup.do?task=listgroup'</script>");
}else
{
out.print("alert('添加失败!');window.history.back();");
}
}
return null;
}
/**
* 显示详细信息
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward showdetail(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
LatencyGroupForm latencyGroupForm = (LatencyGroupForm) form;
Long nid=latencyGroupForm.getNid();
CompanyBean companybean=this.companyifc.particular(nid);
try {
BeanUtils.copyProperties(latencyGroupForm,companybean);
} catch (Exception e) {
}
return mapping.findForward("showdetail");
}
/**
* 注销
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward logout(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
LatencyGroupForm latencyGroupForm = (LatencyGroupForm) form;
Long nid=latencyGroupForm.getNid();
PrintWriter out=null;
try {
out=response.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
boolean flag=this.companyifc.updatelogout(nid);
if(flag)
{
out.print("<script>alert('注销成功!'); window.location.href='latencyGroup.do?task=listgroup'</script>");
}else
{
out.print("<script>alert('注销失败!');window.history.back();</script>");
}
return null;
}
/**
* 显示要审核的列表
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward checkupLatency(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
LatencyGroupForm latencyGroupForm = (LatencyGroupForm) form;
List<CompanyBean> list=new ArrayList<CompanyBean>();
CompanyBean companyBean=new CompanyBean();
companyBean.setServicemanager("");
companyBean.setCompanystate("'录入'");
list=this.companyifc.listcompanyforall(companyBean, request);
request.setAttribute("grouplist",list);
return mapping.findForward("showlist");
}
/**
* 跳转审核
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward tocheckup(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
LatencyGroupForm latencyGroupForm = (LatencyGroupForm) form;
Long nid=latencyGroupForm.getNid();
CompanyBean companybean=this.companyifc.particular(nid);
try {
BeanUtils.copyProperties(latencyGroupForm,companybean);
} catch (Exception e) {
}
return mapping.findForward("checkup");
}
/**
* 审核状态改变
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward changetoLatency(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
LatencyGroupForm latencyGroupForm = (LatencyGroupForm) form;
Long nid=latencyGroupForm.getNid();
boolean flag=this.companyifc.updatecompanystate("潜在","0", nid);
PrintWriter out=null;
try {
out=response.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
if(flag)
{
out.print("<script>alert('审核成功!'); window.location.href='latencyGroup.do?task=checkupLatency'</script>");
}else
{
out.print("<script>alert('审核失败!');window.history.back();</script>");
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -