📄 flowaction.java
字号:
package com.st0705.erp.shenPi.action;
import java.io.PrintWriter;
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.hibernate.criterion.DetachedCriteria;
import com.st0705.erp.base.BaseAction;
import com.st0705.erp.base.BaseDao;
import com.st0705.erp.base.DemoConstants;
import com.st0705.erp.base.DoPageBean;
import com.st0705.erp.base.PageBean;
import com.st0705.erp.shenPi.IService.IFlowService;
import com.st0705.erp.shenPi.IService.IFlowTypeService;
import com.st0705.erp.shenPi.form.FlowForm;
import com.st0705.erp.shenPi.vo.FlowTypeVO;
import com.st0705.erp.shenPi.vo.FlowVO;
public class FlowAction extends BaseAction {
/*
*
* 添加时查询所有审批流程的名称;
*
*/
public ActionForward toGetAddName(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
IFlowTypeService iflow = (IFlowTypeService) getBean(DemoConstants.SERVICEFLOWTYPE);
List list = iflow.SelectAllData("FlowTypeVO");
System.out.println("list="+list.size());
request.setAttribute("types", list);
return mapping.findForward("toAddFlowView");
}
/*
*
* 修改时查询所有审批流程的名称;
*
*/
// public ActionForward findAllName(ActionMapping mapping, ActionForm form,
// HttpServletRequest request, HttpServletResponse response)
// throws Exception {
// IFlowService iflow = (IFlowService) getBean(ServiceName.SERVICEFLOW);
// List list = iflow.SelectAll("from FlowVO");
//
// request.setAttribute("types", list);
// return mapping.findForward("toGetFlowById");
// }
/*
*
* 显示时查询所有审批流程的名称;
*
*/
public ActionForward getAllName(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
IFlowTypeService iflow = (IFlowTypeService) getBean(DemoConstants.SERVICEFLOWTYPE);
List list = iflow.SelectAllData("FlowTypeVO");
request.setAttribute("types", list);
return null;
}
/*
*
* 查询所有审批流程;
*
*/
public ActionForward findAllFlow(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
try {
IFlowService iflow = (IFlowService) getBean(DemoConstants.SERVICEFLOW);
DoPageBean dpb=new DoPageBean();
HttpSession session=request.getSession(true);
DetachedCriteria dc=null;/*离线查询*/
String typeName="";/*类型名称*/
String name=""/*模糊查询值*/;
List list=null;
dc=dpb.getDetachedCriteria(FlowVO.class);
int size = iflow.SelectCount("FlowVO");
PageBean pb=dpb.Work(request,FlowVO.class,size);
list = iflow.SelectAll(dc,pb);
// }else if(type.equals("2")){/*按类型进行分页*/
// if(request.getParameter("typeName")!=null){
// typeName=request.getParameter("typeName");
// session.setAttribute("typeName", typeName);
// }else{
// typeName=(String)session.getAttribute("typeName");
// }
// dc=dpb.getDetachedCriteria(new String(typeName.getBytes("ISO-8859-1"), "GBK").trim(),FlowVO.class,"flowName");
// int size=iflow.getCount(dc);
// System.out.println("size="+size);
// PageBean pb=dpb.Work(request,FlowVO.class,size);
// list = iflow.SelectAll(dc,pb);
//
// request.setAttribute("type", type);
// }
// }else if(type.equals("3")){/*对模糊查询进行分页*/
// if(request.getParameter("name")!=null){
// name=request.getParameter("name");
// session.setAttribute("name", name);
// }else{
// name=(String)session.getAttribute("typeName");
// }
// dc=dpb.getDetachedCriteria1(name,FlowVO.class,"flowName");
// request.setAttribute("type", type);
// }
request.setAttribute("list", list);
getAllName(mapping,form,request,response);
return mapping.findForward("toShowFlowList");
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
// public ActionForward findAllFlow(ActionMapping mapping, ActionForm form,
// HttpServletRequest request, HttpServletResponse response)
// throws Exception {
// try{
// IFlowService iflow = (IFlowService) getBean(DemoConstants.SERVICEFLOW);
// List list=iflow.SelectAllData("FlowVO");
// request.setAttribute("list", list);
//
// getAllName(mapping,form,request,response);
// return mapping.findForward("toShowFlowList");
// }catch(Exception e){
// e.printStackTrace();
// return null;
// }
//
// }
/*
*
* 根据类型查询所有审批流程;
*
*/
public ActionForward getAllFlowByType(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
System.out.println("123456");
try{
int name=new Integer(request.getParameter("selectName"));
IFlowService iflow = (IFlowService) getBean(DemoConstants.SERVICEFLOW);
List list=iflow.getAllFlowByType(name);
System.out.println("list="+list.size());
request.setAttribute("list", list);
getAllName(mapping,form,request,response);
return mapping.findForward("toShowFlowList");
}catch(Exception e){
e.printStackTrace();
return null;
}
}
/*
*
* 添加审批流程;
*
*/
public ActionForward toAddFlow(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
System.out.println("addflow");
FlowForm flow=(FlowForm)form;
FlowVO vo=new FlowVO();
BeanUtils.copyProperties(vo, flow);
FlowTypeVO ft=new FlowTypeVO();
ft.getFlows().add(vo);
vo.setFlowTypes(ft);
IFlowService iflow = (IFlowService) getBean(DemoConstants.SERVICEFLOW);
boolean bool=iflow.add(vo);
System.out.println(bool);
if(bool){
getAllName(mapping,form,request,response);
return mapping.findForward("toShowFlowList");
}else{
return mapping.findForward("error");
}
}
/*
*
* 根据 ID 查询该审批流程;
*
*/
public ActionForward findFlowId(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
FlowForm flowform=(FlowForm)form;
IFlowService iflow = (IFlowService) getBean(DemoConstants.SERVICEFLOW);
int id=new Integer(request.getParameter("id"));
FlowVO flow=(FlowVO)iflow.selectById(FlowVO.class, id);
BeanUtils.copyProperties(flowform, flow);
if(request.getParameter("type").equals("2")){
request.setAttribute("flow", flow);
getAllName(mapping,form,request,response);
return mapping.findForward("toUpdateView");
}else if(request.getParameter("type").equals("1")){
return mapping.findForward("toNodeList");
}
return null;
}
/*
*
* 去修改保存;
*
*/
public ActionForward updateFlow(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
FlowForm flowform=(FlowForm)form;
FlowVO vo=new FlowVO();
vo.setDocType(flowform.getDocType());
BeanUtils.copyProperties(vo, flowform);
System.out.println("oid="+flowform.getOid());
vo.setOid(flowform.getOid());
FlowTypeVO ft=new FlowTypeVO();
ft.getFlows().add(vo);
vo.setFlowTypes(ft);
IFlowService iflow = (IFlowService) getBean(DemoConstants.SERVICEFLOW);
boolean bool=iflow.update(vo);
System.out.println(bool);
if(bool){
getAllName(mapping,form,request,response);
return mapping.findForward("toShowFlowList");
}else{
return mapping.findForward("error");
}
}
/*
*
* 删除审批流程;
*
*/
public ActionForward deleteFlow(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
boolean bool=false;
IFlowService iflow = (IFlowService) getBean(DemoConstants.SERVICEFLOW);
if(request.getParameter("type")!=null){
String id=request.getParameter("oid");
String oid[]=id.split(":");
for (int i = 0; i < oid.length; i++) {
System.out.println(i+":"+oid[i]);
if(i!=0){
int idValue=(int)Integer.parseInt(oid[i].toString());
System.out.println("id============"+idValue);
System.out.println("zhangdu="+oid[i].length());
// FlowVO flowvo=(FlowVO)iflow.selectById(FlowVO.class,idValue);
FlowVO flow=new FlowVO();
flow.setOid(idValue);
bool=iflow.del(flow);
}
}
}else{
int id=new Integer(request.getParameter("id"));
FlowVO flowvo=(FlowVO)iflow.selectById(FlowVO.class, id);
bool=iflow.del(flowvo);
}
System.out.println(bool);
if(bool){
findAllFlow(mapping,form,request,response);
return mapping.findForward("toGetAll");
}else{
return mapping.findForward("error");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -