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

📄 zpserviceimpl.java

📁 人力资源管理系统
💻 JAVA
字号:
package org.HumResManSys.service.impl;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.HumResManSys.dao.EmployeeDAO;
import org.HumResManSys.dao.YpinfoDAO;
import org.HumResManSys.factory.DAOFactory;
import org.HumResManSys.service.ZpService;
import org.HumResManSys.vo.Employee;
import org.HumResManSys.vo.Ypinfo;

public class ZpServiceImpl implements ZpService {
	private DAOFactory daoFactory;

	
	/**
	 * 管理员提交是否录取应聘者
	 */
	public boolean submitZpResult(Ypinfo yp,String state) {
		// TODO Auto-generated method stub
		try{
		  //得到YpinfoDAO	
			YpinfoDAO ypinfoDAO=daoFactory.getYpinfoDAO();
		  //查询应聘信息	
			Ypinfo ypinfo=yp;//;ypinfoDAO.queryOneYpinfoByCondition("y_name", yp.getY_name());
		  //更改应聘信息状态	
			ypinfo.setTab_state(state);
			ypinfoDAO.updateYpinfo(ypinfo);
		  //一定要关闭session	
			ypinfoDAO.closeSession();
		}catch(Exception e){
			System.out.print("ZpService error\n");
			e.printStackTrace();
			return false;
		}
		//如果上面的状态是"录取",那么就把该应聘者保存到员工记录里边
		if(state.equals("批准")){
			try{
				 //获取系统当前时间  格式:08-01-21
			    String time=new SimpleDateFormat("yy,MM,dd").format(new Date(System.currentTimeMillis()));
			    
			  //得到EmployeeDAO	
				EmployeeDAO employeeDAO=daoFactory.getEmployeeDAO();
				Employee emp=new Employee();
				emp.setEmp_name(yp.getY_name());
				emp.setPsw("123456");
                emp.setSex(yp.getY_sex());
                emp.setDept_name("待定");
                emp.setId_card(yp.getY_job());
                emp.setHire_date(time);
/*                emp.setId_card(yp.get);*/
				emp.setJob("员工"); 
				employeeDAO.createEmployee(emp);
			  //一定要关闭session	
				employeeDAO.closeSession();
			}catch(Exception e){
				System.out.print("ZpService create Employee error\n");
				e.printStackTrace();
				return false;
			}
		}
		return true;
	}
	
	
	/**
	 * 查询所有应聘信息
	 */
	public List<Ypinfo> queryAllYpinfo(){
		try{
			  //得到YpinfoDAO	
				YpinfoDAO ypinfoDAO=daoFactory.getYpinfoDAO();
			  //查询应聘信息	
				List<Ypinfo> list=ypinfoDAO.queryAllYpinfos();
			  //一定要关闭session	
				ypinfoDAO.closeSession();
				return list;
			}catch(Exception e){
				System.out.print("ZpService query List<Ypinfo> error\n");
				e.printStackTrace();
				return null;
			}
		
	}
	
	/**
	 * 查询应聘信息,分页查询
	 */
	public List<Ypinfo> queryYpinfoByPage(int firstResult,int maxResults){
		List list=null;
		try {
			list=daoFactory.getYpinfoDAO().queryYpinfosByPageOrderByCondition("y_name", firstResult, maxResults);
			daoFactory.getYpinfoDAO().closeSession();
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
	}
	
//	简单搜索
	public List<Ypinfo> advancedSearch(String key) {
		// TODO Auto-generated method stub
		  
		List<Ypinfo> results=new ArrayList();
		List<Ypinfo> temp=null;
		Ypinfo tempYpInfo=null;

		YpinfoDAO ypinfoDAO=null;
		try {
			//得到YpinfoDAO	
			ypinfoDAO=daoFactory.getYpinfoDAO();
			Ypinfo asParameter1=new Ypinfo();
			asParameter1.setY_name(key);//1
			temp=ypinfoDAO.queryYpinfosByEntityEnableLike(asParameter1);
			System.out.println("in advancedSearch temp results  :"+temp);
			if(temp!=null){
				//results.addAll(temp);
				for(int i=0;i<temp.size();i++){
					Ypinfo t=temp.get(i);
					System.out.println("in advancedSearch t results  :"+t);
					results.add(t);
					System.out.println("add ok");
				}
			}
			
			
			Ypinfo asParameter2=new Ypinfo();
			asParameter2.setY_school(key);//2
			temp=ypinfoDAO.queryYpinfosByEntityEnableLike(asParameter2);
			for(int i=0;i<temp.size();i++){
				tempYpInfo=temp.get(i);
				if(!results.contains(tempYpInfo)){
					results.add(tempYpInfo);
				}
			}
			
			Ypinfo asParameter3=new Ypinfo();
			asParameter3.setY_job(key);//3
			temp=ypinfoDAO.queryYpinfosByEntityEnableLike(asParameter3);
			for(int i=0;i<temp.size();i++){
				tempYpInfo=temp.get(i);
				if(!results.contains(tempYpInfo)){
					results.add(tempYpInfo);
				}
			}
			
			Ypinfo asParameter4=new Ypinfo();
			asParameter4.setY_xueli(key);//4
			temp=ypinfoDAO.queryYpinfosByEntityEnableLike(asParameter4);
			for(int i=0;i<temp.size();i++){
				tempYpInfo=temp.get(i);
				if(!results.contains(tempYpInfo)){
					results.add(tempYpInfo);
				}
			}
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.out.println("advanced search error.");
			ypinfoDAO.closeSession();
			return null;
		}
		
		ypinfoDAO.closeSession();
		return results;
	}


	//高级搜索,通过几个条件搜索匹配项
	public List<Ypinfo> advancedSearchByConditions(Ypinfo ypinfo) {
		// TODO Auto-generated method stub
		List<Ypinfo> results=null;
		YpinfoDAO ypinfoDAO=null;
		
		try {
			//得到YpinfoDAO	
			ypinfoDAO=daoFactory.getYpinfoDAO();
			results=ypinfoDAO.queryYpinfosByEntityEnableLike(ypinfo);
			ypinfoDAO.closeSession();
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.out.println("advanced search by several conditions error.");
			return null;
		}
		
		return results;
	}
	
	

	public DAOFactory getDaoFactory() {
		return daoFactory;
	}

	public void setDaoFactory(DAOFactory daoFactory) {
		this.daoFactory = daoFactory;
	}

}

⌨️ 快捷键说明

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