zss
11 小时以前 20699d8881c88cff9ad9d531bdecf3b6e1e7e22c
src/main/java/com/ruoyi/staff/service/impl/PersonalAttendanceRecordsServiceImpl.java
@@ -71,6 +71,7 @@
        /*查询员工信息*/
        QueryWrapper<StaffOnJob> staffQueryWrapper = new QueryWrapper<>();
        staffQueryWrapper.eq("staff_no", SecurityUtils.getUsername());
        staffQueryWrapper.eq("staff_state", 1);//在职
        StaffOnJob staffOnJob = staffOnJobMapper.selectOne(staffQueryWrapper);
        if (staffOnJob == null) {
            throw new BaseException("当前用户没有对应的员工信息");
@@ -99,23 +100,12 @@
            throw new BaseException(String.format("打卡失败:您当前位置距离考勤点%.2f米,超出允许范围(%s米)", actualDistance, allowedRadius));
        }
        /*判断打卡时间*/
        LocalTime   endAt = locationConfig.getEndAt(); //下班时间
        // 获取考勤下班时间点
        int standardHour = endAt.getHour();
        int standardMinute = endAt.getMinute();
        // 当前时间
        int actualHour = currentDateTime.getHour();
        int actualMinute = currentDateTime.getMinute();
        // 判断打卡时间是否晚于当前时间
        if (actualHour > standardHour || (actualHour == standardHour && actualMinute > standardMinute)) {
            throw new BaseException(String.format("打卡失败:打卡时间不能晚于下班时间(%02d:%02d)", standardHour, standardMinute));
        }
        // 根据员工ID和当前日期查询打卡记录
        QueryWrapper<PersonalAttendanceRecords> attendanceQueryWrapper = new QueryWrapper<>();
        attendanceQueryWrapper.eq("staff_on_job_id", staffOnJob.getId())
                .eq("date", currentDate);
        PersonalAttendanceRecords attendanceRecord = personalAttendanceRecordsMapper.selectOne(attendanceQueryWrapper);
        // 根据字典设置的考勤时间判断迟到早退
        // 根据考勤时间判断迟到早退
        if (attendanceRecord == null) {
            // 不存在打卡记录,创建新记录
            PersonalAttendanceRecords personalAttendanceRecords = new PersonalAttendanceRecords();
@@ -176,6 +166,8 @@
                        return 3; // 迟到早退
                    }
                    return 2; // 早退
                }else if (attendanceRecord.getStatus() == 1) {
                    return 1; // 下班打卡正常但是上班迟到
                }
            }
            return 0; // 正常
@@ -192,6 +184,7 @@
        if (!admin) {
            QueryWrapper<StaffOnJob> staffQueryWrapper = new QueryWrapper<>();
            staffQueryWrapper.eq("staff_no", SecurityUtils.getUsername());
            staffQueryWrapper.eq("staff_state", 1);//在职
            StaffOnJob staffOnJob = staffOnJobMapper.selectOne(staffQueryWrapper);
            if (staffOnJob == null) {
                return new Page<>(page.getCurrent(), page.getSize(), 0);
@@ -210,10 +203,11 @@
        // 首先根据用户ID查询员工信息
        QueryWrapper<StaffOnJob> staffQueryWrapper = new QueryWrapper<>();
        staffQueryWrapper.eq("staff_no", SecurityUtils.getUsername());
        staffQueryWrapper.eq("staff_state", 1);//在职
        StaffOnJob staffOnJob = staffOnJobMapper.selectOne(staffQueryWrapper);
        if (staffOnJob == null) {
            return null; // 当前用户没有对应的员工信息
            throw new BaseException("当前用户没有对应的员工信息");
        }
        // 根据员工ID和当前日期查询打卡记录
@@ -253,6 +247,7 @@
        if (!admin) {
            QueryWrapper<StaffOnJob> staffQueryWrapper = new QueryWrapper<>();
            staffQueryWrapper.eq("staff_no", SecurityUtils.getUsername());
            staffQueryWrapper.eq("staff_state", 1);//在职
            StaffOnJob staffOnJob = staffOnJobMapper.selectOne(staffQueryWrapper);
            if (staffOnJob == null) {
                throw new ServiceException("没有员工信息,无法导出考勤记录");