📄 serviceaction.java
字号:
package com.t53.crm4.serve.web.action;
import java.io.PrintWriter;
import java.util.Date;
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.t53.crm4.common.entity.CstCustomer;
import com.t53.crm4.common.entity.CstService;
import com.t53.crm4.common.entity.SysUser;
import com.t53.crm4.serve.biz.IServiceBiz;
import com.t53.crm4.serve.web.form.ServiceForm;
public class ServiceAction extends DispatchAction {
private IServiceBiz serviceBiz;
/**
* 进入添加服务页面
*/
public ActionForward toAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
List<CstCustomer> custList = serviceBiz.findAllCust();
System.out.println(custList.size());
request.setAttribute("custList", custList);
return mapping.findForward("toAdd");
}
/**
* 处理添加服务Action
*/
public ActionForward doAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// TODO Auto-generated method stub
ServiceForm serviceForm = (ServiceForm) form;
CstService cstService = serviceForm.getCstService();
Long id = serviceBiz.addService(cstService);
if (id != 0) {
request.setAttribute("msg", "创建服务成功");
return toAdd(mapping, form, request, response);
}
return toAdd(mapping, form, request, response);
}
/**
* 查询所有状态为新创建的服务条目
*/
public ActionForward doDispatch(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ServiceForm svrForm = (ServiceForm) form;
System.out.println("*************************");
String beforDate = svrForm.getTime1();
String afterDate = svrForm.getTime2();
CstService cstService = svrForm.getCstService();
List<SysUser> userList = serviceBiz.findByRoleId(4);
List svrTypeList = serviceBiz.findAllsvrType();
request.setAttribute("svrTypeList", svrTypeList);
request.setAttribute("userList", userList);
List<CstService> svrList = null;
svrList = serviceBiz.findByPage(cstService, svrForm.getPageBean(),
beforDate, afterDate);
request.setAttribute("svrList", svrList);
return mapping.findForward("toDispatch");
}
public ActionForward toDispatch(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List svrTypeList = serviceBiz.findAllsvrType();
request.setAttribute("svrTypeList", svrTypeList);
return mapping.findForward("toDispatch");
}
/**
* 删除服务条目
*/
public ActionForward doDelServer(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
Long svrId = Long.parseLong(request.getParameter("svrId"));
serviceBiz.deleteBySvrId(svrId);
PrintWriter out = response.getWriter();
out.write("删除成功");
out.flush();
out.close();
return null;
}
/**
* 处理服务分配的action
*/
public ActionForward doAllot(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
Long svrId = Long.parseLong(request.getParameter("id"));
Long svrDueId = Long.parseLong(request.getParameter("dueId"));
String svrDueTo = request.getParameter("dueName");
CstService cstService = new CstService();
cstService.setSvrId(svrId);
cstService.setSvrDueId(svrDueId);
cstService.setSvrDueTo(svrDueTo);
cstService.setSvrDueDate(new Date());
cstService.setSvrStatus("已分配");
serviceBiz.update(cstService);
PrintWriter out = response.getWriter();
String msg = "分配成功";
out.write(msg);
out.flush();
out.close();
return null;
}
/**
* 进入服务处理页面
*
*/
public ActionForward toDealList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
List svrTypeList = serviceBiz.findAllsvrType();
request.setAttribute("svrTypeList", svrTypeList);
return mapping.findForward("toDealList");
}
/**
* 查询所有状态为已处理的条目
*
*/
public ActionForward doDealList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ServiceForm svrForm = (ServiceForm) form;
String beforDate = svrForm.getTime1();
String afterDate = svrForm.getTime2();
CstService cstService = svrForm.getCstService();
SysUser user = new SysUser();
user = (SysUser) request.getSession().getAttribute("USER");
cstService.setSvrDueId(user.getUsrId());
List<CstService> dealList = serviceBiz.findByPage(cstService, svrForm
.getPageBean(), beforDate, afterDate);
request.setAttribute("dealList", dealList);
List svrTypeList = serviceBiz.findAllsvrType();
request.setAttribute("svrTypeList", svrTypeList);
return mapping.findForward("toDealList");
}
/**
* 处理选中的服务
*
*/
public ActionForward toDetail(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
System.out.println("============================");
Long svrId = Long.parseLong(request.getParameter("svrId"));
System.out.println(svrId);
List svrTypeList = serviceBiz.findAllsvrType();
System.out.println("*****************************");
request.setAttribute("svrTypeList", svrTypeList);
CstService cstService = serviceBiz.findBySvrId(svrId);
request.setAttribute("cstService", cstService);
return mapping.findForward("toDeal_detail");
}
/**
* 服务处理Action
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward doDetail(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ServiceForm serviceForm = (ServiceForm) form;
String beforDate = serviceForm.getTime1();
String afterDate = serviceForm.getTime2();
CstService cstService = serviceForm.getCstService();
serviceBiz.modify(cstService);
serviceForm.reset(mapping, request);
serviceForm.getCstService().setSvrStatus("已分配");
SysUser user = new SysUser();
user = (SysUser) request.getSession().getAttribute("USER");
cstService.setSvrDueTo(user.getUsrName());
List<CstService> dealList = serviceBiz.findByPage(serviceForm
.getCstService(), serviceForm.getPageBean(), beforDate,
afterDate);
request.setAttribute("dealList", dealList);
List svrTypeList = serviceBiz.findAllsvrType();
request.setAttribute("svrTypeList", svrTypeList);
// return mapping.findForward("toDealList");
return doDealList(mapping, form, request, response);
}
/**
* 服务处理Action
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward doBackDetail(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ServiceForm serviceForm = (ServiceForm) form;
String beforDate = serviceForm.getTime1();
String afterDate = serviceForm.getTime2();
CstService cstService = serviceForm.getCstService();
serviceBiz.modify(cstService);
serviceForm.reset(mapping, request);
serviceForm.getCstService().setSvrStatus("已分配");
SysUser user = new SysUser();
user = (SysUser) request.getSession().getAttribute("USER");
cstService.setSvrDueId(user.getUsrId());
List<CstService> dealList = serviceBiz.findByPage(serviceForm
.getCstService(), serviceForm.getPageBean(), beforDate,
afterDate);
request.setAttribute("dealList", dealList);
List svrTypeList = serviceBiz.findAllsvrType();
request.setAttribute("svrTypeList", svrTypeList);
return mapping.findForward("toDealList");
}
/**
* 服务反馈 处理服务结果
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward doDeal_detail(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ServiceForm svrForm = (ServiceForm) form;
CstService cstSvr = svrForm.getCstService();
int satisfy = cstSvr.getSvrSatisfy();
// 根据客户满意度修改服务条目状态
String msg = null;
if (satisfy >= 3) {
cstSvr.setSvrStatus("已归档");
msg = "服务已归档";
} else {
cstSvr.setSvrStatus("已分配");
msg = "服务已重新分配";
}
// 调用更新更新方法
serviceBiz.updateResult(cstSvr);
request.setAttribute("msg", msg);
svrForm.reset(mapping, request);
return doFeedbackList(mapping, svrForm, request, response);
}
/**
* 处理反馈
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward toFeedbackList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
List svrTypeList = serviceBiz.findAllsvrType();
request.setAttribute("svrTypeList", svrTypeList);
return mapping.findForward("toFeedback");
}
/**
* 反馈
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward doFeedbackList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ServiceForm svrForm = (ServiceForm) form;
String beforDate = svrForm.getTime1();
String afterDate = svrForm.getTime2();
CstService cstSvr = svrForm.getCstService();
cstSvr.setSvrStatus("已处理");
List svrTypeList = serviceBiz.findAllsvrType();
request.setAttribute("svrTypeList", svrTypeList);
List feedList = serviceBiz.findByPage(cstSvr, svrForm.getPageBean(),
beforDate, afterDate);
request.setAttribute("feedList", feedList);
return mapping.findForward("toFeedback");
}
/**
* 处理服务反馈
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward toBack(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
Long svrId = Long.parseLong(request.getParameter("svrId"));
List svrTypeList = serviceBiz.findAllsvrType();
request.setAttribute("svrTypeList", svrTypeList);
CstService cstService = serviceBiz.findBySvrId(svrId);
request.setAttribute("cstService", cstService);
return mapping.findForward("toBack_detail");
}
// ///////////////////////////服务归档////////////////////////////////////////////
/**
* 进入服务归档页面
*/
public ActionForward toArchList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
List svrTypeList = serviceBiz.findAllsvrType();
request.setAttribute("svrTypeList", svrTypeList);
List svrStatusList = serviceBiz.findAllStatus();
request.setAttribute("svrStatusList", svrStatusList);
return mapping.findForward("toArch");
}
/**
* 查询所有已归档的服务条目
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward doArchList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ServiceForm svrForm = (ServiceForm) form;
String beforDate = svrForm.getTime1();
String afterDate = svrForm.getTime2();
CstService cstSvr = svrForm.getCstService();
cstSvr.setSvrStatus("已归档");
// 查找所有服务类型
List svrTypeList = serviceBiz.findAllsvrType();
request.setAttribute("svrTypeList", svrTypeList);
List svrStatusList = serviceBiz.findAllStatus();
request.setAttribute("svrStatusList", svrStatusList);
List archList = serviceBiz.findByPage(cstSvr, svrForm.getPageBean(),
beforDate, afterDate);
request.setAttribute("archList", archList);
return mapping.findForward("toArch");
}
/**
* 查看已归档的一条服务条目
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward toArchDetail(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
Long svrId = Long.parseLong(request.getParameter("svrId"));
CstService cstService = serviceBiz.findBySvrId(svrId);
request.setAttribute("cstService", cstService);
return mapping.findForward("toDetail");
}
/**
* 注入
*
* @param serviceBiz
*/
public void setServiceBiz(IServiceBiz serviceBiz) {
this.serviceBiz = serviceBiz;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -