?? 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 + -