|
|
|
@@ -143,6 +143,64 @@ public class DmStaffServiceImpl extends BaseServiceImpl<DmStaffQuery, DmStaffDto |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public DmEmpAttendancePo judgeAttendanceDescStatus(DmEmpAttendancePo po, Date checkDate){ |
|
|
|
SysDeptExt ext = sysDeptExtMapper.selectWorkTimeByDeptId(po.getDeptId()); |
|
|
|
if (null == po) { |
|
|
|
DmEmpAttendancePo ea = new DmEmpAttendancePo(); |
|
|
|
ea.setCheckInTime(checkDate); |
|
|
|
DmHolidayPo holidayPo = holidayService.isHoliday(checkDate); |
|
|
|
if (MyDateUtils.formatDate(checkDate, MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(ext.getOnDutyHourEnd()) > 0) {//识别时间比考勤上班打卡最晚时间更晚 |
|
|
|
ea.setDescStatus(ATTENDANCE_STATUS_BE_LATER); // 迟到 |
|
|
|
if (holidayPo.getHoliday() == 1) { |
|
|
|
ea.setDescStatus(ATTENDANCE_STATUS_OVERTIME); |
|
|
|
} |
|
|
|
} else {//识别时间比考勤上班打卡最晚时间早 |
|
|
|
if (holidayPo.getHoliday() == 1) { |
|
|
|
ea.setDescStatus(ATTENDANCE_STATUS_OVERTIME); |
|
|
|
} |
|
|
|
} |
|
|
|
return ea; |
|
|
|
} |
|
|
|
DmHolidayPo holidayPo = holidayService.isHoliday(po.getCheckInTime()); |
|
|
|
if (holidayPo.getHoliday() == 1) {//如果是节假日 |
|
|
|
po.setDescStatus(ATTENDANCE_STATUS_OVERTIME);//加班 |
|
|
|
return po; |
|
|
|
} |
|
|
|
logger.info("deptId:{}", po.getDeptId()); |
|
|
|
logger.info("ext:start-end:{} end-start:{}" ,ext.getOnDutyHourEnd(), ext.getOffDutyHourStart()); |
|
|
|
if (po.getCheckInTime() == null && po.getCheckOutTime()== null) {//正常不会走这个流程 |
|
|
|
po.setDescStatus(ATTENDANCE_STATUS_ABSENCE); |
|
|
|
return po; |
|
|
|
} else if (po.getCheckInTime() != null && po.getCheckOutTime()== null) {//第一次打卡 |
|
|
|
if (MyDateUtils.formatDate(po.getCheckInTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(ext.getOnDutyHourEnd()) > 0) {//识别时间比考勤上班打卡最晚时间更晚 |
|
|
|
po.setDescStatus(ATTENDANCE_STATUS_LATER_AND_EARLY); |
|
|
|
} else { |
|
|
|
po.setDescStatus(ATTENDANCE_STATUS_LEAVE_EARLY); |
|
|
|
} |
|
|
|
return po; |
|
|
|
} else if (po.getCheckInTime() != null && po.getCheckOutTime() != null) {//之后的打卡 |
|
|
|
if (MyDateUtils.formatDate(po.getCheckInTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(ext.getOffDutyHourStart()) < 0) {//识别时间比考勤下班打卡最早时间更早 |
|
|
|
if (MyDateUtils.formatDate(po.getCheckInTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(ext.getOnDutyHourEnd()) > 0) {//识别时间比考勤上班打卡最晚时间更晚 |
|
|
|
po.setDescStatus(ATTENDANCE_STATUS_LATER_AND_EARLY); |
|
|
|
} else {//正常上班打卡 |
|
|
|
po.setDescStatus(ATTENDANCE_STATUS_LEAVE_EARLY); |
|
|
|
} |
|
|
|
} else {//正常下班打卡 |
|
|
|
if (MyDateUtils.formatDate(po.getCheckInTime(), MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(ext.getOnDutyHourEnd()) > 0) {//识别时间比考勤上班打卡最晚时间更晚 |
|
|
|
po.setDescStatus(ATTENDANCE_STATUS_BE_LATER); |
|
|
|
} else {//正常上班打卡 |
|
|
|
po.setDescStatus(ATTENDANCE_STATUS_NORMAL); |
|
|
|
} |
|
|
|
} |
|
|
|
Date cin = po.getCheckInTime(); |
|
|
|
Date cout = po.getCheckOutTime(); |
|
|
|
Integer diffMin = MyDateUtils.dateDiffMin(cin, cout); |
|
|
|
po.setWorkDuration(diffMin); |
|
|
|
} |
|
|
|
return po; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void updateOrInsertAttendance(DmRecognizedRecordsPo checkRecords) { |
|
|
|
if (ObjectUtil.isNull(checkRecords.getUserId())) { |
|
|
|
return ; |
|
|
|
@@ -160,57 +218,11 @@ public class DmStaffServiceImpl extends BaseServiceImpl<DmStaffQuery, DmStaffDto |
|
|
|
} |
|
|
|
|
|
|
|
DmEmpAttendancePo empAttendance = dmEmpAttendanceMapper.findByEmpAndDate(checkTimeDateStr, userId); |
|
|
|
SysDeptExt ext = sysDeptExtMapper.selectWorkTimeByDeptId(emp.getDeptId()); |
|
|
|
logger.info("deptId:{}", emp.getDeptId()); |
|
|
|
logger.info("ext:start-end:{} end-start:{}" ,ext.getOnDutyHourEnd(), ext.getOffDutyHourStart()); |
|
|
|
|
|
|
|
if (null != empAttendance) { |
|
|
|
|
|
|
|
if (null == empAttendance.getCheckInTime()) { |
|
|
|
empAttendance.setCheckInTime(checkTime); |
|
|
|
} else { |
|
|
|
empAttendance.setCheckOutTime(checkTime); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (null!=empAttendance.getCheckInTime() && null != empAttendance.getCheckOutTime()) { |
|
|
|
Date cin = empAttendance.getCheckInTime(); |
|
|
|
Date cout = empAttendance.getCheckOutTime(); |
|
|
|
Integer diffMin = MyDateUtils.dateDiffMin(cin, cout); |
|
|
|
empAttendance.setWorkDuration(diffMin); |
|
|
|
} |
|
|
|
|
|
|
|
if (MyDateUtils.formatDate(checkTime, MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(ext.getOffDutyHourStart()) < 0) { |
|
|
|
if (ATTENDANCE_STATUS_NORMAL == empAttendance.getDescStatus()) { |
|
|
|
empAttendance.setDescStatus(ATTENDANCE_STATUS_LEAVE_EARLY); |
|
|
|
} else if (ATTENDANCE_STATUS_BE_LATER == empAttendance.getDescStatus()){ |
|
|
|
empAttendance.setDescStatus(ATTENDANCE_STATUS_LATER_AND_EARLY); |
|
|
|
} |
|
|
|
} else { //如果修改考勤时间,则对应修改考勤状态 |
|
|
|
if (ATTENDANCE_STATUS_LATER_AND_EARLY == empAttendance.getDescStatus()) { |
|
|
|
empAttendance.setDescStatus(ATTENDANCE_STATUS_BE_LATER); |
|
|
|
} else if (ATTENDANCE_STATUS_LEAVE_EARLY == empAttendance.getDescStatus()){ |
|
|
|
empAttendance.setDescStatus(ATTENDANCE_STATUS_NORMAL); |
|
|
|
} |
|
|
|
} |
|
|
|
if (null != empAttendance) {//基本都会走这个控制段 |
|
|
|
empAttendance = judgeAttendanceDescStatus(empAttendance, checkTime); |
|
|
|
dmEmpAttendanceMapper.updateById(empAttendance); |
|
|
|
|
|
|
|
} else { |
|
|
|
DmEmpAttendancePo ea = new DmEmpAttendancePo(); |
|
|
|
Date checkDate = checkTime; |
|
|
|
ea.setCheckInTime(checkDate); |
|
|
|
DmHolidayPo holidayPo = holidayService.isHoliday(checkDate); |
|
|
|
if (MyDateUtils.formatDate(checkDate, MyDateUtils.DEFAULT_TIME_PATTERN).compareTo(ext.getOnDutyHourEnd()) > 0) {//识别时间比考勤上班打卡最晚时间更晚 |
|
|
|
ea.setDescStatus(ATTENDANCE_STATUS_BE_LATER); // 迟到 |
|
|
|
if (holidayPo.getHoliday() == 1) { |
|
|
|
ea.setDescStatus(ATTENDANCE_STATUS_OVERTIME); |
|
|
|
} |
|
|
|
} else {//识别时间比考勤上班打卡最晚时间早 |
|
|
|
if (holidayPo.getHoliday() == 1) { |
|
|
|
ea.setDescStatus(ATTENDANCE_STATUS_OVERTIME); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
DmEmpAttendancePo ea = judgeAttendanceDescStatus(empAttendance, checkTime); |
|
|
|
ea.setDateStr(MyDateUtils.formatDate(new Date(), MyDateUtils.DEFAULT_DATE_PATTERN)); |
|
|
|
ea.setUserId(userId); |
|
|
|
ea.setUserName(emp.getUserName()); |
|
|
|
@@ -220,7 +232,6 @@ public class DmStaffServiceImpl extends BaseServiceImpl<DmStaffQuery, DmStaffDto |
|
|
|
ea.setCreateTime(MyDateUtils.currentDateToLocalDateTime()); |
|
|
|
ea.setUpdateTime(MyDateUtils.currentDateToLocalDateTime()); |
|
|
|
dmEmpAttendanceService.updRedisCount(); |
|
|
|
|
|
|
|
dmEmpAttendanceMapper.insert(ea); |
|
|
|
} |
|
|
|
} |