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

📄 mgrmanagerimpl.java

📁 完整应用.简单工作流程.适用于有一定JAVA开发经验的程序员.想进一步提高JAVA三剑客的读者
💻 JAVA
字号:
package org.yeeku.service;

import org.yeeku.dao.*;
import org.yeeku.model.*;
import org.yeeku.business.*;
import org.yeeku.exception.*;

import java.text.*;
import java.util.*;



/**
 * @author  yeeku.H.lee kongyeeku@163.com
 * @version  1.0
 * <br>Copyright (C), 2005-2008, yeeku.H.Lee
 * <br>This program is protected by copyright laws.
 * <br>Program Name:
 * <br>Date: 
 */
public class MgrManagerImpl implements MgrManager
{
    private ApplicationDao appDao;
    private AttendDao attendDao;
    private AttendTypeDao typeDao;
    private CheckBackDao checkDao;
    private EmployeeDao empDao;
    private ManagerDao mgrDao;
    private PaymentDao payDao;
    private SimpleDateFormat sdf = new  SimpleDateFormat("yyyy-MM");


    public void setAppDao(ApplicationDao appDao)
    {
        this.appDao = appDao;
    }

    public void setAttendDao(AttendDao attendDao)
    {
        this.attendDao = attendDao;
    }

    public void setTypeDao(AttendTypeDao typeDao)
    {
        this.typeDao = typeDao;
    }

    public void setCheckDao(CheckBackDao checkDao)
    {
        this.checkDao = checkDao;
    }
    
    public void setEmpDao(EmployeeDao empDao)
    {
        this.empDao = empDao;
    }

    public void setMgrDao(ManagerDao mgrDao)
    {
        this.mgrDao = mgrDao;
    }

    public void setPayDao(PaymentDao payDao)
    {
        this.payDao = payDao;
    }

    /**
      * 新增员工
      * @param user 新增的员工名
      * @param pass 员工的初始密码
      * @param salary 员工的薪水
      */
    public void addEmp(String user , String pass , double salary , String mgr)throws HrException
    {
        Employee emp = new Employee();
        emp.setName(user);
        emp.setPass(pass);
        emp.setSalary(salary);
        Manager m = mgrDao.findByName(mgr);
        if (m == null)
        {
            throw new HrException("新增员工的业务异常");
        }
        emp.setManager(m);
        empDao.save(emp);
    }

    /**
      * 根据经理返回所有的部门上个月工资
      * @param mgr 新增的员工名
      * @return 部门上个月工资
      */
    public List<SalaryBean> getSalaryByMgr(String mgr)throws HrException
    {
        Manager m = mgrDao.findByName(mgr);
        if (m == null)
        {
            throw new HrException("查看部门工资异常");
        }
        List<Employee> emps = empDao.findByMgr(m);

        if (emps == null || emps.size() < 1)
        {
            throw new HrException("您的部门没有员工");
        }

        Calendar c = Calendar.getInstance();
        c.add(Calendar.MONTH , -1);
        String payMonth = sdf.format(c.getTime());

        List<SalaryBean> result = new ArrayList<SalaryBean>();        
        for (Employee e : emps)
        {
            Payment p = payDao.findByMonthAndEmp(payMonth , e);
            if (p != null)
            {
                result.add(new SalaryBean(e.getName() , p.getAmount()));
            }
        }
        return result;

    }

    /**
      * 根据经理返回该部门的全部员工
      * @param mgr 经理名
      * @return 经理的全部下属
      */
    public List<EmpBean> getEmpsByMgr(String mgr)throws HrException
    {
        Manager m = mgrDao.findByName(mgr);
        if (m == null)
        {
            throw new HrException("查看部门工资异常");
        }
        List<Employee> emps = empDao.findByMgr(m);
        if (emps == null || emps.size() < 1)
        {
            throw new HrException("您的部门没有员工");
        }
        List<EmpBean> result = new ArrayList<EmpBean>();        
        for (Employee e : emps)
        {
            result.add(new EmpBean(e.getName() , e.getPass() , e.getSalary()));
        }
        return result;
    }

    /**
      * 根据经理返回该部门的没有批复的申请
      * @param mgr 经理名
      * @return 该部门的全部申请
      */
    public List<AppBean> getAppsByMgr(String mgr)throws HrException
    {
        Manager m = mgrDao.findByName(mgr);
        if (m == null)
        {
            throw new HrException("查看部门工资异常");
        }
        List<Employee> emps = empDao.findByMgr(m);
        if (emps == null || emps.size() < 1)
        {
            throw new HrException("您的部门没有员工");
        }
        List<AppBean> result = new ArrayList<AppBean>();        
        for (Employee e : emps)
        {
            List<Application> apps = appDao.findByEmp(e);
            if (apps != null && apps.size() > 0)
            {
                for (Application app : apps)
                {
                    if (app.getResult() == false)
                    {
                        Attend attend = app.getAttend();
                        result.add(new AppBean(app.getId() , e.getName(), attend.getType().getName(), app.getType().getName(), app.getReason()));
                    }
                }
            }
        }
        return result;
    }

    /**
      * 处理申请
      * @param appid 申请ID
      * @param mgrName 经理名字
      * @param result 是否通过
      */
    public void check(int appid, String mgrName, boolean result)
    {
        Manager mgr = mgrDao.findByName(mgrName);
        Application app = appDao.get(appid);
        CheckBack check = new CheckBack();
        check.setApp(app);
        if (result)
        {
            check.setResult(true);
            //修改申请为已经批复
            app.setResult(true);
            appDao.save(app);
            //为真时,还需要修改出勤的类型
            Attend attend = app.getAttend();
            attend.setType(app.getType());
            attendDao.update(attend);

        }
        else
        {
            check.setResult(false);
            app.setResult(true);
            appDao.save(app);
        }
    }
}

⌨️ 快捷键说明

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