| | |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.attendance.vo.HrmAttendanceMyStatusRespVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.attendance.vo.HrmAttendanceRecordPageReqVO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.attendance.HrmAttendanceRecordDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.attendance.HrmAttendanceRuleDO; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public HrmAttendanceMyStatusRespVO getMyStatus(Long userId) { |
| | | // 1. 员工不存在时返回 null,由前端提示未关联员工,避免打卡页加载直接报错 |
| | | HrmEmployeeDO employee = employeeService.getEmployee(userId); |
| | | if (employee == null) { |
| | | return null; |
| | | } |
| | | LocalDate today = LocalDate.now(); |
| | | // 2. 查询今日考勤记录与考勤规则 |
| | | HrmAttendanceRecordDO record = attendanceRecordMapper.selectByUserIdAndDate(userId, today); |
| | | HrmAttendanceRuleDO rule = attendanceRuleService.getAttendanceRuleByDeptId(employee.getDeptId()); |
| | | boolean workDay = attendanceHolidayService.isWorkDay(today); |
| | | boolean clockInDone = record != null && record.getClockInTime() != null; |
| | | boolean clockOutDone = record != null && record.getClockOutTime() != null; |
| | | |
| | | // 3. 组装今日打卡状态 |
| | | HrmAttendanceMyStatusRespVO respVO = new HrmAttendanceMyStatusRespVO(); |
| | | respVO.setDate(today); |
| | | respVO.setWorkDay(workDay); |
| | | respVO.setEmployeeId(employee.getId()); |
| | | respVO.setUserName(employee.getName()); |
| | | respVO.setDeptId(employee.getDeptId()); |
| | | if (rule != null) { |
| | | respVO.setRuleName(rule.getName()); |
| | | respVO.setWorkStartTime(rule.getWorkStartTime()); |
| | | respVO.setWorkEndTime(rule.getWorkEndTime()); |
| | | } |
| | | if (record != null) { |
| | | respVO.setRecordId(record.getId()); |
| | | respVO.setClockInTime(record.getClockInTime()); |
| | | respVO.setClockOutTime(record.getClockOutTime()); |
| | | respVO.setClockInType(record.getClockInType()); |
| | | respVO.setClockOutType(record.getClockOutType()); |
| | | respVO.setWorkHours(record.getWorkHours()); |
| | | respVO.setOvertimeHours(record.getOvertimeHours()); |
| | | respVO.setLocation(record.getLocation()); |
| | | respVO.setDataSource(record.getDataSource()); |
| | | } |
| | | respVO.setClockInDone(clockInDone); |
| | | respVO.setClockOutDone(clockOutDone); |
| | | // 非工作日不可打卡,与打卡接口的校验保持一致 |
| | | respVO.setCanClockIn(workDay && !clockInDone); |
| | | respVO.setCanClockOut(workDay && !clockOutDone); |
| | | return respVO; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void supplementClockIn(HrmAttendanceExceptionDO exception) { |
| | | // 仅处理补卡类型 |