BAOLH
2025-05-12 7696c9d65300ea76afb126b1ae3e19d047c72393
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java
@@ -114,18 +114,17 @@
                attendance.setStartClockResults((ObjectUtil.isNotEmpty(attendance.getStartClockResults()) && attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_NORMAL)) ? attendance.getStartClockResults() : Constant.ATTENDANCE_STATE_WAITFOR);
                attendance.setEndClockResults((ObjectUtil.isNotEmpty(attendance.getEndClockResults()) && attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_NORMAL)) ? attendance.getEndClockResults() : Constant.ATTENDANCE_STATE_WAITFOR);
                // 考勤日期类是否是周末、节假日、工作日
                if (sysConfigHoliday == null && (calAttendDay.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calAttendDay.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)) {
                if (sysConfigHoliday == null) {
                    if (calAttendDay.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calAttendDay.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
                    // 考勤记录:日期类型-双休
                    attendance.setDateType(Constant.DATE_TYPE_WEEKEND);
                } else if (sysConfigHoliday != null && sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)) {
                    // 考勤记录:日期类型-节假日
                    attendance.setDateType(Constant.DATE_TYPE_LEGAL_HOLIDAYS);
                } else if (sysConfigHoliday != null && sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS)) {
                    // 考勤记录:日期类型-法定节假日
                    attendance.setDateType(Constant.DATE_TYPE_HOLIDAYS);
                } else {
                    // 考勤记录:日期类型-工作日
                    attendance.setDateType(Constant.DATE_TYPE_WEEKDAY);
                    }
                } else {
                    // 考勤记录:日期类型-节假日
                    attendance.setDateType(sysConfigHoliday.getDateType());
                }
                // 时间格式化
                DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
@@ -185,11 +184,11 @@
                // 考勤记录:根据用户和日期查询
                Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), strAttendDate);
                Boolean isHoliday = false;
                if (calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS) || attendance.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS)) {
                if (calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS) || attendance.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS) || attendance.getDateType().equals(Constant.DATE_TYPE_WEEKEND)) {
                    isHoliday = true;
                }
                // 如果是周六或者周日或节假日,打卡状态为等待的话,就改状态为休息(返回结果为空数组的情况下)
                if (ObjectUtils.isNotEmpty(attendance) && (calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS) || attendance.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS))) {
                if (ObjectUtils.isNotEmpty(attendance) && isHoliday) {
                    // 开始打卡结果
                    if (attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR) || attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_LACK_OF_TIME)) {
                        attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST);
@@ -207,6 +206,7 @@
                List<String> userWeComList = new ArrayList<>();
                userWeComList.add(user.getWeComId());
                System.out.println("开始查询用户" + user.getWeComId() + "的" + strAttendDate + "考勤记录");
                try {
                // 企微打卡数据
                List<WxCpCheckinData> weComRecordResultList = wxCpService.getOaService().getCheckinData(1, sdf.parse(strAttendDate + " 00:00:00"), sdf.parse(strAttendDate + " 23:59:59"), userWeComList);
                // 遍历企微打卡数据
@@ -249,6 +249,11 @@
                    getMornOrNoon(user,attendance,attendDate,attendance.getRosteringWorkStartTime(),attendance.getRosteringWorkEndTime(), true);
//                    attendance = updateRecord(user, attendance, true, attendDate);
                    attendanceRepository.save(attendance);
                    }
                } catch (WxErrorException wxe) {
                    System.out.println(wxe.getMessage());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } catch (WxErrorException wxErrorException) {
@@ -305,11 +310,11 @@
                // 考勤记录:根据用户和日期查询
                Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), strAttendDate);
                Boolean isHoliday = false;
                if (calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS) || attendance.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS)) {
                if (calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS) || attendance.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS) || attendance.getDateType().equals(Constant.DATE_TYPE_WEEKEND)) {
                    isHoliday = true;
                }
                // 如果是周六或者周日或节假日,打卡状态为等待的话,就改状态为休息(oapiDingTalkRecordResultList为空的情况下)
                if (ObjectUtils.isNotEmpty(attendance) && (calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS) || attendance.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS))) {
                if (ObjectUtils.isNotEmpty(attendance) && isHoliday) {
                    // 开始打卡结果
                    if (attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR)) {
                        attendance.setStartClockResults(Constant.ATTENDANCE_STATE_REST);
@@ -327,6 +332,7 @@
                List<String> userWeComList = new ArrayList<>();
                userWeComList.add(user.getWeComId());
                System.out.println("开始查询用户" + user.getWeComId() + "的" + strAttendDate + "考勤记录");
                try {
                // 企微打卡数据
                List<WxCpCheckinData> weComRecordResultList = wxCpService.getOaService().getCheckinData(1, sdf.parse(strAttendDate + " 00:00:00"), sdf.parse(strAttendDate + " 23:59:59"), userWeComList);
                // 遍历企微打卡数据
@@ -370,6 +376,11 @@
//                    attendance = updateRecord(user, attendance, false, attendDate);
                    attendanceRepository.save(attendance);
                }
                } catch (WxErrorException wxe) {
                    System.out.println(wxe.getMessage());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } catch (WxErrorException wxErrorException) {
            wxErrorException.printStackTrace();