⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c40action.java

📁 使用spring ,hibernate 框架的稽查管理系统
💻 JAVA
字号:
package com.je.ims.controller.c40;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

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

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import com.je.ims.dao.C40DAO;
import com.je.ims.hibernate.Btree;
import com.je.ims.hibernate.BtreeFull;
import com.je.ims.hibernate.Role;
import com.je.ims.hibernate.RoleId;
import com.je.ims.util.MenuUtils;

public class C40Action implements Controller {
    private C40DAO dao;
    public void setDao(C40DAO dao)
    {
    	this.dao=dao;
    }
	public ModelAndView handleRequest(HttpServletRequest arg0,
			HttpServletResponse arg1) throws Exception {
		ModelAndView model=null;
		String actionType=arg0.getParameter("actionType");
		if(actionType.equals("showlevel"))
			model=getKind(arg0,arg1);
		if(actionType.equals("shownode"))
			model=getNode(arg0,arg1);
		return model;
	}
	public ModelAndView getKind(HttpServletRequest arg0,
			HttpServletResponse arg1) throws Exception {
		// TODO Auto-generated method stub
		HttpSession session=arg0.getSession();
		String index = arg0.getParameter("index");
		Long year=new Long(Long.parseLong(arg0.getParameter("year")));
		String txtName=arg0.getParameter("txtName");
		List list=new LinkedList();	
		String program=arg0.getParameter("program");
		LinkedList list1=(LinkedList)session.getAttribute("menu");
		List roleList=MenuUtils.getRole(list1,program);
        RoleId id=(RoleId)roleList.get(0);
		Role role=dao.getRoleByPk(id);
	
			String nodeid=role.getNodeId();
			if(nodeid==null)
				{
				nodeid="root";
				}
			list=dao.GetAllByParent(nodeid,year);
		for(int i=0;i<list.size();i++)
			{
				Btree bt=(Btree)list.get(i);
				if(bt.getLvl().intValue()>1)
					{
					list.remove(i);
					i--;
					}
			}
			
		BtreeFull[] tf = new BtreeFull[list.size()];
		for (int i =0;i<list.size();i++){
			tf[i] = new BtreeFull();
			Btree temp = (Btree)list.get(i);
			tf[i].setNodeId(temp.getId().getNodeId());
			tf[i].setParentId(temp.getParentId());
			if(dao.IsNode(temp))
				tf[i].setIsNode(1);
			else 
				tf[i].setIsNode(0);	
		}
		Map model = new HashMap();
		model.put("atf",tf);
		model.put("parentId",nodeid);
		model.put("txtName",txtName);
		model.put("index",index);
		return new ModelAndView("c40.jsp",model);
	}
	public ModelAndView getNode(HttpServletRequest arg0,
			HttpServletResponse arg1) throws Exception {
		// TODO Auto-generated method stub
		HttpSession session=arg0.getSession();
		String parentId=arg0.getParameter("parentId");
		int lvl=Integer.parseInt(arg0.getParameter("lvl"));
		String index = arg0.getParameter("index");
		Long year=new Long(Long.parseLong(arg0.getParameter("year")));
		String txtName=arg0.getParameter("txtName");
		List btlist=new LinkedList();
		List list=dao.GetAllByParent(parentId,year);
		for(int i=0;i<list.size();i++)
		{
			Btree bt=(Btree)list.get(i);
			if(bt.getLvl().intValue()>lvl)
				{
				list.remove(i);
				i--;
				}
		}
		BtreeFull[] tf = new BtreeFull[btlist.size()];
		for (int i =0;i<btlist.size();i++){
			tf[i] = new BtreeFull();
			Btree temp = (Btree)btlist.get(i);
			tf[i].setNodeId(temp.getId().getNodeId());
			tf[i].setParentId(temp.getParentId());
			if(dao.IsNode(temp))
				tf[i].setIsNode(1);
			else 
				tf[i].setIsNode(0);	
		}
		Map model = new HashMap();
		model.put("atf",tf);
		model.put("parentId",parentId);
		model.put("txtName",txtName);
		model.put("index",index);
		return new ModelAndView("c40.jsp",model);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -