📄 palnaction.java
字号:
package com.t53.crm4.sale.web.action;
import java.text.SimpleDateFormat;
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.CstLinkman;
import com.t53.crm4.common.entity.SalChance;
import com.t53.crm4.common.entity.SalPlan;
import com.t53.crm4.customer.biz.CustInfManageBizIface;
import com.t53.crm4.sale.biz.IChanceBiz;
import com.t53.crm4.sale.biz.IPlanBiz;
import com.t53.crm4.sale.web.form.PlanForm;
public class PalnAction extends DispatchAction {
private IPlanBiz planbiz;
private IChanceBiz chancebiz;
private CustInfManageBizIface custmanagerBiz;
public CustInfManageBizIface getCustmanagerBiz() {
return custmanagerBiz;
}
public void setCustmanagerBiz(CustInfManageBizIface custmanagerBiz) {
this.custmanagerBiz = custmanagerBiz;
}
public IChanceBiz getChancebiz() {
return chancebiz;
}
public void setChancebiz(IChanceBiz chancebiz) {
this.chancebiz = chancebiz;
}
public IPlanBiz getPlanbiz() {
return planbiz;
}
public void setPlanbiz(IPlanBiz planbiz) {
this.planbiz = planbiz;
}
/**
* 跳转到开发计划列表页面
*
*/
public ActionForward toList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("list");
}
/**
* 执行开发计划页面
*/
public ActionForward doList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// 我要的业务就是将所有的销售机会查询出来
PlanForm planform = (PlanForm) form;
SalChance chanceItem = planform.getSalChance();
// 验证销售机会计划是否为空
if ("".equals(chanceItem.getChcCustName())) {
chanceItem.setChcCustName(null);
}
if ("".equals(chanceItem.getChcTitle())) {
chanceItem.setChcTitle(null);
}
if ("".equals(chanceItem.getChcLinkman())) {
chanceItem.setChcLinkman(null);
}
List<SalChance> chancelist = chancebiz.getSalChanceByPagination(
chanceItem, planform.getPagebean());
// 对销售机会计划列表进行判断
if (chancelist != null && chancelist.size() > 0) {
request.setAttribute("chancelist", chancelist);
}
return mapping.findForward("list");
}
/**
* 执行新建计划项页面
*
*/
public ActionForward doAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
PlanForm planform = (PlanForm) form;
SalPlan salplan = planform.getSalplan();
salplan.setSalChance(chancebiz.getChanceByEntity(planform
.getSalChance().getChcId()));
// 设置创建计划项的时间 ,即当前创建新项时间
salplan.setPlaDate(new Date());
// 保存销售计划项
boolean bool = planbiz.saveSalPlan(salplan);
if (bool) {
request.setAttribute("newplan", "新建计划项成功");
} else {
request.setAttribute("newplan", "新建计划项失败");
}
request.setAttribute("salnewplan", salplan);
request.setAttribute("salChance", chancebiz.getChanceByEntity(salplan
.getSalChance().getChcId()));
planform.setSalplan(new SalPlan());
return mapping.findForward("frame");
}
/**
* 执行编辑计划项(删除操作)
*/
public ActionForward doDel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
PlanForm planform = (PlanForm) form;
SalPlan salplan = planform.getSalplan();
Long id = Long.parseLong(request.getParameter("id"));
salplan = planbiz.getSalPlanByEntity(id);
request.setAttribute("salplan", salplan);
boolean bool = planbiz.deleteSalPlan(id);
if (bool) {
request.setAttribute("deleteplan", "删除成功");
} else {
request.setAttribute("deleteplan", "删除失败");
}
request.setAttribute("salChance", chancebiz.getChanceByEntity(salplan
.getSalChance().getChcId()));
return mapping.findForward("frame");
}
/**
* 跳转到制定计划页面
*
*/
public ActionForward toFrame(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
PlanForm planform = (PlanForm) form;
SalChance salChance = planform.getSalChance();
// 业务逻辑
// 根据销售机会的状态来制定开发计划,状态为2,即已指派才能制定开发计划
Long id = Long.parseLong(request.getParameter("frameid"));
salChance = chancebiz.getChanceByEntity(id);
request.setAttribute("salChance", salChance);
return mapping.findForward("frame");
}
/**
* 保存计划项结果
*/
public ActionForward doSavePlanResult(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
PlanForm planForm = (PlanForm) form;
SalPlan planItem = planForm.getSalplan();
Long chaceId = planItem.getSalChance().getChcId();
// 获得销售机会计划项id
/*
* String id = request.getParameter("planid");
*
* String salid = request.getParameter("salchanceid"); SalChance salItem =
* chancebiz.getChanceByEntity(Long.parseLong(salid)); // 获得计划项结果 String
* planResult = request.getParameter("planresult");
*/
// SalPlan planItem = planbiz.findById(Long.parseLong(id));
// planItem.setPlaResult(planResult);
// 保存计划项的结果
planbiz.saveOrUpdate(planItem);
request.setAttribute("salChance", chancebiz.getChanceByEntity(chaceId));
request.setAttribute("operMsg", "保存计划项成功");
return mapping.findForward("execute");
}
/**
* 跳转到执行页面
*/
public ActionForward toExecute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// 获得销售机会id
String id = request.getParameter("salchanceid");
// Long tempid = Long.parseLong(id);
List<SalPlan> salplanlist = planbiz.getPlanByChanceId(Long
.parseLong(id));
SalChance salItem = chancebiz.getChanceByEntity(Long.parseLong(id));
request.setAttribute("salChance", salItem);
// 对计划项进行判断,如果如果存在,就能执行,否则不能执行
if (salplanlist != null && salplanlist.size() > 0) {
request.setAttribute("salplanlist", salplanlist);
// 设置销售机会的状态
salItem.setChcStatus("0");
return mapping.findForward("execute");
}
request.setAttribute("faileplanlist", "你没有制定计划项,不能执行计划项");
return mapping.findForward("frame");
}
/**
* 查看已归档的销售机会具体信息
*
*/
public ActionForward toSee(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String chanceId = request.getParameter("chanceid");
SalChance salItem = chancebiz.getChanceByEntity(Long
.parseLong(chanceId));
request.setAttribute("salChance", salItem);
return mapping.findForward("see");
}
/**
* 开发成功
*/
public ActionForward doOpenSuccess(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// PlanForm planform = (PlanForm) form;
// 获得销售机会的id
String chanceId = request.getParameter("chanceid");
SalChance salItem = chancebiz.getChanceByEntity(Long
.parseLong(chanceId));
// // 设置销售机会状态
salItem.setChcStatus("3");
// 更新销售机会
chancebiz.updateSalChance(salItem);
/*
* boolean bool = if(bool){ request.setAttribute("salItemmsg", "开发成功");
* }else{ request.setAttribute("salItemmsg", "开发失败"); }
*/
// 根据销售机会开发成功,创建客户信息记录(业务是根据销售机会的客户名称和联系人以及联系人的电话)
String cstname = salItem.getChcCustName();
String linkman = salItem.getChcLinkman();
Long cstmanagerid = salItem.getChcDueId();
String cstmanagerman = salItem.getChcDueTo();
String linktel = salItem.getChcTel();
// 创建客户信息对象
CstCustomer cstCustomer = new CstCustomer();
// 获得客户编号
SimpleDateFormat simdatefmt = new SimpleDateFormat("yyyyMMddhhmmss");
Date date = new Date();
cstCustomer.setCustNo("KF" + simdatefmt.format(date));
cstCustomer.setCustName(cstname);
cstCustomer.setCustManagerId(cstmanagerid);
cstCustomer.setCustManagerName(cstmanagerman);
cstCustomer.setCustTel(linktel);
// 设置客户状态
cstCustomer.setCustStatus("1");
String custNo = custmanagerBiz.saveCstCustomer(cstCustomer);
if (custNo != null || !(custNo.equals(""))) {
CstLinkman cstLinkman = new CstLinkman();
cstLinkman.setCstCustomer((cstCustomer));
cstCustomer.setCustNo(custNo);
cstCustomer.setCustName(cstname);
cstLinkman.setLkmTel(linktel);
cstLinkman.setLkmName(linkman);
custmanagerBiz.sava(cstLinkman);
}
return mapping.findForward("list");
}
// 终止开发
public ActionForward doOpenStop(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String chanceId = request.getParameter("chanceid");
SalChance salItem = chancebiz.getChanceByEntity(Long
.parseLong(chanceId));
// 设置销售机会状态
salItem.setChcStatus("4");
// 更新销售机会
chancebiz.updateSalChance(salItem);
return mapping.findForward("list");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -