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

📄 rightbean.java

📁 这是一个很好用的软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				right = 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 news.ZZ_BMB where BMBH =(select BMBH from news.ZZ_ZGB where ZGBH='"
				+ uid + "')");
		Statement stmt = null;
		try {
			if (rs.next())
				right = 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);
				}
		}
		int t = right.indexOf(uid);
		if (t != -1)
			bool = true;
		return bool;
	}

	/** 文书权限 */
	public boolean isRightSecretary() {
		boolean bool = false;
		String right = "";
		ResultSet rs = selectRecord("select WSZWBH from news.ZZ_BMB where BMBH =(select BMBH from news.ZZ_ZGB where ZGBH='"
				+ uid + "')");
		Statement stmt = null;
		try {
			if (rs.next())
				right = 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);
				}
		}
		if (right != null && right.equals(uid))
			bool = true;
		return bool;
	}

	/** 比较该Vector变量中莫一个变量权限名称 */
	public String getExist(Vector v, String s) {
		String str = "";
		for (int i = 0; i < v.size(); i++) {
			String t = (String) v.get(i);
			if (t.indexOf(s) != -1) {
				int t1 = t.indexOf("<");
				str = t.substring(t1 + 1, t.length() - 1);
				break;
			}
		}
		return str;
	}

	/** 档案权限 */
	//public Vector getRightArchives()档案权限
	//public Vector getRightPeriodical()期刊权限
	//当前职工所在的部门编号(包括被分配职务后得到的职务部门编号)
	public Vector getBMBHS() {
		Vector vect = new Vector();
		String sql = " select BMBH from news.ZZ_ZGZWB where ZGBH='" + uid + "'";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try {
			while (rs.next()) {
				String bmbh = ds.toString(rs.getString(1));
				String bmmc = db.toName("ZZ_BMB", "BMBH", "BMMC", bmbh);
				Hashtable hash = new Hashtable();
				hash.put("BMBH", bmbh);
				hash.put("BMMC", bmmc);
				vect.add(hash);
			}
		} 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 boolean isRightOrg(String lbid) {//ZZ_FBXWB//部门新闻操作权限(根据orgmenu.id判断)(uid,Orgid)
		boolean isright = false;
		ResultSet rst = selectRecord("select LB from news.ZZ_FBXWB where ZGBH='"
				+ uid + "' and BMBH='" + Orgid + "' and LB = 2");
		Statement stmt = null;
		try {
			if (rst.next()) {
				isright = true;
			}
		} catch (Exception e) {
			System.out.println("运行时出错:" + e);
		} finally {
			if (rst != null)
				try {
					stmt = rst.getStatement();
					rst.close();
				} catch (Exception e) {
					System.out.println("关闭记录集rs时出错" + e);
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
					System.out.println("关闭声明时statement出错" + e);
				}
		}
		return isright;
	}

	public boolean isRightPage(String dxbh, String whichtable, String sf,
			String cz) {//版面权限
		boolean isright = false;
		ResultSet rst = selectRecord("select LB from news.ZZ_FBXWB where ZGBH='"
				+ uid
				+ "' and LB = 1 and DXBH='"
				+ dxbh
				+ "' and WHICHTABLE = '"
				+ whichtable
				+ "' and SF='"
				+ sf
				+ "' and cz='" + cz + "'");
		Statement stmt = null;
		try {
			if (rst.next()) {
				isright = true;
			}
		} catch (Exception e) {
			System.out.println("运行时出错:" + e);
		} finally {
			if (rst != null)
				try {
					stmt = rst.getStatement();
					rst.close();
				} catch (Exception e) {
					System.out.println("关闭记录集rs时出错" + e);
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
					System.out.println("关闭声明时statement出错" + e);
				}
		}
		return isright;
	}

	/** 取得模块权限------------lbh-----------11-29 */
	public String getRightModelbh() {
		String czqx = "", czqx1 = "";
		String bmbh = "", bmbhchg = "";
		String zwbh = "";
		String right = "";
		String sql = "select BMBH,ZWBH,CZQX from news.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)+"%')"; }
		 */
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try {
			while (rs.next())//取得职务表权限
			{
				czqx = ds.toString(rs.getString("CZQX"));
				bmbh = ds.toString(rs.getString("BMBH"));
				zwbh = ds.toString(rs.getString("ZWBH"));
				if (!bmbh.equals("") && !zwbh.equals("")) {
					if (czqx.equals(""))//当职务表中权限为空时,去部门职务表权限
					{
						sql = "select CZQX from news.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("CZQX"));

							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 (czqx.equals(""))//当职务权限集合为空时查询字典
							{
								rs_t = selectRecord("select ID from news.CODE_ANCZQXB where MRCZ=1 and SYZT=0");
								while (rs_t.next()) {
									czqx1 = rs_t.getString(1);
									if (czqx.equals(""))
										czqx = czqx1;
									else
										czqx = czqx + "," + czqx1;
								}
							}
						} 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 (!bmbhchg.equals("") && !bmbh.equals(bmbhchg)) {
						right = right + "@" + bmbh + ":" + czqx;
						bmbhchg = bmbh;
						continue;
					}
					if (right.equals("") && !czqx.equals(""))
						right = bmbh + ":" + czqx;
					else if (!right.equals("") && !czqx.equals(""))
						right = right + "," + czqx;
					bmbhchg = bmbh;
				}
			}

			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(""))//当职务权限集合为空时查询字典
			{
				bmbh = Orgid;
				stmt = rs.getStatement();
				rs.close();
				stmt.close();
				rs = selectRecord("select ID from news.CODE_ANCZQXB where MRCZ=1 and SYZT=0");
				while (rs.next()) {
					czqx = rs.getString(1);
					if (!right.equals("") && !czqx.equals(""))
						right = right + "," + czqx;
					if (right.equals("") && !czqx.equals(""))
						right = bmbh + ":" + 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);
				}
		}
		return right;
	}

	/** 是否有模块操作权限------------lbh-----------11-29 */
	public boolean isRightModelbh(String strmkmc, String strbtnmc) {
		boolean bool = false;
		/*
		 * 原先每次取数据库的代码 ResultSet rs = selectRecord("select ID from
		 * news.CODE_ANCZQXB where MKMC='"+ds.toString(strmkmc)+"' and
		 * ANMC='"+ds.toString(strbtnmc)+"'"); 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);} } String rights =
		 * getRightModelbh(); String []ids = rights.split("@"); for(int i=0;i
		 * <ids.length;i++) { String []bmrt = ids[i].split(":"); char bmsub ;
		 * int n=19; for(n=19;n>=0;n--) { bmsub = bmrt[0].charAt(n);
		 * if(bmsub!='0') break; } //要setOrgid为当前部门 if(bmrt[0].equals(Orgid) ||
		 * (bmrt[0].substring(0,n+1)).equals(Orgid.substring(0,n+1))) { String
		 * []rts = bmrt[1].split(","); for(int j=0;j <rts.length;j++) {
		 * if(rts[j].equals(mkbh)) { bool = true; break; } } } }
		 */
		//////////////
		//从静态向量中取得权限记录
		if (PublicData.v_Buttons == null)
			PublicData.rebuildButtonTable();
		String strID = null;
		String strRight = null;
		Hashtable hash = null;
		//得到该按钮的ID
		int k = PublicData.v_Buttons.size();
		for (int i = 0; i < k; i++) {
			hash = (Hashtable) PublicData.v_Buttons.get(i);
			if (strmkmc.equals((String) hash.get("MKMC"))
					&& strbtnmc.equals((String) hash.get("ANMC"))) {
				strID = "," + (String) hash.get("ID") + ",";
				break;
			}
		}
		//得到此人的所有权限
		if (Orgid.equals("-1")) {//不限制所在部门
			if (PublicData.v_right == null)
				PublicData.rebuildRightVector();
			k = PublicData.v_right.size();
			for (int i = 0; i < k; i++) {
				if (uid.equals((String) PublicData.v_right.get(i))) {
					strRight = "," + (String) PublicData.v_right.get(++i) + ",";
					break;
				}
			}
		} else {//限制部门
			if (PublicData.v_RightTable == null)
				PublicData.rebuildRightTable();
			k = PublicData.v_RightTable.size();
			boolean b = false;
			for (int i = 0; i < k; i++) {
				hash = (Hashtable) PublicData.v_RightTable.get(i);
				if (uid.equals((String) hash.get("ZGBH"))) {
					if (!b)
						b = true;
					int n = 19;
					String bmrt = (String) hash.get("BMBH");
					for (n = 19; n >= 0; n--) {
						if (bmrt.charAt(n) != '0')
							break;
					}
					if (bmrt.equals(Orgid)
							|| (bmrt.substring(0, n + 1)).equals(Orgid
									.substring(0, n + 1))) {
						String str = (String) hash.get("CZQX");
						if (strRight == null)
							strRight = str;
						else
							strRight += "," + str;
					}
				} else if (b)
					break;
			}
			if (strRight == null) {
				if (PublicData.s_RightDefault == null)
					PublicData.rebuildRightDefault();
				strRight = "," + PublicData.s_RightDefault + ",";
			} else
				strRight = "," + ds.strDistinct(strRight) + ",";
		}
		//判断权限
		bool = (strRight.indexOf(strID) != -1);
		//////////////
		return bool;
	}

	public static void main(String args[]) {
		RightBean mb = new RightBean();

		mb.setUID("1");

		//判断是否是管理员
		boolean bool = mb.isAdmin();

		//模块权限用法:true/false
		bool = mb.isRightMode("个人信息", "修改个人信息");
		//流程权限用法:true/false
		bool = mb.isRightFlow("发邮件");
		//系统配置参数
		System.out.println(mb.isRightMode("部门列表", "增加子部门"));
		//System.out.println(mb.getConfValue("短消息保存时间"));

		System.out.println("\r\n\r\nend");
	}
}

⌨️ 快捷键说明

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