文章标题

来源:互联网 发布:caxa编程助手安装 编辑:程序博客网 时间:2024/05/22 06:46

第三步 action
package com.isoftstone.zfmi.struts.action.claim;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.isoftstone.iaeap.op.DBPersistenceManager;
import com.isoftstone.iaeap.op.OPSysManager;
import com.isoftstone.iaeap.op.QuerySet;

import com.isoftstone.zfmi.boc.Application.entity.Code;
import com.isoftstone.zfmi.boc.Application.entity.Codefilee;

/**
* @author 1
* wj 编码规则多级菜单的跳转
*
*/
public class ProjectAction extends Action{

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,        HttpServletResponse response) throws Exception {    // TODO 自动生成方法存根     String aa = request.getParameter("project");    List realsubcodetypeList = new ArrayList();    List<Codefilee> list4 = new ArrayList();        Object[] paras = {};        DBPersistenceManager dbpm = OPSysManager.getInstance().getDBPersistenceManager();     try{         dbpm.currentTransaction().begin();         String sql3="SELECT a.realsubcodetype FROM tb_code_filee a where flag='1' group by realsubcodetype,grade order by grade";         QuerySet dptSet2 = dbpm.executeQuery(sql3, paras);         int num3 = dptSet2.getRowCount();            if(num3>0){                 for( int i=1; i<= num3; i++ ){                     String realsubcodetype =dptSet2.getString(i,"realsubcodetype");//标题编号                      realsubcodetypeList.add(realsubcodetype);                 }            }            for (int i = 0; i < realsubcodetypeList.size(); i++) {                String strRealsubcodetype = (String)realsubcodetypeList.get(i);                Object[] paras1 = {strRealsubcodetype};            String sql1 = " SELECT t.* FROM tb_code_filee t where realsubcodetype=? ";            QuerySet dptSet = dbpm.executeQuery(sql1, paras1);            int num = dptSet.getRowCount();             if(num>0){                 List list = new ArrayList();                 for( int j=1; j<= num; j++ ){                    String codecode= dptSet.getString(j,"codecode");//上级代码                    String subcode = dptSet.getString(j,"subcode");//本级代码                    String realsubcode= dptSet.getString(j,"realsubcode");//本级编号                    String realsubcodetype =dptSet.getString(j,"realsubcodetype");//标题编号                    String realsubcname = dptSet.getString(j,"realsubcname");//标题名字                    String subcodecname = dptSet.getString(j,"subcodecname");//属性中文名                    String grade = dptSet.getString(j,"grade");//等级                    Code code =new Code();                    code.setCodecode(codecode);                    code.setSubcode (subcode );                    code.setRealsubcode(realsubcode);                    code.setRealsubcodetype(realsubcodetype);                    code.setRealsubcname(realsubcname);                    code.setSubcodecname(subcodecname);                    code.setGrade(grade);                    list.add(code);                                     }                    Codefilee codefileeDto = new Codefilee();                    codefileeDto.setTitleName(((Code)list.get(0)).getRealsubcname());                    codefileeDto.setGrade(((Code)list.get(0)).getGrade());                    codefileeDto.setSubCode(((Code)list.get(0)).getSubcode());                    codefileeDto.setRealsubcode(((Code)list.get(0)).getRealsubcode());                    codefileeDto.setCodecode(((Code)list.get(0)).getCodecode());                    codefileeDto.setListcode(list);                    list4.add(codefileeDto);                }            }              dbpm.currentTransaction().commit();                dbpm.close();     }catch(Exception ex){     }        request.setAttribute("list4", list4);//传值到前端        //log.debug(mapping.getInputForward());     return mapping.findForward("result");  //返回到配置文件指定路径跳转jsp页面 result}

}

0 0
原创粉丝点击