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

📄 rightbean.java

📁 Oracle源码:Oracle 数据库管理与应用系统开发代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

package oa.bean;

import java.text.*;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.sql.*;
import oa.main.*;

public class RightBean extends ParentBean
{
	String uid = "-1";//人员编号
	String Orgid = "-1";//部门编号

	public void setUID(String uid)//设置人员编号
	{
		this.uid = uid.trim();
	}

	public void setOrgid(String Orgid)//设置部门编号
	{
		this.Orgid = Orgid.trim();
	}

	/**判断是否是系统管理员*/
	public boolean isAdmin()
	{
		String name = toName("ZZ_ZGB","ZGBH","ZGBH",uid).toLowerCase();
		if(name.equals("1"))return true;
		else return false;
	}

	/**配置权限*/
	public Vector getRightConf()
	{
		Vector vect = new Vector();
		String right = "";
		ResultSet rs = selectRecord("select PZCS from ZZ_ZGB where ZGBH='"+uid+"'");
		Statement stmt = null;
		try{
			if(rs.next())
			{
				right = ds.toString(rs.getString("PZCS"));
			}
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("RightBean.getRightConf()关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("RightBean.getRightConf()关闭声明时statement出错"+e);}		

			if(right.equals(""))//当当前人员表为空时,查询职务表权限集合
			{
				rs = selectRecord("select PZCS from ZZ_ZWB where (BMBH,ZWBH) in (select BMBH,ZWBH from ZZ_ZGZWB where ZGBH='"+uid+"')");
				if(rs.next())
				{
					if(!right.equals(""))right+=",";
					right = ds.toString(rs.getString("PZCS"));
				}
				if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("RightBean.getRightConf()关闭记录集rs时出错"+e);}
				if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("RightBean.getRightConf()关闭声明时statement出错"+e);}		
			}


			if(right.equals(""))//当职务表集合为空时
			{
				stmt = rs.getStatement(); rs.close(); stmt.close();
				rs = selectRecord("select PZSZ from CODE_XTPZ order by PZBH");
				while(rs.next())
				{
					vect.add(ds.toString(rs.getString(1)));
				}
				if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("RightBean.getRightConf()关闭记录集rs时出错"+e);}
				if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("RightBean.getRightConf()关闭声明时statement出错"+e);}		
			}
			else
			{
				String str[] = ds.splitStr(right,',');
				for(int i=0;i<str.length;i++)
				{
					vect.add(str[i]);
				}
			}
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
		return vect;
	}

	public String getConfValue(String type)//取得配置数字
	{
		String confvalue = "";
		Vector vect = getRightConf();
		int pzbh = toID("CODE_XTPZ","PZMC","PZBH",type.trim());
		if(vect.size()>=pzbh&&pzbh>0)
			confvalue = (String)vect.get(pzbh-1);
		return confvalue;
	}

	/**模块权限*/
	public Vector getRightMode()
	{
		Vector vect = new Vector();
		String sql = "select BMBH,ZWBH,CZQX from ZZ_ZGZWB where ZGBH='"+uid+"'";
		if(!uid.equals("1") && !Orgid.equals("-1"))
		{
			char bmsub;
			int n=19;
			for(n=19;n>=0;n--)
			{
				bmsub = Orgid.charAt(n);
				if(bmsub!='0')
					break;
			}
			if(n==-1) n=1;
			sql += " and (BMBH='"+Orgid+"' or BMBH like '%"+Orgid.substring(0,n+1)+"%')";
		}
		String right = "";

		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try{
			while(rs.next())//取得职务表权限
			{
				String czqx = ds.toString(rs.getString("CZQX"));
				String bmbh = ds.toString(rs.getString("BMBH"));
				String zwbh = ds.toString(rs.getString("ZWBH"));
				if(czqx.equals(""))//当职务表中权限为空时,去部门职务表权限
				{
					sql = "select CZQX from ZZ_ZWB where BMBH='"+bmbh+"' and ZWBH="+zwbh+" and ZWZT=0";
					ResultSet rs_t = selectRecord(sql);
					try{
					rs_t.next();
					czqx = ds.toString(rs_t.getString("CZQX"));
					}catch(Exception e){System.out.println("运行时出错:"+e);}
					finally{
						if(rs_t!=null)try{ stmt = rs_t.getStatement(); rs_t.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
						if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
					}
				}
				if(!right.equals("")&&!czqx.equals(""))
					right += ",";
				if(!czqx.equals(""))
					right += czqx;
			}

		//if(right.equals(""))//当职务权限集合为空时查询字典
		//{
			stmt = rs.getStatement(); rs.close();stmt.close();
			rs = selectRecord("select ID from CODE_ANCZQXB where MRCZ=1 and SYZT=0");
			while(rs.next())
			{
				vect.add(rs.getString(1));
			}
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
		//}
		//else
		//{
			String str[] = ds.splitStr(right,',');
			for(int i=0;i<str.length;i++)
			{
				vect.add(str[i]);
			}
		//}
		return vect;
	}

	/**流程权限*/
	public Vector getRightFlow()
	{
		Vector vect = new Vector();
		String sql = "select BMBH,ZWBH,LCQX from ZZ_ZGZWB where ZGBH='"+uid+"'";
		if(!Orgid.equals("-1"))sql += " and BMBH='"+Orgid+"'";
		String right = "";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try{
			while(rs.next())//取得职务表权限
			{
				String czqx = ds.toString(rs.getString("LCQX"));
				String bmbh = ds.toString(rs.getString("BMBH"));
				String zwbh = ds.toString(rs.getString("ZWBH"));
				if(czqx.equals(""))//当职务表中权限为空时,去部门职务表权限
				{
					sql = "select LCQX from ZZ_ZWB where BMBH='"+bmbh+"' and ZWBH="+zwbh+" and ZWZT=0";
					ResultSet rs_t = selectRecord(sql);
					try{
					if(rs_t.next())
						czqx = ds.toString(rs_t.getString("LCQX"));
					}catch(Exception e){System.out.println("运行时出错:"+e);}
					finally{
						if(rs_t!=null)try{ stmt = rs_t.getStatement(); rs_t.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
						if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
					}
				}
				if(!right.equals("")&&!czqx.equals(""))
					right += ",";
				if(!czqx.equals(""))
					right += czqx;
			}
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}

		if(right.equals(""))//当职务权限集合为空时查询字典
		{
			rs = selectRecord("select MKBH from CODE_LCQXB where MRCZ=1 and SYZT=0");
			try{
			while(rs.next())
			{
				vect.add(rs.getString(1));
			}
			}catch(Exception e){System.out.println("运行时出错:"+e);}
			finally{
				if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
				if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
			}
		}
		else
		{
			String str[] = ds.splitStr(right,',');
			for(int i=0;i<str.length;i++)
			{
				vect.add(str[i]);
			}
		}

		return vect;
	}

	/**是否有操作button对模块mode的权限*/
	public boolean isRightMode(String mode,String button)
	{
		boolean bool = false;
		ResultSet rs = selectRecord("select ID from CODE_ANCZQXB where MKMC='"+ds.toString(mode)+"' and ANMC='"+ds.toString(button)+"'");
		String mkbh = "";
		Statement stmt = null;
		try{
			if(rs.next())
			{
				 mkbh = ds.toString(rs.getString("ID"));
			}
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
		Vector vect = getRightMode();
		int index = vect.indexOf(mkbh);
		if(index!=-1)bool = true;

		return bool;
	}
	
	public boolean isRightFlow(String flow)//是否有操作流程flow的权限
	{
		boolean bool = false;
		ResultSet rs = selectRecord("select MKBH from CODE_LCQXB where MKMC='"+ds.toString(flow)+"'");
		String mkbh = "";
		Statement stmt = null;
		try{
			if(rs.next())
			{
				 mkbh = ds.toString(rs.getString("MKBH"));
			}
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
		Vector vect = getRightFlow();
		int index = vect.indexOf(mkbh);
		if(index!=-1)bool = true;
		return bool;
	}

	/**机要权限*/
	public Vector getRightConfidential()
	{
		Vector vect = new Vector();
		ResultSet rs = selectRecord("select CKQX from ZZ_BMB where BMBH ='"+Orgid+"'");
		String right = "";
		Statement stmt = null;
		try{
		if(rs.next())
			right = ds.toString(rs.getString("CKQX"));
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
		String str[] = ds.splitStr(right,',');
		for(int i=0;i<str.length;i++)
		{
			vect.add(toName("ZZ_ZGB","ZGBH","XM",str[i]));
		}
		return vect;
	}

	/*判断当前是否有该权限*/
	public boolean isRightConfidential()
	{
		boolean bool = false;
		String right = "";
		ResultSet rs = selectRecord("select CKQX from ZZ_BMB where BMBH =(select BMBH from ZZ_ZGB where ZGBH='"+uid+"')");
		Statement stmt = null;
		try{
		if(rs.next())
			right = ds.toString(rs.getString(1));
		}catch(Exception e){System.out.println("运行时出错:"+e);}
		finally{
			if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("关闭记录集rs时出错"+e);}
			if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("关闭声明时statement出错"+e);}		
		}
		

⌨️ 快捷键说明

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