dutybean.java

来自「这是一个很好用的软件」· Java 代码 · 共 965 行 · 第 1/2 页

JAVA
965
字号

		sql = "select * from news.ZZ_ZGZWB  where BMBH = " + strOrgNO
				+ " and ZWBH = " + strDutyNO + "";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try {
			if (rs.next()) {
				return -1;//职务有人担当,不能删除!
			}
		} catch (Exception e) {
			System.out.println("DutyBean.delDuty()运行时出错:" + e);
		} finally {
			if (rs != null)
				try {
					stmt = rs.getStatement();
					rs.close();
				} catch (Exception e) {
					System.out.println("DutyBean.delDuty()关闭记录集rs时出错" + e);
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
					System.out
							.println("DutyBean.delDuty()关闭声明时statement出错" + e);
				}
		}
		sql = "update  ZZ_ZWB set ZWZT = " + strZWZT + " where BMBH = "
				+ strOrgNO + " and ZWBH = " + strDutyNO + "";
		return deleteRecord(sql);
	}

	//删除当前部门当前职务数据记录
	public int delDBDuty() {
		String sql = "select * from news.ZZ_ZGZWB  where BMBH = " + strOrgNO
				+ " and ZWBH = " + strDutyNO + "";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try {
			if (rs.next()) {
				return -1;//职务有人担当,不能删除!
			}
		} catch (Exception e) {
			System.out.println("DutyBean.delDBDuty()运行时出错:" + e);
		} finally {
			if (rs != null)
				try {
					stmt = rs.getStatement();
					rs.close();
				} catch (Exception e) {
					System.out.println("DutyBean.delDBDuty()关闭记录集rs时出错" + e);
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
					System.out.println("DutyBean.delDBDuty()关闭声明时statement出错"
							+ e);
				}
		}
		sql = "delete from news.ZZ_ZWB where BMBH = " + strOrgNO
				+ " and ZWBH = " + strDutyNO + "";
		return deleteRecord(sql);
	}

	//通过部门编号和职务编号得到当前职务的操作权限,没转化为汉字 11-24
	public String getOper() {
		String strOper = "";
		String sql = "";
		String strMRCZ = "1";
		String strSYZT = "0";
		String str = ",";
		sql = "select CZQX from news.ZZ_ZWB where BMBH = " + strOrgNO
				+ " and ZWBH = " + strDutyNO + "";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try {
			if (rs.next()) {
				String strOperNo = ds.toString(rs.getString("CZQX"));
				if (strOperNo.equals(""))//如果职务表中的操作权限为空则去模块权限表取默认操作权限
				{

					sql = "select ID from news.CODE_ANCZQXB where MRCZ = "
							+ strMRCZ + " and SYZT = " + strSYZT + "";
					ResultSet res = selectRecord(sql);
					try {
						while (res.next()) {
							strOper += ds.toString(res.getString("ID")) + str;
						}
					} catch (Exception e) {
						System.out.println("DutyBean.getOper()运行时出错:" + e);
					} finally {
						if (res != null)
							try {
								stmt = res.getStatement();
								res.close();
							} catch (Exception e) {
								System.out
										.println("DutyBean.getOper()关闭记录集rs时出错"
												+ e);
							}
						if (stmt != null)
							try {
								stmt.close();
							} catch (Exception e) {
								System.out
										.println("DutyBean.getOper()关闭声明时statement出错"
												+ e);
							}
					}
					if (strOper != null && !strOper.equals(""))
						strOper = strOper.substring(0, strOper.length() - 1);
					if (strOper == null)
						strOper = "";
					return strOper;
				}
				//String strOpers[] = strOperNo.split(",");
				//for(int i=0;i<strOpers.length;i++)//根据分割后的编号取得模块名称
				//{
				//	strOper+=db.toName("CODE_CZQXB","MKBH","MKMC",strOpers[i])+str;
				//}
				strOper = strOper.substring(0, strOper.length() - 1);
			}
		} catch (Exception e) {
			System.out.println("DutyBean.getOper()运行时出错:" + e);
		} finally {
			if (rs != null)
				try {
					stmt = rs.getStatement();
					rs.close();
				} catch (Exception e) {
					System.out.println("DutyBean.getOper()关闭记录集rs时出错" + e);
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
					System.out
							.println("DutyBean.getOper()关闭声明时statement出错" + e);
				}
		}
		return strOper;
	}

	//通过部门编号和职务编号得到当前职务的流程权限,并且转化为汉字
	public String getFlow() {
		String strFlow = "";
		String sql = "";
		String strMRCZ = "1";
		String strSYZT = "0";
		String str = ",";
		sql = "select LCQX from news.ZZ_ZWB where BMBH = " + strOrgNO
				+ " and ZWBH = " + strDutyNO + "";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try {
			if (rs.next()) {
				String strFlowNo = ds.toString(rs.getString("LCQX"));
				if (strFlowNo.equals(""))//如果职务表中的流程权限为空则去流程权限表取默认流程权限
				{
					sql = "select  MKMC from news.CODE_LCQXB where MRCZ = "
							+ strMRCZ + " and SYZT = " + strSYZT + "";
					ResultSet res = selectRecord(sql);
					try {
						while (res.next()) {
							strFlow += ds.toString(res.getString("MKMC")) + str;
						}
					} catch (Exception e) {
						System.out.println("DutyBean.getFlow()运行时出错:" + e);
					} finally {
						if (res != null)
							try {
								stmt = res.getStatement();
								res.close();
							} catch (Exception e) {
								System.out
										.println("DutyBean.getFlow()关闭记录集rs时出错"
												+ e);
							}
						if (stmt != null)
							try {
								stmt.close();
							} catch (Exception e) {
								System.out
										.println("DutyBean.getFlow()关闭声明时statement出错"
												+ e);
							}
					}
					if (!strFlow.equals(""))
						strFlow = strFlow.substring(0, strFlow.length() - 1);
					return strFlow;
				}

				String strFlows[] = strFlowNo.split(",");
				for (int i = 0; i < strFlows.length; i++)//根据分割后的编号取得流程名称
				{
					strFlow += db.toName("CODE_LCQXB", "MKBH", "MKMC",
							strFlows[i])
							+ str;
				}
				strFlow = strFlow.substring(0, strFlow.length() - 1);
			}
		} catch (Exception e) {
			System.out.println("DutyBean.getFlow()运行时出错:" + e);
		} finally {
			if (rs != null)
				try {
					stmt = rs.getStatement();
					rs.close();
				} catch (Exception e) {
					System.out.println("DutyBean.getFlow()关闭记录集rs时出错" + e);
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
					System.out
							.println("DutyBean.getFlow()关闭声明时statement出错" + e);
				}
		}
		return strFlow;
	}

	//通过部门编号得到当前职务的配置参数
	public String getConf() {
		String strConf = "";
		String sql = "";
		//String str = ",";
		String str1 = ",";
		String strMax = "";
		int i, num = 0;//,j
		String[] xm = new String[10];//{"邮箱空间:","附件大小:","个人通讯录数目:","文件柜大小:",""};//
		String[] unit = new String[10];//{"MB","MB","条","MB",""};//

		sql = "select PZBH,PZMC,PZSZ,PZSM from news.CODE_XTPZ order by PZBH ";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try {
			while (rs.next()) {
				xm[num] = ds.toString(rs.getString("PZMC"));
				unit[num] = ds.toString(rs.getString("PZSM"));
				num++;
			}
			sql = "select PZCS from news.ZZ_ZWB where BMBH = " + strOrgNO
					+ " and ZWBH = " + strDutyNO + "";
			stmt = rs.getStatement();
			rs.close();
			stmt.close();
			rs = selectRecord(sql);
			if (rs.next()) {
				strConf = ds.toString(rs.getString("PZCS"));
				if (!strConf.equals(""))//如果职工中的配置参数不空
				{
					String sglemt[] = strConf.split(",");

					for (i = 0; i < sglemt.length; i++) {
						if (!strMax.equals(""))
							strMax += str1 + xm[i] + sglemt[i] + unit[i];
						if (strMax.equals(""))
							strMax = xm[i] + sglemt[i] + unit[i];
					}
					strConf = strMax;
					return strConf; //ok
				}
				if (strConf.equals(""))//如果职务表中的配置参数为空则去系统配置表取默认流程权限
				{
					sql = "select PZBH,PZSZ from news.CODE_XTPZ order by PZBH ";
					ResultSet r = selectRecord(sql);
					try {
						while (r.next()) {
							strConf += ds.toString(r.getString("PZSZ")) + str1;
						}
					} catch (Exception e) {
						System.out.println("DutyBean.getConf()运行时出错:" + e);
					} finally {
						if (r != null)
							try {
								stmt = r.getStatement();
								r.close();
							} catch (Exception e) {
								System.out
										.println("DutyBean.getConf()关闭记录集rs时出错"
												+ e);
							}
						if (stmt != null)
							try {
								stmt.close();
							} catch (Exception e) {
								System.out
										.println("DutyBean.getConf()关闭声明时statement出错"
												+ e);
							}
					}
					strConf = strConf.substring(0, strConf.length() - 1);
					String sglelement[] = strConf.split(",");

					for (i = 0; i < sglelement.length; i++) {
						if (!strMax.equals(""))
							strMax += str1 + xm[i] + sglelement[i] + unit[i];
						if (strMax.equals(""))
							strMax = xm[i] + sglelement[i] + unit[i];
					}

					strConf = strMax;
					return strConf; //ok
				}
				//return strConf;
			}
		} catch (Exception e) {
			System.out.println("DutyBean.getConf()运行时出错:" + e);
		} finally {
			if (rs != null)
				try {
					stmt = rs.getStatement();
					rs.close();
				} catch (Exception e) {
					System.out.println("DutyBean.getConf()关闭记录集rs时出错" + e);
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
					System.out
							.println("DutyBean.getConf()关闭声明时statement出错" + e);
				}
		}

		return strConf;
	}

	//根据部门编号返回名称
	public String toName() {
		return db.toName("ZZ_BMB", "BMBH", "BMMC", strOrgNO);
	}

	//根据填写的操作权限转化为存储字符
	public String toOperNo(String strOper) {
		String strOperNo = "";
		String str = ",";

		if (strOper.equals(""))//默认操作权限
		{
			return strOperNo;
		}
		String strOpers[] = strOper.split(",");
		for (int i = 0; i < strOpers.length; i++) {
			strOperNo += db.toID("CODE_CZQXB", "MKMC", "MKBH", strOpers[i])
					+ str;
		}
		strOperNo = strOperNo.substring(0, strOperNo.length() - 1);

		return strOperNo;
	}

	//根据填写的流程权限转化为存储字符
	public String toFlowNo(String strFlow) {
		String strFlowNo = "";
		String str = ",";

		if (strFlow.equals(""))//默认流程权限
		{
			return strFlowNo;
		}
		String strFlows[] = strFlow.split(",");
		for (int i = 0; i < strFlows.length; i++) {
			strFlowNo += db.toID("CODE_LCQXB", "MKMC", "MKBH", strFlows[i])
					+ str;
		}
		strFlowNo = strFlowNo.substring(0, strFlowNo.length() - 1);

		return strFlowNo;
	}

	//设置级别序号
	public String getJBNo() {
		String pri = "0";
		String sql = "select max(JBXH) from news.ZZ_ZWB where BMBH='"
				+ strOrgNO + "'";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try {
			//取得本部门职务的级别序号的最大编号
			if (rs.next()) {
				pri = ds.toString(rs.getInt(1) + 1 + "");
			}
		} catch (Exception e) {
			System.out.println("DutyBean.getJBNo()运行时出错:" + e);
		} finally {
			if (rs != null)
				try {
					stmt = rs.getStatement();
					rs.close();
				} catch (Exception e) {
					System.out.println("DutyBean.getJBNo()关闭记录集rs时出错" + e);
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
					System.out
							.println("DutyBean.getJBNo()关闭声明时statement出错" + e);
				}
		}
		return pri;
	}

	public ResultSet selOper()//从操作权限表里选取所有的模块名称
	{
		String sql = "select MKMC from news.CODE_CZQXB where SYZT=0";
		ResultSet rs = selectRecord(sql);
		return rs;
	}

	public ResultSet selFlow()//从流程表里选取所有的流程名称
	{
		String sql = "select MKMC from news.CODE_LCQXB where SYZT=0 order by JBXH";
		ResultSet rs = selectRecord(sql);
		return rs;
	}

	public String getOrdinaryZWBH(String bmbh, String zwmc)//根椐部门编号、职务名称返回职务编号
	{
		String zwbh = "";
		String sql = "select ZWBH from news.ZZ_ZWB where BMBH='" + bmbh
				+ "' and ZWMC='" + ds.toString(zwmc) + "'";
		ResultSet rs = selectRecord(sql);
		Statement stmt = null;
		try {
			if (rs.next()) {
				zwbh = ds.toString(String.valueOf(rs.getInt(1)));
			}
		} catch (Exception e) {
			System.out.println("DutyBean.getOrdinaryZWBH(String,String)运行时出错:"
					+ e);
		} finally {
			if (rs != null)
				try {
					stmt = rs.getStatement();
					rs.close();
				} catch (Exception e) {
					System.out
							.println("DutyBean.getOrdinaryZWBH(String,String)关闭记录集rs时出错"
									+ e);
				}
			if (stmt != null)
				try {
					stmt.close();
				} catch (Exception e) {
					System.out
							.println("DutyBean.getOrdinaryZWBH(String,String)关闭声明时statement出错"
									+ e);
				}
		}
		return zwbh;
	}

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

		mb.setOrgNO("00040000000000000000");
		mb.setDutyNO("6");
		Hashtable hash = new Hashtable();
		//hash.put("BMBH","00040000000000000000");
		hash.put("ZWMC", "邯钢科技服务部1111");
		hash.put("CZQX", "6");
		hash.put("LCQX", "3");
		hash.put("PZCS", "");
		hash.put("JBXH", "1");
		hash.put("ZWZT", "0");
		System.out.println("\n\n begin \n\n\n");
		System.out.println(mb.toOperNo("模块6"));
		//System.out.println(mb.toFlowNo("Wfdsafdsa,sss"));
		//mb.addDuty(hash);
		//mb.modDuty(hash);
		//System.out.println(mb.getData());
		//mb.delDuty();
		System.out.println("------------liumei--------职务编号: "
				+ mb.getOrdinaryZWBH("00050000000000000000", "一般员工"));
		System.out.println("\n\n end \n\n\n");

	}
}

⌨️ 快捷键说明

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