package net.dbnet.service;
import net.dbnet.dao.*;
import net.dbnet.model.*;
import net.dbnet.business.*;
import java.io.UnsupportedEncodingException;
import java.text.*;
import java.util.*;
/**
* @author
* @version 1.0 <br>
* Copyright (C), 2005-2008 <br>
* This program is protected by copyright laws. <br>
* Program Name: <br>
* Date:
*/
public class EmpManagerImpl implements EmpManager {
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
* 登陆用的密码
* @return 登陆后的身份确认:0为登陆失败,1为登陆emp 2为登陆mgr
*/
public int validLogin(String user, String pass) {
if (mgrDao.findByNameAndPass(user, pass).size() >= 1) {
return LOGIN_MGR;
} else if (empDao.findByNameAndPass(user, pass).size() >= 1) {
return LOGIN_EMP;
} else {
return LOGIN_FAIL;
}
}
/**
* 自动打卡,周一到周五,早上7:00为每个员工插入旷工记录
*/
public void autoPunch() {
System.out.println("自动插入旷工记录");
List<Employee> emps = empDao.findAll();
String dutyDay = new java.sql.Date(System.currentTimeMillis())
.toString();
for (Employee e : emps) {
AttendType atype = typeDao.get(6);
Attend a = new Attend();
a.setDutyDay(dutyDay);
a.setType(atype);
if (Calendar.AM == 0) {
a.setIsCome(true);
}else{
a.setIsCome(false);
}
a.setEmployee(e);
attendDao.save(a);
}
}
/**
* 自动工资结算
*/
public void autoPay() {
System.out.println("自动插入工资结算");
List<Employee> emps = empDao.findAll();
// 获取上个月时间
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_MONTH, -15);
String payMonth = sdf.format(c.getTime());
for (Employee e : emps) {
Payment pay = new Payment();
List<Attend> attends = attendDao.findByEmp(e);
double amount = e.getSalary();
for (Attend a : attends) {
amount += a.getType().getAmerce();
}
pay.setPayMonth(payMonth);
pay.setEmployee(e);
pay.setAmount(amount);
payDao.save(pay);
}
}
/**
* 验证某个员工是否可打卡
*
* @param user
* 员工名
* @param dutyDay
* 日期
* @return 可打卡的类别
*/
public int validPunch(String user, String dutyDay) {
// 不能查找到对应用户,返回无法打卡
Employee emp = empDao.findByName(user);
if (emp == null) {
return NO_PUNCH;
}
List<Attend> attends = attendDao.findByEmpAndDutyDay(emp, dutyDay);
// 系统没有为用户在当天插入空打卡记录,无法打卡
if (attends == null) {
return NO_PUNCH;
}
// 可以上班、下班打卡
if (attends.size() <= 0) {
return NO_PUNCH;
} else if (attends.size() == 1 && attends.get(0).getIsCome()
&& attends.get(0).getPunchTime() == null) {
return COME_PUNCH;
} else if (attends.size() == 1 && attends.get(0).getPunchTime() == null) {
return LEAVE_PUNCH;
} else if (attends.size() == 2) {
if (attends.get(0).getPunchTime() == null
&& attends.get(1).getPunchTime() == null) {
return BOTH_PUNCH;
} else if (attends.get(1).getPunchTime() == null) {
return LEAVE_PUNCH;
} else {
return NO_PUNCH;
}
}
return NO_PUNCH;
}
/**
* 打卡
*
* @param user
* 员工名
* @param dutyDay
* 打卡日期
* @param isCome
* 是否是上班打卡
* @return 打卡结果
*/
public int punch(String user, String dutyDay, boolean isCome) {
Employee emp = empDao.findByName(user);
if (emp == null) {
return PUNCH_FAIL;
}
Attend attend = attendDao.findByEmpAndDutyDayAndCome(emp, dutyDay,
isCome);
if (attend == null) {
return PUNCH_FAIL;
}
if (attend.getPunchTime() != null) {
return PUNCHED;
}
int punchHour = Calendar.HOUR_OF_DAY;
attend.setPunchTime(new Date());
// 上班打卡
if (isCome) {
// 9 点之前算正常
if (punchHour < 9) {
attend.setType(typeDao.get(1));
}
// 9~11 点之间算迟到
else if (punchHour < 11) {
attend.setType(typeDao.get(4));
}
// 11点之后算旷工
}
// 下班打卡
else {
// 6 点之后算正常
if (punchHour > 6) {
attend.setType(typeDao.get(1));
}
// 4~6 点之间算早退
else if (punchHour < 4) {
attend.setType(typeDao.get(5));
}
}
attendDao.update(attend);
return PUNCH_SUCC;
}
/**
* 根据员工浏览自己的工资
*
* @param empName
* 员工名
* @return 该员工的工资列表
*/
public List<PaymentBean> empSalary(String empName) {
Employee emp = empDao.findByName(empName);
List<Payment> pays = payDao.findByEmp(emp);
List<PaymentBean> result = new ArrayList<PaymentBean>();
for (Payment p : pays) {
result.add(new PaymentBean(p.getPayMonth(), p.getAmount()));
}
return result;
}
/**
* 员工查看自己的最近三天非正常打卡
*
* @param empName
* 员工名
* @return 该员工的最近三天的非正常打卡
* @throws UnsupportedEncodingException
*/
public List<AttendBean> unAttend(String empName) {
AttendType type = typeDao.get(1);
Employee emp = empDao.findByName(empName);
List<Attend> attends = attendDao.findByEmpUnAttend(emp, type);
List<AttendBean> result = new ArrayList<AttendBean>();
for (Attend att : attends) {
result.add(new AttendBean(att.getId(), att.getDutyDay(), att
.getType().getName(), att.getPunchTime()));
}
return result;
}
/**
* 返回全部的出勤类别
*
* @return 全部的出勤类别
*/
public List<AttendType> getAllType() {
return typeDao.findAll();
}
/**
* 添加申请
*
* @param attId
* 申请的出勤ID
* @param typeId
* 申请的类型ID
* @param reason
* 申请的理由
* @return 添加的结果
*/
public boolean addApplication(int attId, int typeId, String reason) {
try {
Application app = new Application();
Attend attend = attendDao.get(attId);
AttendType type = typeDao.get(typeId);
app.setAttend(attend);
app.setType(type);
if (reason != null) {
app.setReason(reason);
}
appDao.save(app);
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Java EE hr系统,人力资源管理系统
共223个文件
java:61个
class:61个
jar:26个
4星 · 超过85%的资源 需积分: 10 469 下载量 7 浏览量
2009-03-13
13:55:09
上传
评论 6
收藏 10.53MB RAR 举报
温馨提示
Java EE ,课程设计,人力资源管理系统,毕业设计Java EE ,课程设计,人力资源管理系统,毕业设计Java EE ,课程设计,人力资源管理系统,毕业设计
资源推荐
资源详情
资源评论
收起资源包目录
Java EE hr系统,人力资源管理系统 (223个子文件)
EmpManagerImpl.class 8KB
MgrManagerImpl.class 7KB
AttendDaoHibernate.class 4KB
AuthImg.class 4KB
Employee.class 3KB
index_jsp.class 3KB
EmployeeDaoHibernate.class 3KB
Attend.class 3KB
PaymentDaoHibernate.class 3KB
ManagerDaoTest.class 3KB
ApplicationDaoHibernate.class 3KB
Application.class 3KB
ManagerDaoHibernate.class 3KB
AttendDaoTest.class 2KB
LoginAction.class 2KB
ProcessPunchAction.class 2KB
AddEmpAction.class 2KB
AttendTypeDaoTest.class 2KB
EmployeeDaoTest.class 2KB
CheckBack.class 2KB
Payment.class 2KB
ProcessAppAction.class 2KB
PunchAction.class 2KB
CheckAppAction.class 2KB
ApplicationDaoTest.class 2KB
CheckBackDaoTest.class 2KB
PaymentDaoTest.class 2KB
ViewDeptAction.class 2KB
ViewUnAttendAction.class 2KB
ViewSalaryAction.class 2KB
EmpAuthorityInterceptor.class 2KB
ViewAppAction.class 2KB
MgrAuthorityInterceptor.class 2KB
Manager.class 2KB
AppBean.class 2KB
AttendTypeDaoHibernate.class 2KB
CheckBackDaoHibernate.class 2KB
ViewEmpAction.class 2KB
EmpManagerTest.class 2KB
AttendBean.class 1KB
AppChangeAction.class 1KB
LogoutAction.class 1KB
EmpBean.class 1KB
AttendType.class 1KB
PunchJob.class 1KB
PayJob.class 1KB
AttendDao.class 1KB
EmpManager.class 1KB
PaymentBean.class 987B
SalaryBean.class 981B
MyActionServlet.class 834B
EmployeeDao.class 799B
MgrManager.class 685B
PaymentDao.class 649B
ManagerDao.class 644B
ApplicationDao.class 571B
MgrBaseAction.class 501B
EmpBaseAction.class 501B
HrException.class 450B
AttendTypeDao.class 413B
CheckBackDao.class 408B
.classpath 2KB
css.css 674B
struts.gif 5KB
spring.gif 4KB
bg1.gif 104B
bg2.gif 104B
spring.jar 1.84MB
hibernate3.jar 1.6MB
commons-collections.jar 546KB
struts.jar 537KB
antlr-2.7.5H3.jar 423KB
mysql-connector-java-3.1.10-bin.jar 409KB
c3p0-0.8.5.2.jar 391KB
antlr.jar 350KB
quartz-1.5.1.jar 345KB
cglib-nodep-2.1_3.jar 317KB
dom4j-1.6.1.jar 307KB
commons-beanutils.jar 184KB
commons-digester.jar 164KB
junit.jar 118KB
spring-hibernate3.jar 107KB
commons-validator.jar 82KB
spring-mock.jar 71KB
commons-discovery-0.2.jar 70KB
jakarta-oro.jar 64KB
pull-parser-2.1.10.jar 51KB
ehcache-1.1.jar 46KB
commons-logging.jar 37KB
commons-fileupload.jar 22KB
saaj.jar 19KB
jta.jar 9KB
aopalliance.jar 4KB
EmpManagerImpl.java 7KB
MgrManagerImpl.java 6KB
AttendDaoHibernate.java 4KB
AuthImg.java 3KB
EmployeeDaoHibernate.java 3KB
ProcessPunchAction.java 3KB
Employee.java 3KB
共 223 条
- 1
- 2
- 3
ccuwangjun
- 粉丝: 6
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页