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

📄 imp.java

📁 “JSP数据库项目案例导航”一书从第一章到第十一章各章实例的源程序文件以及数据库文件。 注意: 1. 本书中的案例提供的数据库环境不同
💻 JAVA
字号:
package oa.bean;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.text.*;
import java.lang.*;
import sun.io.*;
import oa.main.*;
//import oa.bean.*;
public class IMP 
{
	javax.servlet.jsp.JspWriter out;

	DealString ds = new DealString();
	public IMP()
	{
	}
	public IMP(javax.servlet.jsp.JspWriter o)
	{
		out = o;
	}
	public String Do(String filename){
		/**输入文件*/
		String infile = "";
		FileInputStream fis = null;//输入文件流
		String output = "";
		DepartmentBean dbean = null;
		PersonBean pbean = null;
		DutyBean dutybn = null;
		PersonDutyBean psdbn = null;
		InputStreamReader isw = null;
		BufferedReader br = null;
		try
		{
			output+="<hr>";
			out.print("<hr>");
			dbean = new DepartmentBean();
			pbean = new PersonBean();
			dutybn = new DutyBean();
			psdbn = new PersonDutyBean();
			infile = filename;
			fis = new FileInputStream(infile);
			//建立Unicode字符流
			isw = new InputStreamReader(fis);
			br = new BufferedReader(isw);

			//读Unicode字符串
			String s = "";
			br.readLine();
			String strZCRQ = (new DealTime()).getDate();
			while((s=br.readLine())!=null)
			{
				//if(!str.equals(""))str = str + "\r\n" + s;
				//else str = str + s;
				//	s = s.replaceAll("1","2");
				String[] record = ds.splitStr(s,'	');
				String[] strBM = ds.splitStr(record[0],'\\');
				String strBMFBH = "00000000000000000000";
				String strBMMC = "";
				String strBMBH = "";
				Hashtable hash = new Hashtable();
				record[0]=record[0].trim();
				record[1]=record[1].trim();
				record[2]=record[2].trim();
				record[3]=record[3].trim();
				{//////////////////////////////////////////////////////////////////处理部门
					if(strBM.length==1){//添加二级部门
						strBMMC = ds.toString(strBM[0]);
						hash.clear();
						hash.put("BMFBH",strBMFBH);
						hash.put("BMMC",strBMMC);
						hash.put("JBXH","0");
						hash.put("TZWBH","");
					}
					else if(strBM.length==2){//添加三级部门
						strBMFBH = dbean.toName("ZZ_BMB","BMMC","BMBH",strBM[0]);//取得二级部门编号
						if(strBMFBH.equals("")){//不存在该二级部门,添加二级部门
							strBMMC = ds.toString(strBM[0]);
							hash.clear();
							hash.put("BMFBH","00000000000000000000");
							hash.put("BMMC",strBMMC);
							hash.put("JBXH","0");
							hash.put("TZWBH","");
							dbean.addRec(hash,false);
							strBMFBH = dbean.toName("ZZ_BMB","BMMC","BMBH",strBM[0]);//重新取得二级部门编号
						}
						strBMMC = ds.toString(strBM[1]);//添加三级部门
						hash.clear();
						hash.put("BMFBH",strBMFBH);
						hash.put("BMMC",strBMMC);
						hash.put("JBXH","0");
						hash.put("TZWBH","");
					}
					else if(strBM.length==3){//添加四级部门
						strBMFBH = dbean.toName("ZZ_BMB","BMMC","BMBH",strBM[0]);//取得二级部门
						if(strBMFBH.equals("")){//不存在该二级部门,添加二级部门
							strBMMC = ds.toString(strBM[0]);
							hash.clear();
							hash.put("BMFBH","00000000000000000000");
							hash.put("BMMC",strBMMC);
							hash.put("JBXH","0");
							hash.put("TZWBH","");
							dbean.addRec(hash,false);
							strBMFBH = dbean.toName("ZZ_BMB","BMMC","BMBH",strBM[0]);//重新取得二级部门编号
						}
						Vector vect = dbean.getOnePage("select BMBH from ZZ_BMB where BMFBH='"+strBMFBH+"' and BMMC='"+strBM[1]+"'",1,1);//取得三级部门编号
						if(vect.size()==1){//不存在该三级部门,添加三级部门
							strBMMC = ds.toString(strBM[0]);
							hash.clear();
							hash.put("BMFBH",strBMFBH);
							hash.put("BMMC",strBMMC);
							hash.put("JBXH","0");
							hash.put("TZWBH","");
							dbean.addRec(hash,false);
							vect = dbean.getOnePage("select BMBH from ZZ_BMB where BMFBH='"+strBMFBH+"' and BMMC='"+strBM[1]+"'",1,1);//重新取得三级部门编号
						}
						strBMFBH = (String)((Hashtable)vect.get(1)).get("BMBH");
						strBMMC = ds.toString(strBM[2]);//添加四级部门
						hash.clear();
						hash.put("BMFBH",strBMFBH);
						hash.put("BMMC",strBMMC);
						hash.put("JBXH","0");
						hash.put("TZWBH","");
					}
					int r = dbean.addRec(hash,false);
					String result = "";
					if(r==0)
						result = "添加部门成功";
					else if(r==1)
						result = "该部门已经存在";
					output+="<br><font size=2>"+("执行结果:"+result)+"</font>";
					output+="<br><font size=2>"+("部门名称:"+strBMMC)+"</font>";
					out.print("<br><font size=2>"+("执行结果:"+result)+"</font>");
					out.print("<br><font size=2>"+("部门名称:"+strBMMC)+"</font>");
					strBMBH = (String)((Hashtable)dbean.getOnePage("select BMBH from ZZ_BMB where BMFBH='"+ strBMFBH +"' and BMMC='"+ strBMMC +"'",1,1).get(1)).get("BMBH");
					output+="<br><font size=2>"+"部门编号为:"+strBMBH;
					out.print("<br><font size=2>"+"部门编号为:"+strBMBH);
					/////////////////////////////////////////////////////////////  添加部门  完成
				}
				{///////////////////////////////////////////////////////////////   添加员工 开始
					String strZGBH = pbean.getMaxzgNo();
					hash.clear();
					hash.put("BMBH",strBMBH);
					hash.put("ZGBH",strZGBH);
					hash.put("XM",record[1]);
					hash.put("XB",record[2]);
					hash.put("GH",record[3]);
					//hash.put("MMWT","您的工号是多少?");
					//hash.put("MMDA",record[3]);
					hash.put("MM",record[3]);
					hash.put("YHM",record[3]);
					hash.put("ZCRQ",strZCRQ);
					hash.put("ZZZT","0");
					hash.put("ZNYH","0");
					int r = pbean.addPerson(hash);
					String result = "";
					if(r==0){
						{///////////////////////////////////////////////////////////////设置一般员工默认职务
							String zwNo = dutybn.getOrdinaryZWBH(strBMBH,"一般员工");
							if(zwNo.equals("")){
								Hashtable dutyhash = new Hashtable();
								dutyhash.put("BMBH",strBMBH);
								dutyhash.put("ZWMC","一般员工");
								dutyhash.put("CZQX","");
								dutyhash.put("LCQX","");
								dutyhash.put("PZCS","");
								dutyhash.put("JBXH","");
								dutyhash.put("ZWZT","0");
								dutybn.addDuty(dutyhash,false);
								zwNo = dutybn.getOrdinaryZWBH(strBMBH,"一般员工");
							}
							psdbn.addRec(strZGBH,strBMBH,zwNo,"","",false);//addRec(String personno,String dutyOrgno,String dutyno,String czqx,String lcqx)
						}
						result = "添加人员成功,设置一般员工职务成功!";
					}
					else if(r==5)
						result = "人员纪录有错误,请仔细检查是否有重复记录,工号已存在";
					output+="<br><font size=2>"+("执行结果:"+result)+"</font>";
					output+="<br><font size=2>"+("职工编号:"+strZGBH)+"</font>";
					output+="<br><font size=2>"+("职工姓名:"+record[1])+"</font>";
					output+="<br><font size=2>"+("职工性别:"+record[2])+"</font>";
					output+="<br><font size=2>"+("职工工号:"+record[3])+"</font>";
					out.print("<br><font size=2>"+("执行结果:"+result)+"</font>");
					out.print("<br><font size=2>"+("职工编号:"+strZGBH)+"</font>");
					out.print("<br><font size=2>"+("职工姓名:"+record[1])+"</font>");
					out.print("<br><font size=2>"+("职工性别:"+record[2])+"</font>");
					out.print("<br><font size=2>"+("职工工号:"+record[3])+"</font>");
				}///////////////////////////////////////////////////////////////   添加员工 开始
				output+="<br><font size=2>"+("-------------The next Record----------</font>");
				out.print("<br><font size=2>"+("-------------The next Record----------</font>"));
			}
		}catch(Exception ioe){output+="<br><font size=2>"+("错误:\r\n"+ioe)+"</font>";try{out.print("<br><font size=2>"+("错误:\r\n"+ioe)+"</font>");}catch(IOException e){}}
		finally{
			if(br!=null)try{br.close();}catch(IOException ioe){output+="<br><font size=2>"+("错误:\r\n"+ioe);try{out.print("<br><font size=2>"+("错误:\r\n"+ioe)+"</font>");}catch(IOException e){}}
			if(isw!=null)try{isw.close();}catch(IOException ioe){output+="<br><font size=2>"+("错误:\r\n"+ioe);try{out.print("<br><font size=2>"+("错误:\r\n"+ioe)+"</font>");}catch(IOException e){}}
			if(fis!=null)try{fis.close();}catch(IOException ioe){output+="<br><font size=2>"+("错误:\r\n"+ioe);try{out.print("<br><font size=2>"+("错误:\r\n"+ioe)+"</font>");}catch(IOException e){}}
			if(dbean!=null){dbean.rebuildTree();dbean.closeConn();}
			if(pbean!=null)pbean.closeConn();
			if(dutybn!=null)dutybn.closeConn();
			if(psdbn!=null)psdbn.closeConn();
		PublicData.rebuildFlowVector();
		PublicData.rebuildRightVector();
		}
		output+="<br><font size=2>"+("-----------END---------------")+"</font>";
		try{out.print("<br><font size=2>"+("-----------END---------------")+"</font>");}catch(IOException e){}
		return output;
	}
	public static void main(String[] args)
	{
		IMP a = new IMP();
		System.out.println(a.Do("烧结厂.txt"));
		if(args.length>0)
			a.Do(args[0]);
	}
}

⌨️ 快捷键说明

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