Commit 56770109 authored by 赵啸非's avatar 赵啸非

添加假日考勤计算

parent 69ba9ebd
package com.mortals.xhx.daemon.task; package com.mortals.xhx.daemon.task;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.PageUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.service.ITask; import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService; import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.base.system.user.model.UserEntity; import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.common.code.SourceType;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.attendance.model.*; import com.mortals.xhx.module.attendance.model.*;
import com.mortals.xhx.module.attendance.service.AttendanceGroupFixedworkService; import com.mortals.xhx.module.attendance.service.AttendanceGroupFixedworkService;
import com.mortals.xhx.module.attendance.service.AttendanceGroupService;
import com.mortals.xhx.module.attendance.service.AttendanceGroupStaffService; import com.mortals.xhx.module.attendance.service.AttendanceGroupStaffService;
import com.mortals.xhx.module.attendance.service.AttendanceRecordHikService; import com.mortals.xhx.module.attendance.service.AttendanceRecordHikService;
import com.mortals.xhx.module.hik.door.model.req.door.DoorEventReq; import com.mortals.xhx.module.holiday.model.HolidayEntity;
import com.mortals.xhx.module.hik.door.model.rsp.door.DoorEventDataInfo; import com.mortals.xhx.module.holiday.model.HolidayQuery;
import com.mortals.xhx.module.hik.door.service.IHikDoorService; import com.mortals.xhx.module.holiday.service.HolidayService;
import com.mortals.xhx.module.staff.model.StaffEntity; import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.model.StaffQuery;
import com.mortals.xhx.module.staff.service.StaffService; import com.mortals.xhx.module.staff.service.StaffService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -47,6 +39,8 @@ public class CalculateDayAttendTaskImpl implements ITaskExcuteService { ...@@ -47,6 +39,8 @@ public class CalculateDayAttendTaskImpl implements ITaskExcuteService {
private AttendanceGroupStaffService attendanceGroupStaffService; private AttendanceGroupStaffService attendanceGroupStaffService;
@Autowired @Autowired
private AttendanceGroupFixedworkService groupFixedworkService; private AttendanceGroupFixedworkService groupFixedworkService;
@Autowired
private HolidayService holidayService;
@Override @Override
...@@ -67,10 +61,23 @@ public class CalculateDayAttendTaskImpl implements ITaskExcuteService { ...@@ -67,10 +61,23 @@ public class CalculateDayAttendTaskImpl implements ITaskExcuteService {
String week = this.getWeek(new Date()); String week = this.getWeek(new Date());
Long weekClassId = this.getWeekClassId(attendanceGroupFixedworkEntity, week); Long weekClassId = this.getWeekClassId(attendanceGroupFixedworkEntity, week);
//weekClassId为-1 则不在考勤 //weekClassId为-1 则不在考勤
//对于节假日 分两种情况。
// 1.当前是工作日,但是是节假日。则不做考勤continue;
// 2.当前是非工作日,但是由于节假日情况,需要补班,需要做考勤
//weekClassId == -1L 当日不需要考勤的 与节假日冲突的 以节假日为准
Boolean checkWorkByHoliday = checkWorkByHoliday();
Boolean checkHolidayByWorkDay = checkHolidayByWorkDay();
if (weekClassId == -1L) { if (weekClassId == -1L) {
//跳过本次循环 //跳过本次循环
log.info("当前日期不在考勤时间范围内,不做处理!"); log.info("当前日期不在考勤时间范围内,不做处理!");
continue; if (!checkWorkByHoliday) {
continue;
}
} else {
if (checkHolidayByWorkDay) {
//本来当天是需要考勤的,但是是节假日,则不计算考勤
continue;
}
} }
List<AttendanceGroupStaffEntity> groupStaffList = item.getValue(); List<AttendanceGroupStaffEntity> groupStaffList = item.getValue();
...@@ -114,6 +121,39 @@ public class CalculateDayAttendTaskImpl implements ITaskExcuteService { ...@@ -114,6 +121,39 @@ public class CalculateDayAttendTaskImpl implements ITaskExcuteService {
calculateAttendByDay(); calculateAttendByDay();
} }
private Boolean checkWorkByHoliday() {
Boolean bool = false;
HolidayQuery holidayQuery = new HolidayQuery();
holidayQuery.setStartTimeStart(DateUtil.today());
holidayQuery.setStartTimeEnd(DateUtil.today());
HolidayEntity holidayEntity = holidayService.selectOne(holidayQuery);
if (!ObjectUtils.isEmpty(holidayEntity)) {
Integer workorholiday = holidayEntity.getWorkorholiday();
if (workorholiday == YesNoEnum.YES.getValue()) {
bool = true;
}
}
return bool;
}
private Boolean checkHolidayByWorkDay() {
Boolean bool = false;
HolidayQuery holidayQuery = new HolidayQuery();
holidayQuery.setStartTimeStart(DateUtil.today());
holidayQuery.setStartTimeEnd(DateUtil.today());
HolidayEntity holidayEntity = holidayService.selectOne(holidayQuery);
if (!ObjectUtils.isEmpty(holidayEntity)) {
Integer workorholiday = holidayEntity.getWorkorholiday();
if (workorholiday == YesNoEnum.NO.getValue()) {
bool = true;
}
}
return bool;
}
private void calculateAttendByDay() { private void calculateAttendByDay() {
Context context = new Context(); Context context = new Context();
UserEntity userEntity = new UserEntity(); UserEntity userEntity = new UserEntity();
......
...@@ -51,7 +51,6 @@ public class SyncDoorsEventAfterTaskImpl implements ITaskExcuteService { ...@@ -51,7 +51,6 @@ public class SyncDoorsEventAfterTaskImpl implements ITaskExcuteService {
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
// syncDoorEvents(); // syncDoorEvents();
//判断时间段 不在时间段的 不做计算 //判断时间段 不在时间段的 不做计算
//早上9点 子晚上8点 计算 //早上9点 子晚上8点 计算
Date beginDateTime=DateUtil.parseDateTime(DateUtil.today()+" 09:00:00"); Date beginDateTime=DateUtil.parseDateTime(DateUtil.today()+" 09:00:00");
......
...@@ -65,7 +65,6 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService { ...@@ -65,7 +65,6 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
} else { } else {
day = 0; day = 0;
} }
Date beginDateTime=DateUtil.parseDateTime(DateUtil.today()+" 08:00:00"); Date beginDateTime=DateUtil.parseDateTime(DateUtil.today()+" 08:00:00");
Date endDateTime=DateUtil.parseDateTime(DateUtil.today()+" 20:30:00"); Date endDateTime=DateUtil.parseDateTime(DateUtil.today()+" 20:30:00");
...@@ -73,28 +72,6 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService { ...@@ -73,28 +72,6 @@ public class SyncDoorsEventTaskImpl implements ITaskExcuteService {
if(in){ if(in){
syncDoorEvents(); syncDoorEvents();
} }
//calculateAttendByDay();
}
private void calculateAttendByDay() {
Context context = new Context();
UserEntity userEntity = new UserEntity();
userEntity.setCreateUserId(1L);
userEntity.setId(1L);
userEntity.setCreateUserName("admin");
userEntity.setCreateTime(new Date());
context.setUser(userEntity);
AttendanceRecordHikQuery recordHikEntity = new AttendanceRecordHikQuery();
// Date todayStart = DateUtil.offsetHour(new Date(), -5).toJdkDate();
// recordHikEntity.setAttendanceDateStart(DateUtils.getCurrStrDate());
recordHikEntity.setAttendanceDateStart(DateUtil.today());
recordHikEntity.setAttendanceDateEnd(DateUtil.today());
try {
recordHikService.addAttendanceRecordByQuery(recordHikEntity, context);
} catch (Exception e) {
log.error("计算考勤异常", e);
}
} }
private void syncDoorEvents() { private void syncDoorEvents() {
......
...@@ -4,10 +4,14 @@ import cn.hutool.core.date.DateUtil; ...@@ -4,10 +4,14 @@ import cn.hutool.core.date.DateUtil;
import com.mortals.xhx.common.code.GoWorkResultEnum; import com.mortals.xhx.common.code.GoWorkResultEnum;
import com.mortals.xhx.common.code.MustEnum; import com.mortals.xhx.common.code.MustEnum;
import com.mortals.xhx.common.code.TypeEnum; import com.mortals.xhx.common.code.TypeEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.attendance.model.*; import com.mortals.xhx.module.attendance.model.*;
import com.mortals.xhx.module.attendance.service.AttendanceClassService; import com.mortals.xhx.module.attendance.service.AttendanceClassService;
import com.mortals.xhx.module.attendance.service.AttendanceGroupFixedworkService; import com.mortals.xhx.module.attendance.service.AttendanceGroupFixedworkService;
import com.mortals.xhx.module.attendance.service.AttendanceGroupFixedworkSpecialService; import com.mortals.xhx.module.attendance.service.AttendanceGroupFixedworkSpecialService;
import com.mortals.xhx.module.holiday.model.HolidayEntity;
import com.mortals.xhx.module.holiday.model.HolidayQuery;
import com.mortals.xhx.module.holiday.service.HolidayService;
import com.mortals.xhx.utils.SpringUtils; import com.mortals.xhx.utils.SpringUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -33,13 +37,15 @@ public class FixWorkAttendance extends AttendanceWorkAbstract { ...@@ -33,13 +37,15 @@ public class FixWorkAttendance extends AttendanceWorkAbstract {
private AttendanceGroupFixedworkSpecialService specialService; private AttendanceGroupFixedworkSpecialService specialService;
private HolidayService holidayService;
public FixWorkAttendance(int type) { public FixWorkAttendance(int type) {
super(type); super(type);
this.attendanceGroupFixedworkService = SpringUtils.getBean(AttendanceGroupFixedworkService.class); this.attendanceGroupFixedworkService = SpringUtils.getBean(AttendanceGroupFixedworkService.class);
this.attendanceClassService = SpringUtils.getBean(AttendanceClassService.class); this.attendanceClassService = SpringUtils.getBean(AttendanceClassService.class);
this.specialService = SpringUtils.getBean(AttendanceGroupFixedworkSpecialService.class); this.specialService = SpringUtils.getBean(AttendanceGroupFixedworkSpecialService.class);
this.holidayService = SpringUtils.getBean(HolidayService.class);
} }
@Override @Override
...@@ -68,11 +74,27 @@ public class FixWorkAttendance extends AttendanceWorkAbstract { ...@@ -68,11 +74,27 @@ public class FixWorkAttendance extends AttendanceWorkAbstract {
Long weekClassId = this.getWeekClassId(attendanceGroupFixedworkEntity, week); Long weekClassId = this.getWeekClassId(attendanceGroupFixedworkEntity, week);
//log.info("weekClassId:{}", weekClassId); //log.info("weekClassId:{}", weekClassId);
//weekClassId为-1 则不在考勤 //weekClassId为-1 则不在考勤
Boolean checkWorkByHoliday = checkWorkByHoliday();
Boolean checkHolidayByWorkDay = checkHolidayByWorkDay();
if (weekClassId == -1L) { if (weekClassId == -1L) {
//跳过本次循环 //跳过本次循环
return; log.info("当前日期不在考勤时间范围内,不做处理!");
if (!checkWorkByHoliday) {
return;
}
} else {
if (checkHolidayByWorkDay) {
//本来当天是需要考勤的,但是是节假日,则不计算考勤
return;
}
} }
/* if (weekClassId == -1L) {
//跳过本次循环
return;
}*/
//特殊日期考勤配置 //特殊日期考勤配置
List<AttendanceGroupFixedworkSpecialEntity> specialEntities = specialService.find(new AttendanceGroupFixedworkSpecialQuery().fixedWorkId(attendanceGroupFixedworkEntity.getId())); List<AttendanceGroupFixedworkSpecialEntity> specialEntities = specialService.find(new AttendanceGroupFixedworkSpecialQuery().fixedWorkId(attendanceGroupFixedworkEntity.getId()));
...@@ -218,7 +240,37 @@ public class FixWorkAttendance extends AttendanceWorkAbstract { ...@@ -218,7 +240,37 @@ public class FixWorkAttendance extends AttendanceWorkAbstract {
} }
} }
} }
}
private Boolean checkWorkByHoliday() {
Boolean bool = false;
HolidayQuery holidayQuery = new HolidayQuery();
holidayQuery.setStartTimeStart(DateUtil.today());
holidayQuery.setStartTimeEnd(DateUtil.today());
HolidayEntity holidayEntity = holidayService.selectOne(holidayQuery);
if (!ObjectUtils.isEmpty(holidayEntity)) {
Integer workorholiday = holidayEntity.getWorkorholiday();
if (workorholiday == YesNoEnum.YES.getValue()) {
bool = true;
}
}
return bool;
}
private Boolean checkHolidayByWorkDay() {
Boolean bool = false;
HolidayQuery holidayQuery = new HolidayQuery();
holidayQuery.setStartTimeStart(DateUtil.today());
holidayQuery.setStartTimeEnd(DateUtil.today());
HolidayEntity holidayEntity = holidayService.selectOne(holidayQuery);
if (!ObjectUtils.isEmpty(holidayEntity)) {
Integer workorholiday = holidayEntity.getWorkorholiday();
if (workorholiday == YesNoEnum.NO.getValue()) {
bool = true;
}
}
return bool;
} }
} }
...@@ -6,9 +6,13 @@ import com.mortals.framework.model.OrderCol; ...@@ -6,9 +6,13 @@ import com.mortals.framework.model.OrderCol;
import com.mortals.xhx.common.code.*; import com.mortals.xhx.common.code.*;
import com.mortals.xhx.module.attendance.model.*; import com.mortals.xhx.module.attendance.model.*;
import com.mortals.xhx.module.attendance.service.*; import com.mortals.xhx.module.attendance.service.*;
import com.mortals.xhx.module.holiday.model.HolidayEntity;
import com.mortals.xhx.module.holiday.model.HolidayQuery;
import com.mortals.xhx.module.holiday.service.HolidayService;
import com.mortals.xhx.utils.SpringUtils; import com.mortals.xhx.utils.SpringUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.*; import java.util.*;
...@@ -38,6 +42,8 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract { ...@@ -38,6 +42,8 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
private AttendanceRecordErrorService errorService; private AttendanceRecordErrorService errorService;
private HolidayService holidayService;
public FixWorkOtherAttendance(int type) { public FixWorkOtherAttendance(int type) {
super(type); super(type);
...@@ -48,6 +54,7 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract { ...@@ -48,6 +54,7 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
this.recordHikService = SpringUtils.getBean(AttendanceRecordHikService.class); this.recordHikService = SpringUtils.getBean(AttendanceRecordHikService.class);
this.attendanceClassDetailService = SpringUtils.getBean(AttendanceClassDetailService.class); this.attendanceClassDetailService = SpringUtils.getBean(AttendanceClassDetailService.class);
this.errorService = SpringUtils.getBean(AttendanceRecordErrorService.class); this.errorService = SpringUtils.getBean(AttendanceRecordErrorService.class);
this.holidayService = SpringUtils.getBean(HolidayService.class);
} }
@Override @Override
...@@ -77,10 +84,25 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract { ...@@ -77,10 +84,25 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
Long weekClassId = this.getWeekClassId(attendanceGroupFixedworkEntity, week); Long weekClassId = this.getWeekClassId(attendanceGroupFixedworkEntity, week);
//log.info("weekClassId:{}", weekClassId); //log.info("weekClassId:{}", weekClassId);
//weekClassId为-1 则不在考勤 //weekClassId为-1 则不在考勤
Boolean checkWorkByHoliday = checkWorkByHoliday();
Boolean checkHolidayByWorkDay = checkHolidayByWorkDay();
if (weekClassId == -1L) { if (weekClassId == -1L) {
//跳过本次循环 //跳过本次循环
return; log.info("当前日期不在考勤时间范围内,不做处理!");
if (!checkWorkByHoliday) {
return;
}
} else {
if (checkHolidayByWorkDay) {
//本来当天是需要考勤的,但是是节假日,则不计算考勤
return;
}
} }
/* if (weekClassId == -1L) {
//跳过本次循环
return;
}*/
//特殊日期考勤配置 //特殊日期考勤配置
List<AttendanceGroupFixedworkSpecialEntity> specialEntities = specialService.find(new AttendanceGroupFixedworkSpecialQuery().fixedWorkId(attendanceGroupFixedworkEntity.getId())); List<AttendanceGroupFixedworkSpecialEntity> specialEntities = specialService.find(new AttendanceGroupFixedworkSpecialQuery().fixedWorkId(attendanceGroupFixedworkEntity.getId()));
...@@ -383,4 +405,37 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract { ...@@ -383,4 +405,37 @@ public class FixWorkOtherAttendance extends AttendanceWorkAbstract {
//删除异常记录 //删除异常记录
} }
} }
private Boolean checkWorkByHoliday() {
Boolean bool = false;
HolidayQuery holidayQuery = new HolidayQuery();
holidayQuery.setStartTimeStart(DateUtil.today());
holidayQuery.setStartTimeEnd(DateUtil.today());
HolidayEntity holidayEntity = holidayService.selectOne(holidayQuery);
if (!ObjectUtils.isEmpty(holidayEntity)) {
Integer workorholiday = holidayEntity.getWorkorholiday();
if (workorholiday == YesNoEnum.YES.getValue()) {
bool = true;
}
}
return bool;
}
private Boolean checkHolidayByWorkDay() {
Boolean bool = false;
HolidayQuery holidayQuery = new HolidayQuery();
holidayQuery.setStartTimeStart(DateUtil.today());
holidayQuery.setStartTimeEnd(DateUtil.today());
HolidayEntity holidayEntity = holidayService.selectOne(holidayQuery);
if (!ObjectUtils.isEmpty(holidayEntity)) {
Integer workorholiday = holidayEntity.getWorkorholiday();
if (workorholiday == YesNoEnum.NO.getValue()) {
bool = true;
}
}
return bool;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment