| | |
| | | // 获取企业微信Token |
| | | wxCpService.getAccessToken(); |
| | | |
| | | // 获取参数日期类 |
| | | Calendar calAttendDate = Calendar.getInstance(); |
| | | // 日期格式化 |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // 参数日期 |
| | | String strAttendDate = ""; |
| | | // 参数日期 TODO:0731修改 企微设置打卡时段为跨天的(当天4:00:00至次日03:59:59) |
| | | String startAttendDate = ""; |
| | | String endAttendDate = ""; |
| | | // 参数日期不为null(考勤按钮调用) |
| | | if (ObjectUtils.isNotEmpty(attendDate)) { |
| | | // 参数日期 |
| | | strAttendDate = attendDate; |
| | | startAttendDate = attendDate; |
| | | } else { |
| | | // 参数日期 |
| | | strAttendDate = df.format(new Date()); |
| | | startAttendDate = df.format(new Date()); |
| | | } |
| | | // 获取参数日期类 |
| | | Calendar calAttendDate = Calendar.getInstance(); |
| | | calAttendDate.setTime(Timestamp.valueOf(strAttendDate + " 00:00:00")); |
| | | // 参数日期 |
| | | calAttendDate.setTime(df.parse(startAttendDate)); |
| | | calAttendDate.add(Calendar.DATE, 1); |
| | | endAttendDate = df.format(calAttendDate.getTime()); |
| | | // 参数日期类 |
| | | calAttendDate.setTime(Timestamp.valueOf(startAttendDate + " 00:00:00")); |
| | | // 用户列表 |
| | | List<User> userList; |
| | | // 获取企业微信考勤白名单 |
| | |
| | | // 遍历用户列表 |
| | | for (User user : userList) { |
| | | // 考勤记录:根据用户和日期查询 |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), strAttendDate); |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), startAttendDate); |
| | | 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) || attendance.getDateType().equals(Constant.DATE_TYPE_WEEKEND)) { |
| | | isHoliday = true; |
| | |
| | | // 企业微信ID |
| | | List<String> userWeComList = new ArrayList<>(); |
| | | userWeComList.add(user.getWeComId()); |
| | | System.out.println("开始查询用户" + user.getWeComId() + "的" + strAttendDate + "考勤记录"); |
| | | System.out.println("开始查询用户" + user.getWeComId() + "的" + startAttendDate + "考勤记录"); |
| | | try { |
| | | // 企微打卡数据 |
| | | List<WxCpCheckinData> weComRecordResultList = wxCpService.getOaService().getCheckinData(1, sdf.parse(strAttendDate + " 00:00:00"), sdf.parse(strAttendDate + " 23:59:59"), userWeComList); |
| | | // 企微打卡数据 TODO:0731修改 企微设置打卡时段为跨天的(当天4:00:00至次日03:59:59) |
| | | List<WxCpCheckinData> weComRecordResultList = wxCpService.getOaService().getCheckinData(1, sdf.parse(startAttendDate + " 04:00:00"), sdf.parse(endAttendDate + " 03:59:59"), userWeComList); |
| | | // 遍历企微打卡数据 |
| | | for (WxCpCheckinData weComRecordResult : weComRecordResultList) { |
| | | // 无打卡记录 |
| | |
| | | // 早打卡 |
| | | // TODO:补充上班补卡记录 |
| | | if (ObjectUtils.isEmpty(attendance.getActualWorkStartTime()) && !isHoliday && (attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR) || attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_LACK_OF_TIME))) { |
| | | cardDatetimeSupplement(attendance.getUserId(), strAttendDate, Constant.CARD_REPLACEMENT_DIFFERENTIATION_GOON, attendance); |
| | | cardDatetimeSupplement(attendance.getUserId(), startAttendDate, Constant.CARD_REPLACEMENT_DIFFERENTIATION_GOON, attendance); |
| | | } |
| | | if ("上班打卡".equals(weComRecordResult.getCheckinType())) { |
| | | // 调用验证状态方法 |
| | |
| | | // 晚打卡 |
| | | // TODO:补充下班补卡记录 |
| | | if (ObjectUtils.isEmpty(attendance.getActualWorkEndTime()) && !isHoliday && (attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR) || attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_LACK_OF_TIME))) { |
| | | cardDatetimeSupplement(attendance.getUserId(), strAttendDate, Constant.CARD_REPLACEMENT_DIFFERENTIATION_GOOFF, attendance); |
| | | cardDatetimeSupplement(attendance.getUserId(), startAttendDate, Constant.CARD_REPLACEMENT_DIFFERENTIATION_GOOFF, attendance); |
| | | } |
| | | if ("下班打卡".equals(weComRecordResult.getCheckinType())) { |
| | | // 调用验证状态方法 |
| | |
| | | // 日期格式化 |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // 参数日期 |
| | | String strAttendDate = ""; |
| | | // 参数日期 TODO:0731修改 企微设置打卡时段为跨天的(当天4:00:00至次日03:59:59) |
| | | String startAttendDate = ""; |
| | | String endAttendDate = ""; |
| | | // 参数日期不为null(考勤按钮调用) |
| | | if (ObjectUtils.isNotEmpty(attendDate)) { |
| | | // 参数日期 |
| | | strAttendDate = attendDate; |
| | | startAttendDate = attendDate; |
| | | } else { |
| | | // 参数日期类 |
| | | calAttendDate.add(Calendar.DATE, -1); |
| | | // 参数日期 |
| | | strAttendDate = df.format(calAttendDate.getTime()); |
| | | startAttendDate = df.format(calAttendDate.getTime()); |
| | | } |
| | | // 参数日期 |
| | | calAttendDate.setTime(df.parse(startAttendDate)); |
| | | calAttendDate.add(Calendar.DATE, 1); |
| | | endAttendDate = df.format(calAttendDate.getTime()); |
| | | // 参数日期类 |
| | | calAttendDate.setTime(Timestamp.valueOf(strAttendDate + " 00:00:00")); |
| | | calAttendDate.setTime(Timestamp.valueOf(startAttendDate + " 00:00:00")); |
| | | // 用户列表 |
| | | List<User> userList; |
| | | // 获取企业微信考勤白名单 |
| | |
| | | // 遍历用户列表 |
| | | for (User user : userList) { |
| | | // 考勤记录:根据用户和日期查询 |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), strAttendDate); |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), startAttendDate); |
| | | 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) || attendance.getDateType().equals(Constant.DATE_TYPE_WEEKEND)) { |
| | | isHoliday = true; |
| | |
| | | // 企业微信ID |
| | | List<String> userWeComList = new ArrayList<>(); |
| | | userWeComList.add(user.getWeComId()); |
| | | System.out.println("开始查询用户" + user.getWeComId() + "的" + strAttendDate + "考勤记录"); |
| | | System.out.println("开始查询用户" + user.getWeComId() + "的" + startAttendDate + "考勤记录"); |
| | | try { |
| | | // 企微打卡数据 |
| | | List<WxCpCheckinData> weComRecordResultList = wxCpService.getOaService().getCheckinData(1, sdf.parse(strAttendDate + " 00:00:00"), sdf.parse(strAttendDate + " 23:59:59"), userWeComList); |
| | | // 企微打卡数据 TODO:0731修改 企微设置打卡时段为跨天的(当天4:00:00至次日03:59:59) |
| | | List<WxCpCheckinData> weComRecordResultList = wxCpService.getOaService().getCheckinData(1, sdf.parse(startAttendDate + " 04:00:00"), sdf.parse(endAttendDate + " 03:59:59"), userWeComList); |
| | | // 遍历企微打卡数据 |
| | | for (WxCpCheckinData weComRecordResult : weComRecordResultList) { |
| | | // 无打卡记录 |
| | |
| | | // 早打卡 |
| | | // TODO:补充上班补卡记录 |
| | | if (ObjectUtils.isEmpty(attendance.getActualWorkStartTime()) && !isHoliday && (attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR) || attendance.getStartClockResults().equals(Constant.ATTENDANCE_STATE_LACK_OF_TIME))) { |
| | | cardDatetimeSupplement(attendance.getUserId(), strAttendDate, Constant.CARD_REPLACEMENT_DIFFERENTIATION_GOON, attendance); |
| | | cardDatetimeSupplement(attendance.getUserId(), startAttendDate, Constant.CARD_REPLACEMENT_DIFFERENTIATION_GOON, attendance); |
| | | } |
| | | if ("上班打卡".equals(weComRecordResult.getCheckinType())) { |
| | | // 调用验证状态方法 |
| | |
| | | // 晚打卡 |
| | | // TODO:补充下班补卡记录 |
| | | if (ObjectUtils.isEmpty(attendance.getActualWorkEndTime()) && !isHoliday && (attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_WAITFOR) || attendance.getEndClockResults().equals(Constant.ATTENDANCE_STATE_LACK_OF_TIME))) { |
| | | cardDatetimeSupplement(attendance.getUserId(), strAttendDate, Constant.CARD_REPLACEMENT_DIFFERENTIATION_GOOFF, attendance); |
| | | cardDatetimeSupplement(attendance.getUserId(), startAttendDate, Constant.CARD_REPLACEMENT_DIFFERENTIATION_GOOFF, attendance); |
| | | } |
| | | if ("下班打卡".equals(weComRecordResult.getCheckinType())) { |
| | | // 调用验证状态方法 |