package org.crazyit.hrsystem.service.impl;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.crazyit.hrsystem.dao.ApplicationDao;
import org.crazyit.hrsystem.dao.AttendDao;
import org.crazyit.hrsystem.dao.AttendTypeDao;
import org.crazyit.hrsystem.dao.CheckBackDao;
import org.crazyit.hrsystem.dao.EmployeeDao;
import org.crazyit.hrsystem.dao.ManagerDao;
import org.crazyit.hrsystem.dao.PaymentDao;
import org.crazyit.hrsystem.domain.Application;
import org.crazyit.hrsystem.domain.Attend;
import org.crazyit.hrsystem.domain.AttendType;
import org.crazyit.hrsystem.domain.Employee;
import org.crazyit.hrsystem.domain.Manager;
import org.crazyit.hrsystem.domain.Payment;
import org.crazyit.hrsystem.service.EmpManager;
import org.crazyit.hrsystem.vo.AttendBean;
import org.crazyit.hrsystem.vo.PaymentBean;
/**
* Description:
* <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
* <br/>Copyright (C), 2001-2018, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee kongyeeku@163.com
* @version 1.0
*/
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;
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 mgr 登录的经理身份
* @return 登录后的身份确认:0为登录失败,1为登录emp 2为登录mgr
*/
public int validLogin(Manager mgr)
{
// 如果找到一个经理,以经理登录
if (mgrDao.findByNameAndPass(mgr).size() >= 1)
{
return LOGIN_MGR;
}
// 如果找到普通员工,以普通员工登录
else if (empDao.findByNameAndPass(mgr).size() >= 1)
{
return LOGIN_EMP;
}
else
{
return LOGIN_FAIL;
}
}
/**
* 自动打卡,周一到周五,早上7:00为每个员工插入旷工记录
*/
public void autoPunch()
{
System.out.println("自动插入旷工记录");
List<Employee> emps = empDao.findAll(Employee.class);
// 获取当前时间
String dutyDay = new java.sql.Date(
System.currentTimeMillis()).toString();
for (Employee e : emps)
{
// 获取旷工对应的出勤类型
AttendType atype = typeDao.get(AttendType.class , 6);
Attend a = new Attend();
a.setDutyDay(dutyDay);
a.setType(atype);
// 如果当前时间是是早上,对应于上班打卡
if (Calendar.getInstance()
.get(Calendar.HOUR_OF_DAY) < AM_LIMIT)
{
// 上班打卡
a.setIsCome(true);
}
else
{
// 下班打卡
a.setIsCome(false);
}
a.setEmployee(e);
attendDao.save(a);
}
}
/**
* 自动结算工资,每月1号,结算上个月工资
*/
public void autoPay()
{
System.out.println("自动插入工资结算");
List<Employee> emps = empDao.findAll(Employee.class);
// 获取上个月时间
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_MONTH, -15);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
String payMonth = sdf.format(c.getTime());
// 为每个员工计算上个月工资
for (Employee e : emps)
{
Payment pay = new Payment();
// 获取该员工的工资
double amount = e.getSalary();
// 获取该员工上个月的出勤记录
List<Attend> attends = attendDao.findByEmpAndMonth(e , payMonth);
// 用工资累积其出勤记录的工资
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 || 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;
}
System.out.println("============打卡==========");
// 获取打卡时间
int punchHour = Calendar.getInstance()
.get(Calendar.HOUR_OF_DAY);
attend.setPunchTime(new Date());
// 上班打卡
if (isCome)
{
// 9点之前算正常
if (punchHour < COME_LIMIT)
{
attend.setType(typeDao.get(AttendType.class , 1));
}
// 9~11点之间算迟到
else if (punchHour < LATE_LIMIT)
{
attend.setType(typeDao.get(AttendType.class , 4));
}
// 11点之后算旷工,无需理会
}
// 下班打卡
else
{
// 18点之后算正常
if (punchHour >= LEAVE_LIMIT)
{
attend.setType(typeDao.get(AttendType.class , 1));
}
// 16~18点之间算早退
else if (punchHour >= EARLY_LIMIT)
{
attend.setType(typeDao.get(AttendType.class , 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>();
// 封装VO集合
for (Payment p : pays )
{
result.add(new PaymentBean(p.getPayMonth()
,p.getAmount()));
}
return result;
}
/**
* 员工查看自己的最近三天非正常打卡
* @param empName 员工名
* @return 该员工的最近三天的非正常打卡
*/
public List<AttendBean> unAttend(String empName)
{
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
《轻量级JavaEE企业应用实战》配套资源第五版 (3564个子文件)
taskHistory.bin 30KB
fileHashes.bin 20KB
resourceHashesCache.bin 19KB
annotation-processors.bin 18KB
outputFiles.bin 18KB
last-build.bin 1B
CriteriaQueryTest.class 11KB
EmpManagerImpl.class 10KB
EmpManagerImpl.class 10KB
MgrManagerImpl.class 8KB
MgrManagerImpl.class 8KB
NativeSQLTest.class 6KB
JoinQueryTest.class 6KB
ProjectionTest.class 6KB
GroupByTest.class 5KB
BaseDaoJpa.class 5KB
BaseDaoJpa.class 5KB
BaseDaoHibernate5.class 5KB
BaseDaoHibernate5.class 5KB
BaseDaoJpa.class 5KB
BaseDaoHibernate5.class 5KB
BaseDaoHibernate5.class 5KB
CrazyitXmlApplicationContext.class 5KB
Employee.class 5KB
Employee.class 5KB
AuthImg.class 4KB
CriteriaTest.class 4KB
QueryTag.class 4KB
ChatEntpoint.class 4KB
AuthImg.class 4KB
BaseDaoHibernate3.class 4KB
BaseDaoHibernate3.class 4KB
Product.class 4KB
FourAdviceTest.class 4KB
JpqlQuery.class 4KB
BaseDaoHibernate3.class 4KB
BaseDaoHibernate3.class 4KB
NewsManager.class 4KB
NativeSQLTest.class 4KB
SpELTest.class 4KB
Attend.class 4KB
Attend.class 4KB
FourAdviceTest.class 4KB
HqlQuery.class 4KB
UploadAction.class 4KB
NamedSQLTest.class 4KB
TxAspect.class 3KB
TxAspect.class 3KB
AspectJTest.class 3KB
AspectJTest.class 3KB
TestServlet.class 3KB
LogAspect.class 3KB
LogAspect.class 3KB
Category.class 3KB
UploadServlet.class 3KB
DbDao.class 3KB
AttendDaoHibernate5.class 3KB
Application.class 3KB
Application.class 3KB
MyInterceptor.class 3KB
AttendDaoHibernate5.class 3KB
DbDao.class 3KB
HqlQuery.class 3KB
TxAspect.class 3KB
AuthAspect.class 3KB
ProductManager.class 3KB
Student.class 3KB
AuthAspect.class 3KB
LoginServlet.class 3KB
Person.class 3KB
RequestListener.class 3KB
UploadAction.class 3KB
UploadAction.class 3KB
CheckBack.class 3KB
CheckBack.class 3KB
PersonManager.class 3KB
PersonManager.class 3KB
PersonManager.class 3KB
DetachedCriteriaTest.class 3KB
Person.class 3KB
Person.class 3KB
AuthorityFilter.class 3KB
BaseDaoHibernate3$2.class 3KB
Person.class 3KB
BaseDaoHibernate3$2.class 3KB
NewsManager.class 3KB
UserManager.class 3KB
ProcessPunchAction.class 3KB
BookAction.class 3KB
LoginRegistAction.class 3KB
RequestListener.class 3KB
Manager.class 3KB
Manager.class 3KB
GetConnListener.class 2KB
OnlineListener$1.class 2KB
LoginAction.class 2KB
LogAspect.class 2KB
RegistAction.class 2KB
HibernateUtil.class 2KB
LoginAction.class 2KB
共 3564 条
- 1
- 2
- 3
- 4
- 5
- 6
- 36
资源评论
- laiyangli0012019-09-23谢谢分享,正需要
- fqrfans2019-09-20学习了,寻找好久了,谢谢
- fjbqy2019-03-07资源很好啊,,遗憾的没有jar包
- qq_164397372018-07-16我以为是书的pdf
- Dustone972018-07-10你是真的坑 把JAR去掉传上来怎么处理依赖关系 这些又不是Maven项目 鬼知道是什么版本的JAR包LYXG0072018-07-16到这里下载jar包信息,链接:https://pan.baidu.com/s/1UfVT54jE3pyWkZDJ0mamCg 密码:3ueu
LYXG007
- 粉丝: 1
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功