packagecom.ts017.zjh;importjava.text.NumberFormat;importjava.util.Iterator;importjava.util.List;importjava.util.Map;importjava.util.Scanner;importcom.ts017.zjh.dao.IDeptDAO;importcom.ts017.zjh.dao.IEmpDAO;importcom.ts017.zjh.dao.factory.DAOFactory;importcom.ts017.zjh.vo.Department;importcom.ts017.zjh.vo.Employee;publicclassDepartmentOperate{privateIDeptDAOdao=null;Scannerscn=null;publicDepartmentOperate(){this.dao=DAOFactory.getIDemptDAOInstance();scn=newScanner(System.in);}publicvoidaddDepartment(){System.out.println();System.out.println("添加部门信息");System.out.println("=================================");System.out.print("请输入部门名称:");StringdeptName=scn.next();DepartmentrepeatDept=getDepartmentByName(deptName);if(repeatDept!=null){System.out.println("您输入的部门名已存在");return;}Departmentdept=newDepartment();dept.setDeptName(deptName);booleanflag=false;try{flag=this.dao.doCreate(dept);}catch(Exceptione){e.printStackTrace();}if(flag){System.out.println("添加部门成功");}else{System.out.println("添加部门失败");}}publicvoiddelDepartment(){System.out.println();System.out.print("请输入要删除的部门编号:");intdeptId=scn.nextInt();Departmentdept=getDepartmentById(deptId);if(dept==null){System.out.println("您输入的部门不存在");return;}IEmpDAOempDAO=DAOFactory.getIEmpDAOInstance();Listemps=null;try{emps=empDAO.findByDeptId(deptId);}catch(Exceptione){e.printStackTrace();}if(emps!=null){this.showDepartment(dept);if(emps.size()>0){System.out.println("该部门中有员工存在,若删除该部门,则相应的员工也会被删除,确定要删除吗(y/n)?");Stringopt=scn.next();if(opt.equalsIgnoreCase("y")){booleanflag=false;try{empDAO.doDeleteByDeptId(deptId);flag=this.dao.doDelete(deptId);}catch(Exceptione){e.printStackTrace();}if(flag){System.out.println("删除部门成功");}else{System.out.println("删除部门失败");}}}else{System.out.println("确定要删除该部门信息吗(y/n)?");Stringopt=scn.next();if(opt.equalsIgnoreCase("y")){booleanflag=false;try{flag=this.dao.doDelete(deptId);}catch(Exceptione){e.printStackTrace();}if(flag){System.out.println("删除部门成功");}else{System.out.println("删除部门失败");}}}}}publicvoidfindAll(){Listdepts=null;try{depts=this.dao.findAll();}catch(Exceptione){e.printStackTrace();}if(depts!=null&&depts.size()!=0){this.showDepartment(depts);}else{System.out.println("没有部门信息");}}publicvoidfindDepartment(){intopt;do{this.showFindMenu();opt=scn.nextInt();switch(opt){case1:this.findByDeptId();break;case2:this.findByDeptname();break;case0:return;}}while(opt!=0);}publicvoidfindByDeptname(){System.out.println();System.out.print("请输入查找的部门名称:");StringdeptName=scn.next();Departmentdept=getDepartmentByName(deptName);if(dept!=null){this.showDepartment(dept);}else{System.out.println("相关信息不存在");}}publicvoidfindByDeptId(){System.out.println();System.out.print("请输入要查找的部门号:");intdeptId=scn.nextInt();Departmentdept=getDepartmentById(deptId);if(dept!=null){this.showDepartment(dept);}else{System.out.println("相关信息不存在");}}publicvoidupdateDepartment(){System.out.println();System.out.print("请输入要更新的部门编号:");intdeptId=scn.nextInt();Departmentdept=getDepartmentById(deptId);if(dept==null){System.out.println("您输入的部门不存在");return;}this.showDepartment(dept);System.out.println("更新部门信息");System.out.println("=====================...